Class TableClientBuilder
- java.lang.Object
-
- com.azure.data.tables.TableClientBuilder
-
public final class TableClientBuilder extends Object
This class provides a fluent builder API to help aid the configuration and instantiation ofTableClientandTableAsyncClientobjects. CallbuildClient()orbuildAsyncClient(), respectively, to construct an instance of the desired client.The minimal configuration options required by
TableClientBuilderto build aTableClientorTableAsyncClientare atableNameandendpointand a form of authentication, which can be set via:connectionString(String),credential(AzureSasCredential),credential(AzureNamedKeyCredential)orsasToken(String)Samples to construct a sync client
TableClient tableClient = new TableClientBuilder() .endpoint("https://myaccount.core.windows.net/") .credential(new AzureNamedKeyCredential("name", "key")) .tableName("myTable") .buildClient();Samples to construct an async client
TableAsyncClient tableAsyncClient = new TableClientBuilder() .endpoint("https://myaccount.core.windows.net/") .credential(new AzureNamedKeyCredential("name", "key")) .tableName("myTable") .buildAsyncClient();- See Also:
TableAsyncClient,TableClient
-
-
Constructor Summary
Constructors Constructor Description TableClientBuilder()Creates a builder instance that is able to configure and constructTableClientandTableAsyncClientobjects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableClientBuilderaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy pipelinePolicy)Adds apipeline policyto apply on each request sent.TableAsyncClientbuildAsyncClient()Creates aTableAsyncClientbased on options set in the builder.TableClientbuildClient()Creates aTableClientbased on options set in the builder.TableClientBuilderclientOptions(com.azure.core.util.ClientOptions clientOptions)Sets theClientOptionssuch as application ID and custom headers to set on a request.TableClientBuilderconfiguration(com.azure.core.util.Configuration configuration)Sets theconfigurationobject used to retrieve environment configuration values during building of the client.TableClientBuilderconnectionString(String connectionString)Sets the connection string to connect to the service.TableClientBuildercredential(com.azure.core.credential.AzureNamedKeyCredential credential)Sets theAzureNamedKeyCredentialused to authorize requests sent to the service.TableClientBuildercredential(com.azure.core.credential.AzureSasCredential credential)Sets theAzureSasCredentialused to authorize requests sent to the service.TableClientBuildercredential(com.azure.core.credential.TokenCredential credential)Sets theTokenCredentialused to authorize requests sent to the service.TableClientBuilderendpoint(String endpoint)Sets the service endpoint.TableClientBuilderhttpClient(com.azure.core.http.HttpClient httpClient)Sets theHttpClientto use for sending and receiving requests to and from the service.TableClientBuilderhttpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)Sets thelogging configurationto use when sending and receiving requests to and from the service.TableClientBuilderpipeline(com.azure.core.http.HttpPipeline pipeline)Sets theHttpPipelineto use for the service client.TableClientBuilderretryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)Sets the requestRetryPolicyfor all the requests made through the client.TableClientBuildersasToken(String sasToken)Sets the SAS token used to authorize requests sent to the service.TableClientBuilderserviceVersion(TableServiceVersion version)Sets theservice versionthat is used when making API requests.TableClientBuildertableName(String tableName)Sets the name of the table.
-
-
-
Constructor Detail
-
TableClientBuilder
public TableClientBuilder()
Creates a builder instance that is able to configure and constructTableClientandTableAsyncClientobjects.
-
-
Method Detail
-
buildClient
public TableClient buildClient()
Creates aTableClientbased on options set in the builder.- Returns:
- A
TableClientcreated from the configurations in this builder. - Throws:
NullPointerException- IfendpointortableNamearenull.IllegalArgumentException- Ifendpointis malformed or empty or iftableNameis 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 TableAsyncClient buildAsyncClient()
Creates aTableAsyncClientbased on options set in the builder.- Returns:
- A
TableAsyncClientcreated from the configurations in this builder. - Throws:
NullPointerException- IfendpointortableNamearenull.IllegalArgumentException- Ifendpointis malformed or empty or iftableNameis 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 TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- IfconnectionStringisnull.IllegalArgumentException- IfconnectionStringisn't a valid connection string.
-
endpoint
public TableClientBuilder endpoint(String endpoint)
Sets the service endpoint.- Parameters:
endpoint- The URL of the storage or CosmosDB table API account endpoint.- Returns:
- The updated
TableClientBuilder. - Throws:
NullPointerException- Ifendpointisnull.IllegalArgumentException- Ifendpointisn't a valid URL.
-
pipeline
public TableClientBuilder 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
TableClientBuilder.
-
configuration
public TableClientBuilder 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
TableClientBuilder.
-
sasToken
public TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- IfsasTokenisnull.IllegalArgumentException- IfsasTokenis empty.
-
credential
public TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
public TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
public TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
httpClient
public TableClientBuilder 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
TableClientBuilder.
-
httpLogOptions
public TableClientBuilder 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
TableClientBuilder.
-
addPolicy
public TableClientBuilder 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
TableClientBuilder. - Throws:
NullPointerException- IfpipelinePolicyisnull.
-
serviceVersion
public TableClientBuilder serviceVersion(TableServiceVersion version)
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:
version- TheTableServiceVersionof the service to be used when making requests.- Returns:
- The updated
TableClientBuilder.
-
retryPolicy
public TableClientBuilder 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
TableClientBuilder.
-
clientOptions
public TableClientBuilder 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
TableClientBuilder.
-
tableName
public TableClientBuilder tableName(String tableName)
Sets the name of the table.- Parameters:
tableName- Name of the table.- Returns:
- The updated
TableClientBuilder. - Throws:
IllegalArgumentException- IftableNameisnullor empty.
-
-