diff --git a/sdk/storage/azure-storage-file-share/CHANGELOG.md b/sdk/storage/azure-storage-file-share/CHANGELOG.md index 0948c61e756b4..8d9fb53f1be76 100644 --- a/sdk/storage/azure-storage-file-share/CHANGELOG.md +++ b/sdk/storage/azure-storage-file-share/CHANGELOG.md @@ -3,6 +3,8 @@ ## 12.32.0-beta.2 (Unreleased) ### Features Added +- Added `ShareProperties.getCreationTime()` and `ShareProperties.setCreationTime(OffsetDateTime)` to expose the share + creation time returned in list and get properties responses. ### Breaking Changes diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 95f4e88276e86..92a17c9561e63 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/storage/azure-storage-file-share", - "Tag": "java/storage/azure-storage-file-share_c861318b2a" + "Tag": "java/storage/azure-storage-file-share_679d0d8151" } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharePropertiesInternal.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharePropertiesInternal.java index b59ff963df07d..aa4782513a182 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharePropertiesInternal.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharePropertiesInternal.java @@ -189,6 +189,12 @@ public final class SharePropertiesInternal implements XmlSerializable */ @@ -847,6 +853,35 @@ public SharePropertiesInternal setEnableSmbDirectoryLease(Boolean enableSmbDirec return this; } + /** + * Get the creationTime property: The CreationTime property. + * + * @return the creationTime value. + */ + @Generated + public OffsetDateTime getCreationTime() { + if (this.creationTime == null) { + return null; + } + return this.creationTime.getDateTime(); + } + + /** + * Set the creationTime property: The CreationTime property. + * + * @param creationTime the creationTime value to set. + * @return the SharePropertiesInternal object itself. + */ + @Generated + public SharePropertiesInternal setCreationTime(OffsetDateTime creationTime) { + if (creationTime == null) { + this.creationTime = null; + } else { + this.creationTime = new DateTimeRfc1123(creationTime); + } + return this; + } + /** * Get the metadata property: Dictionary of <string>. * @@ -913,6 +948,7 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt xmlWriter.writeStringElement("NextAllowedProvisionedBandwidthDowngradeTime", Objects.toString(this.nextAllowedProvisionedBandwidthDowngradeTime, null)); xmlWriter.writeBooleanElement("EnableSmbDirectoryLease", this.enableSmbDirectoryLease); + xmlWriter.writeStringElement("Creation-Time", Objects.toString(this.creationTime, null)); if (this.metadata != null) { xmlWriter.writeStartElement("Metadata"); for (Map.Entry entry : this.metadata.entrySet()) { @@ -1028,6 +1064,8 @@ public static SharePropertiesInternal fromXml(XmlReader xmlReader, String rootEl } else if ("EnableSmbDirectoryLease".equals(elementName.getLocalPart())) { deserializedSharePropertiesInternal.enableSmbDirectoryLease = reader.getNullableElement(Boolean::parseBoolean); + } else if ("Creation-Time".equals(elementName.getLocalPart())) { + deserializedSharePropertiesInternal.creationTime = reader.getNullableElement(DateTimeRfc1123::new); } else if ("Metadata".equals(elementName.getLocalPart())) { while (reader.nextElement() != XmlToken.END_ELEMENT) { if (deserializedSharePropertiesInternal.metadata == null) { diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharesGetPropertiesHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharesGetPropertiesHeaders.java index 4596100989082..170908e40472c 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharesGetPropertiesHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SharesGetPropertiesHeaders.java @@ -148,6 +148,12 @@ public final class SharesGetPropertiesHeaders { @Generated private Boolean xMsEnableSnapshotVirtualDirectoryAccess; + /* + * The x-ms-share-creation-time property. + */ + @Generated + private DateTimeRfc1123 xMsShareCreationTime; + /* * The x-ms-share-paid-bursting-enabled property. */ @@ -236,6 +242,9 @@ public final class SharesGetPropertiesHeaders { private static final HttpHeaderName X_MS_ENABLE_SNAPSHOT_VIRTUAL_DIRECTORY_ACCESS = HttpHeaderName.fromString("x-ms-enable-snapshot-virtual-directory-access"); + private static final HttpHeaderName X_MS_SHARE_CREATION_TIME + = HttpHeaderName.fromString("x-ms-share-creation-time"); + private static final HttpHeaderName X_MS_SHARE_PAID_BURSTING_ENABLED = HttpHeaderName.fromString("x-ms-share-paid-bursting-enabled"); @@ -360,6 +369,12 @@ public SharesGetPropertiesHeaders(HttpHeaders rawHeaders) { } else { this.xMsEnableSnapshotVirtualDirectoryAccess = null; } + String xMsShareCreationTime = rawHeaders.getValue(X_MS_SHARE_CREATION_TIME); + if (xMsShareCreationTime != null) { + this.xMsShareCreationTime = new DateTimeRfc1123(xMsShareCreationTime); + } else { + this.xMsShareCreationTime = null; + } String xMsSharePaidBurstingEnabled = rawHeaders.getValue(X_MS_SHARE_PAID_BURSTING_ENABLED); if (xMsSharePaidBurstingEnabled != null) { this.xMsSharePaidBurstingEnabled = Boolean.parseBoolean(xMsSharePaidBurstingEnabled); @@ -920,6 +935,35 @@ public Boolean isXMsEnableSnapshotVirtualDirectoryAccess() { return this; } + /** + * Get the xMsShareCreationTime property: The x-ms-share-creation-time property. + * + * @return the xMsShareCreationTime value. + */ + @Generated + public OffsetDateTime getXMsShareCreationTime() { + if (this.xMsShareCreationTime == null) { + return null; + } + return this.xMsShareCreationTime.getDateTime(); + } + + /** + * Set the xMsShareCreationTime property: The x-ms-share-creation-time property. + * + * @param xMsShareCreationTime the xMsShareCreationTime value to set. + * @return the SharesGetPropertiesHeaders object itself. + */ + @Generated + public SharesGetPropertiesHeaders setXMsShareCreationTime(OffsetDateTime xMsShareCreationTime) { + if (xMsShareCreationTime == null) { + this.xMsShareCreationTime = null; + } else { + this.xMsShareCreationTime = new DateTimeRfc1123(xMsShareCreationTime); + } + return this; + } + /** * Get the xMsSharePaidBurstingEnabled property: The x-ms-share-paid-bursting-enabled property. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/ModelHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/ModelHelper.java index a6830e7cb854a..0daba31f4fcb0 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/ModelHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/ModelHelper.java @@ -213,6 +213,7 @@ public static ShareItem populateShareItem(ShareItemInternal shareItemInternal) { */ public static ShareProperties populateShareProperties(SharePropertiesInternal sharePropertiesInternal) { ShareProperties properties = new ShareProperties(); + properties.setCreationTime(sharePropertiesInternal.getCreationTime()); properties.setLastModified(sharePropertiesInternal.getLastModified()); properties.setETag(sharePropertiesInternal.getETag()); properties.setQuota(sharePropertiesInternal.getQuota()); @@ -498,6 +499,7 @@ public static Response mapToShareInfoResponse(Response response) { mapGetPropertiesResponse(ResponseBase response) { SharesGetPropertiesHeaders headers = response.getDeserializedHeaders(); ShareProperties shareProperties = new ShareProperties().setETag(headers.getETag()) + .setCreationTime(headers.getXMsShareCreationTime()) .setLastModified(headers.getLastModified()) .setMetadata(headers.getXMsMeta()) .setQuota(headers.getXMsShareQuota()) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareProperties.java index 9293d4e89baee..3d55ab16a53c0 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareProperties.java @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.storage.file.share.models; @@ -25,6 +24,11 @@ */ @Fluent public final class ShareProperties implements XmlSerializable { + /* + * The creationTime property. + */ + private DateTimeRfc1123 creationTime; + /* * The lastModified property. */ @@ -174,6 +178,33 @@ public final class ShareProperties implements XmlSerializable { public ShareProperties() { } + /** + * Get the creationTime property: The creation time of the share. + * + * @return the creationTime value. + */ + public OffsetDateTime getCreationTime() { + if (this.creationTime == null) { + return null; + } + return this.creationTime.getDateTime(); + } + + /** + * Set the creationTime property: The creation time of the share. + * + * @param creationTime the creationTime value to set. + * @return the ShareProperties object itself. + */ + public ShareProperties setCreationTime(OffsetDateTime creationTime) { + if (creationTime == null) { + this.creationTime = null; + } else { + this.creationTime = new DateTimeRfc1123(creationTime); + } + return this; + } + /** * Get the lastModified property: The lastModified property. * @@ -836,6 +867,7 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt rootElementName = CoreUtils.isNullOrEmpty(rootElementName) ? "ShareProperties" : rootElementName; xmlWriter.writeStartElement(rootElementName); + xmlWriter.writeStringElement("Creation-Time", Objects.toString(this.creationTime, null)); xmlWriter.writeStringElement("Last-Modified", Objects.toString(this.lastModified, null)); xmlWriter.writeStringElement("Etag", this.eTag); xmlWriter.writeIntElement("Quota", this.quota); @@ -897,7 +929,9 @@ public static ShareProperties fromXml(XmlReader xmlReader, String rootElementNam while (reader.nextElement() != XmlToken.END_ELEMENT) { QName elementName = reader.getElementName(); - if ("Last-Modified".equals(elementName.getLocalPart())) { + if ("Creation-Time".equals(elementName.getLocalPart())) { + deserializedShareProperties.creationTime = reader.getNullableElement(DateTimeRfc1123::new); + } else if ("Last-Modified".equals(elementName.getLocalPart())) { deserializedShareProperties.lastModified = reader.getNullableElement(DateTimeRfc1123::new); } else if ("Etag".equals(elementName.getLocalPart())) { deserializedShareProperties.eTag = reader.getStringElement(); diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceApiTests.java index be1c74899980b..4c1d004705ff7 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceApiTests.java @@ -173,6 +173,19 @@ public void listSharesWithFilter(ListSharesOptions options, int limits, boolean assertTrue(includeDeleted || !shares.hasNext()); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void listSharesIncludesCreationTime() { + primaryFileServiceClient.createShare(shareName); + + Iterator shares + = primaryFileServiceClient.listShares(new ListSharesOptions().setPrefix(shareName), null, null).iterator(); + assertTrue(shares.hasNext()); + ShareItem firstShare = shares.next(); + assertEquals(shareName, firstShare.getName()); + assertNotNull(firstShare.getProperties().getCreationTime()); + } + private static Stream listSharesWithFilterSupplier() { return Stream.of(Arguments.of(new ListSharesOptions(), 3, false, true, false), Arguments.of(new ListSharesOptions().setIncludeMetadata(true), 3, true, true, false), diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncApiTests.java index 7f4daae7fe2b1..5203786b41cc6 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileServiceAsyncApiTests.java @@ -173,6 +173,19 @@ public void listSharesWithFilter(ListSharesOptions options, int limits, boolean assertTrue(testShares.isEmpty()); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void listSharesIncludesCreationTime() { + StepVerifier + .create(primaryFileServiceAsyncClient.createShare(shareName) + .thenMany(primaryFileServiceAsyncClient.listShares(new ListSharesOptions().setPrefix(shareName)))) + .assertNext(firstShare -> { + assertEquals(shareName, firstShare.getName()); + assertNotNull(firstShare.getProperties().getCreationTime()); + }) + .verifyComplete(); + } + protected static Stream listSharesWithFilterSupplier() { return Stream.of(Arguments.of(new ListSharesOptions(), 3, false, true, false), Arguments.of(new ListSharesOptions().setIncludeMetadata(true), 3, true, true, false), diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ModelTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ModelTests.java index b29c9b05f1176..dad2c5c179224 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ModelTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ModelTests.java @@ -3,11 +3,18 @@ package com.azure.storage.file.share; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.rest.ResponseBase; +import com.azure.storage.file.share.implementation.models.SharePropertiesInternal; +import com.azure.storage.file.share.implementation.models.SharesGetPropertiesHeaders; +import com.azure.storage.file.share.implementation.util.ModelHelper; import com.azure.storage.file.share.models.NtfsFileAttributes; import com.azure.storage.file.share.models.ShareFileUploadRangeOptions; +import com.azure.storage.file.share.models.ShareProperties; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; +import java.time.OffsetDateTime; import java.util.EnumSet; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -61,4 +68,20 @@ void uploadZeroLengthFails() { assertThrows(IllegalArgumentException.class, () -> new ShareFileUploadRangeOptions(new ByteArrayInputStream(new byte[0]), 0)); } + + @Test + void shareCreationTimeIsMappedFromResponses() { + OffsetDateTime creationTime = OffsetDateTime.parse("2026-10-01T12:00:00Z"); + ShareProperties shareProperties = new ShareProperties().setCreationTime(creationTime); + + assertEquals(creationTime, shareProperties.getCreationTime()); + assertEquals(creationTime, + ModelHelper.populateShareProperties(new SharePropertiesInternal().setCreationTime(creationTime)) + .getCreationTime()); + + ResponseBase response = new ResponseBase<>(null, 200, new HttpHeaders(), null, + new SharesGetPropertiesHeaders(new HttpHeaders()).setXMsShareCreationTime(creationTime) + .setXMsShareQuota(1)); + assertEquals(creationTime, ModelHelper.mapGetPropertiesResponse(response).getValue().getCreationTime()); + } } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareApiTests.java index fc0b3b5ce8161..4f83bfc51cd26 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareApiTests.java @@ -537,6 +537,16 @@ public void getProperties() { assertEquals(1, getPropertiesResponse.getValue().getQuota()); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void getPropertiesIncludesCreationTime() { + primaryShareClient.create(); + + ShareProperties properties = primaryShareClient.getProperties(); + assertNotNull(properties.getCreationTime()); + assertNotNull(properties.getETag()); + } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-11-04") @Test public void getPropertiesOAuth() { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncApiTests.java index 188797c2bba17..f79c2f6a51df5 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAsyncApiTests.java @@ -341,6 +341,17 @@ public void getProperties() { }).verifyComplete(); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void getPropertiesIncludesCreationTime() { + StepVerifier.create(primaryShareAsyncClient.create().then(primaryShareAsyncClient.getProperties())) + .assertNext(properties -> { + assertNotNull(properties.getCreationTime()); + assertNotNull(properties.getETag()); + }) + .verifyComplete(); + } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-11-04") @Test public void getPropertiesOAuth() { diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 8a6b604a43fbf..aad699d839edc 100644 --- a/sdk/storage/azure-storage-file-share/swagger/README.md +++ b/sdk/storage/azure-storage-file-share/swagger/README.md @@ -16,7 +16,7 @@ autorest ### Code generation settings ``` yaml use: '@autorest/java@4.1.63' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/15d7f54a5389d5906ffb4e56bb2f38fe5525c0d3/specification/storage/data-plane/Microsoft.FileStorage/stable/2026-06-06/file.json +input-file: https://raw.githubusercontent.com/browndav-msft/azure-rest-api-specs/b6915c1d71519f3e720def065c4710bd96385d25/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share @@ -249,6 +249,7 @@ directive: $.SharePropertiesInternal.properties.Metadata = { "$ref": path }; } $.SharePropertiesInternal.properties.Etag["x-ms-client-name"] = "eTag"; + $.SharePropertiesInternal.properties.CreationTime.xml = {"name": "Creation-Time"}; ``` ### ShareUsageBytes