diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java index 788e5d1fb9fa..7e6473337ea0 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java @@ -76,9 +76,6 @@ static HttpPipeline buildPipeline( httpHeaderList.add(new HttpHeader(header.getName(), header.getValue()))); } - // TODO: Remove the Accept header after making sure the JacksonAdapter can handle not setting such value. - policies.add(new AddHeadersPolicy(new HttpHeaders(httpHeaderList).set("Accept", "application/json"))); - // Add per call additional policies. policies.addAll(perCallAdditionalPolicies); HttpPolicyProviders.addBeforeRetryPolicies(policies); 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 33d3b6539779..3bff81252beb 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 @@ -11,7 +11,6 @@ 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.PagedResponseBase; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; @@ -42,6 +41,7 @@ import com.azure.data.tables.implementation.models.TransactionalBatchResponse; import com.azure.data.tables.implementation.models.TransactionalBatchSubRequest; 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; @@ -57,17 +57,15 @@ import reactor.core.publisher.Mono; import java.net.URI; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.function.Function; import java.util.stream.Collectors; import static com.azure.core.util.CoreUtils.isNullOrEmpty; -import static com.azure.core.util.FluxUtil.fluxContext; import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.core.util.FluxUtil.pagedFluxError; import static com.azure.core.util.FluxUtil.withContext; import static com.azure.data.tables.implementation.TableUtils.swallowExceptionForStatusCode; import static com.azure.data.tables.implementation.TableUtils.toTableServiceError; @@ -845,45 +843,55 @@ Mono> getEntityWithResponse(String partition * Retrieves details about any stored access policies specified on the table that may be used with Shared Access * Signatures. * - * @return A paged reactive result containing the HTTP response and the table's - * {@link TableSignedIdentifier access policies}. + * @return A reactive result containing the table's {@link TableAccessPolicies access policies}. */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listAccessPolicies() { - return (PagedFlux) fluxContext(this::listAccessPolicies); + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAccessPolicies() { + return withContext(context -> getAccessPoliciesWithResponse(context) + .flatMap(response -> Mono.justOrEmpty(response.getValue()))); + } + + /** + * Retrieves details about any stored access policies specified on the table that may be used with Shared Access + * Signatures. + * + * @return A reactive result containing an HTTP response that contains the table's + * {@link TableAccessPolicies access policies}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAccessPoliciesWithResponse() { + return withContext(this::getAccessPoliciesWithResponse); } - PagedFlux listAccessPolicies(Context context) { + Mono> getAccessPoliciesWithResponse(Context context) { context = context == null ? Context.NONE : context; try { - Context finalContext = context; - Function>> retriever = - marker -> - tablesImplementation.getTables() - .getAccessPolicyWithResponseAsync(tableName, null, null, finalContext) - .map(response -> new PagedResponseBase<>(response.getRequest(), - response.getStatusCode(), - response.getHeaders(), - response.getValue().stream() - .map(this::toTableSignedIdentifier) - .collect(Collectors.toList()), - null, - response.getDeserializedHeaders())); - - return new PagedFlux<>(() -> retriever.apply(null), retriever); + return tablesImplementation.getTables() + .getAccessPolicyWithResponseAsync(tableName, null, null, context) + .map(response -> new SimpleResponse<>(response, + new TableAccessPolicies(response.getValue() == null ? null : response.getValue().stream() + .map(this::toTableSignedIdentifier) + .collect(Collectors.toList())))); } catch (RuntimeException e) { - return pagedFluxError(logger, e); + return monoError(logger, e); } } private TableSignedIdentifier toTableSignedIdentifier(SignedIdentifier signedIdentifier) { - return new TableSignedIdentifier() - .setId(signedIdentifier.getId()) + 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()) @@ -918,11 +926,45 @@ public Mono> setAccessPoliciesWithResponse(List> setAccessPoliciesWithResponse(List tableSignedIdentifiers, Context context) { context = context == null ? Context.NONE : context; + List signedIdentifiers = null; + + /* + We truncate to seconds because the service only supports nanoseconds or seconds, but doing an + OffsetDateTime.now will only give back milliseconds (more precise fields are zeroed and not serialized). This + allows for proper serialization with no real detriment to users as sub-second precision on active time for + signed identifiers is not really necessary. + */ + if (tableSignedIdentifiers != null) { + signedIdentifiers = tableSignedIdentifiers.stream() + .map(tableSignedIdentifier -> { + SignedIdentifier signedIdentifier = toSignedIdentifier(tableSignedIdentifier); + + if (signedIdentifier != null) { + if (signedIdentifier.getAccessPolicy() != null + && signedIdentifier.getAccessPolicy().getStart() != null) { + + signedIdentifier.getAccessPolicy() + .setStart(signedIdentifier.getAccessPolicy() + .getStart().truncatedTo(ChronoUnit.SECONDS)); + } + + if (signedIdentifier.getAccessPolicy() != null + && signedIdentifier.getAccessPolicy().getExpiry() != null) { + + signedIdentifier.getAccessPolicy() + .setExpiry(signedIdentifier.getAccessPolicy() + .getExpiry().truncatedTo(ChronoUnit.SECONDS)); + } + } + + return signedIdentifier; + }) + .collect(Collectors.toList()); + } try { return tablesImplementation.getTables() - .setAccessPolicyWithResponseAsync(tableName, null, null, - tableSignedIdentifiers.stream().map(this::toSignedIdentifier).collect(Collectors.toList()), context) + .setAccessPolicyWithResponseAsync(tableName, null, null, signedIdentifiers, context) .map(response -> new SimpleResponse<>(response, response.getValue())); } catch (RuntimeException e) { return monoError(logger, e); @@ -930,12 +972,20 @@ Mono> setAccessPoliciesWithResponse(List t } 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()) 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 ecd189746b23..631d82ecd655 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 @@ -10,6 +10,7 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.data.tables.models.ListEntitiesOptions; +import com.azure.data.tables.models.TableAccessPolicies; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableEntityUpdateMode; import com.azure.data.tables.models.TableItem; @@ -411,12 +412,11 @@ public Response getEntityWithResponse(String partitionKey, String r * Retrieves details about any stored access policies specified on the table that may be used with Shared Access * Signatures. * - * @return A reactive result containing the HTTP response and the table's - * {@link TableSignedIdentifier access policies}. + * @return The table's {@link TableAccessPolicies access policies}. */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listAccessPolicies() { - return new PagedIterable<>(client.listAccessPolicies()); + @ServiceMethod(returns = ReturnType.SINGLE) + public TableAccessPolicies getAccessPolicies() { + return client.getAccessPolicies().block(); } /** @@ -426,12 +426,11 @@ public PagedIterable listAccessPolicies() { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the HTTP pipeline during the service call. * - * @return A reactive result containing the HTTP response and the table's - * {@link TableSignedIdentifier access policies}. + * @return An HTTP response containing the table's {@link TableAccessPolicies access policies}. */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listAccessPolicies(Duration timeout, Context context) { - return new PagedIterable<>(applyOptionalTimeout(client.listAccessPolicies(context), timeout)); + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAccessPoliciesWithResponse(Duration timeout, Context context) { + return blockWithOptionalTimeout(client.getAccessPoliciesWithResponse(context), timeout); } /** 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 180a167db98a..7e5975d09df1 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 @@ -555,7 +555,6 @@ public Mono setProperties(TableServiceProperties tableServiceProperties) { return this.setPropertiesWithResponse(tableServiceProperties).flatMap(FluxUtil::toMono); } - /** * Sets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin * Resource Sharing) rules. 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 6275166a1a82..2abaf1209b7a 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 @@ -26,6 +26,7 @@ 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.SignedIdentifiersWrapper; import com.azure.data.tables.implementation.models.TableProperties; import com.azure.data.tables.implementation.models.TableServiceErrorException; import com.azure.data.tables.implementation.models.TablesCreateResponse; @@ -238,7 +239,7 @@ Mono setAccessPolicy( @HeaderParam("x-ms-client-request-id") String requestId, @PathParam("table") String table, @QueryParam("comp") String comp, - @BodyParam("application/xml") List tableAcl, + @BodyParam("application/xml") SignedIdentifiersWrapper tableAcl, @HeaderParam("Accept") String accept, Context context); } @@ -725,6 +726,9 @@ 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, @@ -732,7 +736,7 @@ public Mono setAccessPolicyWithResponseAsync( requestId, table, comp, - tableAcl, + tableAclConverted, accept, context); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifiersWrapper.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifiersWrapper.java new file mode 100644 index 000000000000..dacd23ed397a --- /dev/null +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/models/SignedIdentifiersWrapper.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.data.tables.implementation.models; + +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<BlobSignedIdentifier> contained in this wrapper. + * + * @return the List<BlobSignedIdentifier>. + */ + public List items() { + return signedIdentifiers; + } +} diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableAccessPolicies.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableAccessPolicies.java new file mode 100644 index 000000000000..0e96efcb441f --- /dev/null +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableAccessPolicies.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.data.tables.models; + +import com.azure.core.annotation.Immutable; + +import java.util.List; + +/** + * This class contains values which correlate to the access polices set for a specific table. + */ +@Immutable +public final class TableAccessPolicies { + private final List identifiers; + + /** + * Constructs a {@link TableAccessPolicies}. + * + * @param identifiers {@link TableSignedIdentifier TableSignedIdentifiers} associated with the table. + */ + public TableAccessPolicies(List identifiers) { + this.identifiers = identifiers; + } + + /** + * @return the {@link TableSignedIdentifier TableSignedIdentifiers} associated with the table. + */ + public List getIdentifiers() { + return this.identifiers; + } +} diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java index 7f3d377f4b51..d758c9e5c275 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableSignedIdentifier.java @@ -5,6 +5,8 @@ import com.azure.core.annotation.Fluent; +import java.util.Objects; + /** * A signed identifier. */ @@ -13,7 +15,7 @@ public final class TableSignedIdentifier { /* * A unique id */ - private String id; + private final String id; /* * An access policy. @@ -21,25 +23,23 @@ public final class TableSignedIdentifier { private TableAccessPolicy accessPolicy; /** - * Get the unique id. + * Create a {@link TableSignedIdentifier}. * - * @return The id. + * @param id A unique id for this {@link TableSignedIdentifier}. */ - public String getId() { - return this.id; + public TableSignedIdentifier(String id) { + Objects.requireNonNull(id, "'id' cannot be null"); + + this.id = id; } /** - * Set a unique id. - * - * @param id The id to set. + * Get the unique id. * - * @return The updated {@link TableSignedIdentifier} object. + * @return The id. */ - public TableSignedIdentifier setId(String id) { - this.id = id; - - return this; + public String getId() { + return this.id; } /** 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 aea0ed4f5502..c4b349f462fc 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 @@ -13,8 +13,10 @@ import com.azure.core.test.TestBase; import com.azure.core.test.utils.TestResourceNamer; import com.azure.data.tables.models.ListEntitiesOptions; +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.TableSignedIdentifier; import com.azure.data.tables.models.TableTransactionAction; import com.azure.data.tables.models.TableTransactionActionResponse; import com.azure.data.tables.models.TableTransactionActionType; @@ -35,6 +37,7 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -1009,4 +1012,86 @@ public void canUseSasTokenToCreateValidTableClient() { .expectComplete() .verify(); } + + @Test + public void setAndListAccessPolicies() { + OffsetDateTime startTime = OffsetDateTime.of(2021, 12, 12, 0, 0, 0, 0, ZoneOffset.UTC); + OffsetDateTime expiryTime = OffsetDateTime.of(2022, 12, 12, 0, 0, 0, 0, ZoneOffset.UTC); + String permissions = "r"; + TableAccessPolicy tableAccessPolicy = new TableAccessPolicy() + .setStartsOn(startTime) + .setExpiresOn(expiryTime) + .setPermissions(permissions); + String id = "testPolicy"; + TableSignedIdentifier tableSignedIdentifier = new TableSignedIdentifier(id).setAccessPolicy(tableAccessPolicy); + + StepVerifier.create(tableClient.setAccessPoliciesWithResponse(Collections.singletonList(tableSignedIdentifier))) + .assertNext(response -> assertEquals(204, response.getStatusCode())) + .expectComplete() + .verify(); + + StepVerifier.create(tableClient.getAccessPolicies()) + .assertNext(tableAccessPolicies -> { + assertNotNull(tableAccessPolicies); + assertNotNull(tableAccessPolicies.getIdentifiers()); + + TableSignedIdentifier signedIdentifier = tableAccessPolicies.getIdentifiers().get(0); + + assertNotNull(signedIdentifier); + + TableAccessPolicy accessPolicy = signedIdentifier.getAccessPolicy(); + + assertNotNull(accessPolicy); + assertEquals(startTime, accessPolicy.getStartsOn()); + assertEquals(expiryTime, accessPolicy.getExpiresOn()); + assertEquals(permissions, accessPolicy.getPermissions()); + assertEquals(id, signedIdentifier.getId()); + }) + .expectComplete() + .verify(); + } + + @Test + public void setAndListMultipleAccessPolicies() { + OffsetDateTime startTime = OffsetDateTime.of(2021, 12, 12, 0, 0, 0, 0, ZoneOffset.UTC); + OffsetDateTime expiryTime = OffsetDateTime.of(2022, 12, 12, 0, 0, 0, 0, ZoneOffset.UTC); + String permissions = "r"; + TableAccessPolicy tableAccessPolicy = new TableAccessPolicy() + .setStartsOn(startTime) + .setExpiresOn(expiryTime) + .setPermissions(permissions); + String id1 = "testPolicy1"; + String id2 = "testPolicy2"; + List tableSignedIdentifiers = new ArrayList<>(); + tableSignedIdentifiers.add(new TableSignedIdentifier(id1).setAccessPolicy(tableAccessPolicy)); + tableSignedIdentifiers.add(new TableSignedIdentifier(id2).setAccessPolicy(tableAccessPolicy)); + + StepVerifier.create(tableClient.setAccessPoliciesWithResponse(tableSignedIdentifiers)) + .assertNext(response -> assertEquals(204, response.getStatusCode())) + .expectComplete() + .verify(); + + StepVerifier.create(tableClient.getAccessPolicies()) + .assertNext(tableAccessPolicies -> { + assertNotNull(tableAccessPolicies); + assertNotNull(tableAccessPolicies.getIdentifiers()); + + assertEquals(2, tableAccessPolicies.getIdentifiers().size()); + assertEquals(id1, tableAccessPolicies.getIdentifiers().get(0).getId()); + assertEquals(id2, tableAccessPolicies.getIdentifiers().get(1).getId()); + + for (TableSignedIdentifier signedIdentifier : tableAccessPolicies.getIdentifiers()) { + assertNotNull(signedIdentifier); + + TableAccessPolicy accessPolicy = signedIdentifier.getAccessPolicy(); + + assertNotNull(accessPolicy); + assertEquals(startTime, accessPolicy.getStartsOn()); + assertEquals(expiryTime, accessPolicy.getExpiresOn()); + assertEquals(permissions, accessPolicy.getPermissions()); + } + }) + .expectComplete() + .verify(); + } } 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 b94b25f1f855..c3268f80ae8d 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 @@ -13,6 +13,8 @@ import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableEntity; 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.TableAccountSasPermission; import com.azure.data.tables.sas.TableAccountSasResourceType; import com.azure.data.tables.sas.TableAccountSasService; @@ -415,4 +417,27 @@ public void canUseSasTokenToCreateValidTableClient() { .expectComplete() .verify(); } + + @Test + public void getProperties() { + TableServiceProperties properties = serviceClient.getProperties().block(); + + assertNotNull(properties); + assertNotNull(properties.getCorsRules()); + assertEquals(1, properties.getCorsRules().size()); + assertNotNull(properties.getCorsRules().get(0)); + assertNotNull(properties.getHourMetrics()); + assertNotNull(properties.getMinuteMetrics()); + assertNotNull(properties.getLogging()); + } + + @Test + public void getStatistics() { + TableServiceStatistics statistics = serviceClient.getStatistics().block(); + + assertNotNull(statistics); + assertNotNull(statistics.getGeoReplication()); + assertNotNull(statistics.getGeoReplication().getStatus()); + assertNotNull(statistics.getGeoReplication().getLastSyncTime()); + } } diff --git a/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListAccessPolicies.json b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListAccessPolicies.json new file mode 100644 index 000000000000..c2b487fbe7fa --- /dev/null +++ b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListAccessPolicies.json @@ -0,0 +1,70 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.table.core.windows.net/Tables", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "dcafda0f-be10-4d42-adb4-2cd6e8f1b4a2", + "Content-Type" : "application/json;odata=nometadata" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "X-Content-Type-Options" : "nosniff", + "retry-after" : "0", + "StatusCode" : "204", + "Date" : "Tue, 08 Jun 2021 22:37:47 GMT", + "Cache-Control" : "no-cache", + "DataServiceId" : "https://tablesstoragetests.table.core.windows.net/Tables('tablename62751f1d')", + "x-ms-request-id" : "2639e140-e002-0076-32b6-5c5add000000", + "x-ms-client-request-id" : "dcafda0f-be10-4d42-adb4-2cd6e8f1b4a2", + "Preference-Applied" : "return-no-content", + "Location" : "https://tablesstoragetests.table.core.windows.net/Tables('tablename62751f1d')" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.table.core.windows.net/tablename62751f1d?comp=acl", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "b1274fd8-e63e-46de-99ac-6813272ecc3a", + "Content-Type" : "application/xml" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "2639e17c-e002-0076-65b6-5c5add000000", + "x-ms-client-request-id" : "b1274fd8-e63e-46de-99ac-6813272ecc3a", + "Date" : "Tue, 08 Jun 2021 22:37:48 GMT" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.table.core.windows.net/tablename62751f1d?comp=acl", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "4ff7b815-5be5-494a-901d-4ada60a8d895" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "2639e1af-e002-0076-16b6-5c5add000000", + "Body" : "testPolicy2021-12-12T00:00:00.0000000Z2022-12-12T00:00:00.0000000Zr", + "x-ms-client-request-id" : "4ff7b815-5be5-494a-901d-4ada60a8d895", + "Date" : "Tue, 08 Jun 2021 22:37:48 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "tablename62751f1d" ] +} \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListMultipleAccessPolicies.json b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListMultipleAccessPolicies.json new file mode 100644 index 000000000000..13a3f632f241 --- /dev/null +++ b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableAsyncClientTest.setAndListMultipleAccessPolicies.json @@ -0,0 +1,70 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "https://REDACTED.table.core.windows.net/Tables", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "e525883a-185b-4f86-a587-0ee72dd66428", + "Content-Type" : "application/json;odata=nometadata" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "X-Content-Type-Options" : "nosniff", + "retry-after" : "0", + "StatusCode" : "204", + "Date" : "Wed, 09 Jun 2021 16:41:46 GMT", + "Cache-Control" : "no-cache", + "DataServiceId" : "https://tablesstoragetests.table.core.windows.net/Tables('tablename75432233')", + "x-ms-request-id" : "9a29f259-6002-0045-024e-5d03f0000000", + "x-ms-client-request-id" : "e525883a-185b-4f86-a587-0ee72dd66428", + "Preference-Applied" : "return-no-content", + "Location" : "https://tablesstoragetests.table.core.windows.net/Tables('tablename75432233')" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.table.core.windows.net/tablename75432233?comp=acl", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "84daf1aa-c1db-4fa9-896c-7a73baaec8ef", + "Content-Type" : "application/xml" + }, + "Response" : { + "content-length" : "0", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "204", + "x-ms-request-id" : "9a29f27c-6002-0045-224e-5d03f0000000", + "x-ms-client-request-id" : "84daf1aa-c1db-4fa9-896c-7a73baaec8ef", + "Date" : "Wed, 09 Jun 2021 16:41:46 GMT" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.table.core.windows.net/tablename75432233?comp=acl", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "8a9badde-cb39-4d9c-9cac-4eab21923603" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "9a29f2a4-6002-0045-464e-5d03f0000000", + "Body" : "testPolicy12021-12-12T00:00:00.0000000Z2022-12-12T00:00:00.0000000ZrtestPolicy22021-12-12T00:00:00.0000000Z2022-12-12T00:00:00.0000000Zr", + "x-ms-client-request-id" : "8a9badde-cb39-4d9c-9cac-4eab21923603", + "Date" : "Wed, 09 Jun 2021 16:41:46 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "tablename75432233" ] +} \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getProperties.json b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getProperties.json new file mode 100644 index 000000000000..f7c85c843553 --- /dev/null +++ b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getProperties.json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.table.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "ab32db33-e94b-4739-99c9-8a8362ccdf5d" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "fadb7285-5002-006f-12da-5c76b5000000", + "Body" : "1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalse", + "x-ms-client-request-id" : "ab32db33-e94b-4739-99c9-8a8362ccdf5d", + "Date" : "Wed, 09 Jun 2021 02:52:51 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ ] +} \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getStatistics.json b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getStatistics.json new file mode 100644 index 000000000000..f68b4668e9cc --- /dev/null +++ b/sdk/tables/azure-data-tables/src/test/resources/session-records/TableServiceAsyncClientTest.getStatistics.json @@ -0,0 +1,25 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://REDACTED.table.core.windows.net?restype=service&comp=stats", + "Headers" : { + "x-ms-version" : "2019-02-02", + "User-Agent" : "azsdk-java-azure-data-tables/12.0.0-beta.8 (11.0.6; Windows 10; 10.0)", + "x-ms-client-request-id" : "6217e123-d132-449a-a2af-3769aa73707e" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-02-02", + "Server" : "Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "f9737ddc-6002-006c-2ad9-5c75b2000000", + "Body" : "liveTue, 04 May 2021 23:33:28 GMT", + "x-ms-client-request-id" : "6217e123-d132-449a-a2af-3769aa73707e", + "Date" : "Wed, 09 Jun 2021 02:45:34 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ ] +} diff --git a/sdk/tables/azure-data-tables/swagger/README.md b/sdk/tables/azure-data-tables/swagger/README.md index ca3855ff4887..8a5b17647479 100644 --- a/sdk/tables/azure-data-tables/swagger/README.md +++ b/sdk/tables/azure-data-tables/swagger/README.md @@ -19,7 +19,7 @@ autorest --java --use=C:/work/autorest.java ``` ### Code generation settings -``` yaml +```yaml 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 java: true output-folder: ..\