Skip to content

Commit

Permalink
Stg94 Snapshot management support via REST for NFS shares (#39739)
Browse files Browse the repository at this point in the history
* Stg93 Snapshot management support via REST for NFS shares (Cleaned) (#38845)

* swagger and hookup

* everything

* style

* removing preprod from test environment suffix

* adding better descriptions

* renaming

* re-recording

* updating required service version for tests
  • Loading branch information
ibrandes authored Apr 22, 2024
1 parent c40ac4b commit a46fdd6
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ Mono<Response<ShareInfo>> createWithResponse(ShareCreateOptions options, Context
enabledProtocol = "".equals(enabledProtocol) ? null : enabledProtocol;
return azureFileStorageClient.getShares()
.createWithResponseAsync(shareName, null, options.getMetadata(), options.getQuotaInGb(),
options.getAccessTier(), enabledProtocol, options.getRootSquash(), context)
options.getAccessTier(), enabledProtocol, options.getRootSquash(),
options.isSnapshotVirtualDirectoryAccessEnabled(), context)
.map(this::mapToShareInfoResponse);
}

Expand Down Expand Up @@ -933,7 +934,8 @@ Mono<Response<ShareInfo>> setPropertiesWithResponse(ShareSetPropertiesOptions op
? new ShareRequestConditions() : options.getRequestConditions();
context = context == null ? Context.NONE : context;
return azureFileStorageClient.getShares().setPropertiesWithResponseAsync(shareName, null,
options.getQuotaInGb(), options.getAccessTier(), requestConditions.getLeaseId(), options.getRootSquash(), context)
options.getQuotaInGb(), options.getAccessTier(), requestConditions.getLeaseId(), options.getRootSquash(),
options.isSnapshotVirtualDirectoryAccessEnabled(), context)
.map(this::mapToShareInfoResponse);
}

