Class 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 Detail

      • createDatabaseIfNotExists

        public Mono<CosmosDatabaseResponse> createDatabaseIfNotExists​(CosmosDatabaseProperties databaseSettings)
        CREATE a Database if it does not already exist on the service The Mono 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 The Mono 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)
        Creates a database. After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created database. In case of failure the Mono 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. The Mono upon successful completion will contain a single resource response with the created database. In case of failure the Mono 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)
        Creates a database. After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created database. In case of failure the Mono 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. The Mono upon successful completion will contain a single resource response with the created database. In case of failure the Mono will error.
        Parameters:
        id - id of the database
        throughput - 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. The Flux will contain one or several feed response of the read databases. In case of failure the Flux 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. The Flux will contain one or several feed response of the read databases. In case of failure the Flux 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. The Flux will contain one or several feed response of the read databases. In case of failure the Flux 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. The Flux will contain one or several feed response of the read databases. In case of failure the Flux 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.
      • getDatabase

        public CosmosDatabase getDatabase​(String id)
        Gets a database object without making a service call.
        Parameters:
        id - name of the database
        Returns:
        CosmosDatabase