public final class ContainerRegistryClientBuilder extends Object
ContainerRegistryClients
and ContainerRegistryAsyncClients
, call buildClient
and buildAsyncClient
respectively to construct an instance of
the desired client.
The client needs the service endpoint of the Azure Container Registry and Azure access credentials.
Instantiating an asynchronous Container Registry client
ContainerRegistryAsyncClient
registryAsyncClient = newContainerRegistryClientBuilder
() .endpoint(endpoint) .credential(credential) .buildAsyncClient();
Instantiating a synchronous Container Registry client
ContainerRegistryClient
registryAsyncClient = newContainerRegistryClientBuilder
() .endpoint(endpoint) .credential(credential) .buildClient();
Another way to construct the client is using a HttpPipeline
. The pipeline gives the client an
authenticated way to communicate with the service but it doesn't contain the service endpoint. Set the pipeline with
this
and set the service endpoint with this
. Using a
pipeline requires additional setup but allows for finer control on how the ContainerRegistryClient
and ContainerRegistryAsyncClient
is built.
The service does not directly support AAD credentials and as a result the clients internally depend on a policy that converts the AAD credentials to the Azure Container Registry specific service credentials. In case you use your own pipeline, you would need to provide implementation for this policy as well. For more information please see Azure Container Registry Authentication .
Instantiating an asynchronous Container Registry client using a custom pipeline
HttpPipeline
pipeline = newHttpPipelineBuilder
() .policies(/* add policies */) .build();ContainerRegistryAsyncClient
registryAsyncClient = newContainerRegistryClientBuilder
() .pipeline(pipeline) .endpoint(endpoint) .credential(credential) .buildAsyncClient();
Instantiating a synchronous Container Registry client with custom pipeline
HttpPipeline
pipeline = newHttpPipelineBuilder
() .policies(/* add policies */) .build();ContainerRegistryClient
registryAsyncClient = newContainerRegistryClientBuilder
() .pipeline(pipeline) .endpoint(endpoint) .credential(credential) .buildClient();
Constructor and Description |
---|
ContainerRegistryClientBuilder() |
Modifier and Type | Method and Description |
---|---|
ContainerRegistryClientBuilder |
addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
Adds a policy to the set of existing policies.
|
ContainerRegistryClientBuilder |
authenticationScope(String authenticationScope)
Sets the authentication scope to be used for getting AAD credentials.
|
ContainerRegistryAsyncClient |
buildAsyncClient()
Creates a
ContainerRegistryAsyncClient based on options set in the Builder. |
ContainerRegistryClient |
buildClient()
Creates a
ContainerRegistryClient based on options set in the Builder. |
ContainerRegistryClientBuilder |
clientOptions(com.azure.core.util.ClientOptions clientOptions)
Sets the
ClientOptions which enables various options to be set on the client. |
ContainerRegistryClientBuilder |
configuration(com.azure.core.util.Configuration configuration)
Sets the configuration store that is used during construction of the service client.
|
ContainerRegistryClientBuilder |
credential(com.azure.core.credential.TokenCredential credential)
Sets the
TokenCredential used to authenticate REST API calls. |
ContainerRegistryClientBuilder |
endpoint(String endpoint)
Sets the service endpoint for the Azure Container Registry instance.
|
ContainerRegistryClientBuilder |
httpClient(com.azure.core.http.HttpClient httpClient)
Sets the HTTP client to use for sending and receiving requests to and from the service.
|
ContainerRegistryClientBuilder |
httpLogOptions(com.azure.core.http.policy.HttpLogOptions httpLogOptions)
Sets the logging configuration for HTTP requests and responses.
|
ContainerRegistryClientBuilder |
pipeline(com.azure.core.http.HttpPipeline httpPipeline)
Sets the HTTP pipeline to use for the service client.
|
ContainerRegistryClientBuilder |
retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
Sets the
HttpPipelinePolicy that is used to retry requests. |
ContainerRegistryClientBuilder |
serviceVersion(ContainerRegistryServiceVersion version)
Sets the
ContainerRegistryServiceVersion that is used when making API requests. |
public ContainerRegistryClientBuilder endpoint(String endpoint)
endpoint
- The URL of the Container Registry instance.ContainerRegistryClientBuilder
object.IllegalArgumentException
- If endpoint
is null or it cannot be parsed into a valid URL.public ContainerRegistryClientBuilder authenticationScope(String authenticationScope)
To connect to a different cloud, set this value to "<resource-id>/.default",
where <resource-id> is one of the Resource IDs listed at
https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/services-support-managed-identities#azure-resource-manager.
For example, to connect to the Azure Germany cloud, authenticationScope
is set to "https://management.microsoftazure.de/.default".
authenticationScope
- ARM management scope associated with the given registry.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder credential(com.azure.core.credential.TokenCredential credential)
TokenCredential
used to authenticate REST API calls.credential
- Azure token credentials used to authenticate HTTP requests.ContainerRegistryClientBuilder
object.NullPointerException
- if credential is null.public ContainerRegistryClientBuilder pipeline(com.azure.core.http.HttpPipeline httpPipeline)
If pipeline
is set, all settings other than endpoint
are ignored
to build ContainerRegistryAsyncClient
or ContainerRegistryClient
.
httpPipeline
- The HTTP pipeline to use for sending service requests and receiving responses.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder serviceVersion(ContainerRegistryServiceVersion version)
ContainerRegistryServiceVersion
that 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 and so newer version of the client library may result in moving to a newer service version.
version
- ContainerRegistryServiceVersion
of the service to be used when making requests.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder httpClient(com.azure.core.http.HttpClient httpClient)
httpClient
- The HTTP client to use for requests.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
ClientOptions
which enables various options to be set on the client. For example setting an
applicationId
using ClientOptions.setApplicationId(String)
to configure
the UserAgentPolicy
for telemetry/monitoring purposes.
More About Azure Core: Telemetry policy
clientOptions
- ClientOptions
.ContainerRegistryClientBuilder
objectpublic ContainerRegistryClientBuilder configuration(com.azure.core.util.Configuration configuration)
The default configuration store is a clone of the global
configuration store
, use Configuration.NONE
to bypass using configuration settings during construction.
configuration
- The configuration store to be used.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions httpLogOptions)
If logLevel is not provided, HTTP request or response logging will not happen.
httpLogOptions
- The logging configuration to use when sending and receiving HTTP requests/responses.ContainerRegistryClientBuilder
object.public ContainerRegistryClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
HttpPipelinePolicy
that is used to retry requests.
The default retry policy will be used if not provided ContainerRegistryClientBuilder.buildAsyncClient()
to
build ContainerRegistryClient
or ContainerRegistryAsyncClient
.
retryPolicy
- The HttpPipelinePolicy
that will be used to retry requests. For example,
RetryPolicy
can be used to retry requests.public ContainerRegistryClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
policy
- The policy for service requests.NullPointerException
- If policy
is null.public ContainerRegistryAsyncClient buildAsyncClient()
ContainerRegistryAsyncClient
based on options set in the Builder. Every time buildAsyncClient()
is called a new instance of ContainerRegistryAsyncClient
is created.
If ContainerRegistryClientBuilder.pipeline(HttpPipeline)
pipeline} is set, then the pipeline
and endpoint
are used to create the client
. All other builder settings are ignored.
ContainerRegistryAsyncClient
with the options set from the builder.NullPointerException
- If endpoint
has not been set. You can set it by calling ContainerRegistryClientBuilder.endpoint(String)
.NullPointerException
- If credential
or httpPipeline
has not been set.public ContainerRegistryClient buildClient()
ContainerRegistryClient
based on options set in the Builder. Every time buildAsyncClient()
is called a new instance of ContainerRegistryClient
is created.
If ContainerRegistryClientBuilder.pipeline(HttpPipeline)
pipeline} is set, then the pipeline
and endpoint
are used to create the client
.
All other builder settings are ignored.
ContainerRegistryClient
with the options set from the builder.NullPointerException
- If endpoint
has not been set. You can set it by calling ContainerRegistryClientBuilder.endpoint(String)
.NullPointerException
- If credential
or httpPipeline
has not been set.Copyright © 2021 Microsoft Corporation. All rights reserved.