public final class SecretClientBuilder extends Object
secret client,
calling build constructs an instance of the client.
The minimal configuration options required by secretClientBuilder to build SecretClient
are endpoint and credential.
SecretClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credential(keyVaultCredential)
.build();
The log detail level, multiple custom policies and custom
http client can be optionally configured in the SecretClientBuilder.
SecretClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credential(keyVaultCredential)
.httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS)
.addPolicy(customPolicyOne)
.addPolicy(customPolicyTwo)
.httpClient(client)
.build();
Alternatively, custom http pipeline with custom HttpPipelinePolicy policies and endpoint
can be specified. It provides finer control over the construction of client
SecretClient.builder()
.pipeline(new HttpPipeline(customPoliciesList))
.endpoint("https://myvault.vault.azure.net/")
.build()
SecretClient| Modifier and Type | Method and Description |
|---|---|
SecretClientBuilder |
addPolicy(HttpPipelinePolicy policy)
Adds a policy to the set of existing policies that are executed after
SecretClient required policies. |
SecretClient |
build()
Creates a
SecretClient based on options set in the builder. |
SecretClientBuilder |
credential(TokenCredential credential)
Sets the credential to use when authenticating HTTP requests.
|
SecretClientBuilder |
endpoint(String endpoint)
Sets the vault endpoint url to send HTTP requests to.
|
SecretClientBuilder |
httpClient(HttpClient client)
Sets the HTTP client to use for sending and receiving requests to and from the service.
|
SecretClientBuilder |
httpLogDetailLevel(HttpLogDetailLevel logLevel)
Sets the logging level for HTTP requests and responses.
|
SecretClientBuilder |
pipeline(HttpPipeline pipeline)
Sets the HTTP pipeline to use for the service client.
|
public SecretClient build()
SecretClient based on options set in the builder.
Every time build() is called, a new instance of SecretClient is created.
If pipeline is set, then the pipeline and
serviceEndpoint are used to create the
client. All other builder settings are ignored. If pipeline is not set,
then key vault credential and
{@link SecretClientBuilder#endpoint(String)} key vault endpoint are required to build the {@link SecretClient client}.
IllegalStateException - If SecretClientBuilder.credential(TokenCredential) or
SecretClientBuilder.endpoint(String) have not been set.public SecretClientBuilder endpoint(String endpoint)
endpoint - The vault endpoint url is used as destination on Azure to send requests to.IllegalArgumentException - if endpoint is null or it cannot be parsed into a valid URL.public SecretClientBuilder credential(TokenCredential credential)
credential - The credential to use for authenticating HTTP requests.NullPointerException - if credential is null.public SecretClientBuilder httpLogDetailLevel(HttpLogDetailLevel logLevel)
logLevel is optional. If not provided, default value of HttpLogDetailLevel.NONE is set.
logLevel - The amount of logging output when sending and receiving HTTP requests/responses.NullPointerException - if logLevel is null.public SecretClientBuilder addPolicy(HttpPipelinePolicy policy)
SecretClient required policies.policy - The policy to be added.NullPointerException - if policy is null.public SecretClientBuilder httpClient(HttpClient client)
client - The HTTP client to use for requests.NullPointerException - If client is null.public SecretClientBuilder pipeline(HttpPipeline pipeline)
pipeline is set, all other settings are ignored, aside from
endpoint to build SecretClient.pipeline - The HTTP pipeline to use for sending service requests and receiving responses.SecretClientBuilder object.Copyright © 2019 Microsoft Corporation. All rights reserved.