Package com.azure.cosmos
Class CosmosClient
java.lang.Object
com.azure.cosmos.CosmosClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
Provides a client-side logical representation of the Azure Cosmos DB service.
Calls to CosmosClient API's are blocked for completion.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close thisCosmosClient
instance.createDatabase
(CosmosDatabaseProperties databaseProperties) Creates a Cosmos database.createDatabase
(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options) Creates a database.createDatabase
(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties) Creates a Cosmos database.createDatabase
(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options) Creates a Cosmos database.createDatabase
(String id) Creates a Cosmos database.createDatabase
(String id, ThroughputProperties throughputProperties) Creates a Cosmos database.Create a Cosmos database if it does not already exist on the service.createDatabaseIfNotExists
(String id, ThroughputProperties throughputProperties) Create a Cosmos database if it does not already exist on the service.createGlobalThroughputControlConfigBuilder
(String databaseId, String containerId) Create global throughput control config builder which will be used to buildGlobalThroughputControlConfig
.getDatabase
(String id) Gets the Cosmos database client.queryDatabases
(SqlQuerySpec querySpec, CosmosQueryRequestOptions options) Query a Cosmos database.queryDatabases
(String query, CosmosQueryRequestOptions options) Query a Cosmos database.Reads all Cosmos databases.
-
Method Details
-
createDatabaseIfNotExists
public CosmosDatabaseResponse createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties) Create a Cosmos database if it does not already exist on the service.The throughputProperties will only be used if the specified database does not exist and therefor a new database will be created with throughputProperties.
- Parameters:
id
- the id of the database.throughputProperties
- the throughputProperties.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabaseIfNotExists
Create a Cosmos database if it does not already exist on the service.- Parameters:
id
- the id of the database.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options) Creates a database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.options
- the request options.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
Creates a Cosmos database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
Creates a Cosmos database.- Parameters:
id
- the id of the database.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options) Creates a Cosmos database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.throughputProperties
- the throughput properties.options
-CosmosDatabaseRequestOptions
the request options.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties) Creates a Cosmos database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.throughputProperties
- the throughput properties.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
createDatabase
Creates a Cosmos database.- Parameters:
id
- the id of the database.throughputProperties
- the throughput properties.- Returns:
- the
CosmosDatabaseResponse
with the created database.
-
readAllDatabases
Reads all Cosmos databases.- Returns:
- the
CosmosPagedIterable
for feed response with the read databases.
-
queryDatabases
public CosmosPagedIterable<CosmosDatabaseProperties> queryDatabases(String query, CosmosQueryRequestOptions options) Query a Cosmos database.- Parameters:
query
- the query.options
-CosmosQueryRequestOptions
the feed options.- Returns:
- the
CosmosPagedIterable
for feed response with the obtained databases.
-
queryDatabases
public CosmosPagedIterable<CosmosDatabaseProperties> queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options) Query a Cosmos database.- Parameters:
querySpec
-SqlQuerySpec
the query spec.options
- the query request options.- Returns:
- the
CosmosPagedIterable
for feed response with the obtained databases.
-
getDatabase
Gets the Cosmos database client.- Parameters:
id
- the id of the database.- Returns:
CosmosDatabase
the cosmos sync database.
-
close
public void close()Close thisCosmosClient
instance.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
createGlobalThroughputControlConfigBuilder
@Beta(value=V4_13_0, warningText="Preview API - subject to change in non-backwards compatible way") public GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigBuilder(String databaseId, String containerId) Create global throughput control config builder which will be used to buildGlobalThroughputControlConfig
.- Parameters:
databaseId
- The database id of the control container.containerId
- The container id of the control container.- Returns:
- A
GlobalThroughputControlConfigBuilder
.
-