Package com.azure.data.cosmos
Class CosmosClientBuilder
- java.lang.Object
-
- com.azure.data.cosmos.CosmosClientBuilder
-
public class CosmosClientBuilder extends Object
Helper class to buildCosmosClient
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 Summary
Constructors Constructor Description CosmosClientBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CosmosClient
build()
Builds a cosmos configuration object with the provided propertiesCosmosSyncClient
buildSyncClient()
Builds a cosmos sync client object with the provided propertiesConnectionPolicy
connectionPolicy()
Gets the (@link ConnectionPolicy) to be usedCosmosClientBuilder
connectionPolicy(ConnectionPolicy connectionPolicy)
Sets theConnectionPolicy
to be usedConsistencyLevel
consistencyLevel()
Gets theConsistencyLevel
to be usedCosmosClientBuilder
consistencyLevel(ConsistencyLevel desiredConsistencyLevel)
Sets theConsistencyLevel
to be usedCosmosKeyCredential
cosmosKeyCredential()
Gets theCosmosKeyCredential
to be usedCosmosClientBuilder
cosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential)
Sets theCosmosKeyCredential
to be usedString
endpoint()
Gets the Azure Cosmos DB endpoint the SDK will connect toCosmosClientBuilder
endpoint(String endpoint)
Sets the Azure Cosmos DB endpoint the SDK will connect toString
key()
Gets either a master or readonly key used to perform authentication for accessing resource.CosmosClientBuilder
key(String key)
Sets either a master or readonly key used to perform authentication for accessing resource.List<com.azure.data.cosmos.internal.Permission>
permissions()
Gets the permission list, which contains the resource tokens needed to access resources.CosmosClientBuilder
permissions(List<com.azure.data.cosmos.internal.Permission> permissions)
Sets the permission list, which contains the resource tokens needed to access resources.String
resourceToken()
Sets a resource token used to perform authentication for accessing resource.CosmosClientBuilder
resourceToken(String resourceToken)
Sets a resource token used to perform authentication for accessing resource.TokenResolver
tokenResolver()
Gets the token resolverCosmosClientBuilder
tokenResolver(TokenResolver tokenResolver)
Sets the token resolver
-
-
-
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.
-
consistencyLevel
public ConsistencyLevel consistencyLevel()
Gets theConsistencyLevel
to be used- Returns:
- the consistency level
-
consistencyLevel
public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyLevel)
Sets theConsistencyLevel
to be used- Parameters:
desiredConsistencyLevel
-ConsistencyLevel
- Returns:
- current Builder
-
connectionPolicy
public ConnectionPolicy connectionPolicy()
Gets the (@link ConnectionPolicy) to be used- Returns:
- the connection policy
-
connectionPolicy
public CosmosClientBuilder connectionPolicy(ConnectionPolicy connectionPolicy)
Sets theConnectionPolicy
to be used- Parameters:
connectionPolicy
-ConnectionPolicy
- Returns:
- current Builder
-
cosmosKeyCredential
public CosmosKeyCredential cosmosKeyCredential()
Gets theCosmosKeyCredential
to be used- Returns:
- cosmosKeyCredential
-
cosmosKeyCredential
public CosmosClientBuilder cosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential)
Sets theCosmosKeyCredential
to be used- Parameters:
cosmosKeyCredential
-CosmosKeyCredential
- Returns:
- current builder
-
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
-
-