Class CosmosEncryptionClientBuilder

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

public class CosmosEncryptionClientBuilder extends Object
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 keyEncryptionKeyResolver(KeyEncryptionKeyResolver), we can input KEY_RESOLVER_NAME_AZURE_KEY_VAULT in keyEncryptionKeyResolverName(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 in keyEncryptionKeyResolver(KeyEncryptionKeyResolver), we can input KEY_RESOLVER_NAME_AZURE_KEY_VAULT in keyEncryptionKeyResolverName(String)
  * 
 CosmosEncryptionClient client = new CosmosEncryptionClientBuilder()
         .cosmosClient(cosmosClient)
         .keyEncryptionKeyResolver(keyEncryptionKeyResolver)
         .keyEncryptionKeyResolverName(keyEncryptionKeyResolverName)
         .buildClient();
 
 
  • Field Details

  • Constructor Details

    • CosmosEncryptionClientBuilder

      public CosmosEncryptionClientBuilder()
      Instantiates a new Cosmos encryption client builder.
  • Method Details

    • 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(com.azure.core.cryptography.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
    • 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