Class KeyEncryptionKeyClientBuilder
- java.lang.Object
-
- com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClientBuilder
-
- All Implemented Interfaces:
com.azure.core.cryptography.AsyncKeyEncryptionKeyResolver,com.azure.core.cryptography.KeyEncryptionKeyResolver
public final class KeyEncryptionKeyClientBuilder extends Object implements com.azure.core.cryptography.KeyEncryptionKeyResolver, com.azure.core.cryptography.AsyncKeyEncryptionKeyResolver
This class provides a fluent builder API to help aid the configuration and instantiation of theKeyEncryptionKey async clientandKeyEncryptionKey sync client, by callingbuildAsyncKeyEncryptionKey(String)andbuildKeyEncryptionKey(String)respectively. It constructs an instance of the desired client.The minimal configuration options required by
KeyEncryptionKeyClientBuilderto buildAsyncKeyEncryptionKeyarejsonWebKeyorAzure Key Vault key identifierandcredential.The
log detail level, multiple custompoliciesand customhttp clientcan be optionally configured in theKeyEncryptionKeyClientBuilder.Alternatively, a custom
http pipelinewith customHttpPipelinePolicypolicies can be specified. It provides finer control over the construction ofAsyncKeyEncryptionKeyandKeyEncryptionKeyThe minimal configuration options required by
keyEncryptionKeyClientBuilderto buildKeyEncryptionKeyarejsonWebKeyorAzure Key Vault key identifierandcredential.
-
-
Constructor Summary
Constructors Constructor Description KeyEncryptionKeyClientBuilder()The constructor with defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyEncryptionKeyClientBuilderaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)Adds a policy to the set of existing policies that are executed after the client required policies.Mono<? extends com.azure.core.cryptography.AsyncKeyEncryptionKey>buildAsyncKeyEncryptionKey(JsonWebKey key)Creates a localKeyEncryptionKeyAsyncClientbased on options set in the builder.Mono<? extends com.azure.core.cryptography.AsyncKeyEncryptionKey>buildAsyncKeyEncryptionKey(String keyId)Creates aKeyEncryptionKeyAsyncClientbased on options set in the builder.com.azure.core.cryptography.KeyEncryptionKeybuildKeyEncryptionKey(JsonWebKey key)Creates a localKeyEncryptionKeyClientfor a given JSON Web Key.com.azure.core.cryptography.KeyEncryptionKeybuildKeyEncryptionKey(String keyId)Creates aKeyEncryptionKeybased on options set in the builder.KeyEncryptionKeyClientBuilderclientOptions(com.azure.core.util.ClientOptions clientOptions)Sets theClientOptionswhich enables various options to be set on the client.KeyEncryptionKeyClientBuilderconfiguration(com.azure.core.util.Configuration configuration)Sets the configuration store that is used during construction of the service client.KeyEncryptionKeyClientBuildercredential(com.azure.core.credential.TokenCredential credential)Sets the credential to use when authenticating HTTP requests.KeyEncryptionKeyClientBuilderhttpClient(com.azure.core.http.HttpClient client)Sets the HTTP client to use for sending and receiving requests to and from the service.KeyEncryptionKeyClientBuilderhttpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)Sets the logging configuration for HTTP requests and responses.KeyEncryptionKeyClientBuilderpipeline(com.azure.core.http.HttpPipeline pipeline)Sets the HTTP pipeline to use for the service client.KeyEncryptionKeyClientBuilderretryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)Sets theRetryPolicythat is used when each request is sent.KeyEncryptionKeyClientBuilderserviceVersion(CryptographyServiceVersion version)Sets theCryptographyServiceVersionthat is used when making API requests.
-
-
-
Method Detail
-
buildKeyEncryptionKey
public com.azure.core.cryptography.KeyEncryptionKey buildKeyEncryptionKey(String keyId)
Creates aKeyEncryptionKeybased on options set in the builder. Every timebuildKeyEncryptionKey(String)is called, a new instance ofKeyEncryptionKeyis created.If
pipelineis set, then thepipelineandkeyIdare used to create theclient. All other builder settings are ignored. Ifpipelineis not set, then anAzure Key Vault credentialandkeyIdare required to build theclient.- Specified by:
buildKeyEncryptionKeyin interfacecom.azure.core.cryptography.KeyEncryptionKeyResolver- Returns:
- A
KeyEncryptionKeyClientwith the options set from the builder. - Throws:
IllegalStateException- Ifcredential(TokenCredential)orkeyIdhave not been set.
-
buildKeyEncryptionKey
public com.azure.core.cryptography.KeyEncryptionKey buildKeyEncryptionKey(JsonWebKey key)
Creates a localKeyEncryptionKeyClientfor a given JSON Web Key. Every timebuildKeyEncryptionKey(JsonWebKey)is called, a new instance ofKeyEncryptionKeyis created. For local clients, all other builder settings are ignored.The
keyis required to build theclient.- Parameters:
key- TheJsonWebKeyto be used for cryptography operations.- Returns:
- A
KeyEncryptionKeyClientwith the options set from the builder. - Throws:
IllegalStateException- If {keyis not set.
-
buildAsyncKeyEncryptionKey
public Mono<? extends com.azure.core.cryptography.AsyncKeyEncryptionKey> buildAsyncKeyEncryptionKey(String keyId)
Creates aKeyEncryptionKeyAsyncClientbased on options set in the builder. Every timebuildAsyncKeyEncryptionKey(String)is called, a new instance ofKeyEncryptionKeyAsyncClientis created.If
pipelineis set, then thepipelineandkeyIdare used to create theasync client. All other builder settings are ignored. Ifpipelineis not set, then anAzure Key Vault credentialsandkeyIdare required to build theasync client.- Specified by:
buildAsyncKeyEncryptionKeyin interfacecom.azure.core.cryptography.AsyncKeyEncryptionKeyResolver- Returns:
- A
KeyEncryptionKeyAsyncClientwith the options set from the builder. - Throws:
IllegalStateException- Ifcredential(TokenCredential)isnullorkeyIdis empty ornull.
-
buildAsyncKeyEncryptionKey
public Mono<? extends com.azure.core.cryptography.AsyncKeyEncryptionKey> buildAsyncKeyEncryptionKey(JsonWebKey key)
Creates a localKeyEncryptionKeyAsyncClientbased on options set in the builder. Every timebuildAsyncKeyEncryptionKey(String)is called, a new instance ofKeyEncryptionKeyAsyncClientis created. For local clients, all other builder settings are ignored.The
keyis required to build theclient.- Parameters:
key- The key to be used for cryptography operations.- Returns:
- A
KeyEncryptionKeyAsyncClientwith the options set from the builder. - Throws:
IllegalArgumentException- Ifkeyhas no id.IllegalStateException- Ifkeyisnull.
-
credential
public KeyEncryptionKeyClientBuilder credential(com.azure.core.credential.TokenCredential credential)
Sets the credential to use when authenticating HTTP requests.- Parameters:
credential- The credential to use for authenticating HTTP requests.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject. - Throws:
NullPointerException- Ifcredentialisnull.
-
httpLogOptions
public KeyEncryptionKeyClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
Sets the logging configuration for HTTP requests and responses.If logLevel is not provided, default value of
HttpLogDetailLevel.NONEis set.- Parameters:
logOptions- The logging configuration to use when sending and receiving HTTP requests/responses.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
addPolicy
public KeyEncryptionKeyClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
Adds a policy to the set of existing policies that are executed after the client required policies.- Parameters:
policy- Thepolicyto be added.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject. - Throws:
NullPointerException- Ifpolicyisnull.
-
httpClient
public KeyEncryptionKeyClientBuilder httpClient(com.azure.core.http.HttpClient client)
Sets the HTTP client to use for sending and receiving requests to and from the service.- Parameters:
client- The HTTP client to use for requests.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
pipeline
public KeyEncryptionKeyClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
Sets the HTTP pipeline to use for the service client. Ifpipelineis set, all other settings are ignored, aside from jsonWebKey identifier or jsonWebKey to build the clients.- Parameters:
pipeline- The HTTP pipeline to use for sending service requests and receiving responses.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
configuration
public KeyEncryptionKeyClientBuilder configuration(com.azure.core.util.Configuration configuration)
Sets the configuration store that is used during construction of the service client. The default configuration store is a clone of theglobal configuration store, useConfiguration.NONEto bypass using configuration settings during construction.- Parameters:
configuration- The configuration store used to get configuration details.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
serviceVersion
public KeyEncryptionKeyClientBuilder serviceVersion(CryptographyServiceVersion version)
Sets theCryptographyServiceVersionthat is used when making API requests.If a service version is not provided, the service version that will be used will be the latest known service version based on the version of the client library being used. If no service version is specified, updating to a newer version the client library will have the result of potentially moving to a newer service version.
- Parameters:
version-CryptographyServiceVersionof the service to be used when making requests.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
retryPolicy
public KeyEncryptionKeyClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
Sets theRetryPolicythat is used when each request is sent. The default retry policy will be used in the pipeline, if not provided.- Parameters:
retryPolicy- User's retry policy applied to each request.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
clientOptions
public KeyEncryptionKeyClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
Sets theClientOptionswhich enables various options to be set on the client. For example setting anapplicationIdusingClientOptions.setApplicationId(String)to configure theUserAgentPolicyfor telemetry/monitoring purposes.More About Azure Core: Telemetry policy
- Parameters:
clientOptions- TheClientOptionsto be set on the client.- Returns:
- The updated
KeyEncryptionKeyClientBuilderobject.
-
-