/** * 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.resources.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.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.HEAD; 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.PUT; import retrofit2.http.Query; import retrofit2.http.Url; import retrofit2.Response; import rx.functions.Func1; import rx.Observable; /** * An instance of this class provides access to all the operations defined * in ResourceGroups. */ public class ResourceGroupsInner { /** The Retrofit service to perform REST calls. */ private ResourceGroupsService service; /** The service client containing this operation class. */ private ResourceManagementClientImpl client; /** * Initializes an instance of ResourceGroupsInner. * * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ public ResourceGroupsInner(Retrofit retrofit, ResourceManagementClientImpl client) { this.service = retrofit.create(ResourceGroupsService.class); this.client = client; } /** * The interface defining all the services for ResourceGroups to be * used by Retrofit to perform actually REST calls. */ interface ResourceGroupsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.resources.ResourceGroups listByResourceGroup" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources") Observable<Response<ResponseBody>> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$expand") String expand, @Query("$top") Integer top, @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.resources.ResourceGroups checkExistence" }) @HEAD("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") Observable<Response<Void>> checkExistence(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @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.resources.ResourceGroups createOrUpdate" }) @PUT("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") Observable<Response<ResponseBody>> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Body ResourceGroupInner 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.resources.ResourceGroups delete" }) @HTTP(path = "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", method = "DELETE", hasBody = true) Observable<Response<ResponseBody>> delete(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @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.resources.ResourceGroups beginDelete" }) @HTTP(path = "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", method = "DELETE", hasBody = true) Observable<Response<ResponseBody>> beginDelete(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @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.resources.ResourceGroups get" }) @GET("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") Observable<Response<ResponseBody>> get(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @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.resources.ResourceGroups patch" }) @PATCH("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}") Observable<Response<ResponseBody>> patch(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Body ResourceGroupInner 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.resources.ResourceGroups exportTemplate" }) @POST("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate") Observable<Response<ResponseBody>> exportTemplate(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Body ExportTemplateRequestInner 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.resources.ResourceGroups list" }) @GET("subscriptions/{subscriptionId}/resourcegroups") Observable<Response<ResponseBody>> list(@Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @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.resources.ResourceGroups listByResourceGroupNext" }) @GET Observable<Response<ResponseBody>> listByResourceGroupNext(@Url String nextUrl, @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.resources.ResourceGroups listNext" }) @GET Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @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<GenericResourceInner> object if successful. */ public PagedList<GenericResourceInner> listByResourceGroup(final String resourceGroupName) { ServiceResponse<Page<GenericResourceInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList<GenericResourceInner>(response.body()) { @Override public Page<GenericResourceInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources 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<List<GenericResourceInner>> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback<GenericResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listByResourceGroupSinglePageAsync(resourceGroupName), new Func1<String, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<Page<GenericResourceInner>> listByResourceGroupAsync(final String resourceGroupName) { return listByResourceGroupWithServiceResponseAsync(resourceGroupName) .map(new Func1<ServiceResponse<Page<GenericResourceInner>>, Page<GenericResourceInner>>() { @Override public Page<GenericResourceInner> call(ServiceResponse<Page<GenericResourceInner>> response) { return response.body(); } }); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { return listByResourceGroupSinglePageAsync(resourceGroupName) .concatMap(new Func1<ServiceResponse<Page<GenericResourceInner>>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(ServiceResponse<Page<GenericResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<GenericResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupSinglePageAsync(final String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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; final String expand = null; final Integer top = null; return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), filter, expand, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<GenericResourceInner>> result = listByResourceGroupDelegate(response); return Observable.just(new ServiceResponse<Page<GenericResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @param filter The filter to apply on the operation. * @param expand The $expand query parameter * @param top The number of results to return. If null is passed, returns all resources. * @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<GenericResourceInner> object if successful. */ public PagedList<GenericResourceInner> listByResourceGroup(final String resourceGroupName, final String filter, final String expand, final Integer top) { ServiceResponse<Page<GenericResourceInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName, filter, expand, top).toBlocking().single(); return new PagedList<GenericResourceInner>(response.body()) { @Override public Page<GenericResourceInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @param filter The filter to apply on the operation. * @param expand The $expand query parameter * @param top The number of results to return. If null is passed, returns all resources. * @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<List<GenericResourceInner>> listByResourceGroupAsync(final String resourceGroupName, final String filter, final String expand, final Integer top, final ListOperationCallback<GenericResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listByResourceGroupSinglePageAsync(resourceGroupName, filter, expand, top), new Func1<String, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @param filter The filter to apply on the operation. * @param expand The $expand query parameter * @param top The number of results to return. If null is passed, returns all resources. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<Page<GenericResourceInner>> listByResourceGroupAsync(final String resourceGroupName, final String filter, final String expand, final Integer top) { return listByResourceGroupWithServiceResponseAsync(resourceGroupName, filter, expand, top) .map(new Func1<ServiceResponse<Page<GenericResourceInner>>, Page<GenericResourceInner>>() { @Override public Page<GenericResourceInner> call(ServiceResponse<Page<GenericResourceInner>> response) { return response.body(); } }); } /** * Get all the resources for a resource group. * * @param resourceGroupName The resource group with the resources to get. * @param filter The filter to apply on the operation. * @param expand The $expand query parameter * @param top The number of results to return. If null is passed, returns all resources. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName, final String filter, final String expand, final Integer top) { return listByResourceGroupSinglePageAsync(resourceGroupName, filter, expand, top) .concatMap(new Func1<ServiceResponse<Page<GenericResourceInner>>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(ServiceResponse<Page<GenericResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Get all the resources for a resource group. * ServiceResponse<PageImpl<GenericResourceInner>> * @param resourceGroupName The resource group with the resources to get. ServiceResponse<PageImpl<GenericResourceInner>> * @param filter The filter to apply on the operation. ServiceResponse<PageImpl<GenericResourceInner>> * @param expand The $expand query parameter ServiceResponse<PageImpl<GenericResourceInner>> * @param top The number of results to return. If null is passed, returns all resources. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<GenericResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupSinglePageAsync(final String resourceGroupName, final String filter, final String expand, final Integer top) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), filter, expand, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<GenericResourceInner>> result = listByResourceGroupDelegate(response); return Observable.just(new ServiceResponse<Page<GenericResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<GenericResourceInner>> listByResourceGroupDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<GenericResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<GenericResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Checks whether a resource group exists. * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. * @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 boolean object if successful. */ public boolean checkExistence(String resourceGroupName) { return checkExistenceWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); } /** * Checks whether a resource group exists. * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. * @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<Boolean> checkExistenceAsync(String resourceGroupName, final ServiceCallback<Boolean> serviceCallback) { return ServiceFuture.fromResponse(checkExistenceWithServiceResponseAsync(resourceGroupName), serviceCallback); } /** * Checks whether a resource group exists. * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the Boolean object */ public Observable<Boolean> checkExistenceAsync(String resourceGroupName) { return checkExistenceWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<Boolean>, Boolean>() { @Override public Boolean call(ServiceResponse<Boolean> response) { return response.body(); } }); } /** * Checks whether a resource group exists. * * @param resourceGroupName The name of the resource group to check. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the Boolean object */ public Observable<ServiceResponse<Boolean>> checkExistenceWithServiceResponseAsync(String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.checkExistence(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<Void>, Observable<ServiceResponse<Boolean>>>() { @Override public Observable<ServiceResponse<Boolean>> call(Response<Void> response) { try { ServiceResponse<Boolean> clientResponse = checkExistenceDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<Boolean> checkExistenceDelegate(Response<Void> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<Boolean, CloudException>newInstance(this.client.serializerAdapter()) .register(204, new TypeToken<Void>() { }.getType()) .register(404, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .buildEmpty(response); } /** * Creates a resource group. * * @param resourceGroupName The name of the resource group to create or update. * @param parameters Parameters supplied to the create or update a resource group. * @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 ResourceGroupInner object if successful. */ public ResourceGroupInner createOrUpdate(String resourceGroupName, ResourceGroupInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().body(); } /** * Creates a resource group. * * @param resourceGroupName The name of the resource group to create or update. * @param parameters Parameters supplied to the create or update a resource group. * @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<ResourceGroupInner> createOrUpdateAsync(String resourceGroupName, ResourceGroupInner parameters, final ServiceCallback<ResourceGroupInner> serviceCallback) { return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, parameters), serviceCallback); } /** * Creates a resource group. * * @param resourceGroupName The name of the resource group to create or update. * @param parameters Parameters supplied to the create or update a resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ResourceGroupInner> createOrUpdateAsync(String resourceGroupName, ResourceGroupInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, parameters).map(new Func1<ServiceResponse<ResourceGroupInner>, ResourceGroupInner>() { @Override public ResourceGroupInner call(ServiceResponse<ResourceGroupInner> response) { return response.body(); } }); } /** * Creates a resource group. * * @param resourceGroupName The name of the resource group to create or update. * @param parameters Parameters supplied to the create or update a resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ServiceResponse<ResourceGroupInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, ResourceGroupInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.createOrUpdate(resourceGroupName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceGroupInner>>>() { @Override public Observable<ServiceResponse<ResourceGroupInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ResourceGroupInner> clientResponse = createOrUpdateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ResourceGroupInner> createOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ResourceGroupInner, CloudException>newInstance(this.client.serializerAdapter()) .register(201, new TypeToken<ResourceGroupInner>() { }.getType()) .register(200, new TypeToken<ResourceGroupInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @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 */ public void delete(String resourceGroupName) { deleteWithServiceResponseAsync(resourceGroupName).toBlocking().last().body(); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @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<Void> deleteAsync(String resourceGroupName, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName), serviceCallback); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<Void> deleteAsync(String resourceGroupName) { return deleteWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); } if (this.client.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); } Observable<Response<ResponseBody>> observable = service.delete(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType()); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @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 */ public void beginDelete(String resourceGroupName) { beginDeleteWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @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<Void> beginDeleteAsync(String resourceGroupName, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(beginDeleteWithServiceResponseAsync(resourceGroupName), serviceCallback); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<Void> beginDeleteAsync(String resourceGroupName) { return beginDeleteWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> beginDeleteWithServiceResponseAsync(String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.beginDelete(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() { @Override public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) { try { ServiceResponse<Void> clientResponse = beginDeleteDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<Void> beginDeleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter()) .register(202, new TypeToken<Void>() { }.getType()) .register(200, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets a resource group. * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. * @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 ResourceGroupInner object if successful. */ public ResourceGroupInner get(String resourceGroupName) { return getWithServiceResponseAsync(resourceGroupName).toBlocking().single().body(); } /** * Gets a resource group. * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. * @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<ResourceGroupInner> getAsync(String resourceGroupName, final ServiceCallback<ResourceGroupInner> serviceCallback) { return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName), serviceCallback); } /** * Gets a resource group. * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ResourceGroupInner> getAsync(String resourceGroupName) { return getWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<ResourceGroupInner>, ResourceGroupInner>() { @Override public ResourceGroupInner call(ServiceResponse<ResourceGroupInner> response) { return response.body(); } }); } /** * Gets a resource group. * * @param resourceGroupName The name of the resource group to get. The name is case insensitive. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ServiceResponse<ResourceGroupInner>> getWithServiceResponseAsync(String resourceGroupName) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceGroupInner>>>() { @Override public Observable<ServiceResponse<ResourceGroupInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ResourceGroupInner> clientResponse = getDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ResourceGroupInner> getDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ResourceGroupInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<ResourceGroupInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Updates a resource group. * Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. * * @param resourceGroupName The name of the resource group to update. The name is case insensitive. * @param parameters Parameters supplied to update a resource group. * @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 ResourceGroupInner object if successful. */ public ResourceGroupInner patch(String resourceGroupName, ResourceGroupInner parameters) { return patchWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().body(); } /** * Updates a resource group. * Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. * * @param resourceGroupName The name of the resource group to update. The name is case insensitive. * @param parameters Parameters supplied to update a resource group. * @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<ResourceGroupInner> patchAsync(String resourceGroupName, ResourceGroupInner parameters, final ServiceCallback<ResourceGroupInner> serviceCallback) { return ServiceFuture.fromResponse(patchWithServiceResponseAsync(resourceGroupName, parameters), serviceCallback); } /** * Updates a resource group. * Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. * * @param resourceGroupName The name of the resource group to update. The name is case insensitive. * @param parameters Parameters supplied to update a resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ResourceGroupInner> patchAsync(String resourceGroupName, ResourceGroupInner parameters) { return patchWithServiceResponseAsync(resourceGroupName, parameters).map(new Func1<ServiceResponse<ResourceGroupInner>, ResourceGroupInner>() { @Override public ResourceGroupInner call(ServiceResponse<ResourceGroupInner> response) { return response.body(); } }); } /** * Updates a resource group. * Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. * * @param resourceGroupName The name of the resource group to update. The name is case insensitive. * @param parameters Parameters supplied to update a resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupInner object */ public Observable<ServiceResponse<ResourceGroupInner>> patchWithServiceResponseAsync(String resourceGroupName, ResourceGroupInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.patch(resourceGroupName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceGroupInner>>>() { @Override public Observable<ServiceResponse<ResourceGroupInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ResourceGroupInner> clientResponse = patchDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ResourceGroupInner> patchDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ResourceGroupInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<ResourceGroupInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Captures the specified resource group as a template. * * @param resourceGroupName The name of the resource group to export as a template. * @param parameters Parameters for exporting the template. * @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 ResourceGroupExportResultInner object if successful. */ public ResourceGroupExportResultInner exportTemplate(String resourceGroupName, ExportTemplateRequestInner parameters) { return exportTemplateWithServiceResponseAsync(resourceGroupName, parameters).toBlocking().single().body(); } /** * Captures the specified resource group as a template. * * @param resourceGroupName The name of the resource group to export as a template. * @param parameters Parameters for exporting the template. * @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<ResourceGroupExportResultInner> exportTemplateAsync(String resourceGroupName, ExportTemplateRequestInner parameters, final ServiceCallback<ResourceGroupExportResultInner> serviceCallback) { return ServiceFuture.fromResponse(exportTemplateWithServiceResponseAsync(resourceGroupName, parameters), serviceCallback); } /** * Captures the specified resource group as a template. * * @param resourceGroupName The name of the resource group to export as a template. * @param parameters Parameters for exporting the template. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupExportResultInner object */ public Observable<ResourceGroupExportResultInner> exportTemplateAsync(String resourceGroupName, ExportTemplateRequestInner parameters) { return exportTemplateWithServiceResponseAsync(resourceGroupName, parameters).map(new Func1<ServiceResponse<ResourceGroupExportResultInner>, ResourceGroupExportResultInner>() { @Override public ResourceGroupExportResultInner call(ServiceResponse<ResourceGroupExportResultInner> response) { return response.body(); } }); } /** * Captures the specified resource group as a template. * * @param resourceGroupName The name of the resource group to export as a template. * @param parameters Parameters for exporting the template. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the ResourceGroupExportResultInner object */ public Observable<ServiceResponse<ResourceGroupExportResultInner>> exportTemplateWithServiceResponseAsync(String resourceGroupName, ExportTemplateRequestInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.exportTemplate(resourceGroupName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceGroupExportResultInner>>>() { @Override public Observable<ServiceResponse<ResourceGroupExportResultInner>> call(Response<ResponseBody> response) { try { ServiceResponse<ResourceGroupExportResultInner> clientResponse = exportTemplateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<ResourceGroupExportResultInner> exportTemplateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<ResourceGroupExportResultInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<ResourceGroupExportResultInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets all the resource groups for a subscription. * * @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<ResourceGroupInner> object if successful. */ public PagedList<ResourceGroupInner> list() { ServiceResponse<Page<ResourceGroupInner>> response = listSinglePageAsync().toBlocking().single(); return new PagedList<ResourceGroupInner>(response.body()) { @Override public Page<ResourceGroupInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Gets all the resource groups for a subscription. * * @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<List<ResourceGroupInner>> listAsync(final ListOperationCallback<ResourceGroupInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listSinglePageAsync(), new Func1<String, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Gets all the resource groups for a subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<Page<ResourceGroupInner>> listAsync() { return listWithServiceResponseAsync() .map(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Page<ResourceGroupInner>>() { @Override public Page<ResourceGroupInner> call(ServiceResponse<Page<ResourceGroupInner>> response) { return response.body(); } }); } /** * Gets all the resource groups for a subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listWithServiceResponseAsync() { return listSinglePageAsync() .concatMap(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(ServiceResponse<Page<ResourceGroupInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Gets all the resource groups for a subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<ResourceGroupInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listSinglePageAsync() { if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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; final Integer top = null; return service.list(this.client.subscriptionId(), filter, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<ResourceGroupInner>> result = listDelegate(response); return Observable.just(new ServiceResponse<Page<ResourceGroupInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } /** * Gets all the resource groups for a subscription. * * @param filter The filter to apply on the operation. * @param top The number of results to return. If null is passed, returns all resource groups. * @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<ResourceGroupInner> object if successful. */ public PagedList<ResourceGroupInner> list(final String filter, final Integer top) { ServiceResponse<Page<ResourceGroupInner>> response = listSinglePageAsync(filter, top).toBlocking().single(); return new PagedList<ResourceGroupInner>(response.body()) { @Override public Page<ResourceGroupInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Gets all the resource groups for a subscription. * * @param filter The filter to apply on the operation. * @param top The number of results to return. If null is passed, returns all resource groups. * @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<List<ResourceGroupInner>> listAsync(final String filter, final Integer top, final ListOperationCallback<ResourceGroupInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listSinglePageAsync(filter, top), new Func1<String, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Gets all the resource groups for a subscription. * * @param filter The filter to apply on the operation. * @param top The number of results to return. If null is passed, returns all resource groups. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<Page<ResourceGroupInner>> listAsync(final String filter, final Integer top) { return listWithServiceResponseAsync(filter, top) .map(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Page<ResourceGroupInner>>() { @Override public Page<ResourceGroupInner> call(ServiceResponse<Page<ResourceGroupInner>> response) { return response.body(); } }); } /** * Gets all the resource groups for a subscription. * * @param filter The filter to apply on the operation. * @param top The number of results to return. If null is passed, returns all resource groups. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listWithServiceResponseAsync(final String filter, final Integer top) { return listSinglePageAsync(filter, top) .concatMap(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(ServiceResponse<Page<ResourceGroupInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Gets all the resource groups for a subscription. * ServiceResponse<PageImpl<ResourceGroupInner>> * @param filter The filter to apply on the operation. ServiceResponse<PageImpl<ResourceGroupInner>> * @param top The number of results to return. If null is passed, returns all resource groups. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<ResourceGroupInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listSinglePageAsync(final String filter, final Integer top) { if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.subscriptionId(), filter, top, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<ResourceGroupInner>> result = listDelegate(response); return Observable.just(new ServiceResponse<Page<ResourceGroupInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<ResourceGroupInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<ResourceGroupInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<ResourceGroupInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Get all the resources for a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PagedList<GenericResourceInner> object if successful. */ public PagedList<GenericResourceInner> listByResourceGroupNext(final String nextPageLink) { ServiceResponse<Page<GenericResourceInner>> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList<GenericResourceInner>(response.body()) { @Override public Page<GenericResourceInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Get all the resources for a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceFuture the ServiceFuture object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ public ServiceFuture<List<GenericResourceInner>> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture<List<GenericResourceInner>> serviceFuture, final ListOperationCallback<GenericResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listByResourceGroupNextSinglePageAsync(nextPageLink), new Func1<String, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Get all the resources for a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<Page<GenericResourceInner>> listByResourceGroupNextAsync(final String nextPageLink) { return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) .map(new Func1<ServiceResponse<Page<GenericResourceInner>>, Page<GenericResourceInner>>() { @Override public Page<GenericResourceInner> call(ServiceResponse<Page<GenericResourceInner>> response) { return response.body(); } }); } /** * Get all the resources for a resource group. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<GenericResourceInner> object */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<GenericResourceInner>>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(ServiceResponse<Page<GenericResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Get all the resources for a resource group. * ServiceResponse<PageImpl<GenericResourceInner>> * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<GenericResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<GenericResourceInner>>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } String nextUrl = String.format("%s", nextPageLink); return service.listByResourceGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<GenericResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<GenericResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<GenericResourceInner>> result = listByResourceGroupNextDelegate(response); return Observable.just(new ServiceResponse<Page<GenericResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<GenericResourceInner>> listByResourceGroupNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<GenericResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<GenericResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets all the resource groups for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PagedList<ResourceGroupInner> object if successful. */ public PagedList<ResourceGroupInner> listNext(final String nextPageLink) { ServiceResponse<Page<ResourceGroupInner>> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList<ResourceGroupInner>(response.body()) { @Override public Page<ResourceGroupInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Gets all the resource groups for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceFuture the ServiceFuture object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ public ServiceFuture<List<ResourceGroupInner>> listNextAsync(final String nextPageLink, final ServiceFuture<List<ResourceGroupInner>> serviceFuture, final ListOperationCallback<ResourceGroupInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listNextSinglePageAsync(nextPageLink), new Func1<String, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Gets all the resource groups for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<Page<ResourceGroupInner>> listNextAsync(final String nextPageLink) { return listNextWithServiceResponseAsync(nextPageLink) .map(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Page<ResourceGroupInner>>() { @Override public Page<ResourceGroupInner> call(ServiceResponse<Page<ResourceGroupInner>> response) { return response.body(); } }); } /** * Gets all the resource groups for a subscription. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<ResourceGroupInner> object */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listNextWithServiceResponseAsync(final String nextPageLink) { return listNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(ServiceResponse<Page<ResourceGroupInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Gets all the resource groups for a subscription. * ServiceResponse<PageImpl<ResourceGroupInner>> * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<ResourceGroupInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<ResourceGroupInner>>> listNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } String nextUrl = String.format("%s", nextPageLink); return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ResourceGroupInner>>>>() { @Override public Observable<ServiceResponse<Page<ResourceGroupInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<ResourceGroupInner>> result = listNextDelegate(response); return Observable.just(new ServiceResponse<Page<ResourceGroupInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<ResourceGroupInner>> listNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<ResourceGroupInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<ResourceGroupInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } }