Class TableServiceClientBuilder
- java.lang.Object
-
- com.azure.data.tables.TableServiceClientBuilder
-
public final class TableServiceClientBuilder extends Object
This class provides a fluent builder API to help aid the configuration and instantiation ofTableServiceClientandTableServiceAsyncClientobjects. CallbuildClient()orbuildAsyncClient(), respectively, to construct an instance of the desired client.The minimal configuration options required by
TableServiceClientBuilderto build aTableServiceClientorTableServiceAsyncClientare anendpointand a form of authentication, which can be set via:connectionString(String),credential(AzureSasCredential),credential(AzureNamedKeyCredential)orsasToken(String)Samples to construct a sync client
TableServiceClient tableServiceClient = new TableServiceClientBuilder() .endpoint("https://myvault.azure.net/") .credential(new AzureNamedKeyCredential("name", "key")) .buildClient();Samples to construct an async client
TableServiceAsyncClient tableServiceAsyncClient = new TableServiceClientBuilder() .endpoint("https://myvault.azure.net/") .credential(new AzureNamedKeyCredential("name", "key")) .buildAsyncClient();- See Also:
TableServiceAsyncClient,TableServiceClient
-
-
Constructor Summary
Constructors Constructor Description TableServiceClientBuilder()Creates a builder instance that is able to configure and constructTableServiceClientandTableServiceAsyncClientobjects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableServiceClientBuilderaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy pipelinePolicy)Adds apipeline policyto apply on each request sent.TableServiceAsyncClientbuildAsyncClient()Creates aTableServiceAsyncClientbased on options set in the builder.TableServiceClientbuildClient()Creates aTableServiceClientbased on options set in the builder.TableServiceClientBuilderclientOptions(com.azure.core.util.ClientOptions clientOptions)Sets theClientOptionssuch as application ID and custom headers to set on a request.TableServiceClientBuilderconfiguration(com.azure.core.util.Configuration configuration)Sets theconfigurationobject used to retrieve environment configuration values during building of the client.TableServiceClientBuilderconnectionString(String connectionString)Sets the connection string to connect to the service.TableServiceClientBuildercredential(com.azure.core.credential.AzureNamedKeyCredential credential)Sets theAzureNamedKeyCredentialused to authorize requests sent to the service.TableServiceClientBuildercredential(com.azure.core.credential.AzureSasCredential credential)Sets theAzureSasCredentialused to authorize requests sent to the service.TableServiceClientBuildercredential(com.azure.core.credential.TokenCredential credential)Sets theTokenCredentialused to authorize requests sent to the service.TableServiceClientBuilderendpoint(String endpoint)Sets the service endpoint.TableServiceClientBuilderhttpClient(com.azure.core.http.HttpClient httpClient)Sets theHttpClientto use for sending and receiving requests to and from the service.TableServiceClientBuilderhttpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)Sets thelogging configurationto use when sending and receiving requests to and from the service.TableServiceClientBuilderpipeline(com.azure.core.http.HttpPipeline pipeline)Sets theHttpPipelineto use for the service client.TableServiceClientBuilderretryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)Sets the requestRetryPolicyfor all the requests made through the client.TableServiceClientBuildersasToken(String sasToken)Sets the SAS token used to authorize requests sent to the service.TableServiceClientBuilderserviceVersion(TableServiceVersion serviceVersion)Sets theservice versionthat is used when making API requests.
-
-
-
Constructor Detail
-
TableServiceClientBuilder
public TableServiceClientBuilder()
Creates a builder instance that is able to configure and constructTableServiceClientandTableServiceAsyncClientobjects.
-
-
Method Detail
-
buildClient
public TableServiceClient buildClient()
Creates aTableServiceClientbased on options set in the builder.- Returns:
- A
TableServiceClientcreated from the configurations in this builder. - Throws:
NullPointerException- Ifendpointisnull.IllegalArgumentException- Ifendpointis malformed or empty.IllegalStateException- If no form of authentication orendpointhave been specified or if multiple forms of authentication are provided, with the exception ofsasToken+connectionString. Also thrown ifendpointand/orsasTokenare set alongside aconnectionStringand the endpoint and/or SAS token in the latter are different than the former, respectively.
-
buildAsyncClient
public TableServiceAsyncClient buildAsyncClient()
Creates aTableServiceAsyncClientbased on options set in the builder.- Returns:
- A
TableServiceAsyncClientcreated from the configurations in this builder. - Throws:
NullPointerException- Ifendpointisnull.IllegalArgumentException- Ifendpointis malformed or empty.IllegalStateException- If no form of authentication orendpointhave been specified or if multiple forms of authentication are provided, with the exception ofsasToken+connectionString. Also thrown ifendpointand/orsasTokenare set alongside aconnectionStringand the endpoint and/or SAS token in the latter are different than the former, respectively.
-
connectionString
public TableServiceClientBuilder connectionString(String connectionString)
Sets the connection string to connect to the service.- Parameters:
connectionString- Connection string of the storage or CosmosDB table API account.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfconnectionStringisnull.IllegalArgumentException- IfconnectionStringisn't a valid connection string.
-
endpoint
public TableServiceClientBuilder endpoint(String endpoint)
Sets the service endpoint.- Parameters:
endpoint- The URL of the storage or CosmosDB table API account endpoint.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
IllegalArgumentException- Ifendpointisn't a valid URL.
-
pipeline
public TableServiceClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
Sets theHttpPipelineto use for the service client. Ifpipelineis set, all other settings are ignored, aside fromendpoint.- Parameters:
pipeline-HttpPipelineto use for sending service requests and receiving responses.- Returns:
- The updated
TableServiceClientBuilder.
-
configuration
public TableServiceClientBuilder configuration(com.azure.core.util.Configuration configuration)
Sets theconfigurationobject used to retrieve environment configuration values during building of the client.The
default configuration storeis a clone of theglobal configuration store, useConfiguration.NONEto bypass using configuration settings during construction.- Parameters:
configuration-Configurationstore used to retrieve environment configuration.- Returns:
- The updated
TableServiceClientBuilder.
-
sasToken
public TableServiceClientBuilder sasToken(String sasToken)
Sets the SAS token used to authorize requests sent to the service. Setting this is mutually exclusive withcredential(AzureNamedKeyCredential),credential(AzureSasCredential)orcredential(TokenCredential).- Parameters:
sasToken- The SAS token to use for authenticating requests.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfsasTokenisnull.IllegalArgumentException- IfsasTokenis empty.
-
credential
public TableServiceClientBuilder credential(com.azure.core.credential.AzureSasCredential credential)
Sets theAzureSasCredentialused to authorize requests sent to the service. Setting this is mutually exclusive withcredential(AzureNamedKeyCredential),credential(TokenCredential)orsasToken(String).- Parameters:
credential-AzureSasCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
public TableServiceClientBuilder credential(com.azure.core.credential.AzureNamedKeyCredential credential)
Sets theAzureNamedKeyCredentialused to authorize requests sent to the service. Setting this is mutually exclusive with usingcredential(AzureSasCredential),credential(TokenCredential)orsasToken(String).- Parameters:
credential-AzureNamedKeyCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
public TableServiceClientBuilder credential(com.azure.core.credential.TokenCredential credential)
Sets theTokenCredentialused to authorize requests sent to the service. Setting this is mutually exclusive with usingcredential(AzureNamedKeyCredential),credential(AzureSasCredential)orsasToken(String).- Parameters:
credential-TokenCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
httpClient
public TableServiceClientBuilder httpClient(com.azure.core.http.HttpClient httpClient)
Sets theHttpClientto use for sending and receiving requests to and from the service.- Parameters:
httpClient- TheHttpClientto use for requests.- Returns:
- The updated
TableServiceClientBuilder.
-
httpLogOptions
public TableServiceClientBuilder 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.- Parameters:
logOptions- Thelogging configurationto use when sending and receiving requests to and from the service.- Returns:
- The updated
TableServiceClientBuilder.
-
addPolicy
public TableServiceClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy pipelinePolicy)
Adds apipeline policyto apply on each request sent. The policy will be added after theretry policy. If the method is called multiple times, allpolicieswill be added and their order preserved.- Parameters:
pipelinePolicy- Apipeline policy.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfpipelinePolicyisnull.
-
serviceVersion
public TableServiceClientBuilder serviceVersion(TableServiceVersion serviceVersion)
Sets theservice versionthat is used when making API requests.If a
service versionis not provided, theservice versionthat will be used will be the latest knownservice versionbased on the version of the client library being used. If noservice versionis specified, updating to a newer version of the client library will have the result of potentially moving to a newerservice version.Targeting a specific
service versionmay also mean that the service will return an error for newer APIs.- Parameters:
serviceVersion- TheTableServiceVersionof the service to be used when making requests.- Returns:
- The updated
TableServiceClientBuilder.
-
retryPolicy
public TableServiceClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
Sets the requestRetryPolicyfor all the requests made through the client. The defaultRetryPolicywill be used in the pipeline, if not provided.- Parameters:
retryPolicy-RetryPolicy.- Returns:
- The updated
TableServiceClientBuilder.
-
clientOptions
public TableServiceClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
Sets theClientOptionssuch as application ID and custom headers to set on a request.- Parameters:
clientOptions- TheClientOptions.- Returns:
- The updated
TableServiceClientBuilder.
-
-