diff --git a/Samples/azure-storage/Azure.Java/StorageManagementClient.java b/Samples/azure-storage/Azure.Java/StorageManagementClient.java index 7a7182c76e6c8..7450ed33d64d0 100644 --- a/Samples/azure-storage/Azure.Java/StorageManagementClient.java +++ b/Samples/azure-storage/Azure.Java/StorageManagementClient.java @@ -4,44 +4,18 @@ package petstore; import com.microsoft.azure.AzureClient; -import com.microsoft.rest.AutoRestBaseUrl; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.serializer.JacksonMapperAdapter; -import java.util.List; -import okhttp3.Interceptor; -import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.azure.RestClient; /** * The interface for StorageManagementClient class. */ public interface StorageManagementClient { /** - * Gets the URL used as the base for all cloud service requests. + * Gets the REST client. * - * @return the BaseUrl object. - */ - AutoRestBaseUrl getBaseUrl(); - - /** - * Gets the list of interceptors the OkHttp client will execute. - * @return the list of interceptors. - */ - List getClientInterceptors(); - - /** - * Sets the logging level for OkHttp client. - * - * @param logLevel the logging level enum. - */ - void setLogLevel(Level logLevel); - - /** - * Gets the adapter for {@link com.fasterxml.jackson.databind.ObjectMapper} for serialization - * and deserialization operations.. - * - * @return the adapter. - */ - JacksonMapperAdapter getMapperAdapter(); + * @return the {@link RestClient} object. + */ + RestClient restClient(); /** * Gets the {@link AzureClient} used for long running operations. @@ -50,74 +24,78 @@ public interface StorageManagementClient { AzureClient getAzureClient(); /** - * Gets Credentials needed for the client to connect to Azure.. + * Gets the User-Agent header for the client. * - * @return the credentials value. + * @return the user agent string. */ - ServiceClientCredentials getCredentials(); + String userAgent(); /** * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. * * @return the subscriptionId value. */ - String getSubscriptionId(); + String subscriptionId(); /** * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.. * * @param subscriptionId the subscriptionId value. + * @return the service client itself */ - void setSubscriptionId(String subscriptionId); + StorageManagementClient withSubscriptionId(String subscriptionId); /** * Gets Client Api Version.. * * @return the apiVersion value. */ - String getApiVersion(); + String apiVersion(); /** * Gets Gets or sets the preferred language for the response.. * * @return the acceptLanguage value. */ - String getAcceptLanguage(); + String acceptLanguage(); /** * Sets Gets or sets the preferred language for the response.. * * @param acceptLanguage the acceptLanguage value. + * @return the service client itself */ - void setAcceptLanguage(String acceptLanguage); + StorageManagementClient withAcceptLanguage(String acceptLanguage); /** * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. * * @return the longRunningOperationRetryTimeout value. */ - int getLongRunningOperationRetryTimeout(); + int longRunningOperationRetryTimeout(); /** * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. * * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself */ - void withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + StorageManagementClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); /** * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. * * @return the generateClientRequestId value. */ - boolean getGenerateClientRequestId(); + boolean generateClientRequestId(); /** * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. * * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself */ - void setGenerateClientRequestId(boolean generateClientRequestId); + StorageManagementClient withGenerateClientRequestId(boolean generateClientRequestId); /** * Gets the StorageAccounts object to access its operations. diff --git a/Samples/azure-storage/Azure.Java/implementation/StorageAccountsImpl.java b/Samples/azure-storage/Azure.Java/implementation/StorageAccountsImpl.java new file mode 100644 index 0000000000000..2c5f77508fe6d --- /dev/null +++ b/Samples/azure-storage/Azure.Java/implementation/StorageAccountsImpl.java @@ -0,0 +1,895 @@ +/** + */ + +package petstore.implementation; + +import retrofit2.Retrofit; +import petstore.StorageAccounts; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import petstore.models.CheckNameAvailabilityResult; +import petstore.models.PageImpl; +import petstore.models.StorageAccount; +import petstore.models.StorageAccountCheckNameAvailabilityParameters; +import petstore.models.StorageAccountCreateParameters; +import petstore.models.StorageAccountKeys; +import petstore.models.StorageAccountRegenerateKeyParameters; +import petstore.models.StorageAccountUpdateParameters; +import retrofit2.Call; +import retrofit2.Callback; +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.Response; + +/** + * An instance of this class provides access to all the operations defined + * in StorageAccounts. + */ +public final class StorageAccountsImpl implements StorageAccounts { + /** The Retrofit service to perform REST calls. */ + private StorageAccountsService service; + /** The service client containing this operation class. */ + private StorageManagementClientImpl client; + + /** + * Initializes an instance of StorageAccountsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public StorageAccountsImpl(Retrofit retrofit, StorageManagementClientImpl client) { + this.service = retrofit.create(StorageAccountsService.class); + this.client = client; + } + + /** + * The interface defining all the services for StorageAccounts to be + * used by Retrofit to perform actually REST calls. + */ + interface StorageAccountsService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + Call checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Body StorageAccountCheckNameAvailabilityParameters accountName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") + Call create(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") + Call beginCreate(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountCreateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", method = "DELETE", hasBody = true) + Call delete(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @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") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") + Call getProperties(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @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") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") + Call update(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountUpdateParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") + Call listKeys(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @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") + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + Call 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") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") + Call 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") + @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") + Call regenerateKey(@Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("subscriptionId") String subscriptionId, @Body StorageAccountRegenerateKeyParameters regenerateKey, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Checks that account name is valid and is not in use. + * + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CheckNameAvailabilityResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse checkNameAvailability(StorageAccountCheckNameAvailabilityParameters accountName) throws CloudException, IOException, IllegalArgumentException { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(accountName); + Call call = service.checkNameAvailability(this.client.subscriptionId(), accountName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return checkNameAvailabilityDelegate(call.execute()); + } + + /** + * Checks that account name is valid and is not in use. + * + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall checkNameAvailabilityAsync(StorageAccountCheckNameAvailabilityParameters accountName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(accountName, serviceCallback); + Call call = service.checkNameAvailability(this.client.subscriptionId(), accountName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(checkNameAvailabilityDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse checkNameAvailabilityDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @throws InterruptedException exception thrown when long running operation is interrupted + * @return the StorageAccount object wrapped in ServiceResponse if successful. + */ + public ServiceResponse create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) throws CloudException, IOException, IllegalArgumentException, InterruptedException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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); + Response result = service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()).execute(); + return client.getAzureClient().getPutOrPatchResult(result, new TypeToken() { }.getType()); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall createAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + } + if (parameters == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + } + Validator.validate(parameters, serviceCallback); + Call call = service.create(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, Throwable t) { + serviceCallback.failure(t); + } + @Override + public void onResponse(Call call, Response response) { + client.getAzureClient().getPutOrPatchResultAsync(response, new TypeToken() { }.getType(), serviceCall, serviceCallback); + } + }); + return serviceCall; + } + + /** + * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the StorageAccount object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse beginCreate(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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); + Call call = service.beginCreate(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return beginCreateDelegate(call.execute()); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall beginCreateAsync(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (parameters == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(parameters, serviceCallback); + Call call = service.beginCreate(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(beginCreateDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse beginCreateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a storage account in Microsoft Azure. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse delete(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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."); + } + Call call = service.delete(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return deleteDelegate(call.execute()); + } + + /** + * Deletes a storage account in Microsoft Azure. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.delete(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the StorageAccount object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getProperties(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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."); + } + Call call = service.getProperties(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return getPropertiesDelegate(call.execute()); + } + + /** + * Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getPropertiesAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.getProperties(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getPropertiesDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getPropertiesDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the StorageAccount object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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); + Call call = service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return updateDelegate(call.execute()); + } + + /** + * Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. In order to replace a custom domain, the old value must be cleared before a new value may be set. To clear a custom domain, simply update the custom domain with empty string. Then call update again with the new cutsom domain name. The update API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to update on the account. Note that only one property can be changed at a time using this API. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateAsync(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (parameters == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(parameters, serviceCallback); + Call call = service.update(resourceGroupName, accountName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists the access keys for the specified storage account. + * + * @param resourceGroupName The name of the resource group. + * @param accountName The name of the storage account. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the StorageAccountKeys object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse listKeys(String resourceGroupName, String accountName) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.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."); + } + Call call = service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return listKeysDelegate(call.execute()); + } + + /** + * Lists the access keys for the specified storage account. + * + * @param resourceGroupName The name of the resource group. + * @param accountName The name of the storage account. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall listKeysAsync(String resourceGroupName, String accountName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.listKeys(resourceGroupName, accountName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(listKeysDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse listKeysDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<StorageAccount> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> list() throws CloudException, IOException, IllegalArgumentException { + 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."); + } + Call call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + ServiceResponse> response = listDelegate(call.execute()); + List result = response.getBody().getItems(); + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall listAsync(final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = listDelegate(response); + serviceCallback.success(new ServiceResponse<>(result.getBody().getItems(), result.getResponse())); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<StorageAccount> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> listByResourceGroup(String resourceGroupName) throws CloudException, IOException, IllegalArgumentException { + 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."); + } + Call call = service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + ServiceResponse> response = listByResourceGroupDelegate(call.execute()); + List result = response.getBody().getItems(); + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + serviceCallback.success(new ServiceResponse<>(result.getBody().getItems(), result.getResponse())); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> listByResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Regenerates the access keys for the specified storage account. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the StorageAccountKeys object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse regenerateKey(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey) throws CloudException, IOException, IllegalArgumentException { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (regenerateKey == null) { + throw new IllegalArgumentException("Parameter regenerateKey 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(regenerateKey); + Call call = service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), regenerateKey, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return regenerateKeyDelegate(call.execute()); + } + + /** + * Regenerates the access keys for the specified storage account. + * + * @param resourceGroupName The name of the resource group within the user's subscription. + * @param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param regenerateKey Specifies name of the key which should be regenerated. key1 or key2 for the default keys + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall regenerateKeyAsync(String resourceGroupName, String accountName, StorageAccountRegenerateKeyParameters regenerateKey, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (resourceGroupName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + return null; + } + if (accountName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + return null; + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (regenerateKey == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter regenerateKey is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(regenerateKey, serviceCallback); + Call call = service.regenerateKey(resourceGroupName, accountName, this.client.subscriptionId(), regenerateKey, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(regenerateKeyDelegate(response)); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse regenerateKeyDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/Samples/azure-storage/Azure.Java/implementation/StorageManagementClientImpl.java b/Samples/azure-storage/Azure.Java/implementation/StorageManagementClientImpl.java new file mode 100644 index 0000000000000..2f80634ad5a88 --- /dev/null +++ b/Samples/azure-storage/Azure.Java/implementation/StorageManagementClientImpl.java @@ -0,0 +1,212 @@ +/** + */ + +package petstore.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.RestClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import petstore.StorageAccounts; +import petstore.StorageManagementClient; +import petstore.Usages; + +/** + * Initializes a new instance of the StorageManagementClientImpl class. + */ +public final class StorageManagementClientImpl extends AzureServiceClient implements StorageManagementClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ + private String subscriptionId; + + /** + * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public StorageManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** Client Api Version. */ + private String apiVersion; + + /** + * Gets Client Api Version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public StorageManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public StorageManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public StorageManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The StorageAccounts object to access its operations. + */ + private StorageAccounts storageAccounts; + + /** + * Gets the StorageAccounts object to access its operations. + * @return the StorageAccounts object. + */ + public StorageAccounts storageAccounts() { + return this.storageAccounts; + } + + /** + * The Usages object to access its operations. + */ + private Usages usages; + + /** + * Gets the Usages object to access its operations. + * @return the Usages object. + */ + public Usages usages() { + return this.usages; + } + + /** + * Initializes an instance of StorageManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public StorageManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of StorageManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public StorageManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + this(new RestClient.Builder() + .withBaseUrl(baseUrl) + .withCredentials(credentials) + .build()); + } + + /** + * Initializes an instance of StorageManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public StorageManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2015-06-15"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.storageAccounts = new StorageAccountsImpl(restClient().retrofit(), this); + this.usages = new UsagesImpl(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("Azure-SDK-For-Java/%s (%s)", + getClass().getPackage().getImplementationVersion(), + "StorageManagementClient, 2015-06-15"); + } +} diff --git a/Samples/azure-storage/Azure.Java/implementation/UsagesImpl.java b/Samples/azure-storage/Azure.Java/implementation/UsagesImpl.java new file mode 100644 index 0000000000000..3d24484a1b2d4 --- /dev/null +++ b/Samples/azure-storage/Azure.Java/implementation/UsagesImpl.java @@ -0,0 +1,123 @@ +/** + */ + +package petstore.implementation; + +import retrofit2.Retrofit; +import petstore.Usages; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import petstore.models.PageImpl; +import petstore.models.Usage; +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; + +/** + * An instance of this class provides access to all the operations defined + * in Usages. + */ +public final class UsagesImpl implements Usages { + /** The Retrofit service to perform REST calls. */ + private UsagesService service; + /** The service client containing this operation class. */ + private StorageManagementClientImpl client; + + /** + * Initializes an instance of UsagesImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public UsagesImpl(Retrofit retrofit, StorageManagementClientImpl client) { + this.service = retrofit.create(UsagesService.class); + this.client = client; + } + + /** + * The interface defining all the services for Usages to be + * used by Retrofit to perform actually REST calls. + */ + interface UsagesService { + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") + Call list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets the current usage count and the limit for the resources under the subscription. + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<Usage> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> list() throws CloudException, IOException, IllegalArgumentException { + 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."); + } + Call call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + ServiceResponse> response = listDelegate(call.execute()); + List result = response.getBody().getItems(); + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * Gets the current usage count and the limit for the resources under the subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall listAsync(final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (this.client.subscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.")); + return null; + } + if (this.client.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.")); + return null; + } + Call call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = listDelegate(response); + serviceCallback.success(new ServiceResponse<>(result.getBody().getItems(), result.getResponse())); + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> listDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/Samples/azure-storage/Azure.Java/implementation/package-info.java b/Samples/azure-storage/Azure.Java/implementation/package-info.java new file mode 100644 index 0000000000000..bedea5103a5de --- /dev/null +++ b/Samples/azure-storage/Azure.Java/implementation/package-info.java @@ -0,0 +1,6 @@ + +/** + * This package contains the implementation classes for StorageManagementClient. + * The Storage Management Client. + */ +package petstore.implementation; diff --git a/Samples/azure-storage/Azure.Java/models/AccountStatus.java b/Samples/azure-storage/Azure.Java/models/AccountStatus.java index 935263fada2a2..9fa05559710ff 100644 --- a/Samples/azure-storage/Azure.Java/models/AccountStatus.java +++ b/Samples/azure-storage/Azure.Java/models/AccountStatus.java @@ -23,16 +23,6 @@ public enum AccountStatus { this.value = value; } - /** - * Gets the serialized value for a AccountStatus instance. - * - * @return the serialized value. - */ - @JsonValue - public String toValue() { - return this.value; - } - /** * Parses a serialized value to a AccountStatus instance. * @@ -40,18 +30,19 @@ public String toValue() { * @return the parsed AccountStatus object, or null if unable to parse. */ @JsonCreator - public static AccountStatus fromValue(String value) { + public static AccountStatus fromString(String value) { AccountStatus[] items = AccountStatus.values(); for (AccountStatus item : items) { - if (item.toValue().equals(value)) { + if (item.toString().equalsIgnoreCase(value)) { return item; } } return null; } + @JsonValue @Override public String toString() { - return toValue(); + return this.value; } } diff --git a/Samples/azure-storage/Azure.Java/models/AccountType.java b/Samples/azure-storage/Azure.Java/models/AccountType.java index 8eb41907b7c13..6cac9839c851e 100644 --- a/Samples/azure-storage/Azure.Java/models/AccountType.java +++ b/Samples/azure-storage/Azure.Java/models/AccountType.java @@ -32,16 +32,6 @@ public enum AccountType { this.value = value; } - /** - * Gets the serialized value for a AccountType instance. - * - * @return the serialized value. - */ - @JsonValue - public String toValue() { - return this.value; - } - /** * Parses a serialized value to a AccountType instance. * @@ -49,18 +39,19 @@ public String toValue() { * @return the parsed AccountType object, or null if unable to parse. */ @JsonCreator - public static AccountType fromValue(String value) { + public static AccountType fromString(String value) { AccountType[] items = AccountType.values(); for (AccountType item : items) { - if (item.toValue().equals(value)) { + if (item.toString().equalsIgnoreCase(value)) { return item; } } return null; } + @JsonValue @Override public String toString() { - return toValue(); + return this.value; } } diff --git a/Samples/azure-storage/Azure.Java/models/CheckNameAvailabilityResult.java b/Samples/azure-storage/Azure.Java/models/CheckNameAvailabilityResult.java index 67493bc3751a0..012278d97a829 100644 --- a/Samples/azure-storage/Azure.Java/models/CheckNameAvailabilityResult.java +++ b/Samples/azure-storage/Azure.Java/models/CheckNameAvailabilityResult.java @@ -32,7 +32,7 @@ public class CheckNameAvailabilityResult { * * @return the nameAvailable value */ - public Boolean getNameAvailable() { + public Boolean nameAvailable() { return this.nameAvailable; } @@ -40,9 +40,11 @@ public Boolean getNameAvailable() { * Set the nameAvailable value. * * @param nameAvailable the nameAvailable value to set + * @return the CheckNameAvailabilityResult object itself. */ - public void setNameAvailable(Boolean nameAvailable) { + public CheckNameAvailabilityResult withNameAvailable(Boolean nameAvailable) { this.nameAvailable = nameAvailable; + return this; } /** @@ -50,7 +52,7 @@ public void setNameAvailable(Boolean nameAvailable) { * * @return the reason value */ - public Reason getReason() { + public Reason reason() { return this.reason; } @@ -58,9 +60,11 @@ public Reason getReason() { * Set the reason value. * * @param reason the reason value to set + * @return the CheckNameAvailabilityResult object itself. */ - public void setReason(Reason reason) { + public CheckNameAvailabilityResult withReason(Reason reason) { this.reason = reason; + return this; } /** @@ -68,7 +72,7 @@ public void setReason(Reason reason) { * * @return the message value */ - public String getMessage() { + public String message() { return this.message; } @@ -76,9 +80,11 @@ public String getMessage() { * Set the message value. * * @param message the message value to set + * @return the CheckNameAvailabilityResult object itself. */ - public void setMessage(String message) { + public CheckNameAvailabilityResult withMessage(String message) { this.message = message; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/CustomDomain.java b/Samples/azure-storage/Azure.Java/models/CustomDomain.java index 892efa9dad92d..8de0baf6b81cc 100644 --- a/Samples/azure-storage/Azure.Java/models/CustomDomain.java +++ b/Samples/azure-storage/Azure.Java/models/CustomDomain.java @@ -27,7 +27,7 @@ public class CustomDomain { * * @return the name value */ - public String getName() { + public String name() { return this.name; } @@ -35,9 +35,11 @@ public String getName() { * Set the name value. * * @param name the name value to set + * @return the CustomDomain object itself. */ - public void setName(String name) { + public CustomDomain withName(String name) { this.name = name; + return this; } /** @@ -45,7 +47,7 @@ public void setName(String name) { * * @return the useSubDomain value */ - public Boolean getUseSubDomain() { + public Boolean useSubDomain() { return this.useSubDomain; } @@ -53,9 +55,11 @@ public Boolean getUseSubDomain() { * Set the useSubDomain value. * * @param useSubDomain the useSubDomain value to set + * @return the CustomDomain object itself. */ - public void setUseSubDomain(Boolean useSubDomain) { + public CustomDomain withUseSubDomain(Boolean useSubDomain) { this.useSubDomain = useSubDomain; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/Endpoints.java b/Samples/azure-storage/Azure.Java/models/Endpoints.java index a143415a76ad2..724193906a46a 100644 --- a/Samples/azure-storage/Azure.Java/models/Endpoints.java +++ b/Samples/azure-storage/Azure.Java/models/Endpoints.java @@ -34,7 +34,7 @@ public class Endpoints { * * @return the blob value */ - public String getBlob() { + public String blob() { return this.blob; } @@ -42,9 +42,11 @@ public String getBlob() { * Set the blob value. * * @param blob the blob value to set + * @return the Endpoints object itself. */ - public void setBlob(String blob) { + public Endpoints withBlob(String blob) { this.blob = blob; + return this; } /** @@ -52,7 +54,7 @@ public void setBlob(String blob) { * * @return the queue value */ - public String getQueue() { + public String queue() { return this.queue; } @@ -60,9 +62,11 @@ public String getQueue() { * Set the queue value. * * @param queue the queue value to set + * @return the Endpoints object itself. */ - public void setQueue(String queue) { + public Endpoints withQueue(String queue) { this.queue = queue; + return this; } /** @@ -70,7 +74,7 @@ public void setQueue(String queue) { * * @return the table value */ - public String getTable() { + public String table() { return this.table; } @@ -78,9 +82,11 @@ public String getTable() { * Set the table value. * * @param table the table value to set + * @return the Endpoints object itself. */ - public void setTable(String table) { + public Endpoints withTable(String table) { this.table = table; + return this; } /** @@ -88,7 +94,7 @@ public void setTable(String table) { * * @return the file value */ - public String getFile() { + public String file() { return this.file; } @@ -96,9 +102,11 @@ public String getFile() { * Set the file value. * * @param file the file value to set + * @return the Endpoints object itself. */ - public void setFile(String file) { + public Endpoints withFile(String file) { this.file = file; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/PageImpl.java b/Samples/azure-storage/Azure.Java/models/PageImpl.java index 1090018626e55..65f3c5f0d7262 100644 --- a/Samples/azure-storage/Azure.Java/models/PageImpl.java +++ b/Samples/azure-storage/Azure.Java/models/PageImpl.java @@ -45,4 +45,26 @@ public String getNextPageLink() { public List getItems() { return items; } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } } diff --git a/Samples/azure-storage/Azure.Java/models/ProvisioningState.java b/Samples/azure-storage/Azure.Java/models/ProvisioningState.java index e3c51eac5efb4..928964f0de2f9 100644 --- a/Samples/azure-storage/Azure.Java/models/ProvisioningState.java +++ b/Samples/azure-storage/Azure.Java/models/ProvisioningState.java @@ -14,7 +14,7 @@ public enum ProvisioningState { CREATING("Creating"), /** Enum value ResolvingDNS. */ - RESOLVINGDNS("ResolvingDNS"), + RESOLVING_DNS("ResolvingDNS"), /** Enum value Succeeded. */ SUCCEEDED("Succeeded"); @@ -26,16 +26,6 @@ public enum ProvisioningState { this.value = value; } - /** - * Gets the serialized value for a ProvisioningState instance. - * - * @return the serialized value. - */ - @JsonValue - public String toValue() { - return this.value; - } - /** * Parses a serialized value to a ProvisioningState instance. * @@ -43,18 +33,19 @@ public String toValue() { * @return the parsed ProvisioningState object, or null if unable to parse. */ @JsonCreator - public static ProvisioningState fromValue(String value) { + public static ProvisioningState fromString(String value) { ProvisioningState[] items = ProvisioningState.values(); for (ProvisioningState item : items) { - if (item.toValue().equals(value)) { + if (item.toString().equalsIgnoreCase(value)) { return item; } } return null; } + @JsonValue @Override public String toString() { - return toValue(); + return this.value; } } diff --git a/Samples/azure-storage/Azure.Java/models/Reason.java b/Samples/azure-storage/Azure.Java/models/Reason.java index d281c844c5058..716297be0fb23 100644 --- a/Samples/azure-storage/Azure.Java/models/Reason.java +++ b/Samples/azure-storage/Azure.Java/models/Reason.java @@ -11,10 +11,10 @@ */ public enum Reason { /** Enum value AccountNameInvalid. */ - ACCOUNTNAMEINVALID("AccountNameInvalid"), + ACCOUNT_NAME_INVALID("AccountNameInvalid"), /** Enum value AlreadyExists. */ - ALREADYEXISTS("AlreadyExists"); + ALREADY_EXISTS("AlreadyExists"); /** The actual serialized value for a Reason instance. */ private String value; @@ -23,16 +23,6 @@ public enum Reason { this.value = value; } - /** - * Gets the serialized value for a Reason instance. - * - * @return the serialized value. - */ - @JsonValue - public String toValue() { - return this.value; - } - /** * Parses a serialized value to a Reason instance. * @@ -40,18 +30,19 @@ public String toValue() { * @return the parsed Reason object, or null if unable to parse. */ @JsonCreator - public static Reason fromValue(String value) { + public static Reason fromString(String value) { Reason[] items = Reason.values(); for (Reason item : items) { - if (item.toValue().equals(value)) { + if (item.toString().equalsIgnoreCase(value)) { return item; } } return null; } + @JsonValue @Override public String toString() { - return toValue(); + return this.value; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccount.java b/Samples/azure-storage/Azure.Java/models/StorageAccount.java index a74289f0118b6..07a9c6443920d 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccount.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccount.java @@ -19,7 +19,7 @@ public class StorageAccount extends Resource { * * @return the properties value */ - public StorageAccountProperties getProperties() { + public StorageAccountProperties properties() { return this.properties; } @@ -27,9 +27,11 @@ public StorageAccountProperties getProperties() { * Set the properties value. * * @param properties the properties value to set + * @return the StorageAccount object itself. */ - public void setProperties(StorageAccountProperties properties) { + public StorageAccount withProperties(StorageAccountProperties properties) { this.properties = properties; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountCheckNameAvailabilityParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountCheckNameAvailabilityParameters.java index d41f1a9f1df8f..0c86c0d2a62a6 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountCheckNameAvailabilityParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountCheckNameAvailabilityParameters.java @@ -25,7 +25,7 @@ public class StorageAccountCheckNameAvailabilityParameters { * * @return the name value */ - public String getName() { + public String name() { return this.name; } @@ -33,9 +33,11 @@ public String getName() { * Set the name value. * * @param name the name value to set + * @return the StorageAccountCheckNameAvailabilityParameters object itself. */ - public void setName(String name) { + public StorageAccountCheckNameAvailabilityParameters withName(String name) { this.name = name; + return this; } /** @@ -43,7 +45,7 @@ public void setName(String name) { * * @return the type value */ - public String getType() { + public String type() { return this.type; } @@ -51,9 +53,11 @@ public String getType() { * Set the type value. * * @param type the type value to set + * @return the StorageAccountCheckNameAvailabilityParameters object itself. */ - public void setType(String type) { + public StorageAccountCheckNameAvailabilityParameters withType(String type) { this.type = type; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountCreateParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountCreateParameters.java index 7f3cc5defc94e..9da392963bdc8 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountCreateParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountCreateParameters.java @@ -31,7 +31,7 @@ public class StorageAccountCreateParameters { * * @return the location value */ - public String getLocation() { + public String location() { return this.location; } @@ -39,9 +39,11 @@ public String getLocation() { * Set the location value. * * @param location the location value to set + * @return the StorageAccountCreateParameters object itself. */ - public void withLocation(String location) { + public StorageAccountCreateParameters withLocation(String location) { this.location = location; + return this; } /** @@ -49,7 +51,7 @@ public void withLocation(String location) { * * @return the tags value */ - public Map getTags() { + public Map tags() { return this.tags; } @@ -57,9 +59,11 @@ public Map getTags() { * Set the tags value. * * @param tags the tags value to set + * @return the StorageAccountCreateParameters object itself. */ - public void withTags(Map tags) { + public StorageAccountCreateParameters withTags(Map tags) { this.tags = tags; + return this; } /** @@ -67,7 +71,7 @@ public void withTags(Map tags) { * * @return the properties value */ - public StorageAccountPropertiesCreateParameters getProperties() { + public StorageAccountPropertiesCreateParameters properties() { return this.properties; } @@ -75,9 +79,11 @@ public StorageAccountPropertiesCreateParameters getProperties() { * Set the properties value. * * @param properties the properties value to set + * @return the StorageAccountCreateParameters object itself. */ - public void setProperties(StorageAccountPropertiesCreateParameters properties) { + public StorageAccountCreateParameters withProperties(StorageAccountPropertiesCreateParameters properties) { this.properties = properties; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountKeys.java b/Samples/azure-storage/Azure.Java/models/StorageAccountKeys.java index 0c431f8fc0111..c459bbe9be495 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountKeys.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountKeys.java @@ -23,7 +23,7 @@ public class StorageAccountKeys { * * @return the key1 value */ - public String getKey1() { + public String key1() { return this.key1; } @@ -31,9 +31,11 @@ public String getKey1() { * Set the key1 value. * * @param key1 the key1 value to set + * @return the StorageAccountKeys object itself. */ - public void setKey1(String key1) { + public StorageAccountKeys withKey1(String key1) { this.key1 = key1; + return this; } /** @@ -41,7 +43,7 @@ public void setKey1(String key1) { * * @return the key2 value */ - public String getKey2() { + public String key2() { return this.key2; } @@ -49,9 +51,11 @@ public String getKey2() { * Set the key2 value. * * @param key2 the key2 value to set + * @return the StorageAccountKeys object itself. */ - public void setKey2(String key2) { + public StorageAccountKeys withKey2(String key2) { this.key2 = key2; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountProperties.java b/Samples/azure-storage/Azure.Java/models/StorageAccountProperties.java index 6f28746269f62..aa7fecd574575 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountProperties.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountProperties.java @@ -87,7 +87,7 @@ public class StorageAccountProperties { * * @return the provisioningState value */ - public ProvisioningState getProvisioningState() { + public ProvisioningState provisioningState() { return this.provisioningState; } @@ -95,9 +95,11 @@ public ProvisioningState getProvisioningState() { * Set the provisioningState value. * * @param provisioningState the provisioningState value to set + * @return the StorageAccountProperties object itself. */ - public void setProvisioningState(ProvisioningState provisioningState) { + public StorageAccountProperties withProvisioningState(ProvisioningState provisioningState) { this.provisioningState = provisioningState; + return this; } /** @@ -105,7 +107,7 @@ public void setProvisioningState(ProvisioningState provisioningState) { * * @return the accountType value */ - public AccountType getAccountType() { + public AccountType accountType() { return this.accountType; } @@ -113,9 +115,11 @@ public AccountType getAccountType() { * Set the accountType value. * * @param accountType the accountType value to set + * @return the StorageAccountProperties object itself. */ - public void setAccountType(AccountType accountType) { + public StorageAccountProperties withAccountType(AccountType accountType) { this.accountType = accountType; + return this; } /** @@ -123,7 +127,7 @@ public void setAccountType(AccountType accountType) { * * @return the primaryEndpoints value */ - public Endpoints getPrimaryEndpoints() { + public Endpoints primaryEndpoints() { return this.primaryEndpoints; } @@ -131,9 +135,11 @@ public Endpoints getPrimaryEndpoints() { * Set the primaryEndpoints value. * * @param primaryEndpoints the primaryEndpoints value to set + * @return the StorageAccountProperties object itself. */ - public void setPrimaryEndpoints(Endpoints primaryEndpoints) { + public StorageAccountProperties withPrimaryEndpoints(Endpoints primaryEndpoints) { this.primaryEndpoints = primaryEndpoints; + return this; } /** @@ -141,7 +147,7 @@ public void setPrimaryEndpoints(Endpoints primaryEndpoints) { * * @return the primaryLocation value */ - public String getPrimaryLocation() { + public String primaryLocation() { return this.primaryLocation; } @@ -149,9 +155,11 @@ public String getPrimaryLocation() { * Set the primaryLocation value. * * @param primaryLocation the primaryLocation value to set + * @return the StorageAccountProperties object itself. */ - public void setPrimaryLocation(String primaryLocation) { + public StorageAccountProperties withPrimaryLocation(String primaryLocation) { this.primaryLocation = primaryLocation; + return this; } /** @@ -159,7 +167,7 @@ public void setPrimaryLocation(String primaryLocation) { * * @return the statusOfPrimary value */ - public AccountStatus getStatusOfPrimary() { + public AccountStatus statusOfPrimary() { return this.statusOfPrimary; } @@ -167,9 +175,11 @@ public AccountStatus getStatusOfPrimary() { * Set the statusOfPrimary value. * * @param statusOfPrimary the statusOfPrimary value to set + * @return the StorageAccountProperties object itself. */ - public void setStatusOfPrimary(AccountStatus statusOfPrimary) { + public StorageAccountProperties withStatusOfPrimary(AccountStatus statusOfPrimary) { this.statusOfPrimary = statusOfPrimary; + return this; } /** @@ -177,7 +187,7 @@ public void setStatusOfPrimary(AccountStatus statusOfPrimary) { * * @return the lastGeoFailoverTime value */ - public DateTime getLastGeoFailoverTime() { + public DateTime lastGeoFailoverTime() { return this.lastGeoFailoverTime; } @@ -185,9 +195,11 @@ public DateTime getLastGeoFailoverTime() { * Set the lastGeoFailoverTime value. * * @param lastGeoFailoverTime the lastGeoFailoverTime value to set + * @return the StorageAccountProperties object itself. */ - public void setLastGeoFailoverTime(DateTime lastGeoFailoverTime) { + public StorageAccountProperties withLastGeoFailoverTime(DateTime lastGeoFailoverTime) { this.lastGeoFailoverTime = lastGeoFailoverTime; + return this; } /** @@ -195,7 +207,7 @@ public void setLastGeoFailoverTime(DateTime lastGeoFailoverTime) { * * @return the secondaryLocation value */ - public String getSecondaryLocation() { + public String secondaryLocation() { return this.secondaryLocation; } @@ -203,9 +215,11 @@ public String getSecondaryLocation() { * Set the secondaryLocation value. * * @param secondaryLocation the secondaryLocation value to set + * @return the StorageAccountProperties object itself. */ - public void setSecondaryLocation(String secondaryLocation) { + public StorageAccountProperties withSecondaryLocation(String secondaryLocation) { this.secondaryLocation = secondaryLocation; + return this; } /** @@ -213,7 +227,7 @@ public void setSecondaryLocation(String secondaryLocation) { * * @return the statusOfSecondary value */ - public AccountStatus getStatusOfSecondary() { + public AccountStatus statusOfSecondary() { return this.statusOfSecondary; } @@ -221,9 +235,11 @@ public AccountStatus getStatusOfSecondary() { * Set the statusOfSecondary value. * * @param statusOfSecondary the statusOfSecondary value to set + * @return the StorageAccountProperties object itself. */ - public void setStatusOfSecondary(AccountStatus statusOfSecondary) { + public StorageAccountProperties withStatusOfSecondary(AccountStatus statusOfSecondary) { this.statusOfSecondary = statusOfSecondary; + return this; } /** @@ -231,7 +247,7 @@ public void setStatusOfSecondary(AccountStatus statusOfSecondary) { * * @return the creationTime value */ - public DateTime getCreationTime() { + public DateTime creationTime() { return this.creationTime; } @@ -239,9 +255,11 @@ public DateTime getCreationTime() { * Set the creationTime value. * * @param creationTime the creationTime value to set + * @return the StorageAccountProperties object itself. */ - public void setCreationTime(DateTime creationTime) { + public StorageAccountProperties withCreationTime(DateTime creationTime) { this.creationTime = creationTime; + return this; } /** @@ -249,7 +267,7 @@ public void setCreationTime(DateTime creationTime) { * * @return the customDomain value */ - public CustomDomain getCustomDomain() { + public CustomDomain customDomain() { return this.customDomain; } @@ -257,9 +275,11 @@ public CustomDomain getCustomDomain() { * Set the customDomain value. * * @param customDomain the customDomain value to set + * @return the StorageAccountProperties object itself. */ - public void setCustomDomain(CustomDomain customDomain) { + public StorageAccountProperties withCustomDomain(CustomDomain customDomain) { this.customDomain = customDomain; + return this; } /** @@ -267,7 +287,7 @@ public void setCustomDomain(CustomDomain customDomain) { * * @return the secondaryEndpoints value */ - public Endpoints getSecondaryEndpoints() { + public Endpoints secondaryEndpoints() { return this.secondaryEndpoints; } @@ -275,9 +295,11 @@ public Endpoints getSecondaryEndpoints() { * Set the secondaryEndpoints value. * * @param secondaryEndpoints the secondaryEndpoints value to set + * @return the StorageAccountProperties object itself. */ - public void setSecondaryEndpoints(Endpoints secondaryEndpoints) { + public StorageAccountProperties withSecondaryEndpoints(Endpoints secondaryEndpoints) { this.secondaryEndpoints = secondaryEndpoints; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesCreateParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesCreateParameters.java index 97ccede7b3ca7..85623a76d77e0 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesCreateParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesCreateParameters.java @@ -21,7 +21,7 @@ public class StorageAccountPropertiesCreateParameters { * * @return the accountType value */ - public AccountType getAccountType() { + public AccountType accountType() { return this.accountType; } @@ -29,9 +29,11 @@ public AccountType getAccountType() { * Set the accountType value. * * @param accountType the accountType value to set + * @return the StorageAccountPropertiesCreateParameters object itself. */ - public void setAccountType(AccountType accountType) { + public StorageAccountPropertiesCreateParameters withAccountType(AccountType accountType) { this.accountType = accountType; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesUpdateParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesUpdateParameters.java index 5e9b7eb3151b8..ef2942152cbb9 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesUpdateParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountPropertiesUpdateParameters.java @@ -30,7 +30,7 @@ public class StorageAccountPropertiesUpdateParameters { * * @return the accountType value */ - public AccountType getAccountType() { + public AccountType accountType() { return this.accountType; } @@ -38,9 +38,11 @@ public AccountType getAccountType() { * Set the accountType value. * * @param accountType the accountType value to set + * @return the StorageAccountPropertiesUpdateParameters object itself. */ - public void setAccountType(AccountType accountType) { + public StorageAccountPropertiesUpdateParameters withAccountType(AccountType accountType) { this.accountType = accountType; + return this; } /** @@ -48,7 +50,7 @@ public void setAccountType(AccountType accountType) { * * @return the customDomain value */ - public CustomDomain getCustomDomain() { + public CustomDomain customDomain() { return this.customDomain; } @@ -56,9 +58,11 @@ public CustomDomain getCustomDomain() { * Set the customDomain value. * * @param customDomain the customDomain value to set + * @return the StorageAccountPropertiesUpdateParameters object itself. */ - public void setCustomDomain(CustomDomain customDomain) { + public StorageAccountPropertiesUpdateParameters withCustomDomain(CustomDomain customDomain) { this.customDomain = customDomain; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountRegenerateKeyParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountRegenerateKeyParameters.java index 878f147a1ebfe..fe84f4742692a 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountRegenerateKeyParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountRegenerateKeyParameters.java @@ -20,7 +20,7 @@ public class StorageAccountRegenerateKeyParameters { * * @return the keyName value */ - public String getKeyName() { + public String keyName() { return this.keyName; } @@ -28,9 +28,11 @@ public String getKeyName() { * Set the keyName value. * * @param keyName the keyName value to set + * @return the StorageAccountRegenerateKeyParameters object itself. */ - public void setKeyName(String keyName) { + public StorageAccountRegenerateKeyParameters withKeyName(String keyName) { this.keyName = keyName; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/StorageAccountUpdateParameters.java b/Samples/azure-storage/Azure.Java/models/StorageAccountUpdateParameters.java index af54df0c7fbd6..a803956adceb5 100644 --- a/Samples/azure-storage/Azure.Java/models/StorageAccountUpdateParameters.java +++ b/Samples/azure-storage/Azure.Java/models/StorageAccountUpdateParameters.java @@ -24,7 +24,7 @@ public class StorageAccountUpdateParameters { * * @return the tags value */ - public Map withTags() { + public Map tags() { return this.tags; } @@ -32,9 +32,11 @@ public Map withTags() { * Set the tags value. * * @param tags the tags value to set + * @return the StorageAccountUpdateParameters object itself. */ - public void withTags(Map tags) { + public StorageAccountUpdateParameters withTags(Map tags) { this.tags = tags; + return this; } /** @@ -42,7 +44,7 @@ public void withTags(Map tags) { * * @return the properties value */ - public StorageAccountPropertiesUpdateParameters getProperties() { + public StorageAccountPropertiesUpdateParameters properties() { return this.properties; } @@ -50,9 +52,11 @@ public StorageAccountPropertiesUpdateParameters getProperties() { * Set the properties value. * * @param properties the properties value to set + * @return the StorageAccountUpdateParameters object itself. */ - public void setProperties(StorageAccountPropertiesUpdateParameters properties) { + public StorageAccountUpdateParameters withProperties(StorageAccountPropertiesUpdateParameters properties) { this.properties = properties; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/Usage.java b/Samples/azure-storage/Azure.Java/models/Usage.java index fef0ceedf7664..9f51b86fc9440 100644 --- a/Samples/azure-storage/Azure.Java/models/Usage.java +++ b/Samples/azure-storage/Azure.Java/models/Usage.java @@ -40,7 +40,7 @@ public class Usage { * * @return the unit value */ - public UsageUnit getUnit() { + public UsageUnit unit() { return this.unit; } @@ -48,9 +48,11 @@ public UsageUnit getUnit() { * Set the unit value. * * @param unit the unit value to set + * @return the Usage object itself. */ - public void setUnit(UsageUnit unit) { + public Usage withUnit(UsageUnit unit) { this.unit = unit; + return this; } /** @@ -58,7 +60,7 @@ public void setUnit(UsageUnit unit) { * * @return the currentValue value */ - public int getCurrentValue() { + public int currentValue() { return this.currentValue; } @@ -66,9 +68,11 @@ public int getCurrentValue() { * Set the currentValue value. * * @param currentValue the currentValue value to set + * @return the Usage object itself. */ - public void setCurrentValue(int currentValue) { + public Usage withCurrentValue(int currentValue) { this.currentValue = currentValue; + return this; } /** @@ -76,7 +80,7 @@ public void setCurrentValue(int currentValue) { * * @return the limit value */ - public int getLimit() { + public int limit() { return this.limit; } @@ -84,9 +88,11 @@ public int getLimit() { * Set the limit value. * * @param limit the limit value to set + * @return the Usage object itself. */ - public void setLimit(int limit) { + public Usage withLimit(int limit) { this.limit = limit; + return this; } /** @@ -94,7 +100,7 @@ public void setLimit(int limit) { * * @return the name value */ - public UsageName getName() { + public UsageName name() { return this.name; } @@ -102,9 +108,11 @@ public UsageName getName() { * Set the name value. * * @param name the name value to set + * @return the Usage object itself. */ - public void setName(UsageName name) { + public Usage withName(UsageName name) { this.name = name; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/UsageName.java b/Samples/azure-storage/Azure.Java/models/UsageName.java index b1dd3dc69f8ca..6542fc045a74d 100644 --- a/Samples/azure-storage/Azure.Java/models/UsageName.java +++ b/Samples/azure-storage/Azure.Java/models/UsageName.java @@ -23,7 +23,7 @@ public class UsageName { * * @return the value value */ - public String getValue() { + public String value() { return this.value; } @@ -31,9 +31,11 @@ public String getValue() { * Set the value value. * * @param value the value value to set + * @return the UsageName object itself. */ - public void setValue(String value) { + public UsageName withValue(String value) { this.value = value; + return this; } /** @@ -41,7 +43,7 @@ public void setValue(String value) { * * @return the localizedValue value */ - public String getLocalizedValue() { + public String localizedValue() { return this.localizedValue; } @@ -49,9 +51,11 @@ public String getLocalizedValue() { * Set the localizedValue value. * * @param localizedValue the localizedValue value to set + * @return the UsageName object itself. */ - public void setLocalizedValue(String localizedValue) { + public UsageName withLocalizedValue(String localizedValue) { this.localizedValue = localizedValue; + return this; } } diff --git a/Samples/azure-storage/Azure.Java/models/UsageUnit.java b/Samples/azure-storage/Azure.Java/models/UsageUnit.java index 1996e58717476..4e1724018b52b 100644 --- a/Samples/azure-storage/Azure.Java/models/UsageUnit.java +++ b/Samples/azure-storage/Azure.Java/models/UsageUnit.java @@ -23,10 +23,10 @@ public enum UsageUnit { PERCENT("Percent"), /** Enum value CountsPerSecond. */ - COUNTSPERSECOND("CountsPerSecond"), + COUNTS_PER_SECOND("CountsPerSecond"), /** Enum value BytesPerSecond. */ - BYTESPERSECOND("BytesPerSecond"); + BYTES_PER_SECOND("BytesPerSecond"); /** The actual serialized value for a UsageUnit instance. */ private String value; @@ -35,16 +35,6 @@ public enum UsageUnit { this.value = value; } - /** - * Gets the serialized value for a UsageUnit instance. - * - * @return the serialized value. - */ - @JsonValue - public String toValue() { - return this.value; - } - /** * Parses a serialized value to a UsageUnit instance. * @@ -52,18 +42,19 @@ public String toValue() { * @return the parsed UsageUnit object, or null if unable to parse. */ @JsonCreator - public static UsageUnit fromValue(String value) { + public static UsageUnit fromString(String value) { UsageUnit[] items = UsageUnit.values(); for (UsageUnit item : items) { - if (item.toValue().equals(value)) { + if (item.toString().equalsIgnoreCase(value)) { return item; } } return null; } + @JsonValue @Override public String toString() { - return toValue(); + return this.value; } } diff --git a/Samples/azure-storage/Azure.Java/models/package-info.java b/Samples/azure-storage/Azure.Java/models/package-info.java index b8c2781aa4b01..0a8afb9b10d80 100644 --- a/Samples/azure-storage/Azure.Java/models/package-info.java +++ b/Samples/azure-storage/Azure.Java/models/package-info.java @@ -1,6 +1,6 @@ /** - * This package contains the model classes for StorageManagementClient. + * This package contains the models classes for StorageManagementClient. * The Storage Management Client. */ package petstore.models; diff --git a/Samples/petstore/Java/SwaggerPetstore.java b/Samples/petstore/Java/SwaggerPetstore.java index b84b27c882574..54ee4eb826036 100644 --- a/Samples/petstore/Java/SwaggerPetstore.java +++ b/Samples/petstore/Java/SwaggerPetstore.java @@ -3,16 +3,12 @@ package petstore; -import java.util.List; -import okhttp3.Interceptor; -import okhttp3.logging.HttpLoggingInterceptor.Level; -import com.microsoft.rest.AutoRestBaseUrl; -import com.microsoft.rest.serializer.JacksonMapperAdapter; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceException; import com.microsoft.rest.ServiceResponse; import java.io.IOException; +import java.util.List; import java.util.Map; import petstore.models.Order; import petstore.models.Pet; @@ -23,33 +19,9 @@ */ public interface SwaggerPetstore { /** - * Gets the URL used as the base for all cloud service requests. - * - * @return the BaseUrl object. - */ - AutoRestBaseUrl getBaseUrl(); - - /** - * Gets the list of interceptors the OkHttp client will execute. - * - * @return the list of interceptors. - */ - List getClientInterceptors(); - - /** - * Sets the logging level for OkHttp client. - * - * @param logLevel the logging level enum. - */ - void setLogLevel(Level logLevel); - - /** - * Gets the adapter for {@link com.fasterxml.jackson.databind.ObjectMapper} for serialization - * and deserialization operations.. - * - * @return the adapter. + * The default base URL. */ - JacksonMapperAdapter getMapperAdapter(); + String DEFAULT_BASE_URL = "http://petstore.swagger.io/v2"; /** * Fake endpoint to test byte array in body parameter for adding a new pet to the store. diff --git a/Samples/petstore/Java/implementation/SwaggerPetstoreImpl.java b/Samples/petstore/Java/implementation/SwaggerPetstoreImpl.java new file mode 100644 index 0000000000000..779d5d1bad848 --- /dev/null +++ b/Samples/petstore/Java/implementation/SwaggerPetstoreImpl.java @@ -0,0 +1,1939 @@ +/** + */ + +package petstore.implementation; + +import petstore.SwaggerPetstore; +import com.microsoft.rest.ServiceClient; +import okhttp3.OkHttpClient; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.rest.serializer.CollectionFormat; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceException; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseBuilder; +import com.microsoft.rest.ServiceResponseCallback; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import okhttp3.ResponseBody; +import petstore.models.Order; +import petstore.models.Pet; +import petstore.models.User; +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Multipart; +import retrofit2.http.Part; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; + +/** + * Initializes a new instance of the SwaggerPetstore class. + */ +public final class SwaggerPetstoreImpl extends ServiceClient implements SwaggerPetstore { + /** + * The Retrofit service to perform REST calls. + */ + private SwaggerPetstoreService service; + + /** + * Initializes an instance of SwaggerPetstore client. + */ + public SwaggerPetstoreImpl() { + this("http://petstore.swagger.io/v2"); + } + + /** + * Initializes an instance of SwaggerPetstore client. + * + * @param baseUrl the base URL of the host + */ + public SwaggerPetstoreImpl(String baseUrl) { + super(baseUrl); + initialize(); + } + + /** + * Initializes an instance of SwaggerPetstore client. + * + * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations + * @param restBuilder the builder for building an Retrofit client, bundled with user configurations + */ + public SwaggerPetstoreImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { + this("http://petstore.swagger.io/v2", clientBuilder, restBuilder); + initialize(); + } + + /** + * Initializes an instance of SwaggerPetstore client. + * + * @param baseUrl the base URL of the host + * @param clientBuilder the builder for building an OkHttp client, bundled with user configurations + * @param restBuilder the builder for building an Retrofit client, bundled with user configurations + */ + public SwaggerPetstoreImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { + super(baseUrl, clientBuilder, restBuilder); + initialize(); + } + + private void initialize() { + initializeService(); + } + + private void initializeService() { + service = retrofit().create(SwaggerPetstoreService.class); + } + + /** + * The interface defining all the services for SwaggerPetstore to be + * used by Retrofit to perform actually REST calls. + */ + interface SwaggerPetstoreService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("pet") + Call addPetUsingByteArray(@Body String body); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("pet") + Call addPet(@Body Pet body); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("pet") + Call updatePet(@Body Pet body); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("pet/findByStatus") + Call findPetsByStatus(@Query("status") String status); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("pet/findByTags") + Call findPetsByTags(@Query("tags") String tags); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("pet/{petId}") + Call findPetsWithByteArray(@Path("petId") long petId); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("pet/{petId}") + Call getPetById(@Path("petId") long petId); + + @Multipart + @POST("pet/{petId}") + Call updatePetWithForm(@Path("petId") String petId, @Part("name") String name, @Part("status") String status); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "pet/{petId}", method = "DELETE", hasBody = true) + Call deletePet(@Path("petId") long petId, @Header("api_key") String apiKey); + + @Multipart + @POST("pet/{petId}/uploadImage") + Call uploadFile(@Path("petId") long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") RequestBody file); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("store/inventory") + Call getInventory(); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("store/order") + Call placeOrder(@Body Order body); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("store/order/{orderId}") + Call getOrderById(@Path("orderId") String orderId); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "store/order/{orderId}", method = "DELETE", hasBody = true) + Call deleteOrder(@Path("orderId") String orderId); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("user") + Call createUser(@Body User body); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("user/createWithArray") + Call createUsersWithArrayInput(@Body List body); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("user/createWithList") + Call createUsersWithListInput(@Body List body); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("user/login") + Call loginUser(@Query("username") String username, @Query("password") String password); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("user/logout") + Call logoutUser(); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("user/{username}") + Call getUserByName(@Path("username") String username); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("user/{username}") + Call updateUser(@Path("username") String username, @Body User body); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "user/{username}", method = "DELETE", hasBody = true) + Call deleteUser(@Path("username") String username); + + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse addPetUsingByteArray() throws ServiceException, IOException { + final String body = null; + Call call = service.addPetUsingByteArray(body); + return addPetUsingByteArrayDelegate(call.execute()); + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall addPetUsingByteArrayAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final String body = null; + Call call = service.addPetUsingByteArray(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(addPetUsingByteArrayDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store. + * + * @param body Pet object in the form of byte array + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse addPetUsingByteArray(String body) throws ServiceException, IOException { + Call call = service.addPetUsingByteArray(body); + return addPetUsingByteArrayDelegate(call.execute()); + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store. + * + * @param body Pet object in the form of byte array + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall addPetUsingByteArrayAsync(String body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.addPetUsingByteArray(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(addPetUsingByteArrayDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse addPetUsingByteArrayDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(405, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Add a new pet to the store. + * Adds a new pet to the store. You may receive an HTTP invalid input if your pet is invalid. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse addPet() throws ServiceException, IOException { + final Pet body = null; + Call call = service.addPet(body); + return addPetDelegate(call.execute()); + } + + /** + * Add a new pet to the store. + * Adds a new pet to the store. You may receive an HTTP invalid input if your pet is invalid. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall addPetAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final Pet body = null; + Call call = service.addPet(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(addPetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Add a new pet to the store. + * Adds a new pet to the store. You may receive an HTTP invalid input if your pet is invalid. + * + * @param body Pet object that needs to be added to the store + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse addPet(Pet body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.addPet(body); + return addPetDelegate(call.execute()); + } + + /** + * Add a new pet to the store. + * Adds a new pet to the store. You may receive an HTTP invalid input if your pet is invalid. + * + * @param body Pet object that needs to be added to the store + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall addPetAsync(Pet body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.addPet(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(addPetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse addPetDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(405, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Update an existing pet. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updatePet() throws ServiceException, IOException { + final Pet body = null; + Call call = service.updatePet(body); + return updatePetDelegate(call.execute()); + } + + /** + * Update an existing pet. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updatePetAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final Pet body = null; + Call call = service.updatePet(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updatePetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Update an existing pet. + * + * @param body Pet object that needs to be added to the store + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updatePet(Pet body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.updatePet(body); + return updatePetDelegate(call.execute()); + } + + /** + * Update an existing pet. + * + * @param body Pet object that needs to be added to the store + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updatePetAsync(Pet body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.updatePet(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updatePetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updatePetDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(405, new TypeToken() { }.getType()) + .register(404, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Finds Pets by status. + * Multiple status values can be provided with comma seperated strings. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Pet> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> findPetsByStatus() throws ServiceException, IOException { + final List status = null; + String statusConverted = this.mapperAdapter().serializeList(status, CollectionFormat.CSV); + Call call = service.findPetsByStatus(statusConverted); + return findPetsByStatusDelegate(call.execute()); + } + + /** + * Finds Pets by status. + * Multiple status values can be provided with comma seperated strings. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall findPetsByStatusAsync(final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final List status = null; + String statusConverted = this.mapperAdapter().serializeList(status, CollectionFormat.CSV); + Call call = service.findPetsByStatus(statusConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(findPetsByStatusDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Finds Pets by status. + * Multiple status values can be provided with comma seperated strings. + * + * @param status Status values that need to be considered for filter + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Pet> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> findPetsByStatus(List status) throws ServiceException, IOException { + Validator.validate(status); + String statusConverted = this.mapperAdapter().serializeList(status, CollectionFormat.CSV); + Call call = service.findPetsByStatus(statusConverted); + return findPetsByStatusDelegate(call.execute()); + } + + /** + * Finds Pets by status. + * Multiple status values can be provided with comma seperated strings. + * + * @param status Status values that need to be considered for filter + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall findPetsByStatusAsync(List status, final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(status, serviceCallback); + String statusConverted = this.mapperAdapter().serializeList(status, CollectionFormat.CSV); + Call call = service.findPetsByStatus(statusConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(findPetsByStatusDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> findPetsByStatusDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder, ServiceException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Finds Pets by tags. + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Pet> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> findPetsByTags() throws ServiceException, IOException { + final List tags = null; + String tagsConverted = this.mapperAdapter().serializeList(tags, CollectionFormat.CSV); + Call call = service.findPetsByTags(tagsConverted); + return findPetsByTagsDelegate(call.execute()); + } + + /** + * Finds Pets by tags. + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall findPetsByTagsAsync(final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final List tags = null; + String tagsConverted = this.mapperAdapter().serializeList(tags, CollectionFormat.CSV); + Call call = service.findPetsByTags(tagsConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(findPetsByTagsDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Finds Pets by tags. + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * + * @param tags Tags to filter by + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Pet> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> findPetsByTags(List tags) throws ServiceException, IOException { + Validator.validate(tags); + String tagsConverted = this.mapperAdapter().serializeList(tags, CollectionFormat.CSV); + Call call = service.findPetsByTags(tagsConverted); + return findPetsByTagsDelegate(call.execute()); + } + + /** + * Finds Pets by tags. + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * + * @param tags Tags to filter by + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall findPetsByTagsAsync(List tags, final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(tags, serviceCallback); + String tagsConverted = this.mapperAdapter().serializeList(tags, CollectionFormat.CSV); + Call call = service.findPetsByTags(tagsConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(findPetsByTagsDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> findPetsByTagsDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder, ServiceException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID'. + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. + * + * @param petId ID of pet that needs to be fetched + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the String object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse findPetsWithByteArray(long petId) throws ServiceException, IOException { + Call call = service.findPetsWithByteArray(petId); + return findPetsWithByteArrayDelegate(call.execute()); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID'. + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. + * + * @param petId ID of pet that needs to be fetched + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall findPetsWithByteArrayAsync(long petId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.findPetsWithByteArray(petId); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(findPetsWithByteArrayDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse findPetsWithByteArrayDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Find pet by ID. + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. + * + * @param petId ID of pet that needs to be fetched + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the Pet object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getPetById(long petId) throws ServiceException, IOException { + Call call = service.getPetById(petId); + return getPetByIdDelegate(call.execute()); + } + + /** + * Find pet by ID. + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. + * + * @param petId ID of pet that needs to be fetched + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getPetByIdAsync(long petId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.getPetById(petId); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getPetByIdDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getPetByIdDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Updates a pet in the store with form data. + * + * @param petId ID of pet that needs to be updated + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updatePetWithForm(String petId) throws ServiceException, IOException, IllegalArgumentException { + if (petId == null) { + throw new IllegalArgumentException("Parameter petId is required and cannot be null."); + } + final String name = null; + final String status = null; + Call call = service.updatePetWithForm(petId, name, status); + return updatePetWithFormDelegate(call.execute()); + } + + /** + * Updates a pet in the store with form data. + * + * @param petId ID of pet that needs to be updated + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updatePetWithFormAsync(String petId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (petId == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter petId is required and cannot be null.")); + return null; + } + final String name = null; + final String status = null; + Call call = service.updatePetWithForm(petId, name, status); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updatePetWithFormDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates a pet in the store with form data. + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updatePetWithForm(String petId, String name, String status) throws ServiceException, IOException, IllegalArgumentException { + if (petId == null) { + throw new IllegalArgumentException("Parameter petId is required and cannot be null."); + } + Call call = service.updatePetWithForm(petId, name, status); + return updatePetWithFormDelegate(call.execute()); + } + + /** + * Updates a pet in the store with form data. + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updatePetWithFormAsync(String petId, String name, String status, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (petId == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter petId is required and cannot be null.")); + return null; + } + Call call = service.updatePetWithForm(petId, name, status); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updatePetWithFormDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updatePetWithFormDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(405, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Deletes a pet. + * + * @param petId Pet id to delete + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse deletePet(long petId) throws ServiceException, IOException { + final String apiKey = null; + Call call = service.deletePet(petId, apiKey); + return deletePetDelegate(call.execute()); + } + + /** + * Deletes a pet. + * + * @param petId Pet id to delete + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deletePetAsync(long petId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final String apiKey = null; + Call call = service.deletePet(petId, apiKey); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deletePetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Deletes a pet. + * + * @param petId Pet id to delete + * @param apiKey + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse deletePet(long petId, String apiKey) throws ServiceException, IOException { + Call call = service.deletePet(petId, apiKey); + return deletePetDelegate(call.execute()); + } + + /** + * Deletes a pet. + * + * @param petId Pet id to delete + * @param apiKey + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deletePetAsync(long petId, String apiKey, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.deletePet(petId, apiKey); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deletePetDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deletePetDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * uploads an image. + * + * @param petId ID of pet to update + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse uploadFile(long petId) throws ServiceException, IOException { + final String additionalMetadata = null; + final byte[] file = new byte[0]; + RequestBody fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), new byte[0]); + if (file != null) { + fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), file); + } + Call call = service.uploadFile(petId, additionalMetadata, fileConverted); + return uploadFileDelegate(call.execute()); + } + + /** + * uploads an image. + * + * @param petId ID of pet to update + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall uploadFileAsync(long petId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final String additionalMetadata = null; + final byte[] file = new byte[0]; + RequestBody fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), new byte[0]); + if (file != null) { + fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), file); + } + Call call = service.uploadFile(petId, additionalMetadata, fileConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(uploadFileDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * uploads an image. + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse uploadFile(long petId, String additionalMetadata, byte[] file) throws ServiceException, IOException { + RequestBody fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), new byte[0]); + if (file != null) { + fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), file); + } + Call call = service.uploadFile(petId, additionalMetadata, fileConverted); + return uploadFileDelegate(call.execute()); + } + + /** + * uploads an image. + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall uploadFileAsync(long petId, String additionalMetadata, byte[] file, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + RequestBody fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), new byte[0]); + if (file != null) { + fileConverted = RequestBody.create(MediaType.parse("multipart/form-data"), file); + } + Call call = service.uploadFile(petId, additionalMetadata, fileConverted); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(uploadFileDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse uploadFileDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .build(response); + } + + /** + * Returns pet inventories by status. + * Returns a map of status codes to quantities. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the Map<String, Integer> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getInventory() throws ServiceException, IOException { + Call call = service.getInventory(); + return getInventoryDelegate(call.execute()); + } + + /** + * Returns pet inventories by status. + * Returns a map of status codes to quantities. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getInventoryAsync(final ServiceCallback> serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.getInventory(); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getInventoryDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getInventoryDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder, ServiceException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .build(response); + } + + /** + * Place an order for a pet. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the Order object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse placeOrder() throws ServiceException, IOException { + final Order body = null; + Call call = service.placeOrder(body); + return placeOrderDelegate(call.execute()); + } + + /** + * Place an order for a pet. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall placeOrderAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final Order body = null; + Call call = service.placeOrder(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(placeOrderDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Place an order for a pet. + * + * @param body order placed for purchasing the pet + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the Order object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse placeOrder(Order body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.placeOrder(body); + return placeOrderDelegate(call.execute()); + } + + /** + * Place an order for a pet. + * + * @param body order placed for purchasing the pet + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall placeOrderAsync(Order body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.placeOrder(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(placeOrderDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse placeOrderDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Find purchase order by ID. + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions. + * + * @param orderId ID of pet that needs to be fetched + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the Order object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getOrderById(String orderId) throws ServiceException, IOException, IllegalArgumentException { + if (orderId == null) { + throw new IllegalArgumentException("Parameter orderId is required and cannot be null."); + } + Call call = service.getOrderById(orderId); + return getOrderByIdDelegate(call.execute()); + } + + /** + * Find purchase order by ID. + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions. + * + * @param orderId ID of pet that needs to be fetched + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getOrderByIdAsync(String orderId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (orderId == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter orderId is required and cannot be null.")); + return null; + } + Call call = service.getOrderById(orderId); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getOrderByIdDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getOrderByIdDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Delete purchase order by ID. + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors. + * + * @param orderId ID of the order that needs to be deleted + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse deleteOrder(String orderId) throws ServiceException, IOException, IllegalArgumentException { + if (orderId == null) { + throw new IllegalArgumentException("Parameter orderId is required and cannot be null."); + } + Call call = service.deleteOrder(orderId); + return deleteOrderDelegate(call.execute()); + } + + /** + * Delete purchase order by ID. + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors. + * + * @param orderId ID of the order that needs to be deleted + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteOrderAsync(String orderId, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (orderId == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter orderId is required and cannot be null.")); + return null; + } + Call call = service.deleteOrder(orderId); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteOrderDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteOrderDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Create user. + * This can only be done by the logged in user. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUser() throws ServiceException, IOException { + final User body = null; + Call call = service.createUser(body); + return createUserDelegate(call.execute()); + } + + /** + * Create user. + * This can only be done by the logged in user. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUserAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final User body = null; + Call call = service.createUser(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Create user. + * This can only be done by the logged in user. + * + * @param body Created user object + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUser(User body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.createUser(body); + return createUserDelegate(call.execute()); + } + + /** + * Create user. + * This can only be done by the logged in user. + * + * @param body Created user object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUserAsync(User body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.createUser(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse createUserDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .build(response); + } + + /** + * Creates list of users with given input array. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUsersWithArrayInput() throws ServiceException, IOException { + final List body = null; + Call call = service.createUsersWithArrayInput(body); + return createUsersWithArrayInputDelegate(call.execute()); + } + + /** + * Creates list of users with given input array. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUsersWithArrayInputAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final List body = null; + Call call = service.createUsersWithArrayInput(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUsersWithArrayInputDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Creates list of users with given input array. + * + * @param body List of user object + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUsersWithArrayInput(List body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.createUsersWithArrayInput(body); + return createUsersWithArrayInputDelegate(call.execute()); + } + + /** + * Creates list of users with given input array. + * + * @param body List of user object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUsersWithArrayInputAsync(List body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.createUsersWithArrayInput(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUsersWithArrayInputDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse createUsersWithArrayInputDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .build(response); + } + + /** + * Creates list of users with given input array. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUsersWithListInput() throws ServiceException, IOException { + final List body = null; + Call call = service.createUsersWithListInput(body); + return createUsersWithListInputDelegate(call.execute()); + } + + /** + * Creates list of users with given input array. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUsersWithListInputAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final List body = null; + Call call = service.createUsersWithListInput(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUsersWithListInputDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Creates list of users with given input array. + * + * @param body List of user object + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse createUsersWithListInput(List body) throws ServiceException, IOException { + Validator.validate(body); + Call call = service.createUsersWithListInput(body); + return createUsersWithListInputDelegate(call.execute()); + } + + /** + * Creates list of users with given input array. + * + * @param body List of user object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createUsersWithListInputAsync(List body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(body, serviceCallback); + Call call = service.createUsersWithListInput(body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createUsersWithListInputDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse createUsersWithListInputDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .build(response); + } + + /** + * Logs user into the system. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the String object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse loginUser() throws ServiceException, IOException { + final String username = null; + final String password = null; + Call call = service.loginUser(username, password); + return loginUserDelegate(call.execute()); + } + + /** + * Logs user into the system. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall loginUserAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final String username = null; + final String password = null; + Call call = service.loginUser(username, password); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(loginUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Logs user into the system. + * + * @param username The user name for login + * @param password The password for login in clear text + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the String object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse loginUser(String username, String password) throws ServiceException, IOException { + Call call = service.loginUser(username, password); + return loginUserDelegate(call.execute()); + } + + /** + * Logs user into the system. + * + * @param username The user name for login + * @param password The password for login in clear text + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall loginUserAsync(String username, String password, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.loginUser(username, password); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(loginUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse loginUserDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Logs out current logged in user session. + * + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse logoutUser() throws ServiceException, IOException { + Call call = service.logoutUser(); + return logoutUserDelegate(call.execute()); + } + + /** + * Logs out current logged in user session. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall logoutUserAsync(final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Call call = service.logoutUser(); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(logoutUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse logoutUserDelegate(Response response) throws ServiceException, IOException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .build(response); + } + + /** + * Get user by user name. + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the User object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getUserByName(String username) throws ServiceException, IOException, IllegalArgumentException { + if (username == null) { + throw new IllegalArgumentException("Parameter username is required and cannot be null."); + } + Call call = service.getUserByName(username); + return getUserByNameDelegate(call.execute()); + } + + /** + * Get user by user name. + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getUserByNameAsync(String username, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (username == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter username is required and cannot be null.")); + return null; + } + Call call = service.getUserByName(username); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getUserByNameDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getUserByNameDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(200, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Updated user. + * This can only be done by the logged in user. + * + * @param username name that need to be deleted + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updateUser(String username) throws ServiceException, IOException, IllegalArgumentException { + if (username == null) { + throw new IllegalArgumentException("Parameter username is required and cannot be null."); + } + final User body = null; + Call call = service.updateUser(username, body); + return updateUserDelegate(call.execute()); + } + + /** + * Updated user. + * This can only be done by the logged in user. + * + * @param username name that need to be deleted + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateUserAsync(String username, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (username == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter username is required and cannot be null.")); + return null; + } + final User body = null; + Call call = service.updateUser(username, body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updated user. + * This can only be done by the logged in user. + * + * @param username name that need to be deleted + * @param body Updated user object + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse updateUser(String username, User body) throws ServiceException, IOException, IllegalArgumentException { + if (username == null) { + throw new IllegalArgumentException("Parameter username is required and cannot be null."); + } + Validator.validate(body); + Call call = service.updateUser(username, body); + return updateUserDelegate(call.execute()); + } + + /** + * Updated user. + * This can only be done by the logged in user. + * + * @param username name that need to be deleted + * @param body Updated user object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateUserAsync(String username, User body, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (username == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter username is required and cannot be null.")); + return null; + } + Validator.validate(body, serviceCallback); + Call call = service.updateUser(username, body); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateUserDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Delete user. + * This can only be done by the logged in user. + * + * @param username The name that needs to be deleted + * @throws ServiceException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse deleteUser(String username) throws ServiceException, IOException, IllegalArgumentException { + if (username == null) { + throw new IllegalArgumentException("Parameter username is required and cannot be null."); + } + Call call = service.deleteUser(username); + return deleteUserDelegate(call.execute()); + } + + /** + * Delete user. + * This can only be done by the logged in user. + * + * @param username The name that needs to be deleted + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteUserAsync(String username, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (username == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter username is required and cannot be null.")); + return null; + } + Call call = service.deleteUser(username); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteUserDelegate(response)); + } catch (ServiceException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteUserDelegate(Response response) throws ServiceException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.mapperAdapter()) + .register(404, new TypeToken() { }.getType()) + .register(400, new TypeToken() { }.getType()) + .build(response); + } + +} diff --git a/Samples/petstore/Java/implementation/package-info.java b/Samples/petstore/Java/implementation/package-info.java new file mode 100644 index 0000000000000..dcf337f4ad119 --- /dev/null +++ b/Samples/petstore/Java/implementation/package-info.java @@ -0,0 +1,6 @@ + +/** + * This package contains the implementation classes for SwaggerPetstore. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters. + */ +package petstore.implementation; diff --git a/Samples/petstore/Java/models/Category.java b/Samples/petstore/Java/models/Category.java index 3a2ff6ff8ae46..4b7d01e1d1c1f 100644 --- a/Samples/petstore/Java/models/Category.java +++ b/Samples/petstore/Java/models/Category.java @@ -23,7 +23,7 @@ public class Category { * * @return the id value */ - public Long getId() { + public Long id() { return this.id; } @@ -31,9 +31,11 @@ public Long getId() { * Set the id value. * * @param id the id value to set + * @return the Category object itself. */ - public void setId(Long id) { + public Category withId(Long id) { this.id = id; + return this; } /** @@ -41,7 +43,7 @@ public void setId(Long id) { * * @return the name value */ - public String getName() { + public String name() { return this.name; } @@ -49,9 +51,11 @@ public String getName() { * Set the name value. * * @param name the name value to set + * @return the Category object itself. */ - public void setName(String name) { + public Category withName(String name) { this.name = name; + return this; } } diff --git a/Samples/petstore/Java/models/Order.java b/Samples/petstore/Java/models/Order.java index 6a884a05c294b..a5c2ccdf9b9dd 100644 --- a/Samples/petstore/Java/models/Order.java +++ b/Samples/petstore/Java/models/Order.java @@ -47,7 +47,7 @@ public class Order { * * @return the id value */ - public Long getId() { + public Long id() { return this.id; } @@ -56,7 +56,7 @@ public Long getId() { * * @return the petId value */ - public Long getPetId() { + public Long petId() { return this.petId; } @@ -64,9 +64,11 @@ public Long getPetId() { * Set the petId value. * * @param petId the petId value to set + * @return the Order object itself. */ - public void setPetId(Long petId) { + public Order withPetId(Long petId) { this.petId = petId; + return this; } /** @@ -74,7 +76,7 @@ public void setPetId(Long petId) { * * @return the quantity value */ - public Integer getQuantity() { + public Integer quantity() { return this.quantity; } @@ -82,9 +84,11 @@ public Integer getQuantity() { * Set the quantity value. * * @param quantity the quantity value to set + * @return the Order object itself. */ - public void setQuantity(Integer quantity) { + public Order withQuantity(Integer quantity) { this.quantity = quantity; + return this; } /** @@ -92,7 +96,7 @@ public void setQuantity(Integer quantity) { * * @return the shipDate value */ - public DateTime getShipDate() { + public DateTime shipDate() { return this.shipDate; } @@ -100,9 +104,11 @@ public DateTime getShipDate() { * Set the shipDate value. * * @param shipDate the shipDate value to set + * @return the Order object itself. */ - public void setShipDate(DateTime shipDate) { + public Order withShipDate(DateTime shipDate) { this.shipDate = shipDate; + return this; } /** @@ -110,7 +116,7 @@ public void setShipDate(DateTime shipDate) { * * @return the status value */ - public String getStatus() { + public String status() { return this.status; } @@ -118,9 +124,11 @@ public String getStatus() { * Set the status value. * * @param status the status value to set + * @return the Order object itself. */ - public void setStatus(String status) { + public Order withStatus(String status) { this.status = status; + return this; } /** @@ -128,7 +136,7 @@ public void setStatus(String status) { * * @return the complete value */ - public Boolean getComplete() { + public Boolean complete() { return this.complete; } @@ -136,9 +144,11 @@ public Boolean getComplete() { * Set the complete value. * * @param complete the complete value to set + * @return the Order object itself. */ - public void setComplete(Boolean complete) { + public Order withComplete(Boolean complete) { this.complete = complete; + return this; } } diff --git a/Samples/petstore/Java/models/Pet.java b/Samples/petstore/Java/models/Pet.java index 0874ad087f027..5b98ed9aeec12 100644 --- a/Samples/petstore/Java/models/Pet.java +++ b/Samples/petstore/Java/models/Pet.java @@ -50,7 +50,7 @@ public class Pet { * * @return the id value */ - public Long getId() { + public Long id() { return this.id; } @@ -58,9 +58,11 @@ public Long getId() { * Set the id value. * * @param id the id value to set + * @return the Pet object itself. */ - public void setId(Long id) { + public Pet withId(Long id) { this.id = id; + return this; } /** @@ -68,7 +70,7 @@ public void setId(Long id) { * * @return the category value */ - public Category getCategory() { + public Category category() { return this.category; } @@ -76,9 +78,11 @@ public Category getCategory() { * Set the category value. * * @param category the category value to set + * @return the Pet object itself. */ - public void setCategory(Category category) { + public Pet withCategory(Category category) { this.category = category; + return this; } /** @@ -86,7 +90,7 @@ public void setCategory(Category category) { * * @return the name value */ - public String getName() { + public String name() { return this.name; } @@ -94,9 +98,11 @@ public String getName() { * Set the name value. * * @param name the name value to set + * @return the Pet object itself. */ - public void setName(String name) { + public Pet withName(String name) { this.name = name; + return this; } /** @@ -104,7 +110,7 @@ public void setName(String name) { * * @return the photoUrls value */ - public List getPhotoUrls() { + public List photoUrls() { return this.photoUrls; } @@ -112,9 +118,11 @@ public List getPhotoUrls() { * Set the photoUrls value. * * @param photoUrls the photoUrls value to set + * @return the Pet object itself. */ - public void setPhotoUrls(List photoUrls) { + public Pet withPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; + return this; } /** @@ -122,7 +130,7 @@ public void setPhotoUrls(List photoUrls) { * * @return the tags value */ - public List getTags() { + public List tags() { return this.tags; } @@ -130,9 +138,11 @@ public List getTags() { * Set the tags value. * * @param tags the tags value to set + * @return the Pet object itself. */ - public void setTags(List tags) { + public Pet withTags(List tags) { this.tags = tags; + return this; } /** @@ -140,7 +150,7 @@ public void setTags(List tags) { * * @return the status value */ - public String getStatus() { + public String status() { return this.status; } @@ -148,9 +158,11 @@ public String getStatus() { * Set the status value. * * @param status the status value to set + * @return the Pet object itself. */ - public void setStatus(String status) { + public Pet withStatus(String status) { this.status = status; + return this; } } diff --git a/Samples/petstore/Java/models/Tag.java b/Samples/petstore/Java/models/Tag.java index 854bd5fe88f9f..5ac2309092f32 100644 --- a/Samples/petstore/Java/models/Tag.java +++ b/Samples/petstore/Java/models/Tag.java @@ -23,7 +23,7 @@ public class Tag { * * @return the id value */ - public Long getId() { + public Long id() { return this.id; } @@ -31,9 +31,11 @@ public Long getId() { * Set the id value. * * @param id the id value to set + * @return the Tag object itself. */ - public void setId(Long id) { + public Tag withId(Long id) { this.id = id; + return this; } /** @@ -41,7 +43,7 @@ public void setId(Long id) { * * @return the name value */ - public String getName() { + public String name() { return this.name; } @@ -49,9 +51,11 @@ public String getName() { * Set the name value. * * @param name the name value to set + * @return the Tag object itself. */ - public void setName(String name) { + public Tag withName(String name) { this.name = name; + return this; } } diff --git a/Samples/petstore/Java/models/User.java b/Samples/petstore/Java/models/User.java index f9e852df64fb1..d039482e93e9f 100644 --- a/Samples/petstore/Java/models/User.java +++ b/Samples/petstore/Java/models/User.java @@ -53,7 +53,7 @@ public class User { * * @return the id value */ - public Long getId() { + public Long id() { return this.id; } @@ -61,9 +61,11 @@ public Long getId() { * Set the id value. * * @param id the id value to set + * @return the User object itself. */ - public void setId(Long id) { + public User withId(Long id) { this.id = id; + return this; } /** @@ -71,7 +73,7 @@ public void setId(Long id) { * * @return the username value */ - public String getUsername() { + public String username() { return this.username; } @@ -79,9 +81,11 @@ public String getUsername() { * Set the username value. * * @param username the username value to set + * @return the User object itself. */ - public void setUsername(String username) { + public User withUsername(String username) { this.username = username; + return this; } /** @@ -89,7 +93,7 @@ public void setUsername(String username) { * * @return the firstName value */ - public String getFirstName() { + public String firstName() { return this.firstName; } @@ -97,9 +101,11 @@ public String getFirstName() { * Set the firstName value. * * @param firstName the firstName value to set + * @return the User object itself. */ - public void setFirstName(String firstName) { + public User withFirstName(String firstName) { this.firstName = firstName; + return this; } /** @@ -107,7 +113,7 @@ public void setFirstName(String firstName) { * * @return the lastName value */ - public String getLastName() { + public String lastName() { return this.lastName; } @@ -115,9 +121,11 @@ public String getLastName() { * Set the lastName value. * * @param lastName the lastName value to set + * @return the User object itself. */ - public void setLastName(String lastName) { + public User withLastName(String lastName) { this.lastName = lastName; + return this; } /** @@ -125,7 +133,7 @@ public void setLastName(String lastName) { * * @return the email value */ - public String getEmail() { + public String email() { return this.email; } @@ -133,9 +141,11 @@ public String getEmail() { * Set the email value. * * @param email the email value to set + * @return the User object itself. */ - public void setEmail(String email) { + public User withEmail(String email) { this.email = email; + return this; } /** @@ -143,7 +153,7 @@ public void setEmail(String email) { * * @return the password value */ - public String getPassword() { + public String password() { return this.password; } @@ -151,9 +161,11 @@ public String getPassword() { * Set the password value. * * @param password the password value to set + * @return the User object itself. */ - public void setPassword(String password) { + public User withPassword(String password) { this.password = password; + return this; } /** @@ -161,7 +173,7 @@ public void setPassword(String password) { * * @return the phone value */ - public String getPhone() { + public String phone() { return this.phone; } @@ -169,9 +181,11 @@ public String getPhone() { * Set the phone value. * * @param phone the phone value to set + * @return the User object itself. */ - public void setPhone(String phone) { + public User withPhone(String phone) { this.phone = phone; + return this; } /** @@ -179,7 +193,7 @@ public void setPhone(String phone) { * * @return the userStatus value */ - public Integer getUserStatus() { + public Integer userStatus() { return this.userStatus; } @@ -187,9 +201,11 @@ public Integer getUserStatus() { * Set the userStatus value. * * @param userStatus the userStatus value to set + * @return the User object itself. */ - public void setUserStatus(Integer userStatus) { + public User withUserStatus(Integer userStatus) { this.userStatus = userStatus; + return this; } } diff --git a/Samples/petstore/Java/models/package-info.java b/Samples/petstore/Java/models/package-info.java index 792df75d6df8a..bf206d6d04a61 100644 --- a/Samples/petstore/Java/models/package-info.java +++ b/Samples/petstore/Java/models/package-info.java @@ -1,6 +1,6 @@ /** - * This package contains the model classes for SwaggerPetstore. + * This package contains the models classes for SwaggerPetstore. * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters. */ package petstore.models;