Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-file-share/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ public final class SharePropertiesInternal implements XmlSerializable<SharePrope
@Generated
private Boolean enableSmbDirectoryLease;

/*
* The CreationTime property.
*/
@Generated
private DateTimeRfc1123 creationTime;

/*
* Dictionary of <string>
*/
Expand Down Expand Up @@ -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 &lt;string&gt;.
*
Expand Down Expand Up @@ -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<String, String> entry : this.metadata.entrySet()) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -498,6 +499,7 @@ public static Response<ShareInfo> mapToShareInfoResponse(Response<?> response) {
mapGetPropertiesResponse(ResponseBase<SharesGetPropertiesHeaders, Void> response) {
SharesGetPropertiesHeaders headers = response.getDeserializedHeaders();
ShareProperties shareProperties = new ShareProperties().setETag(headers.getETag())
.setCreationTime(headers.getXMsShareCreationTime())
.setLastModified(headers.getLastModified())
.setMetadata(headers.getXMsMeta())
.setQuota(headers.getXMsShareQuota())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -25,6 +24,11 @@
*/
@Fluent
public final class ShareProperties implements XmlSerializable<ShareProperties> {
/*
* The creationTime property.
*/
private DateTimeRfc1123 creationTime;

/*
* The lastModified property.
*/
Expand Down Expand Up @@ -174,6 +178,33 @@ public final class ShareProperties implements XmlSerializable<ShareProperties> {
public ShareProperties() {
}

/**
* Get the creationTime property: The creation time of the share.
*
* @return the creationTime value.
*/
public OffsetDateTime getCreationTime() {
Comment thread
ibrandes marked this conversation as resolved.
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.
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShareItem> 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<Arguments> listSharesWithFilterSupplier() {
return Stream.of(Arguments.of(new ListSharesOptions(), 3, false, true, false),
Arguments.of(new ListSharesOptions().setIncludeMetadata(true), 3, true, true, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arguments> listSharesWithFilterSupplier() {
return Stream.of(Arguments.of(new ListSharesOptions(), 3, false, true, false),
Arguments.of(new ListSharesOptions().setIncludeMetadata(true), 3, true, true, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SharesGetPropertiesHeaders, Void> response = new ResponseBase<>(null, 200, new HttpHeaders(), null,
new SharesGetPropertiesHeaders(new HttpHeaders()).setXMsShareCreationTime(creationTime)
.setXMsShareQuota(1));
assertEquals(creationTime, ModelHelper.mapGetPropertiesResponse(response).getValue().getCreationTime());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion sdk/storage/azure-storage-file-share/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading