Class CosmosClientBuilder


  • public class CosmosClientBuilder
    extends Object
    Helper class to build CosmosClient instances as logical representation of the Azure Cosmos database service.
     
     ConnectionPolicy connectionPolicy = new ConnectionPolicy();
     connectionPolicy.connectionMode(ConnectionMode.DIRECT);
     CosmonsClient client = new CosmosClient.builder()
             .endpoint(serviceEndpoint)
             .key(key)
             .connectionPolicy(connectionPolicy)
             .consistencyLevel(ConsistencyLevel.SESSION)
             .build();
     
     
    • Constructor Detail

      • CosmosClientBuilder

        public CosmosClientBuilder()
    • Method Detail

      • tokenResolver

        public TokenResolver tokenResolver()
        Gets the token resolver
        Returns:
        the token resolver
      • tokenResolver

        public CosmosClientBuilder tokenResolver​(TokenResolver tokenResolver)
        Sets the token resolver
        Parameters:
        tokenResolver -
        Returns:
        current builder
      • endpoint

        public String endpoint()
        Gets the Azure Cosmos DB endpoint the SDK will connect to
        Returns:
        the endpoint
      • endpoint

        public CosmosClientBuilder endpoint​(String endpoint)
        Sets the Azure Cosmos DB endpoint the SDK will connect to
        Parameters:
        endpoint - the service endpoint
        Returns:
        current Builder
      • key

        public String key()
        Gets either a master or readonly key used to perform authentication for accessing resource.
        Returns:
        the key
      • key

        public CosmosClientBuilder key​(String key)
        Sets either a master or readonly key used to perform authentication for accessing resource.
        Parameters:
        key - master or readonly key
        Returns:
        current Builder.
      • resourceToken

        public String resourceToken()
        Sets a resource token used to perform authentication for accessing resource.
        Returns:
        the resourceToken
      • resourceToken

        public CosmosClientBuilder resourceToken​(String resourceToken)
        Sets a resource token used to perform authentication for accessing resource.
        Parameters:
        resourceToken - resourceToken for authentication
        Returns:
        current Builder.
      • permissions

        public List<com.azure.data.cosmos.internal.Permission> permissions()
        Gets the permission list, which contains the resource tokens needed to access resources.
        Returns:
        the permission list
      • permissions

        public CosmosClientBuilder permissions​(List<com.azure.data.cosmos.internal.Permission> permissions)
        Sets the permission list, which contains the resource tokens needed to access resources.
        Parameters:
        permissions - Permission list for authentication.
        Returns:
        current Builder.
      • connectionPolicy

        public ConnectionPolicy connectionPolicy()
        Gets the (@link ConnectionPolicy) to be used
        Returns:
        the connection policy
      • build

        public CosmosClient build()
        Builds a cosmos configuration object with the provided properties
        Returns:
        CosmosClient
      • buildSyncClient

        public CosmosSyncClient buildSyncClient()
        Builds a cosmos sync client object with the provided properties
        Returns:
        CosmosSyncClient