Class SchemaRegistryClientBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.ConfigurationTrait<SchemaRegistryClientBuilder>,com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>,com.azure.core.client.traits.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy) Adds apipeline policyto apply on each request sent.Creates aSchemaRegistryAsyncClientbased on options set in the builder.Creates synchronousSchemaRegistryClientinstance.clientOptions(com.azure.core.util.ClientOptions clientOptions) Allows for setting common properties such as application ID, headers, proxy configuration, etc.configuration(com.azure.core.util.Configuration configuration) Sets the configuration store that is used during construction of the service client.credential(com.azure.core.credential.TokenCredential credential) Sets theTokenCredentialused to authorize requests sent to the service.fullyQualifiedNamespace(String fullyQualifiedNamespace) Sets the fully qualified namespace for the Azure Schema Registry instance.httpClient(com.azure.core.http.HttpClient httpClient) Sets theHttpClientto use for sending and receiving requests to and from the service.httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configurationto use when sending and receiving requests to and from the service.pipeline(com.azure.core.http.HttpPipeline httpPipeline) Sets theHttpPipelineto use for the service client.retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) Sets theRetryOptionsfor all the requests made through the client.retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy) Sets theRetryPolicythat is used when each request is sent.serviceVersion(com.azure.core.util.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
SchemaRegistryClientBuilderobject. - Throws:
NullPointerException- iffullyQualifiedNamespaceis nullIllegalArgumentException- iffullyQualifiedNamespacecannot be parsed into a valid URL
-
httpClient
Sets theHttpClientto 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
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis 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:
httpClientin interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
httpClient- TheHttpClientto use for requests.- Returns:
- The updated
SchemaRegistryClientBuilderobject.
-
pipeline
Sets theHttpPipelineto use for the service client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.If
pipelineis set, all other HTTP settings are ignored to buildSchemaRegistryAsyncClient.- Specified by:
pipelinein interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
httpPipeline-HttpPipelineto use for sending service requests and receiving responses.- Returns:
- The updated
SchemaRegistryClientBuilderobject.
-
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.- Specified by:
configurationin interfacecom.azure.core.client.traits.ConfigurationTrait<SchemaRegistryClientBuilder>- Parameters:
configuration- The configuration store used to- Returns:
- The updated SchemaRegistryClientBuilder object.
-
credential
Sets theTokenCredentialused 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 theTokenCredentialtype.- Specified by:
credentialin interfacecom.azure.core.client.traits.TokenCredentialTrait<SchemaRegistryClientBuilder>- Parameters:
credential-TokenCredentialused to authorize requests sent to the service.- Returns:
- The updated
SchemaRegistryClientBuilderobject. - Throws:
NullPointerException- Ifcredentialisnull
-
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 theHttpClientOptionsclass (a subclass of theClientOptionsbase 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
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis 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:
clientOptionsin interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
clientOptions- A configured instance ofHttpClientOptions.- Returns:
- The updated SchemaRegistryClientBuilder object.
- See Also:
-
HttpClientOptions
-
httpLogOptions
public SchemaRegistryClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configurationto use when sending and receiving requests to and from the service. If alogLevelis not provided, default value ofHttpLogDetailLevel.NONEis set.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis 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:
httpLogOptionsin interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
logOptions- Thelogging configurationto use when sending and receiving requests to and from the service.- Returns:
- The updated
SchemaRegistryClientBuilderobject.
-
retryPolicy
Sets theRetryPolicythat 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
SchemaRegistryClientBuilderobject.
-
retryOptions
public SchemaRegistryClientBuilder retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) Sets theRetryOptionsfor all the requests made through the client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis 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:
retryOptionsin interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
retryOptions- TheRetryOptionsto use for all the requests made through the client.- Returns:
- The updated
SchemaRegistryClientBuilderobject.
-
serviceVersion
public SchemaRegistryClientBuilder serviceVersion(com.azure.core.util.ServiceVersion serviceVersion) Sets the service version to use.- Parameters:
serviceVersion- Service version.- Returns:
- The updated instance.
-
addPolicy
Adds apipeline policyto apply on each request sent.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis 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 anHttpPipelineis 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:
addPolicyin interfacecom.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>- Parameters:
policy- Apipeline policy.- Returns:
- The updated
SchemaRegistryClientBuilderobject. - Throws:
NullPointerException- Ifpolicyisnull.
-
buildAsyncClient
Creates aSchemaRegistryAsyncClientbased on options set in the builder. Every timebuildClient()is called a new instance ofSchemaRegistryAsyncClientis created. Ifpipelineis set, then all HTTP pipeline related settings are ignored.- Returns:
- A
SchemaRegistryAsyncClientwith the options set from the builder. - Throws:
NullPointerException- iffullyQualifiedNamespaceandcredentialare not set.IllegalArgumentException- iffullyQualifiedNamespaceis an empty string.IllegalStateException- If bothretryOptions(RetryOptions)andretryPolicy(RetryPolicy)have been set.
-
buildClient
Creates synchronousSchemaRegistryClientinstance. See async builder method for options validation.- Returns:
SchemaRegistryClientwith the options set from the builder.- Throws:
NullPointerException- ifendpointandcredentialare not set.IllegalStateException- If bothretryOptions(RetryOptions)andretryPolicy(RetryPolicy)have been set.
-