Package com.azure.cosmos.encryption
Class CosmosEncryptionClientBuilder
java.lang.Object
com.azure.cosmos.encryption.CosmosEncryptionClientBuilder
Helper class to build
CosmosEncryptionAsyncClient
and CosmosEncryptionClient
instances as logical representation of the Azure Cosmos database service.
When building client, cosmosAsyncClient()/cosmosClient(), keyEncryptionKeyResolver() and keyEncryptionKeyResolverName() are mandatory APIs, without these the initialization will fail.
Building Cosmos Encryption Async Client APIs. If Azure key vault is used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver)
, we can inputKEY_RESOLVER_NAME_AZURE_KEY_VAULT
inkeyEncryptionKeyResolverName(String)
CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient = new CosmosEncryptionClientBuilder() .cosmosAsyncClient(cosmosAsyncClient) .keyEncryptionKeyResolver(keyEncryptionKeyResolver) .keyEncryptionKeyResolverName(keyEncryptionKeyResolverName) .buildAsyncClient();
Building Cosmos Encryption Sync Client minimal APIs If Azure key vault is used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver)
, we can inputKEY_RESOLVER_NAME_AZURE_KEY_VAULT
inkeyEncryptionKeyResolverName(String)
*CosmosEncryptionClient client = new CosmosEncryptionClientBuilder() .cosmosClient(cosmosClient) .keyEncryptionKeyResolver(keyEncryptionKeyResolver) .keyEncryptionKeyResolverName(keyEncryptionKeyResolverName) .buildClient();
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
KeyEncryptionKeyResolver name forkeyEncryptionKeyResolverName(String)
if Azure key vault resolver is being used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver)
. -
Constructor Summary
ConstructorDescriptionInstantiates a new Cosmos encryption client builder. -
Method Summary
Modifier and TypeMethodDescriptionBuilds a cosmos encryption async client.Builds a cosmos encryption async client.cosmosAsyncClient
(CosmosAsyncClient cosmosAsyncClient) Sets the cosmos core async client to be used.cosmosClient
(CosmosClient cosmosClient) Sets the cosmos core sync client to be used.keyEncryptionKeyResolver
(KeyEncryptionKeyResolver keyEncryptionKeyResolver) Sets the key wrap providerkeyEncryptionKeyResolverName
(String keyEncryptionKeyResolverName) Sets the key encryption key resolver name
-
Field Details
-
KEY_RESOLVER_NAME_AZURE_KEY_VAULT
KeyEncryptionKeyResolver name forkeyEncryptionKeyResolverName(String)
if Azure key vault resolver is being used inkeyEncryptionKeyResolver(KeyEncryptionKeyResolver)
.- See Also:
-
-
Constructor Details
-
CosmosEncryptionClientBuilder
public CosmosEncryptionClientBuilder()Instantiates a new Cosmos encryption client builder.
-
-
Method Details
-
cosmosAsyncClient
Sets the cosmos core async client to be used.- Parameters:
cosmosAsyncClient
- cosmos async client- Returns:
- current CosmosEncryptionClientBuilder
-
cosmosClient
Sets the cosmos core sync client to be used.- Parameters:
cosmosClient
- cosmos sync client- Returns:
- current CosmosEncryptionClientBuilder
-
keyEncryptionKeyResolver
public CosmosEncryptionClientBuilder keyEncryptionKeyResolver(KeyEncryptionKeyResolver keyEncryptionKeyResolver) Sets the key wrap provider- Parameters:
keyEncryptionKeyResolver
- custom keyEncryptionKeyResolver implementation ofKeyEncryptionKeyResolver
- Returns:
- current CosmosEncryptionClientBuilder
-
keyEncryptionKeyResolverName
public CosmosEncryptionClientBuilder keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName) Sets the key encryption key resolver name- Parameters:
keyEncryptionKeyResolverName
- customKeyEncryptionKeyResolver
name- Returns:
- current CosmosEncryptionClientBuilder
-
buildAsyncClient
Builds a cosmos encryption async client.- Returns:
- CosmosEncryptionAsyncClient Cosmos encryption async client
-
buildClient
Builds a cosmos encryption async client.- Returns:
- CosmosEncryptionAsyncClient Cosmos encryption async client
-