CosmosEncryptionClientBuilder Class

  • java.lang.Object
    • com.azure.cosmos.encryption.CosmosEncryptionClientBuilder

public class 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 in , we can input  in 

 
 CosmosEncryptionAsyncClient cosmosEncryptionAsyncClient = new CosmosEncryptionClientBuilder()
         .cosmosAsyncClient(cosmosAsyncClient)
         .keyEncryptionKeyResolver(keyEncryptionKeyResolver)
         .keyEncryptionKeyResolverName(keyEncryptionKeyResolverName)
         .buildAsyncClient();
Building Cosmos Encryption Sync Client minimal APIs
     If Azure key vault is used in , we can input  in 
  * 
 CosmosEncryptionClient client = new CosmosEncryptionClientBuilder()
         .cosmosClient(cosmosClient)
         .keyEncryptionKeyResolver(keyEncryptionKeyResolver)
         .keyEncryptionKeyResolverName(keyEncryptionKeyResolverName)
         .buildClient();

Field Summary

Modifier and Type Field and Description
static final String KEY_RESOLVER_NAME_AZURE_KEY_VAULT

KeyEncryptionKeyResolver name for keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName) if Azure key vault resolver is being used in keyEncryptionKeyResolver(KeyEncryptionKeyResolver keyEncryptionKeyResolver).

Constructor Summary

Constructor Description
CosmosEncryptionClientBuilder()

Instantiates a new Cosmos encryption client builder.

Method Summary

Modifier and Type Method and Description
CosmosEncryptionAsyncClient buildAsyncClient()

Builds a cosmos encryption async client.

CosmosEncryptionClient buildClient()

Builds a cosmos encryption async client.

CosmosEncryptionClientBuilder cosmosAsyncClient(CosmosAsyncClient cosmosAsyncClient)

Sets the cosmos core async client to be used.

CosmosEncryptionClientBuilder cosmosClient(CosmosClient cosmosClient)

Sets the cosmos core sync client to be used.

CosmosEncryptionClientBuilder keyEncryptionKeyResolver(KeyEncryptionKeyResolver keyEncryptionKeyResolver)

Sets the key wrap provider

CosmosEncryptionClientBuilder keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName)

Sets the key encryption key resolver name

Methods inherited from java.lang.Object

Field Details

KEY_RESOLVER_NAME_AZURE_KEY_VAULT

public static final String KEY_RESOLVER_NAME_AZURE_KEY_VAULT

KeyEncryptionKeyResolver name for keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName) if Azure key vault resolver is being used in keyEncryptionKeyResolver(KeyEncryptionKeyResolver keyEncryptionKeyResolver).

Constructor Details

CosmosEncryptionClientBuilder

public CosmosEncryptionClientBuilder()

Instantiates a new Cosmos encryption client builder.

Method Details

buildAsyncClient

public CosmosEncryptionAsyncClient buildAsyncClient()

Builds a cosmos encryption async client.

Returns:

CosmosEncryptionAsyncClient Cosmos encryption async client

buildClient

public CosmosEncryptionClient buildClient()

Builds a cosmos encryption async client.

Returns:

CosmosEncryptionAsyncClient Cosmos encryption async client

cosmosAsyncClient

public CosmosEncryptionClientBuilder cosmosAsyncClient(CosmosAsyncClient cosmosAsyncClient)

Sets the cosmos core async client to be used.

Parameters:

cosmosAsyncClient - cosmos async client

Returns:

current CosmosEncryptionClientBuilder

cosmosClient

public CosmosEncryptionClientBuilder cosmosClient(CosmosClient 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 of KeyEncryptionKeyResolver

Returns:

current CosmosEncryptionClientBuilder

keyEncryptionKeyResolverName

public CosmosEncryptionClientBuilder keyEncryptionKeyResolverName(String keyEncryptionKeyResolverName)

Sets the key encryption key resolver name

Parameters:

keyEncryptionKeyResolverName - custom KeyEncryptionKeyResolver name

Returns:

current CosmosEncryptionClientBuilder

Applies to