Class SchemaRegistryClientBuilder
- All Implemented Interfaces:
ConfigurationTrait<SchemaRegistryClientBuilder>
,HttpTrait<SchemaRegistryClientBuilder>
,TokenCredentialTrait<SchemaRegistryClientBuilder>
SchemaRegistryAsyncClient
and
SchemaRegistryClient
. To build the client, the builder requires the service endpoint of the Schema Registry
and an Azure AD credential.
Instantiating the client
// AAD credential to authorize with Schema Registry service. DefaultAzureCredential azureCredential = new DefaultAzureCredentialBuilder() .build(); SchemaRegistryClient client = new SchemaRegistryClientBuilder() .fullyQualifiedNamespace("https://<your-schema-registry-endpoint>.servicebus.windows.net") .credential(azureCredential) .buildClient();
Instantiating the async client
// AAD credential to authorize with Schema Registry service. DefaultAzureCredential azureCredential = new DefaultAzureCredentialBuilder() .build(); SchemaRegistryAsyncClient client = new SchemaRegistryClientBuilder() .fullyQualifiedNamespace("https://<your-schema-registry-endpoint>.servicebus.windows.net") .credential(azureCredential) .buildAsyncClient();
Instantiating with custom retry policy and HTTP log options
DefaultAzureCredential azureCredential = new DefaultAzureCredentialBuilder() .build(); HttpLogOptions httpLogOptions = new HttpLogOptions() .setLogLevel(HttpLogDetailLevel.BODY) .setPrettyPrintBody(true); RetryPolicy retryPolicy = new RetryPolicy(new FixedDelay(5, Duration.ofSeconds(30))); SchemaRegistryAsyncClient client = new SchemaRegistryClientBuilder() .fullyQualifiedNamespace("https://<your-schema-registry-endpoint>.servicebus.windows.net") .httpLogOptions(httpLogOptions) .retryPolicy(retryPolicy) .credential(azureCredential) .buildAsyncClient();
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPolicy
(HttpPipelinePolicy policy) Adds apipeline policy
to apply on each request sent.Creates aSchemaRegistryAsyncClient
based on options set in the builder.Creates synchronousSchemaRegistryClient
instance.clientOptions
(ClientOptions clientOptions) Allows for setting common properties such as application ID, headers, proxy configuration, etc.configuration
(Configuration configuration) Sets the configuration store that is used during construction of the service client.credential
(TokenCredential credential) Sets theTokenCredential
used to authorize requests sent to the service.fullyQualifiedNamespace
(String fullyQualifiedNamespace) Sets the fully qualified namespace for the Azure Schema Registry instance.httpClient
(HttpClient httpClient) Sets theHttpClient
to use for sending and receiving requests to and from the service.httpLogOptions
(HttpLogOptions logOptions) Sets thelogging configuration
to use when sending and receiving requests to and from the service.pipeline
(HttpPipeline httpPipeline) Sets theHttpPipeline
to use for the service client.retryOptions
(RetryOptions retryOptions) Sets theRetryOptions
for all the requests made through the client.retryPolicy
(RetryPolicy retryPolicy) Sets theRetryPolicy
that is used when each request is sent.serviceVersion
(ServiceVersion serviceVersion) Sets the service version to use.
-
Constructor Details
-
SchemaRegistryClientBuilder
public SchemaRegistryClientBuilder()Constructor for SchemaRegistryClientBuilder. Supplies client defaults.
-
-
Method Details
-
fullyQualifiedNamespace
Sets the fully qualified namespace for the Azure Schema Registry instance. This is likely to be similar to "{your-namespace}.servicebus.windows.net".- Parameters:
fullyQualifiedNamespace
- The fully qualified namespace of the Azure Schema Registry instance.- Returns:
- The updated
SchemaRegistryClientBuilder
object. - Throws:
NullPointerException
- iffullyQualifiedNamespace
is nullIllegalArgumentException
- iffullyQualifiedNamespace
cannot be parsed into a valid URL
-
httpClient
Sets theHttpClient
to use for sending and receiving requests to and from the service.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpClient
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
httpClient
- TheHttpClient
to use for requests.- Returns:
- The updated
SchemaRegistryClientBuilder
object.
-
pipeline
Sets theHttpPipeline
to use for the service client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.If
pipeline
is set, all other HTTP settings are ignored to buildSchemaRegistryAsyncClient
.- Specified by:
pipeline
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
httpPipeline
-HttpPipeline
to use for sending service requests and receiving responses.- Returns:
- The updated
SchemaRegistryClientBuilder
object.
-
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.NONE
to bypass using configuration settings during construction.- Specified by:
configuration
in interfaceConfigurationTrait<SchemaRegistryClientBuilder>
- Parameters:
configuration
- The configuration store used to- Returns:
- The updated SchemaRegistryClientBuilder object.
-
credential
Sets theTokenCredential
used to authorize requests sent to the service. Refer to the Azure SDK for Java identity and authentication documentation for more details on proper usage of theTokenCredential
type.- Specified by:
credential
in interfaceTokenCredentialTrait<SchemaRegistryClientBuilder>
- Parameters:
credential
-TokenCredential
used to authorize requests sent to the service.- Returns:
- The updated
SchemaRegistryClientBuilder
object. - Throws:
NullPointerException
- Ifcredential
isnull
-
clientOptions
Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is recommended that this method be called with an instance of theHttpClientOptions
class (a subclass of theClientOptions
base class). The HttpClientOptions subclass provides more configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait interface.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
clientOptions
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
clientOptions
- A configured instance ofHttpClientOptions
.- Returns:
- The updated SchemaRegistryClientBuilder object.
- See Also:
-
httpLogOptions
Sets thelogging configuration
to use when sending and receiving requests to and from the service. If alogLevel
is not provided, default value ofHttpLogDetailLevel.NONE
is set.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpLogOptions
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
logOptions
- Thelogging configuration
to use when sending and receiving requests to and from the service.- Returns:
- The updated
SchemaRegistryClientBuilder
object.
-
retryPolicy
Sets theRetryPolicy
that is used when each request is sent.The default retry policy will be used if not provided to build
SchemaRegistryAsyncClient
.Setting this is mutually exclusive with using
retryOptions(RetryOptions)
.- Parameters:
retryPolicy
- user's retry policy applied to each request.- Returns:
- The updated
SchemaRegistryClientBuilder
object.
-
retryOptions
Sets theRetryOptions
for all the requests made through the client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.Setting this is mutually exclusive with using
retryPolicy(RetryPolicy)
.- Specified by:
retryOptions
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
retryOptions
- TheRetryOptions
to use for all the requests made through the client.- Returns:
- The updated
SchemaRegistryClientBuilder
object.
-
serviceVersion
Sets the service version to use.- Parameters:
serviceVersion
- Service version.- Returns:
- The updated instance.
-
addPolicy
Adds apipeline policy
to apply on each request sent.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
addPolicy
in interfaceHttpTrait<SchemaRegistryClientBuilder>
- Parameters:
policy
- Apipeline policy
.- Returns:
- The updated
SchemaRegistryClientBuilder
object. - Throws:
NullPointerException
- Ifpolicy
isnull
.
-
buildAsyncClient
Creates aSchemaRegistryAsyncClient
based on options set in the builder. Every timebuildClient()
is called a new instance ofSchemaRegistryAsyncClient
is created. Ifpipeline
is set, then all HTTP pipeline related settings are ignored.- Returns:
- A
SchemaRegistryAsyncClient
with the options set from the builder. - Throws:
NullPointerException
- iffullyQualifiedNamespace
andcredential
are not set.IllegalArgumentException
- iffullyQualifiedNamespace
is an empty string.IllegalStateException
- If bothretryOptions(RetryOptions)
andretryPolicy(RetryPolicy)
have been set.
-
buildClient
Creates synchronousSchemaRegistryClient
instance. See async builder method for options validation.- Returns:
SchemaRegistryClient
with the options set from the builder.- Throws:
NullPointerException
- ifendpoint
andcredential
are not set.IllegalStateException
- If bothretryOptions(RetryOptions)
andretryPolicy(RetryPolicy)
have been set.
-