Class SchemaRegistryClientBuilder

java.lang.Object
com.azure.data.schemaregistry.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>

public class SchemaRegistryClientBuilder extends Object implements com.azure.core.client.traits.ConfigurationTrait<SchemaRegistryClientBuilder>, com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<SchemaRegistryClientBuilder>
Fluent builder for interacting with the Schema Registry service via 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 Details

    • SchemaRegistryClientBuilder

      public SchemaRegistryClientBuilder()
      Constructor for SchemaRegistryClientBuilder. Supplies client defaults.
  • Method Details

    • fullyQualifiedNamespace

      public SchemaRegistryClientBuilder fullyQualifiedNamespace(String 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 - if fullyQualifiedNamespace is null
      IllegalArgumentException - if fullyQualifiedNamespace cannot be parsed into a valid URL
    • httpClient

      public SchemaRegistryClientBuilder httpClient(com.azure.core.http.HttpClient httpClient)
      Sets the HttpClient 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 no HttpPipeline 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 an HttpPipeline 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 interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      httpClient - The HttpClient to use for requests.
      Returns:
      The updated SchemaRegistryClientBuilder object.
    • pipeline

      public SchemaRegistryClientBuilder pipeline(com.azure.core.http.HttpPipeline httpPipeline)
      Sets the HttpPipeline 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 no HttpPipeline 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 an HttpPipeline 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 build SchemaRegistryAsyncClient.

      Specified by:
      pipeline in interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      httpPipeline - HttpPipeline to use for sending service requests and receiving responses.
      Returns:
      The updated SchemaRegistryClientBuilder object.
    • configuration

      public SchemaRegistryClientBuilder 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 the global configuration store, use Configuration.NONE to bypass using configuration settings during construction.
      Specified by:
      configuration in interface com.azure.core.client.traits.ConfigurationTrait<SchemaRegistryClientBuilder>
      Parameters:
      configuration - The configuration store used to
      Returns:
      The updated SchemaRegistryClientBuilder object.
    • credential

      public SchemaRegistryClientBuilder credential(com.azure.core.credential.TokenCredential credential)
      Sets the TokenCredential 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 the TokenCredential type.
      Specified by:
      credential in interface com.azure.core.client.traits.TokenCredentialTrait<SchemaRegistryClientBuilder>
      Parameters:
      credential - TokenCredential used to authorize requests sent to the service.
      Returns:
      The updated SchemaRegistryClientBuilder object.
      Throws:
      NullPointerException - If credential is null
    • clientOptions

      public SchemaRegistryClientBuilder clientOptions(com.azure.core.util.ClientOptions 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 the HttpClientOptions class (a subclass of the ClientOptions 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 no HttpPipeline 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 an HttpPipeline 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 interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      clientOptions - A configured instance of HttpClientOptions.
      Returns:
      The updated SchemaRegistryClientBuilder object.
      See Also:
      • HttpClientOptions
    • httpLogOptions

      public SchemaRegistryClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
      Sets the logging configuration to use when sending and receiving requests to and from the service. If a logLevel is not provided, default value of HttpLogDetailLevel.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 no HttpPipeline 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 an HttpPipeline 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 interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      logOptions - The logging configuration to use when sending and receiving requests to and from the service.
      Returns:
      The updated SchemaRegistryClientBuilder object.
    • retryPolicy

      public SchemaRegistryClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
      Sets the RetryPolicy 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

      public SchemaRegistryClientBuilder retryOptions(com.azure.core.http.policy.RetryOptions retryOptions)
      Sets the RetryOptions 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 no HttpPipeline 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 an HttpPipeline 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 interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      retryOptions - The RetryOptions to use for all the requests made through the client.
      Returns:
      The updated SchemaRegistryClientBuilder object.
    • 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

      public SchemaRegistryClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
      Adds a pipeline 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 no HttpPipeline 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 an HttpPipeline 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 interface com.azure.core.client.traits.HttpTrait<SchemaRegistryClientBuilder>
      Parameters:
      policy - A pipeline policy.
      Returns:
      The updated SchemaRegistryClientBuilder object.
      Throws:
      NullPointerException - If policy is null.
    • buildAsyncClient

      public SchemaRegistryAsyncClient buildAsyncClient()
      Creates a SchemaRegistryAsyncClient based on options set in the builder. Every time buildClient() is called a new instance of SchemaRegistryAsyncClient is created. If pipeline is set, then all HTTP pipeline related settings are ignored.
      Returns:
      A SchemaRegistryAsyncClient with the options set from the builder.
      Throws:
      NullPointerException - if fullyQualifiedNamespace and credential are not set.
      IllegalArgumentException - if fullyQualifiedNamespace is an empty string.
      IllegalStateException - If both retryOptions(RetryOptions) and retryPolicy(RetryPolicy) have been set.
    • buildClient

      public SchemaRegistryClient buildClient()
      Creates synchronous SchemaRegistryClient instance. See async builder method for options validation.
      Returns:
      SchemaRegistryClient with the options set from the builder.
      Throws:
      NullPointerException - if endpoint and credential are not set.
      IllegalStateException - If both retryOptions(RetryOptions) and retryPolicy(RetryPolicy) have been set.