다음을 통해 공유


CosmosAsyncDatabase Class

  • java.lang.Object
    • com.azure.cosmos.CosmosAsyncDatabase

public class CosmosAsyncDatabase

Perform read and delete databases, update database throughput, and perform operations on child resources

Method Summary

Modifier and Type Method and Description
Mono<CosmosClientEncryptionKeyResponse> createClientEncryptionKey(CosmosClientEncryptionKeyProperties keyProperties)

Creates a client encryption key after subscription the operation will be performed.

Mono<CosmosContainerResponse> createContainer(CosmosContainerProperties containerProperties)

Creates a Cosmos container.

Mono<CosmosContainerResponse> createContainer(CosmosContainerProperties containerProperties, CosmosContainerRequestOptions options)

Creates a Cosmos container.

Mono<CosmosContainerResponse> createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)

Creates a Cosmos container with custom throughput properties.

Mono<CosmosContainerResponse> createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties, CosmosContainerRequestOptions options)

Creates a container.

Mono<CosmosContainerResponse> createContainer(String id, String partitionKeyPath)

Creates a Cosmos container.

Mono<CosmosContainerResponse> createContainer(String id, String partitionKeyPath, ThroughputProperties throughputProperties)

Creates a Cosmos container.

Mono<CosmosContainerResponse> createContainerIfNotExists(CosmosContainerProperties containerProperties)

Creates a Cosmos container if it does not exist on the service.

Mono<CosmosContainerResponse> createContainerIfNotExists(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)

Creates a Cosmos container if it does not exist on the service.

Mono<CosmosContainerResponse> createContainerIfNotExists(String id, String partitionKeyPath)

Creates a Cosmos container if it does not exist on the service.

Mono<CosmosContainerResponse> createContainerIfNotExists(String id, String partitionKeyPath, ThroughputProperties throughputProperties)

Creates a Cosmos container if it does not exist on the service.

Mono<CosmosUserResponse> createUser(CosmosUserProperties userProperties)

Creates a user After subscription the operation will be performed.

Mono<CosmosDatabaseResponse> delete()

Deletes the current Cosmos database.

Mono<CosmosDatabaseResponse> delete(CosmosDatabaseRequestOptions options)

Deletes the current Cosmos database while specifying additional request options.

CosmosAsyncClientEncryptionKey getClientEncryptionKey(String id)

Gets a CosmosAsyncClientEncryptionKey object without making a service call

CosmosAsyncContainer getContainer(String id)

Gets a CosmosAsyncContainer object without making a service call

String getId()

Get the id of the CosmosAsyncDatabase.

CosmosAsyncUser getUser(String id)

Gets user.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> queryClientEncryptionKeys(SqlQuerySpec querySpec)

