diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/DatabaseAccounts.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/DatabaseAccounts.java index 78943dd10b53..f25304c7f345 100644 --- a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/DatabaseAccounts.java +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/DatabaseAccounts.java @@ -23,6 +23,7 @@ import com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccountUsage; import com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccountMetricDefinition; import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlContainer; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedure; import com.microsoft.azure.management.cosmosdb.v2015_04_08.MongoDBCollection; import com.microsoft.azure.management.cosmosdb.v2015_04_08.GremlinGraph; @@ -44,6 +45,13 @@ public interface DatabaseAccounts extends SupportsCreating getSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName); + + /** + * Lists the SQL stored procedures under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listSqlStoredProceduresAsync(String resourceGroupName, String accountName, String databaseName, String containerName); + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Completable deleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName); + /** * Gets the MongoDB collection under an existing Azure Cosmos DB database account. * diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedure.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedure.java new file mode 100644 index 000000000000..88ea441b2cb8 --- /dev/null +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedure.java @@ -0,0 +1,150 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.cosmosdb.v2015_04_08; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.implementation.SqlStoredProcedureInner; +import com.microsoft.azure.arm.model.Indexable; +import com.microsoft.azure.arm.model.Refreshable; +import com.microsoft.azure.arm.model.Updatable; +import com.microsoft.azure.arm.model.Appliable; +import com.microsoft.azure.arm.model.Creatable; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.implementation.CosmosDBManager; +import java.util.Map; + +/** + * Type representing SqlStoredProcedure. + */ +public interface SqlStoredProcedure extends HasInner, Indexable, Refreshable, Updatable, HasManager { + /** + * @return the _etag value. + */ + String _etag(); + + /** + * @return the _rid value. + */ + String _rid(); + + /** + * @return the _ts value. + */ + Object _ts(); + + /** + * @return the body value. + */ + String body(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the location value. + */ + String location(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the sqlStoredProcedureId value. + */ + String sqlStoredProcedureId(); + + /** + * @return the tags value. + */ + Map tags(); + + /** + * @return the type value. + */ + String type(); + + /** + * The entirety of the SqlStoredProcedure definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithContainer, DefinitionStages.WithOptions, DefinitionStages.WithResource, DefinitionStages.WithCreate { + } + + /** + * Grouping of SqlStoredProcedure definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a SqlStoredProcedure definition. + */ + interface Blank extends WithContainer { + } + + /** + * The stage of the sqlstoredprocedure definition allowing to specify Container. + */ + interface WithContainer { + /** + * Specifies resourceGroupName, accountName, databaseName, containerName. + * @param resourceGroupName Name of an Azure resource group + * @param accountName Cosmos DB database account name + * @param databaseName Cosmos DB database name + * @param containerName Cosmos DB container name + * @return the next definition stage + */ + WithOptions withExistingContainer(String resourceGroupName, String accountName, String databaseName, String containerName); + } + + /** + * The stage of the sqlstoredprocedure definition allowing to specify Options. + */ + interface WithOptions { + /** + * Specifies options. + * @param options A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request + * @return the next definition stage + */ + WithResource withOptions(Map options); + } + + /** + * The stage of the sqlstoredprocedure definition allowing to specify Resource. + */ + interface WithResource { + /** + * Specifies resource. + * @param resource The standard JSON format of a stored procedure + * @return the next definition stage + */ + WithCreate withResource(SqlStoredProcedureResource resource); + } + + /** + * The stage of the definition which contains all the minimum required inputs for + * the resource to be created (via {@link WithCreate#create()}), but also allows + * for any other optional settings to be specified. + */ + interface WithCreate extends Creatable { + } + } + /** + * The template for a SqlStoredProcedure update operation, containing all the settings that can be modified. + */ + interface Update extends Appliable { + } + + /** + * Grouping of SqlStoredProcedure update stages. + */ + interface UpdateStages { + } +} diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureCreateUpdateParameters.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureCreateUpdateParameters.java new file mode 100644 index 000000000000..0e119afd7d65 --- /dev/null +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureCreateUpdateParameters.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.cosmosdb.v2015_04_08; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * Parameters to create and update Cosmos DB stored procedure. + */ +@JsonFlatten +public class SqlStoredProcedureCreateUpdateParameters { + /** + * The standard JSON format of a stored procedure. + */ + @JsonProperty(value = "properties.resource", required = true) + private SqlStoredProcedureResource resource; + + /** + * A key-value pair of options to be applied for the request. This + * corresponds to the headers sent with the request. + */ + @JsonProperty(value = "properties.options", required = true) + private Map options; + + /** + * Get the standard JSON format of a stored procedure. + * + * @return the resource value + */ + public SqlStoredProcedureResource resource() { + return this.resource; + } + + /** + * Set the standard JSON format of a stored procedure. + * + * @param resource the resource value to set + * @return the SqlStoredProcedureCreateUpdateParameters object itself. + */ + public SqlStoredProcedureCreateUpdateParameters withResource(SqlStoredProcedureResource resource) { + this.resource = resource; + return this; + } + + /** + * Get a key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + * + * @return the options value + */ + public Map options() { + return this.options; + } + + /** + * Set a key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + * + * @param options the options value to set + * @return the SqlStoredProcedureCreateUpdateParameters object itself. + */ + public SqlStoredProcedureCreateUpdateParameters withOptions(Map options) { + this.options = options; + return this; + } + +} diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureResource.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureResource.java new file mode 100644 index 000000000000..eeafad6d07be --- /dev/null +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/SqlStoredProcedureResource.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.cosmosdb.v2015_04_08; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Cosmos DB Gremlin graph resource object. + */ +public class SqlStoredProcedureResource { + /** + * Name of the Sql Stored Procedure. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Body of the Stored Procedure. + */ + @JsonProperty(value = "body") + private String body; + + /** + * Get name of the Sql Stored Procedure. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set name of the Sql Stored Procedure. + * + * @param id the id value to set + * @return the SqlStoredProcedureResource object itself. + */ + public SqlStoredProcedureResource withId(String id) { + this.id = id; + return this; + } + + /** + * Get body of the Stored Procedure. + * + * @return the body value + */ + public String body() { + return this.body; + } + + /** + * Set body of the Stored Procedure. + * + * @param body the body value to set + * @return the SqlStoredProcedureResource object itself. + */ + public SqlStoredProcedureResource withBody(String body) { + this.body = body; + return this; + } + +} diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsImpl.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsImpl.java index f9f5a9d9338d..67e537056fd5 100644 --- a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsImpl.java +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsImpl.java @@ -39,6 +39,7 @@ import com.microsoft.azure.management.cosmosdb.v2015_04_08.Throughput; import com.microsoft.azure.management.cosmosdb.v2015_04_08.ThroughputResource; import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlContainer; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedure; import com.microsoft.azure.management.cosmosdb.v2015_04_08.MongoDBCollection; import com.microsoft.azure.management.cosmosdb.v2015_04_08.Table; import com.microsoft.azure.management.cosmosdb.v2015_04_08.CassandraTable; @@ -228,6 +229,11 @@ public SqlContainerImpl defineContainer(String name) { return wrapContainerModel(name); } + @Override + public SqlStoredProcedureImpl defineStoredProcedure(String name) { + return wrapStoredProcedureModel(name); + } + @Override public MongoDBCollectionImpl defineCollection(String name) { return wrapCollectionModel(name); @@ -256,6 +262,10 @@ private SqlContainerImpl wrapContainerModel(String name) { return new SqlContainerImpl(name, this.manager()); } + private SqlStoredProcedureImpl wrapStoredProcedureModel(String name) { + return new SqlStoredProcedureImpl(name, this.manager()); + } + private MongoDBCollectionImpl wrapCollectionModel(String name) { return new MongoDBCollectionImpl(name, this.manager()); } @@ -292,6 +302,10 @@ private SqlContainerImpl wrapSqlContainerModel(SqlContainerInner inner) { return new SqlContainerImpl(inner, manager()); } + private SqlStoredProcedureImpl wrapSqlStoredProcedureModel(SqlStoredProcedureInner inner) { + return new SqlStoredProcedureImpl(inner, manager()); + } + private MongoDBCollectionImpl wrapMongoDBCollectionModel(MongoDBCollectionInner inner) { return new MongoDBCollectionImpl(inner, manager()); } @@ -317,6 +331,16 @@ private Observable getSqlContainerInnerUsingDatabaseAccountsI return client.getSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName); } + private Observable getSqlStoredProcedureInnerUsingDatabaseAccountsInnerAsync(String id) { + String resourceGroupName = IdParsingUtils.getValueFromIdByName(id, "resourceGroups"); + String accountName = IdParsingUtils.getValueFromIdByName(id, "databaseAccounts"); + String databaseName = IdParsingUtils.getValueFromIdByName(id, "databases"); + String containerName = IdParsingUtils.getValueFromIdByName(id, "containers"); + String storedProcedureName = IdParsingUtils.getValueFromIdByName(id, "storedProcedures"); + DatabaseAccountsInner client = this.inner(); + return client.getSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName); + } + private Observable getMongoDBCollectionInnerUsingDatabaseAccountsInnerAsync(String id) { String resourceGroupName = IdParsingUtils.getValueFromIdByName(id, "resourceGroups"); String accountName = IdParsingUtils.getValueFromIdByName(id, "databaseAccounts"); @@ -791,6 +815,42 @@ public Completable deleteSqlContainerAsync(String resourceGroupName, String acco return client.deleteSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName).toCompletable(); } + @Override + public Observable getSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + DatabaseAccountsInner client = this.inner(); + return client.getSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName) + .map(new Func1() { + @Override + public SqlStoredProcedure call(SqlStoredProcedureInner inner) { + return wrapSqlStoredProcedureModel(inner); + } + }); + } + + @Override + public Observable listSqlStoredProceduresAsync(String resourceGroupName, String accountName, String databaseName, String containerName) { + DatabaseAccountsInner client = this.inner(); + return client.listSqlStoredProceduresAsync(resourceGroupName, accountName, databaseName, containerName) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(List innerList) { + return Observable.from(innerList); + } + }) + .map(new Func1() { + @Override + public SqlStoredProcedure call(SqlStoredProcedureInner inner) { + return wrapSqlStoredProcedureModel(inner); + } + }); + } + + @Override + public Completable deleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + DatabaseAccountsInner client = this.inner(); + return client.deleteSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).toCompletable(); + } + @Override public Observable getMongoDBCollectionAsync(String resourceGroupName, String accountName, String databaseName, String collectionName) { DatabaseAccountsInner client = this.inner(); diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java index 8cc3413ca963..1448952ed3fe 100644 --- a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java @@ -30,6 +30,7 @@ import com.microsoft.azure.management.cosmosdb.v2015_04_08.RegionForOnlineOffline; import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlContainerCreateUpdateParameters; import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlDatabaseCreateUpdateParameters; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedureCreateUpdateParameters; import com.microsoft.azure.management.cosmosdb.v2015_04_08.TableCreateUpdateParameters; import com.microsoft.azure.management.cosmosdb.v2015_04_08.ThroughputResource; import com.microsoft.azure.management.cosmosdb.v2015_04_08.ThroughputUpdateParameters; @@ -255,6 +256,30 @@ interface DatabaseAccountsService { @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput") Observable> beginUpdateSqlContainerThroughput(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body ThroughputUpdateParameters updateThroughputParameters, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts listSqlStoredProcedures" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures") + Observable> listSqlStoredProcedures(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts getSqlStoredProcedure" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") + Observable> getSqlStoredProcedure(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Path("storedProcedureName") String storedProcedureName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts createUpdateSqlStoredProcedure" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") + Observable> createUpdateSqlStoredProcedure(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Path("storedProcedureName") String storedProcedureName, @Query("api-version") String apiVersion, @Body SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts beginCreateUpdateSqlStoredProcedure" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") + Observable> beginCreateUpdateSqlStoredProcedure(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Path("storedProcedureName") String storedProcedureName, @Query("api-version") String apiVersion, @Body SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts deleteSqlStoredProcedure" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", method = "DELETE", hasBody = true) + Observable> deleteSqlStoredProcedure(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Path("storedProcedureName") String storedProcedureName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts beginDeleteSqlStoredProcedure" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", method = "DELETE", hasBody = true) + Observable> beginDeleteSqlStoredProcedure(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Path("databaseName") String databaseName, @Path("containerName") String containerName, @Path("storedProcedureName") String storedProcedureName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.v2015_04_08.DatabaseAccounts listMongoDBDatabases" }) @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases") Observable> listMongoDBDatabases(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("accountName") String accountName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @@ -4445,6 +4470,628 @@ private ServiceResponse beginUpdateSqlContainerThroughputDelega .build(response); } + /** + * Lists the SQL stored procedures under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SqlStoredProcedureInner> object if successful. + */ + public List listSqlStoredProcedures(String resourceGroupName, String accountName, String databaseName, String containerName) { + return listSqlStoredProceduresWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName).toBlocking().single().body(); + } + + /** + * Lists the SQL stored procedures under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listSqlStoredProceduresAsync(String resourceGroupName, String accountName, String databaseName, String containerName, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listSqlStoredProceduresWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName), serviceCallback); + } + + /** + * Lists the SQL stored procedures under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SqlStoredProcedureInner> object + */ + public Observable> listSqlStoredProceduresAsync(String resourceGroupName, String accountName, String databaseName, String containerName) { + return listSqlStoredProceduresWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Lists the SQL stored procedures under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SqlStoredProcedureInner> object + */ + public Observable>> listSqlStoredProceduresWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listSqlStoredProcedures(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listSqlStoredProceduresDelegate(response); + List items = null; + if (result.body() != null) { + items = result.body().items(); + } + ServiceResponse> clientResponse = new ServiceResponse>(items, result.response()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listSqlStoredProceduresDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets the SQL StoredProcedure under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SqlStoredProcedureInner object if successful. + */ + public SqlStoredProcedureInner getSqlStoredProcedure(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + return getSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).toBlocking().single().body(); + } + + /** + * Gets the SQL StoredProcedure under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName), serviceCallback); + } + + /** + * Gets the SQL StoredProcedure under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SqlStoredProcedureInner object + */ + public Observable getSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + return getSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).map(new Func1, SqlStoredProcedureInner>() { + @Override + public SqlStoredProcedureInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the SQL StoredProcedure under an existing Azure Cosmos DB database account. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SqlStoredProcedureInner object + */ + public Observable> getSqlStoredProcedureWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (storedProcedureName == null) { + throw new IllegalArgumentException("Parameter storedProcedureName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.getSqlStoredProcedure(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, storedProcedureName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getSqlStoredProcedureDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getSqlStoredProcedureDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SqlStoredProcedureInner object if successful. + */ + public SqlStoredProcedureInner createUpdateSqlStoredProcedure(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + return createUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).toBlocking().last().body(); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createUpdateSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters), serviceCallback); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable createUpdateSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + return createUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).map(new Func1, SqlStoredProcedureInner>() { + @Override + public SqlStoredProcedureInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> createUpdateSqlStoredProcedureWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (storedProcedureName == null) { + throw new IllegalArgumentException("Parameter storedProcedureName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createUpdateSqlStoredProcedureParameters == null) { + throw new IllegalArgumentException("Parameter createUpdateSqlStoredProcedureParameters is required and cannot be null."); + } + Validator.validate(createUpdateSqlStoredProcedureParameters); + Observable> observable = service.createUpdateSqlStoredProcedure(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, storedProcedureName, this.client.apiVersion(), createUpdateSqlStoredProcedureParameters, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SqlStoredProcedureInner object if successful. + */ + public SqlStoredProcedureInner beginCreateUpdateSqlStoredProcedure(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + return beginCreateUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).toBlocking().single().body(); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture beginCreateUpdateSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginCreateUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters), serviceCallback); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SqlStoredProcedureInner object + */ + public Observable beginCreateUpdateSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + return beginCreateUpdateSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).map(new Func1, SqlStoredProcedureInner>() { + @Override + public SqlStoredProcedureInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update an Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param createUpdateSqlStoredProcedureParameters The parameters to provide for the current SQL StoredProcedure. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SqlStoredProcedureInner object + */ + public Observable> beginCreateUpdateSqlStoredProcedureWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (storedProcedureName == null) { + throw new IllegalArgumentException("Parameter storedProcedureName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (createUpdateSqlStoredProcedureParameters == null) { + throw new IllegalArgumentException("Parameter createUpdateSqlStoredProcedureParameters is required and cannot be null."); + } + Validator.validate(createUpdateSqlStoredProcedureParameters); + return service.beginCreateUpdateSqlStoredProcedure(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, storedProcedureName, this.client.apiVersion(), createUpdateSqlStoredProcedureParameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginCreateUpdateSqlStoredProcedureDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginCreateUpdateSqlStoredProcedureDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteSqlStoredProcedure(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + deleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).toBlocking().last().body(); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName), serviceCallback); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable deleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + return deleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> deleteSqlStoredProcedureWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (storedProcedureName == null) { + throw new IllegalArgumentException("Parameter storedProcedureName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Observable> observable = service.deleteSqlStoredProcedure(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, storedProcedureName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void beginDeleteSqlStoredProcedure(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + beginDeleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).toBlocking().single().body(); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture beginDeleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginDeleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName), serviceCallback); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable beginDeleteSqlStoredProcedureAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + return beginDeleteSqlStoredProcedureWithServiceResponseAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes an existing Azure Cosmos DB SQL StoredProcedure. + * + * @param resourceGroupName Name of an Azure resource group. + * @param accountName Cosmos DB database account name. + * @param databaseName Cosmos DB database name. + * @param containerName Cosmos DB container name. + * @param storedProcedureName Cosmos DB SQL StoredProcedure name + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> beginDeleteSqlStoredProcedureWithServiceResponseAsync(String resourceGroupName, String accountName, String databaseName, String containerName, String storedProcedureName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (accountName == null) { + throw new IllegalArgumentException("Parameter accountName is required and cannot be null."); + } + if (databaseName == null) { + throw new IllegalArgumentException("Parameter databaseName is required and cannot be null."); + } + if (containerName == null) { + throw new IllegalArgumentException("Parameter containerName is required and cannot be null."); + } + if (storedProcedureName == null) { + throw new IllegalArgumentException("Parameter storedProcedureName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.beginDeleteSqlStoredProcedure(this.client.subscriptionId(), resourceGroupName, accountName, databaseName, containerName, storedProcedureName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginDeleteSqlStoredProcedureDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginDeleteSqlStoredProcedureDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + /** * Lists the MongoDB databases under an existing Azure Cosmos DB database account. * diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureImpl.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureImpl.java new file mode 100644 index 000000000000..caeefbc8b2e1 --- /dev/null +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureImpl.java @@ -0,0 +1,171 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.cosmosdb.v2015_04_08.implementation; + +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedure; +import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl; +import rx.Observable; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedureCreateUpdateParameters; +import java.util.Map; +import com.microsoft.azure.management.cosmosdb.v2015_04_08.SqlStoredProcedureResource; +import rx.functions.Func1; + +class SqlStoredProcedureImpl extends CreatableUpdatableImpl implements SqlStoredProcedure, SqlStoredProcedure.Definition, SqlStoredProcedure.Update { + private final CosmosDBManager manager; + private String resourceGroupName; + private String accountName; + private String databaseName; + private String containerName; + private String storedProcedureName; + private SqlStoredProcedureCreateUpdateParameters createOrUpdateParameter; + + SqlStoredProcedureImpl(String name, CosmosDBManager manager) { + super(name, new SqlStoredProcedureInner()); + this.manager = manager; + // Set resource name + this.storedProcedureName = name; + // + this.createOrUpdateParameter = new SqlStoredProcedureCreateUpdateParameters(); + } + + SqlStoredProcedureImpl(SqlStoredProcedureInner inner, CosmosDBManager manager) { + super(inner.name(), inner); + this.manager = manager; + // Set resource name + this.storedProcedureName = inner.name(); + // set resource ancestor and positional variables + this.resourceGroupName = IdParsingUtils.getValueFromIdByName(inner.id(), "resourceGroups"); + this.accountName = IdParsingUtils.getValueFromIdByName(inner.id(), "databaseAccounts"); + this.databaseName = IdParsingUtils.getValueFromIdByName(inner.id(), "databases"); + this.containerName = IdParsingUtils.getValueFromIdByName(inner.id(), "containers"); + this.storedProcedureName = IdParsingUtils.getValueFromIdByName(inner.id(), "storedProcedures"); + // + this.createOrUpdateParameter = new SqlStoredProcedureCreateUpdateParameters(); + } + + @Override + public CosmosDBManager manager() { + return this.manager; + } + + @Override + public Observable createResourceAsync() { + DatabaseAccountsInner client = this.manager().inner().databaseAccounts(); + return client.createUpdateSqlStoredProcedureAsync(this.resourceGroupName, this.accountName, this.databaseName, this.containerName, this.storedProcedureName, this.createOrUpdateParameter) + .map(new Func1() { + @Override + public SqlStoredProcedureInner call(SqlStoredProcedureInner resource) { + resetCreateUpdateParameters(); + return resource; + } + }) + .map(innerToFluentMap(this)); + } + + @Override + public Observable updateResourceAsync() { + DatabaseAccountsInner client = this.manager().inner().databaseAccounts(); + return client.createUpdateSqlStoredProcedureAsync(this.resourceGroupName, this.accountName, this.databaseName, this.containerName, this.storedProcedureName, this.createOrUpdateParameter) + .map(new Func1() { + @Override + public SqlStoredProcedureInner call(SqlStoredProcedureInner resource) { + resetCreateUpdateParameters(); + return resource; + } + }) + .map(innerToFluentMap(this)); + } + + @Override + protected Observable getInnerAsync() { + DatabaseAccountsInner client = this.manager().inner().databaseAccounts(); + return client.getSqlStoredProcedureAsync(this.resourceGroupName, this.accountName, this.databaseName, this.containerName, this.storedProcedureName); + } + + @Override + public boolean isInCreateMode() { + return this.inner().id() == null; + } + + private void resetCreateUpdateParameters() { + this.createOrUpdateParameter = new SqlStoredProcedureCreateUpdateParameters(); + } + + @Override + public String _etag() { + return this.inner()._etag(); + } + + @Override + public String _rid() { + return this.inner()._rid(); + } + + @Override + public Object _ts() { + return this.inner()._ts(); + } + + @Override + public String body() { + return this.inner().body(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String location() { + return this.inner().location(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public String sqlStoredProcedureId() { + return this.inner().sqlStoredProcedureId(); + } + + @Override + public Map tags() { + return this.inner().getTags(); + } + + @Override + public String type() { + return this.inner().type(); + } + + @Override + public SqlStoredProcedureImpl withExistingContainer(String resourceGroupName, String accountName, String databaseName, String containerName) { + this.resourceGroupName = resourceGroupName; + this.accountName = accountName; + this.databaseName = databaseName; + this.containerName = containerName; + return this; + } + + @Override + public SqlStoredProcedureImpl withOptions(Map options) { + this.createOrUpdateParameter.withOptions(options); + return this; + } + + @Override + public SqlStoredProcedureImpl withResource(SqlStoredProcedureResource resource) { + this.createOrUpdateParameter.withResource(resource); + return this; + } + +} diff --git a/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureInner.java b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureInner.java new file mode 100644 index 000000000000..be5d61013455 --- /dev/null +++ b/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/SqlStoredProcedureInner.java @@ -0,0 +1,154 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.cosmosdb.v2015_04_08.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.rest.SkipParentValidation; +import com.microsoft.azure.Resource; + +/** + * An Azure Cosmos DB stored procedure. + */ +@JsonFlatten +@SkipParentValidation +public class SqlStoredProcedureInner extends Resource { + /** + * Name of the Sql Stored Procedure. + */ + @JsonProperty(value = "properties.id") + private String sqlStoredProcedureId; + + /** + * Body of the Stored Procedure. + */ + @JsonProperty(value = "properties.body") + private String body; + + /** + * A system generated property. A unique identifier. + */ + @JsonProperty(value = "properties._rid") + private String _rid; + + /** + * A system generated property that denotes the last updated timestamp of + * the resource. + */ + @JsonProperty(value = "properties._ts") + private Object _ts; + + /** + * A system generated property representing the resource etag required for + * optimistic concurrency control. + */ + @JsonProperty(value = "properties._etag") + private String _etag; + + /** + * Get name of the Sql Stored Procedure. + * + * @return the sqlStoredProcedureId value + */ + public String sqlStoredProcedureId() { + return this.sqlStoredProcedureId; + } + + /** + * Set name of the Sql Stored Procedure. + * + * @param sqlStoredProcedureId the sqlStoredProcedureId value to set + * @return the SqlStoredProcedureInner object itself. + */ + public SqlStoredProcedureInner withSqlStoredProcedureId(String sqlStoredProcedureId) { + this.sqlStoredProcedureId = sqlStoredProcedureId; + return this; + } + + /** + * Get body of the Stored Procedure. + * + * @return the body value + */ + public String body() { + return this.body; + } + + /** + * Set body of the Stored Procedure. + * + * @param body the body value to set + * @return the SqlStoredProcedureInner object itself. + */ + public SqlStoredProcedureInner withBody(String body) { + this.body = body; + return this; + } + + /** + * Get a system generated property. A unique identifier. + * + * @return the _rid value + */ + public String _rid() { + return this._rid; + } + + /** + * Set a system generated property. A unique identifier. + * + * @param _rid the _rid value to set + * @return the SqlStoredProcedureInner object itself. + */ + public SqlStoredProcedureInner with_rid(String _rid) { + this._rid = _rid; + return this; + } + + /** + * Get a system generated property that denotes the last updated timestamp of the resource. + * + * @return the _ts value + */ + public Object _ts() { + return this._ts; + } + + /** + * Set a system generated property that denotes the last updated timestamp of the resource. + * + * @param _ts the _ts value to set + * @return the SqlStoredProcedureInner object itself. + */ + public SqlStoredProcedureInner with_ts(Object _ts) { + this._ts = _ts; + return this; + } + + /** + * Get a system generated property representing the resource etag required for optimistic concurrency control. + * + * @return the _etag value + */ + public String _etag() { + return this._etag; + } + + /** + * Set a system generated property representing the resource etag required for optimistic concurrency control. + * + * @param _etag the _etag value to set + * @return the SqlStoredProcedureInner object itself. + */ + public SqlStoredProcedureInner with_etag(String _etag) { + this._etag = _etag; + return this; + } + +}