diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/MessagingRegionsProperties.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/MessagingRegionsProperties.java new file mode 100644 index 00000000000..f81fbd568bb --- /dev/null +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/MessagingRegionsProperties.java @@ -0,0 +1,47 @@ +/** + * 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.eventhub; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MessagingRegionsProperties model. + */ +public class MessagingRegionsProperties { + /** + * Region code. + */ + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /** + * Full name of the region. + */ + @JsonProperty(value = "fullName", access = JsonProperty.Access.WRITE_ONLY) + private String fullName; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Get the fullName value. + * + * @return the fullName value + */ + public String fullName() { + return this.fullName; + } + +} diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ArmDisasterRecoveryInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ArmDisasterRecoveryInner.java index 65dd2d3c930..76a5d532adc 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ArmDisasterRecoveryInner.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ArmDisasterRecoveryInner.java @@ -12,12 +12,13 @@ import com.microsoft.azure.management.eventhub.RoleDisasterRecovery; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; /** * Single item in List or Get Alias(Disaster Recovery configuration) operation. */ @JsonFlatten -public class ArmDisasterRecoveryInner extends NestedResourceInner { +public class ArmDisasterRecoveryInner extends Resource { /** * Provisioning state of the Alias(Disaster Recovery configuration) - * possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/AuthorizationRuleInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/AuthorizationRuleInner.java index faf22fdb350..2ffe95ff6e4 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/AuthorizationRuleInner.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/AuthorizationRuleInner.java @@ -12,12 +12,13 @@ import com.microsoft.azure.management.eventhub.AccessRights; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; /** * Single item in a List or Get AuthorizationRule operation. */ @JsonFlatten -public class AuthorizationRuleInner extends NestedResourceInner { +public class AuthorizationRuleInner extends Resource { /** * The rights associated with the rule. */ diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ConsumerGroupInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ConsumerGroupInner.java index 9bee470ac67..54404c992d8 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ConsumerGroupInner.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/ConsumerGroupInner.java @@ -11,12 +11,13 @@ import org.joda.time.DateTime; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; /** * Single item in List or Get Consumer group operation. */ @JsonFlatten -public class ConsumerGroupInner extends NestedResourceInner { +public class ConsumerGroupInner extends Resource { /** * Exact time the message was created. */ diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EHNamespaceInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EHNamespaceInner.java index e8c5bba7938..fe9ac071069 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EHNamespaceInner.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EHNamespaceInner.java @@ -8,7 +8,6 @@ package com.microsoft.azure.management.eventhub.implementation; -import com.microsoft.azure.Resource; import com.microsoft.azure.management.eventhub.Sku; import org.joda.time.DateTime; import com.fasterxml.jackson.annotation.JsonProperty; @@ -18,7 +17,7 @@ * Single Namespace item in List or Get Operation. */ @JsonFlatten -public class EHNamespaceInner extends Resource { +public class EHNamespaceInner extends TrackedResourceInner { /** * Properties of sku resource. */ diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventHubManagementClientImpl.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventHubManagementClientImpl.java index 96670a46a4c..be2ea190251 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventHubManagementClientImpl.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventHubManagementClientImpl.java @@ -158,6 +158,19 @@ public NamespacesInner namespaces() { return this.namespaces; } + /** + * The MessagingPlansInner object to access its operations. + */ + private MessagingPlansInner messagingPlans; + + /** + * Gets the MessagingPlansInner object to access its operations. + * @return the MessagingPlansInner object. + */ + public MessagingPlansInner messagingPlans() { + return this.messagingPlans; + } + /** * The DisasterRecoveryConfigsInner object to access its operations. */ @@ -197,6 +210,19 @@ public ConsumerGroupsInner consumerGroups() { return this.consumerGroups; } + /** + * The RegionsInner object to access its operations. + */ + private RegionsInner regions; + + /** + * Gets the RegionsInner object to access its operations. + * @return the RegionsInner object. + */ + public RegionsInner regions() { + return this.regions; + } + /** * Initializes an instance of EventHubManagementClient client. * @@ -234,9 +260,11 @@ protected void initialize() { this.generateClientRequestId = true; this.operations = new OperationsInner(restClient().retrofit(), this); this.namespaces = new NamespacesInner(restClient().retrofit(), this); + this.messagingPlans = new MessagingPlansInner(restClient().retrofit(), this); this.disasterRecoveryConfigs = new DisasterRecoveryConfigsInner(restClient().retrofit(), this); this.eventHubs = new EventHubsInner(restClient().retrofit(), this); this.consumerGroups = new ConsumerGroupsInner(restClient().retrofit(), this); + this.regions = new RegionsInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this); } diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventhubInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventhubInner.java index 89202b6c439..488ccded263 100644 --- a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventhubInner.java +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/EventhubInner.java @@ -14,12 +14,13 @@ import com.microsoft.azure.management.eventhub.CaptureDescription; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; /** * Single item in List or Get Event Hub operation. */ @JsonFlatten -public class EventhubInner extends NestedResourceInner { +public class EventhubInner extends Resource { /** * Current number of shards on the Event Hub. */ diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlanInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlanInner.java new file mode 100644 index 00000000000..8284b6ea469 --- /dev/null +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlanInner.java @@ -0,0 +1,113 @@ +/** + * 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.eventhub.implementation; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * Messaging. + */ +@JsonFlatten +public class MessagingPlanInner extends TrackedResourceInner { + /** + * Sku type. + */ + @JsonProperty(value = "properties.sku") + private Integer sku; + + /** + * Selected event hub unit. + */ + @JsonProperty(value = "properties.selectedEventHubUnit") + private Integer selectedEventHubUnit; + + /** + * The exact time the messaging plan was updated. + */ + @JsonProperty(value = "properties.updatedAt", access = JsonProperty.Access.WRITE_ONLY) + private DateTime updatedAt; + + /** + * revision number. + */ + @JsonProperty(value = "properties.revision") + private Long revision; + + /** + * Get the sku value. + * + * @return the sku value + */ + public Integer sku() { + return this.sku; + } + + /** + * Set the sku value. + * + * @param sku the sku value to set + * @return the MessagingPlanInner object itself. + */ + public MessagingPlanInner withSku(Integer sku) { + this.sku = sku; + return this; + } + + /** + * Get the selectedEventHubUnit value. + * + * @return the selectedEventHubUnit value + */ + public Integer selectedEventHubUnit() { + return this.selectedEventHubUnit; + } + + /** + * Set the selectedEventHubUnit value. + * + * @param selectedEventHubUnit the selectedEventHubUnit value to set + * @return the MessagingPlanInner object itself. + */ + public MessagingPlanInner withSelectedEventHubUnit(Integer selectedEventHubUnit) { + this.selectedEventHubUnit = selectedEventHubUnit; + return this; + } + + /** + * Get the updatedAt value. + * + * @return the updatedAt value + */ + public DateTime updatedAt() { + return this.updatedAt; + } + + /** + * Get the revision value. + * + * @return the revision value + */ + public Long revision() { + return this.revision; + } + + /** + * Set the revision value. + * + * @param revision the revision value to set + * @return the MessagingPlanInner object itself. + */ + public MessagingPlanInner withRevision(Long revision) { + this.revision = revision; + return this; + } + +} diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlansInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlansInner.java new file mode 100644 index 00000000000..dffff1f6d2f --- /dev/null +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingPlansInner.java @@ -0,0 +1,146 @@ +/** + * 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.eventhub.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MessagingPlans. + */ +public class MessagingPlansInner { + /** The Retrofit service to perform REST calls. */ + private MessagingPlansService service; + /** The service client containing this operation class. */ + private EventHubManagementClientImpl client; + + /** + * Initializes an instance of MessagingPlansInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MessagingPlansInner(Retrofit retrofit, EventHubManagementClientImpl client) { + this.service = retrofit.create(MessagingPlansService.class); + this.client = client; + } + + /** + * The interface defining all the services for MessagingPlans to be + * used by Retrofit to perform actually REST calls. + */ + interface MessagingPlansService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.eventhub.MessagingPlans get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/messagingplan") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("namespaceName") String namespaceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets a description for the specified namespace. + * + * @param resourceGroupName Name of the resource group within the azure subscription. + * @param namespaceName The Namespace name + * @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 MessagingPlanInner object if successful. + */ + public MessagingPlanInner get(String resourceGroupName, String namespaceName) { + return getWithServiceResponseAsync(resourceGroupName, namespaceName).toBlocking().single().body(); + } + + /** + * Gets a description for the specified namespace. + * + * @param resourceGroupName Name of the resource group within the azure subscription. + * @param namespaceName The Namespace name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String resourceGroupName, String namespaceName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, namespaceName), serviceCallback); + } + + /** + * Gets a description for the specified namespace. + * + * @param resourceGroupName Name of the resource group within the azure subscription. + * @param namespaceName The Namespace name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MessagingPlanInner object + */ + public Observable getAsync(String resourceGroupName, String namespaceName) { + return getWithServiceResponseAsync(resourceGroupName, namespaceName).map(new Func1, MessagingPlanInner>() { + @Override + public MessagingPlanInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets a description for the specified namespace. + * + * @param resourceGroupName Name of the resource group within the azure subscription. + * @param namespaceName The Namespace name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MessagingPlanInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String namespaceName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (namespaceName == null) { + throw new IllegalArgumentException("Parameter namespaceName 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, namespaceName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingRegionsInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingRegionsInner.java new file mode 100644 index 00000000000..de66ccf3167 --- /dev/null +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/MessagingRegionsInner.java @@ -0,0 +1,44 @@ +/** + * 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.eventhub.implementation; + +import com.microsoft.azure.management.eventhub.MessagingRegionsProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Messaging Region. + */ +public class MessagingRegionsInner extends TrackedResourceInner { + /** + * The properties property. + */ + @JsonProperty(value = "properties") + private MessagingRegionsProperties properties; + + /** + * Get the properties value. + * + * @return the properties value + */ + public MessagingRegionsProperties properties() { + return this.properties; + } + + /** + * Set the properties value. + * + * @param properties the properties value to set + * @return the MessagingRegionsInner object itself. + */ + public MessagingRegionsInner withProperties(MessagingRegionsProperties properties) { + this.properties = properties; + return this; + } + +} diff --git a/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/RegionsInner.java b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/RegionsInner.java new file mode 100644 index 00000000000..b992d14f9b6 --- /dev/null +++ b/azure-mgmt-eventhub/src/main/java/com/microsoft/azure/management/eventhub/implementation/RegionsInner.java @@ -0,0 +1,295 @@ +/** + * 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.eventhub.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.management.eventhub.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +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 Regions. + */ +public class RegionsInner { + /** The Retrofit service to perform REST calls. */ + private RegionsService service; + /** The service client containing this operation class. */ + private EventHubManagementClientImpl client; + + /** + * Initializes an instance of RegionsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public RegionsInner(Retrofit retrofit, EventHubManagementClientImpl client) { + this.service = retrofit.create(RegionsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Regions to be + * used by Retrofit to perform actually REST calls. + */ + interface RegionsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.eventhub.Regions listBySku" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.EventHub/sku/{sku}/regions") + Observable> listBySku(@Path("subscriptionId") String subscriptionId, @Path("sku") String sku, @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.eventhub.Regions listBySkuNext" }) + @GET + Observable> listBySkuNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the available Regions for a given sku. + * + * @param sku The sku type. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<MessagingRegionsInner> object if successful. + */ + public PagedList listBySku(final String sku) { + ServiceResponse> response = listBySkuSinglePageAsync(sku).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBySkuNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Gets the available Regions for a given sku. + * + * @param sku The sku type. + * @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> listBySkuAsync(final String sku, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBySkuSinglePageAsync(sku), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBySkuNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Gets the available Regions for a given sku. + * + * @param sku The sku type. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MessagingRegionsInner> object + */ + public Observable> listBySkuAsync(final String sku) { + return listBySkuWithServiceResponseAsync(sku) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Gets the available Regions for a given sku. + * + * @param sku The sku type. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<MessagingRegionsInner> object + */ + public Observable>> listBySkuWithServiceResponseAsync(final String sku) { + return listBySkuSinglePageAsync(sku) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listBySkuNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Gets the available Regions for a given sku. + * + ServiceResponse> * @param sku The sku type. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MessagingRegionsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBySkuSinglePageAsync(final String sku) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (sku == null) { + throw new IllegalArgumentException("Parameter sku 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.listBySku(this.client.subscriptionId(), sku, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBySkuDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBySkuDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Gets the available Regions for a given sku. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException 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<MessagingRegionsInner> object if successful. + */ + public PagedList listBySkuNext(final String nextPageLink) { + ServiceResponse> response = listBySkuNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listBySkuNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Gets the available Regions for a given sku. + * + * @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> listBySkuNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listBySkuNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listBySkuNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Gets the available Regions for a given sku. + * + * @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<MessagingRegionsInner> object + */ + public Observable> listBySkuNextAsync(final String nextPageLink) { + return listBySkuNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Gets the available Regions for a given sku. + * + * @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<MessagingRegionsInner> object + */ + public Observable>> listBySkuNextWithServiceResponseAsync(final String nextPageLink) { + return listBySkuNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.body().nextPageLink(); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(listBySkuNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Gets the available Regions for a given sku. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<MessagingRegionsInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listBySkuNextSinglePageAsync(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.listBySkuNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listBySkuNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listBySkuNextDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +}