Class 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>
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();
-
Constructor Summary
ConstructorDescriptionConstructs a builder with the default parameters. -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy
(com.azure.core.http.policy.HttpPipelinePolicy policy) Adds apipeline policy
to apply on each request sent.Creates aServiceBusAdministrationAsyncClient
based on options set in the builder.Creates aServiceBusAdministrationClient
based on options set in the builder.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.connectionString
(String connectionString) Sets the connection string for a Service Bus namespace or a specific Service Bus resource.credential
(com.azure.core.credential.TokenCredential credential) Sets theTokenCredential
used to authorize requests sent to the service.credential
(String fullyQualifiedNamespace, com.azure.core.credential.TokenCredential credential) Sets the credential used to authenticate HTTP requests to the Service Bus namespace.Sets the service endpoint for the Service Bus namespace.httpClient
(com.azure.core.http.HttpClient client) Sets theHttpClient
to use for sending and receiving requests to and from the service.httpLogOptions
(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configuration
to use when sending and receiving requests to and from the service.pipeline
(com.azure.core.http.HttpPipeline pipeline) Sets theHttpPipeline
to use for the service client.retryOptions
(com.azure.core.http.policy.RetryOptions retryOptions) Sets theRetryOptions
for all the requests made through the client.retryPolicy
(com.azure.core.http.policy.HttpPipelinePolicy retryPolicy) Sets theHttpPipelinePolicy
that is used when each request is sent.serviceVersion
(ServiceBusServiceVersion serviceVersion) Sets theServiceBusServiceVersion
that is used.
-
Constructor Details
-
ServiceBusAdministrationClientBuilder
public ServiceBusAdministrationClientBuilder()Constructs a builder with the default parameters.
-
-
Method Details
-
buildAsyncClient
Creates aServiceBusAdministrationAsyncClient
based on options set in the builder. Every timebuildAsyncClient
is invoked, a new instance of the client is created.If
pipeline
is set, then thepipeline
andendpoint
are used to create theclient
. All other builder settings are ignored.- Returns:
- A
ServiceBusAdministrationAsyncClient
with the options set in the builder. - Throws:
NullPointerException
- ifendpoint
has not been set. This is automatically set whenconnectionString
is set. Explicitly throughendpoint(String)
, or throughcredential(String, TokenCredential)
.IllegalStateException
- If applicationId if set in bothhttpLogOptions
andclientOptions
and not same.IllegalStateException
- If bothretryOptions(RetryOptions)
andretryPolicy(HttpPipelinePolicy)
have been set.
-
buildClient
Creates aServiceBusAdministrationClient
based on options set in the builder. Every timebuildClient
is invoked, a new instance of the client is created.If
pipeline
is set, then thepipeline
andendpoint
are used to create theclient
. All other builder settings are ignored.- Returns:
- A
ServiceBusAdministrationClient
with the options set in the builder. - Throws:
NullPointerException
- ifendpoint
has not been set. This is automatically set whenconnectionString
is set. Explicitly throughendpoint(String)
, or throughcredential(String, TokenCredential)
.IllegalStateException
- If applicationId if set in bothhttpLogOptions
andclientOptions
and not same.IllegalStateException
- If bothretryOptions(RetryOptions)
andretryPolicy(HttpPipelinePolicy)
have been set.
-
addPolicy
public ServiceBusAdministrationClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy) 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 interfacecom.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
policy
- Apipeline policy
.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object. - Throws:
NullPointerException
- Ifpolicy
isnull
.
-
endpoint
Sets the service endpoint for the Service Bus namespace.- Specified by:
endpoint
in interfacecom.azure.core.client.traits.EndpointTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
endpoint
- The URL of the Service Bus namespace.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object. - Throws:
NullPointerException
- ifendpoint
is null.IllegalArgumentException
- ifendpoint
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 theglobal configuration store
, useConfiguration.NONE
to bypass using configuration settings during construction.- Specified by:
configuration
in interfacecom.azure.core.client.traits.ConfigurationTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
configuration
- The configuration store used to- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object.
-
connectionString
Sets the connection string for a Service Bus namespace or a specific Service Bus resource.- Specified by:
connectionString
in interfacecom.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
- IfconnectionString
isnull
.IllegalArgumentException
- IfconnectionString
is an entity specific connection string, and not aconnectionString
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 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 interfacecom.azure.core.client.traits.TokenCredentialTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
credential
-TokenCredential
used to authorize requests sent to the service.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object.
-
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 interfacecom.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
client
- TheHttpClient
to use for requests.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object.
-
httpLogOptions
public ServiceBusAdministrationClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) 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 interfacecom.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
logOptions
- Thelogging 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 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 interfacecom.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
clientOptions
- A configured instance ofHttpClientOptions
.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object. - See Also:
-
HttpClientOptions
-
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.The
endpoint
is not ignored whenpipeline
is set.- Specified by:
pipeline
in interfacecom.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 theHttpPipelinePolicy
that is used when each request is sent. The default retry policy will be used if not providedbuildAsyncClient()
to buildServiceBusAdministrationClient
orServiceBusAdministrationAsyncClient
. Setting this is mutually exclusive with usingretryOptions(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 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(HttpPipelinePolicy)
.- Specified by:
retryOptions
in interfacecom.azure.core.client.traits.HttpTrait<ServiceBusAdministrationClientBuilder>
- Parameters:
retryOptions
- TheRetryOptions
to use for all the requests made through the client.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object.
-
serviceVersion
public ServiceBusAdministrationClientBuilder serviceVersion(ServiceBusServiceVersion serviceVersion) Sets theServiceBusServiceVersion
that is used. By defaultServiceBusServiceVersion.getLatest()
is used when none is specified.- Parameters:
serviceVersion
- Service version to use.- Returns:
- The updated
ServiceBusAdministrationClientBuilder
object.
-