public class CosmosClientBuilder extends Object
CosmosAsyncClient
instances
as logical representation of the Azure Cosmos database service.
ConnectionPolicy getConnectionPolicy = new ConnectionPolicy();
getConnectionPolicy.getConnectionMode(ConnectionMode.DIRECT);
CosmonsClient client = new CosmosAsyncClient.cosmosClientBuilder()
.getEndpoint(serviceEndpoint)
.getKey(getKey)
.getConnectionPolicy(getConnectionPolicy)
.getConsistencyLevel(ConsistencyLevel.SESSION)
.buildAsyncClient();
Constructor and Description |
---|
CosmosClientBuilder() |
Modifier and Type | Method and Description |
---|---|
CosmosAsyncClient |
buildAsyncClient()
Builds a cosmos configuration object with the provided properties
|
CosmosClient |
buildClient()
Builds a cosmos sync client object with the provided properties
|
void |
enableSessionCapturing(boolean sessionCapturingOverride)
Session capturing is enabled by default for
ConsistencyLevel.SESSION . |
ConnectionPolicy |
getConnectionPolicy()
Gets the (@link ConnectionPolicy) to be used
|
ConsistencyLevel |
getConsistencyLevel()
Gets the
ConsistencyLevel to be used |
CosmosKeyCredential |
getCosmosKeyCredential()
Gets the
CosmosKeyCredential to be used |
String |
getEndpoint()
Gets the Azure Cosmos DB endpoint the SDK will connect to
|
String |
getKey()
Gets either a master or readonly key used to perform authentication
for accessing resource.
|
List<com.azure.cosmos.implementation.Permission> |
getPermissions()
Gets the permission list, which contains the
resource tokens needed to access resources.
|
String |
getResourceToken()
Sets a resource token used to perform authentication
for accessing resource.
|
TokenResolver |
getTokenResolver()
Gets the token resolver
|
boolean |
isSessionCapturingOverride()
Indicates if Session capturing is enabled for non Session modes.
|
CosmosClientBuilder |
setConnectionPolicy(ConnectionPolicy connectionPolicy)
Sets the
ConnectionPolicy to be used |
CosmosClientBuilder |
setConsistencyLevel(ConsistencyLevel desiredConsistencyLevel)
Sets the
ConsistencyLevel to be used |
CosmosClientBuilder |
setCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential)
Sets the
CosmosKeyCredential to be used |
CosmosClientBuilder |
setEndpoint(String endpoint)
Sets the Azure Cosmos DB endpoint the SDK will connect to
|
CosmosClientBuilder |
setKey(String key)
Sets either a master or readonly key used to perform authentication
for accessing resource.
|
CosmosClientBuilder |
setPermissions(List<com.azure.cosmos.implementation.Permission> permissions)
Sets the permission list, which contains the
resource tokens needed to access resources.
|
CosmosClientBuilder |
setResourceToken(String resourceToken)
Sets a resource token used to perform authentication
for accessing resource.
|
CosmosClientBuilder |
setTokenResolver(TokenResolver tokenResolver)
Sets the token resolver
|
public void enableSessionCapturing(boolean sessionCapturingOverride)
ConsistencyLevel.SESSION
.
For other consistency levels, it is not needed, unless if you need occasionally send requests with Session
Consistency while the client is not configured in session.
enabling Session capturing for Session mode has no effect.sessionCapturingOverride
- the session capturing overridepublic boolean isSessionCapturingOverride()
public TokenResolver getTokenResolver()
public CosmosClientBuilder setTokenResolver(TokenResolver tokenResolver)
tokenResolver
- the token resolverpublic String getEndpoint()
public CosmosClientBuilder setEndpoint(String endpoint)
endpoint
- the service endpointpublic String getKey()
public CosmosClientBuilder setKey(String key)
key
- master or readonly keypublic String getResourceToken()
public CosmosClientBuilder setResourceToken(String resourceToken)
resourceToken
- resourceToken for authenticationpublic List<com.azure.cosmos.implementation.Permission> getPermissions()
public CosmosClientBuilder setPermissions(List<com.azure.cosmos.implementation.Permission> permissions)
permissions
- Permission list for authentication.public ConsistencyLevel getConsistencyLevel()
ConsistencyLevel
to be usedpublic CosmosClientBuilder setConsistencyLevel(ConsistencyLevel desiredConsistencyLevel)
ConsistencyLevel
to be useddesiredConsistencyLevel
- ConsistencyLevel
public ConnectionPolicy getConnectionPolicy()
public CosmosClientBuilder setConnectionPolicy(ConnectionPolicy connectionPolicy)
ConnectionPolicy
to be usedconnectionPolicy
- ConnectionPolicy
public CosmosKeyCredential getCosmosKeyCredential()
CosmosKeyCredential
to be usedpublic CosmosClientBuilder setCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential)
CosmosKeyCredential
to be usedcosmosKeyCredential
- CosmosKeyCredential
public CosmosAsyncClient buildAsyncClient()
public CosmosClient buildClient()
Copyright © 2020 Microsoft Corporation. All rights reserved.