/** * 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.redis.implementation; import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsGet; import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsListing; import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureServiceFuture; import com.microsoft.azure.CloudException; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.management.redis.RedisKeyType; import com.microsoft.azure.management.redis.RedisRegenerateKeyParameters; 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.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 Redis. */ public class RedisInner implements InnerSupportsGet<RedisResourceInner>, InnerSupportsDelete<Void>, InnerSupportsListing<RedisResourceInner> { /** The Retrofit service to perform REST calls. */ private RedisService service; /** The service client containing this operation class. */ private RedisManagementClientImpl client; /** * Initializes an instance of RedisInner. * * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ public RedisInner(Retrofit retrofit, RedisManagementClientImpl client) { this.service = retrofit.create(RedisService.class); this.client = client; } /** * The interface defining all the services for Redis to be * used by Retrofit to perform actually REST calls. */ interface RedisService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.redis.Redis create" }) @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") Observable<Response<ResponseBody>> create(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisCreateParametersInner 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.redis.Redis beginCreate" }) @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") Observable<Response<ResponseBody>> beginCreate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisCreateParametersInner 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.redis.Redis update" }) @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") Observable<Response<ResponseBody>> update(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisUpdateParametersInner 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.redis.Redis delete" }) @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", method = "DELETE", hasBody = true) Observable<Response<ResponseBody>> delete(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @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.redis.Redis beginDelete" }) @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}", method = "DELETE", hasBody = true) Observable<Response<ResponseBody>> beginDelete(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @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.redis.Redis getByResourceGroup" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}") Observable<Response<ResponseBody>> getByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @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.redis.Redis listByResourceGroup" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/") Observable<Response<ResponseBody>> listByResourceGroup(@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.redis.Redis list" }) @GET("subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/") Observable<Response<ResponseBody>> list(@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.redis.Redis listKeys" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listKeys") Observable<Response<ResponseBody>> listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @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.redis.Redis regenerateKey" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/regenerateKey") Observable<Response<ResponseBody>> regenerateKey(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body RedisRegenerateKeyParameters parameters, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.redis.Redis forceReboot" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/forceReboot") Observable<Response<ResponseBody>> forceReboot(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body RedisRebootParametersInner 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.redis.Redis importData" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/import") Observable<Response<ResponseBody>> importData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner 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.redis.Redis beginImportData" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/import") Observable<Response<ResponseBody>> beginImportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ImportRDBParametersInner 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.redis.Redis exportData" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/export") Observable<Response<ResponseBody>> exportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner 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.redis.Redis beginExportData" }) @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/export") Observable<Response<ResponseBody>> beginExportData(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("subscriptionId") String subscriptionId, @Body ExportRDBParametersInner 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.redis.Redis 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.redis.Redis listNext" }) @GET Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis 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 RedisResourceInner object if successful. */ public RedisResourceInner create(String resourceGroupName, String name, RedisCreateParametersInner parameters) { return createWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().body(); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis 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<RedisResourceInner> createAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters, final ServiceCallback<RedisResourceInner> serviceCallback) { return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<RedisResourceInner> createAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { return createWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<RedisResourceInner>, RedisResourceInner>() { @Override public RedisResourceInner call(ServiceResponse<RedisResourceInner> response) { return response.body(); } }); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<ServiceResponse<RedisResourceInner>> createWithServiceResponseAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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); Observable<Response<ResponseBody>> observable = service.create(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<RedisResourceInner>() { }.getType()); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis 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 RedisResourceInner object if successful. */ public RedisResourceInner beginCreate(String resourceGroupName, String name, RedisCreateParametersInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().body(); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis 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<RedisResourceInner> beginCreateAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters, final ServiceCallback<RedisResourceInner> serviceCallback) { return ServiceFuture.fromResponse(beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<RedisResourceInner> beginCreateAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { return beginCreateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<RedisResourceInner>, RedisResourceInner>() { @Override public RedisResourceInner call(ServiceResponse<RedisResourceInner> response) { return response.body(); } }); } /** * Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Create Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<ServiceResponse<RedisResourceInner>> beginCreateWithServiceResponseAsync(String resourceGroupName, String name, RedisCreateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.beginCreate(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisResourceInner>>>() { @Override public Observable<ServiceResponse<RedisResourceInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisResourceInner> clientResponse = beginCreateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisResourceInner> beginCreateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisResourceInner, CloudException>newInstance(this.client.serializerAdapter()) .register(201, new TypeToken<RedisResourceInner>() { }.getType()) .register(200, new TypeToken<RedisResourceInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Update Redis 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 RedisResourceInner object if successful. */ public RedisResourceInner update(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { return updateWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().body(); } /** * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Update Redis 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<RedisResourceInner> updateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters, final ServiceCallback<RedisResourceInner> serviceCallback) { return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Update Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<RedisResourceInner> updateAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { return updateWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<RedisResourceInner>, RedisResourceInner>() { @Override public RedisResourceInner call(ServiceResponse<RedisResourceInner> response) { return response.body(); } }); } /** * Update an existing Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters supplied to the Update Redis operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<ServiceResponse<RedisResourceInner>> updateWithServiceResponseAsync(String resourceGroupName, String name, RedisUpdateParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.update(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisResourceInner>>>() { @Override public Observable<ServiceResponse<RedisResourceInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisResourceInner> clientResponse = updateDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisResourceInner> updateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisResourceInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<RedisResourceInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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, String name) { deleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().last().body(); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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, String name, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<Void> deleteAsync(String resourceGroupName, String name) { return deleteWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType()); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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, String name) { beginDeleteWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body(); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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, String name, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(beginDeleteWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<Void> beginDeleteAsync(String resourceGroupName, String name) { return beginDeleteWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Deletes a Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> beginDeleteWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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, name, 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(200, new TypeToken<Void>() { }.getType()) .register(204, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets a Redis cache (resource description). * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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 RedisResourceInner object if successful. */ public RedisResourceInner getByResourceGroup(String resourceGroupName, String name) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body(); } /** * Gets a Redis cache (resource description). * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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<RedisResourceInner> getByResourceGroupAsync(String resourceGroupName, String name, final ServiceCallback<RedisResourceInner> serviceCallback) { return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } /** * Gets a Redis cache (resource description). * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<RedisResourceInner> getByResourceGroupAsync(String resourceGroupName, String name) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<RedisResourceInner>, RedisResourceInner>() { @Override public RedisResourceInner call(ServiceResponse<RedisResourceInner> response) { return response.body(); } }); } /** * Gets a Redis cache (resource description). * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisResourceInner object */ public Observable<ServiceResponse<RedisResourceInner>> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.getByResourceGroup(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisResourceInner>>>() { @Override public Observable<ServiceResponse<RedisResourceInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisResourceInner> clientResponse = getByResourceGroupDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisResourceInner> getByResourceGroupDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisResourceInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<RedisResourceInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Lists all Redis caches in a resource group. * * @param resourceGroupName The name of the 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 PagedList<RedisResourceInner> object if successful. */ public PagedList<RedisResourceInner> listByResourceGroup(final String resourceGroupName) { ServiceResponse<Page<RedisResourceInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single(); return new PagedList<RedisResourceInner>(response.body()) { @Override public Page<RedisResourceInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Lists all Redis caches in a resource group. * * @param resourceGroupName The name of the 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<List<RedisResourceInner>> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback<RedisResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listByResourceGroupSinglePageAsync(resourceGroupName), new Func1<String, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Lists all Redis caches in a resource group. * * @param resourceGroupName The name of the resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<RedisResourceInner> object */ public Observable<Page<RedisResourceInner>> listByResourceGroupAsync(final String resourceGroupName) { return listByResourceGroupWithServiceResponseAsync(resourceGroupName) .map(new Func1<ServiceResponse<Page<RedisResourceInner>>, Page<RedisResourceInner>>() { @Override public Page<RedisResourceInner> call(ServiceResponse<Page<RedisResourceInner>> response) { return response.body(); } }); } /** * Lists all Redis caches in a resource group. * * @param resourceGroupName The name of the resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<RedisResourceInner> object */ public Observable<ServiceResponse<Page<RedisResourceInner>>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) { return listByResourceGroupSinglePageAsync(resourceGroupName) .concatMap(new Func1<ServiceResponse<Page<RedisResourceInner>>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(ServiceResponse<Page<RedisResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Lists all Redis caches in a resource group. * ServiceResponse<PageImpl<RedisResourceInner>> * @param resourceGroupName The name of the resource group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<RedisResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<RedisResourceInner>>> 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."); } return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<RedisResourceInner>> result = listByResourceGroupDelegate(response); return Observable.just(new ServiceResponse<Page<RedisResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<RedisResourceInner>> listByResourceGroupDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<RedisResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<RedisResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets all Redis caches in the specified 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<RedisResourceInner> object if successful. */ public PagedList<RedisResourceInner> list() { ServiceResponse<Page<RedisResourceInner>> response = listSinglePageAsync().toBlocking().single(); return new PagedList<RedisResourceInner>(response.body()) { @Override public Page<RedisResourceInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Gets all Redis caches in the specified 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<RedisResourceInner>> listAsync(final ListOperationCallback<RedisResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listSinglePageAsync(), new Func1<String, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Gets all Redis caches in the specified subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<RedisResourceInner> object */ public Observable<Page<RedisResourceInner>> listAsync() { return listWithServiceResponseAsync() .map(new Func1<ServiceResponse<Page<RedisResourceInner>>, Page<RedisResourceInner>>() { @Override public Page<RedisResourceInner> call(ServiceResponse<Page<RedisResourceInner>> response) { return response.body(); } }); } /** * Gets all Redis caches in the specified subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PagedList<RedisResourceInner> object */ public Observable<ServiceResponse<Page<RedisResourceInner>>> listWithServiceResponseAsync() { return listSinglePageAsync() .concatMap(new Func1<ServiceResponse<Page<RedisResourceInner>>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(ServiceResponse<Page<RedisResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Gets all Redis caches in the specified subscription. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<RedisResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<RedisResourceInner>>> 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."); } return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<RedisResourceInner>> result = listDelegate(response); return Observable.just(new ServiceResponse<Page<RedisResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<RedisResourceInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<RedisResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<RedisResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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 RedisAccessKeysInner object if successful. */ public RedisAccessKeysInner listKeys(String resourceGroupName, String name) { return listKeysWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body(); } /** * Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @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<RedisAccessKeysInner> listKeysAsync(String resourceGroupName, String name, final ServiceCallback<RedisAccessKeysInner> serviceCallback) { return ServiceFuture.fromResponse(listKeysWithServiceResponseAsync(resourceGroupName, name), serviceCallback); } /** * Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisAccessKeysInner object */ public Observable<RedisAccessKeysInner> listKeysAsync(String resourceGroupName, String name) { return listKeysWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<RedisAccessKeysInner>, RedisAccessKeysInner>() { @Override public RedisAccessKeysInner call(ServiceResponse<RedisAccessKeysInner> response) { return response.body(); } }); } /** * Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisAccessKeysInner object */ public Observable<ServiceResponse<RedisAccessKeysInner>> listKeysWithServiceResponseAsync(String resourceGroupName, String name) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.listKeys(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisAccessKeysInner>>>() { @Override public Observable<ServiceResponse<RedisAccessKeysInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisAccessKeysInner> clientResponse = listKeysDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisAccessKeysInner> listKeysDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisAccessKeysInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<RedisAccessKeysInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param keyType The Redis access key to regenerate. Possible values include: 'Primary', 'Secondary' * @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 RedisAccessKeysInner object if successful. */ public RedisAccessKeysInner regenerateKey(String resourceGroupName, String name, RedisKeyType keyType) { return regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType).toBlocking().single().body(); } /** * Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param keyType The Redis access key to regenerate. Possible values include: 'Primary', 'Secondary' * @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<RedisAccessKeysInner> regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType, final ServiceCallback<RedisAccessKeysInner> serviceCallback) { return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType), serviceCallback); } /** * Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param keyType The Redis access key to regenerate. Possible values include: 'Primary', 'Secondary' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisAccessKeysInner object */ public Observable<RedisAccessKeysInner> regenerateKeyAsync(String resourceGroupName, String name, RedisKeyType keyType) { return regenerateKeyWithServiceResponseAsync(resourceGroupName, name, keyType).map(new Func1<ServiceResponse<RedisAccessKeysInner>, RedisAccessKeysInner>() { @Override public RedisAccessKeysInner call(ServiceResponse<RedisAccessKeysInner> response) { return response.body(); } }); } /** * Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param keyType The Redis access key to regenerate. Possible values include: 'Primary', 'Secondary' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisAccessKeysInner object */ public Observable<ServiceResponse<RedisAccessKeysInner>> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String name, RedisKeyType keyType) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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."); } if (keyType == null) { throw new IllegalArgumentException("Parameter keyType is required and cannot be null."); } RedisRegenerateKeyParameters parameters = new RedisRegenerateKeyParameters(); parameters.withKeyType(keyType); return service.regenerateKey(resourceGroupName, name, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisAccessKeysInner>>>() { @Override public Observable<ServiceResponse<RedisAccessKeysInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisAccessKeysInner> clientResponse = regenerateKeyDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisAccessKeysInner> regenerateKeyDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisAccessKeysInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<RedisAccessKeysInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Specifies which Redis node(s) to reboot. * @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 RedisForceRebootResponseInner object if successful. */ public RedisForceRebootResponseInner forceReboot(String resourceGroupName, String name, RedisRebootParametersInner parameters) { return forceRebootWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().body(); } /** * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Specifies which Redis node(s) to reboot. * @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<RedisForceRebootResponseInner> forceRebootAsync(String resourceGroupName, String name, RedisRebootParametersInner parameters, final ServiceCallback<RedisForceRebootResponseInner> serviceCallback) { return ServiceFuture.fromResponse(forceRebootWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Specifies which Redis node(s) to reboot. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisForceRebootResponseInner object */ public Observable<RedisForceRebootResponseInner> forceRebootAsync(String resourceGroupName, String name, RedisRebootParametersInner parameters) { return forceRebootWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<RedisForceRebootResponseInner>, RedisForceRebootResponseInner>() { @Override public RedisForceRebootResponseInner call(ServiceResponse<RedisForceRebootResponseInner> response) { return response.body(); } }); } /** * Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Specifies which Redis node(s) to reboot. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the RedisForceRebootResponseInner object */ public Observable<ServiceResponse<RedisForceRebootResponseInner>> forceRebootWithServiceResponseAsync(String resourceGroupName, String name, RedisRebootParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.forceReboot(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<RedisForceRebootResponseInner>>>() { @Override public Observable<ServiceResponse<RedisForceRebootResponseInner>> call(Response<ResponseBody> response) { try { ServiceResponse<RedisForceRebootResponseInner> clientResponse = forceRebootDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<RedisForceRebootResponseInner> forceRebootDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<RedisForceRebootResponseInner, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<RedisForceRebootResponseInner>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import 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 */ public void importData(String resourceGroupName, String name, ImportRDBParametersInner parameters) { importDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().body(); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import 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<Void> importDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(importDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<Void> importDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { return importDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<ServiceResponse<Void>> importDataWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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); Observable<Response<ResponseBody>> observable = service.importData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType()); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import 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 */ public void beginImportData(String resourceGroupName, String name, ImportRDBParametersInner parameters) { beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().body(); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import 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<Void> beginImportDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<Void> beginImportDataAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { return beginImportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Import data into Redis cache. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis import operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> beginImportDataWithServiceResponseAsync(String resourceGroupName, String name, ImportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.beginImportData(resourceGroupName, name, this.client.subscriptionId(), parameters, 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 = beginImportDataDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<Void> beginImportDataDelegate(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()) .register(204, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export 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 */ public void exportData(String resourceGroupName, String name, ExportRDBParametersInner parameters) { exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().body(); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export 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<Void> exportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(exportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<Void> exportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { return exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable for the request */ public Observable<ServiceResponse<Void>> exportDataWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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); Observable<Response<ResponseBody>> observable = service.exportData(resourceGroupName, name, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType()); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export 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 */ public void beginExportData(String resourceGroupName, String name, ExportRDBParametersInner parameters) { beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().single().body(); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export 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<Void> beginExportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters, final ServiceCallback<Void> serviceCallback) { return ServiceFuture.fromResponse(beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters), serviceCallback); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<Void> beginExportDataAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { return beginExportDataWithServiceResponseAsync(resourceGroupName, name, parameters).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) { return response.body(); } }); } /** * Export data from the redis cache to blobs in a container. * * @param resourceGroupName The name of the resource group. * @param name The name of the Redis cache. * @param parameters Parameters for Redis export operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> beginExportDataWithServiceResponseAsync(String resourceGroupName, String name, ExportRDBParametersInner parameters) { if (resourceGroupName == null) { throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); } if (name == null) { throw new IllegalArgumentException("Parameter name 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.beginExportData(resourceGroupName, name, this.client.subscriptionId(), parameters, 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 = beginExportDataDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<Void> beginExportDataDelegate(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()) .register(204, new TypeToken<Void>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Lists all Redis caches in 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<RedisResourceInner> object if successful. */ public PagedList<RedisResourceInner> listByResourceGroupNext(final String nextPageLink) { ServiceResponse<Page<RedisResourceInner>> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList<RedisResourceInner>(response.body()) { @Override public Page<RedisResourceInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Lists all Redis caches in 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<RedisResourceInner>> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture<List<RedisResourceInner>> serviceFuture, final ListOperationCallback<RedisResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listByResourceGroupNextSinglePageAsync(nextPageLink), new Func1<String, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Lists all Redis caches in 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<RedisResourceInner> object */ public Observable<Page<RedisResourceInner>> listByResourceGroupNextAsync(final String nextPageLink) { return listByResourceGroupNextWithServiceResponseAsync(nextPageLink) .map(new Func1<ServiceResponse<Page<RedisResourceInner>>, Page<RedisResourceInner>>() { @Override public Page<RedisResourceInner> call(ServiceResponse<Page<RedisResourceInner>> response) { return response.body(); } }); } /** * Lists all Redis caches in 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<RedisResourceInner> object */ public Observable<ServiceResponse<Page<RedisResourceInner>>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<RedisResourceInner>>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(ServiceResponse<Page<RedisResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Lists all Redis caches in a resource group. * ServiceResponse<PageImpl<RedisResourceInner>> * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<RedisResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<RedisResourceInner>>> 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<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<RedisResourceInner>> result = listByResourceGroupNextDelegate(response); return Observable.just(new ServiceResponse<Page<RedisResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<RedisResourceInner>> listByResourceGroupNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<RedisResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<RedisResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } /** * Gets all Redis caches in the specified 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<RedisResourceInner> object if successful. */ public PagedList<RedisResourceInner> listNext(final String nextPageLink) { ServiceResponse<Page<RedisResourceInner>> response = listNextSinglePageAsync(nextPageLink).toBlocking().single(); return new PagedList<RedisResourceInner>(response.body()) { @Override public Page<RedisResourceInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** * Gets all Redis caches in the specified 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<RedisResourceInner>> listNextAsync(final String nextPageLink, final ServiceFuture<List<RedisResourceInner>> serviceFuture, final ListOperationCallback<RedisResourceInner> serviceCallback) { return AzureServiceFuture.fromPageResponse( listNextSinglePageAsync(nextPageLink), new Func1<String, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(String nextPageLink) { return listNextSinglePageAsync(nextPageLink); } }, serviceCallback); } /** * Gets all Redis caches in the specified 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<RedisResourceInner> object */ public Observable<Page<RedisResourceInner>> listNextAsync(final String nextPageLink) { return listNextWithServiceResponseAsync(nextPageLink) .map(new Func1<ServiceResponse<Page<RedisResourceInner>>, Page<RedisResourceInner>>() { @Override public Page<RedisResourceInner> call(ServiceResponse<Page<RedisResourceInner>> response) { return response.body(); } }); } /** * Gets all Redis caches in the specified 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<RedisResourceInner> object */ public Observable<ServiceResponse<Page<RedisResourceInner>>> listNextWithServiceResponseAsync(final String nextPageLink) { return listNextSinglePageAsync(nextPageLink) .concatMap(new Func1<ServiceResponse<Page<RedisResourceInner>>, Observable<ServiceResponse<Page<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(ServiceResponse<Page<RedisResourceInner>> page) { String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink)); } }); } /** * Gets all Redis caches in the specified subscription. * ServiceResponse<PageImpl<RedisResourceInner>> * @param nextPageLink The NextLink from the previous successful call to List operation. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the PagedList<RedisResourceInner> object wrapped in {@link ServiceResponse} if successful. */ public Observable<ServiceResponse<Page<RedisResourceInner>>> 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<RedisResourceInner>>>>() { @Override public Observable<ServiceResponse<Page<RedisResourceInner>>> call(Response<ResponseBody> response) { try { ServiceResponse<PageImpl<RedisResourceInner>> result = listNextDelegate(response); return Observable.just(new ServiceResponse<Page<RedisResourceInner>>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } } }); } private ServiceResponse<PageImpl<RedisResourceInner>> listNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().<PageImpl<RedisResourceInner>, CloudException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken<PageImpl<RedisResourceInner>>() { }.getType()) .registerError(CloudException.class) .build(response); } }