From 2719e7172bcb309b42fef84c1fd845b2066bd0d8 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 27 Apr 2018 19:28:02 +0000 Subject: [PATCH 1/3] Generated from d7abeaa6ae57648be6ecde4bc11c226d9c85166c Improve redis Swagger. Documenting list all patchSchedules to fix #2968. Documenting the CheckNameAvailability.type property better to fix #2967. And use a realistic timespan value in PatchSchedule examples. --- .../azure/management/redis/DefaultName.java | 38 +++ .../CheckNameAvailabilityParametersInner.java | 13 +- .../implementation/PatchSchedulesInner.java | 247 ++++++++++++++++++ .../redis/implementation/RedisInner.java | 8 +- 4 files changed, 297 insertions(+), 9 deletions(-) create mode 100644 azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java new file mode 100644 index 00000000000..d63335b85de --- /dev/null +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java @@ -0,0 +1,38 @@ +/** + * 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; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for DefaultName. + */ +public final class DefaultName extends ExpandableStringEnum { + /** Static value Microsoft.Cache/redis for DefaultName. */ + public static final DefaultName MICROSOFT_CACHEREDIS = fromString("Microsoft.Cache/redis"); + + /** + * Creates or finds a DefaultName from its string representation. + * @param name a name to look for + * @return the corresponding DefaultName + */ + @JsonCreator + public static DefaultName fromString(String name) { + return fromString(name, DefaultName.class); + } + + /** + * @return known DefaultName values + */ + public static Collection values() { + return values(DefaultName.class); + } +} diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java index b671a52235c..60f9aed8209 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java @@ -8,10 +8,11 @@ package com.microsoft.azure.management.redis.implementation; +import com.microsoft.azure.management.redis.DefaultName; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Parameters body to pass for name availability check. + * Parameters body to pass for resource name availability check. */ public class CheckNameAvailabilityParametersInner { /** @@ -21,10 +22,12 @@ public class CheckNameAvailabilityParametersInner { private String name; /** - * Resource type. + * Resource type to check name availability of, e.g. + * 'Microsoft.Cache/redis'. Possible values include: + * 'Microsoft.Cache/redis'. */ @JsonProperty(value = "type") - private String type; + private DefaultName type; /** * Get the name value. @@ -51,7 +54,7 @@ public CheckNameAvailabilityParametersInner withName(String name) { * * @return the type value */ - public String type() { + public DefaultName type() { return this.type; } @@ -61,7 +64,7 @@ public String type() { * @param type the type value to set * @return the CheckNameAvailabilityParametersInner object itself. */ - public CheckNameAvailabilityParametersInner withType(String type) { + public CheckNameAvailabilityParametersInner withType(DefaultName type) { this.type = type; return this; } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java index 0e4d016ca0f..4885ffc79f1 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/PatchSchedulesInner.java @@ -11,7 +11,11 @@ import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; import retrofit2.Retrofit; import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceFuture; import com.microsoft.azure.CloudException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceResponse; @@ -27,6 +31,7 @@ import retrofit2.http.Path; import retrofit2.http.PUT; import retrofit2.http.Query; +import retrofit2.http.Url; import retrofit2.Response; import rx.functions.Func1; import rx.Observable; @@ -57,6 +62,10 @@ public PatchSchedulesInner(Retrofit retrofit, RedisManagementClientImpl client) * used by Retrofit to perform actually REST calls. */ interface PatchSchedulesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.redis.PatchSchedules listByRedisResource" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{cacheName}/patchSchedules") + Observable> listByRedisResource(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("cacheName") String cacheName, @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.PatchSchedules createOrUpdate" }) @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/{default}") Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("default") String defaultParameter, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body RedisPatchScheduleInner parameters, @Header("User-Agent") String userAgent); @@ -69,6 +78,133 @@ interface PatchSchedulesService { @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/patchSchedules/{default}") Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("name") String name, @Path("default") String defaultParameter, @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.PatchSchedules listByRedisResourceNext" }) + @GET + Observable> listByRedisResourceNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @param resourceGroupName The name of the resource group. + * @param cacheName 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 PagedList<RedisPatchScheduleInner> object if successful. + */ + public PagedList listByRedisResource(final String resourceGroupName, final String cacheName) { + ServiceResponse> response = listByRedisResourceSinglePageAsync(resourceGroupName, cacheName).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByRedisResourceNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @param resourceGroupName The name of the resource group. + * @param cacheName 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> listByRedisResourceAsync(final String resourceGroupName, final String cacheName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByRedisResourceSinglePageAsync(resourceGroupName, cacheName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByRedisResourceNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @param resourceGroupName The name of the resource group. + * @param cacheName The name of the Redis cache. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<RedisPatchScheduleInner> object + */ + public Observable> listByRedisResourceAsync(final String resourceGroupName, final String cacheName) { + return listByRedisResourceWithServiceResponseAsync(resourceGroupName, cacheName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @param resourceGroupName The name of the resource group. + * @param cacheName The name of the Redis cache. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PagedList<RedisPatchScheduleInner> object + */ + public Observable>> listByRedisResourceWithServiceResponseAsync(final String resourceGroupName, final String cacheName) { + return listByRedisResourceSinglePageAsync(resourceGroupName, cacheName) + .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(listByRedisResourceNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + ServiceResponse> * @param resourceGroupName The name of the resource group. + ServiceResponse> * @param cacheName The name of the Redis cache. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<RedisPatchScheduleInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByRedisResourceSinglePageAsync(final String resourceGroupName, final String cacheName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (cacheName == null) { + throw new IllegalArgumentException("Parameter cacheName 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.listByRedisResource(this.client.subscriptionId(), resourceGroupName, cacheName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByRedisResourceDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByRedisResourceDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); } /** @@ -343,4 +479,115 @@ private ServiceResponse getDelegate(Response listByRedisResourceNext(final String nextPageLink) { + ServiceResponse> response = listByRedisResourceNextSinglePageAsync(nextPageLink).toBlocking().single(); + return new PagedList(response.body()) { + @Override + public Page nextPage(String nextPageLink) { + return listByRedisResourceNextSinglePageAsync(nextPageLink).toBlocking().single().body(); + } + }; + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @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> listByRedisResourceNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( + listByRedisResourceNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return listByRedisResourceNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @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<RedisPatchScheduleInner> object + */ + public Observable> listByRedisResourceNextAsync(final String nextPageLink) { + return listByRedisResourceNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + * @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<RedisPatchScheduleInner> object + */ + public Observable>> listByRedisResourceNextWithServiceResponseAsync(final String nextPageLink) { + return listByRedisResourceNextSinglePageAsync(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(listByRedisResourceNextWithServiceResponseAsync(nextPageLink)); + } + }); + } + + /** + * Gets all patch schedules in the specified redis cache (there is only one). + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the PagedList<RedisPatchScheduleInner> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> listByRedisResourceNextSinglePageAsync(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.listByRedisResourceNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByRedisResourceNextDelegate(response); + return Observable.just(new ServiceResponse>(result.body(), result.response())); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByRedisResourceNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + } diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java index fcf726c6596..ddb78af9e89 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisInner.java @@ -149,7 +149,7 @@ interface RedisService { /** * Checks that the redis cache name is valid and is not already in use. * - * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. + * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. The only supported resource type is 'Microsoft.Cache/redis' * @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 @@ -161,7 +161,7 @@ public void checkNameAvailability(CheckNameAvailabilityParametersInner parameter /** * Checks that the redis cache name is valid and is not already in use. * - * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. + * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. The only supported resource type is 'Microsoft.Cache/redis' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object @@ -173,7 +173,7 @@ public ServiceFuture checkNameAvailabilityAsync(CheckNameAvailabilityParam /** * Checks that the redis cache name is valid and is not already in use. * - * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. + * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. The only supported resource type is 'Microsoft.Cache/redis' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ @@ -189,7 +189,7 @@ public Void call(ServiceResponse response) { /** * Checks that the redis cache name is valid and is not already in use. * - * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. + * @param parameters Parameters supplied to the CheckNameAvailability Redis operation. The only supported resource type is 'Microsoft.Cache/redis' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ From 8b0c638b88f65074f740a0b2c9b757ad96f929be Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 30 Apr 2018 21:46:00 +0000 Subject: [PATCH 2/3] Generated from 4f7e77b990601e0cc00b69a5870b50157525364d Implementing suggested usability improvement for redis cache: by not modelling CheckNameAvailabilityParameters.resourceType as a string, it can instead be treated as a cosntant, so that the parameter becomes optional! --- .../azure/management/redis/DefaultName.java | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java index d63335b85de..03adbbdb408 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/DefaultName.java @@ -8,31 +8,43 @@ package com.microsoft.azure.management.redis; -import java.util.Collection; import com.fasterxml.jackson.annotation.JsonCreator; -import com.microsoft.rest.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonValue; /** * Defines values for DefaultName. */ -public final class DefaultName extends ExpandableStringEnum { - /** Static value Microsoft.Cache/redis for DefaultName. */ - public static final DefaultName MICROSOFT_CACHEREDIS = fromString("Microsoft.Cache/redis"); +public enum DefaultName { + /** Enum value Microsoft.Cache/redis. */ + MICROSOFT_CACHEREDIS("Microsoft.Cache/redis"); + + /** The actual serialized value for a DefaultName instance. */ + private String value; + + DefaultName(String value) { + this.value = value; + } /** - * Creates or finds a DefaultName from its string representation. - * @param name a name to look for - * @return the corresponding DefaultName + * Parses a serialized value to a DefaultName instance. + * + * @param value the serialized value to parse. + * @return the parsed DefaultName object, or null if unable to parse. */ @JsonCreator - public static DefaultName fromString(String name) { - return fromString(name, DefaultName.class); + public static DefaultName fromString(String value) { + DefaultName[] items = DefaultName.values(); + for (DefaultName item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; } - /** - * @return known DefaultName values - */ - public static Collection values() { - return values(DefaultName.class); + @JsonValue + @Override + public String toString() { + return this.value; } } From a349907e60cef7de4c29b742d59f4df83a2798b4 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 1 May 2018 20:26:59 +0000 Subject: [PATCH 3/3] Generated from 44e3bae7be1e5d63ad1531c7710d586f47405970 Backport to the Microsoft.cache/redis 2017-10-01 swagger (from 2018-03-01). --- .../CheckNameAvailabilityParametersInner.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java index 60f9aed8209..31162fcb646 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/CheckNameAvailabilityParametersInner.java @@ -8,7 +8,6 @@ package com.microsoft.azure.management.redis.implementation; -import com.microsoft.azure.management.redis.DefaultName; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -18,16 +17,15 @@ public class CheckNameAvailabilityParametersInner { /** * Resource name. */ - @JsonProperty(value = "name") + @JsonProperty(value = "name", required = true) private String name; /** - * Resource type to check name availability of, e.g. - * 'Microsoft.Cache/redis'. Possible values include: - * 'Microsoft.Cache/redis'. + * Resource type. The only legal value of this property for checking redis + * cache name availability is 'Microsoft.Cache/redis'. */ - @JsonProperty(value = "type") - private DefaultName type; + @JsonProperty(value = "type", required = true) + private String type; /** * Get the name value. @@ -54,7 +52,7 @@ public CheckNameAvailabilityParametersInner withName(String name) { * * @return the type value */ - public DefaultName type() { + public String type() { return this.type; } @@ -64,7 +62,7 @@ public DefaultName type() { * @param type the type value to set * @return the CheckNameAvailabilityParametersInner object itself. */ - public CheckNameAvailabilityParametersInner withType(DefaultName type) { + public CheckNameAvailabilityParametersInner withType(String type) { this.type = type; return this; }