Class ServiceBusAdministrationClientBuilder

java.lang.Object
com.azure.messaging.servicebus.administration.ServiceBusAdministrationClientBuilder
All Implemented Interfaces:
com.azure.core.client.traits.ConfigurationTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.ConnectionStringTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.EndpointTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<ServiceBusAdministrationClientBuilder>

public final class ServiceBusAdministrationClientBuilder extends Object implements com.azure.core.client.traits.TokenCredentialTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.ConnectionStringTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.ConfigurationTrait<ServiceBusAdministrationClientBuilder>, com.azure.core.client.traits.EndpointTrait<ServiceBusAdministrationClientBuilder>
This class provides a fluent builder API to help aid the configuration and instantiation of ServiceBusAdministrationClient and ServiceBusAdministrationAsyncClient. Call buildClient() and buildAsyncClient() respectively to construct an instance of the desired client.

Create the sync client using a connection string

 // Retrieve 'connectionString' from your configuration.

 HttpLogOptions logOptions = new HttpLogOptions()
     .setLogLevel(HttpLogDetailLevel.HEADERS);

 ServiceBusAdministrationClient client = new ServiceBusAdministrationClientBuilder()
     .connectionString(connectionString)
     .httpLogOptions(logOptions)
     .buildClient();
 

Create the async client using Azure Identity

 // DefaultAzureCredential creates a credential based on the environment it is executed in.
 TokenCredential credential = new DefaultAzureCredentialBuilder().build();

 ServiceBusAdministrationAsyncClient client = new ServiceBusAdministrationClientBuilder()
     .connectionString("<< Service Bus NAMESPACE connection string>>")
     .credential("<< my-sb-namespace.servicebus.windows.net >>", credential)
     .buildAsyncClient();
 
See Also:
  • Constructor Details

    • ServiceBusAdministrationClientBuilder

      public ServiceBusAdministrationClientBuilder()
      Constructs a builder with the default parameters.
  • Method Details

    • buildAsyncClient

      public ServiceBusAdministrationAsyncClient buildAsyncClient()
      Creates a ServiceBusAdministrationAsyncClient based on options set in the builder. Every time buildAsyncClient is invoked, a new instance of the client is created.

      If pipeline is set, then the pipeline and endpoint are used to create the client. All other builder settings are ignored.

      Returns:
      A ServiceBusAdministrationAsyncClient with the options set in the builder.
      Throws:
      NullPointerException - if endpoint has not been set. This is automatically set when connectionString is set. Explicitly through endpoint(String), or through credential(String, TokenCredential).
      IllegalStateException - If applicationId if set in both httpLogOptions and clientOptions and not same.
      IllegalStateException - If both retryOptions(RetryOptions) and retryPolicy(HttpPipelinePolicy) have been set.
    • buildClient

      public ServiceBusAdministrationClient buildClient()
      Creates a ServiceBusAdministrationClient based on options set in the builder. Every time buildClient is invoked, a new instance of the client is created.

      If pipeline is set, then the pipeline and endpoint are used to create the client. All other builder settings are ignored.

      Returns:
      A ServiceBusAdministrationClient with the options set in the builder.
      Throws:
      NullPointerException - if endpoint has not been set. This is automatically set when connectionString is set. Explicitly through endpoint(String), or through credential(String, TokenCredential).
      IllegalStateException - If applicationId if set in both httpLogOptions and clientOptions and not same.
      IllegalStateException - If both retryOptions(RetryOptions) and retryPolicy(HttpPipelinePolicy) have been set.
    • addPolicy

      public ServiceBusAdministrationClientBuilder 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<ServiceBusAdministrationClientBuilder>
      Parameters:
      policy - A pipeline policy.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
      Throws:
      NullPointerException - If policy is null.
    • endpoint

      public ServiceBusAdministrationClientBuilder endpoint(String endpoint)
      Sets the service endpoint for the Service Bus namespace.
      Specified by:
      endpoint in interface com.azure.core.client.traits.EndpointTrait<ServiceBusAdministrationClientBuilder>
      Parameters:
      endpoint - The URL of the Service Bus namespace.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
      Throws:
      NullPointerException - if endpoint is null.
      IllegalArgumentException - if endpoint cannot be parsed into a valid URL.
    • configuration

      public ServiceBusAdministrationClientBuilder 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<ServiceBusAdministrationClientBuilder>
      Parameters:
      configuration - The configuration store used to
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • connectionString

      public ServiceBusAdministrationClientBuilder connectionString(String connectionString)
      Sets the connection string for a Service Bus namespace or a specific Service Bus resource.
      Specified by:
      connectionString in interface com.azure.core.client.traits.ConnectionStringTrait<ServiceBusAdministrationClientBuilder>
      Parameters:
      connectionString - Connection string for a Service Bus namespace or a specific Service Bus resource.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
      Throws:
      NullPointerException - If connectionString is null.
      IllegalArgumentException - If connectionString is an entity specific connection string, and not a connectionString for the Service Bus namespace.
    • credential

      public ServiceBusAdministrationClientBuilder credential(String fullyQualifiedNamespace, com.azure.core.credential.TokenCredential credential)
      Sets the credential used to authenticate HTTP requests to the Service Bus namespace.
      Parameters:
      fullyQualifiedNamespace - for the Service Bus.
      credential - TokenCredential to be used for authentication.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • credential

      public ServiceBusAdministrationClientBuilder 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<ServiceBusAdministrationClientBuilder>
      Parameters:
      credential - TokenCredential used to authorize requests sent to the service.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • httpClient

      public ServiceBusAdministrationClientBuilder httpClient(com.azure.core.http.HttpClient client)
      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<ServiceBusAdministrationClientBuilder>
      Parameters:
      client - The HttpClient to use for requests.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • httpLogOptions

      public ServiceBusAdministrationClientBuilder 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<ServiceBusAdministrationClientBuilder>
      Parameters:
      logOptions - The logging configuration to use when sending and receiving requests to and from the service.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • clientOptions

      public ServiceBusAdministrationClientBuilder 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<ServiceBusAdministrationClientBuilder>
      Parameters:
      clientOptions - A configured instance of HttpClientOptions.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
      See Also:
      • HttpClientOptions
    • pipeline

      public ServiceBusAdministrationClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
      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.

      The endpoint is not ignored when pipeline is set.

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

      public ServiceBusAdministrationClientBuilder retryPolicy(com.azure.core.http.policy.HttpPipelinePolicy retryPolicy)
      Sets the HttpPipelinePolicy that is used when each request is sent. The default retry policy will be used if not provided buildAsyncClient() to build ServiceBusAdministrationClient or ServiceBusAdministrationAsyncClient. Setting this is mutually exclusive with using retryOptions(RetryOptions).
      Parameters:
      retryPolicy - The user's retry policy applied to each request.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • retryOptions

      public ServiceBusAdministrationClientBuilder 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(HttpPipelinePolicy).

      Specified by:
      retryOptions in interface com.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
      Parameters:
      retryOptions - The RetryOptions to use for all the requests made through the client.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.
    • serviceVersion

      public ServiceBusAdministrationClientBuilder serviceVersion(ServiceBusServiceVersion serviceVersion)
      Sets the ServiceBusServiceVersion that is used. By default ServiceBusServiceVersion.getLatest() is used when none is specified.
      Parameters:
      serviceVersion - Service version to use.
      Returns:
      The updated ServiceBusAdministrationClientBuilder object.