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) 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..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,18 +14,17 @@ 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; 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; 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; @@ -43,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; @@ -238,6 +234,7 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { return new TableSasGenerator(tableSasSignatureValues, getTableName(), azureNamedKeyCredential).getSas(); } + /** * Creates the table within the Tables service. * @@ -287,7 +284,7 @@ public Mono> createTableWithResponse() { } Mono> createTableWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); final TableProperties properties = new TableProperties().setTableName(tableName); try { @@ -349,7 +346,7 @@ public Mono> deleteTableWithResponse() { } Mono> deleteTableWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return tablesImplementation.getTables().deleteWithResponseAsync(tableName, null, context) @@ -432,7 +429,7 @@ public Mono> createEntityWithResponse(TableEntity entity) { } Mono> createEntityWithResponse(TableEntity entity, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); if (entity == null) { return monoError(logger, new IllegalArgumentException("'entity' cannot be null.")); @@ -532,14 +529,14 @@ public Mono> upsertEntityWithResponse(TableEntity entity, TableEn Mono> upsertEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); if (entity == null) { 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); @@ -699,14 +696,14 @@ public Mono> updateEntityWithResponse(TableEntity entity, TableEn Mono> updateEntityWithResponse(TableEntity entity, TableEntityUpdateMode updateMode, boolean ifUnchanged, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); if (entity == null) { 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); @@ -839,7 +836,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 = TableUtils.setContext(context); eTag = ifUnchanged ? eTag : "*"; if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { @@ -848,7 +845,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)); @@ -967,7 +964,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 = TableUtils.setContext(context); String select = null; if (options.getSelect() != null) { @@ -1011,53 +1008,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. * @@ -1156,7 +1106,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(); @@ -1248,7 +1198,7 @@ public Mono> getAccessPoliciesWithResponse() { } Mono> getAccessPoliciesWithResponse(Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); try { return tablesImplementation.getTables() @@ -1256,33 +1206,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. @@ -1368,7 +1298,7 @@ public Mono> setAccessPoliciesWithResponse(List> setAccessPoliciesWithResponse(List tableSignedIdentifiers, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); List signedIdentifiers = null; /* @@ -1380,7 +1310,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 @@ -1415,27 +1345,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 @@ -1617,7 +1526,7 @@ public Mono> submitTransactionWithResponse(List } Mono> submitTransactionWithResponse(List transactionActions, Context context) { - Context finalContext = context == null ? Context.NONE : context; + Context finalContext = TableUtils.setContext(context); if (transactionActions.isEmpty()) { return monoError(logger, @@ -1750,14 +1659,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 ab8d6a53d4f5..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 @@ -7,9 +7,41 @@ import com.azure.core.annotation.ServiceMethod; import com.azure.core.credential.AzureNamedKeyCredential; 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.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.EntityPaged; +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.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.TableEntity; @@ -23,10 +55,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.OptionalLong; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +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.mapThrowableToTableServiceException; +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 +100,63 @@ */ @ServiceClient(builder = TableClientBuilder.class) public final class TableClient { - final TableAsyncClient client; - TableClient(TableAsyncClient client) { - this.client = client; + 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; + private final AzureTableImpl tablesImplementation; + private final TransactionalBatchImpl transactionalBatchImplementation; + private final String accountName; + private final String tableEndpoint; + private final HttpPipeline pipeline; + private final TableClient transactionalBatchClient; + + 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 +165,7 @@ public final class TableClient { * @return The name of the table. */ public String getTableName() { - return this.client.getTableName(); + return tableName; } /** @@ -75,7 +174,7 @@ public String getTableName() { * @return The name of the account containing the table. */ public String getAccountName() { - return this.client.getAccountName(); + return accountName; } /** @@ -84,7 +183,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 +205,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 +222,14 @@ 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(); } /** @@ -132,7 +251,7 @@ public String generateSas(TableSasSignatureValues tableSasSignatureValues) { */ @ServiceMethod(returns = ReturnType.SINGLE) public TableItem createTable() { - return client.createTable().block(); + return createTableWithResponse(null, null).getValue(); } /** @@ -160,7 +279,23 @@ public TableItem createTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.createTableWithResponse(context), timeout); + Context contextValue = TableUtils.setContext(context, true); + final TableProperties properties = new TableProperties().setTableName(tableName); + 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))); + + try { + 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)); + } } /** @@ -180,7 +315,7 @@ public Response createTableWithResponse(Duration timeout, Context con */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable() { - client.deleteTable().block(); + deleteTableWithResponse(null, null); } /** @@ -207,7 +342,36 @@ public void deleteTable() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.deleteTableWithResponse(context), timeout); + Context contextValue = TableUtils.setContext(context, true); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + Callable> callable = () -> + new SimpleResponse<>(tablesImplementation.getTables().deleteWithResponse( + tableName, null, contextValue), + null); + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception 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))); + } } /** @@ -238,7 +402,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 +440,28 @@ 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); + Context contextValue = TableUtils.setContext(context, true); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + EntityHelper.setPropertiesFromGetters(entity, logger); + Callable> callable = () -> { + 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); + }; + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -308,7 +493,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 +541,37 @@ 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); + Context contextValue = TableUtils.setContext(context, true); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); + + EntityHelper.setPropertiesFromGetters(entity, logger); + + Callable> callable = () -> { + 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); + } + }; + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -389,7 +604,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 +644,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 +697,38 @@ 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); + Context contextValue = TableUtils.setContext(context, true); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + if (entity == null) { + throw logger.logExceptionAsError(new IllegalArgumentException("'entity' cannot be null.")); + } + + String partitionKey = TableUtils.escapeSingleQuotes(entity.getPartitionKey()); + String rowKey = TableUtils.escapeSingleQuotes(entity.getRowKey()); + String eTag = ifUnchanged ? entity.getETag() : "*"; + + EntityHelper.setPropertiesFromGetters(entity, logger); + + Callable> callable = () -> { + 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); + } + }; + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -512,7 +757,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 +786,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 +826,33 @@ 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); + 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 = TableUtils.setContext(context, true); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + String finalETag = ifUnchanged ? eTag : "*"; + + if (isNullOrEmpty(partitionKey) || isNullOrEmpty(rowKey)) { + throw logger.logExceptionAsError(new IllegalArgumentException("'partitionKey' and 'rowKey' cannot be null")); + } + + Callable> callable = () -> tablesImplementation.getTables().deleteEntityWithResponse( + tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.escapeSingleQuotes(rowKey), finalETag, null, + null, null, contextValue); + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + Throwable except = mapThrowableToTableServiceException(ex); + return swallow404Exception(except); + } } /** @@ -607,7 +877,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 +929,88 @@ public PagedIterable listEntities() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(client.listEntities(options, context, timeout)); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + + Callable> callable = () -> new PagedIterable<>( + () -> listEntitiesFirstPage(context, options, TableEntity.class), + token -> listEntitiesNextPage(token, context, options, TableEntity.class)); + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((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 = TableUtils.setContext(context, true); + 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, contextValue); + + 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()); } /** @@ -692,7 +1043,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 +1093,48 @@ 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); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Context contextValue = TableUtils.setContext(context, true); + + 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> callable = () -> { + ResponseBase> response = + tablesImplementation.getTables().queryEntityWithPartitionAndRowKeyWithResponse( + tableName, TableUtils.escapeSingleQuotes(partitionKey), TableUtils.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)); + }; + + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); + } } /** @@ -770,7 +1161,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 +1202,30 @@ public TableAccessPolicies getAccessPolicies() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getAccessPoliciesWithResponse(context), timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Context contextValue = TableUtils.setContext(context, true); + + Callable> callable = () -> { + ResponseBase> response = + tablesImplementation.getTables().getAccessPolicyWithResponse( + tableName, null, null, contextValue + ); + return new SimpleResponse<>(response, + new TableAccessPolicies(response.getValue() == null ? null : response.getValue().stream() + .map(TableUtils::toTableSignedIdentifier) + .collect(Collectors.toList()))); + }; + + try { + 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. @@ -848,7 +1261,7 @@ public Response getAccessPoliciesWithResponse(Duration time */ @ServiceMethod(returns = ReturnType.SINGLE) public void setAccessPolicies(List tableSignedIdentifiers) { - client.setAccessPolicies(tableSignedIdentifiers).block(); + setAccessPoliciesWithResponse(tableSignedIdentifiers, null, null); } /** @@ -894,9 +1307,56 @@ 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); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Context contextValue = TableUtils.setContext(context, true); + List signedIdentifiers = null; + + if (tableSignedIdentifiers != null) { + signedIdentifiers = tableSignedIdentifiers.stream() + .map(tableSignedIdentifier -> { + SignedIdentifier signedIdentifier = TableUtils.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> callable = () -> { + ResponseBase response = tablesImplementation.getTables() + .setAccessPolicyWithResponse(tableName, null, null, + finalSignedIdentifiers, contextValue); + return new SimpleResponse<>(response, response.getValue()); + }; + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) (TableUtils.mapThrowableToTableServiceException(ex))); + } } + /** * 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 @@ -982,7 +1442,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 +1539,166 @@ 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); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Context contextValue = TableUtils.setContext(context, true); + + 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> callable = () -> { + 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())); + }; + + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + + throw logger.logExceptionAsError((RuntimeException) TableUtils.interpretException(ex)); + } + } + + private static class RequestActionPair { + private final HttpRequest request; + private final TransactionalBatchAction action; + + 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())); + } } } 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/TableServiceAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java index 0e3d910a192c..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,37 +14,25 @@ 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; 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; -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; @@ -265,7 +251,7 @@ public Mono> 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 +385,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 +474,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()) @@ -522,47 +508,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. @@ -618,82 +563,17 @@ 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) .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. @@ -774,12 +654,12 @@ public Mono> setPropertiesWithResponse(TableServiceProperties tab } Mono> setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { - context = context == null ? Context.NONE : context; + context = TableUtils.setContext(context); 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 +668,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 @@ -904,32 +724,15 @@ 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) .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 7527334a2f4a..b83221d87e46 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 @@ -9,24 +9,44 @@ import com.azure.core.http.HttpPipeline; 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.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.TablePaged; +import com.azure.data.tables.implementation.TableSasUtils; import com.azure.data.tables.implementation.TableUtils; +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.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.TableServiceException; import com.azure.data.tables.models.TableServiceProperties; 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.OptionalLong; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +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 +72,32 @@ */ @ServiceClient(builder = TableServiceClientBuilder.class) public final class TableServiceClient { - private final TableServiceAsyncClient client; - TableServiceClient(TableServiceAsyncClient client) { - this.client = client; + private static final ExecutorService THREAD_POOL = TableUtils.getThreadPoolWithShutdownHook(); + 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 +106,7 @@ public final class TableServiceClient { * @return The name of the account containing the table. */ public String getAccountName() { - return client.getAccountName(); + return accountName; } /** @@ -73,7 +115,7 @@ public String getAccountName() { * @return The endpoint for the Tables service. */ public String getServiceEndpoint() { - return client.getServiceEndpoint(); + return implementation.getUrl(); } /** @@ -82,7 +124,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 +133,7 @@ public TableServiceVersion getServiceVersion() { * @return This client's {@link HttpPipeline}. */ HttpPipeline getHttpPipeline() { - return client.getHttpPipeline(); + return this.pipeline; } /** @@ -109,7 +151,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 +173,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 +234,24 @@ public TableClient createTable(String tableName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(String tableName, Duration timeout, Context context) { - return blockWithOptionalTimeout(createTableWithResponse(tableName, context), timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> createTableWithResponse(tableName, context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); + } } - Mono> createTableWithResponse(String tableName, Context context) { - context = context == null ? Context.NONE : context; + Response createTableWithResponse(String tableName, Context context) { + context = TableUtils.setContext(context, true); 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 +307,31 @@ public TableClient createTableIfNotExists(String tableName) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableIfNotExistsWithResponse(String tableName, Duration timeout, Context context) { - return blockWithOptionalTimeout(createTableIfNotExistsWithResponse(tableName, context), timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> createTableIfNotExistsWithResponse(tableName, context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception e) { + throw logger.logExceptionAsError((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.logExceptionAsError(new RuntimeException(e)); + } } /** @@ -285,7 +356,7 @@ Mono> createTableIfNotExistsWithResponse(String tableName, */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable(String tableName) { - client.deleteTable(tableName).block(); + deleteTableWithResponse(tableName, null, null); } /** @@ -317,7 +388,29 @@ 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); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> deleteTableWithResponse(tableName, context); + try { + 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 + && ((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 = TableUtils.setContext(context, true); + return new SimpleResponse<>( + implementation.getTables().deleteWithResponse(tableName, null, context), null); } /** @@ -340,7 +433,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,9 +466,60 @@ public PagedIterable listTables() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options, Duration timeout, Context context) { - return new PagedIterable<>(client.listTables(options, context, timeout)); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> listTables(options, context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception e) { + throw logger.logExceptionAsError((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 = TableUtils.setContext(context, true); + 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()); + } + + /** * Gets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. @@ -398,7 +542,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,7 +574,22 @@ public TableServiceProperties getProperties() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getPropertiesWithResponse(context), timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> getPropertiesWithResponse(context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception ex) { + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(ex)); + } + } + + Response getPropertiesWithResponse(Context context) { + context = TableUtils.setContext(context, true); + Response response = + this.implementation.getServices().getPropertiesWithResponse(null, null, context); + return new SimpleResponse<>(response, TableUtils.toTableServiceProperties(response.getValue())); } /** @@ -466,7 +625,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 +669,23 @@ 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); + + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> setPropertiesWithResponse(tableServiceProperties, context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception e) { + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); + } + } + + Response setPropertiesWithResponse(TableServiceProperties tableServiceProperties, Context context) { + context = TableUtils.setContext(context, true); + return new SimpleResponse<>(this.implementation.getServices() + .setPropertiesWithResponse(TableUtils.toImplTableServiceProperties(tableServiceProperties), null, + null, context), null); } /** @@ -535,7 +710,7 @@ public Response setPropertiesWithResponse(TableServiceProperties tableServ */ @ServiceMethod(returns = ReturnType.SINGLE) public TableServiceStatistics getStatistics() { - return client.getStatistics().block(); + return getStatisticsWithResponse(null, null).getValue(); } /** @@ -568,6 +743,23 @@ public TableServiceStatistics getStatistics() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getStatisticsWithResponse(Duration timeout, Context context) { - return blockWithOptionalTimeout(client.getStatisticsWithResponse(context), timeout); + OptionalLong timeoutInMillis = TableUtils.setTimeout(timeout); + Callable> callable = () -> getStatisticsWithResponse(context); + try { + return timeoutInMillis.isPresent() + ? THREAD_POOL.submit(callable).get(timeoutInMillis.getAsLong(), TimeUnit.MILLISECONDS) + : callable.call(); + } catch (Exception e) { + throw logger.logExceptionAsError((RuntimeException) TableUtils.mapThrowableToTableServiceException(e)); + } } + + + Response getStatisticsWithResponse(Context context) { + context = TableUtils.setContext(context, true); + Response response = this.implementation.getServices().getStatisticsWithResponse( + null, null, context); + return new SimpleResponse<>(response, TableUtils.toTableServiceStatistics(response.getValue())); + } + } 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..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 @@ -122,9 +122,12 @@ public TableServiceClientBuilder() { * respectively. */ public TableServiceClient buildClient() { - return new TableServiceClient(buildAsyncClient()); + TableServiceVersion serviceVersion = version != null ? version : TableServiceVersion.getLatest(); + HttpPipeline pipeline = prepareClient(); + return new TableServiceClient(pipeline, endpoint, serviceVersion, serializerAdapter); } + /** * Creates a {@link TableServiceAsyncClient} based on options set in the builder. * @@ -140,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); @@ -194,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; } /** 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/EntityPaged.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/EntityPaged.java new file mode 100644 index 000000000000..03c5eb9ef141 --- /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() { + } +} 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/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; + } +} 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 f98603f5318f..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 @@ -6,13 +6,34 @@ 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.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.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.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; @@ -22,15 +43,26 @@ import java.time.Duration; 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; +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; + +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 static final long THREADPOOL_SHUTDOWN_HOOK_TIMEOUT_SECINDS = 5; private TableUtils() { throw new UnsupportedOperationException("Cannot instantiate TablesUtils"); @@ -92,9 +124,13 @@ public static TableServiceException toTableServiceException(TableServiceErrorExc public static Throwable mapThrowableToTableServiceException(Throwable throwable) { if (throwable instanceof TableServiceErrorException) { return toTableServiceException((TableServiceErrorException) throwable); - } else { - return throwable; + } else if (throwable.getCause() instanceof Exception) { + Throwable cause = throwable.getCause(); + if (cause instanceof TableServiceErrorException) { + return toTableServiceException((TableServiceErrorException) cause); + } } + return throwable; } /** @@ -159,6 +195,27 @@ 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); + } + + public static OptionalLong setTimeout(Duration timeout) { + return timeout != null ? OptionalLong.of(timeout.toMillis()) : OptionalLong.empty(); + } + /** * 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). @@ -305,4 +362,237 @@ 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; + } + + 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 (RuntimeException) mapThrowableToTableServiceException(exception); + } + } } 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..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 @@ -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) @@ -244,7 +406,21 @@ 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); + + @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") SignedIdentifiersWrapper 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,63 +503,89 @@ 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 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 on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono queryAsync(String requestId, String nextTableName, QueryOptions queryOptions) { + return queryWithResponseAsync(requestId, nextTableName, queryOptions) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * 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 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 {@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, Context context) { + return queryWithResponseAsync(requestId, nextTableName, queryOptions, context) + .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 along with {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> queryEntitiesWithResponseAsync( - String table, - Integer timeout, - String requestId, - String nextPartitionKey, - String nextRowKey, - QueryOptions queryOptions, - Context context) { + 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; @@ -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,72 +800,2030 @@ 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(); } /** - * Sets stored access policies for the table that may be used with Shared Access Signatures. + * Operation permanently deletes the specified 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 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} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setAccessPolicyWithResponseAsync( - String table, Integer timeout, String requestId, List tableAcl, Context context) { - final String comp = "acl"; - final String accept = "application/xml"; - return service.setAccessPolicy( - this.client.getUrl(), - timeout, + 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"; + SignedIdentifiersWrapper tableAclConverted = new SignedIdentifiersWrapper(tableAcl); + return FluxUtil.withContext( + context -> + service.setAccessPolicy( + this.client.getUrl(), + timeout, + this.client.getVersion(), + requestId, + table, + comp, + tableAclConverted, + 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. + * @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> setAccessPolicyWithResponseAsync( + 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, + this.client.getVersion(), + requestId, + table, + comp, + tableAclConverted, + 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"; + SignedIdentifiersWrapper tableAclConverted = new SignedIdentifiersWrapper(tableAcl); + return service.setAccessPolicySync( + this.client.getUrl(), + timeout, this.client.getVersion(), requestId, table, comp, - tableAcl, + tableAclConverted, 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/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/AccessPolicy.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/AccessPolicy.java index 0a4fd3a399ad..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 { /* @@ -29,6 +31,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..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 { /* @@ -49,6 +51,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..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 { /* @@ -25,6 +27,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..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 { /* @@ -40,6 +42,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..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 { /* @@ -34,6 +36,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..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 { /* @@ -35,6 +37,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..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 { /* @@ -23,6 +25,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..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 @@ -5,10 +5,13 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The ServicesGetPropertiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesGetPropertiesHeaders { /* @@ -29,6 +32,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 +43,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The ServicesGetStatisticsHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesGetStatisticsHeaders { /* @@ -35,7 +38,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 +51,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 +121,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..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 @@ -5,10 +5,13 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** The ServicesSetPropertiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class ServicesSetPropertiesHeaders { /* @@ -29,6 +32,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 +43,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..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 { /* @@ -22,6 +24,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..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 @@ -6,10 +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.List; import java.util.Map; /** The properties for the table entity query response. */ +@JacksonXmlRootElement(localName = "TableEntityQueryResponse") @Fluent public final class TableEntityQueryResponse { /* @@ -24,6 +26,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..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 { /* @@ -16,6 +18,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..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 @@ -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.util.List; /** The properties for the table query response. */ +@JacksonXmlRootElement(localName = "TableQueryResponse") @Fluent public final class TableQueryResponse { /* @@ -23,6 +25,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..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 { /* @@ -16,6 +18,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..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 { /* @@ -34,6 +36,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/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/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/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 e58465ee2bc1..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 { /* @@ -16,6 +18,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesCreateHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesCreateHeaders { /* @@ -35,7 +38,7 @@ public final class TablesCreateHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; /* * The Preference-Applied property. @@ -43,6 +46,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 +57,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 +128,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesDeleteEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesDeleteEntityHeaders { /* @@ -35,7 +38,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 +51,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 +121,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesDeleteHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesDeleteHeaders { /* @@ -35,7 +38,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 +51,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 +121,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesGetAccessPolicyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesGetAccessPolicyHeaders { /* @@ -35,7 +38,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 +51,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 +121,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesInsertEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesInsertEntityHeaders { /* @@ -41,7 +44,7 @@ public final class TablesInsertEntityHeaders { * The Date property. */ @JsonProperty(value = "Date") - private DateTimeRfc1123 dateProperty; + private DateTimeRfc1123 date; /* * The Preference-Applied property. @@ -55,6 +58,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 +69,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 +162,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesMergeEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesMergeEntityHeaders { /* @@ -41,7 +44,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 +57,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 +148,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryEntitiesHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryEntitiesHeaders { /* @@ -47,7 +50,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 +69,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 +181,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryEntityWithPartitionAndRowKeyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryEntityWithPartitionAndRowKeyHeaders { /* @@ -53,7 +56,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 +75,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 +210,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesQueryHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesQueryHeaders { /* @@ -35,7 +38,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 +46,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 +60,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 +131,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesSetAccessPolicyHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesSetAccessPolicyHeaders { /* @@ -35,7 +38,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 +51,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 +121,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..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 @@ -5,12 +5,15 @@ 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; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import java.time.OffsetDateTime; /** The TablesUpdateEntityHeaders model. */ +@JacksonXmlRootElement(localName = "null") @Fluent public final class TablesUpdateEntityHeaders { /* @@ -41,7 +44,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 +57,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 +148,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/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{" 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..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); @@ -109,6 +118,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..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()); @@ -95,6 +104,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 +1142,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/TableClientTestBase.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientTestBase.java index cdab36e22c27..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 @@ -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); @@ -46,13 +48,12 @@ private TableClientBuilder configureTestClientBuilder(TableClientBuilder tableCl if (interceptorManager.isPlaybackMode()) { playbackClient = interceptorManager.getPlaybackClient(); - tableClientBuilder.httpClient(playbackClient); + tableClientBuilder.httpClient(buildAssertingClient(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 3a892a1bead0..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); @@ -106,6 +114,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..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()); @@ -96,6 +104,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/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..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 @@ -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); @@ -46,9 +48,9 @@ private TableServiceClientBuilder configureTestClientBuilder(TableServiceClientB if (interceptorManager.isPlaybackMode()) { playbackClient = interceptorManager.getPlaybackClient(); - tableServiceClientBuilder.httpClient(playbackClient); + tableServiceClientBuilder.httpClient(buildAssertingClient(playbackClient)); } else { - tableServiceClientBuilder.httpClient(DEFAULT_HTTP_CLIENT); + tableServiceClientBuilder.httpClient(buildAssertingClient(DEFAULT_HTTP_CLIENT)); if (!interceptorManager.isLiveMode()) { recordPolicy = interceptorManager.getRecordPolicy(); diff --git a/sdk/tables/azure-data-tables/swagger/README.md b/sdk/tables/azure-data-tables/swagger/README.md index 940c2556ad3f..5e81b9b518a3 100644 --- a/sdk/tables/azure-data-tables/swagger/README.md +++ b/sdk/tables/azure-data-tables/swagger/README.md @@ -21,18 +21,19 @@ 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 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 context-client-method-parameter: true service-interface-as-public: true +enable-xml: true custom-strongly-typed-header-deserialization: true generic-response-type: true ```