Query for cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> queryClientEncryptionKeys(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> queryClientEncryptionKeys(String query)

Query for cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> queryClientEncryptionKeys(String query, CosmosQueryRequestOptions options)

Query for cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosContainerProperties> queryContainers(SqlQuerySpec querySpec)

Query for cosmos containers in a cosmos database.

CosmosPagedFlux<CosmosContainerProperties> queryContainers(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos containers in a cosmos database.

CosmosPagedFlux<CosmosContainerProperties> queryContainers(String query)

Query for cosmos containers in a cosmos database.

CosmosPagedFlux<CosmosContainerProperties> queryContainers(String query, CosmosQueryRequestOptions options)

Query for cosmos containers in a cosmos database.

CosmosPagedFlux<CosmosUserProperties> queryUsers(SqlQuerySpec querySpec)

Query for cosmos users in a database.

CosmosPagedFlux<CosmosUserProperties> queryUsers(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos users in a database.

CosmosPagedFlux<CosmosUserProperties> queryUsers(String query)

Query for cosmos users in a database.

CosmosPagedFlux<CosmosUserProperties> queryUsers(String query, CosmosQueryRequestOptions options)

Query for cosmos users in a database.

Mono<CosmosDatabaseResponse> read()

Reads a database.

Mono<CosmosDatabaseResponse> read(CosmosDatabaseRequestOptions options)

Reads a database.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> readAllClientEncryptionKeys()

Reads all cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosClientEncryptionKeyProperties> readAllClientEncryptionKeys(CosmosQueryRequestOptions options)

Reads all cosmos client encryption keys in a database.

CosmosPagedFlux<CosmosContainerProperties> readAllContainers()

Reads all cosmos containers.

CosmosPagedFlux<CosmosContainerProperties> readAllContainers(CosmosQueryRequestOptions options)

Reads all cosmos containers.

CosmosPagedFlux<CosmosUserProperties> readAllUsers()

Reads all cosmos users in a database.

Mono<ThroughputResponse> readThroughput()

Gets the throughput of the database.

Mono<ThroughputResponse> replaceThroughput(ThroughputProperties throughputProperties)

Sets throughput provisioned for a container in measurement of Requests-per-Unit in the Azure Cosmos service.

Mono<CosmosUserResponse> upsertUser(CosmosUserProperties userProperties)

Upsert a user.

Methods inherited from java.lang.Object

Method Details

createClientEncryptionKey

public Mono createClientEncryptionKey(CosmosClientEncryptionKeyProperties keyProperties)

Creates a client encryption key after subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created client encryption key. In case of failure the Mono will error.

Parameters:

keyProperties - the cosmos client encryption key properties

Returns:

an Mono containing the single resource response with the created cosmos client encryption key or an error.

createContainer

public Mono createContainer(CosmosContainerProperties containerProperties)

Creates a Cosmos container.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainer(containerProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

containerProperties - the container properties.

Returns:

a Mono containing the single cosmos container response with the created container or an error.

createContainer

public Mono createContainer(CosmosContainerProperties containerProperties, CosmosContainerRequestOptions options)

Creates a Cosmos container.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainer(containerProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

containerProperties - the containerProperties.
options - the cosmos container request options.

Returns:

a Mono containing the cosmos container response with the created container or an error.

createContainer

public Mono createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)

Creates a Cosmos container with custom throughput properties.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 ThroughputProperties throughputProperties =
     ThroughputProperties.createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosAsyncDatabase.createContainer(containerProperties, throughputProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

containerProperties - the container properties.
throughputProperties - the throughput properties for the container.

Returns:

a Mono containing the single cosmos container response with the created container or an error.

createContainer

public Mono createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties, CosmosContainerRequestOptions options)

Creates a container.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);

 cosmosAsyncDatabase.createContainer(
         containerProperties,
         throughput,
         options
     )
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

Parameters:

containerProperties - the container properties.
throughputProperties - the throughput properties.
options - the request options.

Returns:

the mono.

createContainer

public Mono createContainer(String id, String partitionKeyPath)

Creates a Cosmos container.

ThroughputProperties throughputProperties =
     ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
 cosmosAsyncDatabase.createContainer(
         containerId,
         partitionKeyPath,
         throughputProperties
     )
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

id - the cosmos container id.
partitionKeyPath - the partition key path.

Returns:

a Mono containing the cosmos container response with the created container or an error.

createContainer

public Mono createContainer(String id, String partitionKeyPath, ThroughputProperties throughputProperties)

Creates a Cosmos container.

ThroughputProperties throughputProperties =
     ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
 cosmosAsyncDatabase.createContainer(
         containerId,
         partitionKeyPath,
         throughputProperties
     )
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

id - the cosmos container id.
partitionKeyPath - the partition key path.
throughputProperties - the throughput properties for the container.

Returns:

a Mono containing the cosmos container response with the created container or an error.

createContainerIfNotExists

public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties)

Creates a Cosmos container if it does not exist on the service.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainerIfNotExists(containerProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created or existing container. In case of failure the Mono will error.

Parameters:

containerProperties - the container properties

Returns:

a Mono containing the cosmos container response with the created or existing container or an error.

createContainerIfNotExists

public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)

Creates a Cosmos container if it does not exist on the service.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainerIfNotExists(containerProperties, throughputProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

The throughput properties will only be used if the specified container does not exist and therefor a new container will be created.

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created or existing container. In case of failure the Mono will error.

Parameters:

containerProperties - the container properties.
throughputProperties - the throughput properties for the container.

Returns:

a Mono containing the cosmos container response with the created or existing container or an error.

createContainerIfNotExists

public Mono createContainerIfNotExists(String id, String partitionKeyPath)

Creates a Cosmos container if it does not exist on the service.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainerIfNotExists(containerProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

id - the cosmos container id.
partitionKeyPath - the partition key path.

Returns:

a Mono containing the cosmos container response with the created container or an error.

createContainerIfNotExists

public Mono createContainerIfNotExists(String id, String partitionKeyPath, ThroughputProperties throughputProperties)

Creates a Cosmos container if it does not exist on the service.

CosmosContainerProperties containerProperties =
     new CosmosContainerProperties(containerId, partitionKeyDefinition);
 cosmosAsyncDatabase.createContainerIfNotExists(containerProperties, throughputProperties)
     .subscribe(
         cosmosContainerResponse -> System.out.println(cosmosContainerResponse),
         throwable -> System.out.println("Failed to create container: " + throwable)
     );

The throughput properties will only be used if the specified container does not exist and therefor a new container will be created.

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos container response with the created container. In case of failure the Mono will error.

Parameters:

id - the cosmos container id.
partitionKeyPath - the partition key path.
throughputProperties - the throughput properties for the container.

Returns:

a Mono containing the cosmos container response with the created container or an error.

createUser

public Mono createUser(CosmosUserProperties userProperties)

Creates a user After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created user. In case of failure the Mono will error.

String userId = "userId";
 CosmosUserProperties userProperties = new CosmosUserProperties();
 userProperties.setId(userId);
 cosmosAsyncDatabase.createUser(userProperties)
     .subscribe(
         userResponse -> System.out.println(userResponse),
         throwable -> System.out.println("Failed to create user: " + throwable)
     );

Parameters:

userProperties - the cosmos user properties

Returns:

an Mono containing the single resource response with the created cosmos user or an error.

delete

public Mono delete()

Deletes the current Cosmos database.

CosmosAsyncDatabase database = cosmosAsyncClient
     .getDatabase("<YOUR DATABASE NAME>");
 database.delete().subscribe(databaseResponse -> {
         System.out.println(databaseResponse);
     },
     throwable -> {
         throwable.printStackTrace();
     });

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos database response with the deleted database. In case of failure the Mono will error.

Returns:

an Mono containing the single cosmos database response.

delete

public Mono delete(CosmosDatabaseRequestOptions options)

Deletes the current Cosmos database while specifying additional request options.

CosmosAsyncDatabase database = cosmosAsyncClient
     .getDatabase("<YOUR DATABASE NAME>");
 database.delete().subscribe(databaseResponse -> {
         System.out.println(databaseResponse);
     },
     throwable -> {
         throwable.printStackTrace();
     });

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos database response with the deleted database. In case of failure the Mono will error.

Parameters:

options - the request options.

Returns:

an Mono containing the single cosmos database response.

getClientEncryptionKey

public CosmosAsyncClientEncryptionKey getClientEncryptionKey(String id)

Gets a CosmosAsyncClientEncryptionKey object without making a service call

Parameters:

id - id of the clientEncryptionKey

Returns:

Cosmos ClientEncryptionKey

getContainer

public CosmosAsyncContainer getContainer(String id)

Gets a CosmosAsyncContainer object without making a service call

Parameters:

id - id of the container

Returns:

Cosmos Container

getId

public String getId()

Get the id of the CosmosAsyncDatabase.

Returns:

the id of the CosmosAsyncDatabase.

getUser

public CosmosAsyncUser getUser(String id)

Gets user.

Parameters:

id - the id

Returns:

the user

queryClientEncryptionKeys

public CosmosPagedFlux queryClientEncryptionKeys(SqlQuerySpec querySpec)

Query for cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained client encryption keys or an error.

queryClientEncryptionKeys

public CosmosPagedFlux queryClientEncryptionKeys(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained client encryption keys or an error.

queryClientEncryptionKeys

public CosmosPagedFlux queryClientEncryptionKeys(String query)

Query for cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - query as string.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained client encryption keys or an error.

queryClientEncryptionKeys

public CosmosPagedFlux queryClientEncryptionKeys(String query, CosmosQueryRequestOptions options)

Query for cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - query as string.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained client encryption keys or an error.

queryContainers

public CosmosPagedFlux queryContainers(SqlQuerySpec querySpec)

Query for cosmos containers in a cosmos database.

cosmosAsyncDatabase.queryContainers("SELECT * FROM DB_NAME")
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained containers. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained containers or an error.

queryContainers

public CosmosPagedFlux queryContainers(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos containers in a cosmos database.

cosmosAsyncDatabase.queryContainers("SELECT * FROM DB_NAME")
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained containers. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained containers or an error.

queryContainers

public CosmosPagedFlux queryContainers(String query)

Query for cosmos containers in a cosmos database.

cosmosAsyncDatabase.queryContainers("SELECT * FROM DB_NAME")
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained containers. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - the query.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained containers or an error.

queryContainers

public CosmosPagedFlux queryContainers(String query, CosmosQueryRequestOptions options)

Query for cosmos containers in a cosmos database.

cosmosAsyncDatabase.queryContainers("SELECT * FROM DB_NAME")
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained containers. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - the query.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained containers or an error.

queryUsers

public CosmosPagedFlux queryUsers(SqlQuerySpec querySpec)

Query for cosmos users in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained users. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained users or an error.

queryUsers

public CosmosPagedFlux queryUsers(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Query for cosmos users in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained users. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained users or an error.

queryUsers

public CosmosPagedFlux queryUsers(String query)

Query for cosmos users in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained users. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - query as string.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained users or an error.

queryUsers

public CosmosPagedFlux queryUsers(String query, CosmosQueryRequestOptions options)

Query for cosmos users in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained users. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - query as string.
options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained users or an error.

read

public Mono read()

Reads a database. Fetch the details and properties of a database based on its unique identifier.

CosmosAsyncDatabase database = cosmosAsyncClient
     .getDatabase("<YOUR DATABASE NAME>");
 database.read().subscribe(databaseResponse -> {
         System.out.println(databaseResponse);
     },
     throwable -> {
         throwable.printStackTrace();
     });

After subscription the operation will be performed. The Mono upon successful completion will contain a single cosmos database response with the read database. In case of failure the Mono will error.

Returns:

an Mono containing the single cosmos database respone with the read database or an error.

read

public Mono read(CosmosDatabaseRequestOptions options)

Reads a database. Fetch the details and properties of a database based on its unique identifier.

CosmosAsyncDatabase database = cosmosAsyncClient
     .getDatabase("<YOUR DATABASE NAME>");
 database.read().subscribe(databaseResponse -> {
         System.out.println(databaseResponse);
     },
     throwable -> {
         throwable.printStackTrace();
     });

After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos database response with the read database. In case of failure the Mono will error.

Parameters:

options - the request options.

Returns:

an Mono containing the single cosmos database response with the read database or an error.

readAllClientEncryptionKeys

public CosmosPagedFlux readAllClientEncryptionKeys()

Reads all cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the read cosmos client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the read cosmos client encryption keys or an error.

readAllClientEncryptionKeys

public CosmosPagedFlux readAllClientEncryptionKeys(CosmosQueryRequestOptions options)

Reads all cosmos client encryption keys in a database.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the read cosmos client encryption keys. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

options - the query request options.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the read cosmos client encryption keys or an error.

readAllContainers

public CosmosPagedFlux readAllContainers()

Reads all cosmos containers.

cosmosAsyncDatabase.readAllContainers()
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the read containers. In case of failure the CosmosPagedFlux<T> will error.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of read containers or an error.

readAllContainers

public CosmosPagedFlux readAllContainers(CosmosQueryRequestOptions options)

Reads all cosmos containers.

cosmosAsyncDatabase.readAllContainers()
     .byPage()
     .flatMap(containerPropertiesFeedResponse -> {
         for (CosmosContainerProperties properties : containerPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the read containers. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of read containers or an error.

readAllUsers

public CosmosPagedFlux readAllUsers()

Reads all cosmos users in a database.

cosmosAsyncDatabase.readAllUsers()
     .byPage()
     .flatMap(userPropertiesFeedResponse -> {
         for (CosmosUserProperties properties : userPropertiesFeedResponse.getResults()) {
             System.out.println(properties);
         }
         return Flux.empty();
     })
     .subscribe();

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the read cosmos users. In case of failure the CosmosPagedFlux<T> will error.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the read cosmos users or an error.

readThroughput

public Mono readThroughput()

Gets the throughput of the database.

cosmosAsyncDatabase.readThroughput()
     .subscribe(throughputResponse -> {
             System.out.println(throughputResponse);
         },
         throwable -> {
             throwable.printStackTrace();
         });

Returns:

the mono containing throughput response.

replaceThroughput

public Mono replaceThroughput(ThroughputProperties throughputProperties)

Sets throughput provisioned for a container in measurement of Requests-per-Unit in the Azure Cosmos service.

ThroughputProperties autoscaledThroughput = ThroughputProperties
     .createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosAsyncDatabase.replaceThroughput(autoscaledThroughput)
     .subscribe(throughputResponse -> {
             System.out.println(throughputResponse);
         },
         throwable -> {
             throwable.printStackTrace();
         });

Parameters:

throughputProperties - the throughput properties.

Returns:

the mono.

upsertUser

public Mono upsertUser(CosmosUserProperties userProperties)

Upsert a user. Upsert will create a new user if it doesn't exist, or replace the existing one if it does. After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created user. In case of failure the Mono will error.

String userId = "userId";
 CosmosUserProperties userProperties = new CosmosUserProperties();
 userProperties.setId(userId);
 cosmosAsyncDatabase.upsertUser(userProperties)
     .subscribe(
         userResponse -> System.out.println(userResponse),
         throwable -> System.out.println("Failed to upsert user: " + throwable)
     );

Parameters:

userProperties - the cosmos user properties

Returns:

an Mono containing the single resource response with the upserted user or an error.

Applies to