Package com.azure.data.cosmos
Class CosmosClient
- java.lang.Object
-
- com.azure.data.cosmos.CosmosClient
-
- All Implemented Interfaces:
AutoCloseable
public class CosmosClient extends Object implements AutoCloseable
Provides a client-side logical representation of the Azure Cosmos database service. This asynchronous client is used to configure and execute requests against the service.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CosmosClientBuilder
builder()
Instantiate the cosmos client builder to build cosmos clientvoid
close()
Close thisCosmosClient
instance and cleans up the resources.Mono<CosmosDatabaseResponse>
createDatabase(CosmosDatabaseProperties databaseSettings)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabase(CosmosDatabaseProperties databaseSettings, int throughput)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabase(CosmosDatabaseProperties databaseSettings, int throughput, CosmosDatabaseRequestOptions options)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabase(CosmosDatabaseProperties databaseSettings, CosmosDatabaseRequestOptions options)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabase(String id)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabase(String id, int throughput)
Creates a database.Mono<CosmosDatabaseResponse>
createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings)
CREATE a Database if it does not already exist on the service TheMono
upon successful completion will contain a single cosmos database response with the created or existing database.Mono<CosmosDatabaseResponse>
createDatabaseIfNotExists(String id)
CREATE a Database if it does not already exist on the service TheMono
upon successful completion will contain a single cosmos database response with the created or existing database.CosmosDatabase
getDatabase(String id)
Gets a database object without making a service call.Flux<FeedResponse<CosmosDatabaseProperties>>
queryDatabases(SqlQuerySpec querySpec, FeedOptions options)
Query for databases.Flux<FeedResponse<CosmosDatabaseProperties>>
queryDatabases(String query, FeedOptions options)
Query for databases.Flux<FeedResponse<CosmosDatabaseProperties>>
readAllDatabases()
Reads all databases.Flux<FeedResponse<CosmosDatabaseProperties>>
readAllDatabases(FeedOptions options)
Reads all databases.Mono<DatabaseAccount>
readDatabaseAccount()
-
-
-
Method Detail
-
builder
public static CosmosClientBuilder builder()
Instantiate the cosmos client builder to build cosmos client- Returns:
CosmosClientBuilder
-
createDatabaseIfNotExists
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings)
CREATE a Database if it does not already exist on the service TheMono
upon successful completion will contain a single cosmos database response with the created or existing database.- Parameters:
databaseSettings
- CosmosDatabaseProperties- Returns:
- a
Mono
containing the cosmos database response with the created or existing database or an error.
-
createDatabaseIfNotExists
public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists(String id)
CREATE a Database if it does not already exist on the service TheMono
upon successful completion will contain a single cosmos database response with the created or existing database.- Parameters:
id
- the id of the database- Returns:
- a
Mono
containing the cosmos database response with the created or existing database or an error
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(CosmosDatabaseProperties databaseSettings, CosmosDatabaseRequestOptions options)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
databaseSettings
-CosmosDatabaseProperties
options
-CosmosDatabaseRequestOptions
- Returns:
- an
Mono
containing the single cosmos database response with the created database or an error.
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(CosmosDatabaseProperties databaseSettings)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
databaseSettings
-CosmosDatabaseProperties
- Returns:
- an
Mono
containing the single cosmos database response with the created database or an error.
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(String id)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
id
- id of the database- Returns:
- a
Mono
containing the single cosmos database response with the created database or an error.
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(CosmosDatabaseProperties databaseSettings, int throughput, CosmosDatabaseRequestOptions options)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
databaseSettings
-CosmosDatabaseProperties
throughput
- the throughput for the databaseoptions
-CosmosDatabaseRequestOptions
- Returns:
- an
Mono
containing the single cosmos database response with the created database or an error.
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(CosmosDatabaseProperties databaseSettings, int throughput)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
databaseSettings
-CosmosDatabaseProperties
throughput
- the throughput for the database- Returns:
- an
Mono
containing the single cosmos database response with the created database or an error.
-
createDatabase
public Mono<CosmosDatabaseResponse> createDatabase(String id, int throughput)
Creates a database. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created database. In case of failure theMono
will error.- Parameters:
id
- id of the databasethroughput
- the throughput for the database- Returns:
- a
Mono
containing the single cosmos database response with the created database or an error.
-
readAllDatabases
public Flux<FeedResponse<CosmosDatabaseProperties>> readAllDatabases(FeedOptions options)
Reads all databases. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read databases. In case of failure theFlux
will error.- Parameters:
options
-FeedOptions
- Returns:
- a
Flux
containing one or several feed response pages of read databases or an error.
-
readAllDatabases
public Flux<FeedResponse<CosmosDatabaseProperties>> readAllDatabases()
Reads all databases. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read databases. In case of failure theFlux
will error.- Returns:
- a
Flux
containing one or several feed response pages of read databases or an error.
-
queryDatabases
public Flux<FeedResponse<CosmosDatabaseProperties>> queryDatabases(String query, FeedOptions options)
Query for databases. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read databases. In case of failure theFlux
will error.- Parameters:
query
- the query.options
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of read databases or an error.
-
queryDatabases
public Flux<FeedResponse<CosmosDatabaseProperties>> queryDatabases(SqlQuerySpec querySpec, FeedOptions options)
Query for databases. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read databases. In case of failure theFlux
will error.- Parameters:
querySpec
- the SQL query specification.options
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of read databases or an error.
-
readDatabaseAccount
public Mono<DatabaseAccount> readDatabaseAccount()
-
getDatabase
public CosmosDatabase getDatabase(String id)
Gets a database object without making a service call.- Parameters:
id
- name of the database- Returns:
CosmosDatabase
-
close
public void close()
Close thisCosmosClient
instance and cleans up the resources.- Specified by:
close
in interfaceAutoCloseable
-
-