Class CosmosDatabase


  • public class CosmosDatabase
    extends Object
    Perform read and delete databases, update database throughput, and perform operations on child resources
    • Method Detail

      • id

        public String id()
        Get the id of the CosmosDatabase
        Returns:
        the id of the CosmosDatabase
      • read

        public Mono<CosmosDatabaseResponse> read()
        Reads a database. After subscription the operation will be performed. The Mono upon successful completion will contain a single cosmos database respone 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<CosmosDatabaseResponse> read​(CosmosDatabaseRequestOptions options)
        Reads a database. After subscription the operation will be performed. The Mono upon successful completion will contain a cosmos cosmos database respone 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.
      • delete

        public Mono<CosmosDatabaseResponse> delete()
        Deletes a database. 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<CosmosDatabaseResponse> delete​(CosmosDatabaseRequestOptions options)
        Deletes a database.

        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
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(CosmosContainerProperties containerSettings)
        Creates a document container. 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:
        containerSettings - the container properties.
        Returns:
        an Flux containing the single cosmos container response with the created container or an error.
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(CosmosContainerProperties containerProperties,
                                                             int throughput)
        Creates a document container. 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.
        throughput - the throughput for the container
        Returns:
        an Flux containing the single cosmos container response with the created container or an error.
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(CosmosContainerProperties containerProperties,
                                                             CosmosContainerRequestOptions options)
        Creates a document container. 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:
        an Flux containing the cosmos container response with the created container or an error.
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(CosmosContainerProperties containerProperties,
                                                             int throughput,
                                                             CosmosContainerRequestOptions options)
        Creates a document container. 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.
        throughput - the throughput for the container
        options - the cosmos container request options
        Returns:
        an Flux containing the cosmos container response with the created container or an error.
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(String id,
                                                             String partitionKeyPath)
        Creates a document container. 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:
        an Flux containing the cosmos container response with the created container or an error.
      • createContainer

        public Mono<CosmosContainerResponse> createContainer​(String id,
                                                             String partitionKeyPath,
                                                             int throughput)
        Creates a document container. 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
        throughput - the throughput for the container
        Returns:
        an Flux containing the cosmos container response with the created container or an error.
      • createContainerIfNotExists

        public Mono<CosmosContainerResponse> createContainerIfNotExists​(CosmosContainerProperties containerProperties)
        Creates a document container if it does not exist on the service.

        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<CosmosContainerResponse> createContainerIfNotExists​(CosmosContainerProperties containerProperties,
                                                                        int throughput)
        Creates a document container if it does not exist on the service.

        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
        throughput - the throughput for the container
        Returns:
        a Mono containing the cosmos container response with the created or existing container or an error.
      • createContainerIfNotExists

        public Mono<CosmosContainerResponse> createContainerIfNotExists​(String id,
                                                                        String partitionKeyPath)
        Creates a document container if it does not exist on the service. 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:
        an Flux containing the cosmos container response with the created container or an error.
      • createContainerIfNotExists

        public Mono<CosmosContainerResponse> createContainerIfNotExists​(String id,
                                                                        String partitionKeyPath,
                                                                        int throughput)
        Creates a document container if it does not exist on the service. 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
        throughput - the throughput for the container
        Returns:
        an Flux containing the cosmos container response with the created container or an error.
      • readAllContainers

        public Flux<FeedResponse<CosmosContainerProperties>> readAllContainers​(FeedOptions options)
        Reads all cosmos containers. After subscription the operation will be performed. The Flux will contain one or several feed response of the read containers. In case of failure the Flux will error.
        Parameters:
        options - FeedOptions
        Returns:
        a Flux containing one or several feed response pages of read containers or an error.
      • readAllContainers

        public Flux<FeedResponse<CosmosContainerProperties>> readAllContainers()
        Reads all cosmos containers. After subscription the operation will be performed. The Flux will contain one or several feed response of the read containers. In case of failure the Flux will error.
        Returns:
        a Flux containing one or several feed response pages of read containers or an error.
      • queryContainers

        public Flux<FeedResponse<CosmosContainerProperties>> queryContainers​(String query)
        Query for cosmos containers in a cosmos database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained containers. In case of failure the Flux will error.
        Parameters:
        query - the query
        Returns:
        a Flux containing one or several feed response pages of the obtained containers or an error.
      • queryContainers

        public Flux<FeedResponse<CosmosContainerProperties>> queryContainers​(String query,
                                                                             FeedOptions options)
        Query for cosmos containers in a cosmos database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained containers. In case of failure the Flux will error.
        Parameters:
        query - the query.
        options - the feed options.
        Returns:
        a Flux containing one or several feed response pages of the obtained containers or an error.
      • queryContainers

        public Flux<FeedResponse<CosmosContainerProperties>> queryContainers​(SqlQuerySpec querySpec)
        Query for cosmos containers in a cosmos database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained containers. In case of failure the Flux will error.
        Parameters:
        querySpec - the SQL query specification.
        Returns:
        a Flux containing one or several feed response pages of the obtained containers or an error.
      • queryContainers

        public Flux<FeedResponse<CosmosContainerProperties>> queryContainers​(SqlQuerySpec querySpec,
                                                                             FeedOptions options)
        Query for cosmos containers in a cosmos database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained containers. In case of failure the Flux will error.
        Parameters:
        querySpec - the SQL query specification.
        options - the feed options.
        Returns:
        a Flux containing one or several feed response pages of the obtained containers or an error.
      • getContainer

        public CosmosContainer getContainer​(String id)
        Gets a CosmosContainer object without making a service call
        Parameters:
        id - id of the container
        Returns:
        Cosmos Container
      • createUser

        public Mono<CosmosUserResponse> createUser​(CosmosUserProperties settings)
        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.
        Parameters:
        settings - the cosmos user properties
        Returns:
        an Mono containing the single resource response with the created cosmos user or an error.
      • upsertUser

        public Mono<CosmosUserResponse> upsertUser​(CosmosUserProperties settings)
        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.
        Parameters:
        settings - the cosmos user properties
        Returns:
        an Mono containing the single resource response with the upserted user or an error.
      • readAllUsers

        public Flux<FeedResponse<CosmosUserProperties>> readAllUsers()
        Reads all cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the read cosmos users. In case of failure the Flux will error.
        Returns:
        an Flux containing one or several feed response pages of the read cosmos users or an error.
      • readAllUsers

        public Flux<FeedResponse<CosmosUserProperties>> readAllUsers​(FeedOptions options)
        Reads all cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the read cosmos users. In case of failure the Flux will error.
        Parameters:
        options - the feed options.
        Returns:
        an Flux containing one or several feed response pages of the read cosmos users or an error.
      • queryUsers

        public Flux<FeedResponse<CosmosUserProperties>> queryUsers​(String query)
        Query for cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained users. In case of failure the Flux will error.
        Parameters:
        query - query as string
        Returns:
        a Flux containing one or several feed response pages of the obtained users or an error.
      • queryUsers

        public Flux<FeedResponse<CosmosUserProperties>> queryUsers​(String query,
                                                                   FeedOptions options)
        Query for cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained users. In case of failure the Flux will error.
        Parameters:
        query - query as string
        options - the feed options
        Returns:
        a Flux containing one or several feed response pages of the obtained users or an error.
      • queryUsers

        public Flux<FeedResponse<CosmosUserProperties>> queryUsers​(SqlQuerySpec querySpec)
        Query for cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained users. In case of failure the Flux will error.
        Parameters:
        querySpec - the SQL query specification.
        Returns:
        a Flux containing one or several feed response pages of the obtained users or an error.
      • queryUsers

        public Flux<FeedResponse<CosmosUserProperties>> queryUsers​(SqlQuerySpec querySpec,
                                                                   FeedOptions options)
        Query for cosmos users in a database. After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained users. In case of failure the Flux will error.
        Parameters:
        querySpec - the SQL query specification.
        options - the feed options.
        Returns:
        a Flux containing one or several feed response pages of the obtained users or an error.
      • readProvisionedThroughput

        public Mono<Integer> readProvisionedThroughput()
        Gets the throughput of the database
        Returns:
        a Mono containing throughput or an error.
      • replaceProvisionedThroughput

        public Mono<Integer> replaceProvisionedThroughput​(int requestUnitsPerSecond)
        Sets throughput provisioned for a container in measurement of Requests-per-Unit in the Azure Cosmos service.
        Parameters:
        requestUnitsPerSecond - the cosmos container throughput, expressed in Request Units per second
        Returns:
        a Mono containing throughput or an error.