Package com.azure.data.cosmos.sync
Class CosmosSyncClient
- java.lang.Object
-
- com.azure.data.cosmos.sync.CosmosSyncClient
-
- All Implemented Interfaces:
AutoCloseable
public class CosmosSyncClient extends Object implements AutoCloseable
Provides a client-side logical representation of the Azure Cosmos database service. SyncClient is used to perform operations in a synchronous way
-
-
Constructor Summary
Constructors Constructor Description CosmosSyncClient(CosmosClientBuilder builder)
-
Method Summary
-
-
-
Constructor Detail
-
CosmosSyncClient
public CosmosSyncClient(CosmosClientBuilder builder)
-
-
Method Detail
-
builder
public static CosmosClientBuilder builder()
Instantiate the cosmos client builder to build cosmos client- Returns:
CosmosClientBuilder
-
createDatabaseIfNotExists
public CosmosSyncDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProperties databaseProperties) throws CosmosClientException
Create a Database if it does not already exist on the service- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception.
-
createDatabaseIfNotExists
public CosmosSyncDatabaseResponse createDatabaseIfNotExists(String id) throws CosmosClientException
Create a Database if it does not already exist on the service- Parameters:
id
- the id of the database- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception.
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options) throws CosmosClientException
Creates a database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.options
- the request options.- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception.
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties) throws CosmosClientException
Creates a database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception.
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(String id) throws CosmosClientException
Creates a database.- Parameters:
id
- the id of the database- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception.
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, int throughput, CosmosDatabaseRequestOptions options) throws CosmosClientException
Creates a database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.throughput
- the throughputoptions
-CosmosDatabaseRequestOptions
the request options- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, int throughput) throws CosmosClientException
Creates a database.- Parameters:
databaseProperties
-CosmosDatabaseProperties
the database properties.throughput
- the throughput- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception
-
createDatabase
public CosmosSyncDatabaseResponse createDatabase(String id, int throughput) throws CosmosClientException
Creates a database.- Parameters:
id
- the id of the databasethroughput
- the throughput- Returns:
- the
CosmosSyncDatabaseResponse
with the created database. - Throws:
CosmosClientException
- the cosmos client exception
-
readAllDatabases
public Iterator<FeedResponse<CosmosDatabaseProperties>> readAllDatabases(FeedOptions options)
Reads all databases.- Parameters:
options
-FeedOptions
the feed options.- Returns:
- the iterator for feed response with the read databases.
-
readAllDatabases
public Iterator<FeedResponse<CosmosDatabaseProperties>> readAllDatabases()
Reads all databases.- Returns:
- the iterator for feed response with the read databases.
-
queryDatabases
public Iterator<FeedResponse<CosmosDatabaseProperties>> queryDatabases(String query, FeedOptions options)
Query a database- Parameters:
query
- the queryoptions
-FeedOptions
the feed options.- Returns:
- the iterator for feed response with the obtained databases.
-
queryDatabases
public Iterator<FeedResponse<CosmosDatabaseProperties>> queryDatabases(SqlQuerySpec querySpec, FeedOptions options)
Query a database- Parameters:
querySpec
-SqlQuerySpec
the query specoptions
- the query- Returns:
- the iterator for feed response with the obtained databases.
-
getDatabase
public CosmosSyncDatabase getDatabase(String id)
Gets the database client- Parameters:
id
- the id of the database- Returns:
CosmosSyncDatabase
the cosmos sync database
-
close
public void close()
Close thisCosmosSyncClient
instance- Specified by:
close
in interfaceAutoCloseable
-
-