From 05e268caabe8e38f034d613b08a8c27016c39dc3 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:42:04 -0800 Subject: [PATCH 01/25] Prepare November 2022 Beta Release for Search --- sdk/search/azure-search-documents/CHANGELOG.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 84fed117b457..f468cd373d9b 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -1,15 +1,15 @@ # Release History -## 11.6.0-beta.3 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed +## 11.6.0-beta.3 (2022-11-10) ### Other Changes +#### Dependency Updates + +- Upgraded `azure-core` from `1.33.0` to version `1.34.0`. +- Upgraded `azure-core-http-netty` from `1.12.6` to version `1.12.7`. +- Upgraded `azure-core-serializer-json-jackson` from `1.2.22` to version `1.2.23`. +- ## 11.6.0-beta.2 (2022-10-12) ### Bugs Fixed From 871408036f3509ad4e2908d1fcfbfbaafe1dbc4c Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 10 Nov 2022 22:28:16 -0500 Subject: [PATCH 02/25] Cherry-Pick updates to Changelog and version_client.txt from November non-main patch release for Search --- eng/versioning/version_client.txt | 2 +- sdk/search/azure-search-documents/CHANGELOG.md | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index d0288048ab84..3a386e66de00 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -140,7 +140,7 @@ com.azure:azure-monitor-query;1.0.12;1.1.0-beta.1 com.azure:azure-monitor-query-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-perf-test-parent;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-quantum-jobs;1.0.0-beta.1;1.0.0-beta.2 -com.azure:azure-search-documents;11.5.1;11.6.0-beta.4 +com.azure:azure-search-documents;11.5.2;11.6.0-beta.4 com.azure:azure-search-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-security-attestation;1.1.8;1.2.0-beta.1 com.azure:azure-security-confidentialledger;1.0.4;1.1.0-beta.1 diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 03ce589a033f..ff312820a831 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -16,6 +16,16 @@ #### Dependency Updates +- Upgraded `azure-core` from `1.33.0` to version `1.34.0`. +- Upgraded `azure-core-http-netty` from `1.12.6` to version `1.12.7`. +- Upgraded `azure-core-serializer-json-jackson` from `1.2.22` to version `1.2.23`. + +## 11.5.2 (2022-11-10) + +### Other Changes + +#### Dependency Updates + - Upgraded `azure-core` from `1.33.0` to version `1.34.0`. - Upgraded `azure-core-http-netty` from `1.12.6` to version `1.12.7`. - Upgraded `azure-core-serializer-json-jackson` from `1.2.22` to version `1.2.23`. From 548aa958817a016e0e41eb1069b2a5fc77feadeb Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:08:40 -0500 Subject: [PATCH 03/25] Autorest regeneration with Sync Stack --- .../implementation/AzureTableImplBuilder.java | 22 +- .../tables/implementation/ServicesImpl.java | 383 +++ .../tables/implementation/TablesImpl.java | 2546 +++++++++++++++-- .../implementation/models/AccessPolicy.java | 3 + .../implementation/models/CorsRule.java | 3 + .../implementation/models/GeoReplication.java | 3 + .../models/GeoReplicationStatusType.java | 2 +- .../tables/implementation/models/Logging.java | 3 + .../tables/implementation/models/Metrics.java | 3 + .../implementation/models/QueryOptions.java | 3 + .../models/RetentionPolicy.java | 3 + .../models/ServicesGetPropertiesHeaders.java | 11 +- .../models/ServicesGetStatisticsHeaders.java | 40 +- .../models/ServicesSetPropertiesHeaders.java | 11 +- .../models/SignedIdentifier.java | 3 + .../models/TableEntityQueryResponse.java | 3 + .../models/TableProperties.java | 3 + .../models/TableQueryResponse.java | 3 + .../implementation/models/TableResponse.java | 3 + .../models/TableResponseProperties.java | 3 + .../models/TableServiceErrorException.java | 1 + .../models/TableServiceStats.java | 3 + .../models/TablesCreateHeaders.java | 42 +- .../models/TablesDeleteEntityHeaders.java | 40 +- .../models/TablesDeleteHeaders.java | 40 +- .../models/TablesGetAccessPolicyHeaders.java | 40 +- .../models/TablesInsertEntityHeaders.java | 46 +- .../models/TablesMergeEntityHeaders.java | 42 +- .../models/TablesQueryEntitiesHeaders.java | 50 +- ...ryEntityWithPartitionAndRowKeyHeaders.java | 52 +- .../models/TablesQueryHeaders.java | 45 +- .../models/TablesSetAccessPolicyHeaders.java | 40 +- .../models/TablesUpdateEntityHeaders.java | 42 +- .../azure-data-tables/swagger/README.md | 2 +- 34 files changed, 3067 insertions(+), 472 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/AzureTableImplBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/AzureTableImplBuilder.java index 9cf4484c0683..ffa24c82844f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/AzureTableImplBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/AzureTableImplBuilder.java @@ -35,6 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** A builder for creating a new instance of the AzureTable type. */ @@ -45,7 +46,7 @@ public final class AzureTableImplBuilder @Generated private static final String SDK_VERSION = "version"; - @Generated private final Map properties = new HashMap<>(); + @Generated private static final Map PROPERTIES = new HashMap<>(); @Generated private final List pipelinePolicies; @@ -124,6 +125,7 @@ public AzureTableImplBuilder retryOptions(RetryOptions retryOptions) { @Generated @Override public AzureTableImplBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); pipelinePolicies.add(customPolicy); return this; } @@ -228,21 +230,17 @@ public AzureTableImpl buildClient() { private HttpPipeline createHttpPipeline() { Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - if (httpLogOptions == null) { - httpLogOptions = new HttpLogOptions(); - } - if (clientOptions == null) { - clientOptions = new ClientOptions(); - } + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; List policies = new ArrayList<>(); - String clientName = properties.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); HttpHeaders headers = new HttpHeaders(); - clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); + localClientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue())); if (headers.getSize() > 0) { policies.add(new AddHeadersPolicy(headers)); } @@ -264,7 +262,7 @@ private HttpPipeline createHttpPipeline() { new HttpPipelineBuilder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) - .clientOptions(clientOptions) + .clientOptions(localClientOptions) .build(); return httpPipeline; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/ServicesImpl.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/ServicesImpl.java index 845838f50d6f..9eccc41842a6 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/ServicesImpl.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/ServicesImpl.java @@ -19,6 +19,7 @@ import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; import com.azure.data.tables.implementation.models.ServicesGetPropertiesHeaders; import com.azure.data.tables.implementation.models.ServicesGetStatisticsHeaders; import com.azure.data.tables.implementation.models.ServicesSetPropertiesHeaders; @@ -66,6 +67,20 @@ Mono> setProperties( @HeaderParam("Accept") String accept, Context context); + @Put("/") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase setPropertiesSync( + @HostParam("url") String url, + @QueryParam("restype") String restype, + @QueryParam("comp") String comp, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @BodyParam("application/xml") TableServiceProperties tableServiceProperties, + @HeaderParam("Accept") String accept, + Context context); + @Get("/") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -79,6 +94,19 @@ Mono> getProp @HeaderParam("Accept") String accept, Context context); + @Get("/") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase getPropertiesSync( + @HostParam("url") String url, + @QueryParam("restype") String restype, + @QueryParam("comp") String comp, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("Accept") String accept, + Context context); + @Get("/") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -91,6 +119,52 @@ Mono> getStatistic @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, Context context); + + @Get("/") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase getStatisticsSync( + @HostParam("url") String url, + @QueryParam("restype") String restype, + @QueryParam("comp") String comp, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param tableServiceProperties The Table Service properties. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setPropertiesWithResponseAsync( + TableServiceProperties tableServiceProperties, Integer timeout, String requestId) { + final String restype = "service"; + final String comp = "properties"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> + service.setProperties( + this.client.getUrl(), + restype, + comp, + timeout, + this.client.getVersion(), + requestId, + tableServiceProperties, + accept, + context)); } /** @@ -125,6 +199,128 @@ public Mono> setPropertiesWithR context); } + /** + * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param tableServiceProperties The Table Service properties. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setPropertiesAsync( + TableServiceProperties tableServiceProperties, Integer timeout, String requestId) { + return setPropertiesWithResponseAsync(tableServiceProperties, timeout, requestId) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param tableServiceProperties The Table Service properties. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setPropertiesAsync( + TableServiceProperties tableServiceProperties, Integer timeout, String requestId, Context context) { + return setPropertiesWithResponseAsync(tableServiceProperties, timeout, requestId, context) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param tableServiceProperties The Table Service properties. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase setPropertiesWithResponse( + TableServiceProperties tableServiceProperties, Integer timeout, String requestId, Context context) { + final String restype = "service"; + final String comp = "properties"; + final String accept = "application/xml"; + return service.setPropertiesSync( + this.client.getUrl(), + restype, + comp, + timeout, + this.client.getVersion(), + requestId, + tableServiceProperties, + accept, + context); + } + + /** + * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS + * (Cross-Origin Resource Sharing) rules. + * + * @param tableServiceProperties The Table Service properties. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void setProperties(TableServiceProperties tableServiceProperties, Integer timeout, String requestId) { + setPropertiesWithResponse(tableServiceProperties, timeout, requestId, Context.NONE); + } + + /** + * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules along with {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesWithResponseAsync( + Integer timeout, String requestId) { + final String restype = "service"; + final String comp = "properties"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> + service.getProperties( + this.client.getUrl(), + restype, + comp, + timeout, + this.client.getVersion(), + requestId, + accept, + context)); + } + /** * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -149,6 +345,117 @@ public Mono> this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, context); } + /** + * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesAsync(Integer timeout, String requestId) { + return getPropertiesWithResponseAsync(timeout, requestId).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesAsync(Integer timeout, String requestId, Context context) { + return getPropertiesWithResponseAsync(timeout, requestId, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getPropertiesWithResponse( + Integer timeout, String requestId, Context context) { + final String restype = "service"; + final String comp = "properties"; + final String accept = "application/xml"; + return service.getPropertiesSync( + this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, context); + } + + /** + * Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin + * Resource Sharing) rules. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TableServiceProperties getProperties(Integer timeout, String requestId) { + return getPropertiesWithResponse(timeout, requestId, Context.NONE).getValue(); + } + + /** + * Retrieves statistics related to replication for the Table service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the account. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the service along with {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStatisticsWithResponseAsync( + Integer timeout, String requestId) { + final String restype = "service"; + final String comp = "stats"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> + service.getStatistics( + this.client.getUrl(), + restype, + comp, + timeout, + this.client.getVersion(), + requestId, + accept, + context)); + } + /** * Retrieves statistics related to replication for the Table service. It is only available on the secondary location * endpoint when read-access geo-redundant replication is enabled for the account. @@ -171,4 +478,80 @@ public Mono> getSt return service.getStatistics( this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, context); } + + /** + * Retrieves statistics related to replication for the Table service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the account. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStatisticsAsync(Integer timeout, String requestId) { + return getStatisticsWithResponseAsync(timeout, requestId).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves statistics related to replication for the Table service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the account. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStatisticsAsync(Integer timeout, String requestId, Context context) { + return getStatisticsWithResponseAsync(timeout, requestId, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves statistics related to replication for the Table service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the account. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the service along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getStatisticsWithResponse( + Integer timeout, String requestId, Context context) { + final String restype = "service"; + final String comp = "stats"; + final String accept = "application/xml"; + return service.getStatisticsSync( + this.client.getUrl(), restype, comp, timeout, this.client.getVersion(), requestId, accept, context); + } + + /** + * Retrieves statistics related to replication for the Table service. It is only available on the secondary location + * endpoint when read-access geo-redundant replication is enabled for the account. + * + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return stats for the service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TableServiceStats getStatistics(Integer timeout, String requestId) { + return getStatisticsWithResponse(timeout, requestId, Context.NONE).getValue(); + } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java index 53ee917f7085..5751de1bc0ee 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java @@ -24,6 +24,7 @@ import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.RestProxy; import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; import com.azure.data.tables.implementation.models.OdataMetadataFormat; import com.azure.data.tables.implementation.models.QueryOptions; import com.azure.data.tables.implementation.models.ResponseFormat; @@ -89,6 +90,22 @@ Mono> query( @HeaderParam("Accept") String accept, Context context); + @Get("/Tables") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + ResponseBase querySync( + @HostParam("url") String url, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @QueryParam("$top") Integer top, + @QueryParam("$select") String select, + @QueryParam("$filter") String filter, + @QueryParam("NextTableName") String nextTableName, + @HeaderParam("Accept") String accept, + Context context); + @Post("/Tables") @ExpectedResponses({201, 204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -103,6 +120,20 @@ Mono> create( @HeaderParam("Accept") String accept, Context context); + @Post("/Tables") + @ExpectedResponses({201, 204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase createSync( + @HostParam("url") String url, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @HeaderParam("Prefer") ResponseFormat responsePreference, + @BodyParam("application/json;odata=nometadata") TableProperties tableProperties, + @HeaderParam("Accept") String accept, + Context context); + @Delete("/Tables('{table}')") @ExpectedResponses({204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -114,6 +145,17 @@ Mono> delete( @HeaderParam("Accept") String accept, Context context); + @Delete("/Tables('{table}')") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase deleteSync( + @HostParam("url") String url, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @PathParam("table") String table, + @HeaderParam("Accept") String accept, + Context context); + @Get("/{table}()") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -133,6 +175,25 @@ Mono> queryEn @HeaderParam("Accept") String accept, Context context); + @Get("/{table}()") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase queryEntitiesSync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @QueryParam("$top") Integer top, + @QueryParam("$select") String select, + @QueryParam("$filter") String filter, + @PathParam("table") String table, + @QueryParam("NextPartitionKey") String nextPartitionKey, + @QueryParam("NextRowKey") String nextRowKey, + @HeaderParam("Accept") String accept, + Context context); + @Get("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -152,6 +213,25 @@ Mono> queryEn @HeaderParam("Accept") String accept, Context context); + @Get("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase> + queryEntityWithPartitionAndRowKeySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @QueryParam("$select") String select, + @QueryParam("$filter") String filter, + @PathParam("table") String table, + @PathParam("partitionKey") String partitionKey, + @PathParam("rowKey") String rowKey, + @HeaderParam("Accept") String accept, + Context context); + @Put("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") @ExpectedResponses({204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -170,6 +250,24 @@ Mono> updateEntity( @HeaderParam("Accept") String accept, Context context); + @Put("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase updateEntitySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @PathParam("table") String table, + @PathParam("partitionKey") String partitionKey, + @PathParam("rowKey") String rowKey, + @HeaderParam("If-Match") String ifMatch, + @BodyParam("application/json") Map tableEntityProperties, + @HeaderParam("Accept") String accept, + Context context); + @Patch("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") @ExpectedResponses({204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -188,6 +286,24 @@ Mono> mergeEntity( @HeaderParam("Accept") String accept, Context context); + @Patch("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase mergeEntitySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @PathParam("table") String table, + @PathParam("partitionKey") String partitionKey, + @PathParam("rowKey") String rowKey, + @HeaderParam("If-Match") String ifMatch, + @BodyParam("application/json") Map tableEntityProperties, + @HeaderParam("Accept") String accept, + Context context); + @Delete("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") @ExpectedResponses({204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -205,6 +321,23 @@ Mono> deleteEntity( @HeaderParam("Accept") String accept, Context context); + @Delete("/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase deleteEntitySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @PathParam("table") String table, + @PathParam("partitionKey") String partitionKey, + @PathParam("rowKey") String rowKey, + @HeaderParam("If-Match") String ifMatch, + @HeaderParam("Accept") String accept, + Context context); + @Post("/{table}") @ExpectedResponses({201, 204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -221,6 +354,22 @@ Mono>> insertEntity( @HeaderParam("Accept") String accept, Context context); + @Post("/{table}") + @ExpectedResponses({201, 204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase> insertEntitySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @QueryParam("$format") OdataMetadataFormat format, + @PathParam("table") String table, + @HeaderParam("Prefer") ResponseFormat responsePreference, + @BodyParam("application/json;odata=nometadata") Map tableEntityProperties, + @HeaderParam("Accept") String accept, + Context context); + @Get("/{table}") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -234,6 +383,19 @@ Mono>> getAcce @HeaderParam("Accept") String accept, Context context); + @Get("/{table}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase> getAccessPolicySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @PathParam("table") String table, + @QueryParam("comp") String comp, + @HeaderParam("Accept") String accept, + Context context); + @Put("/{table}") @ExpectedResponses({204}) @UnexpectedResponseExceptionType(TableServiceErrorException.class) @@ -247,6 +409,20 @@ Mono> setAccessPolicy( @BodyParam("application/xml") List tableAcl, @HeaderParam("Accept") String accept, Context context); + + @Put("/{table}") + @ExpectedResponses({204}) + @UnexpectedResponseExceptionType(TableServiceErrorException.class) + ResponseBase setAccessPolicySync( + @HostParam("url") String url, + @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @PathParam("table") String table, + @QueryParam("comp") String comp, + @BodyParam("application/xml") List tableAcl, + @HeaderParam("Accept") String accept, + Context context); } /** @@ -256,7 +432,6 @@ Mono> setAccessPolicy( * analytics logs when analytics logging is enabled. * @param nextTableName A table query continuation token from a previous call. * @param queryOptions Parameter group. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -265,7 +440,7 @@ Mono> setAccessPolicy( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> queryWithResponseAsync( - String requestId, String nextTableName, QueryOptions queryOptions, Context context) { + String requestId, String nextTableName, QueryOptions queryOptions) { final String dataServiceVersion = "3.0"; final String accept = "application/json;odata=minimalmetadata"; OdataMetadataFormat formatInternal = null; @@ -288,42 +463,39 @@ public Mono> queryWithRespo filterInternal = queryOptions.getFilter(); } String filter = filterInternal; - return service.query( - this.client.getUrl(), - this.client.getVersion(), - requestId, - dataServiceVersion, - format, - top, - select, - filter, - nextTableName, - accept, - context); + return FluxUtil.withContext( + context -> + service.query( + this.client.getUrl(), + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + top, + select, + filter, + nextTableName, + accept, + context)); } /** - * Creates a new table under the given account. + * Queries tables under the given account. * - * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param responsePreference Specifies whether the response should include the inserted entity in the payload. - * Possible values are return-no-content and return-content. + * @param nextTableName A table query continuation token from a previous call. * @param queryOptions Parameter group. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response for a single table along with {@link ResponseBase} on successful completion of {@link Mono}. + * @return the properties for the table query response along with {@link ResponseBase} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createWithResponseAsync( - TableProperties tableProperties, - String requestId, - ResponseFormat responsePreference, - QueryOptions queryOptions, - Context context) { + public Mono> queryWithResponseAsync( + String requestId, String nextTableName, QueryOptions queryOptions, Context context) { final String dataServiceVersion = "3.0"; final String accept = "application/json;odata=minimalmetadata"; OdataMetadataFormat formatInternal = null; @@ -331,68 +503,94 @@ public Mono> createWithResponse formatInternal = queryOptions.getFormat(); } OdataMetadataFormat format = formatInternal; - return service.create( + Integer topInternal = null; + if (queryOptions != null) { + topInternal = queryOptions.getTop(); + } + Integer top = topInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return service.query( this.client.getUrl(), this.client.getVersion(), requestId, dataServiceVersion, format, - responsePreference, - tableProperties, + top, + select, + filter, + nextTableName, accept, context); } /** - * Operation permanently deletes the specified table. + * Queries tables under the given account. * - * @param table The name of the table. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param context The context to associate with this operation. + * @param nextTableName A table query continuation token from a previous call. + * @param queryOptions Parameter group. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the properties for the table query response on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteWithResponseAsync( - String table, String requestId, Context context) { - final String accept = "application/json"; - return service.delete(this.client.getUrl(), this.client.getVersion(), requestId, table, accept, context); + public Mono queryAsync(String requestId, String nextTableName, QueryOptions queryOptions) { + return queryWithResponseAsync(requestId, nextTableName, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** - * Queries entities in a table. + * Queries tables under the given account. * - * @param table The name of the table. - * @param timeout The timeout parameter is expressed in seconds. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param nextPartitionKey An entity query continuation token from a previous call. - * @param nextRowKey An entity query continuation token from a previous call. + * @param nextTableName A table query continuation token from a previous call. * @param queryOptions Parameter group. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws HttpResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the properties for the table entity query response along with {@link ResponseBase} on successful - * completion of {@link Mono}. + * @return the properties for the table query response on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> queryEntitiesWithResponseAsync( - String table, - Integer timeout, - String requestId, - String nextPartitionKey, - String nextRowKey, - QueryOptions queryOptions, - Context context) { - final String dataServiceVersion = "3.0"; - final String accept = "application/json;odata=minimalmetadata"; - OdataMetadataFormat formatInternal = null; - if (queryOptions != null) { - formatInternal = queryOptions.getFormat(); + public Mono queryAsync( + String requestId, String nextTableName, QueryOptions queryOptions, Context context) { + return queryWithResponseAsync(requestId, nextTableName, queryOptions, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Queries tables under the given account. + * + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextTableName A table query continuation token from a previous call. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table query response along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase queryWithResponse( + String requestId, String nextTableName, QueryOptions queryOptions, Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); } OdataMetadataFormat format = formatInternal; Integer topInternal = null; @@ -410,9 +608,8 @@ public Mono> filterInternal = queryOptions.getFilter(); } String filter = filterInternal; - return service.queryEntities( + return service.querySync( this.client.getUrl(), - timeout, this.client.getVersion(), requestId, dataServiceVersion, @@ -420,40 +617,48 @@ public Mono> top, select, filter, - table, - nextPartitionKey, - nextRowKey, + nextTableName, accept, context); } /** - * Queries a single entity in a table. + * Queries tables under the given account. * - * @param table The name of the table. - * @param partitionKey The partition key of the entity. - * @param rowKey The row key of the entity. - * @param timeout The timeout parameter is expressed in seconds. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. + * @param nextTableName A table query continuation token from a previous call. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table query response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TableQueryResponse query(String requestId, String nextTableName, QueryOptions queryOptions) { + return queryWithResponse(requestId, nextTableName, queryOptions, Context.NONE).getValue(); + } + + /** + * Creates a new table under the given account. + * + * @param tableProperties The Table properties. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. * @param queryOptions Parameter group. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of - * {@link Mono}. + * @return the response for a single table along with {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> - queryEntityWithPartitionAndRowKeyWithResponseAsync( - String table, - String partitionKey, - String rowKey, - Integer timeout, - String requestId, - QueryOptions queryOptions, - Context context) { + public Mono> createWithResponseAsync( + TableProperties tableProperties, + String requestId, + ResponseFormat responsePreference, + QueryOptions queryOptions) { final String dataServiceVersion = "3.0"; final String accept = "application/json;odata=minimalmetadata"; OdataMetadataFormat formatInternal = null; @@ -461,217 +666,131 @@ public Mono> formatInternal = queryOptions.getFormat(); } OdataMetadataFormat format = formatInternal; - String selectInternal = null; - if (queryOptions != null) { - selectInternal = queryOptions.getSelect(); - } - String select = selectInternal; - String filterInternal = null; - if (queryOptions != null) { - filterInternal = queryOptions.getFilter(); - } - String filter = filterInternal; - return service.queryEntityWithPartitionAndRowKey( - this.client.getUrl(), - timeout, - this.client.getVersion(), - requestId, - dataServiceVersion, - format, - select, - filter, - table, - partitionKey, - rowKey, - accept, - context); + return FluxUtil.withContext( + context -> + service.create( + this.client.getUrl(), + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + responsePreference, + tableProperties, + accept, + context)); } /** - * Update entity in a table. + * Creates a new table under the given account. * - * @param table The name of the table. - * @param partitionKey The partition key of the entity. - * @param rowKey The row key of the entity. - * @param timeout The timeout parameter is expressed in seconds. + * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an - * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, - * an insert will be performed when no existing entity is found to update and a replace will be performed if an - * existing entity is found. - * @param tableEntityProperties The properties for the table entity. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. * @param queryOptions Parameter group. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the response for a single table along with {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateEntityWithResponseAsync( - String table, - String partitionKey, - String rowKey, - Integer timeout, + public Mono> createWithResponseAsync( + TableProperties tableProperties, String requestId, - String ifMatch, - Map tableEntityProperties, + ResponseFormat responsePreference, QueryOptions queryOptions, Context context) { final String dataServiceVersion = "3.0"; - final String accept = "application/json"; + final String accept = "application/json;odata=minimalmetadata"; OdataMetadataFormat formatInternal = null; if (queryOptions != null) { formatInternal = queryOptions.getFormat(); } OdataMetadataFormat format = formatInternal; - return service.updateEntity( + return service.create( this.client.getUrl(), - timeout, this.client.getVersion(), requestId, dataServiceVersion, format, - table, - partitionKey, - rowKey, - ifMatch, - tableEntityProperties, + responsePreference, + tableProperties, accept, context); } /** - * Merge entity in a table. + * Creates a new table under the given account. * - * @param table The name of the table. - * @param partitionKey The partition key of the entity. - * @param rowKey The row key of the entity. - * @param timeout The timeout parameter is expressed in seconds. + * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an - * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, - * an insert will be performed when no existing entity is found to update and a merge will be performed if an - * existing entity is found. - * @param tableEntityProperties The properties for the table entity. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. * @param queryOptions Parameter group. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the response for a single table on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> mergeEntityWithResponseAsync( - String table, - String partitionKey, - String rowKey, - Integer timeout, + public Mono createAsync( + TableProperties tableProperties, String requestId, - String ifMatch, - Map tableEntityProperties, - QueryOptions queryOptions, - Context context) { - final String dataServiceVersion = "3.0"; - final String accept = "application/json"; - OdataMetadataFormat formatInternal = null; - if (queryOptions != null) { - formatInternal = queryOptions.getFormat(); - } - OdataMetadataFormat format = formatInternal; - return service.mergeEntity( - this.client.getUrl(), - timeout, - this.client.getVersion(), - requestId, - dataServiceVersion, - format, - table, - partitionKey, - rowKey, - ifMatch, - tableEntityProperties, - accept, - context); + ResponseFormat responsePreference, + QueryOptions queryOptions) { + return createWithResponseAsync(tableProperties, requestId, responsePreference, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** - * Deletes the specified entity in a table. + * Creates a new table under the given account. * - * @param table The name of the table. - * @param partitionKey The partition key of the entity. - * @param rowKey The row key of the entity. - * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an - * error will be raised. To force an unconditional delete, set to the wildcard character (*). - * @param timeout The timeout parameter is expressed in seconds. + * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. * @param queryOptions Parameter group. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the response for a single table on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteEntityWithResponseAsync( - String table, - String partitionKey, - String rowKey, - String ifMatch, - Integer timeout, + public Mono createAsync( + TableProperties tableProperties, String requestId, + ResponseFormat responsePreference, QueryOptions queryOptions, Context context) { - final String dataServiceVersion = "3.0"; - final String accept = "application/json;odata=minimalmetadata"; - OdataMetadataFormat formatInternal = null; - if (queryOptions != null) { - formatInternal = queryOptions.getFormat(); - } - OdataMetadataFormat format = formatInternal; - return service.deleteEntity( - this.client.getUrl(), - timeout, - this.client.getVersion(), - requestId, - dataServiceVersion, - format, - table, - partitionKey, - rowKey, - ifMatch, - accept, - context); + return createWithResponseAsync(tableProperties, requestId, responsePreference, queryOptions, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** - * Insert entity in a table. + * Creates a new table under the given account. * - * @param table The name of the table. - * @param timeout The timeout parameter is expressed in seconds. + * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. * @param responsePreference Specifies whether the response should include the inserted entity in the payload. * Possible values are return-no-content and return-content. - * @param tableEntityProperties The properties for the table entity. * @param queryOptions Parameter group. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of - * {@link Mono}. + * @return the response for a single table along with {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> insertEntityWithResponseAsync( - String table, - Integer timeout, + public ResponseBase createWithResponse( + TableProperties tableProperties, String requestId, ResponseFormat responsePreference, - Map tableEntityProperties, QueryOptions queryOptions, Context context) { final String dataServiceVersion = "3.0"; @@ -681,44 +800,1911 @@ public Mono>> insert formatInternal = queryOptions.getFormat(); } OdataMetadataFormat format = formatInternal; - return service.insertEntity( + return service.createSync( this.client.getUrl(), - timeout, this.client.getVersion(), requestId, dataServiceVersion, format, - table, responsePreference, - tableEntityProperties, + tableProperties, accept, context); } /** - * Retrieves details about any stored access policies specified on the table that may be used with Shared Access - * Signatures. + * Creates a new table under the given account. * - * @param table The name of the table. - * @param timeout The timeout parameter is expressed in seconds. + * @param tableProperties The Table properties. * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the * analytics logs when analytics logging is enabled. - * @param context The context to associate with this operation. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param queryOptions Parameter group. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws TableServiceErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a collection of signed identifiers along with {@link ResponseBase} on successful completion of {@link - * Mono}. + * @return the response for a single table. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> getAccessPolicyWithResponseAsync( - String table, Integer timeout, String requestId, Context context) { - final String comp = "acl"; - final String accept = "application/xml"; - return service.getAccessPolicy( - this.client.getUrl(), timeout, this.client.getVersion(), requestId, table, comp, accept, context); - } - + public TableResponse create( + TableProperties tableProperties, + String requestId, + ResponseFormat responsePreference, + QueryOptions queryOptions) { + return createWithResponse(tableProperties, requestId, responsePreference, queryOptions, Context.NONE) + .getValue(); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync(String table, String requestId) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.delete( + this.client.getUrl(), this.client.getVersion(), requestId, table, accept, context)); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWithResponseAsync( + String table, String requestId, Context context) { + final String accept = "application/json"; + return service.delete(this.client.getUrl(), this.client.getVersion(), requestId, table, accept, context); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteAsync(String table, String requestId) { + return deleteWithResponseAsync(table, requestId).flatMap(ignored -> Mono.empty()); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteAsync(String table, String requestId, Context context) { + return deleteWithResponseAsync(table, requestId, context).flatMap(ignored -> Mono.empty()); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase deleteWithResponse(String table, String requestId, Context context) { + final String accept = "application/json"; + return service.deleteSync(this.client.getUrl(), this.client.getVersion(), requestId, table, accept, context); + } + + /** + * Operation permanently deletes the specified table. + * + * @param table The name of the table. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String table, String requestId) { + deleteWithResponse(table, requestId, Context.NONE); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response along with {@link ResponseBase} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryEntitiesWithResponseAsync( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + Integer topInternal = null; + if (queryOptions != null) { + topInternal = queryOptions.getTop(); + } + Integer top = topInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return FluxUtil.withContext( + context -> + service.queryEntities( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + top, + select, + filter, + table, + nextPartitionKey, + nextRowKey, + accept, + context)); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response along with {@link ResponseBase} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryEntitiesWithResponseAsync( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + Integer topInternal = null; + if (queryOptions != null) { + topInternal = queryOptions.getTop(); + } + Integer top = topInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return service.queryEntities( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + top, + select, + filter, + table, + nextPartitionKey, + nextRowKey, + accept, + context); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono queryEntitiesAsync( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions) { + return queryEntitiesWithResponseAsync(table, timeout, requestId, nextPartitionKey, nextRowKey, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono queryEntitiesAsync( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions, + Context context) { + return queryEntitiesWithResponseAsync( + table, timeout, requestId, nextPartitionKey, nextRowKey, queryOptions, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase queryEntitiesWithResponse( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + Integer topInternal = null; + if (queryOptions != null) { + topInternal = queryOptions.getTop(); + } + Integer top = topInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return service.queryEntitiesSync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + top, + select, + filter, + table, + nextPartitionKey, + nextRowKey, + accept, + context); + } + + /** + * Queries entities in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param nextPartitionKey An entity query continuation token from a previous call. + * @param nextRowKey An entity query continuation token from a previous call. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the properties for the table entity query response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TableEntityQueryResponse queryEntities( + String table, + Integer timeout, + String requestId, + String nextPartitionKey, + String nextRowKey, + QueryOptions queryOptions) { + return queryEntitiesWithResponse( + table, timeout, requestId, nextPartitionKey, nextRowKey, queryOptions, Context.NONE) + .getValue(); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> + queryEntityWithPartitionAndRowKeyWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return FluxUtil.withContext( + context -> + service.queryEntityWithPartitionAndRowKey( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + select, + filter, + table, + partitionKey, + rowKey, + accept, + context)); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> + queryEntityWithPartitionAndRowKeyWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return service.queryEntityWithPartitionAndRowKey( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + select, + filter, + table, + partitionKey, + rowKey, + accept, + context); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryEntityWithPartitionAndRowKeyAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + return queryEntityWithPartitionAndRowKeyWithResponseAsync( + table, partitionKey, rowKey, timeout, requestId, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> queryEntityWithPartitionAndRowKeyAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + return queryEntityWithPartitionAndRowKeyWithResponseAsync( + table, partitionKey, rowKey, timeout, requestId, queryOptions, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase> + queryEntityWithPartitionAndRowKeyWithResponse( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + String selectInternal = null; + if (queryOptions != null) { + selectInternal = queryOptions.getSelect(); + } + String select = selectInternal; + String filterInternal = null; + if (queryOptions != null) { + filterInternal = queryOptions.getFilter(); + } + String filter = filterInternal; + return service.queryEntityWithPartitionAndRowKeySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + select, + filter, + table, + partitionKey, + rowKey, + accept, + context); + } + + /** + * Queries a single entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Map queryEntityWithPartitionAndRowKey( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + return queryEntityWithPartitionAndRowKeyWithResponse( + table, partitionKey, rowKey, timeout, requestId, queryOptions, Context.NONE) + .getValue(); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return FluxUtil.withContext( + context -> + service.updateEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context)); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.updateEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateEntityAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + return updateEntityWithResponseAsync( + table, partitionKey, rowKey, timeout, requestId, ifMatch, tableEntityProperties, queryOptions) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateEntityAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + return updateEntityWithResponseAsync( + table, + partitionKey, + rowKey, + timeout, + requestId, + ifMatch, + tableEntityProperties, + queryOptions, + context) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase updateEntityWithResponse( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.updateEntitySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context); + } + + /** + * Update entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a replace will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void updateEntity( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + updateEntityWithResponse( + table, + partitionKey, + rowKey, + timeout, + requestId, + ifMatch, + tableEntityProperties, + queryOptions, + Context.NONE); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> mergeEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return FluxUtil.withContext( + context -> + service.mergeEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context)); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> mergeEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.mergeEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono mergeEntityAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + return mergeEntityWithResponseAsync( + table, partitionKey, rowKey, timeout, requestId, ifMatch, tableEntityProperties, queryOptions) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono mergeEntityAsync( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + return mergeEntityWithResponseAsync( + table, + partitionKey, + rowKey, + timeout, + requestId, + ifMatch, + tableEntityProperties, + queryOptions, + context) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase mergeEntityWithResponse( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.mergeEntitySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + tableEntityProperties, + accept, + context); + } + + /** + * Merge entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param ifMatch Match condition for an entity to be updated. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, + * an insert will be performed when no existing entity is found to update and a merge will be performed if an + * existing entity is found. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void mergeEntity( + String table, + String partitionKey, + String rowKey, + Integer timeout, + String requestId, + String ifMatch, + Map tableEntityProperties, + QueryOptions queryOptions) { + mergeEntityWithResponse( + table, + partitionKey, + rowKey, + timeout, + requestId, + ifMatch, + tableEntityProperties, + queryOptions, + Context.NONE); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return FluxUtil.withContext( + context -> + service.deleteEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + accept, + context)); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteEntityWithResponseAsync( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.deleteEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + accept, + context); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteEntityAsync( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + return deleteEntityWithResponseAsync(table, partitionKey, rowKey, ifMatch, timeout, requestId, queryOptions) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteEntityAsync( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + return deleteEntityWithResponseAsync( + table, partitionKey, rowKey, ifMatch, timeout, requestId, queryOptions, context) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase deleteEntityWithResponse( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.deleteEntitySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + partitionKey, + rowKey, + ifMatch, + accept, + context); + } + + /** + * Deletes the specified entity in a table. + * + * @param table The name of the table. + * @param partitionKey The partition key of the entity. + * @param rowKey The row key of the entity. + * @param ifMatch Match condition for an entity to be deleted. If specified and a matching entity is not found, an + * error will be raised. To force an unconditional delete, set to the wildcard character (*). + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteEntity( + String table, + String partitionKey, + String rowKey, + String ifMatch, + Integer timeout, + String requestId, + QueryOptions queryOptions) { + deleteEntityWithResponse(table, partitionKey, rowKey, ifMatch, timeout, requestId, queryOptions, Context.NONE); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> insertEntityWithResponseAsync( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return FluxUtil.withContext( + context -> + service.insertEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + responsePreference, + tableEntityProperties, + accept, + context)); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> insertEntityWithResponseAsync( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.insertEntity( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + responsePreference, + tableEntityProperties, + accept, + context); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> insertEntityAsync( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions) { + return insertEntityWithResponseAsync( + table, timeout, requestId, responsePreference, tableEntityProperties, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> insertEntityAsync( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + return insertEntityWithResponseAsync( + table, timeout, requestId, responsePreference, tableEntityProperties, queryOptions, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase> insertEntityWithResponse( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions, + Context context) { + final String dataServiceVersion = "3.0"; + final String accept = "application/json;odata=minimalmetadata"; + OdataMetadataFormat formatInternal = null; + if (queryOptions != null) { + formatInternal = queryOptions.getFormat(); + } + OdataMetadataFormat format = formatInternal; + return service.insertEntitySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + dataServiceVersion, + format, + table, + responsePreference, + tableEntityProperties, + accept, + context); + } + + /** + * Insert entity in a table. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param responsePreference Specifies whether the response should include the inserted entity in the payload. + * Possible values are return-no-content and return-content. + * @param tableEntityProperties The properties for the table entity. + * @param queryOptions Parameter group. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the other properties of the table entity. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Map insertEntity( + String table, + Integer timeout, + String requestId, + ResponseFormat responsePreference, + Map tableEntityProperties, + QueryOptions queryOptions) { + return insertEntityWithResponse( + table, + timeout, + requestId, + responsePreference, + tableEntityProperties, + queryOptions, + Context.NONE) + .getValue(); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers along with {@link ResponseBase} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> getAccessPolicyWithResponseAsync( + String table, Integer timeout, String requestId) { + final String comp = "acl"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> + service.getAccessPolicy( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + table, + comp, + accept, + context)); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers along with {@link ResponseBase} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> getAccessPolicyWithResponseAsync( + String table, Integer timeout, String requestId, Context context) { + final String comp = "acl"; + final String accept = "application/xml"; + return service.getAccessPolicy( + this.client.getUrl(), timeout, this.client.getVersion(), requestId, table, comp, accept, context); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPolicyAsync(String table, Integer timeout, String requestId) { + return getAccessPolicyWithResponseAsync(table, timeout, requestId) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPolicyAsync( + String table, Integer timeout, String requestId, Context context) { + return getAccessPolicyWithResponseAsync(table, timeout, requestId, context) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase> getAccessPolicyWithResponse( + String table, Integer timeout, String requestId, Context context) { + final String comp = "acl"; + final String accept = "application/xml"; + return service.getAccessPolicySync( + this.client.getUrl(), timeout, this.client.getVersion(), requestId, table, comp, accept, context); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a collection of signed identifiers. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public List getAccessPolicy(String table, Integer timeout, String requestId) { + return getAccessPolicyWithResponse(table, timeout, requestId, Context.NONE).getValue(); + } + + /** + * Sets stored access policies for the table that may be used with Shared Access Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param tableAcl The acls for the table. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> setAccessPolicyWithResponseAsync( + String table, Integer timeout, String requestId, List tableAcl) { + final String comp = "acl"; + final String accept = "application/xml"; + return FluxUtil.withContext( + context -> + service.setAccessPolicy( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + table, + comp, + tableAcl, + accept, + context)); + } + /** * Sets stored access policies for the table that may be used with Shared Access Signatures. * @@ -749,4 +2735,92 @@ public Mono> setAccessPolicyWit accept, context); } + + /** + * Sets stored access policies for the table that may be used with Shared Access Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param tableAcl The acls for the table. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setAccessPolicyAsync( + String table, Integer timeout, String requestId, List tableAcl) { + return setAccessPolicyWithResponseAsync(table, timeout, requestId, tableAcl).flatMap(ignored -> Mono.empty()); + } + + /** + * Sets stored access policies for the table that may be used with Shared Access Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param tableAcl The acls for the table. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono setAccessPolicyAsync( + String table, Integer timeout, String requestId, List tableAcl, Context context) { + return setAccessPolicyWithResponseAsync(table, timeout, requestId, tableAcl, context) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Sets stored access policies for the table that may be used with Shared Access Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param tableAcl The acls for the table. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase setAccessPolicyWithResponse( + String table, Integer timeout, String requestId, List tableAcl, Context context) { + final String comp = "acl"; + final String accept = "application/xml"; + return service.setAccessPolicySync( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + table, + comp, + tableAcl, + accept, + context); + } + + /** + * Sets stored access policies for the table that may be used with Shared Access Signatures. + * + * @param table The name of the table. + * @param timeout The timeout parameter is expressed in seconds. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when analytics logging is enabled. + * @param tableAcl The acls for the table. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws TableServiceErrorException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void setAccessPolicy(String table, Integer timeout, String requestId, List tableAcl) { + setAccessPolicyWithResponse(table, timeout, requestId, tableAcl, Context.NONE); + } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java index 0a4fd3a399ad..cdbd4bd26059 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java @@ -29,6 +29,9 @@ public final class AccessPolicy { @JsonProperty(value = "Permission", required = true) private String permission; + /** Creates an instance of AccessPolicy class. */ + public AccessPolicy() {} + /** * Get the start property: The start datetime from which the policy is active. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java index eb4c2384f774..cde2032a1087 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java @@ -49,6 +49,9 @@ public final class CorsRule { @JsonProperty(value = "MaxAgeInSeconds", required = true) private int maxAgeInSeconds; + /** Creates an instance of CorsRule class. */ + public CorsRule() {} + /** * Get the allowedOrigins property: The origin domains that are permitted to make a request against the service via * CORS. The origin domain is the domain from which the request originates. Note that the origin must be an exact diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java index c58a56d7a924..67b098938001 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java @@ -25,6 +25,9 @@ public final class GeoReplication { @JsonProperty(value = "LastSyncTime", required = true) private DateTimeRfc1123 lastSyncTime; + /** Creates an instance of GeoReplication class. */ + public GeoReplication() {} + /** * Get the status property: The status of the secondary location. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplicationStatusType.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplicationStatusType.java index e51e45295912..618a81726d5a 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplicationStatusType.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplicationStatusType.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Collection; -/** Defines values for GeoReplicationStatusType. */ +/** The status of the secondary location. */ public final class GeoReplicationStatusType extends ExpandableStringEnum { /** Static value live for GeoReplicationStatusType. */ public static final GeoReplicationStatusType LIVE = fromString("live"); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java index ea7956faebea..0d273b1bd158 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java @@ -40,6 +40,9 @@ public final class Logging { @JsonProperty(value = "RetentionPolicy", required = true) private RetentionPolicy retentionPolicy; + /** Creates an instance of Logging class. */ + public Logging() {} + /** * Get the version property: The version of Analytics to configure. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java index d07a3abdca0c..39ec6f40be62 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java @@ -34,6 +34,9 @@ public final class Metrics { @JsonProperty(value = "RetentionPolicy") private RetentionPolicy retentionPolicy; + /** Creates an instance of Metrics class. */ + public Metrics() {} + /** * Get the version property: The version of Analytics to configure. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java index 1a5a7440e0b1..65abc533556f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java @@ -35,6 +35,9 @@ public final class QueryOptions { @JsonProperty(value = "Filter") private String filter; + /** Creates an instance of QueryOptions class. */ + public QueryOptions() {} + /** * Get the format property: Specifies the media type for the response. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java index fe91a0fcbdd1..82d1b6a8cddc 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java @@ -23,6 +23,9 @@ public final class RetentionPolicy { @JsonProperty(value = "Days") private Integer days; + /** Creates an instance of RetentionPolicy class. */ + public RetentionPolicy() {} + /** * Get the enabled property: Indicates whether a retention policy is enabled for the service. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java index be7bc6ba1d5c..3217ebce53c1 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; @@ -29,6 +30,10 @@ public final class ServicesGetPropertiesHeaders { @JsonProperty(value = "x-ms-client-request-id") private String xMsClientRequestId; + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); + // HttpHeaders containing the raw property values. /** * Creates an instance of ServicesGetPropertiesHeaders class. @@ -36,9 +41,9 @@ public final class ServicesGetPropertiesHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public ServicesGetPropertiesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java index 5f1747dce280..ab1f8504d5dc 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,11 @@ public final class ServicesGetStatisticsHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -44,11 +49,12 @@ public final class ServicesGetStatisticsHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public ServicesGetStatisticsHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -113,28 +119,28 @@ public ServicesGetStatisticsHeaders setXMsClientRequestId(String xMsClientReques } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the ServicesGetStatisticsHeaders object itself. */ - public ServicesGetStatisticsHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public ServicesGetStatisticsHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java index 4435b5bab06c..558a544d9a3e 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; @@ -29,6 +30,10 @@ public final class ServicesSetPropertiesHeaders { @JsonProperty(value = "x-ms-client-request-id") private String xMsClientRequestId; + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); + // HttpHeaders containing the raw property values. /** * Creates an instance of ServicesSetPropertiesHeaders class. @@ -36,9 +41,9 @@ public final class ServicesSetPropertiesHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public ServicesSetPropertiesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java index 2aee67d93333..fed95acc0bd5 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java @@ -22,6 +22,9 @@ public final class SignedIdentifier { @JsonProperty(value = "AccessPolicy", required = true) private AccessPolicy accessPolicy; + /** Creates an instance of SignedIdentifier class. */ + public SignedIdentifier() {} + /** * Get the id property: A unique id. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java index 24bb41fbf5bc..5529b586590c 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java @@ -24,6 +24,9 @@ public final class TableEntityQueryResponse { @JsonProperty(value = "value") private List> value; + /** Creates an instance of TableEntityQueryResponse class. */ + public TableEntityQueryResponse() {} + /** * Get the odataMetadata property: The metadata response of the table. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java index f5dca3abbbeb..c1fb6536f01d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java @@ -16,6 +16,9 @@ public final class TableProperties { @JsonProperty(value = "TableName") private String tableName; + /** Creates an instance of TableProperties class. */ + public TableProperties() {} + /** * Get the tableName property: The name of the table to create. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java index aa213f33dd7f..ae03599e294a 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java @@ -23,6 +23,9 @@ public final class TableQueryResponse { @JsonProperty(value = "value") private List value; + /** Creates an instance of TableQueryResponse class. */ + public TableQueryResponse() {} + /** * Get the odataMetadata property: The metadata response of the table. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java index 5f340e25dae3..1ff687311b17 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java @@ -16,6 +16,9 @@ public final class TableResponse extends TableResponseProperties { @JsonProperty(value = "odata.metadata") private String odataMetadata; + /** Creates an instance of TableResponse class. */ + public TableResponse() {} + /** * Get the odataMetadata property: The metadata response of the table. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java index 304f48daed7c..6732c6a8b537 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java @@ -34,6 +34,9 @@ public class TableResponseProperties { @JsonProperty(value = "odata.editLink") private String odataEditLink; + /** Creates an instance of TableResponseProperties class. */ + public TableResponseProperties() {} + /** * Get the tableName property: The name of the table. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceErrorException.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceErrorException.java index 604e6231e6ab..67ea489eaa3b 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceErrorException.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceErrorException.java @@ -30,6 +30,7 @@ public TableServiceErrorException(String message, HttpResponse response, TableSe super(message, response, value); } + /** {@inheritDoc} */ @Override public TableServiceError getValue() { return (TableServiceError) super.getValue(); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java index e58465ee2bc1..b1d09d95c925 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java @@ -16,6 +16,9 @@ public final class TableServiceStats { @JsonProperty(value = "GeoReplication") private GeoReplication geoReplication; + /** Creates an instance of TableServiceStats class. */ + public TableServiceStats() {} + /** * Get the geoReplication property: Geo-Replication information for the Secondary Storage Service. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java index 41919bb20d83..44de537e7975 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,7 @@ public final class TablesCreateHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; /* * The Preference-Applied property. @@ -43,6 +44,10 @@ public final class TablesCreateHeaders { @JsonProperty(value = "Preference-Applied") private String preferenceApplied; + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); + // HttpHeaders containing the raw property values. /** * Creates an instance of TablesCreateHeaders class. @@ -50,13 +55,14 @@ public final class TablesCreateHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesCreateHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } - this.preferenceApplied = rawHeaders.getValue("Preference-Applied"); + this.preferenceApplied = rawHeaders.getValue(HttpHeaderName.PREFERENCE_APPLIED); } /** @@ -120,28 +126,28 @@ public TablesCreateHeaders setXMsClientRequestId(String xMsClientRequestId) { } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesCreateHeaders object itself. */ - public TablesCreateHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesCreateHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java index 440f911947e3..d228fe713add 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,11 @@ public final class TablesDeleteEntityHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -44,11 +49,12 @@ public final class TablesDeleteEntityHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesDeleteEntityHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -113,28 +119,28 @@ public TablesDeleteEntityHeaders setXMsClientRequestId(String xMsClientRequestId } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesDeleteEntityHeaders object itself. */ - public TablesDeleteEntityHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesDeleteEntityHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java index 1ca55725f1e4..ceff61a3e9d9 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,11 @@ public final class TablesDeleteHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -44,11 +49,12 @@ public final class TablesDeleteHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesDeleteHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -113,28 +119,28 @@ public TablesDeleteHeaders setXMsClientRequestId(String xMsClientRequestId) { } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesDeleteHeaders object itself. */ - public TablesDeleteHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesDeleteHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java index 22784571de91..ab0b4fea9103 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,11 @@ public final class TablesGetAccessPolicyHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -44,11 +49,12 @@ public final class TablesGetAccessPolicyHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesGetAccessPolicyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -113,28 +119,28 @@ public TablesGetAccessPolicyHeaders setXMsClientRequestId(String xMsClientReques } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesGetAccessPolicyHeaders object itself. */ - public TablesGetAccessPolicyHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesGetAccessPolicyHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java index 6b30e16d5808..05eba9f426c8 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -41,7 +42,7 @@ public final class TablesInsertEntityHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; /* * The Preference-Applied property. @@ -55,6 +56,10 @@ public final class TablesInsertEntityHeaders { @JsonProperty(value = "Content-Type") private String contentType; + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); + // HttpHeaders containing the raw property values. /** * Creates an instance of TablesInsertEntityHeaders class. @@ -62,15 +67,16 @@ public final class TablesInsertEntityHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesInsertEntityHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.eTag = rawHeaders.getValue("ETag"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } - this.preferenceApplied = rawHeaders.getValue("Preference-Applied"); - this.contentType = rawHeaders.getValue("Content-Type"); + this.preferenceApplied = rawHeaders.getValue(HttpHeaderName.PREFERENCE_APPLIED); + this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); } /** @@ -154,28 +160,28 @@ public TablesInsertEntityHeaders setXMsClientRequestId(String xMsClientRequestId } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesInsertEntityHeaders object itself. */ - public TablesInsertEntityHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesInsertEntityHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java index cfa258be469d..97a75f11a1de 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -41,7 +42,11 @@ public final class TablesMergeEntityHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -50,12 +55,13 @@ public final class TablesMergeEntityHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesMergeEntityHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.eTag = rawHeaders.getValue("ETag"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -140,28 +146,28 @@ public TablesMergeEntityHeaders setXMsClientRequestId(String xMsClientRequestId) } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesMergeEntityHeaders object itself. */ - public TablesMergeEntityHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesMergeEntityHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java index 1481e4747a81..a5d213c56202 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -47,7 +48,17 @@ public final class TablesQueryEntitiesHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_CONTINUATION_NEXT_PARTITION_KEY = + HttpHeaderName.fromString("x-ms-continuation-NextPartitionKey"); + + private static final HttpHeaderName X_MS_CONTINUATION_NEXT_ROW_KEY = + HttpHeaderName.fromString("x-ms-continuation-NextRowKey"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -56,13 +67,14 @@ public final class TablesQueryEntitiesHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesQueryEntitiesHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsContinuationNextPartitionKey = rawHeaders.getValue("x-ms-continuation-NextPartitionKey"); - this.xMsContinuationNextRowKey = rawHeaders.getValue("x-ms-continuation-NextRowKey"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsContinuationNextPartitionKey = rawHeaders.getValue(X_MS_CONTINUATION_NEXT_PARTITION_KEY); + this.xMsContinuationNextRowKey = rawHeaders.getValue(X_MS_CONTINUATION_NEXT_ROW_KEY); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -167,28 +179,28 @@ public TablesQueryEntitiesHeaders setXMsClientRequestId(String xMsClientRequestI } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesQueryEntitiesHeaders object itself. */ - public TablesQueryEntitiesHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesQueryEntitiesHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java index fe9fb7f21b56..642d72b86531 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -53,7 +54,17 @@ public final class TablesQueryEntityWithPartitionAndRowKeyHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_CONTINUATION_NEXT_PARTITION_KEY = + HttpHeaderName.fromString("x-ms-continuation-NextPartitionKey"); + + private static final HttpHeaderName X_MS_CONTINUATION_NEXT_ROW_KEY = + HttpHeaderName.fromString("x-ms-continuation-NextRowKey"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -62,14 +73,15 @@ public final class TablesQueryEntityWithPartitionAndRowKeyHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesQueryEntityWithPartitionAndRowKeyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsContinuationNextPartitionKey = rawHeaders.getValue("x-ms-continuation-NextPartitionKey"); - this.eTag = rawHeaders.getValue("ETag"); - this.xMsContinuationNextRowKey = rawHeaders.getValue("x-ms-continuation-NextRowKey"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsContinuationNextPartitionKey = rawHeaders.getValue(X_MS_CONTINUATION_NEXT_PARTITION_KEY); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + this.xMsContinuationNextRowKey = rawHeaders.getValue(X_MS_CONTINUATION_NEXT_ROW_KEY); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -196,28 +208,28 @@ public TablesQueryEntityWithPartitionAndRowKeyHeaders setXMsClientRequestId(Stri } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesQueryEntityWithPartitionAndRowKeyHeaders object itself. */ - public TablesQueryEntityWithPartitionAndRowKeyHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesQueryEntityWithPartitionAndRowKeyHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java index 251023e32352..051a022126b8 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,7 @@ public final class TablesQueryHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; /* * The x-ms-continuation-NextTableName property. @@ -43,6 +44,13 @@ public final class TablesQueryHeaders { @JsonProperty(value = "x-ms-continuation-NextTableName") private String xMsContinuationNextTableName; + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); + + private static final HttpHeaderName X_MS_CONTINUATION_NEXT_TABLE_NAME = + HttpHeaderName.fromString("x-ms-continuation-NextTableName"); + // HttpHeaders containing the raw property values. /** * Creates an instance of TablesQueryHeaders class. @@ -50,13 +58,14 @@ public final class TablesQueryHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesQueryHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } - this.xMsContinuationNextTableName = rawHeaders.getValue("x-ms-continuation-NextTableName"); + this.xMsContinuationNextTableName = rawHeaders.getValue(X_MS_CONTINUATION_NEXT_TABLE_NAME); } /** @@ -120,28 +129,28 @@ public TablesQueryHeaders setXMsClientRequestId(String xMsClientRequestId) { } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesQueryHeaders object itself. */ - public TablesQueryHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesQueryHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java index 5e2b0b02207d..2069fb2e00c7 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -35,7 +36,11 @@ public final class TablesSetAccessPolicyHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -44,11 +49,12 @@ public final class TablesSetAccessPolicyHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesSetAccessPolicyHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -113,28 +119,28 @@ public TablesSetAccessPolicyHeaders setXMsClientRequestId(String xMsClientReques } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesSetAccessPolicyHeaders object itself. */ - public TablesSetAccessPolicyHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesSetAccessPolicyHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java index fa4c4434219d..bb99eacfc158 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java @@ -5,6 +5,7 @@ package com.azure.data.tables.implementation.models; import com.azure.core.annotation.Fluent; +import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; @@ -41,7 +42,11 @@ public final class TablesUpdateEntityHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_REQUEST_ID = HttpHeaderName.fromString("x-ms-request-id"); // HttpHeaders containing the raw property values. /** @@ -50,12 +55,13 @@ public final class TablesUpdateEntityHeaders { * @param rawHeaders The raw HttpHeaders that will be used to create the property values. */ public TablesUpdateEntityHeaders(HttpHeaders rawHeaders) { - this.xMsVersion = rawHeaders.getValue("x-ms-version"); - this.eTag = rawHeaders.getValue("ETag"); - this.xMsRequestId = rawHeaders.getValue("x-ms-request-id"); - this.xMsClientRequestId = rawHeaders.getValue("x-ms-client-request-id"); - if (rawHeaders.getValue("Date") != null) { - this.dateProperty = new DateTimeRfc1123(rawHeaders.getValue("Date")); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + this.xMsRequestId = rawHeaders.getValue(X_MS_REQUEST_ID); + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); } } @@ -140,28 +146,28 @@ public TablesUpdateEntityHeaders setXMsClientRequestId(String xMsClientRequestId } /** - * Get the dateProperty property: The Date property. + * Get the date property: The Date property. * - * @return the dateProperty value. + * @return the date value. */ - public OffsetDateTime getDateProperty() { - if (this.dateProperty == null) { + public OffsetDateTime getDate() { + if (this.date == null) { return null; } - return this.dateProperty.getDateTime(); + return this.date.getDateTime(); } /** - * Set the dateProperty property: The Date property. + * Set the date property: The Date property. * - * @param dateProperty the dateProperty value to set. + * @param date the date value to set. * @return the TablesUpdateEntityHeaders object itself. */ - public TablesUpdateEntityHeaders setDateProperty(OffsetDateTime dateProperty) { - if (dateProperty == null) { - this.dateProperty = null; + public TablesUpdateEntityHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; } else { - this.dateProperty = new DateTimeRfc1123(dateProperty); + this.date = new DateTimeRfc1123(date); } return this; } diff --git a/sdk/tables/azure-data-tables/swagger/README.md b/sdk/tables/azure-data-tables/swagger/README.md index 940c2556ad3f..9f22afac5468 100644 --- a/sdk/tables/azure-data-tables/swagger/README.md +++ b/sdk/tables/azure-data-tables/swagger/README.md @@ -27,7 +27,7 @@ output-folder: ..\ generate-client-as-impl: true namespace: com.azure.data.tables generate-client-interfaces: false -sync-methods: none +enable-sync-stack: true license-header: MICROSOFT_MIT_SMALL add-context-parameter: true models-subpackage: implementation.models From e6251250f511cb29ad838b869195b39a87cb1fd4 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:49:00 -0500 Subject: [PATCH 04/25] Stashing my sync stack work --- .../azure/data/tables/TableAsyncClient.java | 24 +- .../com/azure/data/tables/TableClient.java | 846 +++++++++++++++++- .../azure/data/tables/TableClientBuilder.java | 59 +- .../azure/data/tables/TableServiceClient.java | 474 +++++++++- .../tables/TableServiceClientBuilder.java | 59 +- .../TransactionalBatchImpl.java | 33 + .../models/TransactionalBatchAction.java | 24 + 7 files changed, 1431 insertions(+), 88 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index 5aa205936aaf..e6d0c13f482e 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -238,6 +238,10 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { return new TableSasGenerator(tableSasSignatureValues, getTableName(), azureNamedKeyCredential).getSas(); } + private Context setContext(Context context) { + return context == null ? Context.NONE : context; + } + /** * Creates the table within the Tables service. * @@ -287,7 +291,7 @@ public Mono> createTableWithResponse() { } Mono> createTableWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); final TableProperties properties = new TableProperties().setTableName(tableName); try { @@ -349,7 +353,7 @@ public Mono> deleteTableWithResponse() { } Mono> deleteTableWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); try { return tablesImplementation.getTables().deleteWithResponseAsync(tableName, null, context) @@ -432,7 +436,7 @@ public Mono> createEntityWithResponse(TableEntity entity) { } Mono> createEntityWithResponse(TableEntity entity, Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -532,7 +536,7 @@ public Mono> upsertEntityWithResponse(TableEntity entity, TableEn Mono> upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -699,7 +703,7 @@ public Mono> updateEntityWithResponse(TableEntity entity, TableEn Mono> updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -839,7 +843,7 @@ public Mono> deleteEntityWithResponse(TableEntity entity, boolean Mono> deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); eTag = ifUnchanged ? eTag : "*"; if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { @@ -967,7 +971,7 @@ private Mono> listEntitiesNextPage(Stri private Mono> listEntities(String nextPartitionKey, String nextRowKey, Context context, ListEntitiesOptions options, Class resultType) { - context = context == null ? Context.NONE : context; + context = setContext(context); String select = null; if (options.getSelect() != null) { @@ -1248,7 +1252,7 @@ public Mono> getAccessPoliciesWithResponse() { } Mono> getAccessPoliciesWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); try { return tablesImplementation.getTables() @@ -1368,7 +1372,7 @@ public Mono> setAccessPoliciesWithResponse(List> setAccessPoliciesWithResponse(List tableSignedIdentifiers, Context context) { - context = context == null ? Context.NONE : context; + context = setContext(context); List signedIdentifiers = null; /* @@ -1617,7 +1621,7 @@ public Mono> submitTransactionWithResponse(List } Mono> submitTransactionWithResponse(List transactionActions, Context context) { - Context finalContext = context == null ? Context.NONE : context; + Context finalContext = setContext(context); if (transactionActions.isEmpty()) { return monoError(logger, diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index ab8d6a53d4f5..e40f5682e20e 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -6,12 +6,47 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; +import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.ResponseBase; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; +import com.azure.core.util.IterableStream; +import com.azure.core.util.ServiceVersion; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.data.tables.implementation.AzureTableImpl; +import com.azure.data.tables.implementation.AzureTableImplBuilder; +import com.azure.data.tables.implementation.ModelHelper; +import com.azure.data.tables.implementation.TableSasGenerator; +import com.azure.data.tables.implementation.TableSasUtils; +import com.azure.data.tables.implementation.TableUtils; +import com.azure.data.tables.implementation.TransactionalBatchImpl; +import com.azure.data.tables.implementation.models.AccessPolicy; +import com.azure.data.tables.implementation.models.OdataMetadataFormat; +import com.azure.data.tables.implementation.models.QueryOptions; +import com.azure.data.tables.implementation.models.ResponseFormat; +import com.azure.data.tables.implementation.models.SignedIdentifier; +import com.azure.data.tables.implementation.models.TableEntityQueryResponse; +import com.azure.data.tables.implementation.models.TableProperties; +import com.azure.data.tables.implementation.models.TableResponseProperties; +import com.azure.data.tables.implementation.models.TableServiceError; +import com.azure.data.tables.implementation.models.TablesGetAccessPolicyHeaders; +import com.azure.data.tables.implementation.models.TablesQueryEntitiesHeaders; +import com.azure.data.tables.implementation.models.TablesQueryEntityWithPartitionAndRowKeyHeaders; +import com.azure.data.tables.implementation.models.TablesSetAccessPolicyHeaders; +import com.azure.data.tables.implementation.models.TransactionalBatchAction; +import com.azure.data.tables.implementation.models.TransactionalBatchChangeSet; +import com.azure.data.tables.implementation.models.TransactionalBatchRequestBody; +import com.azure.data.tables.implementation.models.TransactionalBatchSubRequest; +import com.azure.data.tables.implementation.models.TransactionalBatchSubmitBatchHeaders; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableAccessPolicies; +import com.azure.data.tables.models.TableAccessPolicy; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableEntityUpdateMode; import com.azure.data.tables.models.TableItem; @@ -23,10 +58,24 @@ import com.azure.data.tables.models.TableTransactionResult; import com.azure.data.tables.sas.TableSasSignatureValues; +import java.net.URI; import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; -import static com.azure.data.tables.implementation.TableUtils.blockWithOptionalTimeout; + +import static com.azure.core.util.CoreUtils.isNullOrEmpty; +import static com.azure.data.tables.implementation.TableUtils.toTableServiceError; /** * Provides a synchronous service client for accessing a table in the Azure Tables service. @@ -54,10 +103,64 @@ */ @ServiceClient(builder = TableClientBuilder.class) public final class TableClient { - final TableAsyncClient client; - TableClient(TableAsyncClient client) { - this.client = client; + private static final String DELIMITER_CONTINUATION_TOKEN = ";"; + private final ClientLogger logger = new ClientLogger(TableClient.class); + private final String tableName; + private final AzureTableImpl tablesImplementation; + private final TransactionalBatchImpl transactionalBatchImplementation; + private final String accountName; + private final String tableEndpoint; + private final HttpPipeline pipeline; + private final TableClient transactionalBatchClient; + + private static final int IMMEDIATELY = -1; + + TableClient(String tableName, HttpPipeline pipeline, String serviceUrl, TableServiceVersion serviceVersion, + SerializerAdapter tablesSerializer, SerializerAdapter transactionalBatchSerializer) { + try { + if (tableName == null) { + throw new NullPointerException(("'tableName' must not be null to create TableClient.")); + } + + if (tableName.isEmpty()) { + throw new IllegalArgumentException("'tableName' must not be empty to create a TableClient."); + } + + final URI uri = URI.create(serviceUrl); + this.accountName = uri.getHost().split("\\.", 2)[0]; + this.tableEndpoint = uri.resolve("/" + tableName).toString(); + logger.verbose("Table Service URI: {}", uri); + } catch (NullPointerException | IllegalArgumentException ex) { + throw logger.logExceptionAsError(ex); + } + + this.tablesImplementation = new AzureTableImplBuilder() + .url(serviceUrl) + .serializerAdapter(tablesSerializer) + .pipeline(pipeline) + .version(serviceVersion.getVersion()) + .buildClient(); + this.transactionalBatchImplementation = + new TransactionalBatchImpl(tablesImplementation, transactionalBatchSerializer); + this.tableName = tableName; + this.pipeline = tablesImplementation.getHttpPipeline(); + this.transactionalBatchClient = new TableClient(this, serviceVersion, tablesSerializer); + } + + TableClient(TableClient client, ServiceVersion serviceVersion, SerializerAdapter tablesSerializer) { + this.accountName = client.getAccountName(); + this.tableEndpoint = client.getTableEndpoint(); + this.pipeline = BuilderHelper.buildNullClientPipeline(); + this.tablesImplementation = new AzureTableImplBuilder() + .url(client.getTablesImplementation().getUrl()) + .serializerAdapter(tablesSerializer) + .pipeline(this.pipeline) + .version(serviceVersion.getVersion()) + .buildClient(); + this.tableName = client.getTableName(); + this.transactionalBatchImplementation = null; + this.transactionalBatchClient = null; } /** @@ -66,7 +169,7 @@ public final class TableClient { * @return The name of the table. */ public String getTableName() { - return this.client.getTableName(); + return tableName; } /** @@ -75,7 +178,7 @@ public String getTableName() { * @return The name of the account containing the table. */ public String getAccountName() { - return this.client.getAccountName(); + return accountName; } /** @@ -84,7 +187,20 @@ public String getAccountName() { * @return The endpoint for this table. */ public String getTableEndpoint() { - return this.client.getTableEndpoint(); + return tableEndpoint; + } + + HttpPipeline getHttpPipeline() { + return this.pipeline; + } + + /** + * Gets the {@link AzureTableImpl} powering this client. + * + * @return This client's {@link AzureTableImpl}. + */ + AzureTableImpl getTablesImplementation() { + return tablesImplementation; } /** @@ -93,7 +209,7 @@ public String getTableEndpoint() { * @return The REST API version used by this client. */ public TableServiceVersion getServiceVersion() { - return this.client.getServiceVersion(); + return TableServiceVersion.fromString(tablesImplementation.getVersion()); } /** @@ -110,7 +226,23 @@ public TableServiceVersion getServiceVersion() { * {@link AzureNamedKeyCredential}. */ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { - return client.generateSas(tableSasSignatureValues); + AzureNamedKeyCredential azureNamedKeyCredential = TableSasUtils.extractNamedKeyCredential(getHttpPipeline()); + + if (azureNamedKeyCredential == null) { + throw logger.logExceptionAsError(new IllegalStateException("Cannot generate a SAS token with a client that" + + " is not authenticated with an AzureNamedKeyCredential.")); + } + + return new TableSasGenerator(tableSasSignatureValues, getTableName(), azureNamedKeyCredential).getSas(); + } + + + private Context setContext(Context context) { + return context == null ? Context.NONE : context; + } + + private Long setTimeout(Duration timeout) { + return timeout != null ? timeout.toMillis() : -1; } /** @@ -132,7 +264,7 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { */ @ServiceMethod(returns = ReturnType.SINGLE) public TableItem createTable() { - return client.createTable().block(); + return createTableWithResponse(null, null).getValue(); } /** @@ -160,7 +292,31 @@ public TableItem createTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.createTableWithResponse(context), timeout); + // TODO: Spawn thread to utilize timeout param + Context contextValue = setContext(context); + final TableProperties properties = new TableProperties().setTableName(tableName); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Callable> createTableOp = () -> { + try { + return new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, + null, + ResponseFormat.RETURN_NO_CONTENT, null, contextValue), + ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); + } catch (RuntimeException ex) { + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); + } + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(createTableOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(ex)); //TODO: Test this error being thrown + } } /** @@ -180,7 +336,7 @@ public Response createTableWithResponse(Duration timeout, Context con */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable() { - client.deleteTable().block(); + deleteTableWithResponse(null, null); } /** @@ -207,7 +363,37 @@ public void deleteTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.deleteTableWithResponse(context), timeout); + // TODO: Spawn thread to utilize timeout param + Context contextValue = setContext(context); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + Callable> deleteTableOp = () -> { + return new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( + tableName, null, contextValue), + null); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(deleteTableOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + if (ex instanceof TableServiceException + && + ((TableServiceException) ex).getResponse().getStatusCode() == 404) { + return new SimpleResponse<>( + ((TableServiceException) ex).getResponse().getRequest(), + ((TableServiceException) ex).getResponse().getStatusCode(), + ((TableServiceException) ex).getResponse().getHeaders(), + null); + } else { + throw logger.logExceptionAsError( + new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + } } /** @@ -238,7 +424,7 @@ public Response deleteTableWithResponse(Duration timeout, Context context) */ @ServiceMethod(returns = ReturnType.SINGLE) public void createEntity(TableEntity entity) { - client.createEntity(entity).block(); + createEntityWithResponse(entity, null, null); } /** @@ -276,7 +462,32 @@ public void createEntity(TableEntity entity) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.createEntityWithResponse(entity, context), timeout); + // TODO: spawn thread to utilize timeout param + Context contextValue = setContext(context); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + EntityHelper.setPropertiesFromGetters(entity, logger); + Callable> createEntityOp = () -> { + Response> response = tablesImplementation.getTables().insertEntityWithResponse( + tableName, null, null, ResponseFormat.RETURN_NO_CONTENT, + entity.getProperties(), null, contextValue); + return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(createEntityOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -308,7 +519,7 @@ public Response createEntityWithResponse(TableEntity entity, Duration time */ @ServiceMethod(returns = ReturnType.SINGLE) public void upsertEntity(TableEntity entity) { - client.upsertEntity(entity).block(); + upsertEntityWithResponse(entity, null, null, null); } /** @@ -356,7 +567,40 @@ public void upsertEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.upsertEntityWithResponse(entity, updateMode, context), timeout); + // TODO: spawn thread to utilize timeout param + Context contextValue = setContext(context); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = escapeSingleQuotes(entity.getRowKey()); + + EntityHelper.setPropertiesFromGetters(entity, logger); + + Callable> upsertEntityOp = () -> { + if (updateMode == TableEntityUpdateMode.REPLACE) { + return tablesImplementation.getTables().updateEntityWithResponse( + tableName, partitionKey, rowKey, null, null, null, + entity.getProperties(), null, contextValue); + } else { + return tablesImplementation.getTables().mergeEntityWithResponse( + tableName, partitionKey, rowKey, null, null, null, + entity.getProperties(), null, contextValue); + } + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(upsertEntityOp, IMMEDIATELY, TimeUnit.SECONDS); + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -389,7 +633,7 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp */ @ServiceMethod(returns = ReturnType.SINGLE) public void updateEntity(TableEntity entity) { - client.updateEntity(entity).block(); + updateEntity(entity, null); } /** @@ -429,7 +673,7 @@ public void updateEntity(TableEntity entity) { */ @ServiceMethod(returns = ReturnType.SINGLE) public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { - client.updateEntity(entity, updateMode).block(); + updateEntityWithResponse(entity, updateMode, false, null, null); } /** @@ -482,8 +726,42 @@ public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { @ServiceMethod(returns = ReturnType.SINGLE) public Response updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Duration timeout, Context context) { - return blockWithOptionalTimeout( - client.updateEntityWithResponse(entity, updateMode, ifUnchanged, context), timeout); + // TODO: spawn thread to utilize timeout param + Context contextValue = setContext(context); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = escapeSingleQuotes(entity.getRowKey()); + String eTag = ifUnchanged ? entity.getETag() : "*"; + + EntityHelper.setPropertiesFromGetters(entity, logger); + + Callable> updateEntityOp = () -> { + if (updateMode == TableEntityUpdateMode.REPLACE) { + return tablesImplementation.getTables() + .updateEntityWithResponse(tableName, partitionKey, rowKey, null, null, eTag, + entity.getProperties(), null, contextValue); + } else { + return tablesImplementation.getTables() + .mergeEntityWithResponse(tableName, partitionKey, rowKey, null, null, eTag, + entity.getProperties(), null, contextValue); + } + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(updateEntityOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -512,7 +790,7 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteEntity(String partitionKey, String rowKey) { - client.deleteEntity(partitionKey, rowKey).block(); + deleteEntityWithResponse(partitionKey, rowKey, null, false, null, null); } /** @@ -541,7 +819,7 @@ public void deleteEntity(String partitionKey, String rowKey) { */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteEntity(TableEntity entity) { - client.deleteEntity(entity).block(); + deleteEntityWithResponse(entity, false, null, null); } /** @@ -581,8 +859,37 @@ public void deleteEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnchanged, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.deleteEntityWithResponse(entity.getPartitionKey(), - entity.getRowKey(), entity.getETag(), ifUnchanged, context), timeout); + // TODO: spawn thread to utilize timeout param + return deleteEntityWithResponse( + entity.getPartitionKey(), entity.getRowKey(), entity.getETag(), ifUnchanged, timeout, context); + } + + private Response deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, + Duration timeout, Context context) { + Context contextValue = setContext(context); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + String finalETag = ifUnchanged ? eTag : "*"; + + if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { + throw logger.logExceptionAsError(new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null")); + } + + Callable> deleteEntityOp = () -> { + return tablesImplementation.getTables().deleteEntityWithResponse( + tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalETag, null, + null, null, contextValue); + }; + + ScheduledFuture> scheduledFuture = scheduler.schedule(deleteEntityOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -607,7 +914,7 @@ public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnc */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities() { - return new PagedIterable<>(client.listEntities()); + return listEntities(new ListEntitiesOptions(), null, null); } /** @@ -659,7 +966,141 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(client.listEntities(options, context, timeout)); + // TODO: spawn thread to utilize timeout param + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + + Callable> listEntitiesOp = () -> { + return new PagedIterable<>( + () -> listEntitiesFirstPage(context, options, TableEntity.class), + token -> listEntitiesNextPage(token, context, options, TableEntity.class)); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(listEntitiesOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + } + + private PagedResponse listEntitiesFirstPage(Context context, + ListEntitiesOptions options, + Class resultType) { + return listEntities(null, null, context, options, resultType); + } + + private PagedResponse listEntitiesNextPage(String token, Context context, + ListEntitiesOptions options, + Class resultType) { + if (token == null) { + return null; + } + + String[] split = token.split(DELIMITER_CONTINUATION_TOKEN, 2); + + if (split.length != 2) { + throw logger.logExceptionAsError(new RuntimeException( + "Split done incorrectly, must have partition and row key: " + token)); + } + + String nextPartitionKey = split[0]; + String nextRowKey = split[1]; + + return listEntities(nextPartitionKey, nextRowKey, context, options, resultType); + + } + + private PagedResponse listEntities(String nextPartitionKey, String nextRowKey, + Context context, ListEntitiesOptions options, + Class resultType) { + Context contextValue = setContext(context); + String select = null; + + if (options.getSelect() != null) { + select = String.join(",", options.getSelect()); + } + + QueryOptions queryOptions = new QueryOptions() + .setFilter(options.getFilter()) + .setTop(options.getTop()) + .setSelect(select) + .setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA); + + final ResponseBase response = + tablesImplementation.getTables().queryEntitiesWithResponse(tableName, null, null, + nextPartitionKey, nextRowKey, queryOptions, context); + + final TableEntityQueryResponse tablesQueryEntityResponse = response.getValue(); + + if (tablesQueryEntityResponse == null) { + return null; + } + + final List> entityResponseValue = tablesQueryEntityResponse.getValue(); + + if (entityResponseValue == null) { + return null; + } + + final List entities = entityResponseValue.stream() + .map(ModelHelper::createEntity) + .map(e -> EntityHelper.convertToSubclass(e, resultType, logger)) + .collect(Collectors.toList()); + + return new EntityPaged<>(response, entities, + response.getDeserializedHeaders().getXMsContinuationNextPartitionKey(), + response.getDeserializedHeaders().getXMsContinuationNextRowKey()); + } + + private static class EntityPaged implements PagedResponse { + private final Response httpResponse; + private final IterableStream entityStream; + private final String continuationToken; + + EntityPaged(Response httpResponse, List entityList, + String nextPartitionKey, String nextRowKey) { + if (nextPartitionKey == null || nextRowKey == null) { + this.continuationToken = null; + } else { + this.continuationToken = String.join(DELIMITER_CONTINUATION_TOKEN, nextPartitionKey, nextRowKey); + } + + this.httpResponse = httpResponse; + this.entityStream = IterableStream.of(entityList); + } + + @Override + public int getStatusCode() { + return httpResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return httpResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return httpResponse.getRequest(); + } + + @Override + public IterableStream getElements() { + return entityStream; + } + + @Override + public String getContinuationToken() { + return continuationToken; + } + + @Override + public void close() { + } } /** @@ -692,7 +1133,7 @@ public PagedIterable listEntities(ListEntitiesOptions options, Dura */ @ServiceMethod(returns = ReturnType.SINGLE) public TableEntity getEntity(String partitionKey, String rowKey) { - return client.getEntity(partitionKey, rowKey).block(); + return getEntityWithResponse(partitionKey, rowKey, null, null, null).getValue(); } /** @@ -742,8 +1183,51 @@ public TableEntity getEntity(String partitionKey, String rowKey) { @ServiceMethod(returns = ReturnType.SINGLE) public Response getEntityWithResponse(String partitionKey, String rowKey, List select, Duration timeout, Context context) { - return blockWithOptionalTimeout( - client.getEntityWithResponse(partitionKey, rowKey, select, TableEntity.class, context), timeout); + // TODO: spawn thread to utilize timeout param + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Context contextValue = setContext(context); + + QueryOptions queryOptions = new QueryOptions() + .setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA); + + if (select != null) { + queryOptions.setSelect(String.join(",", select)); + } + + if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { + throw logger.logExceptionAsError( + new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null.")); + } + + Callable> getEntityOp = () -> { + ResponseBase> response = + tablesImplementation.getTables().queryEntityWithPartitionAndRowKeyWithResponse( + tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, null, + queryOptions, contextValue); + + final Map matchingEntity = response.getValue(); + + if (matchingEntity == null || matchingEntity.isEmpty()) { + logger.info("There was no matching entity. Table {}, partition key: {}, row key: {}.", + tableName, partitionKey, rowKey); + return null; + } + + final TableEntity entity = ModelHelper.createEntity(matchingEntity); + return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), + EntityHelper.convertToSubclass(entity, TableEntity.class, logger)); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(getEntityOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -770,7 +1254,8 @@ public Response getEntityWithResponse(String partitionKey, String r */ @ServiceMethod(returns = ReturnType.SINGLE) public TableAccessPolicies getAccessPolicies() { - return client.getAccessPolicies().block(); + + return getAccessPoliciesWithResponse(null, null).getValue(); } /** @@ -810,9 +1295,52 @@ public TableAccessPolicies getAccessPolicies() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getAccessPoliciesWithResponse(context), timeout); + // TODO: spawn thread to utilize timeout param + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Context contextValue = setContext(context); + + Callable> getAccessPoliciesOp = () -> { + ResponseBase> response = + tablesImplementation.getTables().getAccessPolicyWithResponse( + tableName, null, null, contextValue + ); + return new SimpleResponse<>(response, + new TableAccessPolicies(response.getValue() == null ? null : response.getValue().stream() + .map(this::toTableSignedIdentifier) + .collect(Collectors.toList()))); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(getAccessPoliciesOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } + private TableSignedIdentifier toTableSignedIdentifier(SignedIdentifier signedIdentifier) { + if (signedIdentifier == null) { + return null; + } + + return new TableSignedIdentifier(signedIdentifier.getId()) + .setAccessPolicy(toTableAccessPolicy(signedIdentifier.getAccessPolicy())); + } + + private TableAccessPolicy toTableAccessPolicy(AccessPolicy accessPolicy) { + if (accessPolicy == null) { + return null; + } + + return new TableAccessPolicy() + .setExpiresOn(accessPolicy.getExpiry()) + .setStartsOn(accessPolicy.getStart()) + .setPermissions(accessPolicy.getPermission()); + } /** * Sets stored {@link TableAccessPolicies access policies} for the table that may be used with Shared Access * Signatures. @@ -848,7 +1376,7 @@ public Response getAccessPoliciesWithResponse(Duration time */ @ServiceMethod(returns = ReturnType.SINGLE) public void setAccessPolicies(List tableSignedIdentifiers) { - client.setAccessPolicies(tableSignedIdentifiers).block(); + setAccessPoliciesWithResponse(tableSignedIdentifiers, null, null); } /** @@ -894,7 +1422,78 @@ public void setAccessPolicies(List tableSignedIdentifiers @ServiceMethod(returns = ReturnType.SINGLE) public Response setAccessPoliciesWithResponse(List tableSignedIdentifiers, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.setAccessPoliciesWithResponse(tableSignedIdentifiers, context), timeout); + // TODO: spawn thread to utilize timeout param + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Context contextValue = setContext(context); + List signedIdentifiers = null; + + if (tableSignedIdentifiers != null) { + signedIdentifiers = tableSignedIdentifiers.stream() + .map(tableSignedIdentifier -> { + SignedIdentifier signedIdentifier = toSignedIdentifier(tableSignedIdentifier); + + if (signedIdentifier != null) { + if (signedIdentifier.getAccessPolicy() != null + && signedIdentifier.getAccessPolicy().getStart() != null) { + + signedIdentifier.getAccessPolicy() + .setStart(signedIdentifier.getAccessPolicy() + .getStart().truncatedTo(ChronoUnit.SECONDS)); + } + + if (signedIdentifier.getAccessPolicy() != null + && signedIdentifier.getAccessPolicy().getExpiry() != null) { + + signedIdentifier.getAccessPolicy() + .setExpiry(signedIdentifier.getAccessPolicy() + .getExpiry().truncatedTo(ChronoUnit.SECONDS)); + } + } + + return signedIdentifier; + }) + .collect(Collectors.toList()); + } + + List finalSignedIdentifiers = signedIdentifiers; + Callable> setAccessPoliciesOp = () -> { + ResponseBase response = tablesImplementation.getTables() + .setAccessPolicyWithResponse(tableName, null, null, + finalSignedIdentifiers, contextValue); + return new SimpleResponse<>(response, response.getValue()); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(setAccessPoliciesOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + } + + private SignedIdentifier toSignedIdentifier(TableSignedIdentifier tableSignedIdentifier) { + if (tableSignedIdentifier == null) { + return null; + } + + return new SignedIdentifier() + .setId(tableSignedIdentifier.getId()) + .setAccessPolicy(toAccessPolicy(tableSignedIdentifier.getAccessPolicy())); + } + + private AccessPolicy toAccessPolicy(TableAccessPolicy tableAccessPolicy) { + if (tableAccessPolicy == null) { + return null; + } + + return new AccessPolicy() + .setExpiry(tableAccessPolicy.getExpiresOn()) + .setStart(tableAccessPolicy.getStartsOn()) + .setPermission(tableAccessPolicy.getPermissions()); } /** @@ -982,7 +1581,7 @@ public Response setAccessPoliciesWithResponse(List */ @ServiceMethod(returns = ReturnType.SINGLE) public TableTransactionResult submitTransaction(List transactionActions) { - return client.submitTransaction(transactionActions).block(); + return submitTransactionWithResponse(transactionActions, null, null).getValue(); } /** @@ -1079,6 +1678,181 @@ public TableTransactionResult submitTransaction(List tra */ @ServiceMethod(returns = ReturnType.SINGLE) public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.submitTransactionWithResponse(transactionActions, context), timeout); + // TODO: spawn thread to utilize timeout param + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Context contextValue = setContext(context); + + if (transactionActions.isEmpty()) { + throw logger.logExceptionAsError( + new IllegalArgumentException("A transaction must contain at least one operation.")); + } + + final List operations = new ArrayList<>(); + + for (TableTransactionAction transactionAction : transactionActions) { + switch (transactionAction.getActionType()) { + case CREATE: + operations.add(new TransactionalBatchAction.CreateEntity(transactionAction.getEntity())); + + break; + case UPSERT_MERGE: + operations.add(new TransactionalBatchAction.UpsertEntity(transactionAction.getEntity(), + TableEntityUpdateMode.MERGE)); + + break; + case UPSERT_REPLACE: + operations.add(new TransactionalBatchAction.UpsertEntity(transactionAction.getEntity(), + TableEntityUpdateMode.REPLACE)); + + break; + case UPDATE_MERGE: + operations.add(new TransactionalBatchAction.UpdateEntity(transactionAction.getEntity(), + TableEntityUpdateMode.MERGE, transactionAction.getIfUnchanged())); + + break; + case UPDATE_REPLACE: + operations.add(new TransactionalBatchAction.UpdateEntity(transactionAction.getEntity(), + TableEntityUpdateMode.REPLACE, transactionAction.getIfUnchanged())); + + break; + case DELETE: + operations.add( + new TransactionalBatchAction.DeleteEntity(transactionAction.getEntity(), + transactionAction.getIfUnchanged())); + + break; + default: + break; + } + } + + Callable> submitTransactionOp = () -> { + BiConsumer accumulator = (body, pair) -> { + body.addChangeOperation(new TransactionalBatchSubRequest(pair.getAction(), pair.getRequest())); + }; + BiConsumer combiner = (body1, body2) -> { + body2.getContents().forEach( req -> body1.addChangeOperation((TransactionalBatchSubRequest) req)); + }; + TransactionalBatchRequestBody requestBody = + operations.stream() + .map(op -> new RequestActionPair(op.prepareRequest(transactionalBatchClient), op)) + .collect(TransactionalBatchRequestBody::new, accumulator, combiner); + + ResponseBase response = + transactionalBatchImplementation + .submitTransactionalBatchWithRestResponse(requestBody, null, contextValue); + + Response> parsedResponse = parseResponse(requestBody, response); + return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), + new TableTransactionResult(transactionActions, parsedResponse.getValue())); + }; + + ScheduledFuture> scheduledFuture = + scheduler.schedule(submitTransactionOp, IMMEDIATELY, TimeUnit.SECONDS); + + scheduler.shutdown(); + try { + return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + } + + private static class RequestActionPair { + private final HttpRequest request; + private final TransactionalBatchAction action; + + public RequestActionPair(HttpRequest request, TransactionalBatchAction action) { + this.request = request; + this.action = action; + } + + public HttpRequest getRequest() { + return request; + } + + public TransactionalBatchAction getAction() { + return action; + } + } + + private Response> parseResponse(TransactionalBatchRequestBody requestBody, + ResponseBase response) { + TableServiceError error = null; + String errorMessage = null; + TransactionalBatchChangeSet changes = null; + TransactionalBatchAction failedAction = null; + Integer failedIndex = null; + + if (requestBody.getContents().get(0) instanceof TransactionalBatchChangeSet) { + changes = (TransactionalBatchChangeSet) requestBody.getContents().get(0); + } + + for (int i = 0; i < response.getValue().length; i++) { + TableTransactionActionResponse subResponse = response.getValue()[i]; + + // Attempt to attach a sub-request to each batch sub-response + if (changes != null && changes.getContents().get(i) != null) { + ModelHelper.updateTableTransactionActionResponse(subResponse, + changes.getContents().get(i).getHttpRequest()); + } + + // If one sub-response was an error, we need to throw even though the service responded with 202 + if (subResponse.getStatusCode() >= 400 && error == null && errorMessage == null) { + if (subResponse.getValue() instanceof TableServiceError) { + error = (TableServiceError) subResponse.getValue(); + + // Make a best effort to locate the failed operation and include it in the message + if (changes != null && error.getOdataError() != null + && error.getOdataError().getMessage() != null + && error.getOdataError().getMessage().getValue() != null) { + + String message = error.getOdataError().getMessage().getValue(); + + try { + failedIndex = Integer.parseInt(message.substring(0, message.indexOf(":"))); + failedAction = changes.getContents().get(failedIndex).getOperation(); + } catch (NumberFormatException e) { + // Unable to parse failed operation from batch error message - this just means + // the service did not indicate which request was the one that failed. Since + // this is optional, just swallow the exception. + } + } + } else if (subResponse.getValue() instanceof String) { + errorMessage = "The service returned the following data for the failed operation: " + + subResponse.getValue(); + } else { + errorMessage = + "The service returned the following status code for the failed operation: " + + subResponse.getStatusCode(); + } + } + } + + if (error != null || errorMessage != null) { + String message = "An action within the operation failed, the transaction has been rolled back."; + + if (failedAction != null) { + message += " The failed operation was: " + failedAction; + } else if (errorMessage != null) { + message += " " + errorMessage; + } + + throw logger.logExceptionAsError(new RuntimeException( + new TableTransactionFailedException(message, null, toTableServiceError(error), failedIndex))); + } else { + return new SimpleResponse<>(response, Arrays.asList(response.getValue())); + } + } + + // Single quotes in OData queries should be escaped by using two consecutive single quotes characters. + // Source: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLSyntax. + private String escapeSingleQuotes(String input) { + if (input == null) { + return null; + } + + return input.replace("'", "''"); } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java index 4985eb355866..ac6b7744df92 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java @@ -127,7 +127,64 @@ public TableClientBuilder() { * respectively. */ public TableClient buildClient() { - return new TableClient(buildAsyncClient()); + TableServiceVersion serviceVersion = version != null ? version : TableServiceVersion.getLatest(); + + validateCredentials(azureNamedKeyCredential, azureSasCredential, tokenCredential, sasToken, connectionString, + logger); + + AzureNamedKeyCredential namedKeyCredential = null; + + // If 'connectionString' was provided, extract the endpoint and sasToken. + if (connectionString != null) { + StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, logger); + StorageEndpoint storageConnectionStringTableEndpoint = storageConnectionString.getTableEndpoint(); + + if (storageConnectionStringTableEndpoint == null + || storageConnectionStringTableEndpoint.getPrimaryUri() == null) { + + throw logger.logExceptionAsError(new IllegalArgumentException( + "'connectionString' is missing the required settings to derive a Tables endpoint.")); + } + + String connectionStringEndpoint = storageConnectionStringTableEndpoint.getPrimaryUri(); + + // If no 'endpoint' was provided, use the one in the 'connectionString'. Else, verify they are the same. + if (endpoint == null) { + endpoint = connectionStringEndpoint; + } else { + if (endpoint.endsWith("/")) { + endpoint = endpoint.substring(0, endpoint.length() - 1); + } + + if (connectionStringEndpoint.endsWith("/")) { + connectionStringEndpoint = + connectionStringEndpoint.substring(0, connectionStringEndpoint.length() - 1); + } + + if (!endpoint.equals(connectionStringEndpoint)) { + throw logger.logExceptionAsError(new IllegalStateException( + "'endpoint' points to a different tables endpoint than 'connectionString'.")); + } + } + + StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); + + if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { + namedKeyCredential = (azureNamedKeyCredential != null) ? azureNamedKeyCredential + : new AzureNamedKeyCredential(authSettings.getAccount().getName(), + authSettings.getAccount().getAccessKey()); + } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { + sasToken = (sasToken != null) ? sasToken : authSettings.getSasToken(); + } + } + + HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( + namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, + tokenCredential, sasToken, endpoint, retryPolicy, retryOptions, httpLogOptions, clientOptions, httpClient, + perCallPolicies, perRetryPolicies, configuration, logger, enableTenantDiscovery); + + return new TableClient(tableName, pipeline, endpoint, serviceVersion, TABLES_SERIALIZER, + TRANSACTIONAL_BATCH_SERIALIZER); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 7527334a2f4a..553717d15801 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -6,27 +6,61 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; +import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; +import com.azure.core.util.IterableStream; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.data.tables.implementation.AzureTableImpl; +import com.azure.data.tables.implementation.AzureTableImplBuilder; +import com.azure.data.tables.implementation.ModelHelper; +import com.azure.data.tables.implementation.TableAccountSasGenerator; +import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; +import com.azure.data.tables.implementation.models.CorsRule; +import com.azure.data.tables.implementation.models.GeoReplication; +import com.azure.data.tables.implementation.models.Logging; +import com.azure.data.tables.implementation.models.Metrics; +import com.azure.data.tables.implementation.models.OdataMetadataFormat; +import com.azure.data.tables.implementation.models.QueryOptions; import com.azure.data.tables.implementation.models.ResponseFormat; +import com.azure.data.tables.implementation.models.RetentionPolicy; import com.azure.data.tables.implementation.models.TableProperties; +import com.azure.data.tables.implementation.models.TableQueryResponse; +import com.azure.data.tables.implementation.models.TableResponseProperties; +import com.azure.data.tables.implementation.models.TableServiceStats; +import com.azure.data.tables.implementation.models.TablesQueryHeaders; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableItem; +import com.azure.data.tables.models.TableServiceCorsRule; import com.azure.data.tables.models.TableServiceException; +import com.azure.data.tables.models.TableServiceGeoReplication; +import com.azure.data.tables.models.TableServiceGeoReplicationStatus; +import com.azure.data.tables.models.TableServiceLogging; +import com.azure.data.tables.models.TableServiceMetrics; import com.azure.data.tables.models.TableServiceProperties; +import com.azure.data.tables.models.TableServiceRetentionPolicy; import com.azure.data.tables.models.TableServiceStatistics; import com.azure.data.tables.sas.TableAccountSasSignatureValues; -import reactor.core.publisher.Mono; +import java.net.URI; import java.time.Duration; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.data.tables.implementation.TableUtils.blockWithOptionalTimeout; /** * Provides a synchronous service client for accessing the Azure Tables service. @@ -52,10 +86,31 @@ */ @ServiceClient(builder = TableServiceClientBuilder.class) public final class TableServiceClient { - private final TableServiceAsyncClient client; - TableServiceClient(TableServiceAsyncClient client) { - this.client = client; + private final ClientLogger logger = new ClientLogger(TableServiceClient.class); + private final AzureTableImpl implementation; + private final String accountName; + private final HttpPipeline pipeline; + + TableServiceClient(HttpPipeline pipeline, String url, TableServiceVersion serviceVersion, + SerializerAdapter serializerAdapter) { + + try { + final URI uri = URI.create(url); + this.accountName = uri.getHost().split("\\.", 2)[0]; + + logger.verbose("Table Service URI: {}", uri); + } catch (NullPointerException | IllegalArgumentException ex) { + throw logger.logExceptionAsError(ex); + } + + this.implementation = new AzureTableImplBuilder() + .serializerAdapter(serializerAdapter) + .url(url) + .pipeline(pipeline) + .version(serviceVersion.getVersion()) + .buildClient(); + this.pipeline = implementation.getHttpPipeline(); } /** @@ -64,7 +119,7 @@ public final class TableServiceClient { * @return The name of the account containing the table. */ public String getAccountName() { - return client.getAccountName(); + return accountName; } /** @@ -73,7 +128,7 @@ public String getAccountName() { * @return The endpoint for the Tables service. */ public String getServiceEndpoint() { - return client.getServiceEndpoint(); + return implementation.getUrl(); } /** @@ -82,7 +137,7 @@ public String getServiceEndpoint() { * @return The REST API version used by this client. */ public TableServiceVersion getServiceVersion() { - return client.getServiceVersion(); + return TableServiceVersion.fromString(implementation.getVersion()); } /** @@ -91,7 +146,7 @@ public TableServiceVersion getServiceVersion() { * @return This client's {@link HttpPipeline}. */ HttpPipeline getHttpPipeline() { - return client.getHttpPipeline(); + return this.pipeline; } /** @@ -109,7 +164,14 @@ HttpPipeline getHttpPipeline() { * {@link AzureNamedKeyCredential}. */ public String generateAccountSas(TableAccountSasSignatureValues tableAccountSasSignatureValues) { - return client.generateAccountSas(tableAccountSasSignatureValues); + AzureNamedKeyCredential azureNamedKeyCredential = TableSasUtils.extractNamedKeyCredential(getHttpPipeline()); + + if (azureNamedKeyCredential == null) { + throw logger.logExceptionAsError(new IllegalStateException("Cannot generate a SAS token with a client that" + + " is not authenticated with an AzureNamedKeyCredential.")); + } + + return new TableAccountSasGenerator(tableAccountSasSignatureValues, azureNamedKeyCredential).getSas(); } /** @@ -124,7 +186,13 @@ public String generateAccountSas(TableAccountSasSignatureValues tableAccountSasS * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. */ public TableClient getTableClient(String tableName) { - return new TableClient(client.getTableClient(tableName)); + return new TableClientBuilder() + .pipeline(this.implementation.getHttpPipeline()) + .serviceVersion(this.getServiceVersion()) + .endpoint(this.getServiceEndpoint()) + .tableName(tableName) + .buildClient(); + } /** @@ -179,21 +247,25 @@ public TableClient createTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(String tableName, Duration timeout, Context context) { - return blockWithOptionalTimeout(createTableWithResponse(tableName, context), timeout); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Callable> callable = () -> createTableWithResponse(tableName, context); + Future> future = scheduler.submit(callable); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } } - Mono> createTableWithResponse(String tableName, Context context) { + Response createTableWithResponse(String tableName, Context context) { context = context == null ? Context.NONE : context; final TableProperties properties = new TableProperties().setTableName(tableName); - try { - return client.getImplementation().getTables().createWithResponseAsync(properties, null, - ResponseFormat.RETURN_NO_CONTENT, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceException) - .map(response -> new SimpleResponse<>(response, getTableClient(tableName))); - } catch (RuntimeException ex) { - return monoError(client.getLogger(), ex); - } + return new SimpleResponse<>(implementation.getTables() + .createWithResponse(properties, null, ResponseFormat.RETURN_NO_CONTENT, null, context), + getTableClient(tableName)); } /** @@ -249,18 +321,32 @@ public TableClient createTableIfNotExists(String tableName) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableIfNotExistsWithResponse(String tableName, Duration timeout, Context context) { - return blockWithOptionalTimeout(createTableIfNotExistsWithResponse(tableName, context), timeout); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Callable> callable = () -> createTableIfNotExistsWithResponse(tableName, context); + Future> future = scheduler.submit(callable); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + } } - Mono> createTableIfNotExistsWithResponse(String tableName, Context context) { - return createTableWithResponse(tableName, context).onErrorResume(e -> e instanceof TableServiceException + Response createTableIfNotExistsWithResponse(String tableName, Context context) throws Exception { + try { + return createTableWithResponse(tableName, null, null); + } catch (Exception e) { + if (e instanceof TableServiceException && ((TableServiceException) e).getResponse() != null - && ((TableServiceException) e).getResponse().getStatusCode() == 409, - e -> { + && ((TableServiceException) e).getResponse().getStatusCode() == 409) { HttpResponse response = ((TableServiceException) e).getResponse(); - return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), - response.getHeaders(), null)); - }); + return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), + response.getHeaders(), null); + } + + throw logger.logThrowableAsError(e); + } } /** @@ -285,7 +371,7 @@ Mono> createTableIfNotExistsWithResponse(String tableName, */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable(String tableName) { - client.deleteTable(tableName).block(); + deleteTableWithResponse(tableName, null, null); } /** @@ -317,7 +403,30 @@ public void deleteTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(String tableName, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.deleteTableWithResponse(tableName, context), timeout); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Future> future = + scheduler.submit(() -> deleteTableWithResponse(tableName, context)); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception e) { + Exception exception = (Exception) TableUtils.mapThrowableToTableServiceException(e); + if (exception instanceof TableServiceException + && ((TableServiceException) exception).getResponse().getStatusCode() == 404) { + HttpResponse httpResponse = ((TableServiceException) exception).getResponse(); + return new SimpleResponse<>(httpResponse.getRequest(), httpResponse.getStatusCode(), + httpResponse.getHeaders(), null); + } + + throw logger.logExceptionAsError(new RuntimeException(exception)); + } + } + + Response deleteTableWithResponse(String tableName, Context context) { + context = context == null ? Context.NONE : context; + return new SimpleResponse<>( + implementation.getTables().deleteWithResponse(tableName, null, context), null); } /** @@ -340,7 +449,7 @@ public Response deleteTableWithResponse(String tableName, Duration timeout */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables() { - return new PagedIterable<>(client.listTables()); + return listTables(new ListTablesOptions(), null, null); } /** @@ -373,7 +482,98 @@ public PagedIterable listTables() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(client.listTables(options, context, timeout)); + ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Future> future = scheduler.submit(() -> listTables(options, context)); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + } + } + + private PagedIterable listTables(ListTablesOptions options, Context context) { + return new PagedIterable( + () -> listTablesFirstPage(context, options), + token -> listTablesNextPage(token, context, options) + ); + } + + private PagedResponse listTablesFirstPage(Context context, ListTablesOptions options) { + return listTables(null, context, options); + } + + private PagedResponse listTablesNextPage(String token, Context context, ListTablesOptions options) { + return listTables(token, context, options); + } + + private PagedResponse listTables(String nextTableName, Context context, ListTablesOptions options) { + context = context == null ? Context.NONE : context; + QueryOptions queryOptions = new QueryOptions() + .setFilter(options.getFilter()) + .setTop(options.getTop()) + .setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA); + + ResponseBase response = + implementation.getTables().queryWithResponse(null, nextTableName, queryOptions, context); + TableQueryResponse tableQueryResponse = response.getValue(); + + if (tableQueryResponse == null) { + return null; + } + + List tableResponsePropertiesList = tableQueryResponse.getValue(); + + if (tableResponsePropertiesList == null) { + return null; + } + + final List tables = tableResponsePropertiesList.stream() + .map(ModelHelper::createItem).collect(Collectors.toList()); + + return new TablePaged(response, tables, response.getDeserializedHeaders().getXMsContinuationNextTableName()); + } + + private static class TablePaged implements PagedResponse { + private final Response httpResponse; + private final IterableStream tableStream; + private final String continuationToken; + + TablePaged(Response httpResponse, List tableList, String continuationToken) { + this.httpResponse = httpResponse; + this.tableStream = IterableStream.of(tableList); + this.continuationToken = continuationToken; + } + + @Override + public int getStatusCode() { + return httpResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return httpResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return httpResponse.getRequest(); + } + + @Override + public IterableStream getElements() { + return tableStream; + } + + @Override + public String getContinuationToken() { + return continuationToken; + } + + @Override + public void close() { + } } /** @@ -398,7 +598,7 @@ public PagedIterable listTables(ListTablesOptions options, Duration t */ @ServiceMethod(returns = ReturnType.SINGLE) public TableServiceProperties getProperties() { - return client.getProperties().block(); + return getPropertiesWithResponse(null, null).getValue(); } /** @@ -430,9 +630,88 @@ public TableServiceProperties getProperties() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getPropertiesWithResponse(context), timeout); + ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Future> future = scheduler.submit(() -> getPropertiesWithResponse(context)); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception ex) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + } + + Response getPropertiesWithResponse(Context context) { + context = context == null ? Context.NONE : context; + Response response = + this.implementation.getServices().getPropertiesWithResponse(null, null, context); + return new SimpleResponse<>(response, toTableServiceProperties(response.getValue())); + } + + private TableServiceProperties toTableServiceProperties( + com.azure.data.tables.implementation.models.TableServiceProperties tableServiceProperties) { + + if (tableServiceProperties == null) { + return null; + } + + return new TableServiceProperties() + .setLogging(toTableServiceLogging(tableServiceProperties.getLogging())) + .setHourMetrics(toTableServiceMetrics(tableServiceProperties.getHourMetrics())) + .setMinuteMetrics(toTableServiceMetrics(tableServiceProperties.getMinuteMetrics())) + .setCorsRules(tableServiceProperties.getCors() == null ? null + : tableServiceProperties.getCors().stream() + .map(this::toTablesServiceCorsRule) + .collect(Collectors.toList())); + } + + private TableServiceLogging toTableServiceLogging(Logging logging) { + if (logging == null) { + return null; + } + + return new TableServiceLogging() + .setAnalyticsVersion(logging.getVersion()) + .setDeleteLogged(logging.isDelete()) + .setReadLogged(logging.isRead()) + .setWriteLogged(logging.isWrite()) + .setRetentionPolicy(toTableServiceRetentionPolicy(logging.getRetentionPolicy())); + } + + private TableServiceRetentionPolicy toTableServiceRetentionPolicy(RetentionPolicy retentionPolicy) { + if (retentionPolicy == null) { + return null; + } + + return new TableServiceRetentionPolicy() + .setEnabled(retentionPolicy.isEnabled()) + .setDaysToRetain(retentionPolicy.getDays()); + } + + private TableServiceMetrics toTableServiceMetrics(Metrics metrics) { + if (metrics == null) { + return null; + } + + return new TableServiceMetrics() + .setVersion(metrics.getVersion()) + .setEnabled(metrics.isEnabled()) + .setIncludeApis(metrics.isIncludeAPIs()) + .setRetentionPolicy(toTableServiceRetentionPolicy(metrics.getRetentionPolicy())); } + private TableServiceCorsRule toTablesServiceCorsRule(CorsRule corsRule) { + if (corsRule == null) { + return null; + } + + return new TableServiceCorsRule() + .setAllowedOrigins(corsRule.getAllowedOrigins()) + .setAllowedMethods(corsRule.getAllowedMethods()) + .setAllowedHeaders(corsRule.getAllowedHeaders()) + .setExposedHeaders(corsRule.getExposedHeaders()) + .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); + } /** * Sets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -466,7 +745,7 @@ public Response getPropertiesWithResponse(Duration timeo */ @ServiceMethod(returns = ReturnType.SINGLE) public void setProperties(TableServiceProperties tableServiceProperties) { - client.setProperties(tableServiceProperties).block(); + setPropertiesWithResponse(tableServiceProperties, null, null); } /** @@ -510,7 +789,84 @@ public void setProperties(TableServiceProperties tableServiceProperties) { @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Duration timeout, Context context) { - return blockWithOptionalTimeout(client.setPropertiesWithResponse(tableServiceProperties, context), timeout); + + ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Future> future = scheduler.submit(() -> setPropertiesWithResponse(tableServiceProperties, context)); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + } + } + + Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { + context = context == null ? Context.NONE : context; + return new SimpleResponse<>(this.implementation.getServices() + .setPropertiesWithResponse(toImplTableServiceProperties(tableServiceProperties), null, + null, context), null); + } + + private com.azure.data.tables.implementation.models.TableServiceProperties toImplTableServiceProperties( + TableServiceProperties tableServiceProperties) { + + return new com.azure.data.tables.implementation.models.TableServiceProperties() + .setLogging(toLogging(tableServiceProperties.getLogging())) + .setHourMetrics(toMetrics(tableServiceProperties.getHourMetrics())) + .setMinuteMetrics(toMetrics(tableServiceProperties.getMinuteMetrics())) + .setCors(tableServiceProperties.getCorsRules() == null ? null + : tableServiceProperties.getCorsRules().stream() + .map(this::toCorsRule) + .collect(Collectors.toList())); + } + + private Logging toLogging(TableServiceLogging tableServiceLogging) { + if (tableServiceLogging == null) { + return null; + } + + return new Logging() + .setVersion(tableServiceLogging.getAnalyticsVersion()) + .setDelete(tableServiceLogging.isDeleteLogged()) + .setRead(tableServiceLogging.isReadLogged()) + .setWrite(tableServiceLogging.isWriteLogged()) + .setRetentionPolicy(toRetentionPolicy(tableServiceLogging.getRetentionPolicy())); + } + + private RetentionPolicy toRetentionPolicy(TableServiceRetentionPolicy tableServiceRetentionPolicy) { + if (tableServiceRetentionPolicy == null) { + return null; + } + + return new RetentionPolicy() + .setEnabled(tableServiceRetentionPolicy.isEnabled()) + .setDays(tableServiceRetentionPolicy.getDaysToRetain()); + } + + private Metrics toMetrics(TableServiceMetrics tableServiceMetrics) { + if (tableServiceMetrics == null) { + return null; + } + + return new Metrics() + .setVersion(tableServiceMetrics.getVersion()) + .setEnabled(tableServiceMetrics.isEnabled()) + .setIncludeAPIs(tableServiceMetrics.isIncludeApis()) + .setRetentionPolicy(toRetentionPolicy(tableServiceMetrics.getTableServiceRetentionPolicy())); + } + + private CorsRule toCorsRule(TableServiceCorsRule corsRule) { + if (corsRule == null) { + return null; + } + + return new CorsRule() + .setAllowedOrigins(corsRule.getAllowedOrigins()) + .setAllowedMethods(corsRule.getAllowedMethods()) + .setAllowedHeaders(corsRule.getAllowedHeaders()) + .setExposedHeaders(corsRule.getExposedHeaders()) + .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); } /** @@ -535,7 +891,7 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ */ @ServiceMethod(returns = ReturnType.SINGLE) public TableServiceStatistics getStatistics() { - return client.getStatistics().block(); + return getStatisticsWithResponse(null, null).getValue(); } /** @@ -568,6 +924,44 @@ public TableServiceStatistics getStatistics() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getStatisticsWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getStatisticsWithResponse(context), timeout); + ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + long timeoutInMillis = setTimeout(timeout); + Future> future = scheduler.submit(() -> getStatisticsWithResponse(context)); + scheduler.shutdown(); + try { + return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + } + } + + + Response getStatisticsWithResponse(Context context) { + context = context == null ? Context.NONE : context; + Response response = this.implementation.getServices().getStatisticsWithResponse( + null, null, context); + return new SimpleResponse<>(response, toTableServiceStatistics(response.getValue())); + } + + + private TableServiceStatistics toTableServiceStatistics(TableServiceStats tableServiceStats) { + if (tableServiceStats == null) { + return null; + } + + return new TableServiceStatistics(toTableServiceGeoReplication(tableServiceStats.getGeoReplication())); + } + + private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication geoReplication) { + if (geoReplication == null) { + return null; + } + + return new TableServiceGeoReplication( + TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), + geoReplication.getLastSyncTime()); + } + private Long setTimeout(Duration timeout) { + return timeout != null ? timeout.toMillis() : -1; } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java index 9ad726e0fc71..853ceaa405b3 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java @@ -122,9 +122,66 @@ public TableServiceClientBuilder() { * respectively. */ public TableServiceClient buildClient() { - return new TableServiceClient(buildAsyncClient()); + TableServiceVersion serviceVersion = version != null ? version : TableServiceVersion.getLatest(); + + validateCredentials(azureNamedKeyCredential, azureSasCredential, tokenCredential, sasToken, connectionString, + logger); + + AzureNamedKeyCredential namedKeyCredential = null; + + // If 'connectionString' was provided, extract the endpoint and sasToken. + if (connectionString != null) { + StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, logger); + StorageEndpoint storageConnectionStringTableEndpoint = storageConnectionString.getTableEndpoint(); + + if (storageConnectionStringTableEndpoint == null + || storageConnectionStringTableEndpoint.getPrimaryUri() == null) { + + throw logger.logExceptionAsError(new IllegalArgumentException( + "'connectionString' is missing the required settings to derive a Tables endpoint.")); + } + + String connectionStringEndpoint = storageConnectionStringTableEndpoint.getPrimaryUri(); + + // If no 'endpoint' was provided, use the one in the 'connectionString'. Else, verify they are the same. + if (endpoint == null) { + endpoint = connectionStringEndpoint; + } else { + if (endpoint.endsWith("/")) { + endpoint = endpoint.substring(0, endpoint.length() - 1); + } + + if (connectionStringEndpoint.endsWith("/")) { + connectionStringEndpoint = + connectionStringEndpoint.substring(0, connectionStringEndpoint.length() - 1); + } + + if (!endpoint.equals(connectionStringEndpoint)) { + throw logger.logExceptionAsError(new IllegalStateException( + "'endpoint' points to a different tables endpoint than 'connectionString'.")); + } + } + + StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); + + if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { + namedKeyCredential = (azureNamedKeyCredential != null) ? azureNamedKeyCredential + : new AzureNamedKeyCredential(authSettings.getAccount().getName(), + authSettings.getAccount().getAccessKey()); + } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { + sasToken = (sasToken != null) ? sasToken : authSettings.getSasToken(); + } + } + + HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( + namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, + tokenCredential, sasToken, endpoint, retryPolicy, retryOptions, httpLogOptions, clientOptions, httpClient, + perCallPolicies, perRetryPolicies, configuration, logger, enableTenantDiscovery); + + return new TableServiceClient(pipeline, endpoint, serviceVersion, serializerAdapter); } + /** * Creates a {@link TableServiceAsyncClient} based on options set in the builder. * diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TransactionalBatchImpl.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TransactionalBatchImpl.java index 0515d80bfae5..66d1511bfeaa 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TransactionalBatchImpl.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TransactionalBatchImpl.java @@ -66,6 +66,18 @@ Mono submitTransactionalBatchSync( + @HostParam("url") String url, + @HeaderParam("Content-Type") String multipartContentType, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("DataServiceVersion") String dataServiceVersion, + @BodyParam("multipart/mixed") TransactionalBatchRequestBody body, + Context context); } /** @@ -87,4 +99,25 @@ public Mono}. + * + * @throws IllegalArgumentException If parameters fail validation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase submitTransactionalBatchWithRestResponse(TransactionalBatchRequestBody body, String requestId, Context context) { + final String dataServiceVersion = "3.0"; + + return service.submitTransactionalBatchSync(this.client.getUrl(), body.getContentType(), this.client.getVersion(), requestId, + dataServiceVersion, body, context); + } + } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TransactionalBatchAction.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TransactionalBatchAction.java index 56ce6679addc..ebee309c4818 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TransactionalBatchAction.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TransactionalBatchAction.java @@ -5,6 +5,7 @@ import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.Response; import com.azure.data.tables.TableAsyncClient; +import com.azure.data.tables.TableClient; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableEntityUpdateMode; import reactor.core.publisher.Mono; @@ -12,6 +13,8 @@ public interface TransactionalBatchAction { Mono prepareRequest(TableAsyncClient preparer); + HttpRequest prepareRequest(TableClient preparer); + class CreateEntity implements TransactionalBatchAction { private final TableEntity entity; @@ -28,6 +31,11 @@ public Mono prepareRequest(TableAsyncClient client) { return client.createEntityWithResponse(entity).map(Response::getRequest); } + @Override + public HttpRequest prepareRequest(TableClient client) { + return client.createEntityWithResponse(entity, null, null).getRequest(); + } + @Override public String toString() { return "CreateEntity{" @@ -59,6 +67,11 @@ public Mono prepareRequest(TableAsyncClient preparer) { return preparer.upsertEntityWithResponse(entity, updateMode).map(Response::getRequest); } + @Override + public HttpRequest prepareRequest(TableClient preparer) { + return preparer.upsertEntityWithResponse(entity, updateMode, null, null).getRequest(); + } + @Override public String toString() { return "UpsertEntity{" @@ -97,6 +110,12 @@ public Mono prepareRequest(TableAsyncClient preparer) { return preparer.updateEntityWithResponse(entity, updateMode, ifUnchanged).map(Response::getRequest); } + @Override + public HttpRequest prepareRequest(TableClient preparer) { + return preparer + .updateEntityWithResponse(entity, updateMode, ifUnchanged, null, null).getRequest(); + } + @Override public String toString() { return "UpdateEntity{" @@ -130,6 +149,11 @@ public Mono prepareRequest(TableAsyncClient preparer) { return preparer.deleteEntityWithResponse(entity, ifUnchanged).map(Response::getRequest); } + @Override + public HttpRequest prepareRequest(TableClient preparer) { + return preparer.deleteEntityWithResponse(entity, ifUnchanged, null, null).getRequest(); + } + @Override public String toString() { return "DeleteEntity{" From 65b29980bf3c4130fe48a74437fe613ffe9d5f19 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:44:51 -0800 Subject: [PATCH 05/25] Synchronous implementation of our Clients --- .../com/azure/data/tables/TableClient.java | 85 +++++++++++-------- .../azure/data/tables/TableServiceClient.java | 16 ++-- .../tables/implementation/TableUtils.java | 5 +- .../tables/implementation/TablesImpl.java | 13 +-- .../implementation/models/AccessPolicy.java | 2 + .../implementation/models/CorsRule.java | 2 + .../implementation/models/GeoReplication.java | 2 + .../tables/implementation/models/Logging.java | 2 + .../tables/implementation/models/Metrics.java | 2 + .../implementation/models/QueryOptions.java | 2 + .../models/RetentionPolicy.java | 2 + .../models/ServicesGetPropertiesHeaders.java | 2 + .../models/ServicesGetStatisticsHeaders.java | 2 + .../models/ServicesSetPropertiesHeaders.java | 2 + .../models/SignedIdentifier.java | 2 + .../models/TableEntityQueryResponse.java | 3 + .../models/TableProperties.java | 2 + .../models/TableQueryResponse.java | 3 + .../implementation/models/TableResponse.java | 2 + .../models/TableResponseProperties.java | 2 + .../models/TableServiceError.java | 2 + .../models/TableServiceProperties.java | 6 +- .../models/TableServiceStats.java | 2 + .../models/TablesCreateHeaders.java | 2 + .../models/TablesDeleteEntityHeaders.java | 2 + .../models/TablesDeleteHeaders.java | 2 + .../models/TablesGetAccessPolicyHeaders.java | 2 + .../models/TablesInsertEntityHeaders.java | 2 + .../models/TablesMergeEntityHeaders.java | 2 + .../models/TablesQueryEntitiesHeaders.java | 2 + ...ryEntityWithPartitionAndRowKeyHeaders.java | 2 + .../models/TablesQueryHeaders.java | 2 + .../models/TablesSetAccessPolicyHeaders.java | 2 + .../models/TablesUpdateEntityHeaders.java | 2 + .../tables/models/TableSignedIdentifier.java | 2 + .../data/tables/TableAsyncClientTest.java | 1 + .../azure/data/tables/TableClientTest.java | 4 + .../tables/TableServiceAsyncClientTest.java | 1 + .../data/tables/TableServiceClientTest.java | 1 + .../azure-data-tables/swagger/README.md | 3 +- 40 files changed, 146 insertions(+), 51 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index e40f5682e20e..2fe26f94542f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; +import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpRequest; @@ -66,6 +67,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -75,6 +77,7 @@ import static com.azure.core.util.CoreUtils.isNullOrEmpty; +import static com.azure.data.tables.implementation.TableUtils.mapThrowableToTableServiceException; import static com.azure.data.tables.implementation.TableUtils.toTableServiceError; /** @@ -242,7 +245,7 @@ private Context setContext(Context context) { } private Long setTimeout(Duration timeout) { - return timeout != null ? timeout.toMillis() : -1; + return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); } /** @@ -298,24 +301,23 @@ public Response createTableWithResponse(Duration timeout, Context con final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); Callable> createTableOp = () -> { - try { - return new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, - null, - ResponseFormat.RETURN_NO_CONTENT, null, contextValue), - ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); - } catch (RuntimeException ex) { - throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); - } + return new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, + null, + ResponseFormat.RETURN_NO_CONTENT, null, contextValue), + ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); }; ScheduledFuture> scheduledFuture = scheduler.schedule(createTableOp, IMMEDIATELY, TimeUnit.SECONDS); - scheduler.shutdown(); + //scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + Response response = scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + scheduler.shutdown(); + return response; } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(ex)); //TODO: Test this error being thrown + scheduler.shutdown(); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); //TODO: Test this error being thrown } } @@ -381,18 +383,21 @@ public Response deleteTableWithResponse(Duration timeout, Context context) try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - if (ex instanceof TableServiceException - && - ((TableServiceException) ex).getResponse().getStatusCode() == 404) { - return new SimpleResponse<>( - ((TableServiceException) ex).getResponse().getRequest(), - ((TableServiceException) ex).getResponse().getStatusCode(), - ((TableServiceException) ex).getResponse().getHeaders(), - null); - } else { - throw logger.logExceptionAsError( - new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); - } + Throwable except = mapThrowableToTableServiceException(ex); + return swallow404Exception(except); + } + } + + private Response swallow404Exception(Throwable ex) { + if (ex instanceof TableServiceException && + ((TableServiceException) ex).getResponse().getStatusCode() == 404) { + return new SimpleResponse<>( + ((TableServiceException) ex).getResponse().getRequest(), + ((TableServiceException) ex).getResponse().getStatusCode(), + ((TableServiceException) ex).getResponse().getHeaders(), + null); + } else { + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -486,7 +491,7 @@ public Response createEntityWithResponse(TableEntity entity, Duration time try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -599,7 +604,7 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -760,7 +765,7 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -888,7 +893,8 @@ tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalET try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + Throwable except = mapThrowableToTableServiceException(ex); + return swallow404Exception(except); } } @@ -983,7 +989,7 @@ public PagedIterable listEntities(ListEntitiesOptions options, Dura try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1226,7 +1232,7 @@ tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, n try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1318,7 +1324,7 @@ public Response getAccessPoliciesWithResponse(Duration time try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1471,7 +1477,7 @@ public Response setAccessPoliciesWithResponse(List try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1751,11 +1757,22 @@ public Response submitTransactionWithResponse(List> scheduledFuture = scheduler.schedule(submitTransactionOp, IMMEDIATELY, TimeUnit.SECONDS); + scheduler.shutdown(); try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); - } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + } + catch (Exception ex) { + Exception exception = ex; + if (exception instanceof ExecutionException) { + exception = (Exception) exception.getCause(); + } + if (exception.getCause() instanceof TableTransactionFailedException) { + throw logger.logExceptionAsError((TableTransactionFailedException) exception.getCause()); + } else { + throw logger.logExceptionAsError((RuntimeException)(mapThrowableToTableServiceException(exception))); + } + } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 553717d15801..7be9bb4f86eb 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -255,7 +255,7 @@ public Response createTableWithResponse(String tableName, Duration try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } } @@ -329,7 +329,7 @@ public Response createTableIfNotExistsWithResponse(String tableName try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } } @@ -419,7 +419,7 @@ public Response deleteTableWithResponse(String tableName, Duration timeout httpResponse.getHeaders(), null); } - throw logger.logExceptionAsError(new RuntimeException(exception)); + throw logger.logExceptionAsError((RuntimeException) exception); } } @@ -489,7 +489,7 @@ public PagedIterable listTables(ListTablesOptions options, Duration t try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } } @@ -637,7 +637,7 @@ public Response getPropertiesWithResponse(Duration timeo try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } } @@ -797,7 +797,7 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } } @@ -931,7 +931,7 @@ public Response getStatisticsWithResponse(Duration timeo try { return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { - throw logger.logExceptionAsError(new RuntimeException(TableUtils.mapThrowableToTableServiceException(e))); + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } } @@ -962,6 +962,6 @@ private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication g geoReplication.getLastSyncTime()); } private Long setTimeout(Duration timeout) { - return timeout != null ? timeout.toMillis() : -1; + return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index f98603f5318f..30ccb321ea06 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -92,7 +92,10 @@ public static TableServiceException toTableServiceException(TableServiceErrorExc public static Throwable mapThrowableToTableServiceException(Throwable throwable) { if (throwable instanceof TableServiceErrorException) { return toTableServiceException((TableServiceErrorException) throwable); - } else { + } else if (throwable.getCause() instanceof TableServiceErrorException) { + return toTableServiceException((TableServiceErrorException) throwable.getCause()); + } + else { return throwable; } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java index 5751de1bc0ee..75395ab64852 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablesImpl.java @@ -406,7 +406,7 @@ Mono> setAccessPolicy( @HeaderParam("x-ms-client-request-id") String requestId, @PathParam("table") String table, @QueryParam("comp") String comp, - @BodyParam("application/xml") List tableAcl, + @BodyParam("application/xml") SignedIdentifiersWrapper tableAcl, @HeaderParam("Accept") String accept, Context context); @@ -420,7 +420,7 @@ ResponseBase setAccessPolicySync( @HeaderParam("x-ms-client-request-id") String requestId, @PathParam("table") String table, @QueryParam("comp") String comp, - @BodyParam("application/xml") List tableAcl, + @BodyParam("application/xml") SignedIdentifiersWrapper tableAcl, @HeaderParam("Accept") String accept, Context context); } @@ -2691,6 +2691,7 @@ public Mono> setAccessPolicyWit String table, Integer timeout, String requestId, List tableAcl) { final String comp = "acl"; final String accept = "application/xml"; + SignedIdentifiersWrapper tableAclConverted = new SignedIdentifiersWrapper(tableAcl); return FluxUtil.withContext( context -> service.setAccessPolicy( @@ -2700,7 +2701,7 @@ public Mono> setAccessPolicyWit requestId, table, comp, - tableAcl, + tableAclConverted, accept, context)); } @@ -2724,6 +2725,7 @@ public Mono> setAccessPolicyWit String table, Integer timeout, String requestId, List tableAcl, Context context) { final String comp = "acl"; final String accept = "application/xml"; + SignedIdentifiersWrapper tableAclConverted = new SignedIdentifiersWrapper(tableAcl); return service.setAccessPolicy( this.client.getUrl(), timeout, @@ -2731,7 +2733,7 @@ public Mono> setAccessPolicyWit requestId, table, comp, - tableAcl, + tableAclConverted, accept, context); } @@ -2795,6 +2797,7 @@ public ResponseBase setAccessPolicyWithRespo String table, Integer timeout, String requestId, List tableAcl, Context context) { final String comp = "acl"; final String accept = "application/xml"; + SignedIdentifiersWrapper tableAclConverted = new SignedIdentifiersWrapper(tableAcl); return service.setAccessPolicySync( this.client.getUrl(), timeout, @@ -2802,7 +2805,7 @@ public ResponseBase setAccessPolicyWithRespo requestId, table, comp, - tableAcl, + tableAclConverted, accept, context); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java index cdbd4bd26059..bf82a3974056 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java @@ -6,9 +6,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** An Access policy. */ +@JacksonXmlRootElement(localName = "AccessPolicy") @Fluent public final class AccessPolicy { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java index cde2032a1087..3e44b99f0ef9 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/CorsRule.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** * CORS is an HTTP feature that enables a web application running under one domain to access resources in another @@ -13,6 +14,7 @@ * calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs * in another domain. */ +@JacksonXmlRootElement(localName = "CorsRule") @Fluent public final class CorsRule { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java index 67b098938001..152991dd22bc 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/GeoReplication.java @@ -7,9 +7,11 @@ import com.azure.core.annotation.Fluent; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The GeoReplication model. */ +@JacksonXmlRootElement(localName = "GeoReplication") @Fluent public final class GeoReplication { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java index 0d273b1bd158..4f761071ea81 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Logging.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** Azure Analytics Logging settings. */ +@JacksonXmlRootElement(localName = "Logging") @Fluent public final class Logging { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java index 39ec6f40be62..0abdd4adcb7d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/Metrics.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The Metrics model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class Metrics { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java index 65abc533556f..654a1c2211ac 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/QueryOptions.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** Parameter group. */ +@JacksonXmlRootElement(localName = "QueryOptions") @Fluent public final class QueryOptions { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java index 82d1b6a8cddc..c90703fb255e 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/RetentionPolicy.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The retention policy. */ +@JacksonXmlRootElement(localName = "RetentionPolicy") @Fluent public final class RetentionPolicy { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java index 3217ebce53c1..70ccdd76f8fe 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetPropertiesHeaders.java @@ -8,8 +8,10 @@ import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The ServicesGetPropertiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesGetPropertiesHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java index ab1f8504d5dc..5bc92922d3f0 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesGetStatisticsHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The ServicesGetStatisticsHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesGetStatisticsHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java index 558a544d9a3e..138b5fde3c9b 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/ServicesSetPropertiesHeaders.java @@ -8,8 +8,10 @@ import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The ServicesSetPropertiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesSetPropertiesHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java index fed95acc0bd5..672a9f30503f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifier.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** A signed identifier. */ +@JacksonXmlRootElement(localName = "SignedIdentifier") @Fluent public final class SignedIdentifier { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java index 5529b586590c..00149408b186 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java @@ -6,10 +6,13 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.ArrayList; import java.util.List; import java.util.Map; /** The properties for the table entity query response. */ +@JacksonXmlRootElement(localName = "TableEntityQueryResponse") @Fluent public final class TableEntityQueryResponse { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java index c1fb6536f01d..204021288cb2 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableProperties.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The properties for creating a table. */ +@JacksonXmlRootElement(localName = "TableProperties") @Fluent public final class TableProperties { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java index ae03599e294a..f8f938353a21 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java @@ -6,9 +6,12 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.ArrayList; import java.util.List; /** The properties for the table query response. */ +@JacksonXmlRootElement(localName = "TableQueryResponse") @Fluent public final class TableQueryResponse { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java index 1ff687311b17..fcfe50618384 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponse.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The response for a single table. */ +@JacksonXmlRootElement(localName = "TableResponse") @Fluent public final class TableResponse extends TableResponseProperties { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java index 6732c6a8b537..38455f0c18d3 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableResponseProperties.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The properties for the table response. */ +@JacksonXmlRootElement(localName = "TableResponseProperties") @Fluent public class TableResponseProperties { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceError.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceError.java index 93622896c425..041434353c99 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceError.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceError.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** Table Service error. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TableServiceError { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceProperties.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceProperties.java index 01d9bac84e8b..803750d48251 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceProperties.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceProperties.java @@ -9,7 +9,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; - import java.util.ArrayList; import java.util.List; @@ -44,12 +43,16 @@ private CorsWrapper(@JacksonXmlProperty(localName = "CorsRule") List i this.items = items; } } + /* * The set of CORS rules. */ @JsonProperty(value = "Cors") private CorsWrapper cors; + /** Creates an instance of TableServiceProperties class. */ + public TableServiceProperties() {} + /** * Get the logging property: Azure Analytics Logging settings. * @@ -119,7 +122,6 @@ public List getCors() { if (this.cors == null) { this.cors = new CorsWrapper(new ArrayList()); } - return this.cors.items; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java index b1d09d95c925..d4e2b82973b7 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableServiceStats.java @@ -6,8 +6,10 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** Stats for the service. */ +@JacksonXmlRootElement(localName = "StorageServiceStats") @Fluent public final class TableServiceStats { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java index 44de537e7975..7321722205b2 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesCreateHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesCreateHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesCreateHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java index d228fe713add..e24723cea275 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteEntityHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesDeleteEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesDeleteEntityHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java index ceff61a3e9d9..079e7acdca40 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesDeleteHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesDeleteHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesDeleteHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java index ab0b4fea9103..d45b6b26333d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesGetAccessPolicyHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesGetAccessPolicyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesGetAccessPolicyHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java index 05eba9f426c8..d8aea93228d2 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesInsertEntityHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesInsertEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesInsertEntityHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java index 97a75f11a1de..d6b29bef0174 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesMergeEntityHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesMergeEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesMergeEntityHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java index a5d213c56202..dd3d5ce14fd1 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntitiesHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryEntitiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryEntitiesHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java index 642d72b86531..92bf29fd3a72 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryEntityWithPartitionAndRowKeyHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryEntityWithPartitionAndRowKeyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryEntityWithPartitionAndRowKeyHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java index 051a022126b8..0fe95010a731 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesQueryHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java index 2069fb2e00c7..26870739f798 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesSetAccessPolicyHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesSetAccessPolicyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesSetAccessPolicyHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java index bb99eacfc158..71852b48013f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TablesUpdateEntityHeaders.java @@ -9,9 +9,11 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.util.DateTimeRfc1123; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesUpdateEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesUpdateEntityHeaders { /* diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java index d758c9e5c275..bc40b9655c40 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java @@ -4,12 +4,14 @@ package com.azure.data.tables.models; import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.util.Objects; /** * A signed identifier. */ +@JacksonXmlRootElement(localName = "SignedIdentifier") @Fluent public final class TableSignedIdentifier { /* diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java index 82812abf55be..8e08b9c16f5b 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java @@ -109,6 +109,7 @@ public void createTableWithMultipleTenants() { .clientId(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_ID", "clientId")) .clientSecret(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_SECRET", "clientSecret")) .tenantId(testResourceNamer.randomUuid()) + .additionallyAllowedTenants("*") .build(); final TableAsyncClient tableClient2 = diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java index cd68e2fb2b92..5ec4ad85a98e 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java @@ -95,6 +95,7 @@ public void createTableWithMultipleTenants() { .clientId(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_ID", "clientId")) .clientSecret(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_SECRET", "clientSecret")) .tenantId(testResourceNamer.randomUuid()) + .additionallyAllowedTenants("*") .build(); final TableClient tableClient2 = @@ -1132,4 +1133,7 @@ public void setAndListMultipleAccessPolicies() { assertEquals(permissions, accessPolicy.getPermissions()); } } + + // Testing for correct errors thrown + } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java index 3a892a1bead0..db462d303ac0 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java @@ -106,6 +106,7 @@ public void serviceCreateTableWithMultipleTenants() { .clientId(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_ID", "clientId")) .clientSecret(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_SECRET", "clientSecret")) .tenantId(testResourceNamer.randomUuid()) + .additionallyAllowedTenants("*") .build(); final TableServiceAsyncClient tableServiceAsyncClient = diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java index 5c2b3815454d..b933b6e0efa7 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java @@ -96,6 +96,7 @@ public void serviceCreateTableWithMultipleTenants() { .clientId(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_ID", "clientId")) .clientSecret(Configuration.getGlobalConfiguration().get("TABLES_CLIENT_SECRET", "clientSecret")) .tenantId(testResourceNamer.randomUuid()) + .additionallyAllowedTenants("*") .build(); final TableServiceClient tableServiceClient = diff --git a/sdk/tables/azure-data-tables/swagger/README.md b/sdk/tables/azure-data-tables/swagger/README.md index 9f22afac5468..5e81b9b518a3 100644 --- a/sdk/tables/azure-data-tables/swagger/README.md +++ b/sdk/tables/azure-data-tables/swagger/README.md @@ -21,7 +21,7 @@ autorest ### Code generation settings ```yaml use: '@autorest/java@4.1.2' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json java: true output-folder: ..\ generate-client-as-impl: true @@ -33,6 +33,7 @@ add-context-parameter: true models-subpackage: implementation.models context-client-method-parameter: true service-interface-as-public: true +enable-xml: true custom-strongly-typed-header-deserialization: true generic-response-type: true ``` From 8ad09dfa51005182416366f067212bfcbeea5240 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 09:53:37 -0800 Subject: [PATCH 06/25] Update to CHANGELOG.md --- sdk/tables/azure-data-tables/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index cfdc2c084c7d..4478d5d9cd08 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bugs Fixed ### Other Changes +- Removed Reactor from synchronous clients ## 12.3.7 (2023-01-11) From 6b1ebf9c039a7d6bcc6753473341ae25c9535f50 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:10:39 -0800 Subject: [PATCH 07/25] Fix PR build issues --- .../SignedIdentifiersWrapper.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/SignedIdentifiersWrapper.java diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/SignedIdentifiersWrapper.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/SignedIdentifiersWrapper.java new file mode 100644 index 000000000000..e1debb615867 --- /dev/null +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/SignedIdentifiersWrapper.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.data.tables.implementation; + +import com.azure.data.tables.implementation.models.SignedIdentifier; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.List; + +/** A wrapper around List<SignedIdentifier> which provides top-level metadata for serialization. */ +@JacksonXmlRootElement(localName = "SignedIdentifiers") +public final class SignedIdentifiersWrapper { + @JacksonXmlProperty(localName = "SignedIdentifier") + private final List signedIdentifiers; + + /** + * Creates an instance of SignedIdentifiersWrapper. + * + * @param signedIdentifiers the list. + */ + @JsonCreator + public SignedIdentifiersWrapper(@JsonProperty("SignedIdentifier") List signedIdentifiers) { + this.signedIdentifiers = signedIdentifiers; + } + + /** + * Get the List<SignedIdentifier> contained in this wrapper. + * + * @return the List<SignedIdentifier>. + */ + public List items() { + return signedIdentifiers; + } +} From 373ed438b0c85e79f5eec74c168125d370725786 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:27:27 -0800 Subject: [PATCH 08/25] Fix PR build issues --- .../com/azure/data/tables/TableClient.java | 52 ++++++++----------- .../models/TableEntityQueryResponse.java | 1 - .../models/TableQueryResponse.java | 1 - 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 2fe26f94542f..4a38a7aa4804 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpRequest; @@ -300,12 +299,11 @@ public Response createTableWithResponse(Duration timeout, Context con final TableProperties properties = new TableProperties().setTableName(tableName); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Callable> createTableOp = () -> { - return new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, - null, - ResponseFormat.RETURN_NO_CONTENT, null, contextValue), - ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); - }; + Callable> createTableOp = () -> + new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, + null, + ResponseFormat.RETURN_NO_CONTENT, null, contextValue), + ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); ScheduledFuture> scheduledFuture = scheduler.schedule(createTableOp, IMMEDIATELY, TimeUnit.SECONDS); @@ -370,11 +368,10 @@ public Response deleteTableWithResponse(Duration timeout, Context context) final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Callable> deleteTableOp = () -> { - return new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( - tableName, null, contextValue), - null); - }; + Callable> deleteTableOp = () -> + new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( + tableName, null, contextValue), + null); ScheduledFuture> scheduledFuture = scheduler.schedule(deleteTableOp, IMMEDIATELY, TimeUnit.SECONDS); @@ -389,7 +386,8 @@ public Response deleteTableWithResponse(Duration timeout, Context context) } private Response swallow404Exception(Throwable ex) { - if (ex instanceof TableServiceException && + if (ex instanceof TableServiceException + && ((TableServiceException) ex).getResponse().getStatusCode() == 404) { return new SimpleResponse<>( ((TableServiceException) ex).getResponse().getRequest(), @@ -397,7 +395,7 @@ private Response swallow404Exception(Throwable ex) { ((TableServiceException) ex).getResponse().getHeaders(), null); } else { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -881,11 +879,9 @@ private Response deleteEntityWithResponse(String partitionKey, String rowK throw logger.logExceptionAsError(new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null")); } - Callable> deleteEntityOp = () -> { - return tablesImplementation.getTables().deleteEntityWithResponse( - tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalETag, null, - null, null, contextValue); - }; + Callable> deleteEntityOp = () -> tablesImplementation.getTables().deleteEntityWithResponse( + tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalETag, null, + null, null, contextValue); ScheduledFuture> scheduledFuture = scheduler.schedule(deleteEntityOp, IMMEDIATELY, TimeUnit.SECONDS); @@ -976,11 +972,9 @@ public PagedIterable listEntities(ListEntitiesOptions options, Dura final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Callable> listEntitiesOp = () -> { - return new PagedIterable<>( - () -> listEntitiesFirstPage(context, options, TableEntity.class), - token -> listEntitiesNextPage(token, context, options, TableEntity.class)); - }; + Callable> listEntitiesOp = () -> new PagedIterable<>( + () -> listEntitiesFirstPage(context, options, TableEntity.class), + token -> listEntitiesNextPage(token, context, options, TableEntity.class)); ScheduledFuture> scheduledFuture = scheduler.schedule(listEntitiesOp, IMMEDIATELY, TimeUnit.SECONDS); @@ -1038,7 +1032,7 @@ private PagedResponse listEntities(String nextPartiti final ResponseBase response = tablesImplementation.getTables().queryEntitiesWithResponse(tableName, null, null, - nextPartitionKey, nextRowKey, queryOptions, context); + nextPartitionKey, nextRowKey, queryOptions, contextValue); final TableEntityQueryResponse tablesQueryEntityResponse = response.getValue(); @@ -1734,12 +1728,10 @@ public Response submitTransactionWithResponse(List
> submitTransactionOp = () -> { - BiConsumer accumulator = (body, pair) -> { + BiConsumer accumulator = (body, pair) -> body.addChangeOperation(new TransactionalBatchSubRequest(pair.getAction(), pair.getRequest())); - }; - BiConsumer combiner = (body1, body2) -> { - body2.getContents().forEach( req -> body1.addChangeOperation((TransactionalBatchSubRequest) req)); - }; + BiConsumer combiner = (body1, body2) -> + body2.getContents().forEach(req -> body1.addChangeOperation((TransactionalBatchSubRequest) req)); TransactionalBatchRequestBody requestBody = operations.stream() .map(op -> new RequestActionPair(op.prepareRequest(transactionalBatchClient), op)) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java index 00149408b186..24334ab975a5 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableEntityQueryResponse.java @@ -7,7 +7,6 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java index f8f938353a21..e45c2626e322 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/TableQueryResponse.java @@ -7,7 +7,6 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import java.util.ArrayList; import java.util.List; /** The properties for the table query response. */ From ed2995664d30258bd247ebdbbde71b11e21ac4fd Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:38:34 -0800 Subject: [PATCH 09/25] Removed TODOs left behind. --- .../java/com/azure/data/tables/TableClient.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 4a38a7aa4804..a25466667b72 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -294,7 +294,6 @@ public TableItem createTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(Duration timeout, Context context) { - // TODO: Spawn thread to utilize timeout param Context contextValue = setContext(context); final TableProperties properties = new TableProperties().setTableName(tableName); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); @@ -315,7 +314,7 @@ public Response createTableWithResponse(Duration timeout, Context con return response; } catch (Exception ex) { scheduler.shutdown(); - throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); //TODO: Test this error being thrown + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } } @@ -363,7 +362,6 @@ public void deleteTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { - // TODO: Spawn thread to utilize timeout param Context contextValue = setContext(context); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -465,7 +463,6 @@ public void createEntity(TableEntity entity) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param Context contextValue = setContext(context); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -570,7 +567,6 @@ public void upsertEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param Context contextValue = setContext(context); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -729,7 +725,6 @@ public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { @ServiceMethod(returns = ReturnType.SINGLE) public Response updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param Context contextValue = setContext(context); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -862,7 +857,6 @@ public void deleteEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnchanged, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param return deleteEntityWithResponse( entity.getPartitionKey(), entity.getRowKey(), entity.getETag(), ifUnchanged, timeout, context); } @@ -968,7 +962,6 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -1183,7 +1176,6 @@ public TableEntity getEntity(String partitionKey, String rowKey) { @ServiceMethod(returns = ReturnType.SINGLE) public Response getEntityWithResponse(String partitionKey, String rowKey, List select, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); Context contextValue = setContext(context); @@ -1295,7 +1287,6 @@ public TableAccessPolicies getAccessPolicies() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); Context contextValue = setContext(context); @@ -1422,7 +1413,6 @@ public void setAccessPolicies(List tableSignedIdentifiers @ServiceMethod(returns = ReturnType.SINGLE) public Response setAccessPoliciesWithResponse(List tableSignedIdentifiers, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); Context contextValue = setContext(context); @@ -1678,7 +1668,6 @@ public TableTransactionResult submitTransaction(List tra */ @ServiceMethod(returns = ReturnType.SINGLE) public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { - // TODO: spawn thread to utilize timeout param final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); Context contextValue = setContext(context); @@ -1730,7 +1719,7 @@ public Response submitTransactionWithResponse(List
> submitTransactionOp = () -> { BiConsumer accumulator = (body, pair) -> body.addChangeOperation(new TransactionalBatchSubRequest(pair.getAction(), pair.getRequest())); - BiConsumer combiner = (body1, body2) -> + BiConsumer combiner = (body1, body2) -> body2.getContents().forEach(req -> body1.addChangeOperation((TransactionalBatchSubRequest) req)); TransactionalBatchRequestBody requestBody = operations.stream() From bb77546979114b3e9c48087fbc89785d7dc12621 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:54:22 -0800 Subject: [PATCH 10/25] Adjusting whitespaces --- .../src/main/java/com/azure/data/tables/TableClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index a25466667b72..8d76c27fbaef 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -486,7 +486,7 @@ public Response createEntityWithResponse(TableEntity entity, Duration time try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -598,7 +598,7 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -758,7 +758,7 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -976,7 +976,7 @@ public PagedIterable listEntities(ListEntitiesOptions options, Dura try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } From d87f51de0fe1190418cf253d94b18f8020769a63 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:58:36 -0800 Subject: [PATCH 11/25] Removing unnecessary annotation --- .../com/azure/data/tables/models/TableSignedIdentifier.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java index bc40b9655c40..d758c9e5c275 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java @@ -4,14 +4,12 @@ package com.azure.data.tables.models; import com.azure.core.annotation.Fluent; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.util.Objects; /** * A signed identifier. */ -@JacksonXmlRootElement(localName = "SignedIdentifier") @Fluent public final class TableSignedIdentifier { /* From 3638028f47c00a4f491c34798dcff2c0c17c6bbf Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:09:06 -0800 Subject: [PATCH 12/25] Adjustments to how context information: - Added Synchronous Rest Proxy Context - Added Trailing Context Checkstyle adjustments --- .../azure/data/tables/TableAsyncClient.java | 23 ++++++------ .../com/azure/data/tables/TableClient.java | 35 +++++++++---------- .../data/tables/TableServiceAsyncClient.java | 12 +++---- .../azure/data/tables/TableServiceClient.java | 17 +++++---- .../tables/implementation/TableUtils.java | 22 ++++++++++++ 5 files changed, 65 insertions(+), 44 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index e6d0c13f482e..0e6953d6027d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -238,9 +238,6 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { return new TableSasGenerator(tableSasSignatureValues, getTableName(), azureNamedKeyCredential).getSas(); } - private Context setContext(Context context) { - return context == null ? Context.NONE : context; - } /** * Creates the table within the Tables service. @@ -291,7 +288,7 @@ public Mono> createTableWithResponse() { } Mono> createTableWithResponse(Context context) { - context = setContext(context); + context = TableUtils.setContext(context); final TableProperties properties = new TableProperties().setTableName(tableName); try { @@ -353,7 +350,7 @@ public Mono> deleteTableWithResponse() { } Mono> deleteTableWithResponse(Context context) { - context = setContext(context); + context = TableUtils.setContext(context); try { return tablesImplementation.getTables().deleteWithResponseAsync(tableName, null, context) @@ -436,7 +433,7 @@ public Mono> createEntityWithResponse(TableEntity entity) { } Mono> createEntityWithResponse(TableEntity entity, Context context) { - context = setContext(context); + context = TableUtils.setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -536,7 +533,7 @@ public Mono> upsertEntityWithResponse(TableEntity entity, TableEn Mono> upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Context context) { - context = setContext(context); + context = TableUtils.setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -703,7 +700,7 @@ public Mono> updateEntityWithResponse(TableEntity entity, TableEn Mono> updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Context context) { - context = setContext(context); + context = TableUtils.setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -843,7 +840,7 @@ public Mono> deleteEntityWithResponse(TableEntity entity, boolean Mono> deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, Context context) { - context = setContext(context); + context = TableUtils.setContext(context); eTag = ifUnchanged ? eTag : "*"; if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { @@ -971,7 +968,7 @@ private Mono> listEntitiesNextPage(Stri private Mono> listEntities(String nextPartitionKey, String nextRowKey, Context context, ListEntitiesOptions options, Class resultType) { - context = setContext(context); + context = TableUtils.setContext(context); String select = null; if (options.getSelect() != null) { @@ -1252,7 +1249,7 @@ public Mono> getAccessPoliciesWithResponse() { } Mono> getAccessPoliciesWithResponse(Context context) { - context = setContext(context); + context = TableUtils.setContext(context); try { return tablesImplementation.getTables() @@ -1372,7 +1369,7 @@ public Mono> setAccessPoliciesWithResponse(List> setAccessPoliciesWithResponse(List tableSignedIdentifiers, Context context) { - context = setContext(context); + context = TableUtils.setContext(context); List signedIdentifiers = null; /* @@ -1621,7 +1618,7 @@ public Mono> submitTransactionWithResponse(List } Mono> submitTransactionWithResponse(List transactionActions, Context context) { - Context finalContext = setContext(context); + Context finalContext = TableUtils.setContext(context); if (transactionActions.isEmpty()) { return monoError(logger, diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 8d76c27fbaef..a82bca6a6069 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -239,9 +239,6 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { } - private Context setContext(Context context) { - return context == null ? Context.NONE : context; - } private Long setTimeout(Duration timeout) { return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); @@ -294,7 +291,7 @@ public TableItem createTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final TableProperties properties = new TableProperties().setTableName(tableName); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -362,7 +359,7 @@ public void deleteTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -463,7 +460,7 @@ public void createEntity(TableEntity entity) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -567,7 +564,7 @@ public void upsertEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -725,7 +722,7 @@ public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { @ServiceMethod(returns = ReturnType.SINGLE) public Response updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -863,7 +860,7 @@ public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnc private Response deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, Duration timeout, Context context) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); @@ -1010,7 +1007,7 @@ private PagedResponse listEntitiesNextPage(String tok private PagedResponse listEntities(String nextPartitionKey, String nextRowKey, Context context, ListEntitiesOptions options, Class resultType) { - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); String select = null; if (options.getSelect() != null) { @@ -1178,7 +1175,7 @@ public Response getEntityWithResponse(String partitionKey, String r Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); QueryOptions queryOptions = new QueryOptions() .setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA); @@ -1218,7 +1215,7 @@ tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, n try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1289,7 +1286,7 @@ public TableAccessPolicies getAccessPolicies() { public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); Callable> getAccessPoliciesOp = () -> { ResponseBase> response = @@ -1309,7 +1306,7 @@ public Response getAccessPoliciesWithResponse(Duration time try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1415,7 +1412,7 @@ public Response setAccessPoliciesWithResponse(List Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); List signedIdentifiers = null; if (tableSignedIdentifiers != null) { @@ -1461,7 +1458,7 @@ public Response setAccessPoliciesWithResponse(List try { return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { - throw logger.logExceptionAsError((RuntimeException)(TableUtils.mapThrowableToTableServiceException(ex))); + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } @@ -1670,7 +1667,7 @@ public TableTransactionResult submitTransaction(List tra public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = setTimeout(timeout); - Context contextValue = setContext(context); + Context contextValue = TableUtils.setContext(context, true); if (transactionActions.isEmpty()) { throw logger.logExceptionAsError( @@ -1751,7 +1748,7 @@ public Response submitTransactionWithResponse(List
> createTableWithResponse(String tableName } Mono> createTableWithResponse(String tableName, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); final TableProperties properties = new TableProperties().setTableName(tableName); try { @@ -399,7 +399,7 @@ public Mono> deleteTableWithResponse(String tableName) { } Mono> deleteTableWithResponse(String tableName, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return implementation.getTables().deleteWithResponseAsync(tableName, null, context) @@ -488,7 +488,7 @@ private Mono> listTablesNextPage(String token, Context private Mono> listTables(String nextTableName, Context context, ListTablesOptions options) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); QueryOptions queryOptions = new QueryOptions() .setFilter(options.getFilter()) .setTop(options.getTop()) @@ -618,7 +618,7 @@ public Mono> getPropertiesWithResponse() { } Mono> getPropertiesWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return this.implementation.getServices().getPropertiesWithResponseAsync(null, null, context) @@ -774,7 +774,7 @@ public Mono> setPropertiesWithResponse(TableServiceProperties tab } Mono> setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return @@ -904,7 +904,7 @@ public Mono> getStatisticsWithResponse() { } Mono> getStatisticsWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return this.implementation.getServices().getStatisticsWithResponseAsync(null, null, context) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 7be9bb4f86eb..0251854e341d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -14,6 +14,7 @@ import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.ResponseBase; +import com.azure.core.http.rest.RestProxy; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.IterableStream; @@ -260,7 +261,7 @@ public Response createTableWithResponse(String tableName, Duration } Response createTableWithResponse(String tableName, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); final TableProperties properties = new TableProperties().setTableName(tableName); return new SimpleResponse<>(implementation.getTables() @@ -424,7 +425,7 @@ public Response deleteTableWithResponse(String tableName, Duration timeout } Response deleteTableWithResponse(String tableName, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); return new SimpleResponse<>( implementation.getTables().deleteWithResponse(tableName, null, context), null); } @@ -509,7 +510,7 @@ private PagedResponse listTablesNextPage(String token, Context contex } private PagedResponse listTables(String nextTableName, Context context, ListTablesOptions options) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); QueryOptions queryOptions = new QueryOptions() .setFilter(options.getFilter()) .setTop(options.getTop()) @@ -642,7 +643,7 @@ public Response getPropertiesWithResponse(Duration timeo } Response getPropertiesWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); Response response = this.implementation.getServices().getPropertiesWithResponse(null, null, context); return new SimpleResponse<>(response, toTableServiceProperties(response.getValue())); @@ -802,7 +803,7 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ } Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); return new SimpleResponse<>(this.implementation.getServices() .setPropertiesWithResponse(toImplTableServiceProperties(tableServiceProperties), null, null, context), null); @@ -937,7 +938,7 @@ public Response getStatisticsWithResponse(Duration timeo Response getStatisticsWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context, true); Response response = this.implementation.getServices().getStatisticsWithResponse( null, null, context); return new SimpleResponse<>(response, toTableServiceStatistics(response.getValue())); @@ -964,4 +965,8 @@ private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication g private Long setTimeout(Duration timeout) { return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); } + + private Context enableSyncRestProxy(Context context) { + return context.addData("HTTP_REST_PROXY_SYNC_PROXY_ENABLE", true); + } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 30ccb321ea06..918d92cdabcb 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -6,6 +6,7 @@ import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import com.azure.data.tables.implementation.models.TableServiceErrorException; @@ -26,11 +27,15 @@ import java.util.function.Function; import static com.azure.core.util.FluxUtil.monoError; + +import static com.azure.core.util.tracing.Tracer.AZ_TRACING_NAMESPACE_KEY; /** * A class containing utility methods for the Azure Tables library. */ public final class TableUtils { private static final String UTF8_CHARSET = "UTF-8"; + private static final String HTTP_REST_PROXY_SYNC_PROXY_ENABLE = "com.azure.core.http.restproxy.syncproxy.enable"; + private static final String TABLES_TRACING_NAMESPACE_VALUE = "Microsoft.Tables"; private TableUtils() { throw new UnsupportedOperationException("Cannot instantiate TablesUtils"); @@ -162,6 +167,23 @@ public static Mono> swallowExce return monoError(logger, httpResponseException); } + public static Context setContext(Context context) { + return setContext(context, false); + } + + public static Context setContext(Context context, boolean isSync) { + Context val = context != null ? context : Context.NONE; + return isSync ? enableSyncRestProxy(setTrailingContext(val)) : setTrailingContext(val); + } + + private static Context setTrailingContext(Context context) { + return context.addData(AZ_TRACING_NAMESPACE_KEY, TABLES_TRACING_NAMESPACE_VALUE); + } + + private static Context enableSyncRestProxy(Context context) { + return context.addData(HTTP_REST_PROXY_SYNC_PROXY_ENABLE, true); + } + /** * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is * stored as a parsed array (ex. key=[val1, val2, val3] instead of key=val1,val2,val3). From eab01519848d9f87f0158ca75b8d825748044bcf Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:23:57 -0800 Subject: [PATCH 13/25] Removed unused import --- .../src/main/java/com/azure/data/tables/TableServiceClient.java | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 0251854e341d..c37130f71bbb 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -14,7 +14,6 @@ import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.RestProxy; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.IterableStream; From f324cb6bd5c2ab57ebf38ae341ca981ec14aa497 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 24 Jan 2023 12:06:04 -0800 Subject: [PATCH 14/25] Fixed issues identified by Spotbugs --- .../com/azure/data/tables/TableClient.java | 41 +++++++++---------- .../azure/data/tables/TableServiceClient.java | 25 ++++------- .../tables/implementation/TableUtils.java | 15 ++++--- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index a82bca6a6069..d9ed6c71875f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -238,12 +238,6 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { return new TableSasGenerator(tableSasSignatureValues, getTableName(), azureNamedKeyCredential).getSas(); } - - - private Long setTimeout(Duration timeout) { - return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); - } - /** * Creates the table within the Tables service. * @@ -294,7 +288,7 @@ public Response createTableWithResponse(Duration timeout, Context con Context contextValue = TableUtils.setContext(context, true); final TableProperties properties = new TableProperties().setTableName(tableName); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> createTableOp = () -> new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, null, @@ -361,7 +355,7 @@ public void deleteTable() { public Response deleteTableWithResponse(Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> deleteTableOp = () -> new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( @@ -462,7 +456,7 @@ public void createEntity(TableEntity entity) { public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); @@ -566,7 +560,7 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); @@ -724,7 +718,7 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp boolean ifUnchanged, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); @@ -862,7 +856,7 @@ private Response deleteEntityWithResponse(String partitionKey, String rowK Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); String finalETag = ifUnchanged ? eTag : "*"; @@ -960,7 +954,7 @@ public PagedIterable listEntities() { @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> listEntitiesOp = () -> new PagedIterable<>( () -> listEntitiesFirstPage(context, options, TableEntity.class), @@ -1174,7 +1168,7 @@ public TableEntity getEntity(String partitionKey, String rowKey) { public Response getEntityWithResponse(String partitionKey, String rowKey, List select, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); QueryOptions queryOptions = new QueryOptions() @@ -1285,7 +1279,7 @@ public TableAccessPolicies getAccessPolicies() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); Callable> getAccessPoliciesOp = () -> { @@ -1411,7 +1405,7 @@ public void setAccessPolicies(List tableSignedIdentifiers public Response setAccessPoliciesWithResponse(List tableSignedIdentifiers, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); List signedIdentifiers = null; @@ -1666,7 +1660,7 @@ public TableTransactionResult submitTransaction(List tra @ServiceMethod(returns = ReturnType.SINGLE) public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); if (transactionActions.isEmpty()) { @@ -1742,15 +1736,18 @@ public Response submitTransactionWithResponse(List
createTableWithResponse(String tableName, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableWithResponse(tableName, context); Future> future = scheduler.submit(callable); scheduler.shutdown(); @@ -322,7 +322,7 @@ public TableClient createTableIfNotExists(String tableName) { public Response createTableIfNotExistsWithResponse(String tableName, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableIfNotExistsWithResponse(tableName, context); Future> future = scheduler.submit(callable); scheduler.shutdown(); @@ -345,7 +345,7 @@ Response createTableIfNotExistsWithResponse(String tableName, Conte response.getHeaders(), null); } - throw logger.logThrowableAsError(e); + throw logger.logExceptionAsError(new RuntimeException(e)); } } @@ -404,7 +404,7 @@ public void deleteTable(String tableName) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(String tableName, Duration timeout, Context context) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Future> future = scheduler.submit(() -> deleteTableWithResponse(tableName, context)); scheduler.shutdown(); @@ -419,7 +419,7 @@ public Response deleteTableWithResponse(String tableName, Duration timeout httpResponse.getHeaders(), null); } - throw logger.logExceptionAsError((RuntimeException) exception); + throw logger.logExceptionAsError(new RuntimeException(exception)); } } @@ -483,7 +483,7 @@ public PagedIterable listTables() { @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Future> future = scheduler.submit(() -> listTables(options, context)); scheduler.shutdown(); try { @@ -631,7 +631,7 @@ public TableServiceProperties getProperties() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Future> future = scheduler.submit(() -> getPropertiesWithResponse(context)); scheduler.shutdown(); try { @@ -791,7 +791,7 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ Context context) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Future> future = scheduler.submit(() -> setPropertiesWithResponse(tableServiceProperties, context)); scheduler.shutdown(); try { @@ -925,7 +925,7 @@ public TableServiceStatistics getStatistics() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getStatisticsWithResponse(Duration timeout, Context context) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - long timeoutInMillis = setTimeout(timeout); + long timeoutInMillis = TableUtils.setTimeout(timeout); Future> future = scheduler.submit(() -> getStatisticsWithResponse(context)); scheduler.shutdown(); try { @@ -961,11 +961,4 @@ private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication g TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), geoReplication.getLastSyncTime()); } - private Long setTimeout(Duration timeout) { - return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); - } - - private Context enableSyncRestProxy(Context context) { - return context.addData("HTTP_REST_PROXY_SYNC_PROXY_ENABLE", true); - } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 918d92cdabcb..93645114b203 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -97,12 +97,13 @@ public static TableServiceException toTableServiceException(TableServiceErrorExc public static Throwable mapThrowableToTableServiceException(Throwable throwable) { if (throwable instanceof TableServiceErrorException) { return toTableServiceException((TableServiceErrorException) throwable); - } else if (throwable.getCause() instanceof TableServiceErrorException) { - return toTableServiceException((TableServiceErrorException) throwable.getCause()); - } - else { - return throwable; + } else if (throwable.getCause() instanceof Exception) { + Throwable cause = throwable.getCause(); + if (cause instanceof TableServiceErrorException) { + return toTableServiceException((TableServiceErrorException) cause); + } } + return throwable; } /** @@ -184,6 +185,10 @@ private static Context enableSyncRestProxy(Context context) { return context.addData(HTTP_REST_PROXY_SYNC_PROXY_ENABLE, true); } + public static Long setTimeout(Duration timeout) { + return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); + } + /** * Parses the query string into a key-value pair map that maintains key, query parameter key, order. The value is * stored as a parsed array (ex. key=[val1, val2, val3] instead of key=val1,val2,val3). From 582a70ebeb6d3887064e205621ef625ee0d5f083 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 24 Jan 2023 12:23:02 -0800 Subject: [PATCH 15/25] Bug fixes --- .../main/java/com/azure/data/tables/TableClient.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index d9ed6c71875f..1b773a68d288 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -1735,18 +1735,16 @@ public Response submitTransactionWithResponse(List
Date: Tue, 24 Jan 2023 12:42:50 -0800 Subject: [PATCH 16/25] Checkstyle fixes --- .../com/azure/data/tables/TableClient.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 1b773a68d288..9e683362370d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -1733,19 +1733,23 @@ public Response submitTransactionWithResponse(List
Date: Mon, 30 Jan 2023 11:34:30 -0800 Subject: [PATCH 17/25] Added Asserting Clients --- .../java/com/azure/data/tables/TableAsyncClientTest.java | 9 +++++++++ .../test/java/com/azure/data/tables/TableClientTest.java | 9 +++++++++ .../java/com/azure/data/tables/TableClientTestBase.java | 5 +++-- .../azure/data/tables/TableServiceAsyncClientTest.java | 8 ++++++++ .../com/azure/data/tables/TableServiceClientTest.java | 8 ++++++++ .../azure/data/tables/TableServiceClientTestBase.java | 4 +++- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java index 8e08b9c16f5b..09a0c17490ad 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableAsyncClientTest.java @@ -3,11 +3,13 @@ package com.azure.data.tables; +import com.azure.core.http.HttpClient; import com.azure.core.http.policy.ExponentialBackoff; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.rest.Response; +import com.azure.core.test.http.AssertingHttpClientBuilder; import com.azure.core.test.utils.TestResourceNamer; import com.azure.core.util.Configuration; import com.azure.data.tables.models.ListEntitiesOptions; @@ -58,6 +60,13 @@ public class TableAsyncClientTest extends TableClientTestBase { private TableAsyncClient tableClient; + protected HttpClient buildAssertingClient(HttpClient httpClient) { + return new AssertingHttpClientBuilder(httpClient) + .skipRequest((ignored1, ignored2) -> false) + .assertAsync() + .build(); + } + @BeforeAll static void beforeAll() { StepVerifier.setDefaultTimeout(TIMEOUT); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java index 5ec4ad85a98e..2e5b7072158c 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTest.java @@ -3,12 +3,14 @@ package com.azure.data.tables; +import com.azure.core.http.HttpClient; import com.azure.core.http.policy.ExponentialBackoff; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.test.http.AssertingHttpClientBuilder; import com.azure.core.test.utils.TestResourceNamer; import com.azure.core.util.Configuration; import com.azure.data.tables.models.ListEntitiesOptions; @@ -57,6 +59,13 @@ public class TableClientTest extends TableClientTestBase { private TableClient tableClient; + protected HttpClient buildAssertingClient(HttpClient httpClient) { + return new AssertingHttpClientBuilder(httpClient) + .skipRequest((ignored1, ignored2) -> false) + .assertSync() + .build(); + } + protected void beforeTest() { final String tableName = testResourceNamer.randomName("tableName", 20); final String connectionString = TestUtils.getConnectionString(interceptorManager.isPlaybackMode()); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java index cdab36e22c27..3ab9b2098fa8 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java @@ -18,6 +18,8 @@ public abstract class TableClientTestBase extends TestBase { protected HttpPipelinePolicy recordPolicy; protected HttpClient playbackClient; + protected abstract HttpClient buildAssertingClient(HttpClient httpClient); + protected TableClientBuilder getClientBuilder(String tableName, String connectionString) { final TableClientBuilder tableClientBuilder = new TableClientBuilder() .connectionString(connectionString); @@ -48,11 +50,10 @@ private TableClientBuilder configureTestClientBuilder(TableClientBuilder tableCl tableClientBuilder.httpClient(playbackClient); } else { - tableClientBuilder.httpClient(DEFAULT_HTTP_CLIENT); + tableClientBuilder.httpClient(buildAssertingClient(DEFAULT_HTTP_CLIENT)); if (!interceptorManager.isLiveMode()) { recordPolicy = interceptorManager.getRecordPolicy(); - tableClientBuilder.addPolicy(recordPolicy); } } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java index db462d303ac0..21291294669c 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java @@ -8,6 +8,7 @@ import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.test.http.AssertingHttpClientBuilder; import com.azure.core.util.Configuration; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableEntity; @@ -58,6 +59,13 @@ public class TableServiceAsyncClientTest extends TableServiceClientTestBase { private TableServiceAsyncClient serviceClient; + protected HttpClient buildAssertingClient(HttpClient httpClient) { + return new AssertingHttpClientBuilder(httpClient) + .skipRequest((ignored1, ignored2) -> false) + .assertAsync() + .build(); + } + @BeforeAll static void beforeAll() { StepVerifier.setDefaultTimeout(TIMEOUT); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java index b933b6e0efa7..ba55784fa68b 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java @@ -10,6 +10,7 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.test.http.AssertingHttpClientBuilder; import com.azure.core.util.Configuration; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableEntity; @@ -61,6 +62,13 @@ public class TableServiceClientTest extends TableServiceClientTestBase { private TableServiceClient serviceClient; + protected HttpClient buildAssertingClient(HttpClient httpClient) { + return new AssertingHttpClientBuilder(httpClient) + .skipRequest((ignored1, ignored2) -> false) + .assertSync() + .build(); + } + @Override protected void beforeTest() { final String connectionString = TestUtils.getConnectionString(interceptorManager.isPlaybackMode()); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java index 0d5f06b2029a..a4a0184671dc 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java @@ -19,6 +19,8 @@ public abstract class TableServiceClientTestBase extends TestBase { protected HttpPipelinePolicy recordPolicy; protected HttpClient playbackClient; + protected abstract HttpClient buildAssertingClient(HttpClient httpClient); + protected TableServiceClientBuilder getClientBuilder(String connectionString) { final TableServiceClientBuilder tableServiceClientBuilder = new TableServiceClientBuilder() .connectionString(connectionString); @@ -48,7 +50,7 @@ private TableServiceClientBuilder configureTestClientBuilder(TableServiceClientB tableServiceClientBuilder.httpClient(playbackClient); } else { - tableServiceClientBuilder.httpClient(DEFAULT_HTTP_CLIENT); + tableServiceClientBuilder.httpClient(buildAssertingClient(DEFAULT_HTTP_CLIENT)); if (!interceptorManager.isLiveMode()) { recordPolicy = interceptorManager.getRecordPolicy(); From 13c067e4c8fbb0f96ace46b7acf081f9595fd1f0 Mon Sep 17 00:00:00 2001 From: Jair Myree <67484440+jairmyree@users.noreply.github.com> Date: Wed, 1 Feb 2023 20:19:21 +0000 Subject: [PATCH 18/25] Add asserting client to clients used for playback --- .../test/java/com/azure/data/tables/TableClientTestBase.java | 2 +- .../java/com/azure/data/tables/TableServiceClientTestBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java index 3ab9b2098fa8..869b437becd9 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java @@ -48,7 +48,7 @@ private TableClientBuilder configureTestClientBuilder(TableClientBuilder tableCl if (interceptorManager.isPlaybackMode()) { playbackClient = interceptorManager.getPlaybackClient(); - tableClientBuilder.httpClient(playbackClient); + tableClientBuilder.httpClient(buildAssertingClient(playbackClient)); } else { tableClientBuilder.httpClient(buildAssertingClient(DEFAULT_HTTP_CLIENT)); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java index a4a0184671dc..f66da1d6bbee 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTestBase.java @@ -48,7 +48,7 @@ private TableServiceClientBuilder configureTestClientBuilder(TableServiceClientB if (interceptorManager.isPlaybackMode()) { playbackClient = interceptorManager.getPlaybackClient(); - tableServiceClientBuilder.httpClient(playbackClient); + tableServiceClientBuilder.httpClient(buildAssertingClient(playbackClient)); } else { tableServiceClientBuilder.httpClient(buildAssertingClient(DEFAULT_HTTP_CLIENT)); From f92f51e4540b318b34d10b7d169ae23600bfd65f Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 14 Feb 2023 14:29:26 -0800 Subject: [PATCH 19/25] Replaced method threads with a static Thread Pool --- .../com/azure/data/tables/TableClient.java | 81 +++---------------- .../azure/data/tables/TableServiceClient.java | 41 +++------- .../tables/implementation/TableUtils.java | 28 +++++++ 3 files changed, 50 insertions(+), 100 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 9e683362370d..a0d74bda6802 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -67,9 +67,7 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.stream.Collectors; @@ -106,6 +104,7 @@ @ServiceClient(builder = TableClientBuilder.class) public final class TableClient { + private static final ExecutorService THREAD_POOL = TableUtils.getThreadPoolWithShutdownHook(); private static final String DELIMITER_CONTINUATION_TOKEN = ";"; private final ClientLogger logger = new ClientLogger(TableClient.class); private final String tableName; @@ -287,7 +286,6 @@ public TableItem createTable() { public Response createTableWithResponse(Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final TableProperties properties = new TableProperties().setTableName(tableName); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> createTableOp = () -> new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, @@ -295,16 +293,11 @@ public Response createTableWithResponse(Duration timeout, Context con ResponseFormat.RETURN_NO_CONTENT, null, contextValue), ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); - ScheduledFuture> scheduledFuture = - scheduler.schedule(createTableOp, IMMEDIATELY, TimeUnit.SECONDS); - //scheduler.shutdown(); try { - Response response = scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); - scheduler.shutdown(); + Response response = THREAD_POOL.submit(createTableOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); return response; } catch (Exception ex) { - scheduler.shutdown(); throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } } @@ -354,7 +347,6 @@ public void deleteTable() { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> deleteTableOp = () -> @@ -362,12 +354,8 @@ public Response deleteTableWithResponse(Duration timeout, Context context) tableName, null, contextValue), null); - ScheduledFuture> scheduledFuture = - scheduler.schedule(deleteTableOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(deleteTableOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { Throwable except = mapThrowableToTableServiceException(ex); return swallow404Exception(except); @@ -455,7 +443,6 @@ public void createEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { @@ -470,12 +457,8 @@ public Response createEntityWithResponse(TableEntity entity, Duration time return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null); }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(createEntityOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(createEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -559,7 +542,6 @@ public void upsertEntity(TableEntity entity) { public Response upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { @@ -583,11 +565,8 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp } }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(upsertEntityOp, IMMEDIATELY, TimeUnit.SECONDS); - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(upsertEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -717,7 +696,6 @@ public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { public Response updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { @@ -742,12 +720,8 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp } }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(updateEntityOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(updateEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -855,7 +829,6 @@ public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnc private Response deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); String finalETag = ifUnchanged ? eTag : "*"; @@ -868,11 +841,8 @@ private Response deleteEntityWithResponse(String partitionKey, String rowK tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalETag, null, null, null, contextValue); - ScheduledFuture> scheduledFuture = scheduler.schedule(deleteEntityOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(deleteEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { Throwable except = mapThrowableToTableServiceException(ex); return swallow404Exception(except); @@ -953,19 +923,14 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> listEntitiesOp = () -> new PagedIterable<>( () -> listEntitiesFirstPage(context, options, TableEntity.class), token -> listEntitiesNextPage(token, context, options, TableEntity.class)); - ScheduledFuture> scheduledFuture = - scheduler.schedule(listEntitiesOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(listEntitiesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1167,7 +1132,6 @@ public TableEntity getEntity(String partitionKey, String rowKey) { @ServiceMethod(returns = ReturnType.SINGLE) public Response getEntityWithResponse(String partitionKey, String rowKey, List select, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); @@ -1202,12 +1166,9 @@ tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, n EntityHelper.convertToSubclass(entity, TableEntity.class, logger)); }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(getEntityOp, IMMEDIATELY, TimeUnit.SECONDS); - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(getEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1278,7 +1239,6 @@ public TableAccessPolicies getAccessPolicies() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); @@ -1293,12 +1253,8 @@ public Response getAccessPoliciesWithResponse(Duration time .collect(Collectors.toList()))); }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(getAccessPoliciesOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(getAccessPoliciesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1404,7 +1360,6 @@ public void setAccessPolicies(List tableSignedIdentifiers @ServiceMethod(returns = ReturnType.SINGLE) public Response setAccessPoliciesWithResponse(List tableSignedIdentifiers, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); List signedIdentifiers = null; @@ -1445,12 +1400,8 @@ public Response setAccessPoliciesWithResponse(List return new SimpleResponse<>(response, response.getValue()); }; - ScheduledFuture> scheduledFuture = - scheduler.schedule(setAccessPoliciesOp, IMMEDIATELY, TimeUnit.SECONDS); - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(setAccessPoliciesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1659,7 +1610,6 @@ public TableTransactionResult submitTransaction(List tra */ @ServiceMethod(returns = ReturnType.SINGLE) public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); @@ -1726,13 +1676,8 @@ public Response submitTransactionWithResponse(List
> scheduledFuture = - scheduler.schedule(submitTransactionOp, IMMEDIATELY, TimeUnit.SECONDS); - - - scheduler.shutdown(); try { - return scheduledFuture.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(submitTransactionOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) interpretException(ex)); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index ceef91d838e0..05ddf4e2aefe 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -55,9 +55,7 @@ import java.time.Duration; import java.util.List; import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -87,6 +85,7 @@ @ServiceClient(builder = TableServiceClientBuilder.class) public final class TableServiceClient { + private static final ExecutorService THREAD_POOL = TableUtils.getThreadPoolWithShutdownHook(); private final ClientLogger logger = new ClientLogger(TableServiceClient.class); private final AzureTableImpl implementation; private final String accountName; @@ -247,13 +246,10 @@ public TableClient createTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(String tableName, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableWithResponse(tableName, context); - Future> future = scheduler.submit(callable); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(callable).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } @@ -321,13 +317,10 @@ public TableClient createTableIfNotExists(String tableName) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableIfNotExistsWithResponse(String tableName, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableIfNotExistsWithResponse(tableName, context); - Future> future = scheduler.submit(callable); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(callable).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -403,13 +396,9 @@ public void deleteTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(String tableName, Duration timeout, Context context) { - final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); - Future> future = - scheduler.submit(() -> deleteTableWithResponse(tableName, context)); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(() -> deleteTableWithResponse(tableName, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { Exception exception = (Exception) TableUtils.mapThrowableToTableServiceException(e); if (exception instanceof TableServiceException @@ -482,12 +471,9 @@ public PagedIterable listTables() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); - Future> future = scheduler.submit(() -> listTables(options, context)); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(() -> listTables(options, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -630,12 +616,9 @@ public TableServiceProperties getProperties() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); - Future> future = scheduler.submit(() -> getPropertiesWithResponse(context)); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(() -> getPropertiesWithResponse(context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } @@ -790,12 +773,9 @@ public void setProperties(TableServiceProperties tableServiceProperties) { public Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Duration timeout, Context context) { - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); - Future> future = scheduler.submit(() -> setPropertiesWithResponse(tableServiceProperties, context)); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(() -> setPropertiesWithResponse(tableServiceProperties, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -924,12 +904,9 @@ public TableServiceStatistics getStatistics() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getStatisticsWithResponse(Duration timeout, Context context) { - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); long timeoutInMillis = TableUtils.setTimeout(timeout); - Future> future = scheduler.submit(() -> getStatisticsWithResponse(context)); - scheduler.shutdown(); try { - return future.get(timeoutInMillis, TimeUnit.MILLISECONDS); + return THREAD_POOL.submit(() -> getStatisticsWithResponse(context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 93645114b203..1a0e108464a2 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -24,6 +24,9 @@ import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import static com.azure.core.util.FluxUtil.monoError; @@ -36,6 +39,7 @@ public final class TableUtils { private static final String UTF8_CHARSET = "UTF-8"; private static final String HTTP_REST_PROXY_SYNC_PROXY_ENABLE = "com.azure.core.http.restproxy.syncproxy.enable"; private static final String TABLES_TRACING_NAMESPACE_VALUE = "Microsoft.Tables"; + private static final long THREADPOOL_SHUTDOWN_HOOK_TIMEOUT_SECINDS = 5; private TableUtils() { throw new UnsupportedOperationException("Cannot instantiate TablesUtils"); @@ -335,4 +339,28 @@ private static String encode(final String stringToEncode) { throw new RuntimeException(ex); } } + + public static ExecutorService getThreadPoolWithShutdownHook() { + ExecutorService threadPool = Executors.newCachedThreadPool(); + registerShutdownHook(threadPool); + return threadPool; + } + + static Thread registerShutdownHook(ExecutorService threadPool) { + long halfTimeout = TimeUnit.SECONDS.toNanos(THREADPOOL_SHUTDOWN_HOOK_TIMEOUT_SECINDS) / 2; + Thread hook = new Thread(() -> { + try { + threadPool.shutdown(); + if (!threadPool.awaitTermination(halfTimeout, TimeUnit.NANOSECONDS)) { + threadPool.shutdownNow(); + threadPool.awaitTermination(halfTimeout, TimeUnit.NANOSECONDS); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + threadPool.shutdown(); + } + }); + Runtime.getRuntime().addShutdownHook(hook); + return hook; + } } From 988b0263af3b826444c3ccbf298eba70311761dc Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:09:08 -0800 Subject: [PATCH 20/25] Tables Refactoring --- .../azure/data/tables/TableAsyncClient.java | 115 +-------- .../com/azure/data/tables/TableClient.java | 132 +--------- .../data/tables/TableServiceAsyncClient.java | 190 +------------- .../azure/data/tables/TableServiceClient.java | 190 +------------- .../tables/implementation/EntityPaged.java | 62 +++++ .../tables/implementation/TablePaged.java | 55 ++++ .../tables/implementation/TableUtils.java | 240 +++++++++++++++++- 7 files changed, 384 insertions(+), 600 deletions(-) create mode 100644 sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java create mode 100644 sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablePaged.java diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index 0e6953d6027d..a9c92b1f696f 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -22,6 +22,7 @@ import com.azure.core.util.serializer.SerializerAdapter; import com.azure.data.tables.implementation.AzureTableImpl; import com.azure.data.tables.implementation.AzureTableImplBuilder; +import com.azure.data.tables.implementation.EntityPaged; import com.azure.data.tables.implementation.ModelHelper; import com.azure.data.tables.implementation.TableSasGenerator; import com.azure.data.tables.implementation.TableSasUtils; @@ -539,8 +540,8 @@ Mono> upsertEntityWithResponse(TableEntity entity, TableEntityUpd return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); } - String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); - String rowKey = escapeSingleQuotes(entity.getRowKey()); + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); EntityHelper.setPropertiesFromGetters(entity, logger); @@ -706,8 +707,8 @@ Mono> updateEntityWithResponse(TableEntity entity, TableEntityUpd return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); } - String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); - String rowKey = escapeSingleQuotes(entity.getRowKey()); + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); String eTag = ifUnchanged ? entity.getETag() : "*"; EntityHelper.setPropertiesFromGetters(entity, logger); @@ -849,7 +850,7 @@ Mono> deleteEntityWithResponse(String partitionKey, String rowKey try { return tablesImplementation.getTables().deleteEntityWithResponseAsync(tableName, - escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), eTag, null, null, null, context) + TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), eTag, null, null, null, context) .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> (Response) new SimpleResponse(response, null)) .onErrorResume(TableServiceException.class, e -> swallowExceptionForStatusCode(404, e, logger)); @@ -1012,53 +1013,6 @@ private Mono> listEntities(String nextP } } - private static class EntityPaged implements PagedResponse { - private final Response httpResponse; - private final IterableStream entityStream; - private final String continuationToken; - - EntityPaged(Response httpResponse, List entityList, - String nextPartitionKey, String nextRowKey) { - if (nextPartitionKey == null || nextRowKey == null) { - this.continuationToken = null; - } else { - this.continuationToken = String.join(DELIMITER_CONTINUATION_TOKEN, nextPartitionKey, nextRowKey); - } - - this.httpResponse = httpResponse; - this.entityStream = IterableStream.of(entityList); - } - - @Override - public int getStatusCode() { - return httpResponse.getStatusCode(); - } - - @Override - public HttpHeaders getHeaders() { - return httpResponse.getHeaders(); - } - - @Override - public HttpRequest getRequest() { - return httpResponse.getRequest(); - } - - @Override - public IterableStream getElements() { - return entityStream; - } - - @Override - public String getContinuationToken() { - return continuationToken; - } - - @Override - public void close() { - } - } - /** * Gets a single {@link TableEntity entity} from the table. * @@ -1157,7 +1111,7 @@ Mono> getEntityWithResponse(String partition try { return tablesImplementation.getTables().queryEntityWithPartitionAndRowKeyWithResponseAsync(tableName, - escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, null, queryOptions, context) + TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), null, null, queryOptions, context) .onErrorMap(TableUtils::mapThrowableToTableServiceException) .handle((response, sink) -> { final Map matchingEntity = response.getValue(); @@ -1257,33 +1211,13 @@ Mono> getAccessPoliciesWithResponse(Context contex .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, new TableAccessPolicies(response.getValue() == null ? null : response.getValue().stream() - .map(this::toTableSignedIdentifier) + .map(TableUtils::toTableSignedIdentifier) .collect(Collectors.toList())))); } catch (RuntimeException e) { return monoError(logger, e); } } - private TableSignedIdentifier toTableSignedIdentifier(SignedIdentifier signedIdentifier) { - if (signedIdentifier == null) { - return null; - } - - return new TableSignedIdentifier(signedIdentifier.getId()) - .setAccessPolicy(toTableAccessPolicy(signedIdentifier.getAccessPolicy())); - } - - private TableAccessPolicy toTableAccessPolicy(AccessPolicy accessPolicy) { - if (accessPolicy == null) { - return null; - } - - return new TableAccessPolicy() - .setExpiresOn(accessPolicy.getExpiry()) - .setStartsOn(accessPolicy.getStart()) - .setPermissions(accessPolicy.getPermission()); - } - /** * Sets stored {@link TableAccessPolicies access policies} for the table that may be used with Shared Access * Signatures. @@ -1381,7 +1315,7 @@ OffsetDateTime.now will only give back milliseconds (more precise fields are zer if (tableSignedIdentifiers != null) { signedIdentifiers = tableSignedIdentifiers.stream() .map(tableSignedIdentifier -> { - SignedIdentifier signedIdentifier = toSignedIdentifier(tableSignedIdentifier); + SignedIdentifier signedIdentifier = TableUtils.toSignedIdentifier(tableSignedIdentifier); if (signedIdentifier != null) { if (signedIdentifier.getAccessPolicy() != null @@ -1416,27 +1350,6 @@ OffsetDateTime.now will only give back milliseconds (more precise fields are zer } } - private SignedIdentifier toSignedIdentifier(TableSignedIdentifier tableSignedIdentifier) { - if (tableSignedIdentifier == null) { - return null; - } - - return new SignedIdentifier() - .setId(tableSignedIdentifier.getId()) - .setAccessPolicy(toAccessPolicy(tableSignedIdentifier.getAccessPolicy())); - } - - private AccessPolicy toAccessPolicy(TableAccessPolicy tableAccessPolicy) { - if (tableAccessPolicy == null) { - return null; - } - - return new AccessPolicy() - .setExpiry(tableAccessPolicy.getExpiresOn()) - .setStart(tableAccessPolicy.getStartsOn()) - .setPermission(tableAccessPolicy.getPermissions()); - } - /** * Executes all {@link TableTransactionAction actions} within the list inside a transaction. When the call * completes, either all {@link TableTransactionAction actions} in the transaction will succeed, or if a failure @@ -1751,14 +1664,4 @@ private Mono>> parseResponse(Trans return Mono.just(new SimpleResponse<>(response, Arrays.asList(response.getValue()))); } } - - // Single quotes in OData queries should be escaped by using two consecutive single quotes characters. - // Source: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLSyntax. - private String escapeSingleQuotes(String input) { - if (input == null) { - return null; - } - - return input.replace("'", "''"); - } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index a0d74bda6802..c880817aabea 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -21,6 +21,7 @@ import com.azure.core.util.serializer.SerializerAdapter; import com.azure.data.tables.implementation.AzureTableImpl; import com.azure.data.tables.implementation.AzureTableImplBuilder; +import com.azure.data.tables.implementation.EntityPaged; import com.azure.data.tables.implementation.ModelHelper; import com.azure.data.tables.implementation.TableSasGenerator; import com.azure.data.tables.implementation.TableSasUtils; @@ -115,8 +116,6 @@ public final class TableClient { private final HttpPipeline pipeline; private final TableClient transactionalBatchClient; - private static final int IMMEDIATELY = -1; - TableClient(String tableName, HttpPipeline pipeline, String serviceUrl, TableServiceVersion serviceVersion, SerializerAdapter tablesSerializer, SerializerAdapter transactionalBatchSerializer) { try { @@ -548,8 +547,8 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); } - String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); - String rowKey = escapeSingleQuotes(entity.getRowKey()); + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); EntityHelper.setPropertiesFromGetters(entity, logger); @@ -702,8 +701,8 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); } - String partitionKey = escapeSingleQuotes(entity.getPartitionKey()); - String rowKey = escapeSingleQuotes(entity.getRowKey()); + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); String eTag = ifUnchanged ? entity.getETag() : "*"; EntityHelper.setPropertiesFromGetters(entity, logger); @@ -838,7 +837,7 @@ private Response deleteEntityWithResponse(String partitionKey, String rowK } Callable> deleteEntityOp = () -> tablesImplementation.getTables().deleteEntityWithResponse( - tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), finalETag, null, + tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), finalETag, null, null, null, contextValue); try { @@ -1005,53 +1004,6 @@ private PagedResponse listEntities(String nextPartiti response.getDeserializedHeaders().getXMsContinuationNextRowKey()); } - private static class EntityPaged implements PagedResponse { - private final Response httpResponse; - private final IterableStream entityStream; - private final String continuationToken; - - EntityPaged(Response httpResponse, List entityList, - String nextPartitionKey, String nextRowKey) { - if (nextPartitionKey == null || nextRowKey == null) { - this.continuationToken = null; - } else { - this.continuationToken = String.join(DELIMITER_CONTINUATION_TOKEN, nextPartitionKey, nextRowKey); - } - - this.httpResponse = httpResponse; - this.entityStream = IterableStream.of(entityList); - } - - @Override - public int getStatusCode() { - return httpResponse.getStatusCode(); - } - - @Override - public HttpHeaders getHeaders() { - return httpResponse.getHeaders(); - } - - @Override - public HttpRequest getRequest() { - return httpResponse.getRequest(); - } - - @Override - public IterableStream getElements() { - return entityStream; - } - - @Override - public String getContinuationToken() { - return continuationToken; - } - - @Override - public void close() { - } - } - /** * Gets a single {@link TableEntity entity} from the table. * @@ -1150,7 +1102,7 @@ public Response getEntityWithResponse(String partitionKey, String r Callable> getEntityOp = () -> { ResponseBase> response = tablesImplementation.getTables().queryEntityWithPartitionAndRowKeyWithResponse( - tableName, escapeSingleQuotes(partitionKey), escapeSingleQuotes(rowKey), null, null, + tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), null, null, queryOptions, contextValue); final Map matchingEntity = response.getValue(); @@ -1249,7 +1201,7 @@ public Response getAccessPoliciesWithResponse(Duration time ); return new SimpleResponse<>(response, new TableAccessPolicies(response.getValue() == null ? null : response.getValue().stream() - .map(this::toTableSignedIdentifier) + .map(TableUtils::toTableSignedIdentifier) .collect(Collectors.toList()))); }; @@ -1260,25 +1212,7 @@ public Response getAccessPoliciesWithResponse(Duration time } } - private TableSignedIdentifier toTableSignedIdentifier(SignedIdentifier signedIdentifier) { - if (signedIdentifier == null) { - return null; - } - - return new TableSignedIdentifier(signedIdentifier.getId()) - .setAccessPolicy(toTableAccessPolicy(signedIdentifier.getAccessPolicy())); - } - - private TableAccessPolicy toTableAccessPolicy(AccessPolicy accessPolicy) { - if (accessPolicy == null) { - return null; - } - - return new TableAccessPolicy() - .setExpiresOn(accessPolicy.getExpiry()) - .setStartsOn(accessPolicy.getStart()) - .setPermissions(accessPolicy.getPermission()); - } + /** * Sets stored {@link TableAccessPolicies access policies} for the table that may be used with Shared Access * Signatures. @@ -1367,7 +1301,7 @@ public Response setAccessPoliciesWithResponse(List if (tableSignedIdentifiers != null) { signedIdentifiers = tableSignedIdentifiers.stream() .map(tableSignedIdentifier -> { - SignedIdentifier signedIdentifier = toSignedIdentifier(tableSignedIdentifier); + SignedIdentifier signedIdentifier = TableUtils.toSignedIdentifier(tableSignedIdentifier); if (signedIdentifier != null) { if (signedIdentifier.getAccessPolicy() != null @@ -1407,26 +1341,6 @@ public Response setAccessPoliciesWithResponse(List } } - private SignedIdentifier toSignedIdentifier(TableSignedIdentifier tableSignedIdentifier) { - if (tableSignedIdentifier == null) { - return null; - } - - return new SignedIdentifier() - .setId(tableSignedIdentifier.getId()) - .setAccessPolicy(toAccessPolicy(tableSignedIdentifier.getAccessPolicy())); - } - - private AccessPolicy toAccessPolicy(TableAccessPolicy tableAccessPolicy) { - if (tableAccessPolicy == null) { - return null; - } - - return new AccessPolicy() - .setExpiry(tableAccessPolicy.getExpiresOn()) - .setStart(tableAccessPolicy.getStartsOn()) - .setPermission(tableAccessPolicy.getPermissions()); - } /** * Executes all {@link TableTransactionAction actions} within the list inside a transaction. When the call @@ -1680,21 +1594,7 @@ public Response submitTransactionWithResponse(List
> parseResponse(Transaction return new SimpleResponse<>(response, Arrays.asList(response.getValue())); } } - - // Single quotes in OData queries should be escaped by using two consecutive single quotes characters. - // Source: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLSyntax. - private String escapeSingleQuotes(String input) { - if (input == null) { - return null; - } - - return input.replace("'", "''"); - } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java index 4d16a5aade6e..4dc98c13d308 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java @@ -23,6 +23,7 @@ import com.azure.data.tables.implementation.AzureTableImplBuilder; import com.azure.data.tables.implementation.ModelHelper; import com.azure.data.tables.implementation.TableAccountSasGenerator; +import com.azure.data.tables.implementation.TablePaged; import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; import com.azure.data.tables.implementation.models.CorsRule; @@ -522,47 +523,6 @@ private Mono> listTables(String nextTableName, Context } } - private static class TablePaged implements PagedResponse { - private final Response httpResponse; - private final IterableStream tableStream; - private final String continuationToken; - - TablePaged(Response httpResponse, List tableList, String continuationToken) { - this.httpResponse = httpResponse; - this.tableStream = IterableStream.of(tableList); - this.continuationToken = continuationToken; - } - - @Override - public int getStatusCode() { - return httpResponse.getStatusCode(); - } - - @Override - public HttpHeaders getHeaders() { - return httpResponse.getHeaders(); - } - - @Override - public HttpRequest getRequest() { - return httpResponse.getRequest(); - } - - @Override - public IterableStream getElements() { - return tableStream; - } - - @Override - public String getContinuationToken() { - return continuationToken; - } - - @Override - public void close() { - } - } - /** * Gets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -623,77 +583,12 @@ Mono> getPropertiesWithResponse(Context context try { return this.implementation.getServices().getPropertiesWithResponseAsync(null, null, context) .onErrorMap(TableUtils::mapThrowableToTableServiceException) - .map(response -> new SimpleResponse<>(response, toTableServiceProperties(response.getValue()))); + .map(response -> new SimpleResponse<>(response, TableUtils.toTableServiceProperties(response.getValue()))); } catch (RuntimeException e) { return monoError(logger, e); } } - private TableServiceProperties toTableServiceProperties( - com.azure.data.tables.implementation.models.TableServiceProperties tableServiceProperties) { - - if (tableServiceProperties == null) { - return null; - } - - return new TableServiceProperties() - .setLogging(toTableServiceLogging(tableServiceProperties.getLogging())) - .setHourMetrics(toTableServiceMetrics(tableServiceProperties.getHourMetrics())) - .setMinuteMetrics(toTableServiceMetrics(tableServiceProperties.getMinuteMetrics())) - .setCorsRules(tableServiceProperties.getCors() == null ? null - : tableServiceProperties.getCors().stream() - .map(this::toTablesServiceCorsRule) - .collect(Collectors.toList())); - } - - private TableServiceLogging toTableServiceLogging(Logging logging) { - if (logging == null) { - return null; - } - - return new TableServiceLogging() - .setAnalyticsVersion(logging.getVersion()) - .setDeleteLogged(logging.isDelete()) - .setReadLogged(logging.isRead()) - .setWriteLogged(logging.isWrite()) - .setRetentionPolicy(toTableServiceRetentionPolicy(logging.getRetentionPolicy())); - } - - private TableServiceRetentionPolicy toTableServiceRetentionPolicy(RetentionPolicy retentionPolicy) { - if (retentionPolicy == null) { - return null; - } - - return new TableServiceRetentionPolicy() - .setEnabled(retentionPolicy.isEnabled()) - .setDaysToRetain(retentionPolicy.getDays()); - } - - private TableServiceMetrics toTableServiceMetrics(Metrics metrics) { - if (metrics == null) { - return null; - } - - return new TableServiceMetrics() - .setVersion(metrics.getVersion()) - .setEnabled(metrics.isEnabled()) - .setIncludeApis(metrics.isIncludeAPIs()) - .setRetentionPolicy(toTableServiceRetentionPolicy(metrics.getRetentionPolicy())); - } - - private TableServiceCorsRule toTablesServiceCorsRule(CorsRule corsRule) { - if (corsRule == null) { - return null; - } - - return new TableServiceCorsRule() - .setAllowedOrigins(corsRule.getAllowedOrigins()) - .setAllowedMethods(corsRule.getAllowedMethods()) - .setAllowedHeaders(corsRule.getAllowedHeaders()) - .setExposedHeaders(corsRule.getExposedHeaders()) - .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); - } - /** * Sets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -779,7 +674,7 @@ Mono> setPropertiesWithResponse(TableServiceProperties tableServi try { return this.implementation.getServices() - .setPropertiesWithResponseAsync(toImplTableServiceProperties(tableServiceProperties), null, null, + .setPropertiesWithResponseAsync(TableUtils.toImplTableServiceProperties(tableServiceProperties), null, null, context) .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, null)); @@ -788,66 +683,6 @@ Mono> setPropertiesWithResponse(TableServiceProperties tableServi } } - private com.azure.data.tables.implementation.models.TableServiceProperties toImplTableServiceProperties( - TableServiceProperties tableServiceProperties) { - - return new com.azure.data.tables.implementation.models.TableServiceProperties() - .setLogging(toLogging(tableServiceProperties.getLogging())) - .setHourMetrics(toMetrics(tableServiceProperties.getHourMetrics())) - .setMinuteMetrics(toMetrics(tableServiceProperties.getMinuteMetrics())) - .setCors(tableServiceProperties.getCorsRules() == null ? null - : tableServiceProperties.getCorsRules().stream() - .map(this::toCorsRule) - .collect(Collectors.toList())); - } - - private Logging toLogging(TableServiceLogging tableServiceLogging) { - if (tableServiceLogging == null) { - return null; - } - - return new Logging() - .setVersion(tableServiceLogging.getAnalyticsVersion()) - .setDelete(tableServiceLogging.isDeleteLogged()) - .setRead(tableServiceLogging.isReadLogged()) - .setWrite(tableServiceLogging.isWriteLogged()) - .setRetentionPolicy(toRetentionPolicy(tableServiceLogging.getRetentionPolicy())); - } - - private RetentionPolicy toRetentionPolicy(TableServiceRetentionPolicy tableServiceRetentionPolicy) { - if (tableServiceRetentionPolicy == null) { - return null; - } - - return new RetentionPolicy() - .setEnabled(tableServiceRetentionPolicy.isEnabled()) - .setDays(tableServiceRetentionPolicy.getDaysToRetain()); - } - - private Metrics toMetrics(TableServiceMetrics tableServiceMetrics) { - if (tableServiceMetrics == null) { - return null; - } - - return new Metrics() - .setVersion(tableServiceMetrics.getVersion()) - .setEnabled(tableServiceMetrics.isEnabled()) - .setIncludeAPIs(tableServiceMetrics.isIncludeApis()) - .setRetentionPolicy(toRetentionPolicy(tableServiceMetrics.getTableServiceRetentionPolicy())); - } - - private CorsRule toCorsRule(TableServiceCorsRule corsRule) { - if (corsRule == null) { - return null; - } - - return new CorsRule() - .setAllowedOrigins(corsRule.getAllowedOrigins()) - .setAllowedMethods(corsRule.getAllowedMethods()) - .setAllowedHeaders(corsRule.getAllowedHeaders()) - .setExposedHeaders(corsRule.getExposedHeaders()) - .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); - } /** * Retrieves statistics related to replication for the account's Table service. It is only available on the @@ -909,27 +744,10 @@ Mono> getStatisticsWithResponse(Context context try { return this.implementation.getServices().getStatisticsWithResponseAsync(null, null, context) .onErrorMap(TableUtils::mapThrowableToTableServiceException) - .map(response -> new SimpleResponse<>(response, toTableServiceStatistics(response.getValue()))); + .map(response -> new SimpleResponse<>(response, TableUtils.toTableServiceStatistics(response.getValue()))); } catch (RuntimeException e) { return monoError(logger, e); } } - private TableServiceStatistics toTableServiceStatistics(TableServiceStats tableServiceStats) { - if (tableServiceStats == null) { - return null; - } - - return new TableServiceStatistics(toTableServiceGeoReplication(tableServiceStats.getGeoReplication())); - } - - private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication geoReplication) { - if (geoReplication == null) { - return null; - } - - return new TableServiceGeoReplication( - TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), - geoReplication.getLastSyncTime()); - } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 05ddf4e2aefe..eda12634b722 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -23,6 +23,7 @@ import com.azure.data.tables.implementation.AzureTableImplBuilder; import com.azure.data.tables.implementation.ModelHelper; import com.azure.data.tables.implementation.TableAccountSasGenerator; +import com.azure.data.tables.implementation.TablePaged; import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; import com.azure.data.tables.implementation.models.CorsRule; @@ -521,46 +522,6 @@ private PagedResponse listTables(String nextTableName, Context contex return new TablePaged(response, tables, response.getDeserializedHeaders().getXMsContinuationNextTableName()); } - private static class TablePaged implements PagedResponse { - private final Response httpResponse; - private final IterableStream tableStream; - private final String continuationToken; - - TablePaged(Response httpResponse, List tableList, String continuationToken) { - this.httpResponse = httpResponse; - this.tableStream = IterableStream.of(tableList); - this.continuationToken = continuationToken; - } - - @Override - public int getStatusCode() { - return httpResponse.getStatusCode(); - } - - @Override - public HttpHeaders getHeaders() { - return httpResponse.getHeaders(); - } - - @Override - public HttpRequest getRequest() { - return httpResponse.getRequest(); - } - - @Override - public IterableStream getElements() { - return tableStream; - } - - @Override - public String getContinuationToken() { - return continuationToken; - } - - @Override - public void close() { - } - } /** * Gets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin @@ -628,73 +589,9 @@ Response getPropertiesWithResponse(Context context) { context = TableUtils.setContext(context, true); Response response = this.implementation.getServices().getPropertiesWithResponse(null, null, context); - return new SimpleResponse<>(response, toTableServiceProperties(response.getValue())); - } - - private TableServiceProperties toTableServiceProperties( - com.azure.data.tables.implementation.models.TableServiceProperties tableServiceProperties) { - - if (tableServiceProperties == null) { - return null; - } - - return new TableServiceProperties() - .setLogging(toTableServiceLogging(tableServiceProperties.getLogging())) - .setHourMetrics(toTableServiceMetrics(tableServiceProperties.getHourMetrics())) - .setMinuteMetrics(toTableServiceMetrics(tableServiceProperties.getMinuteMetrics())) - .setCorsRules(tableServiceProperties.getCors() == null ? null - : tableServiceProperties.getCors().stream() - .map(this::toTablesServiceCorsRule) - .collect(Collectors.toList())); - } - - private TableServiceLogging toTableServiceLogging(Logging logging) { - if (logging == null) { - return null; - } - - return new TableServiceLogging() - .setAnalyticsVersion(logging.getVersion()) - .setDeleteLogged(logging.isDelete()) - .setReadLogged(logging.isRead()) - .setWriteLogged(logging.isWrite()) - .setRetentionPolicy(toTableServiceRetentionPolicy(logging.getRetentionPolicy())); - } - - private TableServiceRetentionPolicy toTableServiceRetentionPolicy(RetentionPolicy retentionPolicy) { - if (retentionPolicy == null) { - return null; - } - - return new TableServiceRetentionPolicy() - .setEnabled(retentionPolicy.isEnabled()) - .setDaysToRetain(retentionPolicy.getDays()); - } - - private TableServiceMetrics toTableServiceMetrics(Metrics metrics) { - if (metrics == null) { - return null; - } - - return new TableServiceMetrics() - .setVersion(metrics.getVersion()) - .setEnabled(metrics.isEnabled()) - .setIncludeApis(metrics.isIncludeAPIs()) - .setRetentionPolicy(toTableServiceRetentionPolicy(metrics.getRetentionPolicy())); + return new SimpleResponse<>(response, TableUtils.toTableServiceProperties(response.getValue())); } - private TableServiceCorsRule toTablesServiceCorsRule(CorsRule corsRule) { - if (corsRule == null) { - return null; - } - - return new TableServiceCorsRule() - .setAllowedOrigins(corsRule.getAllowedOrigins()) - .setAllowedMethods(corsRule.getAllowedMethods()) - .setAllowedHeaders(corsRule.getAllowedHeaders()) - .setExposedHeaders(corsRule.getExposedHeaders()) - .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); - } /** * Sets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -784,71 +681,10 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { context = TableUtils.setContext(context, true); return new SimpleResponse<>(this.implementation.getServices() - .setPropertiesWithResponse(toImplTableServiceProperties(tableServiceProperties), null, + .setPropertiesWithResponse(TableUtils.toImplTableServiceProperties(tableServiceProperties), null, null, context), null); } - private com.azure.data.tables.implementation.models.TableServiceProperties toImplTableServiceProperties( - TableServiceProperties tableServiceProperties) { - - return new com.azure.data.tables.implementation.models.TableServiceProperties() - .setLogging(toLogging(tableServiceProperties.getLogging())) - .setHourMetrics(toMetrics(tableServiceProperties.getHourMetrics())) - .setMinuteMetrics(toMetrics(tableServiceProperties.getMinuteMetrics())) - .setCors(tableServiceProperties.getCorsRules() == null ? null - : tableServiceProperties.getCorsRules().stream() - .map(this::toCorsRule) - .collect(Collectors.toList())); - } - - private Logging toLogging(TableServiceLogging tableServiceLogging) { - if (tableServiceLogging == null) { - return null; - } - - return new Logging() - .setVersion(tableServiceLogging.getAnalyticsVersion()) - .setDelete(tableServiceLogging.isDeleteLogged()) - .setRead(tableServiceLogging.isReadLogged()) - .setWrite(tableServiceLogging.isWriteLogged()) - .setRetentionPolicy(toRetentionPolicy(tableServiceLogging.getRetentionPolicy())); - } - - private RetentionPolicy toRetentionPolicy(TableServiceRetentionPolicy tableServiceRetentionPolicy) { - if (tableServiceRetentionPolicy == null) { - return null; - } - - return new RetentionPolicy() - .setEnabled(tableServiceRetentionPolicy.isEnabled()) - .setDays(tableServiceRetentionPolicy.getDaysToRetain()); - } - - private Metrics toMetrics(TableServiceMetrics tableServiceMetrics) { - if (tableServiceMetrics == null) { - return null; - } - - return new Metrics() - .setVersion(tableServiceMetrics.getVersion()) - .setEnabled(tableServiceMetrics.isEnabled()) - .setIncludeAPIs(tableServiceMetrics.isIncludeApis()) - .setRetentionPolicy(toRetentionPolicy(tableServiceMetrics.getTableServiceRetentionPolicy())); - } - - private CorsRule toCorsRule(TableServiceCorsRule corsRule) { - if (corsRule == null) { - return null; - } - - return new CorsRule() - .setAllowedOrigins(corsRule.getAllowedOrigins()) - .setAllowedMethods(corsRule.getAllowedMethods()) - .setAllowedHeaders(corsRule.getAllowedHeaders()) - .setExposedHeaders(corsRule.getExposedHeaders()) - .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); - } - /** * Retrieves statistics related to replication for the account's Table service. It is only available on the * secondary location endpoint when read-access geo-redundant replication is enabled for the account. @@ -917,25 +753,7 @@ Response getStatisticsWithResponse(Context context) { context = TableUtils.setContext(context, true); Response response = this.implementation.getServices().getStatisticsWithResponse( null, null, context); - return new SimpleResponse<>(response, toTableServiceStatistics(response.getValue())); - } - - - private TableServiceStatistics toTableServiceStatistics(TableServiceStats tableServiceStats) { - if (tableServiceStats == null) { - return null; - } - - return new TableServiceStatistics(toTableServiceGeoReplication(tableServiceStats.getGeoReplication())); + return new SimpleResponse<>(response, TableUtils.toTableServiceStatistics(response.getValue())); } - private TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication geoReplication) { - if (geoReplication == null) { - return null; - } - - return new TableServiceGeoReplication( - TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), - geoReplication.getLastSyncTime()); - } } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java new file mode 100644 index 000000000000..6cdd7333aa7f --- /dev/null +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.tables.implementation; + +import java.util.List; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.util.IterableStream; +import com.azure.data.tables.implementation.models.TableEntityQueryResponse; +import com.azure.data.tables.models.TableEntity; + +public class EntityPaged implements PagedResponse { + private static final String DELIMITER_CONTINUATION_TOKEN = ";"; + private final Response httpResponse; + private final IterableStream entityStream; + private final String continuationToken; + + public EntityPaged(Response httpResponse, List entityList, + String nextPartitionKey, String nextRowKey) { + if (nextPartitionKey == null || nextRowKey == null) { + this.continuationToken = null; + } else { + this.continuationToken = String.join(DELIMITER_CONTINUATION_TOKEN, nextPartitionKey, nextRowKey); + } + + this.httpResponse = httpResponse; + this.entityStream = IterableStream.of(entityList); + } + + @Override + public int getStatusCode() { + return httpResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return httpResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return httpResponse.getRequest(); + } + + @Override + public IterableStream getElements() { + return entityStream; + } + + @Override + public String getContinuationToken() { + return continuationToken; + } + + @Override + public void close() { + } +} \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablePaged.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablePaged.java new file mode 100644 index 000000000000..40432318c832 --- /dev/null +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TablePaged.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.tables.implementation; + +import java.util.List; + +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.util.IterableStream; +import com.azure.data.tables.implementation.models.TableQueryResponse; +import com.azure.data.tables.models.TableItem; + +public class TablePaged implements PagedResponse { + final Response httpResponse; + final IterableStream tableStream; + final String continuationToken; + + public TablePaged(Response httpResponse, List tableList, String continuationToken) { + this.httpResponse = httpResponse; + this.tableStream = IterableStream.of(tableList); + this.continuationToken = continuationToken; + } + + @Override + public int getStatusCode() { + return httpResponse.getStatusCode(); + } + + @Override + public HttpHeaders getHeaders() { + return httpResponse.getHeaders(); + } + + @Override + public HttpRequest getRequest() { + return httpResponse.getRequest(); + } + + @Override + public IterableStream getElements() { + return tableStream; + } + + @Override + public String getContinuationToken() { + return continuationToken; + } + + @Override + public void close() { + } +} diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 1a0e108464a2..8bd2a2d53e92 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -3,17 +3,43 @@ package com.azure.data.tables.implementation; import com.azure.core.exception.HttpResponseException; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; +import com.azure.core.util.IterableStream; import com.azure.core.util.logging.ClientLogger; +import com.azure.data.tables.implementation.models.AccessPolicy; +import com.azure.data.tables.implementation.models.CorsRule; +import com.azure.data.tables.implementation.models.GeoReplication; +import com.azure.data.tables.implementation.models.Logging; +import com.azure.data.tables.implementation.models.Metrics; +import com.azure.data.tables.implementation.models.RetentionPolicy; +import com.azure.data.tables.implementation.models.SignedIdentifier; +import com.azure.data.tables.implementation.models.TableQueryResponse; import com.azure.data.tables.implementation.models.TableServiceErrorException; import com.azure.data.tables.implementation.models.TableServiceErrorOdataError; import com.azure.data.tables.implementation.models.TableServiceErrorOdataErrorMessage; +import com.azure.data.tables.implementation.models.TableServiceStats; +import com.azure.data.tables.models.TableServiceProperties; +import com.azure.data.tables.models.TableAccessPolicy; +import com.azure.data.tables.models.TableItem; +import com.azure.data.tables.models.TableServiceCorsRule; import com.azure.data.tables.models.TableServiceError; import com.azure.data.tables.models.TableServiceException; +import com.azure.data.tables.models.TableServiceGeoReplication; +import com.azure.data.tables.models.TableServiceGeoReplicationStatus; +import com.azure.data.tables.models.TableServiceLogging; +import com.azure.data.tables.models.TableServiceMetrics; +import com.azure.data.tables.models.TableServiceRetentionPolicy; +import com.azure.data.tables.models.TableServiceStatistics; +import com.azure.data.tables.models.TableSignedIdentifier; +import com.azure.data.tables.models.TableTransactionFailedException; + import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -21,13 +47,16 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.time.Duration; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.function.Function; +import java.util.stream.Collectors; import static com.azure.core.util.FluxUtil.monoError; @@ -363,4 +392,213 @@ static Thread registerShutdownHook(ExecutorService threadPool) { Runtime.getRuntime().addShutdownHook(hook); return hook; } -} + + public static TableServiceProperties toTableServiceProperties( + com.azure.data.tables.implementation.models.TableServiceProperties tableServiceProperties) { + + if (tableServiceProperties == null) { + return null; + } + + return new TableServiceProperties() + .setLogging(toTableServiceLogging(tableServiceProperties.getLogging())) + .setHourMetrics(toTableServiceMetrics(tableServiceProperties.getHourMetrics())) + .setMinuteMetrics(toTableServiceMetrics(tableServiceProperties.getMinuteMetrics())) + .setCorsRules(tableServiceProperties.getCors() == null ? null + : tableServiceProperties.getCors().stream() + .map(TableUtils::toTablesServiceCorsRule) + .collect(Collectors.toList())); + } + + static TableServiceRetentionPolicy toTableServiceRetentionPolicy(RetentionPolicy retentionPolicy) { + if (retentionPolicy == null) { + return null; + } + + return new TableServiceRetentionPolicy() + .setEnabled(retentionPolicy.isEnabled()) + .setDaysToRetain(retentionPolicy.getDays()); + } + + static TableServiceMetrics toTableServiceMetrics(Metrics metrics) { + if (metrics == null) { + return null; + } + + return new TableServiceMetrics() + .setVersion(metrics.getVersion()) + .setEnabled(metrics.isEnabled()) + .setIncludeApis(metrics.isIncludeAPIs()) + .setRetentionPolicy(toTableServiceRetentionPolicy(metrics.getRetentionPolicy())); + } + + static TableServiceCorsRule toTablesServiceCorsRule(CorsRule corsRule) { + if (corsRule == null) { + return null; + } + + return new TableServiceCorsRule() + .setAllowedOrigins(corsRule.getAllowedOrigins()) + .setAllowedMethods(corsRule.getAllowedMethods()) + .setAllowedHeaders(corsRule.getAllowedHeaders()) + .setExposedHeaders(corsRule.getExposedHeaders()) + .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); + } + + static TableServiceLogging toTableServiceLogging(Logging logging) { + if (logging == null) { + return null; + } + + return new TableServiceLogging() + .setAnalyticsVersion(logging.getVersion()) + .setDeleteLogged(logging.isDelete()) + .setReadLogged(logging.isRead()) + .setWriteLogged(logging.isWrite()) + .setRetentionPolicy(toTableServiceRetentionPolicy(logging.getRetentionPolicy())); + } + + public static com.azure.data.tables.implementation.models.TableServiceProperties toImplTableServiceProperties( + TableServiceProperties tableServiceProperties) { + + return new com.azure.data.tables.implementation.models.TableServiceProperties() + .setLogging(toLogging(tableServiceProperties.getLogging())) + .setHourMetrics(toMetrics(tableServiceProperties.getHourMetrics())) + .setMinuteMetrics(toMetrics(tableServiceProperties.getMinuteMetrics())) + .setCors(tableServiceProperties.getCorsRules() == null ? null + : tableServiceProperties.getCorsRules().stream() + .map(TableUtils::toCorsRule) + .collect(Collectors.toList())); + } + + static Logging toLogging(TableServiceLogging tableServiceLogging) { + if (tableServiceLogging == null) { + return null; + } + + return new Logging() + .setVersion(tableServiceLogging.getAnalyticsVersion()) + .setDelete(tableServiceLogging.isDeleteLogged()) + .setRead(tableServiceLogging.isReadLogged()) + .setWrite(tableServiceLogging.isWriteLogged()) + .setRetentionPolicy(toRetentionPolicy(tableServiceLogging.getRetentionPolicy())); + } + + static RetentionPolicy toRetentionPolicy(TableServiceRetentionPolicy tableServiceRetentionPolicy) { + if (tableServiceRetentionPolicy == null) { + return null; + } + + return new RetentionPolicy() + .setEnabled(tableServiceRetentionPolicy.isEnabled()) + .setDays(tableServiceRetentionPolicy.getDaysToRetain()); + } + + static Metrics toMetrics(TableServiceMetrics tableServiceMetrics) { + if (tableServiceMetrics == null) { + return null; + } + + return new Metrics() + .setVersion(tableServiceMetrics.getVersion()) + .setEnabled(tableServiceMetrics.isEnabled()) + .setIncludeAPIs(tableServiceMetrics.isIncludeApis()) + .setRetentionPolicy(toRetentionPolicy(tableServiceMetrics.getTableServiceRetentionPolicy())); + } + + static CorsRule toCorsRule(TableServiceCorsRule corsRule) { + if (corsRule == null) { + return null; + } + + return new CorsRule() + .setAllowedOrigins(corsRule.getAllowedOrigins()) + .setAllowedMethods(corsRule.getAllowedMethods()) + .setAllowedHeaders(corsRule.getAllowedHeaders()) + .setExposedHeaders(corsRule.getExposedHeaders()) + .setMaxAgeInSeconds(corsRule.getMaxAgeInSeconds()); + } + + public static TableServiceStatistics toTableServiceStatistics(TableServiceStats tableServiceStats) { + if (tableServiceStats == null) { + return null; + } + + return new TableServiceStatistics(toTableServiceGeoReplication(tableServiceStats.getGeoReplication())); + } + + static TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication geoReplication) { + if (geoReplication == null) { + return null; + } + + return new TableServiceGeoReplication( + TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), + geoReplication.getLastSyncTime()); + } + + // Single quotes in OData queries should be escaped by using two consecutive single quotes characters. + // Source: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLSyntax. + public static String escapeSingleQuotes(String input) { + if (input == null) { + return null; + } + + return input.replace("'", "''"); + } + + public static TableSignedIdentifier toTableSignedIdentifier(SignedIdentifier signedIdentifier) { + if (signedIdentifier == null) { + return null; + } + + return new TableSignedIdentifier(signedIdentifier.getId()) + .setAccessPolicy(toTableAccessPolicy(signedIdentifier.getAccessPolicy())); + } + + static TableAccessPolicy toTableAccessPolicy(AccessPolicy accessPolicy) { + if (accessPolicy == null) { + return null; + } + + return new TableAccessPolicy() + .setExpiresOn(accessPolicy.getExpiry()) + .setStartsOn(accessPolicy.getStart()) + .setPermissions(accessPolicy.getPermission()); + } + + public static SignedIdentifier toSignedIdentifier(TableSignedIdentifier tableSignedIdentifier) { + if (tableSignedIdentifier == null) { + return null; + } + + return new SignedIdentifier() + .setId(tableSignedIdentifier.getId()) + .setAccessPolicy(toAccessPolicy(tableSignedIdentifier.getAccessPolicy())); + } + + static AccessPolicy toAccessPolicy(TableAccessPolicy tableAccessPolicy) { + if (tableAccessPolicy == null) { + return null; + } + + return new AccessPolicy() + .setExpiry(tableAccessPolicy.getExpiresOn()) + .setStart(tableAccessPolicy.getStartsOn()) + .setPermission(tableAccessPolicy.getPermissions()); + } + + public static Exception interpretException(Exception ex) { + Throwable exception = ex; + if (exception instanceof ExecutionException) { + exception = exception.getCause(); + } + Throwable cause = exception.getCause(); + if (cause instanceof TableTransactionFailedException) { + TableTransactionFailedException failedException = (TableTransactionFailedException) cause; + return failedException; + } else { + return new RuntimeException(mapThrowableToTableServiceException(exception)); + } + } +} \ No newline at end of file From 8d77fc5f180cf786a4a85ca41ad64194ff6ec8e0 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:20:23 -0800 Subject: [PATCH 21/25] Updating to only use threadpool for timeout cases. --- .../com/azure/data/tables/TableClient.java | 97 +++++++++++-------- .../azure/data/tables/TableServiceClient.java | 62 ++++++------ .../tables/implementation/TableUtils.java | 16 +-- 3 files changed, 96 insertions(+), 79 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index c880817aabea..144e740196a5 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.PagedIterable; @@ -15,7 +14,6 @@ import com.azure.core.http.rest.ResponseBase; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; -import com.azure.core.util.IterableStream; import com.azure.core.util.ServiceVersion; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.SerializerAdapter; @@ -27,7 +25,6 @@ import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; import com.azure.data.tables.implementation.TransactionalBatchImpl; -import com.azure.data.tables.implementation.models.AccessPolicy; import com.azure.data.tables.implementation.models.OdataMetadataFormat; import com.azure.data.tables.implementation.models.QueryOptions; import com.azure.data.tables.implementation.models.ResponseFormat; @@ -47,7 +44,6 @@ import com.azure.data.tables.implementation.models.TransactionalBatchSubmitBatchHeaders; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableAccessPolicies; -import com.azure.data.tables.models.TableAccessPolicy; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableEntityUpdateMode; import com.azure.data.tables.models.TableItem; @@ -66,8 +62,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.OptionalLong; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; @@ -285,16 +281,17 @@ public TableItem createTable() { public Response createTableWithResponse(Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); final TableProperties properties = new TableProperties().setTableName(tableName); - long timeoutInMillis = TableUtils.setTimeout(timeout); - Callable> createTableOp = () -> + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> new SimpleResponse<>(tablesImplementation.getTables().createWithResponse(properties, null, ResponseFormat.RETURN_NO_CONTENT, null, contextValue), ModelHelper.createItem(new TableResponseProperties().setTableName(tableName))); - //scheduler.shutdown(); try { - Response response = THREAD_POOL.submit(createTableOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + Response response = timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); return response; } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); @@ -346,15 +343,17 @@ public void deleteTable() { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); - Callable> deleteTableOp = () -> + Callable> callable = () -> new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( tableName, null, contextValue), null); try { - return THREAD_POOL.submit(deleteTableOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { Throwable except = mapThrowableToTableServiceException(ex); return swallow404Exception(except); @@ -442,14 +441,14 @@ public void createEntity(TableEntity entity) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createEntityWithResponse(TableEntity entity, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); } EntityHelper.setPropertiesFromGetters(entity, logger); - Callable> createEntityOp = () -> { + Callable> callable = () -> { Response> response = tablesImplementation.getTables().insertEntityWithResponse( tableName, null, null, ResponseFormat.RETURN_NO_CONTENT, entity.getProperties(), null, contextValue); @@ -457,7 +456,9 @@ public Response createEntityWithResponse(TableEntity entity, Duration time }; try { - return THREAD_POOL.submit(createEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -541,7 +542,7 @@ public void upsertEntity(TableEntity entity) { public Response upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); @@ -552,7 +553,7 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp EntityHelper.setPropertiesFromGetters(entity, logger); - Callable> upsertEntityOp = () -> { + Callable> callable = () -> { if (updateMode == TableEntityUpdateMode.REPLACE) { return tablesImplementation.getTables().updateEntityWithResponse( tableName, partitionKey, rowKey, null, null, null, @@ -565,7 +566,9 @@ public Response upsertEntityWithResponse(TableEntity entity, TableEntityUp }; try { - return THREAD_POOL.submit(upsertEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -695,7 +698,7 @@ public void updateEntity(TableEntity entity, TableEntityUpdateMode updateMode) { public Response updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); if (entity == null) { throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); @@ -707,7 +710,7 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp EntityHelper.setPropertiesFromGetters(entity, logger); - Callable> updateEntityOp = () -> { + Callable> callable = () -> { if (updateMode == TableEntityUpdateMode.REPLACE) { return tablesImplementation.getTables() .updateEntityWithResponse(tableName, partitionKey, rowKey, null, null, eTag, @@ -720,7 +723,9 @@ public Response updateEntityWithResponse(TableEntity entity, TableEntityUp }; try { - return THREAD_POOL.submit(updateEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -828,7 +833,7 @@ public Response deleteEntityWithResponse(TableEntity entity, boolean ifUnc private Response deleteEntityWithResponse(String partitionKey, String rowKey, String eTag, boolean ifUnchanged, Duration timeout, Context context) { Context contextValue = TableUtils.setContext(context, true); - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); String finalETag = ifUnchanged ? eTag : "*"; @@ -836,12 +841,14 @@ private Response deleteEntityWithResponse(String partitionKey, String rowK throw logger.logExceptionAsError(new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null")); } - Callable> deleteEntityOp = () -> tablesImplementation.getTables().deleteEntityWithResponse( + Callable> callable = () -> tablesImplementation.getTables().deleteEntityWithResponse( tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), finalETag, null, null, null, contextValue); try { - return THREAD_POOL.submit(deleteEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { Throwable except = mapThrowableToTableServiceException(ex); return swallow404Exception(except); @@ -922,14 +929,16 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); - Callable> listEntitiesOp = () -> new PagedIterable<>( + Callable> callable = () -> new PagedIterable<>( () -> listEntitiesFirstPage(context, options, TableEntity.class), token -> listEntitiesNextPage(token, context, options, TableEntity.class)); try { - return THREAD_POOL.submit(listEntitiesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1084,7 +1093,7 @@ public TableEntity getEntity(String partitionKey, String rowKey) { @ServiceMethod(returns = ReturnType.SINGLE) public Response getEntityWithResponse(String partitionKey, String rowKey, List select, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); QueryOptions queryOptions = new QueryOptions() @@ -1099,7 +1108,7 @@ public Response getEntityWithResponse(String partitionKey, String r new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null.")); } - Callable> getEntityOp = () -> { + Callable> callable = () -> { ResponseBase> response = tablesImplementation.getTables().queryEntityWithPartitionAndRowKeyWithResponse( tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), null, null, @@ -1120,7 +1129,9 @@ public Response getEntityWithResponse(String partitionKey, String r try { - return THREAD_POOL.submit(getEntityOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1191,10 +1202,10 @@ public TableAccessPolicies getAccessPolicies() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); - Callable> getAccessPoliciesOp = () -> { + Callable> callable = () -> { ResponseBase> response = tablesImplementation.getTables().getAccessPolicyWithResponse( tableName, null, null, contextValue @@ -1206,13 +1217,15 @@ public Response getAccessPoliciesWithResponse(Duration time }; try { - return THREAD_POOL.submit(getAccessPoliciesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } } - + /** * Sets stored {@link TableAccessPolicies access policies} for the table that may be used with Shared Access * Signatures. @@ -1294,7 +1307,7 @@ public void setAccessPolicies(List tableSignedIdentifiers @ServiceMethod(returns = ReturnType.SINGLE) public Response setAccessPoliciesWithResponse(List tableSignedIdentifiers, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); List signedIdentifiers = null; @@ -1327,7 +1340,7 @@ public Response setAccessPoliciesWithResponse(List } List finalSignedIdentifiers = signedIdentifiers; - Callable> setAccessPoliciesOp = () -> { + Callable> callable = () -> { ResponseBase response = tablesImplementation.getTables() .setAccessPolicyWithResponse(tableName, null, null, finalSignedIdentifiers, contextValue); @@ -1335,7 +1348,9 @@ public Response setAccessPoliciesWithResponse(List }; try { - return THREAD_POOL.submit(setAccessPoliciesOp).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); } @@ -1524,7 +1539,7 @@ public TableTransactionResult submitTransaction(List tra */ @ServiceMethod(returns = ReturnType.SINGLE) public Response submitTransactionWithResponse(List transactionActions, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Context contextValue = TableUtils.setContext(context, true); if (transactionActions.isEmpty()) { @@ -1571,7 +1586,7 @@ public Response submitTransactionWithResponse(List
> submitTransactionOp = () -> { + Callable> callable = () -> { BiConsumer accumulator = (body, pair) -> body.addChangeOperation(new TransactionalBatchSubRequest(pair.getAction(), pair.getRequest())); BiConsumer combiner = (body1, body2) -> @@ -1591,7 +1606,9 @@ public Response submitTransactionWithResponse(List
createTableWithResponse(String tableName, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableWithResponse(tableName, context); try { - return THREAD_POOL.submit(callable).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } @@ -318,10 +307,12 @@ public TableClient createTableIfNotExists(String tableName) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableIfNotExistsWithResponse(String tableName, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); Callable> callable = () -> createTableIfNotExistsWithResponse(tableName, context); try { - return THREAD_POOL.submit(callable).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -397,9 +388,12 @@ public void deleteTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(String tableName, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> deleteTableWithResponse(tableName, context); try { - return THREAD_POOL.submit(() -> deleteTableWithResponse(tableName, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception e) { Exception exception = (Exception) TableUtils.mapThrowableToTableServiceException(e); if (exception instanceof TableServiceException @@ -472,9 +466,12 @@ public PagedIterable listTables() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> listTables(options, context); try { - return THREAD_POOL.submit(() -> listTables(options, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -577,9 +574,12 @@ public TableServiceProperties getProperties() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> getPropertiesWithResponse(context); try { - return THREAD_POOL.submit(() -> getPropertiesWithResponse(context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception ex) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); } @@ -670,9 +670,12 @@ public void setProperties(TableServiceProperties tableServiceProperties) { public Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> setPropertiesWithResponse(tableServiceProperties, context); try { - return THREAD_POOL.submit(() -> setPropertiesWithResponse(tableServiceProperties, context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } @@ -740,9 +743,12 @@ public TableServiceStatistics getStatistics() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getStatisticsWithResponse(Duration timeout, Context context) { - long timeoutInMillis = TableUtils.setTimeout(timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> getStatisticsWithResponse(context); try { - return THREAD_POOL.submit(() -> getStatisticsWithResponse(context)).get(timeoutInMillis, TimeUnit.MILLISECONDS); + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); } catch (Exception e) { throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 8bd2a2d53e92..31abbbf29cc0 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -3,15 +3,11 @@ package com.azure.data.tables.implementation; import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; -import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; -import com.azure.core.util.IterableStream; import com.azure.core.util.logging.ClientLogger; import com.azure.data.tables.implementation.models.AccessPolicy; import com.azure.data.tables.implementation.models.CorsRule; @@ -20,14 +16,12 @@ import com.azure.data.tables.implementation.models.Metrics; import com.azure.data.tables.implementation.models.RetentionPolicy; import com.azure.data.tables.implementation.models.SignedIdentifier; -import com.azure.data.tables.implementation.models.TableQueryResponse; import com.azure.data.tables.implementation.models.TableServiceErrorException; import com.azure.data.tables.implementation.models.TableServiceErrorOdataError; import com.azure.data.tables.implementation.models.TableServiceErrorOdataErrorMessage; import com.azure.data.tables.implementation.models.TableServiceStats; import com.azure.data.tables.models.TableServiceProperties; import com.azure.data.tables.models.TableAccessPolicy; -import com.azure.data.tables.models.TableItem; import com.azure.data.tables.models.TableServiceCorsRule; import com.azure.data.tables.models.TableServiceError; import com.azure.data.tables.models.TableServiceException; @@ -47,9 +41,9 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.time.Duration; -import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.OptionalLong; import java.util.TreeMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -218,8 +212,8 @@ private static Context enableSyncRestProxy(Context context) { return context.addData(HTTP_REST_PROXY_SYNC_PROXY_ENABLE, true); } - public static Long setTimeout(Duration timeout) { - return timeout != null ? timeout.toMillis() : Duration.ofDays(1).toMillis(); + public static OptionalLong setTimeout(Duration timeout) { + return timeout != null ? OptionalLong.of(timeout.toMillis()) : OptionalLong.empty(); } /** @@ -536,7 +530,7 @@ static TableServiceGeoReplication toTableServiceGeoReplication(GeoReplication ge TableServiceGeoReplicationStatus.fromString(geoReplication.getStatus().toString()), geoReplication.getLastSyncTime()); } - + // Single quotes in OData queries should be escaped by using two consecutive single quotes characters. // Source: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLSyntax. public static String escapeSingleQuotes(String input) { @@ -601,4 +595,4 @@ public static Exception interpretException(Exception ex) { return new RuntimeException(mapThrowableToTableServiceException(exception)); } } -} \ No newline at end of file +} From b88706a8bf2a0f54dc4d1ac3cc18e97ac16ac9b0 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Thu, 23 Feb 2023 12:41:55 -0800 Subject: [PATCH 22/25] Additional refactoring --- .../tables/TableServiceClientBuilder.java | 64 ++----------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java index 853ceaa405b3..f5afa64e2364 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java @@ -123,61 +123,7 @@ public TableServiceClientBuilder() { */ public TableServiceClient buildClient() { TableServiceVersion serviceVersion = version != null ? version : TableServiceVersion.getLatest(); - - validateCredentials(azureNamedKeyCredential, azureSasCredential, tokenCredential, sasToken, connectionString, - logger); - - AzureNamedKeyCredential namedKeyCredential = null; - - // If 'connectionString' was provided, extract the endpoint and sasToken. - if (connectionString != null) { - StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, logger); - StorageEndpoint storageConnectionStringTableEndpoint = storageConnectionString.getTableEndpoint(); - - if (storageConnectionStringTableEndpoint == null - || storageConnectionStringTableEndpoint.getPrimaryUri() == null) { - - throw logger.logExceptionAsError(new IllegalArgumentException( - "'connectionString' is missing the required settings to derive a Tables endpoint.")); - } - - String connectionStringEndpoint = storageConnectionStringTableEndpoint.getPrimaryUri(); - - // If no 'endpoint' was provided, use the one in the 'connectionString'. Else, verify they are the same. - if (endpoint == null) { - endpoint = connectionStringEndpoint; - } else { - if (endpoint.endsWith("/")) { - endpoint = endpoint.substring(0, endpoint.length() - 1); - } - - if (connectionStringEndpoint.endsWith("/")) { - connectionStringEndpoint = - connectionStringEndpoint.substring(0, connectionStringEndpoint.length() - 1); - } - - if (!endpoint.equals(connectionStringEndpoint)) { - throw logger.logExceptionAsError(new IllegalStateException( - "'endpoint' points to a different tables endpoint than 'connectionString'.")); - } - } - - StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); - - if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { - namedKeyCredential = (azureNamedKeyCredential != null) ? azureNamedKeyCredential - : new AzureNamedKeyCredential(authSettings.getAccount().getName(), - authSettings.getAccount().getAccessKey()); - } else if (authSettings.getType() == StorageAuthenticationSettings.Type.SAS_TOKEN) { - sasToken = (sasToken != null) ? sasToken : authSettings.getSasToken(); - } - } - - HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( - namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, - tokenCredential, sasToken, endpoint, retryPolicy, retryOptions, httpLogOptions, clientOptions, httpClient, - perCallPolicies, perRetryPolicies, configuration, logger, enableTenantDiscovery); - + HttpPipeline pipeline = prepareClient(); return new TableServiceClient(pipeline, endpoint, serviceVersion, serializerAdapter); } @@ -197,7 +143,11 @@ public TableServiceClient buildClient() { */ public TableServiceAsyncClient buildAsyncClient() { TableServiceVersion serviceVersion = version != null ? version : TableServiceVersion.getLatest(); + HttpPipeline pipeline = prepareClient(); + return new TableServiceAsyncClient(pipeline, endpoint, serviceVersion, serializerAdapter); + } + private HttpPipeline prepareClient() { validateCredentials(azureNamedKeyCredential, azureSasCredential, tokenCredential, sasToken, connectionString, logger); @@ -251,8 +201,8 @@ public TableServiceAsyncClient buildAsyncClient() { namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, tokenCredential, sasToken, endpoint, retryPolicy, retryOptions, httpLogOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, configuration, logger, enableTenantDiscovery); - - return new TableServiceAsyncClient(pipeline, endpoint, serviceVersion, serializerAdapter); + + return pipeline; } /** From 95e7fbbeaa423d1d5904bb9d55f7eecc8db5903d Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Fri, 24 Feb 2023 09:37:53 -0800 Subject: [PATCH 23/25] Removed unused imports --- .../com/azure/data/tables/TableAsyncClient.java | 5 ----- .../data/tables/TableServiceAsyncClient.java | 15 --------------- 2 files changed, 20 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index a9c92b1f696f..1ea8c2251a08 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -6,9 +6,7 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpRequest; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; @@ -16,7 +14,6 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; -import com.azure.core.util.IterableStream; import com.azure.core.util.ServiceVersion; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.SerializerAdapter; @@ -28,7 +25,6 @@ import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; import com.azure.data.tables.implementation.TransactionalBatchImpl; -import com.azure.data.tables.implementation.models.AccessPolicy; import com.azure.data.tables.implementation.models.OdataMetadataFormat; import com.azure.data.tables.implementation.models.QueryOptions; import com.azure.data.tables.implementation.models.ResponseFormat; @@ -44,7 +40,6 @@ import com.azure.data.tables.implementation.models.TransactionalBatchSubmitBatchHeaders; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableAccessPolicies; -import com.azure.data.tables.models.TableAccessPolicy; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableEntityUpdateMode; import com.azure.data.tables.models.TableItem; diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java index 4dc98c13d308..9541dc378a51 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java @@ -6,9 +6,7 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; -import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; @@ -16,7 +14,6 @@ import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; -import com.azure.core.util.IterableStream; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.SerializerAdapter; import com.azure.data.tables.implementation.AzureTableImpl; @@ -26,28 +23,16 @@ import com.azure.data.tables.implementation.TablePaged; import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; -import com.azure.data.tables.implementation.models.CorsRule; -import com.azure.data.tables.implementation.models.GeoReplication; -import com.azure.data.tables.implementation.models.Logging; -import com.azure.data.tables.implementation.models.Metrics; import com.azure.data.tables.implementation.models.OdataMetadataFormat; import com.azure.data.tables.implementation.models.QueryOptions; import com.azure.data.tables.implementation.models.ResponseFormat; -import com.azure.data.tables.implementation.models.RetentionPolicy; import com.azure.data.tables.implementation.models.TableProperties; import com.azure.data.tables.implementation.models.TableQueryResponse; import com.azure.data.tables.implementation.models.TableResponseProperties; -import com.azure.data.tables.implementation.models.TableServiceStats; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableItem; -import com.azure.data.tables.models.TableServiceCorsRule; import com.azure.data.tables.models.TableServiceException; -import com.azure.data.tables.models.TableServiceGeoReplication; -import com.azure.data.tables.models.TableServiceGeoReplicationStatus; -import com.azure.data.tables.models.TableServiceLogging; -import com.azure.data.tables.models.TableServiceMetrics; import com.azure.data.tables.models.TableServiceProperties; -import com.azure.data.tables.models.TableServiceRetentionPolicy; import com.azure.data.tables.models.TableServiceStatistics; import com.azure.data.tables.sas.TableAccountSasSignatureValues; import reactor.core.publisher.Mono; From 93320f84d89d4b796bbbe3f4762921b3ea51f37a Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:25:21 -0800 Subject: [PATCH 24/25] Fixed Checkstyle Issues --- .../java/com/azure/data/tables/implementation/EntityPaged.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java index 6cdd7333aa7f..03c5eb9ef141 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java @@ -59,4 +59,4 @@ public String getContinuationToken() { @Override public void close() { } -} \ No newline at end of file +} From 3e72216b63adaeec3c2e3ac34a9fde0f5da3f2d1 Mon Sep 17 00:00:00 2001 From: Jair <67484440+jairmyree@users.noreply.github.com> Date: Fri, 24 Feb 2023 13:34:48 -0800 Subject: [PATCH 25/25] Bug fix for failing Cosmos test --- .../java/com/azure/data/tables/implementation/TableUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 31abbbf29cc0..2d71318300ba 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -592,7 +592,7 @@ public static Exception interpretException(Exception ex) { TableTransactionFailedException failedException = (TableTransactionFailedException) cause; return failedException; } else { - return new RuntimeException(mapThrowableToTableServiceException(exception)); + return (RuntimeException) mapThrowableToTableServiceException(exception); } } }