Expand Down Expand Up @@ -2308,7 +2310,8 @@ private Response<ShareProperties> mapGetPropertiesResponse(
.setAccessTierChangeTime(headers.getXMsAccessTierChangeTime())
.setAccessTierTransitionState(headers.getXMsAccessTierTransitionState())
.setProtocols(ModelHelper.parseShareProtocols(headers.getXMsEnabledProtocols()))
.setRootSquash(headers.getXMsRootSquash());
.setRootSquash(headers.getXMsRootSquash())
.setEnableSnapshotVirtualDirectoryAccess(headers.isXMsEnableSnapshotVirtualDirectoryAccess());

return new SimpleResponse<>(response, shareProperties);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public final class SharePropertiesInternal {
@JsonProperty(value = "RootSquash")
private ShareRootSquash rootSquash;

/*
* The EnableSnapshotVirtualDirectoryAccess property.
*/
@JsonProperty(value = "EnableSnapshotVirtualDirectoryAccess")
private Boolean enableSnapshotVirtualDirectoryAccess;

/*
* Dictionary of <string>
*/
Expand Down Expand Up @@ -526,6 +532,27 @@ public SharePropertiesInternal setRootSquash(ShareRootSquash rootSquash) {
return this;
}

/**
* Get the enableSnapshotVirtualDirectoryAccess property: The EnableSnapshotVirtualDirectoryAccess property.
*
* @return the enableSnapshotVirtualDirectoryAccess value.
*/
public Boolean isEnableSnapshotVirtualDirectoryAccess() {
return this.enableSnapshotVirtualDirectoryAccess;
}

/**
* Set the enableSnapshotVirtualDirectoryAccess property: The EnableSnapshotVirtualDirectoryAccess property.
*
* @param enableSnapshotVirtualDirectoryAccess the enableSnapshotVirtualDirectoryAccess value to set.
* @return the SharePropertiesInternal object itself.
*/
public SharePropertiesInternal setEnableSnapshotVirtualDirectoryAccess(
Boolean enableSnapshotVirtualDirectoryAccess) {
this.enableSnapshotVirtualDirectoryAccess = enableSnapshotVirtualDirectoryAccess;
return this;
}

/**
* Get the metadata property: Dictionary of &lt;string&gt;.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public final class SharesGetPropertiesHeaders {
@JsonProperty(value = "x-ms-access-tier-change-time")
private DateTimeRfc1123 xMsAccessTierChangeTime;

/*
* The x-ms-enable-snapshot-virtual-directory-access property.
*/
@JsonProperty(value = "x-ms-enable-snapshot-virtual-directory-access")
private Boolean xMsEnableSnapshotVirtualDirectoryAccess;

/*
* The x-ms-meta- property.
*/
Expand Down Expand Up @@ -158,6 +164,9 @@ public final class SharesGetPropertiesHeaders {
private static final HttpHeaderName X_MS_ACCESS_TIER_CHANGE_TIME =
HttpHeaderName.fromString("x-ms-access-tier-change-time");

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_PROVISIONED_INGRESS_MBPS =
HttpHeaderName.fromString("x-ms-share-provisioned-ingress-mbps");

Expand Down Expand Up @@ -215,6 +224,12 @@ public SharesGetPropertiesHeaders(HttpHeaders rawHeaders) {
if (xMsAccessTierChangeTime != null) {
this.xMsAccessTierChangeTime = new DateTimeRfc1123(xMsAccessTierChangeTime);
}
String xMsEnableSnapshotVirtualDirectoryAccess =
rawHeaders.getValue(X_MS_ENABLE_SNAPSHOT_VIRTUAL_DIRECTORY_ACCESS);
if (xMsEnableSnapshotVirtualDirectoryAccess != null) {
this.xMsEnableSnapshotVirtualDirectoryAccess =
Boolean.parseBoolean(xMsEnableSnapshotVirtualDirectoryAccess);
}
String date = rawHeaders.getValue(HttpHeaderName.DATE);
if (date != null) {
this.date = new DateTimeRfc1123(date);
Expand Down Expand Up @@ -415,6 +430,29 @@ public SharesGetPropertiesHeaders setXMsAccessTierChangeTime(OffsetDateTime xMsA
return this;
}

/**
* Get the xMsEnableSnapshotVirtualDirectoryAccess property: The x-ms-enable-snapshot-virtual-directory-access
* property.
*
* @return the xMsEnableSnapshotVirtualDirectoryAccess value.
*/
public Boolean isXMsEnableSnapshotVirtualDirectoryAccess() {
return this.xMsEnableSnapshotVirtualDirectoryAccess;
}

/**
* Set the xMsEnableSnapshotVirtualDirectoryAccess property: The x-ms-enable-snapshot-virtual-directory-access
* property.
*
* @param xMsEnableSnapshotVirtualDirectoryAccess the xMsEnableSnapshotVirtualDirectoryAccess value to set.
* @return the SharesGetPropertiesHeaders object itself.
*/
public SharesGetPropertiesHeaders setXMsEnableSnapshotVirtualDirectoryAccess(
Boolean xMsEnableSnapshotVirtualDirectoryAccess) {
this.xMsEnableSnapshotVirtualDirectoryAccess = xMsEnableSnapshotVirtualDirectoryAccess;
return this;
}

/**
* Get the xMsMeta property: The x-ms-meta- property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public static ShareProperties populateShareProperties(SharePropertiesInternal sh
properties.setRootSquash(sharePropertiesInternal.getRootSquash());
properties.setMetadata(sharePropertiesInternal.getMetadata());
properties.setProvisionedBandwidthMiBps(sharePropertiesInternal.getProvisionedBandwidthMiBps());
properties.setEnableSnapshotVirtualDirectoryAccess(sharePropertiesInternal.isEnableSnapshotVirtualDirectoryAccess());

return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public final class ShareProperties {
*/
private Integer provisionedBandwidthMiBps;

/*
* The EnableSnapshotVirtualDirectoryAccess property.
*/
@JsonProperty(value = "EnableSnapshotVirtualDirectoryAccess")
private Boolean enableSnapshotVirtualDirectoryAccess;

/**
* Get the lastModified property: The lastModified property.
*
Expand Down Expand Up @@ -568,4 +574,32 @@ public ShareProperties setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

/**
* Get the enableSnapshotVirtualDirectoryAccess property:
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
*
* @return the enableSnapshotVirtualDirectoryAccess value.
*/
public Boolean isEnableSnapshotVirtualDirectoryAccess() {
return this.enableSnapshotVirtualDirectoryAccess;
}

/**
* Set the enableSnapshotVirtualDirectoryAccess property:
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
*
* @param enableSnapshotVirtualDirectoryAccess the enableSnapshotVirtualDirectoryAccess value to set.
* @return the ShareProperties object itself.
*/
public ShareProperties setEnableSnapshotVirtualDirectoryAccess(
Boolean enableSnapshotVirtualDirectoryAccess) {
this.enableSnapshotVirtualDirectoryAccess = enableSnapshotVirtualDirectoryAccess;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ShareCreateOptions {
private ShareAccessTier accessTier;
private ShareProtocols protocols;
private ShareRootSquash rootSquash;
private Boolean enableSnapshotVirtualDirectoryAccess;

/**
* @return Size in GB to limit the share's growth.
Expand Down Expand Up @@ -102,4 +103,29 @@ public ShareCreateOptions setRootSquash(ShareRootSquash rootSquash) {
this.rootSquash = rootSquash;
return this;
}

/**
* Get the enableSnapshotVirtualDirectoryAccess property: The EnableSnapshotVirtualDirectoryAccess property.
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
* @return the enableSnapshotVirtualDirectoryAccess value.
*/
public Boolean isSnapshotVirtualDirectoryAccessEnabled() {
return enableSnapshotVirtualDirectoryAccess;
}

/**
* Set the enableSnapshotVirtualDirectoryAccess property:
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
* @param snapshotVirtualDirectoryAccessEnabled the enableSnapshotVirtualDirectoryAccess value to set.
* @return the ShareCreateOptions object itself.
*/
public ShareCreateOptions setSnapshotVirtualDirectoryAccessEnabled(
Boolean snapshotVirtualDirectoryAccessEnabled) {
this.enableSnapshotVirtualDirectoryAccess = snapshotVirtualDirectoryAccessEnabled;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ShareSetPropertiesOptions {
private ShareAccessTier accessTier;
private ShareRootSquash rootSquash;
private ShareRequestConditions requestConditions;
private Boolean enableSnapshotVirtualDirectoryAccess;

/**
* @return {@link ShareAccessTier}
Expand Down Expand Up @@ -82,4 +83,31 @@ public ShareSetPropertiesOptions setRequestConditions(ShareRequestConditions req
this.requestConditions = requestConditions;
return this;
}

/**
* Get the enableSnapshotVirtualDirectoryAccess property: The EnableSnapshotVirtualDirectoryAccess property.
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
*
* @return the enableSnapshotVirtualDirectoryAccess value.
*/
public Boolean isSnapshotVirtualDirectoryAccessEnabled() {
return enableSnapshotVirtualDirectoryAccess;
}

/**
* Set the enableSnapshotVirtualDirectoryAccess property: The EnableSnapshotVirtualDirectoryAccess property.
* Optional. Supported in version 2023-08-03 and above.
* Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
* If not specified, the default is true.
*
* @param snapshotVirtualDirectoryAccessEnabled the enableSnapshotVirtualDirectoryAccess value to set.
* @return the ShareSetPropertiesOptions object itself.
*/
public ShareSetPropertiesOptions setSnapshotVirtualDirectoryAccessEnabled(
Boolean snapshotVirtualDirectoryAccessEnabled) {
this.enableSnapshotVirtualDirectoryAccess = snapshotVirtualDirectoryAccessEnabled;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.test.shared.extensions.PlaybackOnly;
import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion;
import com.azure.storage.file.share.implementation.util.ModelHelper;
import com.azure.storage.file.share.models.ListSharesOptions;
import com.azure.storage.file.share.models.ShareAccessTier;
import com.azure.storage.file.share.models.ShareCorsRule;
Expand All @@ -17,6 +19,7 @@
import com.azure.storage.file.share.models.ShareMetrics;
import com.azure.storage.file.share.models.ShareProperties;
import com.azure.storage.file.share.models.ShareProtocolSettings;
import com.azure.storage.file.share.models.ShareProtocols;
import com.azure.storage.file.share.models.ShareRetentionPolicy;
import com.azure.storage.file.share.models.ShareServiceProperties;
import com.azure.storage.file.share.models.ShareSmbSettings;
Expand Down Expand Up @@ -415,4 +418,20 @@ public void perCallPolicy() {
Response<ShareServiceProperties> response = serviceClient.getPropertiesWithResponse(null, null);
assertEquals(response.getHeaders().getValue(X_MS_VERSION), "2017-11-09");
}

@RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04")
@Test
public void listSharesEnableSnapshotVirtualDirectoryAccess() {
ShareCreateOptions options = new ShareCreateOptions();
ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL);
options.setProtocols(protocols);
options.setSnapshotVirtualDirectoryAccessEnabled(true);

ShareClient shareClient = primaryFileServiceClient.getShareClient(generateShareName());
shareClient.createWithResponse(options, null, null);

ShareItem share = primaryFileServiceClient.listShares().iterator().next();
assertEquals(protocols.toString(), share.getProperties().getProtocols().toString());
assertTrue(share.getProperties().isEnableSnapshotVirtualDirectoryAccess());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion;
import com.azure.storage.file.share.implementation.util.ModelHelper;
import com.azure.storage.file.share.models.ListSharesOptions;
import com.azure.storage.file.share.models.ShareCorsRule;
import com.azure.storage.file.share.models.ShareErrorCode;
import com.azure.storage.file.share.models.ShareItem;
import com.azure.storage.file.share.models.ShareMetrics;
import com.azure.storage.file.share.models.ShareProperties;
import com.azure.storage.file.share.models.ShareProtocols;
import com.azure.storage.file.share.models.ShareRetentionPolicy;
import com.azure.storage.file.share.models.ShareServiceProperties;
import com.azure.storage.file.share.options.ShareCreateOptions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -300,4 +304,24 @@ public void restoreShareError() {
.verifyErrorSatisfies(it -> FileShareTestHelper.assertExceptionStatusCodeAndMessage(it, 404,
ShareErrorCode.SHARE_NOT_FOUND));
}

@RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04")
@Test
public void listSharesEnableSnapshotVirtualDirectoryAccess() {
ShareCreateOptions options = new ShareCreateOptions();
ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL);
options.setProtocols(protocols);
options.setSnapshotVirtualDirectoryAccessEnabled(true);

ShareAsyncClient shareClient = primaryFileServiceAsyncClient.getShareAsyncClient(generateShareName());
shareClient.createWithResponse(options).block();

StepVerifier.create(primaryFileServiceAsyncClient.listShares())
.assertNext(r -> {
ShareProperties properties = r.getProperties();
assertEquals(protocols.toString(), properties.getProtocols().toString());
assertTrue(properties.isEnableSnapshotVirtualDirectoryAccess());
})
.verifyComplete();
}
}
Loading

0 comments on commit a46fdd6

Please sign in to comment.