From a46fdd6b2a24e79cf212f4d31f40b566de587732 Mon Sep 17 00:00:00 2001 From: Isabelle <141270045+ibrandes@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:34:43 -0700 Subject: [PATCH] Stg94 Snapshot management support via REST for NFS shares (#39739) * 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 --- .../storage/file/share/ShareAsyncClient.java | 9 +- .../file/share/implementation/SharesImpl.java | 91 +++++++++++++++++-- .../models/SharePropertiesInternal.java | 27 ++++++ .../models/SharesGetPropertiesHeaders.java | 38 ++++++++ .../implementation/util/ModelHelper.java | 1 + .../file/share/models/ShareProperties.java | 34 +++++++ .../share/options/ShareCreateOptions.java | 26 ++++++ .../options/ShareSetPropertiesOptions.java | 28 ++++++ .../file/share/FileServiceApiTests.java | 19 ++++ .../file/share/FileServiceAsyncApiTests.java | 24 +++++ .../storage/file/share/ShareApiTests.java | 52 +++++++++++ .../file/share/ShareAsyncApiTests.java | 61 +++++++++++++ .../swagger/README.md | 2 +- 13 files changed, 398 insertions(+), 14 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareAsyncClient.java index 073e035b37b80..ec0e8787b4d6e 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareAsyncClient.java @@ -375,7 +375,8 @@ Mono> 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); } @@ -933,7 +934,8 @@ Mono> 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); } @@ -2308,7 +2310,8 @@ private Response 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); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/SharesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/SharesImpl.java index b09772a9d99e6..5e82406f9064c 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/SharesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/SharesImpl.java @@ -91,6 +91,8 @@ Mono> create( @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-enabled-protocols") String enabledProtocols, @HeaderParam("x-ms-root-squash") ShareRootSquash rootSquash, + @HeaderParam("x-ms-enable-snapshot-virtual-directory-access") + Boolean enableSnapshotVirtualDirectoryAccess, @HeaderParam("Accept") String accept, Context context); @@ -108,6 +110,8 @@ Mono> createNoCustomHeaders( @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-enabled-protocols") String enabledProtocols, @HeaderParam("x-ms-root-squash") ShareRootSquash rootSquash, + @HeaderParam("x-ms-enable-snapshot-virtual-directory-access") + Boolean enableSnapshotVirtualDirectoryAccess, @HeaderParam("Accept") String accept, Context context); @@ -447,6 +451,8 @@ Mono> setProperties( @HeaderParam("x-ms-access-tier") ShareAccessTier accessTier, @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-root-squash") ShareRootSquash rootSquash, + @HeaderParam("x-ms-enable-snapshot-virtual-directory-access") + Boolean enableSnapshotVirtualDirectoryAccess, @HeaderParam("Accept") String accept, Context context); @@ -464,6 +470,8 @@ Mono> setPropertiesNoCustomHeaders( @HeaderParam("x-ms-access-tier") ShareAccessTier accessTier, @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-root-squash") ShareRootSquash rootSquash, + @HeaderParam("x-ms-enable-snapshot-virtual-directory-access") + Boolean enableSnapshotVirtualDirectoryAccess, @HeaderParam("Accept") String accept, Context context); @@ -629,6 +637,7 @@ Mono> restoreNoCustomHeaders( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -642,7 +651,8 @@ public Mono> createWithResponseAsync( Integer quota, ShareAccessTier accessTier, String enabledProtocols, - ShareRootSquash rootSquash) { + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { final String restype = "share"; final String accept = "application/xml"; return FluxUtil.withContext( @@ -658,6 +668,7 @@ public Mono> createWithResponseAsync( this.client.getVersion(), enabledProtocols, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context)); } @@ -675,6 +686,7 @@ public Mono> createWithResponseAsync( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -690,6 +702,7 @@ public Mono> createWithResponseAsync( ShareAccessTier accessTier, String enabledProtocols, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { final String restype = "share"; final String accept = "application/xml"; @@ -704,6 +717,7 @@ public Mono> createWithResponseAsync( this.client.getVersion(), enabledProtocols, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context); } @@ -721,6 +735,7 @@ public Mono> createWithResponseAsync( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -734,8 +749,17 @@ public Mono createAsync( Integer quota, ShareAccessTier accessTier, String enabledProtocols, - ShareRootSquash rootSquash) { - return createWithResponseAsync(shareName, timeout, metadata, quota, accessTier, enabledProtocols, rootSquash) + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { + return createWithResponseAsync( + shareName, + timeout, + metadata, + quota, + accessTier, + enabledProtocols, + rootSquash, + enableSnapshotVirtualDirectoryAccess) .flatMap(ignored -> Mono.empty()); } @@ -752,6 +776,7 @@ public Mono createAsync( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -767,9 +792,18 @@ public Mono createAsync( ShareAccessTier accessTier, String enabledProtocols, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { return createWithResponseAsync( - shareName, timeout, metadata, quota, accessTier, enabledProtocols, rootSquash, context) + shareName, + timeout, + metadata, + quota, + accessTier, + enabledProtocols, + rootSquash, + enableSnapshotVirtualDirectoryAccess, + context) .flatMap(ignored -> Mono.empty()); } @@ -786,6 +820,7 @@ public Mono createAsync( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -799,7 +834,8 @@ public Mono> createNoCustomHeadersWithResponseAsync( Integer quota, ShareAccessTier accessTier, String enabledProtocols, - ShareRootSquash rootSquash) { + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { final String restype = "share"; final String accept = "application/xml"; return FluxUtil.withContext( @@ -815,6 +851,7 @@ public Mono> createNoCustomHeadersWithResponseAsync( this.client.getVersion(), enabledProtocols, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context)); } @@ -832,6 +869,7 @@ public Mono> createNoCustomHeadersWithResponseAsync( * @param accessTier Specifies the access tier of the share. * @param enabledProtocols Protocols to enable on the share. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -847,6 +885,7 @@ public Mono> createNoCustomHeadersWithResponseAsync( ShareAccessTier accessTier, String enabledProtocols, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { final String restype = "share"; final String accept = "application/xml"; @@ -861,6 +900,7 @@ public Mono> createNoCustomHeadersWithResponseAsync( this.client.getVersion(), enabledProtocols, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context); } @@ -3113,6 +3153,7 @@ public Mono> getPermissionNoCustomHeadersWithResponseA * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -3125,7 +3166,8 @@ public Mono> setPropertiesWithRes Integer quota, ShareAccessTier accessTier, String leaseId, - ShareRootSquash rootSquash) { + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { final String restype = "share"; final String comp = "properties"; final String accept = "application/xml"; @@ -3142,6 +3184,7 @@ public Mono> setPropertiesWithRes accessTier, leaseId, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context)); } @@ -3157,6 +3200,7 @@ public Mono> setPropertiesWithRes * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -3171,6 +3215,7 @@ public Mono> setPropertiesWithRes ShareAccessTier accessTier, String leaseId, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { final String restype = "share"; final String comp = "properties"; @@ -3186,6 +3231,7 @@ public Mono> setPropertiesWithRes accessTier, leaseId, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context); } @@ -3201,6 +3247,7 @@ public Mono> setPropertiesWithRes * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -3213,8 +3260,16 @@ public Mono setPropertiesAsync( Integer quota, ShareAccessTier accessTier, String leaseId, - ShareRootSquash rootSquash) { - return setPropertiesWithResponseAsync(shareName, timeout, quota, accessTier, leaseId, rootSquash) + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { + return setPropertiesWithResponseAsync( + shareName, + timeout, + quota, + accessTier, + leaseId, + rootSquash, + enableSnapshotVirtualDirectoryAccess) .flatMap(ignored -> Mono.empty()); } @@ -3229,6 +3284,7 @@ public Mono setPropertiesAsync( * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -3243,8 +3299,17 @@ public Mono setPropertiesAsync( ShareAccessTier accessTier, String leaseId, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { - return setPropertiesWithResponseAsync(shareName, timeout, quota, accessTier, leaseId, rootSquash, context) + return setPropertiesWithResponseAsync( + shareName, + timeout, + quota, + accessTier, + leaseId, + rootSquash, + enableSnapshotVirtualDirectoryAccess, + context) .flatMap(ignored -> Mono.empty()); } @@ -3259,6 +3324,7 @@ public Mono setPropertiesAsync( * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -3271,7 +3337,8 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync( Integer quota, ShareAccessTier accessTier, String leaseId, - ShareRootSquash rootSquash) { + ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess) { final String restype = "share"; final String comp = "properties"; final String accept = "application/xml"; @@ -3288,6 +3355,7 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync( accessTier, leaseId, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context)); } @@ -3303,6 +3371,7 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync( * @param accessTier Specifies the access tier of the share. * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. * @param rootSquash Root squash to set on the share. Only valid for NFS shares. + * @param enableSnapshotVirtualDirectoryAccess The enableSnapshotVirtualDirectoryAccess parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageException thrown if the request is rejected by server. @@ -3317,6 +3386,7 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync( ShareAccessTier accessTier, String leaseId, ShareRootSquash rootSquash, + Boolean enableSnapshotVirtualDirectoryAccess, Context context) { final String restype = "share"; final String comp = "properties"; @@ -3332,6 +3402,7 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync( accessTier, leaseId, rootSquash, + enableSnapshotVirtualDirectoryAccess, accept, context); } 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 c006dded9dab4..a5a2b46858138 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 @@ -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 */ @@ -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 <string>. * 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 40bdd22eb36d6..9d016da2308e6 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 @@ -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. */ @@ -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"); @@ -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); @@ -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. * 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 f30ffd5806696..c043479facd43 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 @@ -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; } 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 e2fdf97ecf1be..dc2caf89b83cb 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 @@ -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. * @@ -568,4 +574,32 @@ public ShareProperties setMetadata(Map 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; + } + } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareCreateOptions.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareCreateOptions.java index 4d5e803601303..86719011fe6ca 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareCreateOptions.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareCreateOptions.java @@ -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. @@ -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; + } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareSetPropertiesOptions.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareSetPropertiesOptions.java index 7086bd21aa319..fb5d3b7f67ebc 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareSetPropertiesOptions.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareSetPropertiesOptions.java @@ -18,6 +18,7 @@ public class ShareSetPropertiesOptions { private ShareAccessTier accessTier; private ShareRootSquash rootSquash; private ShareRequestConditions requestConditions; + private Boolean enableSnapshotVirtualDirectoryAccess; /** * @return {@link ShareAccessTier} @@ -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; + } } 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 f6f18b8843498..4ec0d3ab8afcb 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 @@ -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; @@ -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; @@ -415,4 +418,20 @@ public void perCallPolicy() { Response 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()); + } } 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 0faf3f05f67ee..c75f3cb39fdc5 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 @@ -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; @@ -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(); + } } 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 fb61238922eb1..9c8d326da3973 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 @@ -1253,4 +1253,56 @@ public void audienceFromString() { String infoPermission = aadShareClient.createPermission(permission); assertNotNull(infoPermission); } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-05-04") + @ParameterizedTest + @MethodSource("createEnableSnapshotVirtualDirectoryAccessSupplier") + public void createEnableSnapshotVirtualDirectoryAccess(Boolean enableSnapshotVirtualDirectoryAccess) { + ShareCreateOptions options = new ShareCreateOptions(); + ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL); + options.setProtocols(protocols); + options.setSnapshotVirtualDirectoryAccessEnabled(enableSnapshotVirtualDirectoryAccess); + + primaryShareClient.createWithResponse(options, null, null); + + ShareProperties response = primaryShareClient.getProperties(); + assertEquals(protocols.toString(), response.getProtocols().toString()); + if (enableSnapshotVirtualDirectoryAccess == null || enableSnapshotVirtualDirectoryAccess) { + assertTrue(response.isEnableSnapshotVirtualDirectoryAccess()); + } else { + assertFalse(response.isEnableSnapshotVirtualDirectoryAccess()); + } + } + + private static Stream createEnableSnapshotVirtualDirectoryAccessSupplier() { + return Stream.of( + Arguments.of(true), + Arguments.of(false), + Arguments.of((Boolean) null)); + } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04") + @ParameterizedTest + @MethodSource("createEnableSnapshotVirtualDirectoryAccessSupplier") + public void setPropertiesEnableSnapshotVirtualDirectoryAccess(Boolean enableSnapshotVirtualDirectoryAccess) { + ShareCreateOptions options = new ShareCreateOptions(); + ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL); + options.setProtocols(protocols); + + primaryShareClient.createWithResponse(options, null, null); + + ShareSetPropertiesOptions setPropertiesOptions = new ShareSetPropertiesOptions(); + setPropertiesOptions.setSnapshotVirtualDirectoryAccessEnabled(enableSnapshotVirtualDirectoryAccess); + setPropertiesOptions.setAccessTier(ShareAccessTier.TRANSACTION_OPTIMIZED); + + primaryShareClient.setProperties(setPropertiesOptions); + + ShareProperties response = primaryShareClient.getProperties(); + assertEquals(protocols.toString(), response.getProtocols().toString()); + if (enableSnapshotVirtualDirectoryAccess == null || enableSnapshotVirtualDirectoryAccess) { + assertTrue(response.isEnableSnapshotVirtualDirectoryAccess()); + } else { + assertFalse(response.isEnableSnapshotVirtualDirectoryAccess()); + } + } } 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 66722521a7b42..602ff6bfeaaf4 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 @@ -5,10 +5,12 @@ import com.azure.core.http.rest.Response; 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.NtfsFileAttributes; +import com.azure.storage.file.share.models.ShareAccessTier; import com.azure.storage.file.share.models.ShareAudience; import com.azure.storage.file.share.models.ShareErrorCode; import com.azure.storage.file.share.models.ShareFileHttpHeaders; @@ -813,4 +815,63 @@ public void audienceFromString() { .assertNext(r -> assertNotNull(r)) .verifyComplete(); } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-05-04") + @ParameterizedTest + @MethodSource("createEnableSnapshotVirtualDirectoryAccessSupplier") + public void createEnableSnapshotVirtualDirectoryAccess(Boolean enableSnapshotVirtualDirectoryAccess) { + ShareCreateOptions options = new ShareCreateOptions(); + ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL); + options.setProtocols(protocols); + options.setSnapshotVirtualDirectoryAccessEnabled(enableSnapshotVirtualDirectoryAccess); + + primaryShareAsyncClient.createWithResponse(options).block(); + + StepVerifier.create(primaryShareAsyncClient.getProperties()) + .assertNext(r -> { + assertEquals(protocols.toString(), r.getProtocols().toString()); + if (enableSnapshotVirtualDirectoryAccess == null || enableSnapshotVirtualDirectoryAccess) { + assertTrue(r.isEnableSnapshotVirtualDirectoryAccess()); + } else { + assertFalse(r.isEnableSnapshotVirtualDirectoryAccess()); + } + }) + .verifyComplete(); + } + + private static Stream createEnableSnapshotVirtualDirectoryAccessSupplier() { + return Stream.of( + Arguments.of(true), + Arguments.of(false), + Arguments.of((Boolean) null)); + } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2024-08-04") + @ParameterizedTest + @MethodSource("createEnableSnapshotVirtualDirectoryAccessSupplier") + public void setPropertiesEnableSnapshotVirtualDirectoryAccess(Boolean enableSnapshotVirtualDirectoryAccess) { + ShareCreateOptions options = new ShareCreateOptions(); + ShareProtocols protocols = ModelHelper.parseShareProtocols(Constants.HeaderConstants.NFS_PROTOCOL); + options.setProtocols(protocols); + + primaryShareAsyncClient.createWithResponse(options).block(); + + ShareSetPropertiesOptions setPropertiesOptions = new ShareSetPropertiesOptions(); + setPropertiesOptions.setSnapshotVirtualDirectoryAccessEnabled(enableSnapshotVirtualDirectoryAccess); + setPropertiesOptions.setAccessTier(ShareAccessTier.TRANSACTION_OPTIMIZED); + + primaryShareAsyncClient.setProperties(setPropertiesOptions).block(); + + StepVerifier.create(primaryShareAsyncClient.getProperties()) + .assertNext(r -> { + assertEquals(protocols.toString(), r.getProtocols().toString()); + if (enableSnapshotVirtualDirectoryAccess == null || enableSnapshotVirtualDirectoryAccess) { + assertTrue(r.isEnableSnapshotVirtualDirectoryAccess()); + } else { + assertFalse(r.isEnableSnapshotVirtualDirectoryAccess()); + } + }) + .verifyComplete(); + } + } diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 57de2ba899b66..2be198ed51ad9 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.16' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/12e0ceead6d4611abdd617d2bbc5c9068e4c772a/specification/storage/data-plane/Microsoft.FileStorage/stable/2024-08-04/file.json +input-file: https://raw.githubusercontent.com/seanmcc-msft/azure-rest-api-specs/bbb7986063b2d5f3e248d3c57c8664ad5625e5b1/specification/storage/data-plane/Microsoft.FileStorage/stable/2024-08-04/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share