From 492df0728c190034f0398efac50ebb0bc2b495c5 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 29 Sep 2026 15:58:26 -0400 Subject: [PATCH 01/39] Regenerate azure-storage-file-share for STG105 Files by ID --- .../file/share/implementation/FilesImpl.java | 325 ++++ .../DirectoriesGetPropertiesHeaders.java | 31 + .../models/FilesGetHardLinksHeaders.java | 1332 +++++++++++++++++ .../models/FilesGetPropertiesHeaders.java | 31 + .../share/implementation/models/HardLink.java | 144 ++ .../implementation/models/HardLinkList.java | 119 ++ .../swagger/README.md | 2 +- 7 files changed, 1983 insertions(+), 1 deletion(-) create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLink.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLinkList.java diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index e2391f3e79237..d27ecff38de7a 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -38,6 +38,7 @@ import com.azure.storage.file.share.implementation.models.FilesDeleteHeaders; import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; @@ -49,6 +50,7 @@ import com.azure.storage.file.share.implementation.models.FilesStartCopyHeaders; import com.azure.storage.file.share.implementation.models.FilesUploadRangeFromURLHeaders; import com.azure.storage.file.share.implementation.models.FilesUploadRangeHeaders; +import com.azure.storage.file.share.implementation.models.HardLinkList; import com.azure.storage.file.share.implementation.models.ListHandlesResponse; import com.azure.storage.file.share.implementation.models.ShareFileRangeWriteType; import com.azure.storage.file.share.implementation.models.ShareStorageExceptionInternal; @@ -104,6 +106,54 @@ public final class FilesImpl { @ServiceInterface(name = "AzureFileStorageFiles") public interface FilesService { + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getHardLinks(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("comp") String comp, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("fileid") String fileId, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getHardLinksNoCustomHeaders(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("comp") String comp, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("fileid") String fileId, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + ResponseBase getHardLinksSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("comp") String comp, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("fileid") String fileId, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Response getHardLinksNoCustomHeadersSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("comp") String comp, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("fileid") String fileId, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + @Put("/{shareName}/{fileName}") @ExpectedResponses({ 201 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) @@ -1513,6 +1563,281 @@ Response createHardLinkNoCustomHeadersSync(@HostParam("url") String url, @HeaderParam("Accept") String accept, Context context); } + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getHardLinksWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { + return FluxUtil + .withContext(context -> getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, + leaseId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getHardLinksWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + final String comp = "hardlinks"; + final String accept = "application/xml"; + return service + .getHardLinks(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId) { + return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId, Context context) { + return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId) { + return FluxUtil + .withContext(context -> getHardLinksNoCustomHeadersWithResponseAsync(shareName, fileId, sharesnapshot, + timeout, requestId, leaseId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + final String comp = "hardlinks"; + final String accept = "application/xml"; + return service + .getHardLinksNoCustomHeaders(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getHardLinksWithResponse(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + try { + final String comp = "hardlinks"; + final String accept = "application/xml"; + return service.getHardLinksSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public HardLinkList getHardLinks(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId) { + try { + return getHardLinksWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE) + .getValue(); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + + /** + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the file whose hard links are returned. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getHardLinksNoCustomHeadersWithResponse(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + try { + final String comp = "hardlinks"; + final String accept = "application/xml"; + return service.getHardLinksNoCustomHeadersSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, + timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + /** * Creates a new file or replaces a file. Can also initialize the file with content. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesHeaders.java index 6ac4d9f918b4c..84ed7b328e2f5 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesHeaders.java @@ -97,6 +97,12 @@ public final class DirectoriesGetPropertiesHeaders { @Generated private String xMsFileId; + /* + * The x-ms-file-name property. + */ + @Generated + private String xMsFileName; + /* * The x-ms-file-parent-id property. */ @@ -145,6 +151,8 @@ public final class DirectoriesGetPropertiesHeaders { private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); + private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); + private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); @@ -204,6 +212,7 @@ public DirectoriesGetPropertiesHeaders(HttpHeaders rawHeaders) { } this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); + this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); this.xMsMode = rawHeaders.getValue(X_MS_MODE); this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); @@ -525,6 +534,28 @@ public DirectoriesGetPropertiesHeaders setXMsFileId(String xMsFileId) { return this; } + /** + * Get the xMsFileName property: The x-ms-file-name property. + * + * @return the xMsFileName value. + */ + @Generated + public String getXMsFileName() { + return this.xMsFileName; + } + + /** + * Set the xMsFileName property: The x-ms-file-name property. + * + * @param xMsFileName the xMsFileName value to set. + * @return the DirectoriesGetPropertiesHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesHeaders setXMsFileName(String xMsFileName) { + this.xMsFileName = xMsFileName; + return this; + } + /** * Get the xMsFileParentId property: The x-ms-file-parent-id property. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java new file mode 100644 index 0000000000000..0e73849e3cde7 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java @@ -0,0 +1,1332 @@ +// 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.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.file.share.models.CopyStatusType; +import com.azure.storage.file.share.models.LeaseDurationType; +import com.azure.storage.file.share.models.LeaseStateType; +import com.azure.storage.file.share.models.LeaseStatusType; +import com.azure.storage.file.share.models.NfsFileType; +import java.time.OffsetDateTime; +import java.util.Base64; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The FilesGetHardLinksHeaders model. + */ +@Fluent +public final class FilesGetHardLinksHeaders { + /* + * The Last-Modified property. + */ + @Generated + private DateTimeRfc1123 lastModified; + + /* + * The x-ms-meta- property. + */ + @Generated + private Map xMsMeta; + + /* + * The x-ms-type property. + */ + @Generated + private String xMsType = "File"; + + /* + * The ETag property. + */ + @Generated + private String eTag; + + /* + * The x-ms-content-type property. + */ + @Generated + private String xMsContentType; + + /* + * The x-ms-content-length property. + */ + @Generated + private Long xMsContentLength; + + /* + * The x-ms-content-md5 property. + */ + @Generated + private byte[] xMsContentMd5; + + /* + * The x-ms-content-encoding property. + */ + @Generated + private String xMsContentEncoding; + + /* + * The x-ms-content-language property. + */ + @Generated + private String xMsContentLanguage; + + /* + * The x-ms-cache-control property. + */ + @Generated + private String xMsCacheControl; + + /* + * The x-ms-content-disposition property. + */ + @Generated + private String xMsContentDisposition; + + /* + * The x-ms-copy-completion-time property. + */ + @Generated + private DateTimeRfc1123 xMsCopyCompletionTime; + + /* + * The x-ms-copy-status-description property. + */ + @Generated + private String xMsCopyStatusDescription; + + /* + * The x-ms-copy-id property. + */ + @Generated + private String xMsCopyId; + + /* + * The x-ms-copy-progress property. + */ + @Generated + private String xMsCopyProgress; + + /* + * The x-ms-copy-source property. + */ + @Generated + private String xMsCopySource; + + /* + * The x-ms-copy-status property. + */ + @Generated + private CopyStatusType xMsCopyStatus; + + /* + * The x-ms-server-encrypted property. + */ + @Generated + private Boolean xMsServerEncrypted; + + /* + * The x-ms-file-attributes property. + */ + @Generated + private String xMsFileAttributes; + + /* + * The x-ms-file-creation-time property. + */ + @Generated + private DateTimeRfc1123 xMsFileCreationTime; + + /* + * The x-ms-file-last-write-time property. + */ + @Generated + private DateTimeRfc1123 xMsFileLastWriteTime; + + /* + * The x-ms-file-change-time property. + */ + @Generated + private DateTimeRfc1123 xMsFileChangeTime; + + /* + * The x-ms-file-permission-key property. + */ + @Generated + private String xMsFilePermissionKey; + + /* + * The x-ms-file-id property. + */ + @Generated + private String xMsFileId; + + /* + * The x-ms-file-name property. + */ + @Generated + private String xMsFileName; + + /* + * The x-ms-file-parent-id property. + */ + @Generated + private String xMsFileParentId; + + /* + * The x-ms-lease-duration property. + */ + @Generated + private LeaseDurationType xMsLeaseDuration; + + /* + * The x-ms-lease-state property. + */ + @Generated + private LeaseStateType xMsLeaseState; + + /* + * The x-ms-lease-status property. + */ + @Generated + private LeaseStatusType xMsLeaseStatus; + + /* + * The x-ms-mode property. + */ + @Generated + private String xMsMode; + + /* + * The x-ms-owner property. + */ + @Generated + private String xMsOwner; + + /* + * The x-ms-group property. + */ + @Generated + private String xMsGroup; + + /* + * The x-ms-link-count property. + */ + @Generated + private Integer xMsLinkCount; + + /* + * The x-ms-file-file-type property. + */ + @Generated + private NfsFileType xMsFileFileType; + + /* + * The x-ms-request-id property. + */ + @Generated + private String xMsRequestId; + + /* + * The x-ms-version property. + */ + @Generated + private String xMsVersion; + + /* + * The Date property. + */ + @Generated + private DateTimeRfc1123 date; + + /* + * The x-ms-client-request-id property. + */ + @Generated + private String xMsClientRequestId; + + private static final HttpHeaderName X_MS_TYPE = HttpHeaderName.fromString("x-ms-type"); + + private static final HttpHeaderName X_MS_CONTENT_TYPE = HttpHeaderName.fromString("x-ms-content-type"); + + private static final HttpHeaderName X_MS_CONTENT_LENGTH = HttpHeaderName.fromString("x-ms-content-length"); + + private static final HttpHeaderName X_MS_CONTENT_MD5 = HttpHeaderName.fromString("x-ms-content-md5"); + + private static final HttpHeaderName X_MS_CONTENT_ENCODING = HttpHeaderName.fromString("x-ms-content-encoding"); + + private static final HttpHeaderName X_MS_CONTENT_LANGUAGE = HttpHeaderName.fromString("x-ms-content-language"); + + private static final HttpHeaderName X_MS_CACHE_CONTROL = HttpHeaderName.fromString("x-ms-cache-control"); + + private static final HttpHeaderName X_MS_CONTENT_DISPOSITION + = HttpHeaderName.fromString("x-ms-content-disposition"); + + private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME + = HttpHeaderName.fromString("x-ms-copy-completion-time"); + + private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION + = HttpHeaderName.fromString("x-ms-copy-status-description"); + + private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); + + private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); + + private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); + + private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); + + private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); + + private static final HttpHeaderName X_MS_FILE_ATTRIBUTES = HttpHeaderName.fromString("x-ms-file-attributes"); + + private static final HttpHeaderName X_MS_FILE_CREATION_TIME = HttpHeaderName.fromString("x-ms-file-creation-time"); + + private static final HttpHeaderName X_MS_FILE_LAST_WRITE_TIME + = HttpHeaderName.fromString("x-ms-file-last-write-time"); + + private static final HttpHeaderName X_MS_FILE_CHANGE_TIME = HttpHeaderName.fromString("x-ms-file-change-time"); + + private static final HttpHeaderName X_MS_FILE_PERMISSION_KEY + = HttpHeaderName.fromString("x-ms-file-permission-key"); + + private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); + + private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); + + private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); + + private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); + + private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); + + private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); + + private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); + + private static final HttpHeaderName X_MS_OWNER = HttpHeaderName.fromString("x-ms-owner"); + + private static final HttpHeaderName X_MS_GROUP = HttpHeaderName.fromString("x-ms-group"); + + private static final HttpHeaderName X_MS_LINK_COUNT = HttpHeaderName.fromString("x-ms-link-count"); + + private static final HttpHeaderName X_MS_FILE_FILE_TYPE = HttpHeaderName.fromString("x-ms-file-file-type"); + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + // HttpHeaders containing the raw property values. + /** + * Creates an instance of FilesGetHardLinksHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public FilesGetHardLinksHeaders(HttpHeaders rawHeaders) { + String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); + if (lastModified != null) { + this.lastModified = new DateTimeRfc1123(lastModified); + } else { + this.lastModified = null; + } + this.xMsType = rawHeaders.getValue(X_MS_TYPE); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + this.xMsContentType = rawHeaders.getValue(X_MS_CONTENT_TYPE); + String xMsContentLength = rawHeaders.getValue(X_MS_CONTENT_LENGTH); + if (xMsContentLength != null) { + this.xMsContentLength = Long.parseLong(xMsContentLength); + } else { + this.xMsContentLength = null; + } + String xMsContentMd5 = rawHeaders.getValue(X_MS_CONTENT_MD5); + if (xMsContentMd5 != null) { + this.xMsContentMd5 = Base64.getDecoder().decode(xMsContentMd5); + } else { + this.xMsContentMd5 = null; + } + this.xMsContentEncoding = rawHeaders.getValue(X_MS_CONTENT_ENCODING); + this.xMsContentLanguage = rawHeaders.getValue(X_MS_CONTENT_LANGUAGE); + this.xMsCacheControl = rawHeaders.getValue(X_MS_CACHE_CONTROL); + this.xMsContentDisposition = rawHeaders.getValue(X_MS_CONTENT_DISPOSITION); + String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); + if (xMsCopyCompletionTime != null) { + this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); + } else { + this.xMsCopyCompletionTime = null; + } + this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); + this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); + this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); + this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); + String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); + if (xMsCopyStatus != null) { + this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); + } else { + this.xMsCopyStatus = null; + } + String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); + if (xMsServerEncrypted != null) { + this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); + } else { + this.xMsServerEncrypted = null; + } + this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); + String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); + if (xMsFileCreationTime != null) { + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + } else { + this.xMsFileCreationTime = null; + } + String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); + if (xMsFileLastWriteTime != null) { + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + } else { + this.xMsFileLastWriteTime = null; + } + String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); + if (xMsFileChangeTime != null) { + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + } else { + this.xMsFileChangeTime = null; + } + this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); + this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); + this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); + this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); + String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); + if (xMsLeaseDuration != null) { + this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); + } else { + this.xMsLeaseDuration = null; + } + String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); + if (xMsLeaseState != null) { + this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); + } else { + this.xMsLeaseState = null; + } + String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); + if (xMsLeaseStatus != null) { + this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); + } else { + this.xMsLeaseStatus = null; + } + this.xMsMode = rawHeaders.getValue(X_MS_MODE); + this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); + this.xMsGroup = rawHeaders.getValue(X_MS_GROUP); + String xMsLinkCount = rawHeaders.getValue(X_MS_LINK_COUNT); + if (xMsLinkCount != null) { + this.xMsLinkCount = Integer.parseInt(xMsLinkCount); + } else { + this.xMsLinkCount = null; + } + String xMsFileFileType = rawHeaders.getValue(X_MS_FILE_FILE_TYPE); + if (xMsFileFileType != null) { + this.xMsFileFileType = NfsFileType.fromString(xMsFileFileType); + } else { + this.xMsFileFileType = null; + } + this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); + } else { + this.date = null; + } + this.xMsClientRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_CLIENT_REQUEST_ID); + Map xMsMetaHeaderCollection = new LinkedHashMap<>(); + + rawHeaders.stream().forEach(header -> { + String headerName = header.getName(); + if (headerName.startsWith("x-ms-meta-")) { + xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); + } + }); + this.xMsMeta = xMsMetaHeaderCollection; + } + + /** + * Get the lastModified property: The Last-Modified property. + * + * @return the lastModified value. + */ + @Generated + public OffsetDateTime getLastModified() { + if (this.lastModified == null) { + return null; + } + return this.lastModified.getDateTime(); + } + + /** + * Set the lastModified property: The Last-Modified property. + * + * @param lastModified the lastModified value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setLastModified(OffsetDateTime lastModified) { + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new DateTimeRfc1123(lastModified); + } + return this; + } + + /** + * Get the xMsMeta property: The x-ms-meta- property. + * + * @return the xMsMeta value. + */ + @Generated + public Map getXMsMeta() { + return this.xMsMeta; + } + + /** + * Set the xMsMeta property: The x-ms-meta- property. + * + * @param xMsMeta the xMsMeta value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsMeta(Map xMsMeta) { + this.xMsMeta = xMsMeta; + return this; + } + + /** + * Get the xMsType property: The x-ms-type property. + * + * @return the xMsType value. + */ + @Generated + public String getXMsType() { + return this.xMsType; + } + + /** + * Set the xMsType property: The x-ms-type property. + * + * @param xMsType the xMsType value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsType(String xMsType) { + this.xMsType = xMsType; + return this; + } + + /** + * Get the eTag property: The ETag property. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Set the eTag property: The ETag property. + * + * @param eTag the eTag value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setETag(String eTag) { + this.eTag = eTag; + return this; + } + + /** + * Get the xMsContentType property: The x-ms-content-type property. + * + * @return the xMsContentType value. + */ + @Generated + public String getXMsContentType() { + return this.xMsContentType; + } + + /** + * Set the xMsContentType property: The x-ms-content-type property. + * + * @param xMsContentType the xMsContentType value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentType(String xMsContentType) { + this.xMsContentType = xMsContentType; + return this; + } + + /** + * Get the xMsContentLength property: The x-ms-content-length property. + * + * @return the xMsContentLength value. + */ + @Generated + public Long getXMsContentLength() { + return this.xMsContentLength; + } + + /** + * Set the xMsContentLength property: The x-ms-content-length property. + * + * @param xMsContentLength the xMsContentLength value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentLength(Long xMsContentLength) { + this.xMsContentLength = xMsContentLength; + return this; + } + + /** + * Get the xMsContentMd5 property: The x-ms-content-md5 property. + * + * @return the xMsContentMd5 value. + */ + @Generated + public byte[] getXMsContentMd5() { + return CoreUtils.clone(this.xMsContentMd5); + } + + /** + * Set the xMsContentMd5 property: The x-ms-content-md5 property. + * + * @param xMsContentMd5 the xMsContentMd5 value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentMd5(byte[] xMsContentMd5) { + this.xMsContentMd5 = CoreUtils.clone(xMsContentMd5); + return this; + } + + /** + * Get the xMsContentEncoding property: The x-ms-content-encoding property. + * + * @return the xMsContentEncoding value. + */ + @Generated + public String getXMsContentEncoding() { + return this.xMsContentEncoding; + } + + /** + * Set the xMsContentEncoding property: The x-ms-content-encoding property. + * + * @param xMsContentEncoding the xMsContentEncoding value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentEncoding(String xMsContentEncoding) { + this.xMsContentEncoding = xMsContentEncoding; + return this; + } + + /** + * Get the xMsContentLanguage property: The x-ms-content-language property. + * + * @return the xMsContentLanguage value. + */ + @Generated + public String getXMsContentLanguage() { + return this.xMsContentLanguage; + } + + /** + * Set the xMsContentLanguage property: The x-ms-content-language property. + * + * @param xMsContentLanguage the xMsContentLanguage value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentLanguage(String xMsContentLanguage) { + this.xMsContentLanguage = xMsContentLanguage; + return this; + } + + /** + * Get the xMsCacheControl property: The x-ms-cache-control property. + * + * @return the xMsCacheControl value. + */ + @Generated + public String getXMsCacheControl() { + return this.xMsCacheControl; + } + + /** + * Set the xMsCacheControl property: The x-ms-cache-control property. + * + * @param xMsCacheControl the xMsCacheControl value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCacheControl(String xMsCacheControl) { + this.xMsCacheControl = xMsCacheControl; + return this; + } + + /** + * Get the xMsContentDisposition property: The x-ms-content-disposition property. + * + * @return the xMsContentDisposition value. + */ + @Generated + public String getXMsContentDisposition() { + return this.xMsContentDisposition; + } + + /** + * Set the xMsContentDisposition property: The x-ms-content-disposition property. + * + * @param xMsContentDisposition the xMsContentDisposition value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsContentDisposition(String xMsContentDisposition) { + this.xMsContentDisposition = xMsContentDisposition; + return this; + } + + /** + * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. + * + * @return the xMsCopyCompletionTime value. + */ + @Generated + public OffsetDateTime getXMsCopyCompletionTime() { + if (this.xMsCopyCompletionTime == null) { + return null; + } + return this.xMsCopyCompletionTime.getDateTime(); + } + + /** + * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. + * + * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { + if (xMsCopyCompletionTime == null) { + this.xMsCopyCompletionTime = null; + } else { + this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); + } + return this; + } + + /** + * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. + * + * @return the xMsCopyStatusDescription value. + */ + @Generated + public String getXMsCopyStatusDescription() { + return this.xMsCopyStatusDescription; + } + + /** + * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. + * + * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { + this.xMsCopyStatusDescription = xMsCopyStatusDescription; + return this; + } + + /** + * Get the xMsCopyId property: The x-ms-copy-id property. + * + * @return the xMsCopyId value. + */ + @Generated + public String getXMsCopyId() { + return this.xMsCopyId; + } + + /** + * Set the xMsCopyId property: The x-ms-copy-id property. + * + * @param xMsCopyId the xMsCopyId value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopyId(String xMsCopyId) { + this.xMsCopyId = xMsCopyId; + return this; + } + + /** + * Get the xMsCopyProgress property: The x-ms-copy-progress property. + * + * @return the xMsCopyProgress value. + */ + @Generated + public String getXMsCopyProgress() { + return this.xMsCopyProgress; + } + + /** + * Set the xMsCopyProgress property: The x-ms-copy-progress property. + * + * @param xMsCopyProgress the xMsCopyProgress value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopyProgress(String xMsCopyProgress) { + this.xMsCopyProgress = xMsCopyProgress; + return this; + } + + /** + * Get the xMsCopySource property: The x-ms-copy-source property. + * + * @return the xMsCopySource value. + */ + @Generated + public String getXMsCopySource() { + return this.xMsCopySource; + } + + /** + * Set the xMsCopySource property: The x-ms-copy-source property. + * + * @param xMsCopySource the xMsCopySource value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopySource(String xMsCopySource) { + this.xMsCopySource = xMsCopySource; + return this; + } + + /** + * Get the xMsCopyStatus property: The x-ms-copy-status property. + * + * @return the xMsCopyStatus value. + */ + @Generated + public CopyStatusType getXMsCopyStatus() { + return this.xMsCopyStatus; + } + + /** + * Set the xMsCopyStatus property: The x-ms-copy-status property. + * + * @param xMsCopyStatus the xMsCopyStatus value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { + this.xMsCopyStatus = xMsCopyStatus; + return this; + } + + /** + * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @return the xMsServerEncrypted value. + */ + @Generated + public Boolean isXMsServerEncrypted() { + return this.xMsServerEncrypted; + } + + /** + * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @param xMsServerEncrypted the xMsServerEncrypted value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { + this.xMsServerEncrypted = xMsServerEncrypted; + return this; + } + + /** + * Get the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @return the xMsFileAttributes value. + */ + @Generated + public String getXMsFileAttributes() { + return this.xMsFileAttributes; + } + + /** + * Set the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @param xMsFileAttributes the xMsFileAttributes value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileAttributes(String xMsFileAttributes) { + this.xMsFileAttributes = xMsFileAttributes; + return this; + } + + /** + * Get the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @return the xMsFileCreationTime value. + */ + @Generated + public OffsetDateTime getXMsFileCreationTime() { + if (this.xMsFileCreationTime == null) { + return null; + } + return this.xMsFileCreationTime.getDateTime(); + } + + /** + * Set the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @param xMsFileCreationTime the xMsFileCreationTime value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { + if (xMsFileCreationTime == null) { + this.xMsFileCreationTime = null; + } else { + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + } + return this; + } + + /** + * Get the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @return the xMsFileLastWriteTime value. + */ + @Generated + public OffsetDateTime getXMsFileLastWriteTime() { + if (this.xMsFileLastWriteTime == null) { + return null; + } + return this.xMsFileLastWriteTime.getDateTime(); + } + + /** + * Set the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @param xMsFileLastWriteTime the xMsFileLastWriteTime value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { + if (xMsFileLastWriteTime == null) { + this.xMsFileLastWriteTime = null; + } else { + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + } + return this; + } + + /** + * Get the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @return the xMsFileChangeTime value. + */ + @Generated + public OffsetDateTime getXMsFileChangeTime() { + if (this.xMsFileChangeTime == null) { + return null; + } + return this.xMsFileChangeTime.getDateTime(); + } + + /** + * Set the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @param xMsFileChangeTime the xMsFileChangeTime value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { + if (xMsFileChangeTime == null) { + this.xMsFileChangeTime = null; + } else { + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + } + return this; + } + + /** + * Get the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @return the xMsFilePermissionKey value. + */ + @Generated + public String getXMsFilePermissionKey() { + return this.xMsFilePermissionKey; + } + + /** + * Set the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @param xMsFilePermissionKey the xMsFilePermissionKey value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFilePermissionKey(String xMsFilePermissionKey) { + this.xMsFilePermissionKey = xMsFilePermissionKey; + return this; + } + + /** + * Get the xMsFileId property: The x-ms-file-id property. + * + * @return the xMsFileId value. + */ + @Generated + public String getXMsFileId() { + return this.xMsFileId; + } + + /** + * Set the xMsFileId property: The x-ms-file-id property. + * + * @param xMsFileId the xMsFileId value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileId(String xMsFileId) { + this.xMsFileId = xMsFileId; + return this; + } + + /** + * Get the xMsFileName property: The x-ms-file-name property. + * + * @return the xMsFileName value. + */ + @Generated + public String getXMsFileName() { + return this.xMsFileName; + } + + /** + * Set the xMsFileName property: The x-ms-file-name property. + * + * @param xMsFileName the xMsFileName value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileName(String xMsFileName) { + this.xMsFileName = xMsFileName; + return this; + } + + /** + * Get the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @return the xMsFileParentId value. + */ + @Generated + public String getXMsFileParentId() { + return this.xMsFileParentId; + } + + /** + * Set the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @param xMsFileParentId the xMsFileParentId value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileParentId(String xMsFileParentId) { + this.xMsFileParentId = xMsFileParentId; + return this; + } + + /** + * Get the xMsLeaseDuration property: The x-ms-lease-duration property. + * + * @return the xMsLeaseDuration value. + */ + @Generated + public LeaseDurationType getXMsLeaseDuration() { + return this.xMsLeaseDuration; + } + + /** + * Set the xMsLeaseDuration property: The x-ms-lease-duration property. + * + * @param xMsLeaseDuration the xMsLeaseDuration value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { + this.xMsLeaseDuration = xMsLeaseDuration; + return this; + } + + /** + * Get the xMsLeaseState property: The x-ms-lease-state property. + * + * @return the xMsLeaseState value. + */ + @Generated + public LeaseStateType getXMsLeaseState() { + return this.xMsLeaseState; + } + + /** + * Set the xMsLeaseState property: The x-ms-lease-state property. + * + * @param xMsLeaseState the xMsLeaseState value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { + this.xMsLeaseState = xMsLeaseState; + return this; + } + + /** + * Get the xMsLeaseStatus property: The x-ms-lease-status property. + * + * @return the xMsLeaseStatus value. + */ + @Generated + public LeaseStatusType getXMsLeaseStatus() { + return this.xMsLeaseStatus; + } + + /** + * Set the xMsLeaseStatus property: The x-ms-lease-status property. + * + * @param xMsLeaseStatus the xMsLeaseStatus value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { + this.xMsLeaseStatus = xMsLeaseStatus; + return this; + } + + /** + * Get the xMsMode property: The x-ms-mode property. + * + * @return the xMsMode value. + */ + @Generated + public String getXMsMode() { + return this.xMsMode; + } + + /** + * Set the xMsMode property: The x-ms-mode property. + * + * @param xMsMode the xMsMode value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsMode(String xMsMode) { + this.xMsMode = xMsMode; + return this; + } + + /** + * Get the xMsOwner property: The x-ms-owner property. + * + * @return the xMsOwner value. + */ + @Generated + public String getXMsOwner() { + return this.xMsOwner; + } + + /** + * Set the xMsOwner property: The x-ms-owner property. + * + * @param xMsOwner the xMsOwner value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsOwner(String xMsOwner) { + this.xMsOwner = xMsOwner; + return this; + } + + /** + * Get the xMsGroup property: The x-ms-group property. + * + * @return the xMsGroup value. + */ + @Generated + public String getXMsGroup() { + return this.xMsGroup; + } + + /** + * Set the xMsGroup property: The x-ms-group property. + * + * @param xMsGroup the xMsGroup value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsGroup(String xMsGroup) { + this.xMsGroup = xMsGroup; + return this; + } + + /** + * Get the xMsLinkCount property: The x-ms-link-count property. + * + * @return the xMsLinkCount value. + */ + @Generated + public Integer getXMsLinkCount() { + return this.xMsLinkCount; + } + + /** + * Set the xMsLinkCount property: The x-ms-link-count property. + * + * @param xMsLinkCount the xMsLinkCount value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsLinkCount(Integer xMsLinkCount) { + this.xMsLinkCount = xMsLinkCount; + return this; + } + + /** + * Get the xMsFileFileType property: The x-ms-file-file-type property. + * + * @return the xMsFileFileType value. + */ + @Generated + public NfsFileType getXMsFileFileType() { + return this.xMsFileFileType; + } + + /** + * Set the xMsFileFileType property: The x-ms-file-file-type property. + * + * @param xMsFileFileType the xMsFileFileType value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsFileFileType(NfsFileType xMsFileFileType) { + this.xMsFileFileType = xMsFileFileType; + return this; + } + + /** + * Get the xMsRequestId property: The x-ms-request-id property. + * + * @return the xMsRequestId value. + */ + @Generated + public String getXMsRequestId() { + return this.xMsRequestId; + } + + /** + * Set the xMsRequestId property: The x-ms-request-id property. + * + * @param xMsRequestId the xMsRequestId value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsRequestId(String xMsRequestId) { + this.xMsRequestId = xMsRequestId; + return this; + } + + /** + * Get the xMsVersion property: The x-ms-version property. + * + * @return the xMsVersion value. + */ + @Generated + public String getXMsVersion() { + return this.xMsVersion; + } + + /** + * Set the xMsVersion property: The x-ms-version property. + * + * @param xMsVersion the xMsVersion value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsVersion(String xMsVersion) { + this.xMsVersion = xMsVersion; + return this; + } + + /** + * Get the date property: The Date property. + * + * @return the date value. + */ + @Generated + public OffsetDateTime getDate() { + if (this.date == null) { + return null; + } + return this.date.getDateTime(); + } + + /** + * Set the date property: The Date property. + * + * @param date the date value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; + } else { + this.date = new DateTimeRfc1123(date); + } + return this; + } + + /** + * Get the xMsClientRequestId property: The x-ms-client-request-id property. + * + * @return the xMsClientRequestId value. + */ + @Generated + public String getXMsClientRequestId() { + return this.xMsClientRequestId; + } + + /** + * Set the xMsClientRequestId property: The x-ms-client-request-id property. + * + * @param xMsClientRequestId the xMsClientRequestId value to set. + * @return the FilesGetHardLinksHeaders object itself. + */ + @Generated + public FilesGetHardLinksHeaders setXMsClientRequestId(String xMsClientRequestId) { + this.xMsClientRequestId = xMsClientRequestId; + return this; + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesHeaders.java index 857221a951aa2..e0c298598356c 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesHeaders.java @@ -187,6 +187,12 @@ public final class FilesGetPropertiesHeaders { @Generated private String xMsFileId; + /* + * The x-ms-file-name property. + */ + @Generated + private String xMsFileName; + /* * The x-ms-file-parent-id property. */ @@ -275,6 +281,8 @@ public final class FilesGetPropertiesHeaders { private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); + private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); + private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); @@ -376,6 +384,7 @@ public FilesGetPropertiesHeaders(HttpHeaders rawHeaders) { } this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); + this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); if (xMsLeaseDuration != null) { @@ -1036,6 +1045,28 @@ public FilesGetPropertiesHeaders setXMsFileId(String xMsFileId) { return this; } + /** + * Get the xMsFileName property: The x-ms-file-name property. + * + * @return the xMsFileName value. + */ + @Generated + public String getXMsFileName() { + return this.xMsFileName; + } + + /** + * Set the xMsFileName property: The x-ms-file-name property. + * + * @param xMsFileName the xMsFileName value to set. + * @return the FilesGetPropertiesHeaders object itself. + */ + @Generated + public FilesGetPropertiesHeaders setXMsFileName(String xMsFileName) { + this.xMsFileName = xMsFileName; + return this; + } + /** * Get the xMsFileParentId property: The x-ms-file-parent-id property. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLink.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLink.java new file mode 100644 index 0000000000000..e73351509a837 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLink.java @@ -0,0 +1,144 @@ +// 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.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.xml.XmlReader; +import com.azure.xml.XmlSerializable; +import com.azure.xml.XmlToken; +import com.azure.xml.XmlWriter; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; + +/** + * A hard link to a file. + */ +@Fluent +public final class HardLink implements XmlSerializable { + /* + * The name of the hard link. + */ + @Generated + private StringEncoded fileName; + + /* + * The fileId of the parent directory of the hard link. + */ + @Generated + private String parentId; + + /** + * Creates an instance of HardLink class. + */ + @Generated + public HardLink() { + } + + /** + * Get the fileName property: The name of the hard link. + * + * @return the fileName value. + */ + @Generated + public StringEncoded getFileName() { + return this.fileName; + } + + /** + * Set the fileName property: The name of the hard link. + * + * @param fileName the fileName value to set. + * @return the HardLink object itself. + */ + @Generated + public HardLink setFileName(StringEncoded fileName) { + this.fileName = fileName; + return this; + } + + /** + * Get the parentId property: The fileId of the parent directory of the hard link. + * + * @return the parentId value. + */ + @Generated + public String getParentId() { + return this.parentId; + } + + /** + * Set the parentId property: The fileId of the parent directory of the hard link. + * + * @param parentId the parentId value to set. + * @return the HardLink object itself. + */ + @Generated + public HardLink setParentId(String parentId) { + this.parentId = parentId; + return this; + } + + @Generated + @Override + public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { + return toXml(xmlWriter, null); + } + + @Generated + @Override + public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { + rootElementName = rootElementName == null || rootElementName.isEmpty() ? "HardLink" : rootElementName; + xmlWriter.writeStartElement(rootElementName); + xmlWriter.writeXml(this.fileName, "FileName"); + xmlWriter.writeStringElement("ParentId", this.parentId); + return xmlWriter.writeEndElement(); + } + + /** + * Reads an instance of HardLink from the XmlReader. + * + * @param xmlReader The XmlReader being read. + * @return An instance of HardLink if the XmlReader was pointing to an instance of it, or null if it was pointing to + * XML null. + * @throws XMLStreamException If an error occurs while reading the HardLink. + */ + @Generated + public static HardLink fromXml(XmlReader xmlReader) throws XMLStreamException { + return fromXml(xmlReader, null); + } + + /** + * Reads an instance of HardLink from the XmlReader. + * + * @param xmlReader The XmlReader being read. + * @param rootElementName Optional root element name to override the default defined by the model. Used to support + * cases where the model can deserialize from different root element names. + * @return An instance of HardLink if the XmlReader was pointing to an instance of it, or null if it was pointing to + * XML null. + * @throws XMLStreamException If an error occurs while reading the HardLink. + */ + @Generated + public static HardLink fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { + String finalRootElementName + = rootElementName == null || rootElementName.isEmpty() ? "HardLink" : rootElementName; + return xmlReader.readObject(finalRootElementName, reader -> { + HardLink deserializedHardLink = new HardLink(); + while (reader.nextElement() != XmlToken.END_ELEMENT) { + QName elementName = reader.getElementName(); + + if ("FileName".equals(elementName.getLocalPart())) { + deserializedHardLink.fileName = StringEncoded.fromXml(reader, "FileName"); + } else if ("ParentId".equals(elementName.getLocalPart())) { + deserializedHardLink.parentId = reader.getStringElement(); + } else { + reader.skipElement(); + } + } + + return deserializedHardLink; + }); + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLinkList.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLinkList.java new file mode 100644 index 0000000000000..4dd75df71bb02 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/HardLinkList.java @@ -0,0 +1,119 @@ +// 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.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.xml.XmlReader; +import com.azure.xml.XmlSerializable; +import com.azure.xml.XmlToken; +import com.azure.xml.XmlWriter; +import java.util.ArrayList; +import java.util.List; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; + +/** + * The list of hard links for a file. + */ +@Fluent +public final class HardLinkList implements XmlSerializable { + /* + * The hard links. + */ + @Generated + private List hardLinks = new ArrayList<>(); + + /** + * Creates an instance of HardLinkList class. + */ + @Generated + public HardLinkList() { + } + + /** + * Get the hardLinks property: The hard links. + * + * @return the hardLinks value. + */ + @Generated + public List getHardLinks() { + return this.hardLinks; + } + + /** + * Set the hardLinks property: The hard links. + * + * @param hardLinks the hardLinks value to set. + * @return the HardLinkList object itself. + */ + @Generated + public HardLinkList setHardLinks(List hardLinks) { + this.hardLinks = hardLinks; + return this; + } + + @Generated + @Override + public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { + return toXml(xmlWriter, null); + } + + @Generated + @Override + public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { + rootElementName = rootElementName == null || rootElementName.isEmpty() ? "HardLinks" : rootElementName; + xmlWriter.writeStartElement(rootElementName); + if (this.hardLinks != null) { + for (HardLink element : this.hardLinks) { + xmlWriter.writeXml(element, "HardLink"); + } + } + return xmlWriter.writeEndElement(); + } + + /** + * Reads an instance of HardLinkList from the XmlReader. + * + * @param xmlReader The XmlReader being read. + * @return An instance of HardLinkList if the XmlReader was pointing to an instance of it, or null if it was + * pointing to XML null. + * @throws XMLStreamException If an error occurs while reading the HardLinkList. + */ + @Generated + public static HardLinkList fromXml(XmlReader xmlReader) throws XMLStreamException { + return fromXml(xmlReader, null); + } + + /** + * Reads an instance of HardLinkList from the XmlReader. + * + * @param xmlReader The XmlReader being read. + * @param rootElementName Optional root element name to override the default defined by the model. Used to support + * cases where the model can deserialize from different root element names. + * @return An instance of HardLinkList if the XmlReader was pointing to an instance of it, or null if it was + * pointing to XML null. + * @throws XMLStreamException If an error occurs while reading the HardLinkList. + */ + @Generated + public static HardLinkList fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { + String finalRootElementName + = rootElementName == null || rootElementName.isEmpty() ? "HardLinks" : rootElementName; + return xmlReader.readObject(finalRootElementName, reader -> { + HardLinkList deserializedHardLinkList = new HardLinkList(); + while (reader.nextElement() != XmlToken.END_ELEMENT) { + QName elementName = reader.getElementName(); + + if ("HardLink".equals(elementName.getLocalPart())) { + deserializedHardLinkList.hardLinks.add(HardLink.fromXml(reader, "HardLink")); + } else { + reader.skipElement(); + } + } + + return deserializedHardLinkList; + }); + } +} diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 223d605db8f0d..8d50f922c9573 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/seanmcc-msft/azure-rest-api-specs/e38b4c39072e9c00e3607cde729cea2e8d237b92/specification/storage/data-plane/Microsoft.FileStorage/stable/2026-12-06/file.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/eca1da9f213c2bc8e38aee5dcf4e10e4b009992d/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share From ac1d2a64dea2e2405dec56818229ca726f7389d9 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 29 Sep 2026 18:21:17 -0400 Subject: [PATCH 02/39] first pass with harness --- .../storage/file/share/ShareAsyncClient.java | 27 ++ .../azure/storage/file/share/ShareClient.java | 29 +++ .../file/share/ShareDirectoryAsyncClient.java | 55 +++- .../file/share/ShareDirectoryClient.java | 53 +++- .../file/share/ShareFileAsyncClient.java | 118 ++++++++- .../storage/file/share/ShareFileClient.java | 131 +++++++++- .../file/share/ShareFileClientBuilder.java | 52 +++- .../implementation/AzureFileStorageImpl.java | 11 + .../implementation/FileIdOperations.java | 174 +++++++++++++ .../ShareDirectoryPropertiesHelper.java | 10 +- .../ShareFilePropertiesHelper.java | 29 ++- .../implementation/util/ModelHelper.java | 39 ++- .../models/ShareDirectoryProperties.java | 15 +- .../file/share/models/ShareFileLink.java | 44 ++++ .../file/share/models/ShareFileLinks.java | 50 ++++ .../share/models/ShareFileProperties.java | 30 ++- .../storage/file/share/DirectoryApiTests.java | 100 +++++++- .../file/share/DirectoryAsyncApiTests.java | 94 ++++++- .../storage/file/share/FileApiTests.java | 240 +++++++++++++++++- .../storage/file/share/FileAsyncApiTests.java | 126 ++++++++- .../storage/file/share/FileIdTestHelper.java | 30 +++ .../storage/file/share/FileShareTestBase.java | 56 ++-- 22 files changed, 1422 insertions(+), 91 deletions(-) create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLink.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLinks.java create mode 100644 sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java 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 4f9c29bc7d9ca..9bbd849070040 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 @@ -21,6 +21,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.SharePermission; import com.azure.storage.file.share.implementation.util.ModelHelper; import com.azure.storage.file.share.implementation.util.ShareSasImplUtil; @@ -187,6 +188,32 @@ public ShareFileAsyncClient getFileClient(String filePath) { serviceVersion, sasToken); } + /** + * Creates a file client that addresses a file by its file ID. + * + * @param fileId The file ID of the file. + * @return A client for interacting with the file by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareFileAsyncClient getFileClientByFileId(String fileId) { + FileIdOperations.validateFileId(fileId); + return new ShareFileAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + + /** + * Creates a directory client that addresses a directory by its file ID. + * + * @param fileId The file ID of the directory. + * @return A client for interacting with the directory by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareDirectoryAsyncClient getDirectoryClientByFileId(String fileId) { + FileIdOperations.validateFileId(fileId); + return new ShareDirectoryAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + /** * Creates a new {@link ShareAsyncClient} linked to the {@code snapshot} of this share resource. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java index 5eddfa88edf7b..b171e399588a6 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java @@ -22,6 +22,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.SharePermission; import com.azure.storage.file.share.implementation.models.ShareSignedIdentifierWrapper; import com.azure.storage.file.share.implementation.models.ShareStats; @@ -196,6 +197,34 @@ public ShareFileClient getFileClient(String filePath) { azureFileStorageClient, shareName, filePath, snapshot, accountName, serviceVersion, sasToken); } + /** + * Creates a file client that addresses a file by its file ID. + * + * @param fileId The file ID of the file. + * @return A client for interacting with the file by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareFileClient getFileClientByFileId(String fileId) { + FileIdOperations.validateFileId(fileId); + ShareFileAsyncClient asyncClient = new ShareFileAsyncClient(azureFileStorageClient, shareName, "", fileId, + snapshot, accountName, serviceVersion, sasToken); + return new ShareFileClient(asyncClient, azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + + /** + * Creates a directory client that addresses a directory by its file ID. + * + * @param fileId The file ID of the directory. + * @return A client for interacting with the directory by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareDirectoryClient getDirectoryClientByFileId(String fileId) { + FileIdOperations.validateFileId(fileId); + return new ShareDirectoryClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + /** * Creates a new {@link ShareAsyncClient} linked to the {@code snapshot} of this share resource. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index da521421629a9..b1bdbc87511c0 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -23,6 +23,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.ListFilesIncludeType; @@ -92,6 +93,7 @@ public class ShareDirectoryAsyncClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -109,10 +111,17 @@ public class ShareDirectoryAsyncClient { */ ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); + } + + ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, + String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, + AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -122,8 +131,9 @@ public class ShareDirectoryAsyncClient { ShareDirectoryAsyncClient(ShareDirectoryAsyncClient directoryAsyncClient) { this(directoryAsyncClient.azureFileStorageClient, directoryAsyncClient.shareName, - Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.snapshot, - directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, directoryAsyncClient.sasToken); + Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.fileId, + directoryAsyncClient.snapshot, directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, + directoryAsyncClient.sasToken); } /** @@ -132,16 +142,31 @@ public class ShareDirectoryAsyncClient { * @return the URL of the storage directory client */ public String getDirectoryUrl() { - StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/") - .append(shareName) - .append("/") - .append(directoryPath); + StringBuilder directoryUrlString + = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + if (fileId.isEmpty()) { + directoryUrlString.append("/").append(directoryPath); + } if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + directoryUrlString.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + directoryUrlString.append("?fileid=").append(fileId); } return directoryUrlString.toString(); } + /** + * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + /** * Gets the service version the client is using. * @@ -161,6 +186,7 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileAsyncClient that interacts with the specified share */ public ShareFileAsyncClient getFileClient(String fileName) { + FileIdOperations.ensurePathAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -180,6 +206,7 @@ public ShareFileAsyncClient getFileClient(String fileName) { * @return a ShareDirectoryAsyncClient that interacts with the specified directory */ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) { + FileIdOperations.ensurePathAddressed(fileId, "getSubdirectoryClient"); StringBuilder directoryPathBuilder = new StringBuilder().append(this.directoryPath); if (!this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/")) { directoryPathBuilder.append("/"); @@ -230,6 +257,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { + FileIdOperations.ensurePathAddressed(fileId, "exists"); return this.getPropertiesWithResponse(context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -355,6 +383,7 @@ public Mono> createWithResponse(ShareDirectoryCreat Mono> createWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Map metadata, FilePropertySemantics filePropertySemantics, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "create"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -522,6 +551,7 @@ public Mono> deleteWithResponse() { } Mono> deleteWithResponse(Context context) { + FileIdOperations.ensurePathAddressed(fileId, "delete"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponseAsync(shareName, directoryPath, null, context); @@ -660,6 +690,11 @@ public Mono> getPropertiesWithResponse() { Mono> getPropertiesWithResponse(Context context) { context = context == null ? Context.NONE : context; + if (!fileId.isEmpty()) { + return azureFileStorageClient.getFileIdOperations() + .getDirectoryPropertiesAsync(shareName, fileId, snapshot, null, context) + .map(ModelHelper::mapShareDirectoryPropertiesResponse); + } return azureFileStorageClient.getDirectories() .getPropertiesWithResponseAsync(shareName, directoryPath, snapshot, null, context) .map(ModelHelper::mapShareDirectoryPropertiesResponse); @@ -769,6 +804,7 @@ public Mono> setPropertiesWithResponse(ShareDirecto Mono> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setProperties"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -869,6 +905,7 @@ public Mono> setMetadataWithResponse(Map Mono> setMetadataWithResponse(Map metadata, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .setMetadataWithResponseAsync(shareName, directoryPath, null, metadata, context) @@ -976,6 +1013,7 @@ public PagedFlux listFilesAndDirectories(ShareListFilesAndDirecto PagedFlux listFilesAndDirectoriesWithOptionalTimeout(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listFilesAndDirectories"); final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; @@ -1030,6 +1068,7 @@ public PagedFlux listHandles(Integer maxResultPerPage, boolean recur PagedFlux listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .listHandlesWithResponseAsync(shareName, directoryPath, marker, maxResultPerPage, null, snapshot, @@ -1102,6 +1141,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); return this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, handleId, null, null, snapshot, false, context) @@ -1145,6 +1185,7 @@ public Mono forceCloseAllHandles(boolean recursive) { } PagedFlux forceCloseAllHandlesWithTimeout(boolean recursive, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, "*", null, marker, snapshot, recursive, @@ -1226,6 +1267,7 @@ public Mono> renameWithResponse(ShareFileRen } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -2140,6 +2182,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 3780bc4143750..6c244e3dd5d43 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -23,6 +23,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; @@ -99,6 +100,7 @@ public class ShareDirectoryClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -117,22 +119,35 @@ public class ShareDirectoryClient { */ ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); + } + + ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, + String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, + AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; this.serviceVersion = serviceVersion; this.sasToken = sasToken; - StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/") - .append(shareName) - .append("/") - .append(directoryPath); + StringBuilder directoryUrlString + = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + if (fileId.isEmpty()) { + directoryUrlString.append("/").append(directoryPath); + } if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + directoryUrlString.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + directoryUrlString.append("?fileid=").append(fileId); } this.directoryUrl = directoryUrlString.toString(); } @@ -146,6 +161,15 @@ public String getDirectoryUrl() { return this.directoryUrl; } + /** + * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + /** * Gets the service version the client is using. * @@ -165,6 +189,7 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileClient that interacts with the specified share */ public ShareFileClient getFileClient(String fileName) { + FileIdOperations.ensurePathAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -185,6 +210,7 @@ public ShareFileClient getFileClient(String fileName) { * @return a ShareDirectoryClient that interacts with the specified directory */ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { + FileIdOperations.ensurePathAddressed(fileId, "getSubdirectoryClient"); boolean needPathDelimiter = !this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/"); String subDirectoryPath = this.directoryPath + (needPathDelimiter ? "/" : "") + subdirectoryName; return new ShareDirectoryClient(azureFileStorageClient, shareName, subDirectoryPath, snapshot, accountName, @@ -227,6 +253,7 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -341,6 +368,7 @@ public Response createWithResponse(FileSmbProperties smbProp @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareDirectoryCreateOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "create"); Context finalContext = context == null ? Context.NONE : context; ShareDirectoryCreateOptions finalOptions = options == null ? new ShareDirectoryCreateOptions() : options; @@ -493,6 +521,7 @@ public void delete() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponse(shareName, directoryPath, null, finalContext); @@ -622,9 +651,11 @@ public ShareDirectoryProperties getProperties() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureFileStorageClient.getDirectories() - .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext); + Callable> operation = fileId.isEmpty() + ? () -> this.azureFileStorageClient.getDirectories() + .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext) + : () -> this.azureFileStorageClient.getFileIdOperations() + .getDirectoryProperties(shareName, fileId, snapshot, null, finalContext); return ModelHelper .mapShareDirectoryPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); @@ -723,6 +754,7 @@ public Response setPropertiesWithResponse(FileSmbProperties @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareDirectorySetPropertiesOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setProperties"); Context finalContext = context == null ? Context.NONE : context; ShareDirectorySetPropertiesOptions finalOptions = options == null ? new ShareDirectorySetPropertiesOptions() : options; @@ -830,6 +862,7 @@ public ShareDirectorySetMetadataInfo setMetadata(Map metadata) { @ServiceMethod(returns = ReturnType.SINGLE) public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() @@ -940,6 +973,7 @@ public PagedIterable listFilesAndDirectories(String prefix, Integ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listFilesAndDirectories"); Context finalContext = context == null ? Context.NONE : context; final ShareListFilesAndDirectoriesOptions modifiedOptions @@ -1000,6 +1034,7 @@ public PagedIterable listHandles(Integer maxResultsPerPage, boolean PagedIterable listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { Callable> operation @@ -1076,6 +1111,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -1119,6 +1155,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(boolean recursive, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { @@ -1205,6 +1242,7 @@ public ShareDirectoryClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; @@ -2040,6 +2078,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index c6e2bde18e29c..aab68b0d35899 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -36,6 +36,7 @@ import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.UploadUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; @@ -60,6 +61,7 @@ import com.azure.storage.file.share.models.ShareFileDownloadHeaders; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareFileInfo; +import com.azure.storage.file.share.models.ShareFileLinks; import com.azure.storage.file.share.models.ShareFileMetadataInfo; import com.azure.storage.file.share.models.ShareFilePermission; import com.azure.storage.file.share.models.ShareFileProperties; @@ -149,6 +151,7 @@ public class ShareFileAsyncClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String filePath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -164,11 +167,17 @@ public class ShareFileAsyncClient { * @param snapshot The snapshot of the share */ ShareFileAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String filePath, + String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(azureFileStorageClient, shareName, filePath, "", snapshot, accountName, serviceVersion, sasToken); + } + + ShareFileAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String filePath, String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(filePath, "'filePath' cannot be null."); this.shareName = shareName; this.filePath = filePath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -178,8 +187,8 @@ public class ShareFileAsyncClient { ShareFileAsyncClient(ShareFileAsyncClient fileAsyncClient) { this(fileAsyncClient.azureFileStorageClient, fileAsyncClient.shareName, - Utility.urlEncode(fileAsyncClient.filePath), fileAsyncClient.snapshot, fileAsyncClient.accountName, - fileAsyncClient.serviceVersion, fileAsyncClient.sasToken); + Utility.urlEncode(fileAsyncClient.filePath), fileAsyncClient.fileId, fileAsyncClient.snapshot, + fileAsyncClient.accountName, fileAsyncClient.serviceVersion, fileAsyncClient.sasToken); } /** @@ -197,12 +206,17 @@ public String getAccountUrl() { * @return the URL of the storage file client */ public String getFileUrl() { - StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/") - .append(shareName) - .append("/") - .append(filePath); + StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + if (fileId.isEmpty()) { + fileUrlstring.append("/").append(filePath); + } if (snapshot != null) { fileUrlstring.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + fileUrlstring.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + fileUrlstring.append("?fileid=").append(fileId); } return fileUrlstring.toString(); } @@ -216,10 +230,74 @@ public ShareServiceVersion getServiceVersion() { return serviceVersion; } + /** + * Gets the file ID used to address the file, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + AzureSasCredential getSasToken() { return sasToken; } + /** + * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * + * @return A response containing the file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileLinksWithResponse() { + return getFileLinksWithResponse(null); + } + + /** + * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * + * @param requestConditions Conditions to apply to the request. + * @return A response containing the file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileLinksWithResponse(ShareRequestConditions requestConditions) { + try { + FileIdOperations.ensureFileIdAddressed(fileId, "getFileLinks"); + return withContext(context -> getFileLinksWithResponse(requestConditions, context)); + } catch (RuntimeException exception) { + return monoError(LOGGER, exception); + } + } + + Mono> getFileLinksWithResponse(ShareRequestConditions requestConditions, Context context) { + ShareRequestConditions conditions + = requestConditions == null ? new ShareRequestConditions() : requestConditions; + return azureFileStorageClient.getFiles() + .getHardLinksWithResponseAsync(shareName, fileId, snapshot, null, null, conditions.getLeaseId(), context) + .map(ModelHelper::getFileLinksResponse); + } + + /** + * Gets the file links. + * + * @return The file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFileLinks() { + return getFileLinks(null); + } + + /** + * Gets the file links. + * + * @param requestConditions Conditions to apply to the request. + * @return The file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFileLinks(ShareRequestConditions requestConditions) { + return getFileLinksWithResponse(requestConditions).flatMap(FluxUtil::toMono); + } + /** * Determines if the file this client represents exists in the cloud. * @@ -261,6 +339,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { + FileIdOperations.ensurePathAddressed(fileId, "exists"); return this.getPropertiesWithResponse(null, context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -464,6 +543,7 @@ Mono> createWithResponse(long maxSize, ShareFileHttpHead FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties filePosixProperties, Map metadata, ShareRequestConditions requestConditions, FilePropertySemantics filePropertySemantics, BinaryData binaryData, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "create"); final Context contextLocal = context == null ? Context.NONE : context; final ShareRequestConditions requestConditionsLocal = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -652,6 +732,7 @@ public PollerFlux beginCopy(String sourceUrl, FileSmbPr */ public PollerFlux beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { + FileIdOperations.ensurePathAddressed(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() @@ -878,6 +959,7 @@ public Mono> abortCopyWithResponse(String copyId, ShareRequestCon Mono> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "abortCopy"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .abortCopyNoCustomHeadersWithResponseAsync(shareName, filePath, copyId, null, @@ -1007,6 +1089,7 @@ public Mono> downloadToFileWithResponse(String dow Mono> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "downloadToFile"); return Mono.using(() -> channelSetup(downloadFilePath, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), channel -> getPropertiesWithResponse(requestConditions, context) .flatMap(response -> downloadResponseInChunk(response, channel, range, requestConditions, context)), @@ -1185,6 +1268,7 @@ public Mono downloadWithResponse(ShareFileDownlo } Mono downloadWithResponse(ShareFileDownloadOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "download"); options = options == null ? new ShareFileDownloadOptions() : options; ShareFileRange range = options.getRange() == null ? new ShareFileRange(0) : options.getRange(); ShareRequestConditions requestConditions @@ -1349,6 +1433,7 @@ public Mono> deleteWithResponse(ShareRequestConditions requestCon } Mono> deleteWithResponse(ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "delete"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .deleteNoCustomHeadersWithResponseAsync(shareName, filePath, null, requestConditions.getLeaseId(), context); @@ -1530,6 +1615,11 @@ Mono> getPropertiesWithResponse(ShareRequestCondit Context context) { requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; + if (!fileId.isEmpty()) { + return azureFileStorageClient.getFileIdOperations() + .getFilePropertiesAsync(shareName, fileId, snapshot, null, requestConditions.getLeaseId(), context) + .map(ModelHelper::getPropertiesResponse); + } return azureFileStorageClient.getFiles() .getPropertiesWithResponseAsync(shareName, filePath, snapshot, null, requestConditions.getLeaseId(), context) @@ -1779,6 +1869,7 @@ public Mono> setPropertiesWithResponse(ShareFileSetPrope Mono> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties fileposixProperties, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setProperties"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; @@ -1922,6 +2013,7 @@ public Mono> setMetadataWithResponse(Map> setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; try { @@ -2132,6 +2224,7 @@ public Mono> uploadWithResponse(ShareFileUploadOpt } Mono> uploadWithResponse(ShareFileUploadOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "upload"); try { StorageImplUtils.assertNotNull("options", options); ShareRequestConditions validatedRequestConditions = options.getRequestConditions() == null @@ -2301,6 +2394,7 @@ public Mono> uploadRangeWithResponse(ShareFileUplo * One-shot upload range. */ Mono> uploadRangeWithResponse(ShareFileUploadRangeOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "uploadRange"); ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); long rangeOffset = (options.getOffset() == null) ? 0L : options.getOffset(); @@ -2465,6 +2559,7 @@ public Mono> uploadRangeFromUrlWithRes Mono> uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "uploadRangeFromUrl"); ShareRequestConditions modifiedRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2588,6 +2683,7 @@ public Mono> clearRangeWithResponse(long length, l Mono> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "clearRange"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); context = context == null ? Context.NONE : context; @@ -2958,6 +3054,7 @@ PagedFlux listAllRangesInternal(ShareFileRange range, ShareR Mono> listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -3024,6 +3121,7 @@ public PagedFlux listHandles(Integer maxResultsPerPage) { } PagedFlux listHandlesWithOptionalTimeout(Integer maxResultsPerPage, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getFiles() .listHandlesWithResponseAsync(shareName, filePath, marker, maxResultsPerPage, null, snapshot, context), @@ -3095,6 +3193,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getFiles() .forceCloseHandlesWithResponseAsync(shareName, filePath, handleId, null, null, snapshot, context) @@ -3136,6 +3235,7 @@ public Mono forceCloseAllHandles() { } PagedFlux forceCloseAllHandlesWithOptionalTimeout(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout( this.azureFileStorageClient.getFiles() @@ -3221,6 +3321,7 @@ public Mono> renameWithResponse(ShareFileRenameOp } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -3439,6 +3540,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3490,6 +3592,7 @@ public Mono> createHardLinkWithResponse(ShareFileCreateH Mono> createHardLinkWithResponse(String targetFile, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "createHardLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return this.azureFileStorageClient.getFiles() @@ -3545,6 +3648,7 @@ public Mono> createSymbolicLinkWithResponse(ShareFileCre Mono> createSymbolicLinkWithResponse(String linkText, Map metadata, OffsetDateTime fileCreationTime, OffsetDateTime fileLastWriteTime, String owner, String group, ShareRequestConditions requestConditions, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "createSymbolicLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String fileCreationTimeString = FileSmbProperties.parseFileSMBDate(fileCreationTime); @@ -3596,6 +3700,7 @@ public Mono> getSymbolicLinkWithResponse() { } Mono> getSymbolicLinkWithResponse(Context context) { + FileIdOperations.ensurePathAddressed(fileId, "getSymbolicLink"); context = context == null ? Context.NONE : context; return this.azureFileStorageClient.getFiles() .getSymbolicLinkWithResponseAsync(shareName, filePath, null, snapshot, null, context) @@ -3630,6 +3735,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index 81febcdf9130d..f6794f35b3cff 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -33,15 +33,18 @@ import com.azure.storage.common.implementation.StorageSeekableByteChannel; import com.azure.storage.common.implementation.UploadUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.FilesCreateHardLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesCreateHeaders; import com.azure.storage.file.share.implementation.models.FilesCreateSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; +import com.azure.storage.file.share.implementation.models.HardLinkList; import com.azure.storage.file.share.implementation.models.FilesListHandlesHeaders; import com.azure.storage.file.share.implementation.models.FilesSetHttpHeadersHeaders; import com.azure.storage.file.share.implementation.models.FilesSetMetadataHeaders; @@ -66,6 +69,7 @@ import com.azure.storage.file.share.models.ShareFileDownloadResponse; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareFileInfo; +import com.azure.storage.file.share.models.ShareFileLinks; import com.azure.storage.file.share.models.ShareFileMetadataInfo; import com.azure.storage.file.share.models.ShareFilePermission; import com.azure.storage.file.share.models.ShareFileProperties; @@ -144,6 +148,7 @@ public class ShareFileClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String filePath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -163,23 +168,36 @@ public class ShareFileClient { ShareFileClient(ShareFileAsyncClient shareFileAsyncClient, AzureFileStorageImpl azureFileStorageClient, String shareName, String filePath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(shareFileAsyncClient, azureFileStorageClient, shareName, filePath, "", snapshot, accountName, + serviceVersion, sasToken); + } + + ShareFileClient(ShareFileAsyncClient shareFileAsyncClient, AzureFileStorageImpl azureFileStorageClient, + String shareName, String filePath, String fileId, String snapshot, String accountName, + ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { this.shareFileAsyncClient = shareFileAsyncClient; Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(filePath, "'filePath' cannot be null."); this.shareName = shareName; this.filePath = filePath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; this.serviceVersion = serviceVersion; this.sasToken = sasToken; - StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/") - .append(shareName) - .append("/") - .append(filePath); + StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + if (fileId.isEmpty()) { + fileUrlstring.append("/").append(filePath); + } if (snapshot != null) { fileUrlstring.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + fileUrlstring.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + fileUrlstring.append("?fileid=").append(fileId); } this.fileUrlString = fileUrlstring.toString(); } @@ -202,6 +220,15 @@ public String getFileUrl() { return this.fileUrlString; } + /** + * Gets the file ID used to address the file, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + /** * Gets the service version the client is using. * @@ -211,6 +238,67 @@ public ShareServiceVersion getServiceVersion() { return this.serviceVersion; } + /** + * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * + * @return A response containing the file properties and hard links. + */ + public Response getFileLinksWithResponse() { + return getFileLinksWithResponse(null, null, Context.NONE); + } + + /** + * Gets the hard links to this file. + * + * @param requestConditions Conditions to apply to the request. + * @return A response containing the file properties and hard links. + */ + public Response getFileLinksWithResponse(ShareRequestConditions requestConditions) { + return getFileLinksWithResponse(requestConditions, null, Context.NONE); + } + + /** + * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * + * @param requestConditions Conditions to apply to the request. + * @param timeout An optional timeout applied to the operation. + * @param context Additional context passed through the HTTP pipeline. + * @return A response containing the file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFileLinksWithResponse(ShareRequestConditions requestConditions, Duration timeout, + Context context) { + FileIdOperations.ensureFileIdAddressed(fileId, "getFileLinks"); + ShareRequestConditions conditions + = requestConditions == null ? new ShareRequestConditions() : requestConditions; + Context finalContext = context == null ? Context.NONE : context; + Callable> operation = () -> azureFileStorageClient + .getFiles() + .getHardLinksWithResponse(shareName, fileId, snapshot, null, null, conditions.getLeaseId(), finalContext); + return ModelHelper.getFileLinksResponse(sendRequest(operation, timeout, ShareStorageException.class)); + } + + /** + * Gets the file links. + * + * @return The file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ShareFileLinks getFileLinks() { + return getFileLinksWithResponse().getValue(); + } + + /** + * Gets the file links. + * + * @param requestConditions Conditions to apply to the request. + * @return The file properties and hard links. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ShareFileLinks getFileLinks(ShareRequestConditions requestConditions) { + return getFileLinksWithResponse(requestConditions, null, Context.NONE).getValue(); + } + /** * Opens a file input stream to download the file. * @@ -229,6 +317,7 @@ public final StorageFileInputStream openInputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileInputStream openInputStream(ShareFileRange range) { + FileIdOperations.ensurePathAddressed(fileId, "openInputStream"); return new StorageFileInputStream(shareFileAsyncClient, range.getStart(), range.getEnd() == null ? null : (range.getEnd() - range.getStart() + 1)); } @@ -253,6 +342,7 @@ public final StorageFileOutputStream getFileOutputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileOutputStream getFileOutputStream(long offset) { + FileIdOperations.ensurePathAddressed(fileId, "getFileOutputStream"); return new StorageFileOutputStream(shareFileAsyncClient, offset); } @@ -262,6 +352,7 @@ public final StorageFileOutputStream getFileOutputStream(long offset) { * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByteChannelWriteOptions options) { + FileIdOperations.ensurePathAddressed(fileId, "getFileSeekableByteChannelWrite"); Objects.requireNonNull(options, "'options' cannot be null."); if (options.isOverwriteMode()) { @@ -282,6 +373,7 @@ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByte * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelRead(ShareFileSeekableByteChannelReadOptions options) { + FileIdOperations.ensurePathAddressed(fileId, "getFileSeekableByteChannelRead"); ShareRequestConditions conditions = options != null ? options.getRequestConditions() : null; Long configuredChunkSize = options != null ? options.getChunkSizeInBytes() : null; int chunkSize @@ -326,6 +418,7 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -531,6 +624,7 @@ public Response createWithResponse(long maxSize, ShareFileHttpHea @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareFileCreateOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "create"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -721,6 +815,7 @@ public SyncPoller beginCopy(String sourceUrl, FileSmbPr */ public SyncPoller beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { + FileIdOperations.ensurePathAddressed(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -936,6 +1031,7 @@ public Response abortCopyWithResponse(String copyId, Duration timeout, Con @ServiceMethod(returns = ReturnType.SINGLE) public Response abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "abortCopy"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1310,6 +1406,7 @@ public Response deleteWithResponse(Duration timeout, Context context) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(ShareRequestConditions requestConditions, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1480,9 +1577,13 @@ public Response getPropertiesWithResponse(ShareRequestCondi Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; - Callable> operation = () -> this.azureFileStorageClient.getFiles() - .getPropertiesWithResponse(shareName, filePath, snapshot, null, finalRequestConditions.getLeaseId(), - finalContext); + Callable> operation = fileId.isEmpty() + ? () -> this.azureFileStorageClient.getFiles() + .getPropertiesWithResponse(shareName, filePath, snapshot, null, finalRequestConditions.getLeaseId(), + finalContext) + : () -> this.azureFileStorageClient.getFileIdOperations() + .getFileProperties(shareName, fileId, snapshot, null, finalRequestConditions.getLeaseId(), + finalContext); return ModelHelper.getPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); } @@ -1716,6 +1817,7 @@ public Response setPropertiesWithResponse(long newFileSize, Share @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareFileSetPropertiesOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setProperties"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions @@ -1869,6 +1971,7 @@ public Response setMetadataWithResponse(Map setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2276,6 +2379,7 @@ public Response uploadRangeFromUrlWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "uploadRangeFromUrl"); ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2390,6 +2494,7 @@ public Response clearRangeWithResponse(long length, long of @ServiceMethod(returns = ReturnType.SINGLE) public Response clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "clearRange"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); @@ -2546,6 +2651,7 @@ public PagedIterable listRanges(ShareFileRange range, Duration t @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRanges(ShareFileRange range, ShareRequestConditions requestConditions, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listRanges"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2735,6 +2841,7 @@ public ShareFileRangeList listRangesDiff(String previousSnapshot) { @ServiceMethod(returns = ReturnType.SINGLE) public Response listRangesDiffWithResponse(ShareFileListRangesDiffOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listRangesDiff"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); @@ -2798,6 +2905,7 @@ public PagedIterable listHandles() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listHandles(Integer maxResultsPerPage, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -2876,6 +2984,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> azureFileStorageClient.getFiles() .forceCloseHandlesWithResponse(shareName, filePath, handleId, null, null, snapshot, finalContext); @@ -2913,6 +3022,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -3001,6 +3111,7 @@ public ShareFileClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions sourceRequestConditions = options.getSourceRequestConditions() == null @@ -3223,6 +3334,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3267,6 +3379,7 @@ public ShareFileInfo createHardLink(String targetFile) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createHardLinkWithResponse(ShareFileCreateHardLinkOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "createHardLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3318,6 +3431,7 @@ public ShareFileInfo createSymbolicLink(String linkText) { */ public Response createSymbolicLinkWithResponse(ShareFileCreateSymbolicLinkOptions options, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "createSymbolicLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3368,6 +3482,7 @@ public ShareFileSymbolicLinkInfo getSymbolicLink() { * describing the symbolic link. */ public Response getSymbolicLinkWithResponse(Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "getSymbolicLink"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -3405,6 +3520,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } @@ -3412,6 +3528,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ ResponseBase listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Duration timeout, Context context) { + FileIdOperations.ensurePathAddressed(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String rangeString = range == null ? null : range.toString(); diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index fe1fbc329ade4..eca27ad656c74 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -35,6 +35,7 @@ import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.sas.CommonSasQueryParameters; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.FileIdOperations; import com.azure.storage.file.share.implementation.util.BuilderHelper; import com.azure.storage.file.share.models.ShareAudience; import com.azure.storage.file.share.models.ShareTokenIntent; @@ -162,6 +163,7 @@ public class ShareFileClientBuilder implements TokenCredentialTrait * - *

Query parameters of the endpoint will be parsed in an attempt to generate a SAS token to authenticate - * requests sent to the service.

+ *

The {@code sharesnapshot} and {@code fileid} query parameters are parsed from the endpoint. Other query + * parameters are parsed in an attempt to generate a SAS token to authenticate requests sent to the service.

* * @param endpoint The URL of the Azure Storage File instance to send service requests to and receive responses * from. @@ -340,10 +342,19 @@ public ShareFileClientBuilder endpoint(String endpoint) { this.shareSnapshot = snapshotArray[0]; } + this.fileId = ""; + String[] fileIdArray = queryParamsMap.remove("fileid"); + if (fileIdArray != null) { + if (CoreUtils.isNullOrEmpty(fileIdArray[0])) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be empty.")); + } + this.fileId = fileIdArray[0]; + this.resourcePath = ""; + } + // TODO (gapra): What happens if a user has custom queries? // Attempt to get the SAS token from the URL passed - String sasToken - = new CommonSasQueryParameters(SasImplUtils.parseQueryString(fullUrl.getQuery()), false).encode(); + String sasToken = new CommonSasQueryParameters(queryParamsMap, false).encode(); if (!CoreUtils.isNullOrEmpty(sasToken)) { sasToken(sasToken); } @@ -367,6 +378,23 @@ public ShareFileClientBuilder shareName(String shareName) { return this; } + /** + * Sets the file ID used to address a file or directory. + * + *

Setting a file ID clears the resource path. The file ID can also be read from the {@code fileid} query + * parameter when supplied in the endpoint.

+ * + * @param fileId The file ID of the file or directory. + * @return the updated ShareFileClientBuilder object + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareFileClientBuilder fileId(String fileId) { + FileIdOperations.validateFileId(fileId); + this.fileId = fileId; + this.resourcePath = ""; + return this; + } + /** * Sets the shareSnapshot that the constructed clients will interact with. This shareSnapshot must be linked to the * share that has been specified in the builder. @@ -381,7 +409,8 @@ public ShareFileClientBuilder snapshot(String snapshot) { } /** - * Sets the file that the constructed clients will interact with + * Sets the file or directory path that the constructed clients will interact with. Calling this method clears any + * file ID previously set with {@link #fileId(String)}. * * @param resourcePath Path of the file (or directory). * @return the updated ShareFileClientBuilder object @@ -389,6 +418,7 @@ public ShareFileClientBuilder snapshot(String snapshot) { */ public ShareFileClientBuilder resourcePath(String resourcePath) { this.resourcePath = resourcePath; + this.fileId = ""; return this; } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java index b46ccad589380..49240a02545bf 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java @@ -146,6 +146,7 @@ public SharesImpl getShares() { * The DirectoriesImpl object to access its operations. */ private final DirectoriesImpl directories; + private final FileIdOperations fileIdOperations; /** * Gets the DirectoriesImpl object to access its operations. @@ -170,6 +171,15 @@ public FilesImpl getFiles() { return this.files; } + /** + * Gets the REST operations that address files and directories by ID. + * + * @return The file-ID REST operations. + */ + public FileIdOperations getFileIdOperations() { + return this.fileIdOperations; + } + /** * Initializes an instance of AzureFileStorage client. * @@ -226,5 +236,6 @@ public AzureFileStorageImpl(HttpPipeline httpPipeline, SerializerAdapter seriali this.shares = new SharesImpl(this); this.directories = new DirectoriesImpl(this); this.files = new FilesImpl(this); + this.fileIdOperations = new FileIdOperations(this); } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java new file mode 100644 index 0000000000000..5dac091238779 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.Head; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.http.rest.ResponseBase; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.Context; +import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; +import com.azure.storage.file.share.implementation.models.ShareStorageExceptionInternal; +import com.azure.storage.file.share.implementation.util.ModelHelper; +import com.azure.storage.file.share.models.ShareTokenIntent; +import reactor.core.publisher.Mono; + +/** + * REST operations that accept a file ID as a query parameter but are not represented by the generated operation + * signatures. + */ +public final class FileIdOperations { + private static final ClientLogger LOGGER = new ClientLogger(FileIdOperations.class); + + private final OperationsService service; + private final AzureFileStorageImpl client; + + /** + * Creates a file-ID operations client. + * + * @param client The generated service client. + */ + public FileIdOperations(AzureFileStorageImpl client) { + this.client = client; + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + } + + /** + * Validates a file ID accepted by a client factory or builder. + * + * @param fileId The ID to validate. + * @throws IllegalArgumentException If the ID is null or blank. + */ + public static void validateFileId(String fileId) { + if (fileId == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be null.")); + } + if (fileId.trim().isEmpty()) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be empty.")); + } + } + + /** + * Ensures an operation is used with a file-ID-addressed client. + * + * @param fileId The client's file ID. + * @param operationName The operation name to report on failure. + */ + public static void ensureFileIdAddressed(String fileId, String operationName) { + if (fileId == null || fileId.isEmpty()) { + throw LOGGER.logExceptionAsError( + new IllegalStateException(operationName + " requires a file-ID-addressed client.")); + } + } + + /** + * Ensures a path-based operation is not used with a file-ID-addressed client. + * + * @param fileId The client's file ID. + * @param operationName The operation name to report on failure. + */ + public static void ensurePathAddressed(String fileId, String operationName) { + if (fileId != null && !fileId.isEmpty()) { + throw LOGGER.logExceptionAsError( + new IllegalStateException(operationName + " is not supported for a file-ID-addressed client.")); + } + } + + public Mono> getFilePropertiesAsync(String shareName, String fileId, + String snapshot, Integer timeout, String leaseId, Context context) { + return service + .getFileProperties(client.getUrl(), shareName, fileId, snapshot, timeout, client.isAllowTrailingDot(), + client.getVersion(), leaseId, client.getFileRequestIntent(), null, "application/xml", context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + public ResponseBase getFileProperties(String shareName, String fileId, + String snapshot, Integer timeout, String leaseId, Context context) { + try { + return service.getFilePropertiesSync(client.getUrl(), shareName, fileId, snapshot, timeout, + client.isAllowTrailingDot(), client.getVersion(), leaseId, client.getFileRequestIntent(), null, + "application/xml", context); + } catch (ShareStorageExceptionInternal exception) { + throw LOGGER.logExceptionAsError(ModelHelper.mapToShareStorageException(exception)); + } + } + + public Mono> getDirectoryPropertiesAsync(String shareName, + String fileId, String snapshot, Integer timeout, Context context) { + return service + .getDirectoryProperties(client.getUrl(), shareName, "directory", fileId, snapshot, timeout, + client.isAllowTrailingDot(), client.getVersion(), client.getFileRequestIntent(), null, + "application/xml", context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + public ResponseBase getDirectoryProperties(String shareName, String fileId, + String snapshot, Integer timeout, Context context) { + try { + return service.getDirectoryPropertiesSync(client.getUrl(), shareName, "directory", fileId, snapshot, + timeout, client.isAllowTrailingDot(), client.getVersion(), client.getFileRequestIntent(), null, + "application/xml", context); + } catch (ShareStorageExceptionInternal exception) { + throw LOGGER.logExceptionAsError(ModelHelper.mapToShareStorageException(exception)); + } + } + + @Host("{url}") + @ServiceInterface(name = "AzureFileStorageByFileId") + public interface OperationsService { + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + Mono> getFileProperties(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String snapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, + Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + ResponseBase getFilePropertiesSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String snapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, + Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + Mono> getDirectoryProperties(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String resourceType, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String snapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, + Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + ResponseBase getDirectoryPropertiesSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String resourceType, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String snapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, + Context context); + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java index 7dd95ad83c29a..158fb7df90647 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java @@ -34,10 +34,12 @@ public interface ShareDirectoryPropertiesAccessor { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. + * @param fileName The name of the directory when returned by a file-ID request. * @return A new instance of {@link ShareDirectoryProperties}. */ ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties); + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, + String fileName); } /** @@ -59,11 +61,12 @@ public static void setAccessor(ShareDirectoryPropertiesAccessor accessor) { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. + * @param fileName The name of the directory when returned by a file-ID request. * @return A new instance of {@link ShareDirectoryProperties}. */ public static ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, boolean isServerEncrypted, FileSmbProperties smbProperties, - FilePosixProperties posixProperties) { + FilePosixProperties posixProperties, String fileName) { // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the // application accesses ShareDirectoryProperties which triggers the accessor to be configured. So, if the accessor // is null this effectively pokes the class to set up the accessor. @@ -72,6 +75,7 @@ public static ShareDirectoryProperties create(Map metadata, Stri } assert accessor != null; - return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties); + return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties, + fileName); } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFilePropertiesHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFilePropertiesHelper.java index 7e6c151276cc8..31ae579a728d1 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFilePropertiesHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFilePropertiesHelper.java @@ -37,6 +37,7 @@ public interface ShareFilePropertiesAccessor { * @param contentLength The number of bytes present in the response body. * @param contentType The content type specified for the file. The default content type is * application/octet-stream. + * @param contentLanguage The content language specified for the file. * @param contentMd5 The MD5 hash of the file to check the message content integrity. * @param contentEncoding This header returns the value that was specified for the Content-Encoding request header. * @param cacheControl This header is returned if it was previously specified for the file. @@ -67,15 +68,16 @@ public interface ShareFilePropertiesAccessor { * completely encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the file. * @param posixProperties The NFS properties of the file. + * @param fileName The name of the file when returned by a file-ID request. * @return A new instance of {@link ShareFileProperties}. */ ShareFileProperties create(String eTag, OffsetDateTime lastModified, Map metadata, - String fileType, Long contentLength, String contentType, byte[] contentMd5, String contentEncoding, - String cacheControl, String contentDisposition, LeaseStatusType leaseStatusType, + String fileType, Long contentLength, String contentType, String contentLanguage, byte[] contentMd5, + String contentEncoding, String cacheControl, String contentDisposition, LeaseStatusType leaseStatusType, LeaseStateType leaseStateType, LeaseDurationType leaseDurationType, OffsetDateTime copyCompletionTime, String copyStatusDescription, String copyId, String copyProgress, String copySource, CopyStatusType copyStatus, Boolean isServerEncrypted, FileSmbProperties smbProperties, - FilePosixProperties posixProperties); + FilePosixProperties posixProperties, String fileName); } /** @@ -97,6 +99,7 @@ public static void setAccessor(ShareFilePropertiesAccessor accessor) { * @param contentLength The number of bytes present in the response body. * @param contentType The content type specified for the file. The default content type is * application/octet-stream. + * @param contentLanguage The content language specified for the file. * @param contentMd5 The MD5 hash of the file to check the message content integrity. * @param contentEncoding This header returns the value that was specified for the Content-Encoding request header. * @param cacheControl This header is returned if it was previously specified for the file. @@ -127,14 +130,16 @@ public static void setAccessor(ShareFilePropertiesAccessor accessor) { * completely encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the file. * @param posixProperties The NFS properties of the file. + * @param fileName The name of the file when returned by a file-ID request. * @return A new instance of {@link ShareFileProperties}. */ public static ShareFileProperties create(String eTag, OffsetDateTime lastModified, Map metadata, - String fileType, Long contentLength, String contentType, byte[] contentMd5, String contentEncoding, - String cacheControl, String contentDisposition, LeaseStatusType leaseStatusType, LeaseStateType leaseStateType, - LeaseDurationType leaseDurationType, OffsetDateTime copyCompletionTime, String copyStatusDescription, - String copyId, String copyProgress, String copySource, CopyStatusType copyStatus, Boolean isServerEncrypted, - FileSmbProperties smbProperties, FilePosixProperties posixProperties) { + String fileType, Long contentLength, String contentType, String contentLanguage, byte[] contentMd5, + String contentEncoding, String cacheControl, String contentDisposition, LeaseStatusType leaseStatusType, + LeaseStateType leaseStateType, LeaseDurationType leaseDurationType, OffsetDateTime copyCompletionTime, + String copyStatusDescription, String copyId, String copyProgress, String copySource, CopyStatusType copyStatus, + Boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, + String fileName) { // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the // application accesses ShareFileProperties which triggers the accessor to be configured. So, if the accessor // is null this effectively pokes the class to set up the accessor. @@ -144,9 +149,9 @@ public static ShareFileProperties create(String eTag, OffsetDateTime lastModifie } assert accessor != null; - return accessor.create(eTag, lastModified, metadata, fileType, contentLength, contentType, contentMd5, - contentEncoding, cacheControl, contentDisposition, leaseStatusType, leaseStateType, leaseDurationType, - copyCompletionTime, copyStatusDescription, copyId, copyProgress, copySource, copyStatus, isServerEncrypted, - smbProperties, posixProperties); + return accessor.create(eTag, lastModified, metadata, fileType, contentLength, contentType, contentLanguage, + contentMd5, contentEncoding, cacheControl, contentDisposition, leaseStatusType, leaseStateType, + leaseDurationType, copyCompletionTime, copyStatusDescription, copyId, copyProgress, copySource, copyStatus, + isServerEncrypted, smbProperties, posixProperties, fileName); } } 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 dd398752a1cd0..d30e35a89037c 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 @@ -42,8 +42,11 @@ import com.azure.storage.file.share.implementation.models.FilesCreateHeaders; import com.azure.storage.file.share.implementation.models.FilesCreateSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; +import com.azure.storage.file.share.implementation.models.HardLink; +import com.azure.storage.file.share.implementation.models.HardLinkList; import com.azure.storage.file.share.implementation.models.FilesSetHttpHeadersHeaders; import com.azure.storage.file.share.implementation.models.FilesSetMetadataHeaders; import com.azure.storage.file.share.implementation.models.FilesUploadRangeFromURLHeaders; @@ -80,6 +83,8 @@ import com.azure.storage.file.share.models.ShareFileInfo; import com.azure.storage.file.share.models.ShareFileItem; import com.azure.storage.file.share.models.ShareFileItemProperties; +import com.azure.storage.file.share.models.ShareFileLink; +import com.azure.storage.file.share.models.ShareFileLinks; import com.azure.storage.file.share.models.ShareFileMetadataInfo; import com.azure.storage.file.share.models.ShareFileProperties; import com.azure.storage.file.share.models.ShareFileRange; @@ -434,9 +439,10 @@ public static Response createFileInfoResponse(ResponseBase(response, shareFileProperties); } @@ -601,8 +607,9 @@ public static Response mapGetStatisticsResponse(Response(response, shareDirectoryProperties); } @@ -858,4 +865,26 @@ public static List toShareFileRangeItems(ShareFileRangeList } return ranges; } + + public static Response + getFileLinksResponse(ResponseBase response) { + FilesGetHardLinksHeaders headers = response.getDeserializedHeaders(); + FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders()); + FilePosixProperties posixProperties = FilePosixPropertiesHelper.create(response.getHeaders()); + ShareFileProperties properties = ShareFilePropertiesHelper.create(headers.getETag(), headers.getLastModified(), + headers.getXMsMeta(), headers.getXMsType(), headers.getXMsContentLength(), headers.getXMsContentType(), + headers.getXMsContentLanguage(), headers.getXMsContentMd5(), headers.getXMsContentEncoding(), + headers.getXMsCacheControl(), headers.getXMsContentDisposition(), headers.getXMsLeaseStatus(), + headers.getXMsLeaseState(), headers.getXMsLeaseDuration(), headers.getXMsCopyCompletionTime(), + headers.getXMsCopyStatusDescription(), headers.getXMsCopyId(), headers.getXMsCopyProgress(), + headers.getXMsCopySource(), headers.getXMsCopyStatus(), headers.isXMsServerEncrypted(), smbProperties, + posixProperties, headers.getXMsFileName()); + List links = new ArrayList<>(); + for (HardLink hardLink : response.getValue().getHardLinks()) { + StringEncoded encodedFileName = hardLink.getFileName(); + links.add(new ShareFileLink(hardLink.getParentId(), + encodedFileName == null ? null : decodeName(encodedFileName))); + } + return new SimpleResponse<>(response, new ShareFileLinks(properties, links)); + } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java index b70915b269370..024a24a26193e 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java @@ -21,6 +21,7 @@ public final class ShareDirectoryProperties { private final boolean isServerEncrypted; private final FileSmbProperties smbProperties; private final FilePosixProperties posixProperties; + private final String fileName; /** * Creates an instance of properties information about a specific Directory. @@ -40,17 +41,20 @@ public ShareDirectoryProperties(Map metadata, String eTag, Offse this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = null; + this.fileName = null; } //Internal constructor to support FilePosixProperties class. private ShareDirectoryProperties(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties) { + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, + String fileName) { this.metadata = metadata; this.eTag = eTag; this.lastModified = lastModified; this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = posixProperties; + this.fileName = fileName; } static { @@ -113,4 +117,13 @@ public FileSmbProperties getSmbProperties() { public FilePosixProperties getPosixProperties() { return posixProperties; } + + /** + * Gets the name of the directory returned by a request addressed by file ID. + * + * @return The directory name, or {@code null} when the service did not return it. + */ + public String getFileName() { + return fileName; + } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLink.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLink.java new file mode 100644 index 0000000000000..ade041f892a12 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLink.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share.models; + +import com.azure.core.annotation.Immutable; + +/** + * Describes one path that links to a file. + */ +@Immutable +public final class ShareFileLink { + private final String parentId; + private final String name; + + /** + * Creates a file link. + * + * @param parentId The file ID of the parent directory. + * @param name The name of the file link. + */ + public ShareFileLink(String parentId, String name) { + this.parentId = parentId; + this.name = name; + } + + /** + * Gets the file ID of the parent directory. + * + * @return The parent directory ID. + */ + public String getParentId() { + return parentId; + } + + /** + * Gets the name of the file link. + * + * @return The file link name. + */ + public String getName() { + return name; + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLinks.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLinks.java new file mode 100644 index 0000000000000..6810198e76076 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileLinks.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share.models; + +import com.azure.core.annotation.Immutable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Contains a file's properties and the paths that link to the file. + */ +@Immutable +public final class ShareFileLinks { + private final ShareFileProperties properties; + private final List links; + + /** + * Creates a file links result. + * + * @param properties The file's properties. + * @param links The paths that link to the file. + */ + public ShareFileLinks(ShareFileProperties properties, List links) { + this.properties = Objects.requireNonNull(properties, "'properties' cannot be null."); + this.links + = Collections.unmodifiableList(new ArrayList<>(Objects.requireNonNull(links, "'links' cannot be null."))); + } + + /** + * Gets the file's properties. + * + * @return The file's properties. + */ + public ShareFileProperties getProperties() { + return properties; + } + + /** + * Gets the paths that link to the file. + * + * @return The file links. + */ + public List getLinks() { + return links; + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileProperties.java index 740d480e88b36..321d815a429be 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileProperties.java @@ -22,6 +22,7 @@ public final class ShareFileProperties { private final String fileType; private final Long contentLength; private final String contentType; + private final String contentLanguage; private final byte[] contentMd5; private final String contentEncoding; private final String cacheControl; @@ -38,6 +39,7 @@ public final class ShareFileProperties { private final Boolean isServerEncrypted; private final FileSmbProperties smbProperties; private final FilePosixProperties posixProperties; + private final String fileName; /** * Creates an instance of property information about a specific File. @@ -138,6 +140,7 @@ public ShareFileProperties(String eTag, OffsetDateTime lastModified, Map metadata, String fileType, - Long contentLength, String contentType, byte[] contentMd5, String contentEncoding, String cacheControl, - String contentDisposition, LeaseStatusType leaseStatusType, LeaseStateType leaseStateType, + Long contentLength, String contentType, String contentLanguage, byte[] contentMd5, String contentEncoding, + String cacheControl, String contentDisposition, LeaseStatusType leaseStatusType, LeaseStateType leaseStateType, LeaseDurationType leaseDurationType, OffsetDateTime copyCompletionTime, String copyStatusDescription, String copyId, String copyProgress, String copySource, CopyStatusType copyStatus, Boolean isServerEncrypted, - FileSmbProperties smbProperties, FilePosixProperties posixProperties) { + FileSmbProperties smbProperties, FilePosixProperties posixProperties, String fileName) { this.eTag = eTag; this.lastModified = lastModified; this.metadata = metadata; this.fileType = fileType; this.contentLength = contentLength; this.contentType = contentType; + this.contentLanguage = contentLanguage; this.contentMd5 = CoreUtils.clone(contentMd5); this.contentEncoding = contentEncoding; this.cacheControl = cacheControl; @@ -185,6 +190,7 @@ private ShareFileProperties(String eTag, OffsetDateTime lastModified, Map requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareDirectoryClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); + Assertions.assertEquals("", directoryClient.getDirectoryPath()); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + + FileIdTestHelper.FILE_ID, directoryClient.getDirectoryUrl()); + Assertions.assertEquals("directory", directoryClient.getProperties().getFileName()); + Assertions.assertTrue(requestUrl.get().startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "?restype=directory")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void directoryClientBuilderSetsFileId() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + }).build(); + + ShareDirectoryClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildDirectoryClient(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); + Assertions.assertEquals("", directoryClient.getDirectoryPath()); + Assertions.assertEquals("directory", directoryClient.getProperties().getFileName()); + Assertions.assertTrue(requestUrl.get().contains("restype=directory")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void directoryIdClientRejectsPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareDirectoryClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertThrows(IllegalStateException.class, directoryClient::exists); + Assertions.assertThrows(IllegalStateException.class, directoryClient::create); + Assertions.assertThrows(IllegalStateException.class, directoryClient::delete); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("file.txt")); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("directory")); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + Assertions.assertThrows(IllegalArgumentException.class, + () -> testShareClient.getDirectoryClientByFileId("")); + Assertions.assertThrows(IllegalArgumentException.class, + () -> testShareClient.getDirectoryClientByFileId(null)); + Assertions.assertFalse(requestSent.get()); + } + @Test public void getShareSnapshotUrl() { String accountName diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 749addc8e4b46..7f229ec9b2eaf 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -4,7 +4,12 @@ package com.azure.storage.file.share; import com.azure.core.http.HttpHeader; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.rest.Response; +import com.azure.core.test.annotation.DoNotRecord; +import com.azure.core.test.http.MockHttpResponse; import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; @@ -33,7 +38,9 @@ import com.azure.storage.file.share.options.ShareListFilesAndDirectoriesOptions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -52,6 +59,7 @@ import java.util.Map; import java.util.Objects; import java.util.Queue; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import static com.azure.storage.common.implementation.Constants.HeaderConstants.ERROR_CODE_HEADER_NAME; @@ -76,7 +84,11 @@ public class DirectoryAsyncApiTests extends FileShareTestBase { = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)S:NO_ACCESS_CONTROL"; @BeforeEach - public void setup() { + public void setup(TestInfo testInfo) { + if (testInfo.getTags().contains("file-id-mock")) { + return; + } + shareName = generateShareName(); directoryPath = generatePathName(); shareClient = shareBuilderHelper(shareName).buildClient(); @@ -97,6 +109,86 @@ public void getDirectoryURL() { assertEquals(expectURL, directoryURL); } + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncDirectoryPropertiesByIdUseFileIdQueryAndMapFileName() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareDirectoryProperties properties + = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); + + Assertions.assertEquals("directory", properties.getFileName()); + Assertions.assertTrue(requestUrl.get().contains("restype=directory")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncDirectoryClientBuilderSetsFileId() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + }).build(); + + ShareDirectoryAsyncClient directoryClient = new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildDirectoryAsyncClient(); + ShareDirectoryProperties properties = directoryClient.getProperties().block(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); + Assertions.assertEquals("", directoryClient.getDirectoryPath()); + Assertions.assertEquals("directory", properties.getFileName()); + Assertions.assertTrue(requestUrl.get().contains("restype=directory")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncDirectoryIdClientRejectsPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareDirectoryAsyncClient directoryClient + = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.create().block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.delete().block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.exists().block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null).block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination").block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.listFilesAndDirectories().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, + () -> directoryClient.forceCloseAllHandles(false).block()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + Assertions.assertFalse(requestSent.get()); + } + @Test public void getSubDirectoryClient() { ShareDirectoryAsyncClient subDirectoryClient diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index f2d1e78db613c..b376cce97c348 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -6,8 +6,14 @@ import com.azure.core.exception.UnexpectedLengthException; import com.azure.core.http.HttpHeader; import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; +import com.azure.core.test.annotation.DoNotRecord; +import com.azure.core.test.http.MockHttpResponse; import com.azure.core.test.TestMode; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; @@ -51,6 +57,7 @@ import com.azure.storage.file.share.models.ShareFileHandleAccessRights; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareFileInfo; +import com.azure.storage.file.share.models.ShareFileLinks; import com.azure.storage.file.share.models.ShareFileItem; import com.azure.storage.file.share.models.ShareFileMetadataInfo; import com.azure.storage.file.share.models.ShareFilePermission; @@ -85,7 +92,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -121,6 +130,8 @@ import java.util.Scanner; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.concurrent.atomic.AtomicReference; +import reactor.core.publisher.Mono; import static com.azure.storage.common.implementation.Constants.HeaderConstants.ERROR_CODE_HEADER_NAME; import static org.junit.jupiter.api.Assertions.assertArrayEquals; @@ -148,7 +159,11 @@ class FileApiTests extends FileShareTestBase { = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)S:NO_ACCESS_CONTROL"; @BeforeEach - public void setup() { + public void setup(TestInfo testInfo) { + if (testInfo.getTags().contains("file-id-mock")) { + return; + } + shareName = generateShareName(); filePath = generatePathName(); shareClient = shareBuilderHelper(shareName).buildClient(); @@ -170,6 +185,229 @@ public void getFileURL() { assertEquals(expectURL, fileURL); } + @DoNotRecord + @Tag("file-id-mock") + @Test + public void filePropertiesByIdUseFileIdQueryAndMapFileName() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); + Assertions.assertEquals("", fileClient.getFilePath()); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); + Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + + FileIdTestHelper.FILE_ID, requestUrl.get()); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileLinksMapPropertiesAndDecodeLinkNames() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + String body = "file%20name.txt" + + "parent-id" + ""; + HttpHeaders headers = FileIdTestHelper.fileHeaders("file.txt") + .set(HttpHeaderName.CONTENT_TYPE, "application/xml"); + return Mono.just(new MockHttpResponse(request, 200, headers, body.getBytes(StandardCharsets.UTF_8))); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareFileLinks links = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getFileLinks(); + + Assertions.assertEquals("file.txt", links.getProperties().getFileName()); + Assertions.assertEquals("en", links.getProperties().getContentLanguage()); + Assertions.assertEquals("gzip", links.getProperties().getContentEncoding()); + Assertions.assertEquals(1, links.getLinks().size()); + Assertions.assertEquals("file name.txt", links.getLinks().get(0).getName()); + Assertions.assertEquals("parent-id", links.getLinks().get(0).getParentId()); + Assertions.assertTrue(requestUrl.get().contains("comp=hardlinks")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileIdClientsRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertThrows(IllegalStateException.class, fileClient::exists); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024)); + Assertions.assertThrows(IllegalStateException.class, fileClient::delete); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination")); + Assertions.assertThrows(IllegalStateException.class, fileClient::getFileOutputStream); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); + Assertions.assertThrows(IllegalStateException.class, + () -> testShareClient.getFileClient("path/file").getFileLinks()); + Assertions.assertThrows(IllegalArgumentException.class, + () -> testShareClient.getFileClientByFileId(" ")); + Assertions.assertThrows(IllegalArgumentException.class, + () -> testShareClient.getFileClientByFileId(null)); + Assertions.assertFalse(requestSent.get()); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileClientBuilderParsesFileIdFromEndpointQuery() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareFileClient fileClient + = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "?fileid=" + FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); + Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + + FileIdTestHelper.FILE_ID, requestUrl.get()); + + ShareFileClient pathClient = new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/file.txt") + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); + Assertions.assertEquals("", pathClient.getFileId()); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileClientBuilderSetsFileId() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareFileClient fileClient = new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/previous/path") + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); + Assertions.assertEquals("", fileClient.getFilePath()); + Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + + ShareFileClient pathClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .resourcePath("path/file.txt") + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); + Assertions.assertEquals("", pathClient.getFileId()); + Assertions.assertEquals("path/file.txt", pathClient.getFilePath()); + Assertions.assertThrows(IllegalArgumentException.class, + () -> new ShareFileClientBuilder().fileId(" ")); + Assertions.assertThrows(IllegalArgumentException.class, + () -> new ShareFileClientBuilder().fileId(null)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileClientBuilderParsesFileIdAndSnapshotFromEndpointQuery() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + String endpoint = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?sharesnapshot=snapshot-id" + + "&fileid=" + FileIdTestHelper.FILE_ID; + + ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(endpoint) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); + + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "?sharesnapshot=snapshot-id&fileid=" + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); + fileClient.getProperties(); + Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot-id")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileClientBuilderParsesFileIdAndSasFromEndpointQuery() { + String endpoint = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + + FileIdTestHelper.FILE_ID + "&sig=signature"; + + ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(endpoint).buildFileClient(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); + Assertions.assertTrue(fileClient.getSasToken().getSignature().contains("sig=signature")); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void fileIdClientsPreserveShareSnapshot() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME) + .getSnapshotClient("snapshot-id"); + ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "?sharesnapshot=snapshot-id&fileid=" + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); + fileClient.getProperties(); + Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot-id")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + @Test public void getShareSnapshotURL() { String accountName diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 99d9120e0dd92..5cc54e2792270 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -6,8 +6,14 @@ import com.azure.core.exception.UnexpectedLengthException; import com.azure.core.http.HttpHeader; import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.rest.Response; +import com.azure.core.test.annotation.DoNotRecord; import com.azure.core.test.TestMode; +import com.azure.core.test.http.MockHttpResponse; import com.azure.core.util.BinaryData; import com.azure.core.util.CoreUtils; import com.azure.core.util.FluxUtil; @@ -38,6 +44,7 @@ import com.azure.storage.file.share.models.ShareFileDownloadHeaders; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareFileInfo; +import com.azure.storage.file.share.models.ShareFileLinks; import com.azure.storage.file.share.models.ShareFilePermission; import com.azure.storage.file.share.models.ShareFileProperties; import com.azure.storage.file.share.models.ShareFileRange; @@ -65,7 +72,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -102,6 +111,7 @@ import java.util.Map; import java.util.Objects; import java.util.Scanner; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -128,7 +138,11 @@ public class FileAsyncApiTests extends FileShareTestBase { = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)S:NO_ACCESS_CONTROL"; @BeforeEach - public void setup() { + public void setup(TestInfo testInfo) { + if (testInfo.getTags().contains("file-id-mock")) { + return; + } + shareName = generateShareName(); filePath = generatePathName(); shareAsyncClient = shareBuilderHelper(shareName).buildAsyncClient(); @@ -149,6 +163,116 @@ public void getFileURL() { assertEquals(expectURL, fileURL); } + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncFilePropertiesByIdUseFileIdQueryAndMapFileName() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareFileProperties properties + = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); + + Assertions.assertEquals("file.txt", properties.getFileName()); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncFileClientBuilderSetsFileId() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestUrl.set(request.getUrl().toString()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + + ShareFileAsyncClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileAsyncClient(); + ShareFileProperties properties = fileClient.getProperties().block(); + + Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); + Assertions.assertEquals("", fileClient.getFilePath()); + Assertions.assertEquals("file.txt", properties.getFileName()); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { + AtomicReference requestUrl = new AtomicReference<>(); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); + requestUrl.set(request.getUrl().toString()); + String body = "file%20name.txt" + + "parent-id" + ""; + HttpHeaders headers = FileIdTestHelper.fileHeaders("file.txt") + .set(HttpHeaderName.CONTENT_TYPE, "application/xml"); + return Mono.just(new MockHttpResponse(request, 200, headers, body.getBytes(StandardCharsets.UTF_8))); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareFileLinks links + = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getFileLinks().block(); + + Assertions.assertEquals("file.txt", links.getProperties().getFileName()); + Assertions.assertEquals("en", links.getProperties().getContentLanguage()); + Assertions.assertEquals("gzip", links.getProperties().getContentEncoding()); + Assertions.assertEquals(1, links.getLinks().size()); + Assertions.assertEquals("file name.txt", links.getLinks().get(0).getName()); + Assertions.assertEquals("parent-id", links.getLinks().get(0).getParentId()); + Assertions.assertTrue(requestUrl.get().contains("comp=hardlinks")); + Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncFileIdClientsRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareFileAsyncClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024).block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.delete().block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.exists().block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.download().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.listRanges().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null).block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination").block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles().block()); + Assertions.assertThrows(IllegalStateException.class, + () -> testShareClient.getFileClient("path/file").getFileLinks().block()); + Assertions.assertFalse(requestSent.get()); + } + @Test public void createFile() { StepVerifier.create(primaryFileAsyncClient.createWithResponse(1024, null, null, null, null)) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java new file mode 100644 index 0000000000000..9b92c31b8dff7 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; + +final class FileIdTestHelper { + static final String ENDPOINT = "https://account.file.core.windows.net"; + static final String SHARE_NAME = "share"; + static final String FILE_ID = "12384898975283830"; + + private FileIdTestHelper() { + } + + static HttpHeaders fileHeaders(String fileName) { + return new HttpHeaders().set(HttpHeaderName.ETAG, "\"0x8DEAF1479E1C087\"") + .set(HttpHeaderName.LAST_MODIFIED, "Wed, 21 Oct 2015 07:28:00 GMT") + .set(HttpHeaderName.fromString("x-ms-file-id"), FILE_ID) + .set(HttpHeaderName.fromString("x-ms-file-parent-id"), "parent-id") + .set(HttpHeaderName.fromString("x-ms-file-name"), fileName) + .set(HttpHeaderName.fromString("x-ms-type"), "file") + .set(HttpHeaderName.fromString("x-ms-server-encrypted"), "false") + .set(HttpHeaderName.fromString("x-ms-content-type"), "application/octet-stream") + .set(HttpHeaderName.fromString("x-ms-content-length"), "1024") + .set(HttpHeaderName.fromString("x-ms-content-language"), "en") + .set(HttpHeaderName.fromString("x-ms-content-encoding"), "gzip"); + } +} diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java index b9ee8dfb621ef..e2dabe2911861 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java @@ -92,38 +92,42 @@ public void beforeTest() { super.beforeTest(); prefix = StorageCommonTestUtils.getCrc32(testContextManager.getTestPlaybackRecordingName()); - if (getTestMode() != TestMode.LIVE) { - interceptorManager - .addSanitizers(Arrays.asList(new TestProxySanitizer("sig=(.*)", "REDACTED", TestProxySanitizerType.URL), - new TestProxySanitizer("x-ms-file-rename-source", ".*", "REDACTED", TestProxySanitizerType.HEADER), - new TestProxySanitizer("x-ms-copy-source", "sig=(.*)", "REDACTED", TestProxySanitizerType.HEADER), + if (!testContextManager.doNotRecordTest()) { + if (getTestMode() != TestMode.LIVE) { + interceptorManager.addSanitizers(Arrays.asList( + new TestProxySanitizer("sig=(.*)", "REDACTED", TestProxySanitizerType.URL), + new TestProxySanitizer("x-ms-file-rename-source", ".*", "REDACTED", + TestProxySanitizerType.HEADER), + new TestProxySanitizer("x-ms-copy-source", "sig=(.*)", "REDACTED", + TestProxySanitizerType.HEADER), new TestProxySanitizer("x-ms-copy-source-authorization", ".*", "REDACTED", TestProxySanitizerType.HEADER), new TestProxySanitizer("x-ms-file-rename-source-authorization", ".*", "REDACTED", TestProxySanitizerType.HEADER), new TestProxySanitizer("x-ms-link-text", "((?<=http://|https://)([^/?]+)|sig=(.*))", "REDACTED", TestProxySanitizerType.HEADER))); - } - - // Ignore changes to the order of query parameters and wholly ignore the 'sv' (service version) query parameter - // in SAS tokens. - interceptorManager - .addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false) - .setHeadersKeyOnlyMatch(Arrays.asList("x-ms-lease-id", "x-ms-proposed-lease-id", "If-Modified-Since", - "If-Unmodified-Since", "x-ms-expiry-time", "x-ms-source-if-modified-since", "x-ms-copy-source", - "x-ms-file-rename-source", "x-ms-source-if-unmodified-since", "x-ms-source-lease-id", - "x-ms-encryption-key-sha256")) - .setQueryOrderingIgnored(true) - .setIgnoredQueryParameters(Arrays.asList("sv")) - .setExcludedHeaders(Collections.singletonList("x-ms-meta-testmetadata")))); - - ShareServiceClientBuilder builder = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount()); - primaryFileServiceClient = builder.buildClient(); - primaryFileServiceAsyncClient = builder.buildAsyncClient(); + } - builder = getServiceClientBuilder(ENVIRONMENT.getPremiumFileAccount()); - premiumFileServiceClient = builder.buildClient(); - premiumFileServiceAsyncClient = builder.buildAsyncClient(); + // Ignore changes to the order of query parameters and wholly ignore the 'sv' (service version) query + // parameter in SAS tokens. + interceptorManager + .addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false) + .setHeadersKeyOnlyMatch(Arrays.asList("x-ms-lease-id", "x-ms-proposed-lease-id", "If-Modified-Since", + "If-Unmodified-Since", "x-ms-expiry-time", "x-ms-source-if-modified-since", "x-ms-copy-source", + "x-ms-file-rename-source", "x-ms-source-if-unmodified-since", "x-ms-source-lease-id", + "x-ms-encryption-key-sha256")) + .setQueryOrderingIgnored(true) + .setIgnoredQueryParameters(Arrays.asList("sv")) + .setExcludedHeaders(Collections.singletonList("x-ms-meta-testmetadata")))); + + ShareServiceClientBuilder builder = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount()); + primaryFileServiceClient = builder.buildClient(); + primaryFileServiceAsyncClient = builder.buildAsyncClient(); + + builder = getServiceClientBuilder(ENVIRONMENT.getPremiumFileAccount()); + premiumFileServiceClient = builder.buildClient(); + premiumFileServiceAsyncClient = builder.buildAsyncClient(); + } } /** @@ -132,7 +136,7 @@ public void beforeTest() { @Override protected void afterTest() { super.afterTest(); - if (getTestMode() == TestMode.PLAYBACK) { + if (getTestMode() == TestMode.PLAYBACK || testContextManager.doNotRecordTest()) { return; } From 4f75989a735e49d613fd4f4a3842046e4e424a20 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 29 Sep 2026 22:42:18 -0400 Subject: [PATCH 03/39] Regenerate File Share property-by-ID APIs from updated Swagger --- .../implementation/AzureFileStorageImpl.java | 11 - .../share/implementation/DirectoriesImpl.java | 379 ++++- .../file/share/implementation/FilesImpl.java | 409 +++++- ...rectoriesGetPropertiesByFileIdHeaders.java | 668 +++++++++ .../FilesGetPropertiesByFileIdHeaders.java | 1267 +++++++++++++++++ .../swagger/README.md | 25 +- 6 files changed, 2663 insertions(+), 96 deletions(-) create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java index 49240a02545bf..b46ccad589380 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/AzureFileStorageImpl.java @@ -146,7 +146,6 @@ public SharesImpl getShares() { * The DirectoriesImpl object to access its operations. */ private final DirectoriesImpl directories; - private final FileIdOperations fileIdOperations; /** * Gets the DirectoriesImpl object to access its operations. @@ -171,15 +170,6 @@ public FilesImpl getFiles() { return this.files; } - /** - * Gets the REST operations that address files and directories by ID. - * - * @return The file-ID REST operations. - */ - public FileIdOperations getFileIdOperations() { - return this.fileIdOperations; - } - /** * Initializes an instance of AzureFileStorage client. * @@ -236,6 +226,5 @@ public AzureFileStorageImpl(HttpPipeline httpPipeline, SerializerAdapter seriali this.shares = new SharesImpl(this); this.directories = new DirectoriesImpl(this); this.files = new FilesImpl(this); - this.fileIdOperations = new FileIdOperations(this); } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java index f166775a06c68..df88eb0e5de8a 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java @@ -26,6 +26,7 @@ import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesDeleteHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesForceCloseHandlesHeaders; +import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesByFileIdHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListFilesAndDirectoriesSegmentHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListHandlesHeaders; @@ -631,6 +632,54 @@ Response renameNoCustomHeadersSync(@HostParam("url") String url, @PathPara @HeaderParam("x-ms-source-allow-trailing-dot") Boolean allowSourceTrailingDot, @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileId( + @HostParam("url") String url, @PathParam("shareName") String shareName, + @QueryParam("restype") String restype, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + ResponseBase getPropertiesByFileIdSync( + @HostParam("url") String url, @PathParam("shareName") String shareName, + @QueryParam("restype") String restype, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); } /** @@ -653,8 +702,8 @@ Response renameNoCustomHeadersSync(@HostParam("url") String url, @PathPara * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -702,8 +751,8 @@ public Mono> createWithResponseAsyn * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -755,8 +804,8 @@ public Mono> createWithResponseAsyn * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -803,8 +852,8 @@ public Mono createAsync(String shareName, String directory, Integer timeou * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -852,8 +901,8 @@ public Mono createAsync(String shareName, String directory, Integer timeou * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -901,8 +950,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -955,8 +1004,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1011,8 +1060,8 @@ public ResponseBase createWithResponse(String sh * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1056,8 +1105,8 @@ public void create(String shareName, String directory, Integer timeout, Map deleteNoCustomHeadersWithResponse(String shareName, String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1598,8 +1647,8 @@ public Mono> setPropertiesWi * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1647,8 +1696,8 @@ public Mono> setPropertiesWi * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1690,8 +1739,8 @@ public Mono setPropertiesAsync(String shareName, String directory, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1734,8 +1783,8 @@ public Mono setPropertiesAsync(String shareName, String directory, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1778,8 +1827,8 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync(String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1827,8 +1876,8 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync(String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1878,8 +1927,8 @@ public ResponseBase setPropertiesWithResp * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1919,8 +1968,8 @@ public void setProperties(String shareName, String directory, Integer timeout, S * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3767,4 +3816,262 @@ public Response renameNoCustomHeadersWithResponse(String shareName, String throw ModelHelper.mapToShareStorageException(internalException); } } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, + requestId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { + final String restype = "directory"; + final String accept = "application/xml"; + return service + .getPropertiesByFileId(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, timeout, + this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, Context context) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, + sharesnapshot, timeout, requestId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, Context context) { + final String restype = "directory"; + final String accept = "application/xml"; + return service + .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, + timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getPropertiesByFileIdWithResponse( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { + try { + final String restype = "directory"; + final String accept = "application/xml"; + return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, + timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId) { + getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, Context.NONE); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, Context context) { + try { + final String restype = "directory"; + final String accept = "application/xml"; + return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, restype, fileId, + sharesnapshot, timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index d27ecff38de7a..d173728c96df0 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -39,6 +39,7 @@ import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetPropertiesByFileIdHeaders; import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; @@ -106,6 +107,54 @@ public final class FilesImpl { @ServiceInterface(name = "AzureFileStorageFiles") public interface FilesService { + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileId(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + @Get("/{shareName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) @@ -1563,6 +1612,270 @@ Response createHardLinkNoCustomHeadersSync(@HostParam("url") String url, @HeaderParam("Accept") String accept, Context context); } + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, + requestId, leaseId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, + Context context) { + final String accept = "application/xml"; + return service + .getPropertiesByFileId(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId, Context context) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, + context).onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, + sharesnapshot, timeout, requestId, leaseId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + final String accept = "application/xml"; + return service + .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getPropertiesByFileIdWithResponse(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + try { + final String accept = "application/xml"; + return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, String leaseId) { + getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE); + } + + /** + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param leaseId If specified, the operation only succeeds if the resource's lease is active and matches this ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + try { + final String accept = "application/xml"; + return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, fileId, + sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties * for the file. NFS only. @@ -1859,8 +2172,8 @@ public Response getHardLinksNoCustomHeadersWithResponse(String sha * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1927,8 +2240,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2033,8 +2346,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2099,8 +2412,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2167,8 +2480,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2235,8 +2548,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2341,8 +2654,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2409,8 +2722,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2515,8 +2828,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2581,8 +2894,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2649,8 +2962,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2717,8 +3030,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2823,8 +3136,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2931,8 +3244,8 @@ public ResponseBase createWithResponse(String shareNam * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2995,8 +3308,8 @@ public void create(String shareName, String fileName, long fileContentLength, In * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3828,8 +4141,8 @@ public Response deleteNoCustomHeadersWithResponse(String shareName, String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3877,8 +4190,8 @@ public Mono> setHttpHeadersWithRe * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3962,8 +4275,8 @@ public Mono> setHttpHeadersWithRe * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4010,8 +4323,8 @@ public Mono setHttpHeadersAsync(String shareName, String fileName, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4059,8 +4372,8 @@ public Mono setHttpHeadersAsync(String shareName, String fileName, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4109,8 +4422,8 @@ public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(Strin * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4195,8 +4508,8 @@ public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(Strin * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4283,8 +4596,8 @@ public ResponseBase setHttpHeadersWithResponse * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4328,8 +4641,8 @@ public void setHttpHeaders(String shareName, String fileName, Integer timeout, L * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file - * and ‘Directory’ for directory. ‘None’ can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file + * and 'Directory' for directory. 'None' can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java new file mode 100644 index 0000000000000..1a53639818610 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java @@ -0,0 +1,668 @@ +// 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.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.file.share.models.NfsFileType; +import java.time.OffsetDateTime; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The DirectoriesGetPropertiesByFileIdHeaders model. + */ +@Fluent +public final class DirectoriesGetPropertiesByFileIdHeaders { + /* + * The x-ms-meta- property. + */ + @Generated + private Map xMsMeta; + + /* + * The ETag property. + */ + @Generated + private String eTag; + + /* + * The Last-Modified property. + */ + @Generated + private DateTimeRfc1123 lastModified; + + /* + * The x-ms-request-id property. + */ + @Generated + private String xMsRequestId; + + /* + * The x-ms-version property. + */ + @Generated + private String xMsVersion; + + /* + * The Date property. + */ + @Generated + private DateTimeRfc1123 date; + + /* + * The x-ms-server-encrypted property. + */ + @Generated + private Boolean xMsServerEncrypted; + + /* + * The x-ms-file-attributes property. + */ + @Generated + private String xMsFileAttributes; + + /* + * The x-ms-file-creation-time property. + */ + @Generated + private OffsetDateTime xMsFileCreationTime; + + /* + * The x-ms-file-last-write-time property. + */ + @Generated + private OffsetDateTime xMsFileLastWriteTime; + + /* + * The x-ms-file-change-time property. + */ + @Generated + private OffsetDateTime xMsFileChangeTime; + + /* + * The x-ms-file-permission-key property. + */ + @Generated + private String xMsFilePermissionKey; + + /* + * The x-ms-file-id property. + */ + @Generated + private String xMsFileId; + + /* + * The x-ms-file-name property. + */ + @Generated + private String xMsFileName; + + /* + * The x-ms-file-parent-id property. + */ + @Generated + private String xMsFileParentId; + + /* + * The x-ms-mode property. + */ + @Generated + private String xMsMode; + + /* + * The x-ms-owner property. + */ + @Generated + private String xMsOwner; + + /* + * The x-ms-group property. + */ + @Generated + private String xMsGroup; + + /* + * The x-ms-file-file-type property. + */ + @Generated + private NfsFileType xMsFileFileType; + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); + + private static final HttpHeaderName X_MS_FILE_ATTRIBUTES = HttpHeaderName.fromString("x-ms-file-attributes"); + + private static final HttpHeaderName X_MS_FILE_CREATION_TIME = HttpHeaderName.fromString("x-ms-file-creation-time"); + + private static final HttpHeaderName X_MS_FILE_LAST_WRITE_TIME + = HttpHeaderName.fromString("x-ms-file-last-write-time"); + + private static final HttpHeaderName X_MS_FILE_CHANGE_TIME = HttpHeaderName.fromString("x-ms-file-change-time"); + + private static final HttpHeaderName X_MS_FILE_PERMISSION_KEY + = HttpHeaderName.fromString("x-ms-file-permission-key"); + + private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); + + private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); + + private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); + + private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); + + private static final HttpHeaderName X_MS_OWNER = HttpHeaderName.fromString("x-ms-owner"); + + private static final HttpHeaderName X_MS_GROUP = HttpHeaderName.fromString("x-ms-group"); + + private static final HttpHeaderName X_MS_FILE_FILE_TYPE = HttpHeaderName.fromString("x-ms-file-file-type"); + + // HttpHeaders containing the raw property values. + /** + * Creates an instance of DirectoriesGetPropertiesByFileIdHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public DirectoriesGetPropertiesByFileIdHeaders(HttpHeaders rawHeaders) { + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); + if (lastModified != null) { + this.lastModified = new DateTimeRfc1123(lastModified); + } else { + this.lastModified = null; + } + this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); + } else { + this.date = null; + } + String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); + if (xMsServerEncrypted != null) { + this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); + } else { + this.xMsServerEncrypted = null; + } + this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); + String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); + if (xMsFileCreationTime != null) { + this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); + } else { + this.xMsFileCreationTime = null; + } + String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); + if (xMsFileLastWriteTime != null) { + this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); + } else { + this.xMsFileLastWriteTime = null; + } + String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); + if (xMsFileChangeTime != null) { + this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); + } else { + this.xMsFileChangeTime = null; + } + this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); + this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); + this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); + this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); + this.xMsMode = rawHeaders.getValue(X_MS_MODE); + this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); + this.xMsGroup = rawHeaders.getValue(X_MS_GROUP); + String xMsFileFileType = rawHeaders.getValue(X_MS_FILE_FILE_TYPE); + if (xMsFileFileType != null) { + this.xMsFileFileType = NfsFileType.fromString(xMsFileFileType); + } else { + this.xMsFileFileType = null; + } + Map xMsMetaHeaderCollection = new LinkedHashMap<>(); + + rawHeaders.stream().forEach(header -> { + String headerName = header.getName(); + if (headerName.startsWith("x-ms-meta-")) { + xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); + } + }); + this.xMsMeta = xMsMetaHeaderCollection; + } + + /** + * Get the xMsMeta property: The x-ms-meta- property. + * + * @return the xMsMeta value. + */ + @Generated + public Map getXMsMeta() { + return this.xMsMeta; + } + + /** + * Set the xMsMeta property: The x-ms-meta- property. + * + * @param xMsMeta the xMsMeta value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsMeta(Map xMsMeta) { + this.xMsMeta = xMsMeta; + return this; + } + + /** + * Get the eTag property: The ETag property. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Set the eTag property: The ETag property. + * + * @param eTag the eTag value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setETag(String eTag) { + this.eTag = eTag; + return this; + } + + /** + * Get the lastModified property: The Last-Modified property. + * + * @return the lastModified value. + */ + @Generated + public OffsetDateTime getLastModified() { + if (this.lastModified == null) { + return null; + } + return this.lastModified.getDateTime(); + } + + /** + * Set the lastModified property: The Last-Modified property. + * + * @param lastModified the lastModified value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setLastModified(OffsetDateTime lastModified) { + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new DateTimeRfc1123(lastModified); + } + return this; + } + + /** + * Get the xMsRequestId property: The x-ms-request-id property. + * + * @return the xMsRequestId value. + */ + @Generated + public String getXMsRequestId() { + return this.xMsRequestId; + } + + /** + * Set the xMsRequestId property: The x-ms-request-id property. + * + * @param xMsRequestId the xMsRequestId value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsRequestId(String xMsRequestId) { + this.xMsRequestId = xMsRequestId; + return this; + } + + /** + * Get the xMsVersion property: The x-ms-version property. + * + * @return the xMsVersion value. + */ + @Generated + public String getXMsVersion() { + return this.xMsVersion; + } + + /** + * Set the xMsVersion property: The x-ms-version property. + * + * @param xMsVersion the xMsVersion value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsVersion(String xMsVersion) { + this.xMsVersion = xMsVersion; + return this; + } + + /** + * Get the date property: The Date property. + * + * @return the date value. + */ + @Generated + public OffsetDateTime getDate() { + if (this.date == null) { + return null; + } + return this.date.getDateTime(); + } + + /** + * Set the date property: The Date property. + * + * @param date the date value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; + } else { + this.date = new DateTimeRfc1123(date); + } + return this; + } + + /** + * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @return the xMsServerEncrypted value. + */ + @Generated + public Boolean isXMsServerEncrypted() { + return this.xMsServerEncrypted; + } + + /** + * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @param xMsServerEncrypted the xMsServerEncrypted value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { + this.xMsServerEncrypted = xMsServerEncrypted; + return this; + } + + /** + * Get the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @return the xMsFileAttributes value. + */ + @Generated + public String getXMsFileAttributes() { + return this.xMsFileAttributes; + } + + /** + * Set the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @param xMsFileAttributes the xMsFileAttributes value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileAttributes(String xMsFileAttributes) { + this.xMsFileAttributes = xMsFileAttributes; + return this; + } + + /** + * Get the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @return the xMsFileCreationTime value. + */ + @Generated + public OffsetDateTime getXMsFileCreationTime() { + return this.xMsFileCreationTime; + } + + /** + * Set the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @param xMsFileCreationTime the xMsFileCreationTime value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { + this.xMsFileCreationTime = xMsFileCreationTime; + return this; + } + + /** + * Get the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @return the xMsFileLastWriteTime value. + */ + @Generated + public OffsetDateTime getXMsFileLastWriteTime() { + return this.xMsFileLastWriteTime; + } + + /** + * Set the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @param xMsFileLastWriteTime the xMsFileLastWriteTime value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { + this.xMsFileLastWriteTime = xMsFileLastWriteTime; + return this; + } + + /** + * Get the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @return the xMsFileChangeTime value. + */ + @Generated + public OffsetDateTime getXMsFileChangeTime() { + return this.xMsFileChangeTime; + } + + /** + * Set the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @param xMsFileChangeTime the xMsFileChangeTime value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { + this.xMsFileChangeTime = xMsFileChangeTime; + return this; + } + + /** + * Get the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @return the xMsFilePermissionKey value. + */ + @Generated + public String getXMsFilePermissionKey() { + return this.xMsFilePermissionKey; + } + + /** + * Set the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @param xMsFilePermissionKey the xMsFilePermissionKey value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFilePermissionKey(String xMsFilePermissionKey) { + this.xMsFilePermissionKey = xMsFilePermissionKey; + return this; + } + + /** + * Get the xMsFileId property: The x-ms-file-id property. + * + * @return the xMsFileId value. + */ + @Generated + public String getXMsFileId() { + return this.xMsFileId; + } + + /** + * Set the xMsFileId property: The x-ms-file-id property. + * + * @param xMsFileId the xMsFileId value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileId(String xMsFileId) { + this.xMsFileId = xMsFileId; + return this; + } + + /** + * Get the xMsFileName property: The x-ms-file-name property. + * + * @return the xMsFileName value. + */ + @Generated + public String getXMsFileName() { + return this.xMsFileName; + } + + /** + * Set the xMsFileName property: The x-ms-file-name property. + * + * @param xMsFileName the xMsFileName value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileName(String xMsFileName) { + this.xMsFileName = xMsFileName; + return this; + } + + /** + * Get the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @return the xMsFileParentId value. + */ + @Generated + public String getXMsFileParentId() { + return this.xMsFileParentId; + } + + /** + * Set the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @param xMsFileParentId the xMsFileParentId value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileParentId(String xMsFileParentId) { + this.xMsFileParentId = xMsFileParentId; + return this; + } + + /** + * Get the xMsMode property: The x-ms-mode property. + * + * @return the xMsMode value. + */ + @Generated + public String getXMsMode() { + return this.xMsMode; + } + + /** + * Set the xMsMode property: The x-ms-mode property. + * + * @param xMsMode the xMsMode value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsMode(String xMsMode) { + this.xMsMode = xMsMode; + return this; + } + + /** + * Get the xMsOwner property: The x-ms-owner property. + * + * @return the xMsOwner value. + */ + @Generated + public String getXMsOwner() { + return this.xMsOwner; + } + + /** + * Set the xMsOwner property: The x-ms-owner property. + * + * @param xMsOwner the xMsOwner value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsOwner(String xMsOwner) { + this.xMsOwner = xMsOwner; + return this; + } + + /** + * Get the xMsGroup property: The x-ms-group property. + * + * @return the xMsGroup value. + */ + @Generated + public String getXMsGroup() { + return this.xMsGroup; + } + + /** + * Set the xMsGroup property: The x-ms-group property. + * + * @param xMsGroup the xMsGroup value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsGroup(String xMsGroup) { + this.xMsGroup = xMsGroup; + return this; + } + + /** + * Get the xMsFileFileType property: The x-ms-file-file-type property. + * + * @return the xMsFileFileType value. + */ + @Generated + public NfsFileType getXMsFileFileType() { + return this.xMsFileFileType; + } + + /** + * Set the xMsFileFileType property: The x-ms-file-file-type property. + * + * @param xMsFileFileType the xMsFileFileType value to set. + * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public DirectoriesGetPropertiesByFileIdHeaders setXMsFileFileType(NfsFileType xMsFileFileType) { + this.xMsFileFileType = xMsFileFileType; + return this; + } +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java new file mode 100644 index 0000000000000..7340b552b03f6 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java @@ -0,0 +1,1267 @@ +// 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.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.DateTimeRfc1123; +import com.azure.storage.file.share.models.CopyStatusType; +import com.azure.storage.file.share.models.LeaseDurationType; +import com.azure.storage.file.share.models.LeaseStateType; +import com.azure.storage.file.share.models.LeaseStatusType; +import com.azure.storage.file.share.models.NfsFileType; +import java.time.OffsetDateTime; +import java.util.Base64; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The FilesGetPropertiesByFileIdHeaders model. + */ +@Fluent +public final class FilesGetPropertiesByFileIdHeaders { + /* + * The Last-Modified property. + */ + @Generated + private DateTimeRfc1123 lastModified; + + /* + * The x-ms-meta- property. + */ + @Generated + private Map xMsMeta; + + /* + * The x-ms-type property. + */ + @Generated + private String xMsType = "File"; + + /* + * The Content-Length property. + */ + @Generated + private Long contentLength; + + /* + * The Content-Type property. + */ + @Generated + private String contentType; + + /* + * The ETag property. + */ + @Generated + private String eTag; + + /* + * The Content-MD5 property. + */ + @Generated + private byte[] contentMD5; + + /* + * The Content-Encoding property. + */ + @Generated + private String contentEncoding; + + /* + * The Cache-Control property. + */ + @Generated + private String cacheControl; + + /* + * The Content-Disposition property. + */ + @Generated + private String contentDisposition; + + /* + * The Content-Language property. + */ + @Generated + private String contentLanguage; + + /* + * The x-ms-request-id property. + */ + @Generated + private String xMsRequestId; + + /* + * The x-ms-version property. + */ + @Generated + private String xMsVersion; + + /* + * The Date property. + */ + @Generated + private DateTimeRfc1123 date; + + /* + * The x-ms-copy-completion-time property. + */ + @Generated + private DateTimeRfc1123 xMsCopyCompletionTime; + + /* + * The x-ms-copy-status-description property. + */ + @Generated + private String xMsCopyStatusDescription; + + /* + * The x-ms-copy-id property. + */ + @Generated + private String xMsCopyId; + + /* + * The x-ms-copy-progress property. + */ + @Generated + private String xMsCopyProgress; + + /* + * The x-ms-copy-source property. + */ + @Generated + private String xMsCopySource; + + /* + * The x-ms-copy-status property. + */ + @Generated + private CopyStatusType xMsCopyStatus; + + /* + * The x-ms-server-encrypted property. + */ + @Generated + private Boolean xMsServerEncrypted; + + /* + * The x-ms-file-attributes property. + */ + @Generated + private String xMsFileAttributes; + + /* + * The x-ms-file-creation-time property. + */ + @Generated + private OffsetDateTime xMsFileCreationTime; + + /* + * The x-ms-file-last-write-time property. + */ + @Generated + private OffsetDateTime xMsFileLastWriteTime; + + /* + * The x-ms-file-change-time property. + */ + @Generated + private OffsetDateTime xMsFileChangeTime; + + /* + * The x-ms-file-permission-key property. + */ + @Generated + private String xMsFilePermissionKey; + + /* + * The x-ms-file-id property. + */ + @Generated + private String xMsFileId; + + /* + * The x-ms-file-name property. + */ + @Generated + private String xMsFileName; + + /* + * The x-ms-file-parent-id property. + */ + @Generated + private String xMsFileParentId; + + /* + * The x-ms-lease-duration property. + */ + @Generated + private LeaseDurationType xMsLeaseDuration; + + /* + * The x-ms-lease-state property. + */ + @Generated + private LeaseStateType xMsLeaseState; + + /* + * The x-ms-lease-status property. + */ + @Generated + private LeaseStatusType xMsLeaseStatus; + + /* + * The x-ms-mode property. + */ + @Generated + private String xMsMode; + + /* + * The x-ms-owner property. + */ + @Generated + private String xMsOwner; + + /* + * The x-ms-group property. + */ + @Generated + private String xMsGroup; + + /* + * The x-ms-link-count property. + */ + @Generated + private Long xMsLinkCount; + + /* + * The x-ms-file-file-type property. + */ + @Generated + private NfsFileType xMsFileFileType; + + private static final HttpHeaderName X_MS_TYPE = HttpHeaderName.fromString("x-ms-type"); + + private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); + + private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME + = HttpHeaderName.fromString("x-ms-copy-completion-time"); + + private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION + = HttpHeaderName.fromString("x-ms-copy-status-description"); + + private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); + + private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); + + private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); + + private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); + + private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); + + private static final HttpHeaderName X_MS_FILE_ATTRIBUTES = HttpHeaderName.fromString("x-ms-file-attributes"); + + private static final HttpHeaderName X_MS_FILE_CREATION_TIME = HttpHeaderName.fromString("x-ms-file-creation-time"); + + private static final HttpHeaderName X_MS_FILE_LAST_WRITE_TIME + = HttpHeaderName.fromString("x-ms-file-last-write-time"); + + private static final HttpHeaderName X_MS_FILE_CHANGE_TIME = HttpHeaderName.fromString("x-ms-file-change-time"); + + private static final HttpHeaderName X_MS_FILE_PERMISSION_KEY + = HttpHeaderName.fromString("x-ms-file-permission-key"); + + private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); + + private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); + + private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); + + private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); + + private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); + + private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); + + private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); + + private static final HttpHeaderName X_MS_OWNER = HttpHeaderName.fromString("x-ms-owner"); + + private static final HttpHeaderName X_MS_GROUP = HttpHeaderName.fromString("x-ms-group"); + + private static final HttpHeaderName X_MS_LINK_COUNT = HttpHeaderName.fromString("x-ms-link-count"); + + private static final HttpHeaderName X_MS_FILE_FILE_TYPE = HttpHeaderName.fromString("x-ms-file-file-type"); + + // HttpHeaders containing the raw property values. + /** + * Creates an instance of FilesGetPropertiesByFileIdHeaders class. + * + * @param rawHeaders The raw HttpHeaders that will be used to create the property values. + */ + public FilesGetPropertiesByFileIdHeaders(HttpHeaders rawHeaders) { + String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); + if (lastModified != null) { + this.lastModified = new DateTimeRfc1123(lastModified); + } else { + this.lastModified = null; + } + this.xMsType = rawHeaders.getValue(X_MS_TYPE); + String contentLength = rawHeaders.getValue(HttpHeaderName.CONTENT_LENGTH); + if (contentLength != null) { + this.contentLength = Long.parseLong(contentLength); + } else { + this.contentLength = null; + } + this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); + this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); + String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); + if (contentMD5 != null) { + this.contentMD5 = Base64.getDecoder().decode(contentMD5); + } else { + this.contentMD5 = null; + } + this.contentEncoding = rawHeaders.getValue(HttpHeaderName.CONTENT_ENCODING); + this.cacheControl = rawHeaders.getValue(HttpHeaderName.CACHE_CONTROL); + this.contentDisposition = rawHeaders.getValue(HttpHeaderName.CONTENT_DISPOSITION); + this.contentLanguage = rawHeaders.getValue(HttpHeaderName.CONTENT_LANGUAGE); + this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); + this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); + String date = rawHeaders.getValue(HttpHeaderName.DATE); + if (date != null) { + this.date = new DateTimeRfc1123(date); + } else { + this.date = null; + } + String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); + if (xMsCopyCompletionTime != null) { + this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); + } else { + this.xMsCopyCompletionTime = null; + } + this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); + this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); + this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); + this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); + String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); + if (xMsCopyStatus != null) { + this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); + } else { + this.xMsCopyStatus = null; + } + String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); + if (xMsServerEncrypted != null) { + this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); + } else { + this.xMsServerEncrypted = null; + } + this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); + String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); + if (xMsFileCreationTime != null) { + this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); + } else { + this.xMsFileCreationTime = null; + } + String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); + if (xMsFileLastWriteTime != null) { + this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); + } else { + this.xMsFileLastWriteTime = null; + } + String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); + if (xMsFileChangeTime != null) { + this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); + } else { + this.xMsFileChangeTime = null; + } + this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); + this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); + this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); + this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); + String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); + if (xMsLeaseDuration != null) { + this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); + } else { + this.xMsLeaseDuration = null; + } + String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); + if (xMsLeaseState != null) { + this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); + } else { + this.xMsLeaseState = null; + } + String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); + if (xMsLeaseStatus != null) { + this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); + } else { + this.xMsLeaseStatus = null; + } + this.xMsMode = rawHeaders.getValue(X_MS_MODE); + this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); + this.xMsGroup = rawHeaders.getValue(X_MS_GROUP); + String xMsLinkCount = rawHeaders.getValue(X_MS_LINK_COUNT); + if (xMsLinkCount != null) { + this.xMsLinkCount = Long.parseLong(xMsLinkCount); + } else { + this.xMsLinkCount = null; + } + String xMsFileFileType = rawHeaders.getValue(X_MS_FILE_FILE_TYPE); + if (xMsFileFileType != null) { + this.xMsFileFileType = NfsFileType.fromString(xMsFileFileType); + } else { + this.xMsFileFileType = null; + } + Map xMsMetaHeaderCollection = new LinkedHashMap<>(); + + rawHeaders.stream().forEach(header -> { + String headerName = header.getName(); + if (headerName.startsWith("x-ms-meta-")) { + xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); + } + }); + this.xMsMeta = xMsMetaHeaderCollection; + } + + /** + * Get the lastModified property: The Last-Modified property. + * + * @return the lastModified value. + */ + @Generated + public OffsetDateTime getLastModified() { + if (this.lastModified == null) { + return null; + } + return this.lastModified.getDateTime(); + } + + /** + * Set the lastModified property: The Last-Modified property. + * + * @param lastModified the lastModified value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setLastModified(OffsetDateTime lastModified) { + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new DateTimeRfc1123(lastModified); + } + return this; + } + + /** + * Get the xMsMeta property: The x-ms-meta- property. + * + * @return the xMsMeta value. + */ + @Generated + public Map getXMsMeta() { + return this.xMsMeta; + } + + /** + * Set the xMsMeta property: The x-ms-meta- property. + * + * @param xMsMeta the xMsMeta value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsMeta(Map xMsMeta) { + this.xMsMeta = xMsMeta; + return this; + } + + /** + * Get the xMsType property: The x-ms-type property. + * + * @return the xMsType value. + */ + @Generated + public String getXMsType() { + return this.xMsType; + } + + /** + * Set the xMsType property: The x-ms-type property. + * + * @param xMsType the xMsType value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsType(String xMsType) { + this.xMsType = xMsType; + return this; + } + + /** + * Get the contentLength property: The Content-Length property. + * + * @return the contentLength value. + */ + @Generated + public Long getContentLength() { + return this.contentLength; + } + + /** + * Set the contentLength property: The Content-Length property. + * + * @param contentLength the contentLength value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentLength(Long contentLength) { + this.contentLength = contentLength; + return this; + } + + /** + * Get the contentType property: The Content-Type property. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The Content-Type property. + * + * @param contentType the contentType value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the eTag property: The ETag property. + * + * @return the eTag value. + */ + @Generated + public String getETag() { + return this.eTag; + } + + /** + * Set the eTag property: The ETag property. + * + * @param eTag the eTag value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setETag(String eTag) { + this.eTag = eTag; + return this; + } + + /** + * Get the contentMD5 property: The Content-MD5 property. + * + * @return the contentMD5 value. + */ + @Generated + public byte[] getContentMD5() { + return CoreUtils.clone(this.contentMD5); + } + + /** + * Set the contentMD5 property: The Content-MD5 property. + * + * @param contentMD5 the contentMD5 value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentMD5(byte[] contentMD5) { + this.contentMD5 = CoreUtils.clone(contentMD5); + return this; + } + + /** + * Get the contentEncoding property: The Content-Encoding property. + * + * @return the contentEncoding value. + */ + @Generated + public String getContentEncoding() { + return this.contentEncoding; + } + + /** + * Set the contentEncoding property: The Content-Encoding property. + * + * @param contentEncoding the contentEncoding value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentEncoding(String contentEncoding) { + this.contentEncoding = contentEncoding; + return this; + } + + /** + * Get the cacheControl property: The Cache-Control property. + * + * @return the cacheControl value. + */ + @Generated + public String getCacheControl() { + return this.cacheControl; + } + + /** + * Set the cacheControl property: The Cache-Control property. + * + * @param cacheControl the cacheControl value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setCacheControl(String cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + /** + * Get the contentDisposition property: The Content-Disposition property. + * + * @return the contentDisposition value. + */ + @Generated + public String getContentDisposition() { + return this.contentDisposition; + } + + /** + * Set the contentDisposition property: The Content-Disposition property. + * + * @param contentDisposition the contentDisposition value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentDisposition(String contentDisposition) { + this.contentDisposition = contentDisposition; + return this; + } + + /** + * Get the contentLanguage property: The Content-Language property. + * + * @return the contentLanguage value. + */ + @Generated + public String getContentLanguage() { + return this.contentLanguage; + } + + /** + * Set the contentLanguage property: The Content-Language property. + * + * @param contentLanguage the contentLanguage value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setContentLanguage(String contentLanguage) { + this.contentLanguage = contentLanguage; + return this; + } + + /** + * Get the xMsRequestId property: The x-ms-request-id property. + * + * @return the xMsRequestId value. + */ + @Generated + public String getXMsRequestId() { + return this.xMsRequestId; + } + + /** + * Set the xMsRequestId property: The x-ms-request-id property. + * + * @param xMsRequestId the xMsRequestId value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsRequestId(String xMsRequestId) { + this.xMsRequestId = xMsRequestId; + return this; + } + + /** + * Get the xMsVersion property: The x-ms-version property. + * + * @return the xMsVersion value. + */ + @Generated + public String getXMsVersion() { + return this.xMsVersion; + } + + /** + * Set the xMsVersion property: The x-ms-version property. + * + * @param xMsVersion the xMsVersion value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsVersion(String xMsVersion) { + this.xMsVersion = xMsVersion; + return this; + } + + /** + * Get the date property: The Date property. + * + * @return the date value. + */ + @Generated + public OffsetDateTime getDate() { + if (this.date == null) { + return null; + } + return this.date.getDateTime(); + } + + /** + * Set the date property: The Date property. + * + * @param date the date value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setDate(OffsetDateTime date) { + if (date == null) { + this.date = null; + } else { + this.date = new DateTimeRfc1123(date); + } + return this; + } + + /** + * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. + * + * @return the xMsCopyCompletionTime value. + */ + @Generated + public OffsetDateTime getXMsCopyCompletionTime() { + if (this.xMsCopyCompletionTime == null) { + return null; + } + return this.xMsCopyCompletionTime.getDateTime(); + } + + /** + * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. + * + * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { + if (xMsCopyCompletionTime == null) { + this.xMsCopyCompletionTime = null; + } else { + this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); + } + return this; + } + + /** + * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. + * + * @return the xMsCopyStatusDescription value. + */ + @Generated + public String getXMsCopyStatusDescription() { + return this.xMsCopyStatusDescription; + } + + /** + * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. + * + * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { + this.xMsCopyStatusDescription = xMsCopyStatusDescription; + return this; + } + + /** + * Get the xMsCopyId property: The x-ms-copy-id property. + * + * @return the xMsCopyId value. + */ + @Generated + public String getXMsCopyId() { + return this.xMsCopyId; + } + + /** + * Set the xMsCopyId property: The x-ms-copy-id property. + * + * @param xMsCopyId the xMsCopyId value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopyId(String xMsCopyId) { + this.xMsCopyId = xMsCopyId; + return this; + } + + /** + * Get the xMsCopyProgress property: The x-ms-copy-progress property. + * + * @return the xMsCopyProgress value. + */ + @Generated + public String getXMsCopyProgress() { + return this.xMsCopyProgress; + } + + /** + * Set the xMsCopyProgress property: The x-ms-copy-progress property. + * + * @param xMsCopyProgress the xMsCopyProgress value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopyProgress(String xMsCopyProgress) { + this.xMsCopyProgress = xMsCopyProgress; + return this; + } + + /** + * Get the xMsCopySource property: The x-ms-copy-source property. + * + * @return the xMsCopySource value. + */ + @Generated + public String getXMsCopySource() { + return this.xMsCopySource; + } + + /** + * Set the xMsCopySource property: The x-ms-copy-source property. + * + * @param xMsCopySource the xMsCopySource value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopySource(String xMsCopySource) { + this.xMsCopySource = xMsCopySource; + return this; + } + + /** + * Get the xMsCopyStatus property: The x-ms-copy-status property. + * + * @return the xMsCopyStatus value. + */ + @Generated + public CopyStatusType getXMsCopyStatus() { + return this.xMsCopyStatus; + } + + /** + * Set the xMsCopyStatus property: The x-ms-copy-status property. + * + * @param xMsCopyStatus the xMsCopyStatus value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { + this.xMsCopyStatus = xMsCopyStatus; + return this; + } + + /** + * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @return the xMsServerEncrypted value. + */ + @Generated + public Boolean isXMsServerEncrypted() { + return this.xMsServerEncrypted; + } + + /** + * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. + * + * @param xMsServerEncrypted the xMsServerEncrypted value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { + this.xMsServerEncrypted = xMsServerEncrypted; + return this; + } + + /** + * Get the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @return the xMsFileAttributes value. + */ + @Generated + public String getXMsFileAttributes() { + return this.xMsFileAttributes; + } + + /** + * Set the xMsFileAttributes property: The x-ms-file-attributes property. + * + * @param xMsFileAttributes the xMsFileAttributes value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileAttributes(String xMsFileAttributes) { + this.xMsFileAttributes = xMsFileAttributes; + return this; + } + + /** + * Get the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @return the xMsFileCreationTime value. + */ + @Generated + public OffsetDateTime getXMsFileCreationTime() { + return this.xMsFileCreationTime; + } + + /** + * Set the xMsFileCreationTime property: The x-ms-file-creation-time property. + * + * @param xMsFileCreationTime the xMsFileCreationTime value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { + this.xMsFileCreationTime = xMsFileCreationTime; + return this; + } + + /** + * Get the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @return the xMsFileLastWriteTime value. + */ + @Generated + public OffsetDateTime getXMsFileLastWriteTime() { + return this.xMsFileLastWriteTime; + } + + /** + * Set the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. + * + * @param xMsFileLastWriteTime the xMsFileLastWriteTime value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { + this.xMsFileLastWriteTime = xMsFileLastWriteTime; + return this; + } + + /** + * Get the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @return the xMsFileChangeTime value. + */ + @Generated + public OffsetDateTime getXMsFileChangeTime() { + return this.xMsFileChangeTime; + } + + /** + * Set the xMsFileChangeTime property: The x-ms-file-change-time property. + * + * @param xMsFileChangeTime the xMsFileChangeTime value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { + this.xMsFileChangeTime = xMsFileChangeTime; + return this; + } + + /** + * Get the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @return the xMsFilePermissionKey value. + */ + @Generated + public String getXMsFilePermissionKey() { + return this.xMsFilePermissionKey; + } + + /** + * Set the xMsFilePermissionKey property: The x-ms-file-permission-key property. + * + * @param xMsFilePermissionKey the xMsFilePermissionKey value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFilePermissionKey(String xMsFilePermissionKey) { + this.xMsFilePermissionKey = xMsFilePermissionKey; + return this; + } + + /** + * Get the xMsFileId property: The x-ms-file-id property. + * + * @return the xMsFileId value. + */ + @Generated + public String getXMsFileId() { + return this.xMsFileId; + } + + /** + * Set the xMsFileId property: The x-ms-file-id property. + * + * @param xMsFileId the xMsFileId value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileId(String xMsFileId) { + this.xMsFileId = xMsFileId; + return this; + } + + /** + * Get the xMsFileName property: The x-ms-file-name property. + * + * @return the xMsFileName value. + */ + @Generated + public String getXMsFileName() { + return this.xMsFileName; + } + + /** + * Set the xMsFileName property: The x-ms-file-name property. + * + * @param xMsFileName the xMsFileName value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileName(String xMsFileName) { + this.xMsFileName = xMsFileName; + return this; + } + + /** + * Get the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @return the xMsFileParentId value. + */ + @Generated + public String getXMsFileParentId() { + return this.xMsFileParentId; + } + + /** + * Set the xMsFileParentId property: The x-ms-file-parent-id property. + * + * @param xMsFileParentId the xMsFileParentId value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileParentId(String xMsFileParentId) { + this.xMsFileParentId = xMsFileParentId; + return this; + } + + /** + * Get the xMsLeaseDuration property: The x-ms-lease-duration property. + * + * @return the xMsLeaseDuration value. + */ + @Generated + public LeaseDurationType getXMsLeaseDuration() { + return this.xMsLeaseDuration; + } + + /** + * Set the xMsLeaseDuration property: The x-ms-lease-duration property. + * + * @param xMsLeaseDuration the xMsLeaseDuration value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { + this.xMsLeaseDuration = xMsLeaseDuration; + return this; + } + + /** + * Get the xMsLeaseState property: The x-ms-lease-state property. + * + * @return the xMsLeaseState value. + */ + @Generated + public LeaseStateType getXMsLeaseState() { + return this.xMsLeaseState; + } + + /** + * Set the xMsLeaseState property: The x-ms-lease-state property. + * + * @param xMsLeaseState the xMsLeaseState value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { + this.xMsLeaseState = xMsLeaseState; + return this; + } + + /** + * Get the xMsLeaseStatus property: The x-ms-lease-status property. + * + * @return the xMsLeaseStatus value. + */ + @Generated + public LeaseStatusType getXMsLeaseStatus() { + return this.xMsLeaseStatus; + } + + /** + * Set the xMsLeaseStatus property: The x-ms-lease-status property. + * + * @param xMsLeaseStatus the xMsLeaseStatus value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { + this.xMsLeaseStatus = xMsLeaseStatus; + return this; + } + + /** + * Get the xMsMode property: The x-ms-mode property. + * + * @return the xMsMode value. + */ + @Generated + public String getXMsMode() { + return this.xMsMode; + } + + /** + * Set the xMsMode property: The x-ms-mode property. + * + * @param xMsMode the xMsMode value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsMode(String xMsMode) { + this.xMsMode = xMsMode; + return this; + } + + /** + * Get the xMsOwner property: The x-ms-owner property. + * + * @return the xMsOwner value. + */ + @Generated + public String getXMsOwner() { + return this.xMsOwner; + } + + /** + * Set the xMsOwner property: The x-ms-owner property. + * + * @param xMsOwner the xMsOwner value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsOwner(String xMsOwner) { + this.xMsOwner = xMsOwner; + return this; + } + + /** + * Get the xMsGroup property: The x-ms-group property. + * + * @return the xMsGroup value. + */ + @Generated + public String getXMsGroup() { + return this.xMsGroup; + } + + /** + * Set the xMsGroup property: The x-ms-group property. + * + * @param xMsGroup the xMsGroup value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsGroup(String xMsGroup) { + this.xMsGroup = xMsGroup; + return this; + } + + /** + * Get the xMsLinkCount property: The x-ms-link-count property. + * + * @return the xMsLinkCount value. + */ + @Generated + public Long getXMsLinkCount() { + return this.xMsLinkCount; + } + + /** + * Set the xMsLinkCount property: The x-ms-link-count property. + * + * @param xMsLinkCount the xMsLinkCount value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsLinkCount(Long xMsLinkCount) { + this.xMsLinkCount = xMsLinkCount; + return this; + } + + /** + * Get the xMsFileFileType property: The x-ms-file-file-type property. + * + * @return the xMsFileFileType value. + */ + @Generated + public NfsFileType getXMsFileFileType() { + return this.xMsFileFileType; + } + + /** + * Set the xMsFileFileType property: The x-ms-file-file-type property. + * + * @param xMsFileFileType the xMsFileFileType value to set. + * @return the FilesGetPropertiesByFileIdHeaders object itself. + */ + @Generated + public FilesGetPropertiesByFileIdHeaders setXMsFileFileType(NfsFileType xMsFileFileType) { + this.xMsFileFileType = xMsFileFileType; + return this; + } +} diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 8d50f922c9573..92e4a3b9b4fc8 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/eca1da9f213c2bc8e38aee5dcf4e10e4b009992d/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5bdba2451c9c437df1779566e424b11d4ae429f8/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share @@ -102,6 +102,29 @@ directive: op.get.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; ``` +### File-ID property response timestamps +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"] + transform: > + for (const [path, method] of [["/{shareName}?restype=directory", "get"], ["/{shareName}", "head"]]) { + const headers = $[path][method].responses["200"].headers; + for (const name of ["x-ms-file-creation-time", "x-ms-file-last-write-time", "x-ms-file-change-time"]) { + headers[name].format = "date-time"; + } + } +``` + +### Keep file attribute documentation ASCII +``` yaml +directive: +- from: swagger-document + where: $.parameters.FileAttributes + transform: > + $.description = $.description.replace(/[\u2018\u2019]/g, "'"); +``` + ### /{shareName}/{directory}?restype=directory&comp=rename ``` yaml directive: From f3390223c22b3b1c7ef1109ff15e8629c58b2546 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 29 Sep 2026 23:07:57 -0400 Subject: [PATCH 04/39] Keep Files-by-ID timestamp handling consistent with existing SDK overrides Extend the Files-by-ID response timestamp directive to Get Hard Links and regenerate its headers. ISO-8601 SMB creation, last-write, and change timestamps cannot be parsed by the RFC 1123 deserializer selected by the shared Swagger. Research: the pre-existing Java swagger/README.md already overrides these response headers to date-time for directory create/get/set/rename and file create/get/download/set/rename/link operations. Generated FilesGetPropertiesHeaders and DirectoriesCreateHeaders use OffsetDateTime.parse, as does the hand-written FileSmbProperties header mapping. Python's azure-storage-file-share/swagger/README.md instead overrides all three response headers to strings to preserve timestamp precision. Keep the shared Microsoft.FileStorage/stable/2027-03-07/file.json unchanged: SDKs already apply language-specific handling, and changing existing shared definitions would broaden this feature's compatibility impact. Scope the new Java directives to file/directory properties by ID and Get Hard Links. Preserve previous operations and the RFC 1123 handling of HTTP Date, Last-Modified, and copy-completion timestamps. Generated Java was produced by AutoRest, not manually edited. The local Files-by-ID mock regressions cover fractional-second timestamps and sync/async file and directory property calls. The hard-link cases exposed the same parser mismatch and now pass with the regenerated model. --- .../models/FilesGetHardLinksHeaders.java | 45 +++++-------------- .../swagger/README.md | 4 +- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java index 0e73849e3cde7..dd9919d5906a7 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java @@ -143,19 +143,19 @@ public final class FilesGetHardLinksHeaders { * The x-ms-file-creation-time property. */ @Generated - private DateTimeRfc1123 xMsFileCreationTime; + private OffsetDateTime xMsFileCreationTime; /* * The x-ms-file-last-write-time property. */ @Generated - private DateTimeRfc1123 xMsFileLastWriteTime; + private OffsetDateTime xMsFileLastWriteTime; /* * The x-ms-file-change-time property. */ @Generated - private DateTimeRfc1123 xMsFileChangeTime; + private OffsetDateTime xMsFileChangeTime; /* * The x-ms-file-permission-key property. @@ -379,19 +379,19 @@ public FilesGetHardLinksHeaders(HttpHeaders rawHeaders) { this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); } else { this.xMsFileCreationTime = null; } String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); } else { this.xMsFileLastWriteTime = null; } String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); } else { this.xMsFileChangeTime = null; } @@ -891,10 +891,7 @@ public FilesGetHardLinksHeaders setXMsFileAttributes(String xMsFileAttributes) { */ @Generated public OffsetDateTime getXMsFileCreationTime() { - if (this.xMsFileCreationTime == null) { - return null; - } - return this.xMsFileCreationTime.getDateTime(); + return this.xMsFileCreationTime; } /** @@ -905,11 +902,7 @@ public OffsetDateTime getXMsFileCreationTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - if (xMsFileCreationTime == null) { - this.xMsFileCreationTime = null; - } else { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); - } + this.xMsFileCreationTime = xMsFileCreationTime; return this; } @@ -920,10 +913,7 @@ public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCre */ @Generated public OffsetDateTime getXMsFileLastWriteTime() { - if (this.xMsFileLastWriteTime == null) { - return null; - } - return this.xMsFileLastWriteTime.getDateTime(); + return this.xMsFileLastWriteTime; } /** @@ -934,11 +924,7 @@ public OffsetDateTime getXMsFileLastWriteTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - if (xMsFileLastWriteTime == null) { - this.xMsFileLastWriteTime = null; - } else { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); - } + this.xMsFileLastWriteTime = xMsFileLastWriteTime; return this; } @@ -949,10 +935,7 @@ public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLa */ @Generated public OffsetDateTime getXMsFileChangeTime() { - if (this.xMsFileChangeTime == null) { - return null; - } - return this.xMsFileChangeTime.getDateTime(); + return this.xMsFileChangeTime; } /** @@ -963,11 +946,7 @@ public OffsetDateTime getXMsFileChangeTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - if (xMsFileChangeTime == null) { - this.xMsFileChangeTime = null; - } else { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); - } + this.xMsFileChangeTime = xMsFileChangeTime; return this; } diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 92e4a3b9b4fc8..27cc1963971e7 100644 --- a/sdk/storage/azure-storage-file-share/swagger/README.md +++ b/sdk/storage/azure-storage-file-share/swagger/README.md @@ -102,13 +102,13 @@ directive: op.get.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; ``` -### File-ID property response timestamps +### File-ID property and hard-link response timestamps ``` yaml directive: - from: swagger-document where: $["x-ms-paths"] transform: > - for (const [path, method] of [["/{shareName}?restype=directory", "get"], ["/{shareName}", "head"]]) { + for (const [path, method] of [["/{shareName}?restype=directory", "get"], ["/{shareName}", "head"], ["/{shareName}?comp=hardlinks", "get"]]) { const headers = $[path][method].responses["200"].headers; for (const name of ["x-ms-file-creation-time", "x-ms-file-last-write-time", "x-ms-file-change-time"]) { headers[name].format = "date-time"; From f432e991e85c865f572def25c4b933ef0e097494 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 29 Sep 2026 23:14:04 -0400 Subject: [PATCH 05/39] Use generated APIs for file and directory properties by ID Replace the hand-written FileIdOperations REST client with generated operations in both synchronous and asynchronous clients. Centralize file-ID validation and addressing-mode guards in ShareErrors. Reuse property response mapping across path- and ID-addressed requests while preserving existing path-based behavior. Add regression coverage for timestamp and metadata mapping, service errors, and addressing-mode restrictions. --- .../storage/file/share/ShareAsyncClient.java | 6 +- .../azure/storage/file/share/ShareClient.java | 6 +- .../file/share/ShareDirectoryAsyncClient.java | 32 ++-- .../file/share/ShareDirectoryClient.java | 35 ++-- .../file/share/ShareFileAsyncClient.java | 55 +++--- .../storage/file/share/ShareFileClient.java | 63 ++++--- .../file/share/ShareFileClientBuilder.java | 4 +- .../implementation/FileIdOperations.java | 174 ------------------ .../share/implementation/ShareErrors.java | 59 ++++++ .../implementation/util/ModelHelper.java | 23 ++- .../storage/file/share/DirectoryApiTests.java | 25 ++- .../file/share/DirectoryAsyncApiTests.java | 14 +- .../storage/file/share/FileApiTests.java | 109 ++++++++--- .../storage/file/share/FileAsyncApiTests.java | 71 ++++++- .../storage/file/share/FileIdTestHelper.java | 21 +++ 15 files changed, 364 insertions(+), 333 deletions(-) delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java create mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java 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 9bbd849070040..044b674b9da97 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 @@ -21,7 +21,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.SharePermission; import com.azure.storage.file.share.implementation.util.ModelHelper; import com.azure.storage.file.share.implementation.util.ShareSasImplUtil; @@ -196,7 +196,7 @@ public ShareFileAsyncClient getFileClient(String filePath) { * @throws IllegalArgumentException If {@code fileId} is null or blank. */ public ShareFileAsyncClient getFileClientByFileId(String fileId) { - FileIdOperations.validateFileId(fileId); + ShareErrors.validateFileId(fileId); return new ShareFileAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, serviceVersion, sasToken); } @@ -209,7 +209,7 @@ public ShareFileAsyncClient getFileClientByFileId(String fileId) { * @throws IllegalArgumentException If {@code fileId} is null or blank. */ public ShareDirectoryAsyncClient getDirectoryClientByFileId(String fileId) { - FileIdOperations.validateFileId(fileId); + ShareErrors.validateFileId(fileId); return new ShareDirectoryAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, serviceVersion, sasToken); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java index b171e399588a6..ca15ff0d526b1 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java @@ -22,7 +22,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.SharePermission; import com.azure.storage.file.share.implementation.models.ShareSignedIdentifierWrapper; import com.azure.storage.file.share.implementation.models.ShareStats; @@ -205,7 +205,7 @@ public ShareFileClient getFileClient(String filePath) { * @throws IllegalArgumentException If {@code fileId} is null or blank. */ public ShareFileClient getFileClientByFileId(String fileId) { - FileIdOperations.validateFileId(fileId); + ShareErrors.validateFileId(fileId); ShareFileAsyncClient asyncClient = new ShareFileAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, serviceVersion, sasToken); return new ShareFileClient(asyncClient, azureFileStorageClient, shareName, "", fileId, snapshot, accountName, @@ -220,7 +220,7 @@ public ShareFileClient getFileClientByFileId(String fileId) { * @throws IllegalArgumentException If {@code fileId} is null or blank. */ public ShareDirectoryClient getDirectoryClientByFileId(String fileId) { - FileIdOperations.validateFileId(fileId); + ShareErrors.validateFileId(fileId); return new ShareDirectoryClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, serviceVersion, sasToken); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index b1bdbc87511c0..71d42c8bb1b01 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -23,7 +23,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.ListFilesIncludeType; @@ -186,7 +186,7 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileAsyncClient that interacts with the specified share */ public ShareFileAsyncClient getFileClient(String fileName) { - FileIdOperations.ensurePathAddressed(fileId, "getFileClient"); + ShareErrors.assertNotFileIdAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -206,7 +206,7 @@ public ShareFileAsyncClient getFileClient(String fileName) { * @return a ShareDirectoryAsyncClient that interacts with the specified directory */ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) { - FileIdOperations.ensurePathAddressed(fileId, "getSubdirectoryClient"); + ShareErrors.assertNotFileIdAddressed(fileId, "getSubdirectoryClient"); StringBuilder directoryPathBuilder = new StringBuilder().append(this.directoryPath); if (!this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/")) { directoryPathBuilder.append("/"); @@ -257,7 +257,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { - FileIdOperations.ensurePathAddressed(fileId, "exists"); + ShareErrors.assertNotFileIdAddressed(fileId, "exists"); return this.getPropertiesWithResponse(context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -383,7 +383,7 @@ public Mono> createWithResponse(ShareDirectoryCreat Mono> createWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Map metadata, FilePropertySemantics filePropertySemantics, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "create"); + ShareErrors.assertNotFileIdAddressed(fileId, "create"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -551,7 +551,7 @@ public Mono> deleteWithResponse() { } Mono> deleteWithResponse(Context context) { - FileIdOperations.ensurePathAddressed(fileId, "delete"); + ShareErrors.assertNotFileIdAddressed(fileId, "delete"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponseAsync(shareName, directoryPath, null, context); @@ -691,8 +691,8 @@ public Mono> getPropertiesWithResponse() { Mono> getPropertiesWithResponse(Context context) { context = context == null ? Context.NONE : context; if (!fileId.isEmpty()) { - return azureFileStorageClient.getFileIdOperations() - .getDirectoryPropertiesAsync(shareName, fileId, snapshot, null, context) + return azureFileStorageClient.getDirectories() + .getPropertiesByFileIdWithResponseAsync(shareName, fileId, snapshot, null, null, context) .map(ModelHelper::mapShareDirectoryPropertiesResponse); } return azureFileStorageClient.getDirectories() @@ -804,7 +804,7 @@ public Mono> setPropertiesWithResponse(ShareDirecto Mono> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setProperties"); + ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -905,7 +905,7 @@ public Mono> setMetadataWithResponse(Map Mono> setMetadataWithResponse(Map metadata, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); + ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .setMetadataWithResponseAsync(shareName, directoryPath, null, metadata, context) @@ -1013,7 +1013,7 @@ public PagedFlux listFilesAndDirectories(ShareListFilesAndDirecto PagedFlux listFilesAndDirectoriesWithOptionalTimeout(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listFilesAndDirectories"); + ShareErrors.assertNotFileIdAddressed(fileId, "listFilesAndDirectories"); final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; @@ -1068,7 +1068,7 @@ public PagedFlux listHandles(Integer maxResultPerPage, boolean recur PagedFlux listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .listHandlesWithResponseAsync(shareName, directoryPath, marker, maxResultPerPage, null, snapshot, @@ -1141,7 +1141,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); return this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, handleId, null, null, snapshot, false, context) @@ -1185,7 +1185,7 @@ public Mono forceCloseAllHandles(boolean recursive) { } PagedFlux forceCloseAllHandlesWithTimeout(boolean recursive, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, "*", null, marker, snapshot, recursive, @@ -1267,7 +1267,7 @@ public Mono> renameWithResponse(ShareFileRen } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "rename"); + ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -2182,7 +2182,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 6c244e3dd5d43..3cd97d5cb268b 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -23,12 +23,11 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesForceCloseHandlesHeaders; -import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListHandlesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetMetadataHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetPropertiesHeaders; @@ -189,7 +188,7 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileClient that interacts with the specified share */ public ShareFileClient getFileClient(String fileName) { - FileIdOperations.ensurePathAddressed(fileId, "getFileClient"); + ShareErrors.assertNotFileIdAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -210,7 +209,7 @@ public ShareFileClient getFileClient(String fileName) { * @return a ShareDirectoryClient that interacts with the specified directory */ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { - FileIdOperations.ensurePathAddressed(fileId, "getSubdirectoryClient"); + ShareErrors.assertNotFileIdAddressed(fileId, "getSubdirectoryClient"); boolean needPathDelimiter = !this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/"); String subDirectoryPath = this.directoryPath + (needPathDelimiter ? "/" : "") + subdirectoryName; return new ShareDirectoryClient(azureFileStorageClient, shareName, subDirectoryPath, snapshot, accountName, @@ -253,7 +252,7 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "exists"); + ShareErrors.assertNotFileIdAddressed(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -368,7 +367,7 @@ public Response createWithResponse(FileSmbProperties smbProp @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareDirectoryCreateOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "create"); + ShareErrors.assertNotFileIdAddressed(fileId, "create"); Context finalContext = context == null ? Context.NONE : context; ShareDirectoryCreateOptions finalOptions = options == null ? new ShareDirectoryCreateOptions() : options; @@ -521,7 +520,7 @@ public void delete() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "delete"); + ShareErrors.assertNotFileIdAddressed(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponse(shareName, directoryPath, null, finalContext); @@ -651,11 +650,11 @@ public ShareDirectoryProperties getProperties() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { Context finalContext = context == null ? Context.NONE : context; - Callable> operation = fileId.isEmpty() + Callable> operation = fileId.isEmpty() ? () -> this.azureFileStorageClient.getDirectories() .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext) - : () -> this.azureFileStorageClient.getFileIdOperations() - .getDirectoryProperties(shareName, fileId, snapshot, null, finalContext); + : () -> this.azureFileStorageClient.getDirectories() + .getPropertiesByFileIdWithResponse(shareName, fileId, snapshot, null, null, finalContext); return ModelHelper .mapShareDirectoryPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); @@ -754,7 +753,7 @@ public Response setPropertiesWithResponse(FileSmbProperties @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareDirectorySetPropertiesOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setProperties"); + ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); Context finalContext = context == null ? Context.NONE : context; ShareDirectorySetPropertiesOptions finalOptions = options == null ? new ShareDirectorySetPropertiesOptions() : options; @@ -862,7 +861,7 @@ public ShareDirectorySetMetadataInfo setMetadata(Map metadata) { @ServiceMethod(returns = ReturnType.SINGLE) public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); + ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() @@ -973,7 +972,7 @@ public PagedIterable listFilesAndDirectories(String prefix, Integ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listFilesAndDirectories"); + ShareErrors.assertNotFileIdAddressed(fileId, "listFilesAndDirectories"); Context finalContext = context == null ? Context.NONE : context; final ShareListFilesAndDirectoriesOptions modifiedOptions @@ -1034,7 +1033,7 @@ public PagedIterable listHandles(Integer maxResultsPerPage, boolean PagedIterable listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { Callable> operation @@ -1111,7 +1110,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -1155,7 +1154,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(boolean recursive, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { @@ -1242,7 +1241,7 @@ public ShareDirectoryClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "rename"); + ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; @@ -2078,7 +2077,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index aab68b0d35899..58f807df952b2 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -36,7 +36,7 @@ import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.common.implementation.UploadUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; @@ -262,7 +262,7 @@ public Mono> getFileLinksWithResponse() { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getFileLinksWithResponse(ShareRequestConditions requestConditions) { try { - FileIdOperations.ensureFileIdAddressed(fileId, "getFileLinks"); + ShareErrors.assertFileIdAddressed(fileId, "getFileLinks"); return withContext(context -> getFileLinksWithResponse(requestConditions, context)); } catch (RuntimeException exception) { return monoError(LOGGER, exception); @@ -339,7 +339,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { - FileIdOperations.ensurePathAddressed(fileId, "exists"); + ShareErrors.assertNotFileIdAddressed(fileId, "exists"); return this.getPropertiesWithResponse(null, context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -543,7 +543,7 @@ Mono> createWithResponse(long maxSize, ShareFileHttpHead FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties filePosixProperties, Map metadata, ShareRequestConditions requestConditions, FilePropertySemantics filePropertySemantics, BinaryData binaryData, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "create"); + ShareErrors.assertNotFileIdAddressed(fileId, "create"); final Context contextLocal = context == null ? Context.NONE : context; final ShareRequestConditions requestConditionsLocal = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -732,7 +732,7 @@ public PollerFlux beginCopy(String sourceUrl, FileSmbPr */ public PollerFlux beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { - FileIdOperations.ensurePathAddressed(fileId, "beginCopy"); + ShareErrors.assertNotFileIdAddressed(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() @@ -959,7 +959,7 @@ public Mono> abortCopyWithResponse(String copyId, ShareRequestCon Mono> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "abortCopy"); + ShareErrors.assertNotFileIdAddressed(fileId, "abortCopy"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .abortCopyNoCustomHeadersWithResponseAsync(shareName, filePath, copyId, null, @@ -1089,7 +1089,7 @@ public Mono> downloadToFileWithResponse(String dow Mono> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "downloadToFile"); + ShareErrors.assertNotFileIdAddressed(fileId, "downloadToFile"); return Mono.using(() -> channelSetup(downloadFilePath, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), channel -> getPropertiesWithResponse(requestConditions, context) .flatMap(response -> downloadResponseInChunk(response, channel, range, requestConditions, context)), @@ -1268,7 +1268,7 @@ public Mono downloadWithResponse(ShareFileDownlo } Mono downloadWithResponse(ShareFileDownloadOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "download"); + ShareErrors.assertNotFileIdAddressed(fileId, "download"); options = options == null ? new ShareFileDownloadOptions() : options; ShareFileRange range = options.getRange() == null ? new ShareFileRange(0) : options.getRange(); ShareRequestConditions requestConditions @@ -1433,7 +1433,7 @@ public Mono> deleteWithResponse(ShareRequestConditions requestCon } Mono> deleteWithResponse(ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "delete"); + ShareErrors.assertNotFileIdAddressed(fileId, "delete"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .deleteNoCustomHeadersWithResponseAsync(shareName, filePath, null, requestConditions.getLeaseId(), context); @@ -1616,8 +1616,9 @@ Mono> getPropertiesWithResponse(ShareRequestCondit requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; if (!fileId.isEmpty()) { - return azureFileStorageClient.getFileIdOperations() - .getFilePropertiesAsync(shareName, fileId, snapshot, null, requestConditions.getLeaseId(), context) + return azureFileStorageClient.getFiles() + .getPropertiesByFileIdWithResponseAsync(shareName, fileId, snapshot, null, null, + requestConditions.getLeaseId(), context) .map(ModelHelper::getPropertiesResponse); } return azureFileStorageClient.getFiles() @@ -1869,7 +1870,7 @@ public Mono> setPropertiesWithResponse(ShareFileSetPrope Mono> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties fileposixProperties, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setProperties"); + ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; @@ -2013,7 +2014,7 @@ public Mono> setMetadataWithResponse(Map> setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); + ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; try { @@ -2224,7 +2225,7 @@ public Mono> uploadWithResponse(ShareFileUploadOpt } Mono> uploadWithResponse(ShareFileUploadOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "upload"); + ShareErrors.assertNotFileIdAddressed(fileId, "upload"); try { StorageImplUtils.assertNotNull("options", options); ShareRequestConditions validatedRequestConditions = options.getRequestConditions() == null @@ -2394,7 +2395,7 @@ public Mono> uploadRangeWithResponse(ShareFileUplo * One-shot upload range. */ Mono> uploadRangeWithResponse(ShareFileUploadRangeOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "uploadRange"); + ShareErrors.assertNotFileIdAddressed(fileId, "uploadRange"); ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); long rangeOffset = (options.getOffset() == null) ? 0L : options.getOffset(); @@ -2559,7 +2560,7 @@ public Mono> uploadRangeFromUrlWithRes Mono> uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "uploadRangeFromUrl"); + ShareErrors.assertNotFileIdAddressed(fileId, "uploadRangeFromUrl"); ShareRequestConditions modifiedRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2683,7 +2684,7 @@ public Mono> clearRangeWithResponse(long length, l Mono> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "clearRange"); + ShareErrors.assertNotFileIdAddressed(fileId, "clearRange"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); context = context == null ? Context.NONE : context; @@ -3054,7 +3055,7 @@ PagedFlux listAllRangesInternal(ShareFileRange range, ShareR Mono> listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listRanges"); + ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -3121,7 +3122,7 @@ public PagedFlux listHandles(Integer maxResultsPerPage) { } PagedFlux listHandlesWithOptionalTimeout(Integer maxResultsPerPage, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getFiles() .listHandlesWithResponseAsync(shareName, filePath, marker, maxResultsPerPage, null, snapshot, context), @@ -3193,7 +3194,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getFiles() .forceCloseHandlesWithResponseAsync(shareName, filePath, handleId, null, null, snapshot, context) @@ -3235,7 +3236,7 @@ public Mono forceCloseAllHandles() { } PagedFlux forceCloseAllHandlesWithOptionalTimeout(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout( this.azureFileStorageClient.getFiles() @@ -3321,7 +3322,7 @@ public Mono> renameWithResponse(ShareFileRenameOp } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "rename"); + ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -3540,7 +3541,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3592,7 +3593,7 @@ public Mono> createHardLinkWithResponse(ShareFileCreateH Mono> createHardLinkWithResponse(String targetFile, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "createHardLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "createHardLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return this.azureFileStorageClient.getFiles() @@ -3648,7 +3649,7 @@ public Mono> createSymbolicLinkWithResponse(ShareFileCre Mono> createSymbolicLinkWithResponse(String linkText, Map metadata, OffsetDateTime fileCreationTime, OffsetDateTime fileLastWriteTime, String owner, String group, ShareRequestConditions requestConditions, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "createSymbolicLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "createSymbolicLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String fileCreationTimeString = FileSmbProperties.parseFileSMBDate(fileCreationTime); @@ -3700,7 +3701,7 @@ public Mono> getSymbolicLinkWithResponse() { } Mono> getSymbolicLinkWithResponse(Context context) { - FileIdOperations.ensurePathAddressed(fileId, "getSymbolicLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "getSymbolicLink"); context = context == null ? Context.NONE : context; return this.azureFileStorageClient.getFiles() .getSymbolicLinkWithResponseAsync(shareName, filePath, null, snapshot, null, context) @@ -3735,7 +3736,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateUserDelegationSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index f6794f35b3cff..ad2b62a8a7d02 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -33,7 +33,7 @@ import com.azure.storage.common.implementation.StorageSeekableByteChannel; import com.azure.storage.common.implementation.UploadUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.FilesCreateHardLinkHeaders; @@ -41,7 +41,6 @@ import com.azure.storage.file.share.implementation.models.FilesCreateSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; -import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.HardLinkList; @@ -268,7 +267,7 @@ public Response getFileLinksWithResponse(ShareRequestConditions @ServiceMethod(returns = ReturnType.SINGLE) public Response getFileLinksWithResponse(ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensureFileIdAddressed(fileId, "getFileLinks"); + ShareErrors.assertFileIdAddressed(fileId, "getFileLinks"); ShareRequestConditions conditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; Context finalContext = context == null ? Context.NONE : context; @@ -317,7 +316,7 @@ public final StorageFileInputStream openInputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileInputStream openInputStream(ShareFileRange range) { - FileIdOperations.ensurePathAddressed(fileId, "openInputStream"); + ShareErrors.assertNotFileIdAddressed(fileId, "openInputStream"); return new StorageFileInputStream(shareFileAsyncClient, range.getStart(), range.getEnd() == null ? null : (range.getEnd() - range.getStart() + 1)); } @@ -342,7 +341,7 @@ public final StorageFileOutputStream getFileOutputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileOutputStream getFileOutputStream(long offset) { - FileIdOperations.ensurePathAddressed(fileId, "getFileOutputStream"); + ShareErrors.assertNotFileIdAddressed(fileId, "getFileOutputStream"); return new StorageFileOutputStream(shareFileAsyncClient, offset); } @@ -352,7 +351,7 @@ public final StorageFileOutputStream getFileOutputStream(long offset) { * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByteChannelWriteOptions options) { - FileIdOperations.ensurePathAddressed(fileId, "getFileSeekableByteChannelWrite"); + ShareErrors.assertNotFileIdAddressed(fileId, "getFileSeekableByteChannelWrite"); Objects.requireNonNull(options, "'options' cannot be null."); if (options.isOverwriteMode()) { @@ -373,7 +372,7 @@ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByte * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelRead(ShareFileSeekableByteChannelReadOptions options) { - FileIdOperations.ensurePathAddressed(fileId, "getFileSeekableByteChannelRead"); + ShareErrors.assertNotFileIdAddressed(fileId, "getFileSeekableByteChannelRead"); ShareRequestConditions conditions = options != null ? options.getRequestConditions() : null; Long configuredChunkSize = options != null ? options.getChunkSizeInBytes() : null; int chunkSize @@ -418,7 +417,7 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "exists"); + ShareErrors.assertNotFileIdAddressed(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -624,7 +623,7 @@ public Response createWithResponse(long maxSize, ShareFileHttpHea @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareFileCreateOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "create"); + ShareErrors.assertNotFileIdAddressed(fileId, "create"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -815,7 +814,7 @@ public SyncPoller beginCopy(String sourceUrl, FileSmbPr */ public SyncPoller beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { - FileIdOperations.ensurePathAddressed(fileId, "beginCopy"); + ShareErrors.assertNotFileIdAddressed(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -1031,7 +1030,7 @@ public Response abortCopyWithResponse(String copyId, Duration timeout, Con @ServiceMethod(returns = ReturnType.SINGLE) public Response abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "abortCopy"); + ShareErrors.assertNotFileIdAddressed(fileId, "abortCopy"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1406,7 +1405,7 @@ public Response deleteWithResponse(Duration timeout, Context context) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "delete"); + ShareErrors.assertNotFileIdAddressed(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1577,13 +1576,13 @@ public Response getPropertiesWithResponse(ShareRequestCondi Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; - Callable> operation = fileId.isEmpty() + Callable> operation = fileId.isEmpty() ? () -> this.azureFileStorageClient.getFiles() .getPropertiesWithResponse(shareName, filePath, snapshot, null, finalRequestConditions.getLeaseId(), finalContext) - : () -> this.azureFileStorageClient.getFileIdOperations() - .getFileProperties(shareName, fileId, snapshot, null, finalRequestConditions.getLeaseId(), - finalContext); + : () -> this.azureFileStorageClient.getFiles() + .getPropertiesByFileIdWithResponse(shareName, fileId, snapshot, null, null, + finalRequestConditions.getLeaseId(), finalContext); return ModelHelper.getPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); } @@ -1817,7 +1816,7 @@ public Response setPropertiesWithResponse(long newFileSize, Share @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareFileSetPropertiesOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setProperties"); + ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions @@ -1971,7 +1970,7 @@ public Response setMetadataWithResponse(Map setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "setMetadata"); + ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2379,7 +2378,7 @@ public Response uploadRangeFromUrlWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "uploadRangeFromUrl"); + ShareErrors.assertNotFileIdAddressed(fileId, "uploadRangeFromUrl"); ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2494,7 +2493,7 @@ public Response clearRangeWithResponse(long length, long of @ServiceMethod(returns = ReturnType.SINGLE) public Response clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "clearRange"); + ShareErrors.assertNotFileIdAddressed(fileId, "clearRange"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); @@ -2651,7 +2650,7 @@ public PagedIterable listRanges(ShareFileRange range, Duration t @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRanges(ShareFileRange range, ShareRequestConditions requestConditions, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listRanges"); + ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2841,7 +2840,7 @@ public ShareFileRangeList listRangesDiff(String previousSnapshot) { @ServiceMethod(returns = ReturnType.SINGLE) public Response listRangesDiffWithResponse(ShareFileListRangesDiffOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listRangesDiff"); + ShareErrors.assertNotFileIdAddressed(fileId, "listRangesDiff"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); @@ -2905,7 +2904,7 @@ public PagedIterable listHandles() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listHandles(Integer maxResultsPerPage, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -2984,7 +2983,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseHandle"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> azureFileStorageClient.getFiles() .forceCloseHandlesWithResponse(shareName, filePath, handleId, null, null, snapshot, finalContext); @@ -3022,7 +3021,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -3111,7 +3110,7 @@ public ShareFileClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "rename"); + ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions sourceRequestConditions = options.getSourceRequestConditions() == null @@ -3334,7 +3333,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3379,7 +3378,7 @@ public ShareFileInfo createHardLink(String targetFile) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createHardLinkWithResponse(ShareFileCreateHardLinkOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "createHardLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "createHardLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3431,7 +3430,7 @@ public ShareFileInfo createSymbolicLink(String linkText) { */ public Response createSymbolicLinkWithResponse(ShareFileCreateSymbolicLinkOptions options, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "createSymbolicLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "createSymbolicLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3482,7 +3481,7 @@ public ShareFileSymbolicLinkInfo getSymbolicLink() { * describing the symbolic link. */ public Response getSymbolicLinkWithResponse(Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "getSymbolicLink"); + ShareErrors.assertNotFileIdAddressed(fileId, "getSymbolicLink"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -3520,7 +3519,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "generateUserDelegationSas"); + ShareErrors.assertNotFileIdAddressed(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } @@ -3528,7 +3527,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ ResponseBase listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Duration timeout, Context context) { - FileIdOperations.ensurePathAddressed(fileId, "listRanges"); + ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String rangeString = range == null ? null : range.toString(); diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index eca27ad656c74..72b7f27a6f22d 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -35,7 +35,7 @@ import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.sas.CommonSasQueryParameters; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.FileIdOperations; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.util.BuilderHelper; import com.azure.storage.file.share.models.ShareAudience; import com.azure.storage.file.share.models.ShareTokenIntent; @@ -389,7 +389,7 @@ public ShareFileClientBuilder shareName(String shareName) { * @throws IllegalArgumentException If {@code fileId} is null or blank. */ public ShareFileClientBuilder fileId(String fileId) { - FileIdOperations.validateFileId(fileId); + ShareErrors.validateFileId(fileId); this.fileId = fileId; this.resourcePath = ""; return this; diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java deleted file mode 100644 index 5dac091238779..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FileIdOperations.java +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.file.share.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Head; -import com.azure.core.annotation.HeaderParam; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.QueryParam; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.http.rest.ResponseBase; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.Context; -import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; -import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; -import com.azure.storage.file.share.implementation.models.ShareStorageExceptionInternal; -import com.azure.storage.file.share.implementation.util.ModelHelper; -import com.azure.storage.file.share.models.ShareTokenIntent; -import reactor.core.publisher.Mono; - -/** - * REST operations that accept a file ID as a query parameter but are not represented by the generated operation - * signatures. - */ -public final class FileIdOperations { - private static final ClientLogger LOGGER = new ClientLogger(FileIdOperations.class); - - private final OperationsService service; - private final AzureFileStorageImpl client; - - /** - * Creates a file-ID operations client. - * - * @param client The generated service client. - */ - public FileIdOperations(AzureFileStorageImpl client) { - this.client = client; - this.service - = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); - } - - /** - * Validates a file ID accepted by a client factory or builder. - * - * @param fileId The ID to validate. - * @throws IllegalArgumentException If the ID is null or blank. - */ - public static void validateFileId(String fileId) { - if (fileId == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be null.")); - } - if (fileId.trim().isEmpty()) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be empty.")); - } - } - - /** - * Ensures an operation is used with a file-ID-addressed client. - * - * @param fileId The client's file ID. - * @param operationName The operation name to report on failure. - */ - public static void ensureFileIdAddressed(String fileId, String operationName) { - if (fileId == null || fileId.isEmpty()) { - throw LOGGER.logExceptionAsError( - new IllegalStateException(operationName + " requires a file-ID-addressed client.")); - } - } - - /** - * Ensures a path-based operation is not used with a file-ID-addressed client. - * - * @param fileId The client's file ID. - * @param operationName The operation name to report on failure. - */ - public static void ensurePathAddressed(String fileId, String operationName) { - if (fileId != null && !fileId.isEmpty()) { - throw LOGGER.logExceptionAsError( - new IllegalStateException(operationName + " is not supported for a file-ID-addressed client.")); - } - } - - public Mono> getFilePropertiesAsync(String shareName, String fileId, - String snapshot, Integer timeout, String leaseId, Context context) { - return service - .getFileProperties(client.getUrl(), shareName, fileId, snapshot, timeout, client.isAllowTrailingDot(), - client.getVersion(), leaseId, client.getFileRequestIntent(), null, "application/xml", context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - public ResponseBase getFileProperties(String shareName, String fileId, - String snapshot, Integer timeout, String leaseId, Context context) { - try { - return service.getFilePropertiesSync(client.getUrl(), shareName, fileId, snapshot, timeout, - client.isAllowTrailingDot(), client.getVersion(), leaseId, client.getFileRequestIntent(), null, - "application/xml", context); - } catch (ShareStorageExceptionInternal exception) { - throw LOGGER.logExceptionAsError(ModelHelper.mapToShareStorageException(exception)); - } - } - - public Mono> getDirectoryPropertiesAsync(String shareName, - String fileId, String snapshot, Integer timeout, Context context) { - return service - .getDirectoryProperties(client.getUrl(), shareName, "directory", fileId, snapshot, timeout, - client.isAllowTrailingDot(), client.getVersion(), client.getFileRequestIntent(), null, - "application/xml", context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - public ResponseBase getDirectoryProperties(String shareName, String fileId, - String snapshot, Integer timeout, Context context) { - try { - return service.getDirectoryPropertiesSync(client.getUrl(), shareName, "directory", fileId, snapshot, - timeout, client.isAllowTrailingDot(), client.getVersion(), client.getFileRequestIntent(), null, - "application/xml", context); - } catch (ShareStorageExceptionInternal exception) { - throw LOGGER.logExceptionAsError(ModelHelper.mapToShareStorageException(exception)); - } - } - - @Host("{url}") - @ServiceInterface(name = "AzureFileStorageByFileId") - public interface OperationsService { - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - Mono> getFileProperties(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String snapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - ResponseBase getFilePropertiesSync(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String snapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - Mono> getDirectoryProperties(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("restype") String resourceType, - @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - ResponseBase getDirectoryPropertiesSync(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("restype") String resourceType, - @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String snapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("x-ms-client-request-id") String requestId, @HeaderParam("Accept") String accept, - Context context); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java new file mode 100644 index 0000000000000..4db7358cdd418 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share.implementation; + +import com.azure.core.util.logging.ClientLogger; + +/** + * Shared checks for operations that require a particular resource addressing mode. + */ +public final class ShareErrors { + private static final ClientLogger LOGGER = new ClientLogger(ShareErrors.class); + + private ShareErrors() { + } + + /** + * Validates a file ID accepted by a client factory or builder. + * + * @param fileId The ID to validate. + * @throws IllegalArgumentException If the ID is null or blank. + */ + public static void validateFileId(String fileId) { + if (fileId == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be null.")); + } + if (fileId.trim().isEmpty()) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be empty.")); + } + } + + /** + * Throws if the client does not address its resource by file ID. + * + * @param fileId The client's file ID. + * @param operationName The operation name to report on failure. + * @throws IllegalStateException If the client is not file-ID-addressed. + */ + public static void assertFileIdAddressed(String fileId, String operationName) { + if (fileId == null || fileId.isEmpty()) { + throw LOGGER.logExceptionAsError( + new IllegalStateException(operationName + " requires a file-ID-addressed client.")); + } + } + + /** + * Throws if the client addresses its resource by file ID. + * + * @param fileId The client's file ID. + * @param operationName The operation name to report on failure. + * @throws IllegalStateException If the client is file-ID-addressed. + */ + public static void assertNotFileIdAddressed(String fileId, String operationName) { + if (fileId != null && !fileId.isEmpty()) { + throw LOGGER.logExceptionAsError( + new IllegalStateException(operationName + " is not supported for a file-ID-addressed client.")); + } + } +} 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 d30e35a89037c..217cc8c0cc27c 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 @@ -408,9 +408,9 @@ public static Response createFileInfoResponse(ResponseBase(response, shareFileInfo); } - public static Response - getPropertiesResponse(final ResponseBase response) { - FilesGetPropertiesHeaders headers = response.getDeserializedHeaders(); + public static Response getPropertiesResponse(final Response response) { + // Path and file-ID operations return the same headers using different generated model types. + FilesGetPropertiesHeaders headers = new FilesGetPropertiesHeaders(response.getHeaders()); String eTag = headers.getETag(); OffsetDateTime lastModified = headers.getLastModified(); Map metadata = headers.getXMsMeta(); @@ -599,17 +599,16 @@ public static Response mapGetStatisticsResponse(Response(response, shareDirectoryInfo); } - public static Response - mapShareDirectoryPropertiesResponse(ResponseBase response) { - Map metadata = response.getDeserializedHeaders().getXMsMeta(); - String eTag = response.getDeserializedHeaders().getETag(); - OffsetDateTime offsetDateTime = response.getDeserializedHeaders().getLastModified(); - boolean isServerEncrypted = response.getDeserializedHeaders().isXMsServerEncrypted(); + public static Response mapShareDirectoryPropertiesResponse(Response response) { + DirectoriesGetPropertiesHeaders headers = new DirectoriesGetPropertiesHeaders(response.getHeaders()); + Map metadata = headers.getXMsMeta(); + String eTag = headers.getETag(); + OffsetDateTime offsetDateTime = headers.getLastModified(); + boolean isServerEncrypted = headers.isXMsServerEncrypted(); FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders()); FilePosixProperties posixProperties = FilePosixPropertiesHelper.create(response.getHeaders()); - ShareDirectoryProperties shareDirectoryProperties - = ShareDirectoryPropertiesHelper.create(metadata, eTag, offsetDateTime, isServerEncrypted, smbProperties, - posixProperties, response.getDeserializedHeaders().getXMsFileName()); + ShareDirectoryProperties shareDirectoryProperties = ShareDirectoryPropertiesHelper.create(metadata, eTag, + offsetDateTime, isServerEncrypted, smbProperties, posixProperties, headers.getXMsFileName()); return new SimpleResponse<>(response, shareDirectoryProperties); } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index ecffac7b9cbce..022b417b0a386 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -141,11 +141,15 @@ public void directoryPropertiesByIdUseFileIdQueryAndMapFileName() { Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); Assertions.assertEquals("", directoryClient.getDirectoryPath()); - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" - + FileIdTestHelper.FILE_ID, directoryClient.getDirectoryUrl()); - Assertions.assertEquals("directory", directoryClient.getProperties().getFileName()); - Assertions.assertTrue(requestUrl.get().startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "?restype=directory")); + Assertions.assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, + directoryClient.getDirectoryUrl()); + ShareDirectoryProperties properties = directoryClient.getProperties(); + Assertions.assertEquals("directory", properties.getFileName()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + Assertions.assertTrue(requestUrl.get() + .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?restype=directory")); Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } @@ -191,17 +195,18 @@ public void directoryIdClientRejectsPathOperations() { ShareDirectoryClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); Assertions.assertThrows(IllegalStateException.class, directoryClient::exists); - Assertions.assertThrows(IllegalStateException.class, directoryClient::create); + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, directoryClient::create); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); Assertions.assertThrows(IllegalStateException.class, directoryClient::delete); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("file.txt")); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("directory")); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); - Assertions.assertThrows(IllegalArgumentException.class, - () -> testShareClient.getDirectoryClientByFileId("")); - Assertions.assertThrows(IllegalArgumentException.class, - () -> testShareClient.getDirectoryClientByFileId(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getDirectoryClientByFileId("")); + Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getDirectoryClientByFileId(null)); Assertions.assertFalse(requestSent.get()); } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 7f229ec9b2eaf..a0266792f1bf7 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -129,6 +129,8 @@ public void asyncDirectoryPropertiesByIdUseFileIdQueryAndMapFileName() { = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); Assertions.assertEquals("directory", properties.getFileName()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); Assertions.assertTrue(requestUrl.get().contains("restype=directory")); Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } @@ -143,8 +145,7 @@ public void asyncDirectoryClientBuilderSetsFileId() { return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); }).build(); - ShareDirectoryAsyncClient directoryClient = new ShareFileClientBuilder() - .endpoint(FileIdTestHelper.ENDPOINT) + ShareDirectoryAsyncClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) .fileId(FileIdTestHelper.FILE_ID) .pipeline(pipeline) @@ -177,14 +178,17 @@ public void asyncDirectoryIdClientRejectsPathOperations() { ShareDirectoryAsyncClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.create().block()); + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.create().block()); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.delete().block()); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.exists().block()); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null).block()); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination").block()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.listFilesAndDirectories().blockFirst()); Assertions.assertThrows(IllegalStateException.class, - () -> directoryClient.forceCloseAllHandles(false).block()); + () -> directoryClient.listFilesAndDirectories().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseAllHandles(false).block()); Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); Assertions.assertFalse(requestSent.get()); } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index b376cce97c348..3ed788738f61e 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -205,11 +205,19 @@ public void filePropertiesByIdUseFileIdQueryAndMapFileName() { Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); Assertions.assertEquals("", fileClient.getFilePath()); - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" - + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); - Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" - + FileIdTestHelper.FILE_ID, requestUrl.get()); + Assertions.assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, + fileClient.getFileUrl()); + ShareFileProperties properties = fileClient.getProperties(); + Assertions.assertEquals("file.txt", properties.getFileName()); + Assertions.assertEquals(1024, properties.getContentLength()); + Assertions.assertEquals("en", properties.getContentLanguage()); + Assertions.assertEquals("gzip", properties.getContentEncoding()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + Assertions.assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, + requestUrl.get()); } @DoNotRecord @@ -222,8 +230,8 @@ public void fileLinksMapPropertiesAndDecodeLinkNames() { requestUrl.set(request.getUrl().toString()); String body = "file%20name.txt" + "parent-id" + ""; - HttpHeaders headers = FileIdTestHelper.fileHeaders("file.txt") - .set(HttpHeaderName.CONTENT_TYPE, "application/xml"); + HttpHeaders headers + = FileIdTestHelper.fileHeaders("file.txt").set(HttpHeaderName.CONTENT_TYPE, "application/xml"); return Mono.just(new MockHttpResponse(request, 200, headers, body.getBytes(StandardCharsets.UTF_8))); }).build(); @@ -237,6 +245,7 @@ public void fileLinksMapPropertiesAndDecodeLinkNames() { Assertions.assertEquals("file.txt", links.getProperties().getFileName()); Assertions.assertEquals("en", links.getProperties().getContentLanguage()); Assertions.assertEquals("gzip", links.getProperties().getContentEncoding()); + FileIdTestHelper.assertSmbProperties(links.getProperties().getSmbProperties()); Assertions.assertEquals(1, links.getLinks().size()); Assertions.assertEquals("file name.txt", links.getLinks().get(0).getName()); Assertions.assertEquals("parent-id", links.getLinks().get(0).getParentId()); @@ -244,6 +253,55 @@ public void fileLinksMapPropertiesAndDecodeLinkNames() { Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void propertiesByIdMapServiceErrors(boolean directory) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, + 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); + ShareClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + + ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, () -> { + if (directory) { + client.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties(); + } else { + client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties(); + } + }); + Assertions.assertEquals(404, exception.getStatusCode()); + Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void pathPropertiesRetainTimestampMapping(boolean directory) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals("/share/item", request.getUrl().getPath()); + Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); + Assertions.assertEquals(directory ? HttpMethod.GET : HttpMethod.HEAD, request.getHttpMethod()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("item"))); + }).build(); + ShareClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + + if (directory) { + FileIdTestHelper.assertSmbProperties(client.getDirectoryClient("item").getProperties().getSmbProperties()); + } else { + ShareFileProperties properties = client.getFileClient("item").getProperties(); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + Assertions.assertEquals(1024, properties.getContentLength()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + } + } + @DoNotRecord @Tag("file-id-mock") @Test @@ -262,18 +320,20 @@ public void fileIdClientsRejectPathOperations() { ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); Assertions.assertThrows(IllegalStateException.class, fileClient::exists); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024)); + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024)); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); Assertions.assertThrows(IllegalStateException.class, fileClient::delete); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null)); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination")); Assertions.assertThrows(IllegalStateException.class, fileClient::getFileOutputStream); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); - Assertions.assertThrows(IllegalStateException.class, + IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks()); - Assertions.assertThrows(IllegalArgumentException.class, - () -> testShareClient.getFileClientByFileId(" ")); - Assertions.assertThrows(IllegalArgumentException.class, - () -> testShareClient.getFileClientByFileId(null)); + Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); + Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getFileClientByFileId(" ")); + Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getFileClientByFileId(null)); Assertions.assertFalse(requestSent.get()); } @@ -288,17 +348,18 @@ public void fileClientBuilderParsesFileIdFromEndpointQuery() { return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); }).build(); - ShareFileClient fileClient - = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "?fileid=" + FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildFileClient(); + ShareFileClient fileClient = new ShareFileClientBuilder() + .endpoint( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildFileClient(); Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" - + FileIdTestHelper.FILE_ID, requestUrl.get()); + Assertions.assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, + requestUrl.get()); ShareFileClient pathClient = new ShareFileClientBuilder() .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/file.txt") @@ -340,10 +401,8 @@ public void fileClientBuilderSetsFileId() { .buildFileClient(); Assertions.assertEquals("", pathClient.getFileId()); Assertions.assertEquals("path/file.txt", pathClient.getFilePath()); - Assertions.assertThrows(IllegalArgumentException.class, - () -> new ShareFileClientBuilder().fileId(" ")); - Assertions.assertThrows(IllegalArgumentException.class, - () -> new ShareFileClientBuilder().fileId(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(" ")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(null)); } @DoNotRecord diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 5cc54e2792270..cebab4614ae03 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -183,6 +183,11 @@ public void asyncFilePropertiesByIdUseFileIdQueryAndMapFileName() { = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); Assertions.assertEquals("file.txt", properties.getFileName()); + Assertions.assertEquals(1024, properties.getContentLength()); + Assertions.assertEquals("en", properties.getContentLanguage()); + Assertions.assertEquals("gzip", properties.getContentEncoding()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } @@ -220,8 +225,8 @@ public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { requestUrl.set(request.getUrl().toString()); String body = "file%20name.txt" + "parent-id" + ""; - HttpHeaders headers = FileIdTestHelper.fileHeaders("file.txt") - .set(HttpHeaderName.CONTENT_TYPE, "application/xml"); + HttpHeaders headers + = FileIdTestHelper.fileHeaders("file.txt").set(HttpHeaderName.CONTENT_TYPE, "application/xml"); return Mono.just(new MockHttpResponse(request, 200, headers, body.getBytes(StandardCharsets.UTF_8))); }).build(); @@ -230,12 +235,12 @@ public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { .serviceVersion(ShareServiceVersion.V2027_03_07) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareFileLinks links - = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getFileLinks().block(); + ShareFileLinks links = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getFileLinks().block(); Assertions.assertEquals("file.txt", links.getProperties().getFileName()); Assertions.assertEquals("en", links.getProperties().getContentLanguage()); Assertions.assertEquals("gzip", links.getProperties().getContentEncoding()); + FileIdTestHelper.assertSmbProperties(links.getProperties().getSmbProperties()); Assertions.assertEquals(1, links.getLinks().size()); Assertions.assertEquals("file name.txt", links.getLinks().get(0).getName()); Assertions.assertEquals("parent-id", links.getLinks().get(0).getParentId()); @@ -243,6 +248,56 @@ public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncPropertiesByIdMapServiceErrors(boolean directory) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, + 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); + ShareAsyncClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + + ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, () -> { + if (directory) { + client.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); + } else { + client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); + } + }); + Assertions.assertEquals(404, exception.getStatusCode()); + Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncPathPropertiesRetainTimestampMapping(boolean directory) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + Assertions.assertEquals("/share/item", request.getUrl().getPath()); + Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); + Assertions.assertEquals(directory ? HttpMethod.GET : HttpMethod.HEAD, request.getHttpMethod()); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("item"))); + }).build(); + ShareAsyncClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + + if (directory) { + FileIdTestHelper + .assertSmbProperties(client.getDirectoryClient("item").getProperties().block().getSmbProperties()); + } else { + ShareFileProperties properties = client.getFileClient("item").getProperties().block(); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + Assertions.assertEquals(1024, properties.getContentLength()); + Assertions.assertEquals("value", properties.getMetadata().get("key")); + } + } + @DoNotRecord @Tag("file-id-mock") @Test @@ -260,7 +315,10 @@ public void asyncFileIdClientsRejectPathOperations() { .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); ShareFileAsyncClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024).block()); + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024).block()); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.delete().block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.exists().block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.download().blockFirst()); @@ -268,8 +326,9 @@ public void asyncFileIdClientsRejectPathOperations() { Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null).block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination").block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles().block()); - Assertions.assertThrows(IllegalStateException.class, + IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks().block()); + Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); Assertions.assertFalse(requestSent.get()); } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java index 9b92c31b8dff7..b9dc78e682994 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdTestHelper.java @@ -6,10 +6,15 @@ import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; +import java.time.OffsetDateTime; + +import static org.junit.jupiter.api.Assertions.assertEquals; + final class FileIdTestHelper { static final String ENDPOINT = "https://account.file.core.windows.net"; static final String SHARE_NAME = "share"; static final String FILE_ID = "12384898975283830"; + private static final String FILE_TIME = "2026-09-29T12:34:56.1234567Z"; private FileIdTestHelper() { } @@ -17,6 +22,14 @@ private FileIdTestHelper() { static HttpHeaders fileHeaders(String fileName) { return new HttpHeaders().set(HttpHeaderName.ETAG, "\"0x8DEAF1479E1C087\"") .set(HttpHeaderName.LAST_MODIFIED, "Wed, 21 Oct 2015 07:28:00 GMT") + .set(HttpHeaderName.CONTENT_TYPE, "application/octet-stream") + .set(HttpHeaderName.CONTENT_LENGTH, "1024") + .set(HttpHeaderName.CONTENT_LANGUAGE, "en") + .set(HttpHeaderName.CONTENT_ENCODING, "gzip") + .set(HttpHeaderName.fromString("x-ms-meta-key"), "value") + .set(HttpHeaderName.fromString("x-ms-file-creation-time"), FILE_TIME) + .set(HttpHeaderName.fromString("x-ms-file-last-write-time"), FILE_TIME) + .set(HttpHeaderName.fromString("x-ms-file-change-time"), FILE_TIME) .set(HttpHeaderName.fromString("x-ms-file-id"), FILE_ID) .set(HttpHeaderName.fromString("x-ms-file-parent-id"), "parent-id") .set(HttpHeaderName.fromString("x-ms-file-name"), fileName) @@ -27,4 +40,12 @@ static HttpHeaders fileHeaders(String fileName) { .set(HttpHeaderName.fromString("x-ms-content-language"), "en") .set(HttpHeaderName.fromString("x-ms-content-encoding"), "gzip"); } + + static void assertSmbProperties(FileSmbProperties properties) { + assertEquals(FILE_ID, properties.getFileId()); + assertEquals("parent-id", properties.getParentId()); + assertEquals(OffsetDateTime.parse(FILE_TIME), properties.getFileCreationTime()); + assertEquals(OffsetDateTime.parse(FILE_TIME), properties.getFileLastWriteTime()); + assertEquals(OffsetDateTime.parse(FILE_TIME), properties.getFileChangeTime()); + } } From 913700c5a499fc5c5009731addfc7b92dafbfa4a Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 14:13:01 -0400 Subject: [PATCH 06/39] remove directory by id through swagger update --- .../share/implementation/DirectoriesImpl.java | 343 +-------------- .../file/share/implementation/FilesImpl.java | 402 +++++++++--------- .../models/FilesGetHardLinksHeaders.java | 45 +- .../FilesGetPropertiesByFileIdHeaders.java | 45 +- .../swagger/README.md | 2 +- 5 files changed, 286 insertions(+), 551 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java index df88eb0e5de8a..efdd0c8e5414b 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java @@ -26,7 +26,6 @@ import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesDeleteHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesForceCloseHandlesHeaders; -import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesByFileIdHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListFilesAndDirectoriesSegmentHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListHandlesHeaders; @@ -632,54 +631,6 @@ Response renameNoCustomHeadersSync(@HostParam("url") String url, @PathPara @HeaderParam("x-ms-source-allow-trailing-dot") Boolean allowSourceTrailingDot, @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, @HeaderParam("Accept") String accept, Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Mono> getPropertiesByFileId( - @HostParam("url") String url, @PathParam("shareName") String shareName, - @QueryParam("restype") String restype, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("restype") String restype, - @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - ResponseBase getPropertiesByFileIdSync( - @HostParam("url") String url, @PathParam("shareName") String shareName, - @QueryParam("restype") String restype, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Get("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("restype") String restype, - @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, - @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, - @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); } /** @@ -2914,7 +2865,7 @@ public Response listHandlesNoCustomHeadersWithResponse(Stri * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2947,7 +2898,7 @@ public Mono> forceCloseH * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2984,7 +2935,7 @@ public Mono> forceCloseH * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3015,7 +2966,7 @@ public Mono forceCloseHandlesAsync(String shareName, String directory, Str * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3047,7 +2998,7 @@ public Mono forceCloseHandlesAsync(String shareName, String directory, Str * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3079,7 +3030,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3115,7 +3066,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3154,7 +3105,7 @@ public ResponseBase forceCloseHandles * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3183,7 +3134,7 @@ public void forceCloseHandles(String shareName, String directory, String handleI * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3228,7 +3179,7 @@ public Response forceCloseHandlesNoCustomHeadersWithResponse(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3278,7 +3229,7 @@ public Mono> renameWithResponseAsyn * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3365,7 +3316,7 @@ public Mono> renameWithResponseAsyn * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3415,7 +3366,7 @@ public Mono renameAsync(String shareName, String directory, String renameS * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3467,7 +3418,7 @@ public Mono renameAsync(String shareName, String directory, String renameS * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3517,7 +3468,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3604,7 +3555,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3693,7 +3644,7 @@ public ResponseBase renameWithResponse(String sh * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3740,7 +3691,7 @@ public void rename(String shareName, String directory, String renameSource, Inte * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3816,262 +3767,4 @@ public Response renameNoCustomHeadersWithResponse(String shareName, String throw ModelHelper.mapToShareStorageException(internalException); } } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, - requestId, context)) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { - final String restype = "directory"; - final String accept = "application/xml"; - return service - .getPropertiesByFileId(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, timeout, - this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), - this.client.getFileRequestIntent(), accept, context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, - String requestId) { - return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, - String requestId, Context context) { - return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, - String sharesnapshot, Integer timeout, String requestId) { - return FluxUtil - .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, - sharesnapshot, timeout, requestId, context)) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, - String sharesnapshot, Integer timeout, String requestId, Context context) { - final String restype = "directory"; - final String accept = "application/xml"; - return service - .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, - timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), - this.client.getFileRequestIntent(), accept, context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesByFileIdWithResponse( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { - try { - final String restype = "directory"; - final String accept = "application/xml"; - return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, - timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), - this.client.getFileRequestIntent(), accept, context); - } catch (ShareStorageExceptionInternal internalException) { - throw ModelHelper.mapToShareStorageException(internalException); - } - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, - String requestId) { - getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, Context.NONE); - } - - /** - * Returns all system properties for the directory identified by its file ID. The data returned does not include the - * files in the directory or any subdirectories. - * - * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. - * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share - * snapshot to query. - * @param timeout The timeout parameter is expressed in seconds. For more information, see <a - * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting - * Timeouts for File Service Operations.</a>. - * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the - * analytics logs when storage analytics logging is enabled. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, - String sharesnapshot, Integer timeout, String requestId, Context context) { - try { - final String restype = "directory"; - final String accept = "application/xml"; - return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, restype, fileId, - sharesnapshot, timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), - this.client.getFileRequestIntent(), accept, context); - } catch (ShareStorageExceptionInternal internalException) { - throw ModelHelper.mapToShareStorageException(internalException); - } - } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index d173728c96df0..b4689a572e257 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -107,54 +107,6 @@ public final class FilesImpl { @ServiceInterface(name = "AzureFileStorageFiles") public interface FilesService { - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Mono> getPropertiesByFileId(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - - @Head("/{shareName}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, - @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, - @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, - @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, - @HeaderParam("x-ms-lease-id") String leaseId, - @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, - @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, - @HeaderParam("Accept") String accept, Context context); - @Get("/{shareName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) @@ -203,6 +155,54 @@ Response getHardLinksNoCustomHeadersSync(@HostParam("url") String @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, @HeaderParam("Accept") String accept, Context context); + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileId(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Head("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, + @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, + @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-lease-id") String leaseId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + @Put("/{shareName}/{fileName}") @ExpectedResponses({ 201 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) @@ -1613,11 +1613,11 @@ Response createHardLinkNoCustomHeadersSync(@HostParam("url") String url, } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1629,23 +1629,24 @@ Response createHardLinkNoCustomHeadersSync(@HostParam("url") String url, * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { + public Mono> getHardLinksWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { return FluxUtil - .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, - requestId, leaseId, context)) + .withContext(context -> getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, + leaseId, context)) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1658,26 +1659,27 @@ public Mono> getProperties * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase} on successful completion of {@link Mono}. + * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, - Context context) { + public Mono> getHardLinksWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + final String comp = "hardlinks"; final String accept = "application/xml"; return service - .getPropertiesByFileId(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + .getHardLinks(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1689,22 +1691,22 @@ public Mono> getProperties * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @return the list of hard links for a file on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { - return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) + return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(ignored -> Mono.empty()); + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1717,22 +1719,22 @@ public Mono getPropertiesByFileIdAsync(String shareName, String fileId, St * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @return the list of hard links for a file on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { - return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, - context).onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(ignored -> Mono.empty()); + return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1744,23 +1746,23 @@ public Mono getPropertiesByFileIdAsync(String shareName, String fileId, St * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { return FluxUtil - .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, - sharesnapshot, timeout, requestId, leaseId, context)) + .withContext(context -> getHardLinksNoCustomHeadersWithResponseAsync(shareName, fileId, sharesnapshot, + timeout, requestId, leaseId, context)) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1773,25 +1775,26 @@ public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsyn * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { + final String comp = "hardlinks"; final String accept = "application/xml"; return service - .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + .getHardLinksNoCustomHeaders(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1804,14 +1807,15 @@ public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsyn * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link ResponseBase}. + * @return the list of hard links for a file along with {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesByFileIdWithResponse(String shareName, + public ResponseBase getHardLinksWithResponse(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { try { + final String comp = "hardlinks"; final String accept = "application/xml"; - return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, + return service.getHardLinksSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context); } catch (ShareStorageExceptionInternal internalException) { @@ -1820,11 +1824,11 @@ public ResponseBase getPropertiesByFile } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1836,19 +1840,25 @@ public ResponseBase getPropertiesByFile * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the list of hard links for a file. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, + public HardLinkList getHardLinks(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { - getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE); + try { + return getHardLinksWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE) + .getValue(); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } } /** - * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its - * file ID. It does not return the content of the file. + * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties + * for the file. NFS only. * * @param shareName The name of the target share. - * @param fileId The file ID of the target file or directory. + * @param fileId The file ID of the file whose hard links are returned. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1861,15 +1871,16 @@ public void getPropertiesByFileId(String shareName, String fileId, String shares * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. + * @return the list of hard links for a file along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, + public Response getHardLinksNoCustomHeadersWithResponse(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { try { + final String comp = "hardlinks"; final String accept = "application/xml"; - return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, fileId, - sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + return service.getHardLinksNoCustomHeadersSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, + timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context); } catch (ShareStorageExceptionInternal internalException) { throw ModelHelper.mapToShareStorageException(internalException); @@ -1877,11 +1888,11 @@ public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String sh } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1893,24 +1904,23 @@ public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String sh * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of - * {@link Mono}. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getHardLinksWithResponseAsync(String shareName, - String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { return FluxUtil - .withContext(context -> getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, - leaseId, context)) + .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, + requestId, leaseId, context)) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1923,27 +1933,26 @@ public Mono> getHardLinksWi * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link ResponseBase} on successful completion of - * {@link Mono}. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getHardLinksWithResponseAsync(String shareName, - String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { - final String comp = "hardlinks"; + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, + Context context) { final String accept = "application/xml"; return service - .getHardLinks(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + .getPropertiesByFileId(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1955,22 +1964,22 @@ public Mono> getHardLinksWi * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file on successful completion of {@link Mono}. + * @return A {@link Mono} that completes when a successful response is received. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { - return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + .flatMap(ignored -> Mono.empty()); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -1983,22 +1992,22 @@ public Mono getHardLinksAsync(String shareName, String fileId, Str * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file on successful completion of {@link Mono}. + * @return A {@link Mono} that completes when a successful response is received. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getHardLinksAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { - return getHardLinksWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, context) - .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, + context).onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -2010,23 +2019,23 @@ public Mono getHardLinksAsync(String shareName, String fileId, Str * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { return FluxUtil - .withContext(context -> getHardLinksNoCustomHeadersWithResponseAsync(shareName, fileId, sharesnapshot, - timeout, requestId, leaseId, context)) + .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, + sharesnapshot, timeout, requestId, leaseId, context)) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -2039,26 +2048,25 @@ public Mono> getHardLinksNoCustomHeadersWithResponseAsync * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link Response} on successful completion of {@link Mono}. + * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getHardLinksNoCustomHeadersWithResponseAsync(String shareName, String fileId, + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { - final String comp = "hardlinks"; final String accept = "application/xml"; return service - .getHardLinksNoCustomHeaders(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context) .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -2071,15 +2079,14 @@ public Mono> getHardLinksNoCustomHeadersWithResponseAsync * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link ResponseBase}. + * @return the {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getHardLinksWithResponse(String shareName, + public ResponseBase getPropertiesByFileIdWithResponse(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { try { - final String comp = "hardlinks"; final String accept = "application/xml"; - return service.getHardLinksSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, timeout, + return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context); } catch (ShareStorageExceptionInternal internalException) { @@ -2088,11 +2095,11 @@ public ResponseBase getHardLinksWithResp } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -2104,25 +2111,19 @@ public ResponseBase getHardLinksWithResp * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file. */ @ServiceMethod(returns = ReturnType.SINGLE) - public HardLinkList getHardLinks(String shareName, String fileId, String sharesnapshot, Integer timeout, + public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { - try { - return getHardLinksWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE) - .getValue(); - } catch (ShareStorageExceptionInternal internalException) { - throw ModelHelper.mapToShareStorageException(internalException); - } + getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, Context.NONE); } /** - * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * Returns all user-defined metadata, standard HTTP properties, and system properties for the file identified by its + * file ID. It does not return the content of the file. * * @param shareName The name of the target share. - * @param fileId The file ID of the file whose hard links are returned. + * @param fileId The file ID of the target file or directory. * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share * snapshot to query. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a @@ -2135,16 +2136,15 @@ public HardLinkList getHardLinks(String shareName, String fileId, String sharesn * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the list of hard links for a file along with {@link Response}. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getHardLinksNoCustomHeadersWithResponse(String shareName, String fileId, + public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { try { - final String comp = "hardlinks"; final String accept = "application/xml"; - return service.getHardLinksNoCustomHeadersSync(this.client.getUrl(), shareName, comp, sharesnapshot, fileId, - timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), + return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, fileId, + sharesnapshot, timeout, this.client.getVersion(), requestId, leaseId, this.client.isAllowTrailingDot(), this.client.getFileRequestIntent(), accept, context); } catch (ShareStorageExceptionInternal internalException) { throw ModelHelper.mapToShareStorageException(internalException); @@ -8754,7 +8754,7 @@ public Response listHandlesNoCustomHeadersWithResponse(Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8784,7 +8784,7 @@ public Mono> forceCloseHandles * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8818,7 +8818,7 @@ public Mono> forceCloseHandles * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8847,7 +8847,7 @@ public Mono forceCloseHandlesAsync(String shareName, String fileName, Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8877,7 +8877,7 @@ public Mono forceCloseHandlesAsync(String shareName, String fileName, Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8907,7 +8907,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8941,7 +8941,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8977,7 +8977,7 @@ public ResponseBase forceCloseHandlesWithRe * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -9003,7 +9003,7 @@ public void forceCloseHandles(String shareName, String fileName, String handleId * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -9046,7 +9046,7 @@ public Response forceCloseHandlesNoCustomHeadersWithResponse(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9097,7 +9097,7 @@ public Mono> renameWithResponseAsync(Stri * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9189,7 +9189,7 @@ public Mono> renameWithResponseAsync(Stri * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9241,7 +9241,7 @@ public Mono renameAsync(String shareName, String fileName, String renameSo * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9294,7 +9294,7 @@ public Mono renameAsync(String shareName, String fileName, String renameSo * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9345,7 +9345,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9437,7 +9437,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9531,7 +9531,7 @@ public ResponseBase renameWithResponse(String shareNam * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9579,7 +9579,7 @@ public void rename(String shareName, String fileName, String renameSource, Integ * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java index dd9919d5906a7..0e73849e3cde7 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java @@ -143,19 +143,19 @@ public final class FilesGetHardLinksHeaders { * The x-ms-file-creation-time property. */ @Generated - private OffsetDateTime xMsFileCreationTime; + private DateTimeRfc1123 xMsFileCreationTime; /* * The x-ms-file-last-write-time property. */ @Generated - private OffsetDateTime xMsFileLastWriteTime; + private DateTimeRfc1123 xMsFileLastWriteTime; /* * The x-ms-file-change-time property. */ @Generated - private OffsetDateTime xMsFileChangeTime; + private DateTimeRfc1123 xMsFileChangeTime; /* * The x-ms-file-permission-key property. @@ -379,19 +379,19 @@ public FilesGetHardLinksHeaders(HttpHeaders rawHeaders) { this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); } else { this.xMsFileCreationTime = null; } String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); } else { this.xMsFileLastWriteTime = null; } String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); } else { this.xMsFileChangeTime = null; } @@ -891,7 +891,10 @@ public FilesGetHardLinksHeaders setXMsFileAttributes(String xMsFileAttributes) { */ @Generated public OffsetDateTime getXMsFileCreationTime() { - return this.xMsFileCreationTime; + if (this.xMsFileCreationTime == null) { + return null; + } + return this.xMsFileCreationTime.getDateTime(); } /** @@ -902,7 +905,11 @@ public OffsetDateTime getXMsFileCreationTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - this.xMsFileCreationTime = xMsFileCreationTime; + if (xMsFileCreationTime == null) { + this.xMsFileCreationTime = null; + } else { + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + } return this; } @@ -913,7 +920,10 @@ public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCre */ @Generated public OffsetDateTime getXMsFileLastWriteTime() { - return this.xMsFileLastWriteTime; + if (this.xMsFileLastWriteTime == null) { + return null; + } + return this.xMsFileLastWriteTime.getDateTime(); } /** @@ -924,7 +934,11 @@ public OffsetDateTime getXMsFileLastWriteTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - this.xMsFileLastWriteTime = xMsFileLastWriteTime; + if (xMsFileLastWriteTime == null) { + this.xMsFileLastWriteTime = null; + } else { + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + } return this; } @@ -935,7 +949,10 @@ public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLa */ @Generated public OffsetDateTime getXMsFileChangeTime() { - return this.xMsFileChangeTime; + if (this.xMsFileChangeTime == null) { + return null; + } + return this.xMsFileChangeTime.getDateTime(); } /** @@ -946,7 +963,11 @@ public OffsetDateTime getXMsFileChangeTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - this.xMsFileChangeTime = xMsFileChangeTime; + if (xMsFileChangeTime == null) { + this.xMsFileChangeTime = null; + } else { + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + } return this; } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java index 7340b552b03f6..1d928b52b3b5f 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java @@ -161,19 +161,19 @@ public final class FilesGetPropertiesByFileIdHeaders { * The x-ms-file-creation-time property. */ @Generated - private OffsetDateTime xMsFileCreationTime; + private DateTimeRfc1123 xMsFileCreationTime; /* * The x-ms-file-last-write-time property. */ @Generated - private OffsetDateTime xMsFileLastWriteTime; + private DateTimeRfc1123 xMsFileLastWriteTime; /* * The x-ms-file-change-time property. */ @Generated - private OffsetDateTime xMsFileChangeTime; + private DateTimeRfc1123 xMsFileChangeTime; /* * The x-ms-file-permission-key property. @@ -366,19 +366,19 @@ public FilesGetPropertiesByFileIdHeaders(HttpHeaders rawHeaders) { this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); } else { this.xMsFileCreationTime = null; } String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); } else { this.xMsFileLastWriteTime = null; } String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); } else { this.xMsFileChangeTime = null; } @@ -942,7 +942,10 @@ public FilesGetPropertiesByFileIdHeaders setXMsFileAttributes(String xMsFileAttr */ @Generated public OffsetDateTime getXMsFileCreationTime() { - return this.xMsFileCreationTime; + if (this.xMsFileCreationTime == null) { + return null; + } + return this.xMsFileCreationTime.getDateTime(); } /** @@ -953,7 +956,11 @@ public OffsetDateTime getXMsFileCreationTime() { */ @Generated public FilesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - this.xMsFileCreationTime = xMsFileCreationTime; + if (xMsFileCreationTime == null) { + this.xMsFileCreationTime = null; + } else { + this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + } return this; } @@ -964,7 +971,10 @@ public FilesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime x */ @Generated public OffsetDateTime getXMsFileLastWriteTime() { - return this.xMsFileLastWriteTime; + if (this.xMsFileLastWriteTime == null) { + return null; + } + return this.xMsFileLastWriteTime.getDateTime(); } /** @@ -975,7 +985,11 @@ public OffsetDateTime getXMsFileLastWriteTime() { */ @Generated public FilesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - this.xMsFileLastWriteTime = xMsFileLastWriteTime; + if (xMsFileLastWriteTime == null) { + this.xMsFileLastWriteTime = null; + } else { + this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + } return this; } @@ -986,7 +1000,10 @@ public FilesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime */ @Generated public OffsetDateTime getXMsFileChangeTime() { - return this.xMsFileChangeTime; + if (this.xMsFileChangeTime == null) { + return null; + } + return this.xMsFileChangeTime.getDateTime(); } /** @@ -997,7 +1014,11 @@ public OffsetDateTime getXMsFileChangeTime() { */ @Generated public FilesGetPropertiesByFileIdHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - this.xMsFileChangeTime = xMsFileChangeTime; + if (xMsFileChangeTime == null) { + this.xMsFileChangeTime = null; + } else { + this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + } return this; } diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 27cc1963971e7..2805cb573304c 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/5bdba2451c9c437df1779566e424b11d4ae429f8/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/25afaa4b9194ad7fa1af0b8816c07ad0a39d322d/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share From 9959bf20e5138c72417e4582805619d28d48a7ce Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 14:15:29 -0400 Subject: [PATCH 07/39] change time changes from loop to hardcode in swagger doc --- .../swagger/README.md | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 2805cb573304c..51976378c9ee0 100644 --- a/sdk/storage/azure-storage-file-share/swagger/README.md +++ b/sdk/storage/azure-storage-file-share/swagger/README.md @@ -102,18 +102,28 @@ directive: op.get.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; ``` -### File-ID property and hard-link response timestamps +### /{shareName} ``` yaml directive: - from: swagger-document where: $["x-ms-paths"] transform: > - for (const [path, method] of [["/{shareName}?restype=directory", "get"], ["/{shareName}", "head"], ["/{shareName}?comp=hardlinks", "get"]]) { - const headers = $[path][method].responses["200"].headers; - for (const name of ["x-ms-file-creation-time", "x-ms-file-last-write-time", "x-ms-file-change-time"]) { - headers[name].format = "date-time"; - } - } + const op = $["/{shareName}"]; + op.head.responses["200"].headers["x-ms-file-creation-time"].format = "date-time"; + op.head.responses["200"].headers["x-ms-file-last-write-time"].format = "date-time"; + op.head.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; +``` + +### /{shareName}?comp=hardlinks +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"] + transform: > + const op = $["/{shareName}?comp=hardlinks"]; + op.get.responses["200"].headers["x-ms-file-creation-time"].format = "date-time"; + op.get.responses["200"].headers["x-ms-file-last-write-time"].format = "date-time"; + op.get.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; ``` ### Keep file attribute documentation ASCII From 8e48b0dd30d7dce1d759bc9df692975d5933c469 Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:01:28 -0400 Subject: [PATCH 08/39] Remove directory-by-ID support from File Share clients --- .../storage/file/share/ShareAsyncClient.java | 13 - .../azure/storage/file/share/ShareClient.java | 13 - .../file/share/ShareDirectoryAsyncClient.java | 49 +- .../file/share/ShareDirectoryClient.java | 49 +- .../file/share/ShareFileClientBuilder.java | 18 +- .../ShareDirectoryPropertiesHelper.java | 10 +- ...rectoriesGetPropertiesByFileIdHeaders.java | 668 ------------------ .../implementation/util/ModelHelper.java | 7 +- .../models/ShareDirectoryProperties.java | 14 +- .../storage/file/share/DirectoryApiTests.java | 106 +-- .../file/share/DirectoryAsyncApiTests.java | 107 +-- .../storage/file/share/FileApiTests.java | 14 +- .../storage/file/share/FileAsyncApiTests.java | 14 +- 13 files changed, 147 insertions(+), 935 deletions(-) delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java 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 044b674b9da97..06a2c38b49774 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 @@ -201,19 +201,6 @@ public ShareFileAsyncClient getFileClientByFileId(String fileId) { serviceVersion, sasToken); } - /** - * Creates a directory client that addresses a directory by its file ID. - * - * @param fileId The file ID of the directory. - * @return A client for interacting with the directory by ID. - * @throws IllegalArgumentException If {@code fileId} is null or blank. - */ - public ShareDirectoryAsyncClient getDirectoryClientByFileId(String fileId) { - ShareErrors.validateFileId(fileId); - return new ShareDirectoryAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, - serviceVersion, sasToken); - } - /** * Creates a new {@link ShareAsyncClient} linked to the {@code snapshot} of this share resource. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java index ca15ff0d526b1..47ac0d5612e34 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java @@ -212,19 +212,6 @@ public ShareFileClient getFileClientByFileId(String fileId) { serviceVersion, sasToken); } - /** - * Creates a directory client that addresses a directory by its file ID. - * - * @param fileId The file ID of the directory. - * @return A client for interacting with the directory by ID. - * @throws IllegalArgumentException If {@code fileId} is null or blank. - */ - public ShareDirectoryClient getDirectoryClientByFileId(String fileId) { - ShareErrors.validateFileId(fileId); - return new ShareDirectoryClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, - serviceVersion, sasToken); - } - /** * Creates a new {@link ShareAsyncClient} linked to the {@code snapshot} of this share resource. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index 71d42c8bb1b01..c37ab6d97f017 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -23,7 +23,6 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.ListFilesIncludeType; @@ -93,7 +92,6 @@ public class ShareDirectoryAsyncClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; - private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -111,17 +109,10 @@ public class ShareDirectoryAsyncClient { */ ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { - this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); - } - - ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, - String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, - AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; - this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -131,8 +122,8 @@ public class ShareDirectoryAsyncClient { ShareDirectoryAsyncClient(ShareDirectoryAsyncClient directoryAsyncClient) { this(directoryAsyncClient.azureFileStorageClient, directoryAsyncClient.shareName, - Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.fileId, - directoryAsyncClient.snapshot, directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, + Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.snapshot, + directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, directoryAsyncClient.sasToken); } @@ -144,29 +135,13 @@ public class ShareDirectoryAsyncClient { public String getDirectoryUrl() { StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); - if (fileId.isEmpty()) { - directoryUrlString.append("/").append(directoryPath); - } + directoryUrlString.append("/").append(directoryPath); if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - directoryUrlString.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - directoryUrlString.append("?fileid=").append(fileId); } return directoryUrlString.toString(); } - /** - * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. - * - * @return The file ID. - */ - public String getFileId() { - return fileId; - } - /** * Gets the service version the client is using. * @@ -186,7 +161,6 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileAsyncClient that interacts with the specified share */ public ShareFileAsyncClient getFileClient(String fileName) { - ShareErrors.assertNotFileIdAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -206,7 +180,6 @@ public ShareFileAsyncClient getFileClient(String fileName) { * @return a ShareDirectoryAsyncClient that interacts with the specified directory */ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) { - ShareErrors.assertNotFileIdAddressed(fileId, "getSubdirectoryClient"); StringBuilder directoryPathBuilder = new StringBuilder().append(this.directoryPath); if (!this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/")) { directoryPathBuilder.append("/"); @@ -257,7 +230,6 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "exists"); return this.getPropertiesWithResponse(context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -383,7 +355,6 @@ public Mono> createWithResponse(ShareDirectoryCreat Mono> createWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Map metadata, FilePropertySemantics filePropertySemantics, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "create"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -551,7 +522,6 @@ public Mono> deleteWithResponse() { } Mono> deleteWithResponse(Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "delete"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponseAsync(shareName, directoryPath, null, context); @@ -690,11 +660,6 @@ public Mono> getPropertiesWithResponse() { Mono> getPropertiesWithResponse(Context context) { context = context == null ? Context.NONE : context; - if (!fileId.isEmpty()) { - return azureFileStorageClient.getDirectories() - .getPropertiesByFileIdWithResponseAsync(shareName, fileId, snapshot, null, null, context) - .map(ModelHelper::mapShareDirectoryPropertiesResponse); - } return azureFileStorageClient.getDirectories() .getPropertiesWithResponseAsync(shareName, directoryPath, snapshot, null, context) .map(ModelHelper::mapShareDirectoryPropertiesResponse); @@ -804,7 +769,6 @@ public Mono> setPropertiesWithResponse(ShareDirecto Mono> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -905,7 +869,6 @@ public Mono> setMetadataWithResponse(Map Mono> setMetadataWithResponse(Map metadata, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .setMetadataWithResponseAsync(shareName, directoryPath, null, metadata, context) @@ -1013,7 +976,6 @@ public PagedFlux listFilesAndDirectories(ShareListFilesAndDirecto PagedFlux listFilesAndDirectoriesWithOptionalTimeout(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listFilesAndDirectories"); final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; @@ -1068,7 +1030,6 @@ public PagedFlux listHandles(Integer maxResultPerPage, boolean recur PagedFlux listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .listHandlesWithResponseAsync(shareName, directoryPath, marker, maxResultPerPage, null, snapshot, @@ -1141,7 +1102,6 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); return this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, handleId, null, null, snapshot, false, context) @@ -1185,7 +1145,6 @@ public Mono forceCloseAllHandles(boolean recursive) { } PagedFlux forceCloseAllHandlesWithTimeout(boolean recursive, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, "*", null, marker, snapshot, recursive, @@ -1267,7 +1226,6 @@ public Mono> renameWithResponse(ShareFileRen } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -2182,7 +2140,6 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 3cd97d5cb268b..db9c3079fd609 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -23,11 +23,11 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; -import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesForceCloseHandlesHeaders; +import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListHandlesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetMetadataHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetPropertiesHeaders; @@ -99,7 +99,6 @@ public class ShareDirectoryClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; - private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -118,17 +117,10 @@ public class ShareDirectoryClient { */ ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { - this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); - } - - ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, - String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, - AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; - this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -137,16 +129,9 @@ public class ShareDirectoryClient { StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); - if (fileId.isEmpty()) { - directoryUrlString.append("/").append(directoryPath); - } + directoryUrlString.append("/").append(directoryPath); if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - directoryUrlString.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - directoryUrlString.append("?fileid=").append(fileId); } this.directoryUrl = directoryUrlString.toString(); } @@ -160,15 +145,6 @@ public String getDirectoryUrl() { return this.directoryUrl; } - /** - * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. - * - * @return The file ID. - */ - public String getFileId() { - return fileId; - } - /** * Gets the service version the client is using. * @@ -188,7 +164,6 @@ public ShareServiceVersion getServiceVersion() { * @return a ShareFileClient that interacts with the specified share */ public ShareFileClient getFileClient(String fileName) { - ShareErrors.assertNotFileIdAddressed(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -209,7 +184,6 @@ public ShareFileClient getFileClient(String fileName) { * @return a ShareDirectoryClient that interacts with the specified directory */ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { - ShareErrors.assertNotFileIdAddressed(fileId, "getSubdirectoryClient"); boolean needPathDelimiter = !this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/"); String subDirectoryPath = this.directoryPath + (needPathDelimiter ? "/" : "") + subdirectoryName; return new ShareDirectoryClient(azureFileStorageClient, shareName, subDirectoryPath, snapshot, accountName, @@ -252,7 +226,6 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -367,7 +340,6 @@ public Response createWithResponse(FileSmbProperties smbProp @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareDirectoryCreateOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "create"); Context finalContext = context == null ? Context.NONE : context; ShareDirectoryCreateOptions finalOptions = options == null ? new ShareDirectoryCreateOptions() : options; @@ -520,7 +492,6 @@ public void delete() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponse(shareName, directoryPath, null, finalContext); @@ -650,11 +621,9 @@ public ShareDirectoryProperties getProperties() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { Context finalContext = context == null ? Context.NONE : context; - Callable> operation = fileId.isEmpty() - ? () -> this.azureFileStorageClient.getDirectories() - .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext) - : () -> this.azureFileStorageClient.getDirectories() - .getPropertiesByFileIdWithResponse(shareName, fileId, snapshot, null, null, finalContext); + Callable> operation + = () -> this.azureFileStorageClient.getDirectories() + .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext); return ModelHelper .mapShareDirectoryPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); @@ -753,7 +722,6 @@ public Response setPropertiesWithResponse(FileSmbProperties @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareDirectorySetPropertiesOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); Context finalContext = context == null ? Context.NONE : context; ShareDirectorySetPropertiesOptions finalOptions = options == null ? new ShareDirectorySetPropertiesOptions() : options; @@ -861,7 +829,6 @@ public ShareDirectorySetMetadataInfo setMetadata(Map metadata) { @ServiceMethod(returns = ReturnType.SINGLE) public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() @@ -972,7 +939,6 @@ public PagedIterable listFilesAndDirectories(String prefix, Integ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listFilesAndDirectories"); Context finalContext = context == null ? Context.NONE : context; final ShareListFilesAndDirectoriesOptions modifiedOptions @@ -1033,7 +999,6 @@ public PagedIterable listHandles(Integer maxResultsPerPage, boolean PagedIterable listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { Callable> operation @@ -1110,7 +1075,6 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -1154,7 +1118,6 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(boolean recursive, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { @@ -1241,7 +1204,6 @@ public ShareDirectoryClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; @@ -2077,7 +2039,6 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index 72b7f27a6f22d..9098e0d755ea2 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -228,11 +228,12 @@ private AzureFileStorageImpl constructImpl() { * @throws NullPointerException If {@code shareName} is {@code null} or {@code shareName} is {@code null}. * @throws IllegalArgumentException If neither a {@link StorageSharedKeyCredential} * or {@link #sasToken(String) SAS token} has been set. - * @throws IllegalStateException If multiple credentials have been specified. + * @throws IllegalStateException If multiple credentials have been specified, or a file ID is configured. */ public ShareDirectoryAsyncClient buildDirectoryAsyncClient() { + ShareErrors.assertNotFileIdAddressed(fileId, "buildDirectoryAsyncClient"); ShareServiceVersion serviceVersion = getServiceVersion(); - return new ShareDirectoryAsyncClient(constructImpl(), shareName, resourcePath, fileId, shareSnapshot, + return new ShareDirectoryAsyncClient(constructImpl(), shareName, resourcePath, shareSnapshot, accountName, serviceVersion, sasToken != null ? new AzureSasCredential(sasToken) : azureSasCredential); } @@ -250,11 +251,12 @@ public ShareDirectoryAsyncClient buildDirectoryAsyncClient() { * @throws NullPointerException If {@code endpoint}, {@code shareName} or {@code directoryPath} is {@code null}. * @throws IllegalArgumentException If neither a {@link StorageSharedKeyCredential} * or {@link #sasToken(String) SAS token} has been set. - * @throws IllegalStateException If multiple credentials have been specified. + * @throws IllegalStateException If multiple credentials have been specified, or a file ID is configured. */ public ShareDirectoryClient buildDirectoryClient() { + ShareErrors.assertNotFileIdAddressed(fileId, "buildDirectoryClient"); ShareServiceVersion serviceVersion = getServiceVersion(); - return new ShareDirectoryClient(constructImpl(), shareName, resourcePath, fileId, shareSnapshot, accountName, + return new ShareDirectoryClient(constructImpl(), shareName, resourcePath, shareSnapshot, accountName, serviceVersion, sasToken != null ? new AzureSasCredential(sasToken) : azureSasCredential); } @@ -379,12 +381,14 @@ public ShareFileClientBuilder shareName(String shareName) { } /** - * Sets the file ID used to address a file or directory. + * Sets the file ID used to address a file. * *

Setting a file ID clears the resource path. The file ID can also be read from the {@code fileid} query - * parameter when supplied in the endpoint.

+ * parameter when supplied in the endpoint. File IDs are supported only for file clients; building a directory + * client with a file ID configured throws {@link IllegalStateException}. Use {@link #resourcePath(String)} to + * clear the file ID and address a directory by path.

* - * @param fileId The file ID of the file or directory. + * @param fileId The file ID of the file. * @return the updated ShareFileClientBuilder object * @throws IllegalArgumentException If {@code fileId} is null or blank. */ diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java index 158fb7df90647..7dd95ad83c29a 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java @@ -34,12 +34,10 @@ public interface ShareDirectoryPropertiesAccessor { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. - * @param fileName The name of the directory when returned by a file-ID request. * @return A new instance of {@link ShareDirectoryProperties}. */ ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, - String fileName); + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties); } /** @@ -61,12 +59,11 @@ public static void setAccessor(ShareDirectoryPropertiesAccessor accessor) { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. - * @param fileName The name of the directory when returned by a file-ID request. * @return A new instance of {@link ShareDirectoryProperties}. */ public static ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, boolean isServerEncrypted, FileSmbProperties smbProperties, - FilePosixProperties posixProperties, String fileName) { + FilePosixProperties posixProperties) { // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the // application accesses ShareDirectoryProperties which triggers the accessor to be configured. So, if the accessor // is null this effectively pokes the class to set up the accessor. @@ -75,7 +72,6 @@ public static ShareDirectoryProperties create(Map metadata, Stri } assert accessor != null; - return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties, - fileName); + return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties); } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java deleted file mode 100644 index 1a53639818610..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoriesGetPropertiesByFileIdHeaders.java +++ /dev/null @@ -1,668 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.file.share.models.NfsFileType; -import java.time.OffsetDateTime; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The DirectoriesGetPropertiesByFileIdHeaders model. - */ -@Fluent -public final class DirectoriesGetPropertiesByFileIdHeaders { - /* - * The x-ms-meta- property. - */ - @Generated - private Map xMsMeta; - - /* - * The ETag property. - */ - @Generated - private String eTag; - - /* - * The Last-Modified property. - */ - @Generated - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-request-id property. - */ - @Generated - private String xMsRequestId; - - /* - * The x-ms-version property. - */ - @Generated - private String xMsVersion; - - /* - * The Date property. - */ - @Generated - private DateTimeRfc1123 date; - - /* - * The x-ms-server-encrypted property. - */ - @Generated - private Boolean xMsServerEncrypted; - - /* - * The x-ms-file-attributes property. - */ - @Generated - private String xMsFileAttributes; - - /* - * The x-ms-file-creation-time property. - */ - @Generated - private OffsetDateTime xMsFileCreationTime; - - /* - * The x-ms-file-last-write-time property. - */ - @Generated - private OffsetDateTime xMsFileLastWriteTime; - - /* - * The x-ms-file-change-time property. - */ - @Generated - private OffsetDateTime xMsFileChangeTime; - - /* - * The x-ms-file-permission-key property. - */ - @Generated - private String xMsFilePermissionKey; - - /* - * The x-ms-file-id property. - */ - @Generated - private String xMsFileId; - - /* - * The x-ms-file-name property. - */ - @Generated - private String xMsFileName; - - /* - * The x-ms-file-parent-id property. - */ - @Generated - private String xMsFileParentId; - - /* - * The x-ms-mode property. - */ - @Generated - private String xMsMode; - - /* - * The x-ms-owner property. - */ - @Generated - private String xMsOwner; - - /* - * The x-ms-group property. - */ - @Generated - private String xMsGroup; - - /* - * The x-ms-file-file-type property. - */ - @Generated - private NfsFileType xMsFileFileType; - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - - private static final HttpHeaderName X_MS_FILE_ATTRIBUTES = HttpHeaderName.fromString("x-ms-file-attributes"); - - private static final HttpHeaderName X_MS_FILE_CREATION_TIME = HttpHeaderName.fromString("x-ms-file-creation-time"); - - private static final HttpHeaderName X_MS_FILE_LAST_WRITE_TIME - = HttpHeaderName.fromString("x-ms-file-last-write-time"); - - private static final HttpHeaderName X_MS_FILE_CHANGE_TIME = HttpHeaderName.fromString("x-ms-file-change-time"); - - private static final HttpHeaderName X_MS_FILE_PERMISSION_KEY - = HttpHeaderName.fromString("x-ms-file-permission-key"); - - private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); - - private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); - - private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); - - private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); - - private static final HttpHeaderName X_MS_OWNER = HttpHeaderName.fromString("x-ms-owner"); - - private static final HttpHeaderName X_MS_GROUP = HttpHeaderName.fromString("x-ms-group"); - - private static final HttpHeaderName X_MS_FILE_FILE_TYPE = HttpHeaderName.fromString("x-ms-file-file-type"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of DirectoriesGetPropertiesByFileIdHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public DirectoriesGetPropertiesByFileIdHeaders(HttpHeaders rawHeaders) { - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } else { - this.lastModified = null; - } - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } else { - this.date = null; - } - String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); - if (xMsServerEncrypted != null) { - this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); - } else { - this.xMsServerEncrypted = null; - } - this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); - String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); - if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); - } else { - this.xMsFileCreationTime = null; - } - String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); - if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); - } else { - this.xMsFileLastWriteTime = null; - } - String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); - if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); - } else { - this.xMsFileChangeTime = null; - } - this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); - this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); - this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); - this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); - this.xMsMode = rawHeaders.getValue(X_MS_MODE); - this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); - this.xMsGroup = rawHeaders.getValue(X_MS_GROUP); - String xMsFileFileType = rawHeaders.getValue(X_MS_FILE_FILE_TYPE); - if (xMsFileFileType != null) { - this.xMsFileFileType = NfsFileType.fromString(xMsFileFileType); - } else { - this.xMsFileFileType = null; - } - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - - rawHeaders.stream().forEach(header -> { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - } - }); - this.xMsMeta = xMsMetaHeaderCollection; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - @Generated - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - @Generated - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - @Generated - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - @Generated - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - @Generated - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - @Generated - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @return the xMsServerEncrypted value. - */ - @Generated - public Boolean isXMsServerEncrypted() { - return this.xMsServerEncrypted; - } - - /** - * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @param xMsServerEncrypted the xMsServerEncrypted value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { - this.xMsServerEncrypted = xMsServerEncrypted; - return this; - } - - /** - * Get the xMsFileAttributes property: The x-ms-file-attributes property. - * - * @return the xMsFileAttributes value. - */ - @Generated - public String getXMsFileAttributes() { - return this.xMsFileAttributes; - } - - /** - * Set the xMsFileAttributes property: The x-ms-file-attributes property. - * - * @param xMsFileAttributes the xMsFileAttributes value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileAttributes(String xMsFileAttributes) { - this.xMsFileAttributes = xMsFileAttributes; - return this; - } - - /** - * Get the xMsFileCreationTime property: The x-ms-file-creation-time property. - * - * @return the xMsFileCreationTime value. - */ - @Generated - public OffsetDateTime getXMsFileCreationTime() { - return this.xMsFileCreationTime; - } - - /** - * Set the xMsFileCreationTime property: The x-ms-file-creation-time property. - * - * @param xMsFileCreationTime the xMsFileCreationTime value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - this.xMsFileCreationTime = xMsFileCreationTime; - return this; - } - - /** - * Get the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. - * - * @return the xMsFileLastWriteTime value. - */ - @Generated - public OffsetDateTime getXMsFileLastWriteTime() { - return this.xMsFileLastWriteTime; - } - - /** - * Set the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. - * - * @param xMsFileLastWriteTime the xMsFileLastWriteTime value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - this.xMsFileLastWriteTime = xMsFileLastWriteTime; - return this; - } - - /** - * Get the xMsFileChangeTime property: The x-ms-file-change-time property. - * - * @return the xMsFileChangeTime value. - */ - @Generated - public OffsetDateTime getXMsFileChangeTime() { - return this.xMsFileChangeTime; - } - - /** - * Set the xMsFileChangeTime property: The x-ms-file-change-time property. - * - * @param xMsFileChangeTime the xMsFileChangeTime value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - this.xMsFileChangeTime = xMsFileChangeTime; - return this; - } - - /** - * Get the xMsFilePermissionKey property: The x-ms-file-permission-key property. - * - * @return the xMsFilePermissionKey value. - */ - @Generated - public String getXMsFilePermissionKey() { - return this.xMsFilePermissionKey; - } - - /** - * Set the xMsFilePermissionKey property: The x-ms-file-permission-key property. - * - * @param xMsFilePermissionKey the xMsFilePermissionKey value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFilePermissionKey(String xMsFilePermissionKey) { - this.xMsFilePermissionKey = xMsFilePermissionKey; - return this; - } - - /** - * Get the xMsFileId property: The x-ms-file-id property. - * - * @return the xMsFileId value. - */ - @Generated - public String getXMsFileId() { - return this.xMsFileId; - } - - /** - * Set the xMsFileId property: The x-ms-file-id property. - * - * @param xMsFileId the xMsFileId value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileId(String xMsFileId) { - this.xMsFileId = xMsFileId; - return this; - } - - /** - * Get the xMsFileName property: The x-ms-file-name property. - * - * @return the xMsFileName value. - */ - @Generated - public String getXMsFileName() { - return this.xMsFileName; - } - - /** - * Set the xMsFileName property: The x-ms-file-name property. - * - * @param xMsFileName the xMsFileName value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileName(String xMsFileName) { - this.xMsFileName = xMsFileName; - return this; - } - - /** - * Get the xMsFileParentId property: The x-ms-file-parent-id property. - * - * @return the xMsFileParentId value. - */ - @Generated - public String getXMsFileParentId() { - return this.xMsFileParentId; - } - - /** - * Set the xMsFileParentId property: The x-ms-file-parent-id property. - * - * @param xMsFileParentId the xMsFileParentId value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileParentId(String xMsFileParentId) { - this.xMsFileParentId = xMsFileParentId; - return this; - } - - /** - * Get the xMsMode property: The x-ms-mode property. - * - * @return the xMsMode value. - */ - @Generated - public String getXMsMode() { - return this.xMsMode; - } - - /** - * Set the xMsMode property: The x-ms-mode property. - * - * @param xMsMode the xMsMode value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsMode(String xMsMode) { - this.xMsMode = xMsMode; - return this; - } - - /** - * Get the xMsOwner property: The x-ms-owner property. - * - * @return the xMsOwner value. - */ - @Generated - public String getXMsOwner() { - return this.xMsOwner; - } - - /** - * Set the xMsOwner property: The x-ms-owner property. - * - * @param xMsOwner the xMsOwner value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsOwner(String xMsOwner) { - this.xMsOwner = xMsOwner; - return this; - } - - /** - * Get the xMsGroup property: The x-ms-group property. - * - * @return the xMsGroup value. - */ - @Generated - public String getXMsGroup() { - return this.xMsGroup; - } - - /** - * Set the xMsGroup property: The x-ms-group property. - * - * @param xMsGroup the xMsGroup value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsGroup(String xMsGroup) { - this.xMsGroup = xMsGroup; - return this; - } - - /** - * Get the xMsFileFileType property: The x-ms-file-file-type property. - * - * @return the xMsFileFileType value. - */ - @Generated - public NfsFileType getXMsFileFileType() { - return this.xMsFileFileType; - } - - /** - * Set the xMsFileFileType property: The x-ms-file-file-type property. - * - * @param xMsFileFileType the xMsFileFileType value to set. - * @return the DirectoriesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public DirectoriesGetPropertiesByFileIdHeaders setXMsFileFileType(NfsFileType xMsFileFileType) { - this.xMsFileFileType = xMsFileFileType; - return this; - } -} 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 217cc8c0cc27c..8fe89d84b66cc 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 @@ -599,8 +599,9 @@ public static Response mapGetStatisticsResponse(Response(response, shareDirectoryInfo); } - public static Response mapShareDirectoryPropertiesResponse(Response response) { - DirectoriesGetPropertiesHeaders headers = new DirectoriesGetPropertiesHeaders(response.getHeaders()); + public static Response + mapShareDirectoryPropertiesResponse(ResponseBase response) { + DirectoriesGetPropertiesHeaders headers = response.getDeserializedHeaders(); Map metadata = headers.getXMsMeta(); String eTag = headers.getETag(); OffsetDateTime offsetDateTime = headers.getLastModified(); @@ -608,7 +609,7 @@ public static Response mapShareDirectoryPropertiesResp FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders()); FilePosixProperties posixProperties = FilePosixPropertiesHelper.create(response.getHeaders()); ShareDirectoryProperties shareDirectoryProperties = ShareDirectoryPropertiesHelper.create(metadata, eTag, - offsetDateTime, isServerEncrypted, smbProperties, posixProperties, headers.getXMsFileName()); + offsetDateTime, isServerEncrypted, smbProperties, posixProperties); return new SimpleResponse<>(response, shareDirectoryProperties); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java index 024a24a26193e..b6e5cdd0223f8 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java @@ -21,7 +21,6 @@ public final class ShareDirectoryProperties { private final boolean isServerEncrypted; private final FileSmbProperties smbProperties; private final FilePosixProperties posixProperties; - private final String fileName; /** * Creates an instance of properties information about a specific Directory. @@ -41,20 +40,17 @@ public ShareDirectoryProperties(Map metadata, String eTag, Offse this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = null; - this.fileName = null; } //Internal constructor to support FilePosixProperties class. private ShareDirectoryProperties(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, - String fileName) { + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties) { this.metadata = metadata; this.eTag = eTag; this.lastModified = lastModified; this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = posixProperties; - this.fileName = fileName; } static { @@ -118,12 +114,4 @@ public FilePosixProperties getPosixProperties() { return posixProperties; } - /** - * Gets the name of the directory returned by a request addressed by file ID. - * - * @return The directory name, or {@code null} when the service did not return it. - */ - public String getFileName() { - return fileName; - } } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 022b417b0a386..9672b3895092b 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -17,6 +17,7 @@ import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.Utility; import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.test.shared.extensions.LiveOnly; import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; @@ -123,8 +124,9 @@ public void getDirectoryUrl() { @DoNotRecord @Tag("file-id-mock") - @Test - public void directoryPropertiesByIdUseFileIdQueryAndMapFileName() { + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void directoryPropertiesUsePath(String path) { AtomicReference requestUrl = new AtomicReference<>(); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); @@ -137,77 +139,77 @@ public void directoryPropertiesByIdUseFileIdQueryAndMapFileName() { .serviceVersion(ShareServiceVersion.V2027_03_07) .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME); - ShareDirectoryClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + ShareDirectoryClient directoryClient = testShareClient.getSnapshotClient("snapshot").getDirectoryClient(path); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); - Assertions.assertEquals("", directoryClient.getDirectoryPath()); + Assertions.assertEquals(path, directoryClient.getDirectoryPath()); Assertions.assertEquals( - FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?sharesnapshot=snapshot", directoryClient.getDirectoryUrl()); ShareDirectoryProperties properties = directoryClient.getProperties(); - Assertions.assertEquals("directory", properties.getFileName()); Assertions.assertEquals("value", properties.getMetadata().get("key")); FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertTrue(requestUrl.get() - .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + Assertions.assertTrue(Utility.urlDecode(requestUrl.get()) + .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?")); + Assertions.assertTrue(requestUrl.get().contains("restype=directory")); + Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot")); + Assertions.assertFalse(requestUrl.get().contains("fileid=")); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", + directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); } @DoNotRecord @Tag("file-id-mock") - @Test - public void directoryClientBuilderSetsFileId() { - AtomicReference requestUrl = new AtomicReference<>(); + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void directoryClientBuilderRejectsFileId(boolean fromEndpoint) { + AtomicReference requestSent = new AtomicReference<>(false); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); }).build(); - ShareDirectoryClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildDirectoryClient(); - - Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); - Assertions.assertEquals("", directoryClient.getDirectoryPath()); - Assertions.assertEquals("directory", directoryClient.getProperties().getFileName()); - Assertions.assertTrue(requestUrl.get().contains("restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + .pipeline(pipeline); + if (fromEndpoint) { + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "/directory?fileid=" + FileIdTestHelper.FILE_ID); + } else { + builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); + } + IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, + builder::buildDirectoryClient); + Assertions.assertEquals("buildDirectoryClient is not supported for a file-ID-addressed client.", + exception.getMessage()); + Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileClient().getFileId()); + Assertions.assertFalse(requestSent.get()); } @DoNotRecord @Tag("file-id-mock") - @Test - public void directoryIdClientRejectsPathOperations() { - AtomicReference requestSent = new AtomicReference<>(false); + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void directoryClientBuilderClearsFileIdForPath(String path) { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestSent.set(true); - return Mono.just(new MockHttpResponse(request, 200)); + Assertions.assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, + Utility.urlDecode(request.getUrl().getPath())); + Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); }).build(); - - ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME); - ShareDirectoryClient directoryClient = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); - - Assertions.assertThrows(IllegalStateException.class, directoryClient::exists); - IllegalStateException createException - = Assertions.assertThrows(IllegalStateException.class, directoryClient::create); - Assertions.assertEquals("create is not supported for a file-ID-addressed client.", - createException.getMessage()); - Assertions.assertThrows(IllegalStateException.class, directoryClient::delete); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("file.txt")); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("directory")); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); - Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getDirectoryClientByFileId("")); - Assertions.assertThrows(IllegalArgumentException.class, () -> testShareClient.getDirectoryClientByFileId(null)); - Assertions.assertFalse(requestSent.get()); + .fileId(FileIdTestHelper.FILE_ID); + ShareDirectoryClient directoryClient = builder.resourcePath(path).buildDirectoryClient(); + Assertions.assertEquals(path, directoryClient.getDirectoryPath()); + FileIdTestHelper.assertSmbProperties(directoryClient.getProperties().getSmbProperties()); + String expectedUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path; + Assertions.assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); + Assertions.assertEquals(expectedUrl + (path.isEmpty() ? "" : "/") + "file.txt", + directoryClient.getFileClient("file.txt").getFileUrl()); + Assertions.assertEquals(expectedUrl, + builder.fileId(FileIdTestHelper.FILE_ID).endpoint(expectedUrl).buildDirectoryClient().getDirectoryUrl()); } @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index a0266792f1bf7..2f40c3ac7bd6e 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -13,6 +13,7 @@ import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; +import com.azure.storage.common.Utility; import com.azure.storage.common.test.shared.extensions.LiveOnly; import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; import com.azure.storage.file.share.models.FilePropertySemantics; @@ -44,6 +45,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -111,8 +113,9 @@ public void getDirectoryURL() { @DoNotRecord @Tag("file-id-mock") - @Test - public void asyncDirectoryPropertiesByIdUseFileIdQueryAndMapFileName() { + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void asyncDirectoryPropertiesUsePath(String path) { AtomicReference requestUrl = new AtomicReference<>(); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); @@ -125,72 +128,78 @@ public void asyncDirectoryPropertiesByIdUseFileIdQueryAndMapFileName() { .serviceVersion(ShareServiceVersion.V2027_03_07) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareDirectoryProperties properties - = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); + ShareDirectoryAsyncClient directoryClient + = testShareClient.getSnapshotClient("snapshot").getDirectoryClient(path); + Assertions.assertEquals(path, directoryClient.getDirectoryPath()); + Assertions.assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?sharesnapshot=snapshot", + directoryClient.getDirectoryUrl()); + ShareDirectoryProperties properties = directoryClient.getProperties().block(); - Assertions.assertEquals("directory", properties.getFileName()); Assertions.assertEquals("value", properties.getMetadata().get("key")); FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + Assertions.assertTrue(Utility.urlDecode(requestUrl.get()) + .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?")); Assertions.assertTrue(requestUrl.get().contains("restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot")); + Assertions.assertFalse(requestUrl.get().contains("fileid=")); + Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", + directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); } @DoNotRecord @Tag("file-id-mock") - @Test - public void asyncDirectoryClientBuilderSetsFileId() { - AtomicReference requestUrl = new AtomicReference<>(); + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncDirectoryClientBuilderRejectsFileId(boolean fromEndpoint) { + AtomicReference requestSent = new AtomicReference<>(false); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); }).build(); - ShareDirectoryAsyncClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildDirectoryAsyncClient(); - ShareDirectoryProperties properties = directoryClient.getProperties().block(); - - Assertions.assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); - Assertions.assertEquals("", directoryClient.getDirectoryPath()); - Assertions.assertEquals("directory", properties.getFileName()); - Assertions.assertTrue(requestUrl.get().contains("restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + .pipeline(pipeline); + if (fromEndpoint) { + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "/directory?fileid=" + FileIdTestHelper.FILE_ID); + } else { + builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); + } + IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, + builder::buildDirectoryAsyncClient); + Assertions.assertEquals("buildDirectoryAsyncClient is not supported for a file-ID-addressed client.", + exception.getMessage()); + Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileAsyncClient().getFileId()); + Assertions.assertFalse(requestSent.get()); } @DoNotRecord @Tag("file-id-mock") - @Test - public void asyncDirectoryIdClientRejectsPathOperations() { - AtomicReference requestSent = new AtomicReference<>(false); + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void asyncDirectoryClientBuilderClearsFileIdForPath(String path) { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestSent.set(true); - return Mono.just(new MockHttpResponse(request, 200)); + Assertions.assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, + Utility.urlDecode(request.getUrl().getPath())); + Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); }).build(); - - ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildAsyncClient() - .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareDirectoryAsyncClient directoryClient - = testShareClient.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); - - IllegalStateException createException - = Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.create().block()); - Assertions.assertEquals("create is not supported for a file-ID-addressed client.", - createException.getMessage()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.delete().block()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.exists().block()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null).block()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination").block()); - Assertions.assertThrows(IllegalStateException.class, - () -> directoryClient.listFilesAndDirectories().blockFirst()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseAllHandles(false).block()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); - Assertions.assertFalse(requestSent.get()); + .fileId(FileIdTestHelper.FILE_ID); + ShareDirectoryAsyncClient directoryClient = builder.resourcePath(path).buildDirectoryAsyncClient(); + Assertions.assertEquals(path, directoryClient.getDirectoryPath()); + FileIdTestHelper.assertSmbProperties(directoryClient.getProperties().block().getSmbProperties()); + String expectedUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path; + Assertions.assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); + Assertions.assertEquals(expectedUrl + (path.isEmpty() ? "" : "/") + "file.txt", + directoryClient.getFileClient("file.txt").getFileUrl()); + Assertions.assertEquals(expectedUrl, + builder.fileId(FileIdTestHelper.FILE_ID).endpoint(expectedUrl).buildDirectoryAsyncClient().getDirectoryUrl()); } @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index 3ed788738f61e..d2135f665060a 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -255,9 +255,8 @@ public void fileLinksMapPropertiesAndDecodeLinkNames() { @DoNotRecord @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void propertiesByIdMapServiceErrors(boolean directory) { + @Test + public void propertiesByIdMapServiceErrors() { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); ShareClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) @@ -265,13 +264,8 @@ public void propertiesByIdMapServiceErrors(boolean directory) { .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME); - ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, () -> { - if (directory) { - client.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties(); - } else { - client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties(); - } - }); + ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, + () -> client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties()); Assertions.assertEquals(404, exception.getStatusCode()); Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index cebab4614ae03..2176ba36a0aab 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -250,9 +250,8 @@ public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { @DoNotRecord @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void asyncPropertiesByIdMapServiceErrors(boolean directory) { + @Test + public void asyncPropertiesByIdMapServiceErrors() { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); ShareAsyncClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) @@ -260,13 +259,8 @@ public void asyncPropertiesByIdMapServiceErrors(boolean directory) { .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, () -> { - if (directory) { - client.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); - } else { - client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); - } - }); + ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, + () -> client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block()); Assertions.assertEquals(404, exception.getStatusCode()); Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); } From 45e563d7cab3c7339cafdcbf654dcdb62cc0faf3 Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:02:03 -0400 Subject: [PATCH 09/39] Regenerate File Share with explicit timestamp overrides --- .../share/implementation/DirectoriesImpl.java | 36 +++++++-------- .../file/share/implementation/FilesImpl.java | 36 +++++++-------- .../models/FilesGetHardLinksHeaders.java | 45 +++++-------------- 3 files changed, 48 insertions(+), 69 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java index efdd0c8e5414b..c84952a0d73e2 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java @@ -2865,7 +2865,7 @@ public Response listHandlesNoCustomHeadersWithResponse(Stri * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2898,7 +2898,7 @@ public Mono> forceCloseH * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2935,7 +2935,7 @@ public Mono> forceCloseH * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2966,7 +2966,7 @@ public Mono forceCloseHandlesAsync(String shareName, String directory, Str * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -2998,7 +2998,7 @@ public Mono forceCloseHandlesAsync(String shareName, String directory, Str * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3030,7 +3030,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3066,7 +3066,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3105,7 +3105,7 @@ public ResponseBase forceCloseHandles * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3134,7 +3134,7 @@ public void forceCloseHandles(String shareName, String directory, String handleI * * @param shareName The name of the target share. * @param directory The path of the target directory. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -3179,7 +3179,7 @@ public Response forceCloseHandlesNoCustomHeadersWithResponse(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3229,7 +3229,7 @@ public Mono> renameWithResponseAsyn * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3316,7 +3316,7 @@ public Mono> renameWithResponseAsyn * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3366,7 +3366,7 @@ public Mono renameAsync(String shareName, String directory, String renameS * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3418,7 +3418,7 @@ public Mono renameAsync(String shareName, String directory, String renameS * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3468,7 +3468,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3555,7 +3555,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3644,7 +3644,7 @@ public ResponseBase renameWithResponse(String sh * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -3691,7 +3691,7 @@ public void rename(String shareName, String directory, String renameSource, Inte * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index b4689a572e257..cf86bd6ea5e96 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -8754,7 +8754,7 @@ public Response listHandlesNoCustomHeadersWithResponse(Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8784,7 +8784,7 @@ public Mono> forceCloseHandles * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8818,7 +8818,7 @@ public Mono> forceCloseHandles * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8847,7 +8847,7 @@ public Mono forceCloseHandlesAsync(String shareName, String fileName, Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8877,7 +8877,7 @@ public Mono forceCloseHandlesAsync(String shareName, String fileName, Stri * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8907,7 +8907,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8941,7 +8941,7 @@ public Mono> forceCloseHandlesNoCustomHeadersWithResponseAsync(St * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -8977,7 +8977,7 @@ public ResponseBase forceCloseHandlesWithRe * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -9003,7 +9003,7 @@ public void forceCloseHandles(String shareName, String fileName, String handleId * * @param shareName The name of the target share. * @param fileName The path of the target file. - * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (�*�) is a wildcard + * @param handleId Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard * that specifies all handles. * @param timeout The timeout parameter is expressed in seconds. For more information, see <a * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting @@ -9046,7 +9046,7 @@ public Response forceCloseHandlesNoCustomHeadersWithResponse(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9097,7 +9097,7 @@ public Mono> renameWithResponseAsync(Stri * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9189,7 +9189,7 @@ public Mono> renameWithResponseAsync(Stri * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9241,7 +9241,7 @@ public Mono renameAsync(String shareName, String fileName, String renameSo * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9294,7 +9294,7 @@ public Mono renameAsync(String shareName, String fileName, String renameSo * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9345,7 +9345,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9437,7 +9437,7 @@ public Mono> renameNoCustomHeadersWithResponseAsync(String shareN * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9531,7 +9531,7 @@ public ResponseBase renameWithResponse(String shareNam * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the @@ -9579,7 +9579,7 @@ public void rename(String shareName, String fileName, String renameSource, Integ * @param replaceIfExists Optional. A boolean value for if the destination file already exists, whether this request * will overwrite the file or not. If true, the rename will succeed and will overwrite the destination file. If not * provided or if false and the destination file does exist, the request will not overwrite the destination file. If - * provided and the destination file doesn�t exist, the rename will succeed. Note: This value does not override the + * provided and the destination file doesn’t exist, the rename will succeed. Note: This value does not override the * x-ms-file-copy-ignore-read-only header value. * @param ignoreReadOnly Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting * destination file should be respected. If true, the rename will succeed, otherwise, a previous file at the diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java index 0e73849e3cde7..dd9919d5906a7 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetHardLinksHeaders.java @@ -143,19 +143,19 @@ public final class FilesGetHardLinksHeaders { * The x-ms-file-creation-time property. */ @Generated - private DateTimeRfc1123 xMsFileCreationTime; + private OffsetDateTime xMsFileCreationTime; /* * The x-ms-file-last-write-time property. */ @Generated - private DateTimeRfc1123 xMsFileLastWriteTime; + private OffsetDateTime xMsFileLastWriteTime; /* * The x-ms-file-change-time property. */ @Generated - private DateTimeRfc1123 xMsFileChangeTime; + private OffsetDateTime xMsFileChangeTime; /* * The x-ms-file-permission-key property. @@ -379,19 +379,19 @@ public FilesGetHardLinksHeaders(HttpHeaders rawHeaders) { this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); + this.xMsFileCreationTime = OffsetDateTime.parse(xMsFileCreationTime); } else { this.xMsFileCreationTime = null; } String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); + this.xMsFileLastWriteTime = OffsetDateTime.parse(xMsFileLastWriteTime); } else { this.xMsFileLastWriteTime = null; } String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); + this.xMsFileChangeTime = OffsetDateTime.parse(xMsFileChangeTime); } else { this.xMsFileChangeTime = null; } @@ -891,10 +891,7 @@ public FilesGetHardLinksHeaders setXMsFileAttributes(String xMsFileAttributes) { */ @Generated public OffsetDateTime getXMsFileCreationTime() { - if (this.xMsFileCreationTime == null) { - return null; - } - return this.xMsFileCreationTime.getDateTime(); + return this.xMsFileCreationTime; } /** @@ -905,11 +902,7 @@ public OffsetDateTime getXMsFileCreationTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - if (xMsFileCreationTime == null) { - this.xMsFileCreationTime = null; - } else { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); - } + this.xMsFileCreationTime = xMsFileCreationTime; return this; } @@ -920,10 +913,7 @@ public FilesGetHardLinksHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCre */ @Generated public OffsetDateTime getXMsFileLastWriteTime() { - if (this.xMsFileLastWriteTime == null) { - return null; - } - return this.xMsFileLastWriteTime.getDateTime(); + return this.xMsFileLastWriteTime; } /** @@ -934,11 +924,7 @@ public OffsetDateTime getXMsFileLastWriteTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - if (xMsFileLastWriteTime == null) { - this.xMsFileLastWriteTime = null; - } else { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); - } + this.xMsFileLastWriteTime = xMsFileLastWriteTime; return this; } @@ -949,10 +935,7 @@ public FilesGetHardLinksHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLa */ @Generated public OffsetDateTime getXMsFileChangeTime() { - if (this.xMsFileChangeTime == null) { - return null; - } - return this.xMsFileChangeTime.getDateTime(); + return this.xMsFileChangeTime; } /** @@ -963,11 +946,7 @@ public OffsetDateTime getXMsFileChangeTime() { */ @Generated public FilesGetHardLinksHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - if (xMsFileChangeTime == null) { - this.xMsFileChangeTime = null; - } else { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); - } + this.xMsFileChangeTime = xMsFileChangeTime; return this; } From cece0159626b7cc340a67b4d1d8637faaabb4501 Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:02:24 -0400 Subject: [PATCH 10/39] Reuse file property headers for ID-based requests --- .../storage/file/share/ShareFileClient.java | 3 +- .../file/share/implementation/FilesImpl.java | 16 +- .../FilesGetPropertiesByFileIdHeaders.java | 1288 ----------------- .../implementation/util/ModelHelper.java | 6 +- .../main/java/ShareStorageCustomization.java | 30 + 5 files changed, 42 insertions(+), 1301 deletions(-) delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index ad2b62a8a7d02..a96a5bdb0df3c 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -41,6 +41,7 @@ import com.azure.storage.file.share.implementation.models.FilesCreateSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; +import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; import com.azure.storage.file.share.implementation.models.HardLinkList; @@ -1576,7 +1577,7 @@ public Response getPropertiesWithResponse(ShareRequestCondi Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; - Callable> operation = fileId.isEmpty() + Callable> operation = fileId.isEmpty() ? () -> this.azureFileStorageClient.getFiles() .getPropertiesWithResponse(shareName, filePath, snapshot, null, finalRequestConditions.getLeaseId(), finalContext) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index cf86bd6ea5e96..a3e66ebf1ae0c 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -39,7 +39,6 @@ import com.azure.storage.file.share.implementation.models.FilesDownloadHeaders; import com.azure.storage.file.share.implementation.models.FilesForceCloseHandlesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetHardLinksHeaders; -import com.azure.storage.file.share.implementation.models.FilesGetPropertiesByFileIdHeaders; import com.azure.storage.file.share.implementation.models.FilesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.FilesGetRangeListHeaders; import com.azure.storage.file.share.implementation.models.FilesGetSymbolicLinkHeaders; @@ -158,7 +157,7 @@ Response getHardLinksNoCustomHeadersSync(@HostParam("url") String @Head("/{shareName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - Mono> getPropertiesByFileId(@HostParam("url") String url, + Mono> getPropertiesByFileId(@HostParam("url") String url, @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @@ -182,7 +181,7 @@ Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") Stri @Head("/{shareName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) - ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, + ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, @PathParam("shareName") String shareName, @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @@ -1907,8 +1906,8 @@ public Response getHardLinksNoCustomHeadersWithResponse(String sha * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { + public Mono> getPropertiesByFileIdWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId) { return FluxUtil .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, leaseId, context)) @@ -1936,9 +1935,8 @@ public Mono> getProperties * @return the {@link ResponseBase} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getPropertiesByFileIdWithResponseAsync( - String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, - Context context) { + public Mono> getPropertiesByFileIdWithResponseAsync(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { final String accept = "application/xml"; return service .getPropertiesByFileId(this.client.getUrl(), shareName, fileId, sharesnapshot, timeout, @@ -2082,7 +2080,7 @@ public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsyn * @return the {@link ResponseBase}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseBase getPropertiesByFileIdWithResponse(String shareName, + public ResponseBase getPropertiesByFileIdWithResponse(String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, String leaseId, Context context) { try { final String accept = "application/xml"; diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java deleted file mode 100644 index 1d928b52b3b5f..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesGetPropertiesByFileIdHeaders.java +++ /dev/null @@ -1,1288 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.DateTimeRfc1123; -import com.azure.storage.file.share.models.CopyStatusType; -import com.azure.storage.file.share.models.LeaseDurationType; -import com.azure.storage.file.share.models.LeaseStateType; -import com.azure.storage.file.share.models.LeaseStatusType; -import com.azure.storage.file.share.models.NfsFileType; -import java.time.OffsetDateTime; -import java.util.Base64; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * The FilesGetPropertiesByFileIdHeaders model. - */ -@Fluent -public final class FilesGetPropertiesByFileIdHeaders { - /* - * The Last-Modified property. - */ - @Generated - private DateTimeRfc1123 lastModified; - - /* - * The x-ms-meta- property. - */ - @Generated - private Map xMsMeta; - - /* - * The x-ms-type property. - */ - @Generated - private String xMsType = "File"; - - /* - * The Content-Length property. - */ - @Generated - private Long contentLength; - - /* - * The Content-Type property. - */ - @Generated - private String contentType; - - /* - * The ETag property. - */ - @Generated - private String eTag; - - /* - * The Content-MD5 property. - */ - @Generated - private byte[] contentMD5; - - /* - * The Content-Encoding property. - */ - @Generated - private String contentEncoding; - - /* - * The Cache-Control property. - */ - @Generated - private String cacheControl; - - /* - * The Content-Disposition property. - */ - @Generated - private String contentDisposition; - - /* - * The Content-Language property. - */ - @Generated - private String contentLanguage; - - /* - * The x-ms-request-id property. - */ - @Generated - private String xMsRequestId; - - /* - * The x-ms-version property. - */ - @Generated - private String xMsVersion; - - /* - * The Date property. - */ - @Generated - private DateTimeRfc1123 date; - - /* - * The x-ms-copy-completion-time property. - */ - @Generated - private DateTimeRfc1123 xMsCopyCompletionTime; - - /* - * The x-ms-copy-status-description property. - */ - @Generated - private String xMsCopyStatusDescription; - - /* - * The x-ms-copy-id property. - */ - @Generated - private String xMsCopyId; - - /* - * The x-ms-copy-progress property. - */ - @Generated - private String xMsCopyProgress; - - /* - * The x-ms-copy-source property. - */ - @Generated - private String xMsCopySource; - - /* - * The x-ms-copy-status property. - */ - @Generated - private CopyStatusType xMsCopyStatus; - - /* - * The x-ms-server-encrypted property. - */ - @Generated - private Boolean xMsServerEncrypted; - - /* - * The x-ms-file-attributes property. - */ - @Generated - private String xMsFileAttributes; - - /* - * The x-ms-file-creation-time property. - */ - @Generated - private DateTimeRfc1123 xMsFileCreationTime; - - /* - * The x-ms-file-last-write-time property. - */ - @Generated - private DateTimeRfc1123 xMsFileLastWriteTime; - - /* - * The x-ms-file-change-time property. - */ - @Generated - private DateTimeRfc1123 xMsFileChangeTime; - - /* - * The x-ms-file-permission-key property. - */ - @Generated - private String xMsFilePermissionKey; - - /* - * The x-ms-file-id property. - */ - @Generated - private String xMsFileId; - - /* - * The x-ms-file-name property. - */ - @Generated - private String xMsFileName; - - /* - * The x-ms-file-parent-id property. - */ - @Generated - private String xMsFileParentId; - - /* - * The x-ms-lease-duration property. - */ - @Generated - private LeaseDurationType xMsLeaseDuration; - - /* - * The x-ms-lease-state property. - */ - @Generated - private LeaseStateType xMsLeaseState; - - /* - * The x-ms-lease-status property. - */ - @Generated - private LeaseStatusType xMsLeaseStatus; - - /* - * The x-ms-mode property. - */ - @Generated - private String xMsMode; - - /* - * The x-ms-owner property. - */ - @Generated - private String xMsOwner; - - /* - * The x-ms-group property. - */ - @Generated - private String xMsGroup; - - /* - * The x-ms-link-count property. - */ - @Generated - private Long xMsLinkCount; - - /* - * The x-ms-file-file-type property. - */ - @Generated - private NfsFileType xMsFileFileType; - - private static final HttpHeaderName X_MS_TYPE = HttpHeaderName.fromString("x-ms-type"); - - private static final HttpHeaderName X_MS_VERSION = HttpHeaderName.fromString("x-ms-version"); - - private static final HttpHeaderName X_MS_COPY_COMPLETION_TIME - = HttpHeaderName.fromString("x-ms-copy-completion-time"); - - private static final HttpHeaderName X_MS_COPY_STATUS_DESCRIPTION - = HttpHeaderName.fromString("x-ms-copy-status-description"); - - private static final HttpHeaderName X_MS_COPY_ID = HttpHeaderName.fromString("x-ms-copy-id"); - - private static final HttpHeaderName X_MS_COPY_PROGRESS = HttpHeaderName.fromString("x-ms-copy-progress"); - - private static final HttpHeaderName X_MS_COPY_SOURCE = HttpHeaderName.fromString("x-ms-copy-source"); - - private static final HttpHeaderName X_MS_COPY_STATUS = HttpHeaderName.fromString("x-ms-copy-status"); - - private static final HttpHeaderName X_MS_SERVER_ENCRYPTED = HttpHeaderName.fromString("x-ms-server-encrypted"); - - private static final HttpHeaderName X_MS_FILE_ATTRIBUTES = HttpHeaderName.fromString("x-ms-file-attributes"); - - private static final HttpHeaderName X_MS_FILE_CREATION_TIME = HttpHeaderName.fromString("x-ms-file-creation-time"); - - private static final HttpHeaderName X_MS_FILE_LAST_WRITE_TIME - = HttpHeaderName.fromString("x-ms-file-last-write-time"); - - private static final HttpHeaderName X_MS_FILE_CHANGE_TIME = HttpHeaderName.fromString("x-ms-file-change-time"); - - private static final HttpHeaderName X_MS_FILE_PERMISSION_KEY - = HttpHeaderName.fromString("x-ms-file-permission-key"); - - private static final HttpHeaderName X_MS_FILE_ID = HttpHeaderName.fromString("x-ms-file-id"); - - private static final HttpHeaderName X_MS_FILE_NAME = HttpHeaderName.fromString("x-ms-file-name"); - - private static final HttpHeaderName X_MS_FILE_PARENT_ID = HttpHeaderName.fromString("x-ms-file-parent-id"); - - private static final HttpHeaderName X_MS_LEASE_DURATION = HttpHeaderName.fromString("x-ms-lease-duration"); - - private static final HttpHeaderName X_MS_LEASE_STATE = HttpHeaderName.fromString("x-ms-lease-state"); - - private static final HttpHeaderName X_MS_LEASE_STATUS = HttpHeaderName.fromString("x-ms-lease-status"); - - private static final HttpHeaderName X_MS_MODE = HttpHeaderName.fromString("x-ms-mode"); - - private static final HttpHeaderName X_MS_OWNER = HttpHeaderName.fromString("x-ms-owner"); - - private static final HttpHeaderName X_MS_GROUP = HttpHeaderName.fromString("x-ms-group"); - - private static final HttpHeaderName X_MS_LINK_COUNT = HttpHeaderName.fromString("x-ms-link-count"); - - private static final HttpHeaderName X_MS_FILE_FILE_TYPE = HttpHeaderName.fromString("x-ms-file-file-type"); - - // HttpHeaders containing the raw property values. - /** - * Creates an instance of FilesGetPropertiesByFileIdHeaders class. - * - * @param rawHeaders The raw HttpHeaders that will be used to create the property values. - */ - public FilesGetPropertiesByFileIdHeaders(HttpHeaders rawHeaders) { - String lastModified = rawHeaders.getValue(HttpHeaderName.LAST_MODIFIED); - if (lastModified != null) { - this.lastModified = new DateTimeRfc1123(lastModified); - } else { - this.lastModified = null; - } - this.xMsType = rawHeaders.getValue(X_MS_TYPE); - String contentLength = rawHeaders.getValue(HttpHeaderName.CONTENT_LENGTH); - if (contentLength != null) { - this.contentLength = Long.parseLong(contentLength); - } else { - this.contentLength = null; - } - this.contentType = rawHeaders.getValue(HttpHeaderName.CONTENT_TYPE); - this.eTag = rawHeaders.getValue(HttpHeaderName.ETAG); - String contentMD5 = rawHeaders.getValue(HttpHeaderName.CONTENT_MD5); - if (contentMD5 != null) { - this.contentMD5 = Base64.getDecoder().decode(contentMD5); - } else { - this.contentMD5 = null; - } - this.contentEncoding = rawHeaders.getValue(HttpHeaderName.CONTENT_ENCODING); - this.cacheControl = rawHeaders.getValue(HttpHeaderName.CACHE_CONTROL); - this.contentDisposition = rawHeaders.getValue(HttpHeaderName.CONTENT_DISPOSITION); - this.contentLanguage = rawHeaders.getValue(HttpHeaderName.CONTENT_LANGUAGE); - this.xMsRequestId = rawHeaders.getValue(HttpHeaderName.X_MS_REQUEST_ID); - this.xMsVersion = rawHeaders.getValue(X_MS_VERSION); - String date = rawHeaders.getValue(HttpHeaderName.DATE); - if (date != null) { - this.date = new DateTimeRfc1123(date); - } else { - this.date = null; - } - String xMsCopyCompletionTime = rawHeaders.getValue(X_MS_COPY_COMPLETION_TIME); - if (xMsCopyCompletionTime != null) { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } else { - this.xMsCopyCompletionTime = null; - } - this.xMsCopyStatusDescription = rawHeaders.getValue(X_MS_COPY_STATUS_DESCRIPTION); - this.xMsCopyId = rawHeaders.getValue(X_MS_COPY_ID); - this.xMsCopyProgress = rawHeaders.getValue(X_MS_COPY_PROGRESS); - this.xMsCopySource = rawHeaders.getValue(X_MS_COPY_SOURCE); - String xMsCopyStatus = rawHeaders.getValue(X_MS_COPY_STATUS); - if (xMsCopyStatus != null) { - this.xMsCopyStatus = CopyStatusType.fromString(xMsCopyStatus); - } else { - this.xMsCopyStatus = null; - } - String xMsServerEncrypted = rawHeaders.getValue(X_MS_SERVER_ENCRYPTED); - if (xMsServerEncrypted != null) { - this.xMsServerEncrypted = Boolean.parseBoolean(xMsServerEncrypted); - } else { - this.xMsServerEncrypted = null; - } - this.xMsFileAttributes = rawHeaders.getValue(X_MS_FILE_ATTRIBUTES); - String xMsFileCreationTime = rawHeaders.getValue(X_MS_FILE_CREATION_TIME); - if (xMsFileCreationTime != null) { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); - } else { - this.xMsFileCreationTime = null; - } - String xMsFileLastWriteTime = rawHeaders.getValue(X_MS_FILE_LAST_WRITE_TIME); - if (xMsFileLastWriteTime != null) { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); - } else { - this.xMsFileLastWriteTime = null; - } - String xMsFileChangeTime = rawHeaders.getValue(X_MS_FILE_CHANGE_TIME); - if (xMsFileChangeTime != null) { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); - } else { - this.xMsFileChangeTime = null; - } - this.xMsFilePermissionKey = rawHeaders.getValue(X_MS_FILE_PERMISSION_KEY); - this.xMsFileId = rawHeaders.getValue(X_MS_FILE_ID); - this.xMsFileName = rawHeaders.getValue(X_MS_FILE_NAME); - this.xMsFileParentId = rawHeaders.getValue(X_MS_FILE_PARENT_ID); - String xMsLeaseDuration = rawHeaders.getValue(X_MS_LEASE_DURATION); - if (xMsLeaseDuration != null) { - this.xMsLeaseDuration = LeaseDurationType.fromString(xMsLeaseDuration); - } else { - this.xMsLeaseDuration = null; - } - String xMsLeaseState = rawHeaders.getValue(X_MS_LEASE_STATE); - if (xMsLeaseState != null) { - this.xMsLeaseState = LeaseStateType.fromString(xMsLeaseState); - } else { - this.xMsLeaseState = null; - } - String xMsLeaseStatus = rawHeaders.getValue(X_MS_LEASE_STATUS); - if (xMsLeaseStatus != null) { - this.xMsLeaseStatus = LeaseStatusType.fromString(xMsLeaseStatus); - } else { - this.xMsLeaseStatus = null; - } - this.xMsMode = rawHeaders.getValue(X_MS_MODE); - this.xMsOwner = rawHeaders.getValue(X_MS_OWNER); - this.xMsGroup = rawHeaders.getValue(X_MS_GROUP); - String xMsLinkCount = rawHeaders.getValue(X_MS_LINK_COUNT); - if (xMsLinkCount != null) { - this.xMsLinkCount = Long.parseLong(xMsLinkCount); - } else { - this.xMsLinkCount = null; - } - String xMsFileFileType = rawHeaders.getValue(X_MS_FILE_FILE_TYPE); - if (xMsFileFileType != null) { - this.xMsFileFileType = NfsFileType.fromString(xMsFileFileType); - } else { - this.xMsFileFileType = null; - } - Map xMsMetaHeaderCollection = new LinkedHashMap<>(); - - rawHeaders.stream().forEach(header -> { - String headerName = header.getName(); - if (headerName.startsWith("x-ms-meta-")) { - xMsMetaHeaderCollection.put(headerName.substring(10), header.getValue()); - } - }); - this.xMsMeta = xMsMetaHeaderCollection; - } - - /** - * Get the lastModified property: The Last-Modified property. - * - * @return the lastModified value. - */ - @Generated - public OffsetDateTime getLastModified() { - if (this.lastModified == null) { - return null; - } - return this.lastModified.getDateTime(); - } - - /** - * Set the lastModified property: The Last-Modified property. - * - * @param lastModified the lastModified value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setLastModified(OffsetDateTime lastModified) { - if (lastModified == null) { - this.lastModified = null; - } else { - this.lastModified = new DateTimeRfc1123(lastModified); - } - return this; - } - - /** - * Get the xMsMeta property: The x-ms-meta- property. - * - * @return the xMsMeta value. - */ - @Generated - public Map getXMsMeta() { - return this.xMsMeta; - } - - /** - * Set the xMsMeta property: The x-ms-meta- property. - * - * @param xMsMeta the xMsMeta value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsMeta(Map xMsMeta) { - this.xMsMeta = xMsMeta; - return this; - } - - /** - * Get the xMsType property: The x-ms-type property. - * - * @return the xMsType value. - */ - @Generated - public String getXMsType() { - return this.xMsType; - } - - /** - * Set the xMsType property: The x-ms-type property. - * - * @param xMsType the xMsType value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsType(String xMsType) { - this.xMsType = xMsType; - return this; - } - - /** - * Get the contentLength property: The Content-Length property. - * - * @return the contentLength value. - */ - @Generated - public Long getContentLength() { - return this.contentLength; - } - - /** - * Set the contentLength property: The Content-Length property. - * - * @param contentLength the contentLength value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - /** - * Get the contentType property: The Content-Type property. - * - * @return the contentType value. - */ - @Generated - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The Content-Type property. - * - * @param contentType the contentType value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the eTag property: The ETag property. - * - * @return the eTag value. - */ - @Generated - public String getETag() { - return this.eTag; - } - - /** - * Set the eTag property: The ETag property. - * - * @param eTag the eTag value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setETag(String eTag) { - this.eTag = eTag; - return this; - } - - /** - * Get the contentMD5 property: The Content-MD5 property. - * - * @return the contentMD5 value. - */ - @Generated - public byte[] getContentMD5() { - return CoreUtils.clone(this.contentMD5); - } - - /** - * Set the contentMD5 property: The Content-MD5 property. - * - * @param contentMD5 the contentMD5 value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentMD5(byte[] contentMD5) { - this.contentMD5 = CoreUtils.clone(contentMD5); - return this; - } - - /** - * Get the contentEncoding property: The Content-Encoding property. - * - * @return the contentEncoding value. - */ - @Generated - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * Set the contentEncoding property: The Content-Encoding property. - * - * @param contentEncoding the contentEncoding value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - /** - * Get the cacheControl property: The Cache-Control property. - * - * @return the cacheControl value. - */ - @Generated - public String getCacheControl() { - return this.cacheControl; - } - - /** - * Set the cacheControl property: The Cache-Control property. - * - * @param cacheControl the cacheControl value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - /** - * Get the contentDisposition property: The Content-Disposition property. - * - * @return the contentDisposition value. - */ - @Generated - public String getContentDisposition() { - return this.contentDisposition; - } - - /** - * Set the contentDisposition property: The Content-Disposition property. - * - * @param contentDisposition the contentDisposition value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentDisposition(String contentDisposition) { - this.contentDisposition = contentDisposition; - return this; - } - - /** - * Get the contentLanguage property: The Content-Language property. - * - * @return the contentLanguage value. - */ - @Generated - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * Set the contentLanguage property: The Content-Language property. - * - * @param contentLanguage the contentLanguage value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - /** - * Get the xMsRequestId property: The x-ms-request-id property. - * - * @return the xMsRequestId value. - */ - @Generated - public String getXMsRequestId() { - return this.xMsRequestId; - } - - /** - * Set the xMsRequestId property: The x-ms-request-id property. - * - * @param xMsRequestId the xMsRequestId value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsRequestId(String xMsRequestId) { - this.xMsRequestId = xMsRequestId; - return this; - } - - /** - * Get the xMsVersion property: The x-ms-version property. - * - * @return the xMsVersion value. - */ - @Generated - public String getXMsVersion() { - return this.xMsVersion; - } - - /** - * Set the xMsVersion property: The x-ms-version property. - * - * @param xMsVersion the xMsVersion value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsVersion(String xMsVersion) { - this.xMsVersion = xMsVersion; - return this; - } - - /** - * Get the date property: The Date property. - * - * @return the date value. - */ - @Generated - public OffsetDateTime getDate() { - if (this.date == null) { - return null; - } - return this.date.getDateTime(); - } - - /** - * Set the date property: The Date property. - * - * @param date the date value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setDate(OffsetDateTime date) { - if (date == null) { - this.date = null; - } else { - this.date = new DateTimeRfc1123(date); - } - return this; - } - - /** - * Get the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @return the xMsCopyCompletionTime value. - */ - @Generated - public OffsetDateTime getXMsCopyCompletionTime() { - if (this.xMsCopyCompletionTime == null) { - return null; - } - return this.xMsCopyCompletionTime.getDateTime(); - } - - /** - * Set the xMsCopyCompletionTime property: The x-ms-copy-completion-time property. - * - * @param xMsCopyCompletionTime the xMsCopyCompletionTime value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopyCompletionTime(OffsetDateTime xMsCopyCompletionTime) { - if (xMsCopyCompletionTime == null) { - this.xMsCopyCompletionTime = null; - } else { - this.xMsCopyCompletionTime = new DateTimeRfc1123(xMsCopyCompletionTime); - } - return this; - } - - /** - * Get the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @return the xMsCopyStatusDescription value. - */ - @Generated - public String getXMsCopyStatusDescription() { - return this.xMsCopyStatusDescription; - } - - /** - * Set the xMsCopyStatusDescription property: The x-ms-copy-status-description property. - * - * @param xMsCopyStatusDescription the xMsCopyStatusDescription value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopyStatusDescription(String xMsCopyStatusDescription) { - this.xMsCopyStatusDescription = xMsCopyStatusDescription; - return this; - } - - /** - * Get the xMsCopyId property: The x-ms-copy-id property. - * - * @return the xMsCopyId value. - */ - @Generated - public String getXMsCopyId() { - return this.xMsCopyId; - } - - /** - * Set the xMsCopyId property: The x-ms-copy-id property. - * - * @param xMsCopyId the xMsCopyId value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopyId(String xMsCopyId) { - this.xMsCopyId = xMsCopyId; - return this; - } - - /** - * Get the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @return the xMsCopyProgress value. - */ - @Generated - public String getXMsCopyProgress() { - return this.xMsCopyProgress; - } - - /** - * Set the xMsCopyProgress property: The x-ms-copy-progress property. - * - * @param xMsCopyProgress the xMsCopyProgress value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopyProgress(String xMsCopyProgress) { - this.xMsCopyProgress = xMsCopyProgress; - return this; - } - - /** - * Get the xMsCopySource property: The x-ms-copy-source property. - * - * @return the xMsCopySource value. - */ - @Generated - public String getXMsCopySource() { - return this.xMsCopySource; - } - - /** - * Set the xMsCopySource property: The x-ms-copy-source property. - * - * @param xMsCopySource the xMsCopySource value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopySource(String xMsCopySource) { - this.xMsCopySource = xMsCopySource; - return this; - } - - /** - * Get the xMsCopyStatus property: The x-ms-copy-status property. - * - * @return the xMsCopyStatus value. - */ - @Generated - public CopyStatusType getXMsCopyStatus() { - return this.xMsCopyStatus; - } - - /** - * Set the xMsCopyStatus property: The x-ms-copy-status property. - * - * @param xMsCopyStatus the xMsCopyStatus value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsCopyStatus(CopyStatusType xMsCopyStatus) { - this.xMsCopyStatus = xMsCopyStatus; - return this; - } - - /** - * Get the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @return the xMsServerEncrypted value. - */ - @Generated - public Boolean isXMsServerEncrypted() { - return this.xMsServerEncrypted; - } - - /** - * Set the xMsServerEncrypted property: The x-ms-server-encrypted property. - * - * @param xMsServerEncrypted the xMsServerEncrypted value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsServerEncrypted(Boolean xMsServerEncrypted) { - this.xMsServerEncrypted = xMsServerEncrypted; - return this; - } - - /** - * Get the xMsFileAttributes property: The x-ms-file-attributes property. - * - * @return the xMsFileAttributes value. - */ - @Generated - public String getXMsFileAttributes() { - return this.xMsFileAttributes; - } - - /** - * Set the xMsFileAttributes property: The x-ms-file-attributes property. - * - * @param xMsFileAttributes the xMsFileAttributes value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileAttributes(String xMsFileAttributes) { - this.xMsFileAttributes = xMsFileAttributes; - return this; - } - - /** - * Get the xMsFileCreationTime property: The x-ms-file-creation-time property. - * - * @return the xMsFileCreationTime value. - */ - @Generated - public OffsetDateTime getXMsFileCreationTime() { - if (this.xMsFileCreationTime == null) { - return null; - } - return this.xMsFileCreationTime.getDateTime(); - } - - /** - * Set the xMsFileCreationTime property: The x-ms-file-creation-time property. - * - * @param xMsFileCreationTime the xMsFileCreationTime value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileCreationTime(OffsetDateTime xMsFileCreationTime) { - if (xMsFileCreationTime == null) { - this.xMsFileCreationTime = null; - } else { - this.xMsFileCreationTime = new DateTimeRfc1123(xMsFileCreationTime); - } - return this; - } - - /** - * Get the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. - * - * @return the xMsFileLastWriteTime value. - */ - @Generated - public OffsetDateTime getXMsFileLastWriteTime() { - if (this.xMsFileLastWriteTime == null) { - return null; - } - return this.xMsFileLastWriteTime.getDateTime(); - } - - /** - * Set the xMsFileLastWriteTime property: The x-ms-file-last-write-time property. - * - * @param xMsFileLastWriteTime the xMsFileLastWriteTime value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileLastWriteTime(OffsetDateTime xMsFileLastWriteTime) { - if (xMsFileLastWriteTime == null) { - this.xMsFileLastWriteTime = null; - } else { - this.xMsFileLastWriteTime = new DateTimeRfc1123(xMsFileLastWriteTime); - } - return this; - } - - /** - * Get the xMsFileChangeTime property: The x-ms-file-change-time property. - * - * @return the xMsFileChangeTime value. - */ - @Generated - public OffsetDateTime getXMsFileChangeTime() { - if (this.xMsFileChangeTime == null) { - return null; - } - return this.xMsFileChangeTime.getDateTime(); - } - - /** - * Set the xMsFileChangeTime property: The x-ms-file-change-time property. - * - * @param xMsFileChangeTime the xMsFileChangeTime value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileChangeTime(OffsetDateTime xMsFileChangeTime) { - if (xMsFileChangeTime == null) { - this.xMsFileChangeTime = null; - } else { - this.xMsFileChangeTime = new DateTimeRfc1123(xMsFileChangeTime); - } - return this; - } - - /** - * Get the xMsFilePermissionKey property: The x-ms-file-permission-key property. - * - * @return the xMsFilePermissionKey value. - */ - @Generated - public String getXMsFilePermissionKey() { - return this.xMsFilePermissionKey; - } - - /** - * Set the xMsFilePermissionKey property: The x-ms-file-permission-key property. - * - * @param xMsFilePermissionKey the xMsFilePermissionKey value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFilePermissionKey(String xMsFilePermissionKey) { - this.xMsFilePermissionKey = xMsFilePermissionKey; - return this; - } - - /** - * Get the xMsFileId property: The x-ms-file-id property. - * - * @return the xMsFileId value. - */ - @Generated - public String getXMsFileId() { - return this.xMsFileId; - } - - /** - * Set the xMsFileId property: The x-ms-file-id property. - * - * @param xMsFileId the xMsFileId value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileId(String xMsFileId) { - this.xMsFileId = xMsFileId; - return this; - } - - /** - * Get the xMsFileName property: The x-ms-file-name property. - * - * @return the xMsFileName value. - */ - @Generated - public String getXMsFileName() { - return this.xMsFileName; - } - - /** - * Set the xMsFileName property: The x-ms-file-name property. - * - * @param xMsFileName the xMsFileName value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileName(String xMsFileName) { - this.xMsFileName = xMsFileName; - return this; - } - - /** - * Get the xMsFileParentId property: The x-ms-file-parent-id property. - * - * @return the xMsFileParentId value. - */ - @Generated - public String getXMsFileParentId() { - return this.xMsFileParentId; - } - - /** - * Set the xMsFileParentId property: The x-ms-file-parent-id property. - * - * @param xMsFileParentId the xMsFileParentId value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileParentId(String xMsFileParentId) { - this.xMsFileParentId = xMsFileParentId; - return this; - } - - /** - * Get the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @return the xMsLeaseDuration value. - */ - @Generated - public LeaseDurationType getXMsLeaseDuration() { - return this.xMsLeaseDuration; - } - - /** - * Set the xMsLeaseDuration property: The x-ms-lease-duration property. - * - * @param xMsLeaseDuration the xMsLeaseDuration value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsLeaseDuration(LeaseDurationType xMsLeaseDuration) { - this.xMsLeaseDuration = xMsLeaseDuration; - return this; - } - - /** - * Get the xMsLeaseState property: The x-ms-lease-state property. - * - * @return the xMsLeaseState value. - */ - @Generated - public LeaseStateType getXMsLeaseState() { - return this.xMsLeaseState; - } - - /** - * Set the xMsLeaseState property: The x-ms-lease-state property. - * - * @param xMsLeaseState the xMsLeaseState value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsLeaseState(LeaseStateType xMsLeaseState) { - this.xMsLeaseState = xMsLeaseState; - return this; - } - - /** - * Get the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @return the xMsLeaseStatus value. - */ - @Generated - public LeaseStatusType getXMsLeaseStatus() { - return this.xMsLeaseStatus; - } - - /** - * Set the xMsLeaseStatus property: The x-ms-lease-status property. - * - * @param xMsLeaseStatus the xMsLeaseStatus value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsLeaseStatus(LeaseStatusType xMsLeaseStatus) { - this.xMsLeaseStatus = xMsLeaseStatus; - return this; - } - - /** - * Get the xMsMode property: The x-ms-mode property. - * - * @return the xMsMode value. - */ - @Generated - public String getXMsMode() { - return this.xMsMode; - } - - /** - * Set the xMsMode property: The x-ms-mode property. - * - * @param xMsMode the xMsMode value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsMode(String xMsMode) { - this.xMsMode = xMsMode; - return this; - } - - /** - * Get the xMsOwner property: The x-ms-owner property. - * - * @return the xMsOwner value. - */ - @Generated - public String getXMsOwner() { - return this.xMsOwner; - } - - /** - * Set the xMsOwner property: The x-ms-owner property. - * - * @param xMsOwner the xMsOwner value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsOwner(String xMsOwner) { - this.xMsOwner = xMsOwner; - return this; - } - - /** - * Get the xMsGroup property: The x-ms-group property. - * - * @return the xMsGroup value. - */ - @Generated - public String getXMsGroup() { - return this.xMsGroup; - } - - /** - * Set the xMsGroup property: The x-ms-group property. - * - * @param xMsGroup the xMsGroup value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsGroup(String xMsGroup) { - this.xMsGroup = xMsGroup; - return this; - } - - /** - * Get the xMsLinkCount property: The x-ms-link-count property. - * - * @return the xMsLinkCount value. - */ - @Generated - public Long getXMsLinkCount() { - return this.xMsLinkCount; - } - - /** - * Set the xMsLinkCount property: The x-ms-link-count property. - * - * @param xMsLinkCount the xMsLinkCount value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsLinkCount(Long xMsLinkCount) { - this.xMsLinkCount = xMsLinkCount; - return this; - } - - /** - * Get the xMsFileFileType property: The x-ms-file-file-type property. - * - * @return the xMsFileFileType value. - */ - @Generated - public NfsFileType getXMsFileFileType() { - return this.xMsFileFileType; - } - - /** - * Set the xMsFileFileType property: The x-ms-file-file-type property. - * - * @param xMsFileFileType the xMsFileFileType value to set. - * @return the FilesGetPropertiesByFileIdHeaders object itself. - */ - @Generated - public FilesGetPropertiesByFileIdHeaders setXMsFileFileType(NfsFileType xMsFileFileType) { - this.xMsFileFileType = xMsFileFileType; - return this; - } -} 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 8fe89d84b66cc..8679ea08928cd 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 @@ -408,9 +408,9 @@ public static Response createFileInfoResponse(ResponseBase(response, shareFileInfo); } - public static Response getPropertiesResponse(final Response response) { - // Path and file-ID operations return the same headers using different generated model types. - FilesGetPropertiesHeaders headers = new FilesGetPropertiesHeaders(response.getHeaders()); + public static Response + getPropertiesResponse(final ResponseBase response) { + FilesGetPropertiesHeaders headers = response.getDeserializedHeaders(); String eTag = headers.getETag(); OffsetDateTime lastModified = headers.getLastModified(); Map metadata = headers.getXMsMeta(); diff --git a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java index e106aa49f0684..a416e0b0a5b1b 100644 --- a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java +++ b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java @@ -2,6 +2,7 @@ // Licensed under the MIT License. import com.azure.autorest.customization.Customization; +import com.azure.autorest.customization.Editor; import com.azure.autorest.customization.LibraryCustomization; import com.azure.autorest.customization.PackageCustomization; import com.github.javaparser.ParseProblemException; @@ -41,6 +42,35 @@ public void customize(LibraryCustomization customization, Logger logger) { + "@see ShareFileItem#getFileType()"))); updateImplToMapInternalException(customization.getPackage("com.azure.storage.file.share.implementation")); + reusePropertyHeaders(customization.getRawEditor(), "Files"); + } + + private static void reusePropertyHeaders(Editor editor, String operationGroup) { + String implementationPath = "src/main/java/com/azure/storage/file/share/implementation/"; + String headersName = operationGroup + "GetPropertiesHeaders"; + String fileIdHeadersName = operationGroup + "GetPropertiesByFileIdHeaders"; + String headersPath = implementationPath + "models/" + headersName + ".java"; + String fileIdHeadersPath = implementationPath + "models/" + fileIdHeadersName + ".java"; + String clientPath = implementationPath + operationGroup + "Impl.java"; + String headers = editor.getFileContent(headersPath); + String fileIdHeaders = editor.getFileContent(fileIdHeadersPath); + String client = editor.getFileContent(clientPath); + if (headers == null || fileIdHeaders == null || client == null) { + throw new IllegalStateException("Missing generated sources for " + operationGroup + " property headers."); + } + + // Compare the entire model, including parsing, before discarding the operation-specific copy. + if (!headers.replace("\r\n", "\n") + .equals(fileIdHeaders.replace(fileIdHeadersName, headersName).replace("\r\n", "\n"))) { + throw new IllegalStateException(fileIdHeadersName + " differs from " + headersName + + ". Review the response headers before reusing the existing model."); + } + if (!client.contains(fileIdHeadersName)) { + throw new IllegalStateException(clientPath + " no longer references " + fileIdHeadersName + "."); + } + + editor.replaceFile(clientPath, client.replace(fileIdHeadersName, headersName)); + editor.removeFile(fileIdHeadersPath); } /** From 17331cbcc9b793482cd855f7be993d469ce1f38d Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:18:18 -0400 Subject: [PATCH 11/39] remove cosmetic change in ModelHelper --- .../file/share/implementation/util/ModelHelper.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 8679ea08928cd..f5cf3277ea3a5 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 @@ -601,11 +601,10 @@ public static Response mapGetStatisticsResponse(Response mapShareDirectoryPropertiesResponse(ResponseBase response) { - DirectoriesGetPropertiesHeaders headers = response.getDeserializedHeaders(); - Map metadata = headers.getXMsMeta(); - String eTag = headers.getETag(); - OffsetDateTime offsetDateTime = headers.getLastModified(); - boolean isServerEncrypted = headers.isXMsServerEncrypted(); + Map metadata = response.getDeserializedHeaders().getXMsMeta(); + String eTag = response.getDeserializedHeaders().getETag(); + OffsetDateTime offsetDateTime = response.getDeserializedHeaders().getLastModified(); + boolean isServerEncrypted = response.getDeserializedHeaders().isXMsServerEncrypted(); FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders()); FilePosixProperties posixProperties = FilePosixPropertiesHelper.create(response.getHeaders()); ShareDirectoryProperties shareDirectoryProperties = ShareDirectoryPropertiesHelper.create(metadata, eTag, From 18a4e9182329684d553d262c43eb17f78c74b2ec Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:42:32 -0400 Subject: [PATCH 12/39] remove change for utf8 encoding for quotes --- .../share/implementation/DirectoriesImpl.java | 72 +++++++------- .../file/share/implementation/FilesImpl.java | 96 +++++++++---------- .../swagger/README.md | 9 -- 3 files changed, 84 insertions(+), 93 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java index c84952a0d73e2..f166775a06c68 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java @@ -653,8 +653,8 @@ Response renameNoCustomHeadersSync(@HostParam("url") String url, @PathPara * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -702,8 +702,8 @@ public Mono> createWithResponseAsyn * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -755,8 +755,8 @@ public Mono> createWithResponseAsyn * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -803,8 +803,8 @@ public Mono createAsync(String shareName, String directory, Integer timeou * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -852,8 +852,8 @@ public Mono createAsync(String shareName, String directory, Integer timeou * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -901,8 +901,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -955,8 +955,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1011,8 +1011,8 @@ public ResponseBase createWithResponse(String sh * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1056,8 +1056,8 @@ public void create(String shareName, String directory, Integer timeout, Map deleteNoCustomHeadersWithResponse(String shareName, String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1598,8 +1598,8 @@ public Mono> setPropertiesWi * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1647,8 +1647,8 @@ public Mono> setPropertiesWi * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1690,8 +1690,8 @@ public Mono setPropertiesAsync(String shareName, String directory, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1734,8 +1734,8 @@ public Mono setPropertiesAsync(String shareName, String directory, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1778,8 +1778,8 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync(String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1827,8 +1827,8 @@ public Mono> setPropertiesNoCustomHeadersWithResponseAsync(String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1878,8 +1878,8 @@ public ResponseBase setPropertiesWithResp * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -1919,8 +1919,8 @@ public void setProperties(String shareName, String directory, Integer timeout, S * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index a3e66ebf1ae0c..27f4bd0670274 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -2170,8 +2170,8 @@ public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String sh * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2238,8 +2238,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2344,8 +2344,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2410,8 +2410,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2478,8 +2478,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2546,8 +2546,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2652,8 +2652,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2720,8 +2720,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2826,8 +2826,8 @@ public Mono> createWithResponseAsync(Stri * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2892,8 +2892,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -2960,8 +2960,8 @@ public Mono createAsync(String shareName, String fileName, long fileConten * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3028,8 +3028,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3134,8 +3134,8 @@ public Mono> createNoCustomHeadersWithResponseAsync(String shareN * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3242,8 +3242,8 @@ public ResponseBase createWithResponse(String shareNam * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -3306,8 +3306,8 @@ public void create(String shareName, String fileName, long fileContentLength, In * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4139,8 +4139,8 @@ public Response deleteNoCustomHeadersWithResponse(String shareName, String * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4188,8 +4188,8 @@ public Mono> setHttpHeadersWithRe * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4273,8 +4273,8 @@ public Mono> setHttpHeadersWithRe * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4321,8 +4321,8 @@ public Mono setHttpHeadersAsync(String shareName, String fileName, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4370,8 +4370,8 @@ public Mono setHttpHeadersAsync(String shareName, String fileName, Integer * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4420,8 +4420,8 @@ public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(Strin * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4506,8 +4506,8 @@ public Mono> setHttpHeadersNoCustomHeadersWithResponseAsync(Strin * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4594,8 +4594,8 @@ public ResponseBase setHttpHeadersWithResponse * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. @@ -4639,8 +4639,8 @@ public void setHttpHeaders(String shareName, String fileName, Integer timeout, L * permission. * @param filePermissionKey Key of the permission to be set for the directory/file. Note: Only one of the * x-ms-file-permission or x-ms-file-permission-key should be specified. - * @param fileAttributes If specified, the provided file attributes shall be set. Default value: 'Archive' for file - * and 'Directory' for directory. 'None' can also be specified as default. + * @param fileAttributes If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file + * and ‘Directory’ for directory. ‘None’ can also be specified as default. * @param fileCreationTime Creation time for the file/directory. Default value: Now. * @param fileLastWriteTime Last write time for the file/directory. Default value: Now. * @param fileChangeTime Change time for the file/directory. Default value: Now. diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 51976378c9ee0..744becc454830 100644 --- a/sdk/storage/azure-storage-file-share/swagger/README.md +++ b/sdk/storage/azure-storage-file-share/swagger/README.md @@ -126,15 +126,6 @@ directive: op.get.responses["200"].headers["x-ms-file-change-time"].format = "date-time"; ``` -### Keep file attribute documentation ASCII -``` yaml -directive: -- from: swagger-document - where: $.parameters.FileAttributes - transform: > - $.description = $.description.replace(/[\u2018\u2019]/g, "'"); -``` - ### /{shareName}/{directory}?restype=directory&comp=rename ``` yaml directive: From 483de3d0314ec3e83eab2de6dff5f297ae4e861d Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 16:47:37 -0400 Subject: [PATCH 13/39] spotless apply --- .../file/share/ShareDirectoryAsyncClient.java | 3 +-- .../file/share/ShareFileClientBuilder.java | 4 ++-- .../models/ShareDirectoryProperties.java | 1 - .../storage/file/share/DirectoryApiTests.java | 8 +++---- .../file/share/DirectoryAsyncApiTests.java | 13 +++++++---- .../storage/file/share/FileShareTestBase.java | 23 ++++++++----------- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index c37ab6d97f017..3c87b2749cbc7 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -123,8 +123,7 @@ public class ShareDirectoryAsyncClient { ShareDirectoryAsyncClient(ShareDirectoryAsyncClient directoryAsyncClient) { this(directoryAsyncClient.azureFileStorageClient, directoryAsyncClient.shareName, Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.snapshot, - directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, - directoryAsyncClient.sasToken); + directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, directoryAsyncClient.sasToken); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index 9098e0d755ea2..3e7c63e7a5fc7 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -233,8 +233,8 @@ private AzureFileStorageImpl constructImpl() { public ShareDirectoryAsyncClient buildDirectoryAsyncClient() { ShareErrors.assertNotFileIdAddressed(fileId, "buildDirectoryAsyncClient"); ShareServiceVersion serviceVersion = getServiceVersion(); - return new ShareDirectoryAsyncClient(constructImpl(), shareName, resourcePath, shareSnapshot, - accountName, serviceVersion, sasToken != null ? new AzureSasCredential(sasToken) : azureSasCredential); + return new ShareDirectoryAsyncClient(constructImpl(), shareName, resourcePath, shareSnapshot, accountName, + serviceVersion, sasToken != null ? new AzureSasCredential(sasToken) : azureSasCredential); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java index b6e5cdd0223f8..b70915b269370 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java @@ -113,5 +113,4 @@ public FileSmbProperties getSmbProperties() { public FilePosixProperties getPosixProperties() { return posixProperties; } - } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 9672b3895092b..aec882df83ab3 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -173,13 +173,13 @@ public void directoryClientBuilderRejectsFileId(boolean fromEndpoint) { .shareName(FileIdTestHelper.SHARE_NAME) .pipeline(pipeline); if (fromEndpoint) { - builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "/directory?fileid=" + FileIdTestHelper.FILE_ID); + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" + + FileIdTestHelper.FILE_ID); } else { builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); } - IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, - builder::buildDirectoryClient); + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryClient); Assertions.assertEquals("buildDirectoryClient is not supported for a file-ID-addressed client.", exception.getMessage()); Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileClient().getFileId()); diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 2f40c3ac7bd6e..df518515674c7 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -163,13 +163,13 @@ public void asyncDirectoryClientBuilderRejectsFileId(boolean fromEndpoint) { .shareName(FileIdTestHelper.SHARE_NAME) .pipeline(pipeline); if (fromEndpoint) { - builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "/directory?fileid=" + FileIdTestHelper.FILE_ID); + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" + + FileIdTestHelper.FILE_ID); } else { builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); } - IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, - builder::buildDirectoryAsyncClient); + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryAsyncClient); Assertions.assertEquals("buildDirectoryAsyncClient is not supported for a file-ID-addressed client.", exception.getMessage()); Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileAsyncClient().getFileId()); @@ -199,7 +199,10 @@ public void asyncDirectoryClientBuilderClearsFileIdForPath(String path) { Assertions.assertEquals(expectedUrl + (path.isEmpty() ? "" : "/") + "file.txt", directoryClient.getFileClient("file.txt").getFileUrl()); Assertions.assertEquals(expectedUrl, - builder.fileId(FileIdTestHelper.FILE_ID).endpoint(expectedUrl).buildDirectoryAsyncClient().getDirectoryUrl()); + builder.fileId(FileIdTestHelper.FILE_ID) + .endpoint(expectedUrl) + .buildDirectoryAsyncClient() + .getDirectoryUrl()); } @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java index e2dabe2911861..d2e3bb701d34d 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareTestBase.java @@ -96,10 +96,8 @@ public void beforeTest() { if (getTestMode() != TestMode.LIVE) { interceptorManager.addSanitizers(Arrays.asList( new TestProxySanitizer("sig=(.*)", "REDACTED", TestProxySanitizerType.URL), - new TestProxySanitizer("x-ms-file-rename-source", ".*", "REDACTED", - TestProxySanitizerType.HEADER), - new TestProxySanitizer("x-ms-copy-source", "sig=(.*)", "REDACTED", - TestProxySanitizerType.HEADER), + new TestProxySanitizer("x-ms-file-rename-source", ".*", "REDACTED", TestProxySanitizerType.HEADER), + new TestProxySanitizer("x-ms-copy-source", "sig=(.*)", "REDACTED", TestProxySanitizerType.HEADER), new TestProxySanitizer("x-ms-copy-source-authorization", ".*", "REDACTED", TestProxySanitizerType.HEADER), new TestProxySanitizer("x-ms-file-rename-source-authorization", ".*", "REDACTED", @@ -110,15 +108,14 @@ public void beforeTest() { // Ignore changes to the order of query parameters and wholly ignore the 'sv' (service version) query // parameter in SAS tokens. - interceptorManager - .addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false) - .setHeadersKeyOnlyMatch(Arrays.asList("x-ms-lease-id", "x-ms-proposed-lease-id", "If-Modified-Since", - "If-Unmodified-Since", "x-ms-expiry-time", "x-ms-source-if-modified-since", "x-ms-copy-source", - "x-ms-file-rename-source", "x-ms-source-if-unmodified-since", "x-ms-source-lease-id", - "x-ms-encryption-key-sha256")) - .setQueryOrderingIgnored(true) - .setIgnoredQueryParameters(Arrays.asList("sv")) - .setExcludedHeaders(Collections.singletonList("x-ms-meta-testmetadata")))); + interceptorManager.addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false) + .setHeadersKeyOnlyMatch(Arrays.asList("x-ms-lease-id", "x-ms-proposed-lease-id", "If-Modified-Since", + "If-Unmodified-Since", "x-ms-expiry-time", "x-ms-source-if-modified-since", "x-ms-copy-source", + "x-ms-file-rename-source", "x-ms-source-if-unmodified-since", "x-ms-source-lease-id", + "x-ms-encryption-key-sha256")) + .setQueryOrderingIgnored(true) + .setIgnoredQueryParameters(Arrays.asList("sv")) + .setExcludedHeaders(Collections.singletonList("x-ms-meta-testmetadata")))); ShareServiceClientBuilder builder = getServiceClientBuilder(ENVIRONMENT.getPrimaryAccount()); primaryFileServiceClient = builder.buildClient(); From c12ff916a7364f99c5d00d0569ecb48f4fcdea0e Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 18:07:37 -0400 Subject: [PATCH 14/39] add live tests --- .../storage/file/share/FileApiTests.java | 175 ++++-------------- .../storage/file/share/FileAsyncApiTests.java | 73 +++----- 2 files changed, 62 insertions(+), 186 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index d2135f665060a..5a4df8ae4a5bb 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -148,10 +148,13 @@ // It is still necessary to test deprecated APIs. @SuppressWarnings("deprecation") class FileApiTests extends FileShareTestBase { + private static final String FILE_ID_TEST_CONTENT = "file-id properties"; + private ShareFileClient primaryFileClient; private ShareClient shareClient; private String shareName; private String filePath; + private String fileId; private static Map testMetadata; private static ShareFileHttpHeaders httpHeaders; private FileSmbProperties smbProperties; @@ -172,6 +175,14 @@ public void setup(TestInfo testInfo) { testMetadata = Collections.singletonMap("testmetadata", "value"); httpHeaders = new ShareFileHttpHeaders().setContentLanguage("en").setContentType("application/octet-stream"); smbProperties = new FileSmbProperties().setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.NORMAL)); + + if (testInfo.getTags().contains("file-id-integration")) { + byte[] content = FILE_ID_TEST_CONTENT.getBytes(StandardCharsets.UTF_8); + primaryFileClient.create(content.length); + primaryFileClient.upload(new ByteArrayInputStream(content), content.length); + fileId = primaryFileClient.getProperties().getSmbProperties().getFileId(); + assertNotNull(fileId); + } } @Test @@ -185,39 +196,23 @@ public void getFileURL() { assertEquals(expectURL, fileURL); } - @DoNotRecord - @Tag("file-id-mock") + @Tag("file-id-integration") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test - public void filePropertiesByIdUseFileIdQueryAndMapFileName() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - - ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME); - ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + public void filePropertiesById() { + ShareFileClient factoryClient = shareClient.getFileClientByFileId(fileId); + ShareFileClient builderClient = instrument(new ShareFileClientBuilder()) + .connectionString(ENVIRONMENT.getPrimaryAccount().getConnectionString()) + .shareName(shareName) + .fileId(fileId) + .buildFileClient(); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); - Assertions.assertEquals("", fileClient.getFilePath()); - Assertions.assertEquals( - FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, - fileClient.getFileUrl()); - ShareFileProperties properties = fileClient.getProperties(); - Assertions.assertEquals("file.txt", properties.getFileName()); - Assertions.assertEquals(1024, properties.getContentLength()); - Assertions.assertEquals("en", properties.getContentLanguage()); - Assertions.assertEquals("gzip", properties.getContentEncoding()); - Assertions.assertEquals("value", properties.getMetadata().get("key")); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertEquals( - FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, - requestUrl.get()); + for (ShareFileClient fileIdClient : Arrays.asList(factoryClient, builderClient)) { + ShareFileProperties properties = fileIdClient.getProperties(); + assertEquals(filePath, properties.getFileName()); + assertEquals(FILE_ID_TEST_CONTENT.length(), properties.getContentLength()); + assertEquals(fileId, properties.getSmbProperties().getFileId()); + } } @DoNotRecord @@ -335,132 +330,34 @@ public void fileIdClientsRejectPathOperations() { @Tag("file-id-mock") @Test public void fileClientBuilderParsesFileIdFromEndpointQuery() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - ShareFileClient fileClient = new ShareFileClientBuilder() .endpoint( FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) .buildFileClient(); Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); - Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); + Assertions.assertEquals("", fileClient.getFilePath()); Assertions.assertEquals( FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, - requestUrl.get()); - - ShareFileClient pathClient = new ShareFileClientBuilder() - .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/file.txt") - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildFileClient(); - Assertions.assertEquals("", pathClient.getFileId()); - } - - @DoNotRecord - @Tag("file-id-mock") - @Test - public void fileClientBuilderSetsFileId() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); + fileClient.getFileUrl()); - ShareFileClient fileClient = new ShareFileClientBuilder() - .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/previous/path") + ShareFileClient configuredFileIdClient = new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) .buildFileClient(); + Assertions.assertEquals(FileIdTestHelper.FILE_ID, configuredFileIdClient.getFileId()); + Assertions.assertEquals("", configuredFileIdClient.getFilePath()); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); - Assertions.assertEquals("", fileClient.getFilePath()); - Assertions.assertEquals("file.txt", fileClient.getProperties().getFileName()); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); - - ShareFileClient pathClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .resourcePath("path/file.txt") - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildFileClient(); + ShareFileClient pathClient + = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + "/file.txt").buildFileClient(); Assertions.assertEquals("", pathClient.getFileId()); - Assertions.assertEquals("path/file.txt", pathClient.getFilePath()); + Assertions.assertEquals("file.txt", pathClient.getFilePath()); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(" ")); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(null)); } - @DoNotRecord - @Tag("file-id-mock") - @Test - public void fileClientBuilderParsesFileIdAndSnapshotFromEndpointQuery() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - String endpoint = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?sharesnapshot=snapshot-id" - + "&fileid=" + FileIdTestHelper.FILE_ID; - - ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(endpoint) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildFileClient(); - - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "?sharesnapshot=snapshot-id&fileid=" + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); - fileClient.getProperties(); - Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot-id")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); - } - - @DoNotRecord - @Tag("file-id-mock") - @Test - public void fileClientBuilderParsesFileIdAndSasFromEndpointQuery() { - String endpoint = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" - + FileIdTestHelper.FILE_ID + "&sig=signature"; - - ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(endpoint).buildFileClient(); - - Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); - Assertions.assertTrue(fileClient.getSasToken().getSignature().contains("sig=signature")); - } - - @DoNotRecord - @Tag("file-id-mock") - @Test - public void fileIdClientsPreserveShareSnapshot() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - - ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME) - .getSnapshotClient("snapshot-id"); - ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); - - Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "?sharesnapshot=snapshot-id&fileid=" + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); - fileClient.getProperties(); - Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot-id")); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); - } - @Test public void getShareSnapshotURL() { String accountName diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 2176ba36a0aab..ccc259b6a0228 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -127,10 +127,13 @@ @SuppressWarnings("deprecation") public class FileAsyncApiTests extends FileShareTestBase { + private static final String FILE_ID_TEST_CONTENT = "file-id properties"; + private ShareFileAsyncClient primaryFileAsyncClient; private ShareAsyncClient shareAsyncClient; private String shareName; private String filePath; + private String fileId; private static Map testMetadata; private static ShareFileHttpHeaders httpHeaders; private FileSmbProperties smbProperties; @@ -151,6 +154,15 @@ public void setup(TestInfo testInfo) { testMetadata = Collections.singletonMap("testmetadata", "value"); httpHeaders = new ShareFileHttpHeaders().setContentLanguage("en").setContentType("application/octet-stream"); smbProperties = new FileSmbProperties().setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.NORMAL)); + + if (testInfo.getTags().contains("file-id-integration")) { + byte[] content = FILE_ID_TEST_CONTENT.getBytes(StandardCharsets.UTF_8); + primaryFileAsyncClient.create(content.length).block(); + primaryFileAsyncClient.upload(Flux.just(ByteBuffer.wrap(content)), content.length).block(); + ShareFileProperties properties = Objects.requireNonNull(primaryFileAsyncClient.getProperties().block()); + fileId = Objects.requireNonNull(properties.getSmbProperties()).getFileId(); + Assertions.assertNotNull(fileId); + } } @Test @@ -163,56 +175,23 @@ public void getFileURL() { assertEquals(expectURL, fileURL); } - @DoNotRecord - @Tag("file-id-mock") - @Test - public void asyncFilePropertiesByIdUseFileIdQueryAndMapFileName() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals(HttpMethod.HEAD, request.getHttpMethod()); - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - - ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) - .buildAsyncClient() - .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareFileProperties properties - = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block(); - - Assertions.assertEquals("file.txt", properties.getFileName()); - Assertions.assertEquals(1024, properties.getContentLength()); - Assertions.assertEquals("en", properties.getContentLanguage()); - Assertions.assertEquals("gzip", properties.getContentEncoding()); - Assertions.assertEquals("value", properties.getMetadata().get("key")); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); - } - - @DoNotRecord - @Tag("file-id-mock") + @Tag("file-id-integration") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test - public void asyncFileClientBuilderSetsFileId() { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); - }).build(); - - ShareFileAsyncClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .serviceVersion(ShareServiceVersion.V2027_03_07) + public void asyncFilePropertiesById() { + ShareFileAsyncClient factoryClient = shareAsyncClient.getFileClientByFileId(fileId); + ShareFileAsyncClient builderClient = instrument(new ShareFileClientBuilder()) + .connectionString(ENVIRONMENT.getPrimaryAccount().getConnectionString()) + .shareName(shareName) + .fileId(fileId) .buildFileAsyncClient(); - ShareFileProperties properties = fileClient.getProperties().block(); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, fileClient.getFileId()); - Assertions.assertEquals("", fileClient.getFilePath()); - Assertions.assertEquals("file.txt", properties.getFileName()); - Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); + for (ShareFileAsyncClient fileIdClient : Arrays.asList(factoryClient, builderClient)) { + ShareFileProperties properties = fileIdClient.getProperties().block(); + Assertions.assertEquals(filePath, properties.getFileName()); + Assertions.assertEquals(FILE_ID_TEST_CONTENT.length(), properties.getContentLength()); + Assertions.assertEquals(fileId, properties.getSmbProperties().getFileId()); + } } @DoNotRecord From c610eefcb96eb46dbd39f60ccf4f8e865b77c020 Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 30 Sep 2026 19:59:15 -0400 Subject: [PATCH 15/39] add live tests and recordings --- .../azure-storage-file-share/assets.json | 2 +- .../storage/file/share/FileApiTests.java | 40 ++++++++++--------- .../storage/file/share/FileAsyncApiTests.java | 29 ++++++++------ 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index eabc0bb2c022e..10d27376b90d9 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_741d1f4fbd" + "Tag": "java/storage/azure-storage-file-share_9d5e1b5425" } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index 5a4df8ae4a5bb..45f39b9a2109c 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -215,6 +215,19 @@ public void filePropertiesById() { } } + @Tag("file-id-integration") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void fileLinksById() { + ShareFileLinks links = shareClient.getFileClientByFileId(fileId).getFileLinks(); + + assertEquals(FILE_ID_TEST_CONTENT.length(), links.getProperties().getContentLength()); + assertEquals(fileId, links.getProperties().getSmbProperties().getFileId()); + assertEquals(1, links.getLinks().size()); + assertEquals(filePath, links.getLinks().get(0).getName()); + assertEquals(links.getProperties().getSmbProperties().getParentId(), links.getLinks().get(0).getParentId()); + } + @DoNotRecord @Tag("file-id-mock") @Test @@ -248,21 +261,13 @@ public void fileLinksMapPropertiesAndDecodeLinkNames() { Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } - @DoNotRecord - @Tag("file-id-mock") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test public void propertiesByIdMapServiceErrors() { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, - 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); - ShareClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME); - - ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, - () -> client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties()); - Assertions.assertEquals(404, exception.getStatusCode()); - Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); + ShareStorageException exception = assertThrows(ShareStorageException.class, + () -> shareClient.getFileClientByFileId("invalid-file-id").getProperties()); + assertEquals(400, exception.getStatusCode()); + assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); } @DoNotRecord @@ -341,17 +346,16 @@ public void fileClientBuilderParsesFileIdFromEndpointQuery() { FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=" + FileIdTestHelper.FILE_ID, fileClient.getFileUrl()); - ShareFileClient configuredFileIdClient = new ShareFileClientBuilder() - .endpoint(FileIdTestHelper.ENDPOINT) + ShareFileClient configuredFileIdClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) .fileId(FileIdTestHelper.FILE_ID) .buildFileClient(); Assertions.assertEquals(FileIdTestHelper.FILE_ID, configuredFileIdClient.getFileId()); Assertions.assertEquals("", configuredFileIdClient.getFilePath()); - ShareFileClient pathClient - = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME - + "/file.txt").buildFileClient(); + ShareFileClient pathClient = new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/file.txt") + .buildFileClient(); Assertions.assertEquals("", pathClient.getFileId()); Assertions.assertEquals("file.txt", pathClient.getFilePath()); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(" ")); diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index ccc259b6a0228..859a80e6f77e0 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -194,6 +194,19 @@ public void asyncFilePropertiesById() { } } + @Tag("file-id-integration") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void asyncFileLinksById() { + ShareFileLinks links = shareAsyncClient.getFileClientByFileId(fileId).getFileLinks().block(); + + assertEquals(FILE_ID_TEST_CONTENT.length(), links.getProperties().getContentLength()); + assertEquals(fileId, links.getProperties().getSmbProperties().getFileId()); + assertEquals(1, links.getLinks().size()); + assertEquals(filePath, links.getLinks().get(0).getName()); + assertEquals(links.getProperties().getSmbProperties().getParentId(), links.getLinks().get(0).getParentId()); + } + @DoNotRecord @Tag("file-id-mock") @Test @@ -227,21 +240,13 @@ public void asyncFileLinksMapPropertiesAndDecodeLinkNames() { Assertions.assertTrue(requestUrl.get().contains("fileid=" + FileIdTestHelper.FILE_ID)); } - @DoNotRecord - @Tag("file-id-mock") + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test public void asyncPropertiesByIdMapServiceErrors() { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just(new MockHttpResponse(request, - 404, new HttpHeaders().set(HttpHeaderName.fromString("x-ms-error-code"), "ResourceNotFound")))).build(); - ShareAsyncClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildAsyncClient() - .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareStorageException exception = Assertions.assertThrows(ShareStorageException.class, - () -> client.getFileClientByFileId(FileIdTestHelper.FILE_ID).getProperties().block()); - Assertions.assertEquals(404, exception.getStatusCode()); - Assertions.assertEquals(ShareErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); + () -> shareAsyncClient.getFileClientByFileId("invalid-file-id").getProperties().block()); + assertEquals(400, exception.getStatusCode()); + assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); } @DoNotRecord From 4800d03df2bf45f487fb9b5f88df7921779d45cf Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 13:53:46 -0400 Subject: [PATCH 16/39] add getDirectoryByFileId, add customization to avoid file-by-id variants for getproperties --- .../storage/file/share/ShareAsyncClient.java | 13 + .../azure/storage/file/share/ShareClient.java | 13 + .../file/share/ShareDirectoryAsyncClient.java | 34 +- .../file/share/ShareDirectoryClient.java | 40 ++- .../share/implementation/DirectoriesImpl.java | 306 ++++++++++++++++++ .../ShareDirectoryPropertiesHelper.java | 10 +- .../implementation/util/ModelHelper.java | 14 +- .../models/ShareDirectoryProperties.java | 15 +- .../swagger/README.md | 2 +- .../main/java/ShareStorageCustomization.java | 16 +- 10 files changed, 435 insertions(+), 28 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 06a2c38b49774..bc27781f5c8b2 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 @@ -174,6 +174,19 @@ public ShareDirectoryAsyncClient getDirectoryClient(String directoryName) { serviceVersion, sasToken); } + /** + * Creates a directory client that addresses a directory by its file ID. + * + * @param fileId The file ID of the directory. + * @return A client for interacting with the directory by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareDirectoryAsyncClient getDirectoryClientByFileId(String fileId) { + ShareErrors.validateFileId(fileId); + return new ShareDirectoryAsyncClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + /** * Constructs a {@link ShareFileAsyncClient} that interacts with the specified file. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java index 47ac0d5612e34..bbb0428045448 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java @@ -181,6 +181,19 @@ public ShareDirectoryClient getDirectoryClient(String directoryName) { serviceVersion, sasToken); } + /** + * Creates a directory client that addresses a directory by its file ID. + * + * @param fileId The file ID of the directory. + * @return A client for interacting with the directory by ID. + * @throws IllegalArgumentException If {@code fileId} is null or blank. + */ + public ShareDirectoryClient getDirectoryClientByFileId(String fileId) { + ShareErrors.validateFileId(fileId); + return new ShareDirectoryClient(azureFileStorageClient, shareName, "", fileId, snapshot, accountName, + serviceVersion, sasToken); + } + /** * Constructs a {@link ShareFileClient} that interacts with the specified file. * diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index 3c87b2749cbc7..746bc62e76478 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -92,6 +92,7 @@ public class ShareDirectoryAsyncClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -109,10 +110,17 @@ public class ShareDirectoryAsyncClient { */ ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); + } + + ShareDirectoryAsyncClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, + String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, + AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -122,7 +130,8 @@ public class ShareDirectoryAsyncClient { ShareDirectoryAsyncClient(ShareDirectoryAsyncClient directoryAsyncClient) { this(directoryAsyncClient.azureFileStorageClient, directoryAsyncClient.shareName, - Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.snapshot, + Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.fileId, + directoryAsyncClient.snapshot, directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, directoryAsyncClient.sasToken); } @@ -134,13 +143,29 @@ public class ShareDirectoryAsyncClient { public String getDirectoryUrl() { StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); - directoryUrlString.append("/").append(directoryPath); + if (fileId.isEmpty()) { + directoryUrlString.append("/").append(directoryPath); + } if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + directoryUrlString.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + directoryUrlString.append("?fileid=").append(fileId); } return directoryUrlString.toString(); } + /** + * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + /** * Gets the service version the client is using. * @@ -659,6 +684,11 @@ public Mono> getPropertiesWithResponse() { Mono> getPropertiesWithResponse(Context context) { context = context == null ? Context.NONE : context; + if (!fileId.isEmpty()) { + return azureFileStorageClient.getDirectories() + .getPropertiesByFileIdWithResponseAsync(shareName, fileId, snapshot, null, null, context) + .map(ModelHelper::mapShareDirectoryPropertiesResponse); + } return azureFileStorageClient.getDirectories() .getPropertiesWithResponseAsync(shareName, directoryPath, snapshot, null, context) .map(ModelHelper::mapShareDirectoryPropertiesResponse); diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index db9c3079fd609..846b3debc5775 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -99,6 +99,7 @@ public class ShareDirectoryClient { private final AzureFileStorageImpl azureFileStorageClient; private final String shareName; private final String directoryPath; + private final String fileId; private final String snapshot; private final String accountName; private final ShareServiceVersion serviceVersion; @@ -117,10 +118,17 @@ public class ShareDirectoryClient { */ ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, String snapshot, String accountName, ShareServiceVersion serviceVersion, AzureSasCredential sasToken) { + this(azureFileStorageClient, shareName, directoryPath, "", snapshot, accountName, serviceVersion, sasToken); + } + + ShareDirectoryClient(AzureFileStorageImpl azureFileStorageClient, String shareName, String directoryPath, + String fileId, String snapshot, String accountName, ShareServiceVersion serviceVersion, + AzureSasCredential sasToken) { Objects.requireNonNull(shareName, "'shareName' cannot be null."); Objects.requireNonNull(directoryPath); this.shareName = shareName; this.directoryPath = directoryPath; + this.fileId = fileId; this.snapshot = snapshot; this.azureFileStorageClient = azureFileStorageClient; this.accountName = accountName; @@ -129,9 +137,16 @@ public class ShareDirectoryClient { StringBuilder directoryUrlString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); - directoryUrlString.append("/").append(directoryPath); + if (fileId.isEmpty()) { + directoryUrlString.append("/").append(directoryPath); + } if (snapshot != null) { directoryUrlString.append("?sharesnapshot=").append(snapshot); + if (!fileId.isEmpty()) { + directoryUrlString.append("&fileid=").append(fileId); + } + } else if (!fileId.isEmpty()) { + directoryUrlString.append("?fileid=").append(fileId); } this.directoryUrl = directoryUrlString.toString(); } @@ -145,6 +160,15 @@ public String getDirectoryUrl() { return this.directoryUrl; } + /** + * Gets the file ID used to address the directory, or an empty string when the client is path-addressed. + * + * @return The file ID. + */ + public String getFileId() { + return fileId; + } + /** * Gets the service version the client is using. * @@ -621,12 +645,14 @@ public ShareDirectoryProperties getProperties() { @ServiceMethod(returns = ReturnType.SINGLE) public Response getPropertiesWithResponse(Duration timeout, Context context) { Context finalContext = context == null ? Context.NONE : context; - Callable> operation - = () -> this.azureFileStorageClient.getDirectories() - .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext); - - return ModelHelper - .mapShareDirectoryPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); + Callable> operation = fileId.isEmpty() + ? () -> this.azureFileStorageClient.getDirectories() + .getPropertiesWithResponse(shareName, directoryPath, snapshot, null, finalContext) + : () -> this.azureFileStorageClient.getDirectories() + .getPropertiesByFileIdWithResponse(shareName, fileId, snapshot, null, null, finalContext); + + return ModelHelper.mapShareDirectoryPropertiesResponse( + sendRequest(operation, timeout, ShareStorageException.class)); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java index f166775a06c68..466f68f0d3c69 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/DirectoriesImpl.java @@ -631,6 +631,54 @@ Response renameNoCustomHeadersSync(@HostParam("url") String url, @PathPara @HeaderParam("x-ms-source-allow-trailing-dot") Boolean allowSourceTrailingDot, @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileId(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Mono> getPropertiesByFileIdNoCustomHeaders(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + ResponseBase getPropertiesByFileIdSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); + + @Get("/{shareName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ShareStorageExceptionInternal.class) + Response getPropertiesByFileIdNoCustomHeadersSync(@HostParam("url") String url, + @PathParam("shareName") String shareName, @QueryParam("restype") String restype, + @QueryParam("fileid") String fileId, @QueryParam("sharesnapshot") String sharesnapshot, + @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-version") String version, + @HeaderParam("x-ms-client-request-id") String requestId, + @HeaderParam("x-ms-allow-trailing-dot") Boolean allowTrailingDot, + @HeaderParam("x-ms-file-request-intent") ShareTokenIntent fileRequestIntent, + @HeaderParam("Accept") String accept, Context context); } /** @@ -3767,4 +3815,262 @@ public Response renameNoCustomHeadersWithResponse(String shareName, String throw ModelHelper.mapToShareStorageException(internalException); } } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, + requestId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdWithResponseAsync( + String shareName, String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { + final String restype = "directory"; + final String accept = "application/xml"; + return service + .getPropertiesByFileId(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, timeout, + this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getPropertiesByFileIdAsync(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId, Context context) { + return getPropertiesByFileIdWithResponseAsync(shareName, fileId, sharesnapshot, timeout, requestId, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId) { + return FluxUtil + .withContext(context -> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(shareName, fileId, + sharesnapshot, timeout, requestId, context)) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getPropertiesByFileIdNoCustomHeadersWithResponseAsync(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, Context context) { + final String restype = "directory"; + final String accept = "application/xml"; + return service + .getPropertiesByFileIdNoCustomHeaders(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, + timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context) + .onErrorMap(ShareStorageExceptionInternal.class, ModelHelper::mapToShareStorageException); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link ResponseBase}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseBase getPropertiesByFileIdWithResponse(String shareName, + String fileId, String sharesnapshot, Integer timeout, String requestId, Context context) { + try { + final String restype = "directory"; + final String accept = "application/xml"; + return service.getPropertiesByFileIdSync(this.client.getUrl(), shareName, restype, fileId, sharesnapshot, + timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void getPropertiesByFileId(String shareName, String fileId, String sharesnapshot, Integer timeout, + String requestId) { + getPropertiesByFileIdWithResponse(shareName, fileId, sharesnapshot, timeout, requestId, Context.NONE); + } + + /** + * Returns all system properties for the directory identified by its file ID. The data returned does not include the + * files in the directory or any subdirectories. + * + * @param shareName The name of the target share. + * @param fileId The file ID of the target file or directory. + * @param sharesnapshot The snapshot parameter is an opaque DateTime value that, when present, specifies the share + * snapshot to query. + * @param timeout The timeout parameter is expressed in seconds. For more information, see <a + * href="https://learn.microsoft.com/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations">Setting + * Timeouts for File Service Operations.</a>. + * @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the + * analytics logs when storage analytics logging is enabled. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ShareStorageExceptionInternal thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getPropertiesByFileIdNoCustomHeadersWithResponse(String shareName, String fileId, + String sharesnapshot, Integer timeout, String requestId, Context context) { + try { + final String restype = "directory"; + final String accept = "application/xml"; + return service.getPropertiesByFileIdNoCustomHeadersSync(this.client.getUrl(), shareName, restype, fileId, + sharesnapshot, timeout, this.client.getVersion(), requestId, this.client.isAllowTrailingDot(), + this.client.getFileRequestIntent(), accept, context); + } catch (ShareStorageExceptionInternal internalException) { + throw ModelHelper.mapToShareStorageException(internalException); + } + } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java index 7dd95ad83c29a..8ea3694fb668d 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareDirectoryPropertiesHelper.java @@ -34,10 +34,12 @@ public interface ShareDirectoryPropertiesAccessor { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. + * @param fileName The name returned by the service. * @return A new instance of {@link ShareDirectoryProperties}. */ ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties); + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, + String fileName); } /** @@ -59,11 +61,12 @@ public static void setAccessor(ShareDirectoryPropertiesAccessor accessor) { * encrypted using the specified algorithm. Otherwise, the value is set to false. * @param smbProperties The SMB properties of the directory. * @param posixProperties the NFS properties of the directory. + * @param fileName The name returned by the service. * @return A new instance of {@link ShareDirectoryProperties}. */ public static ShareDirectoryProperties create(Map metadata, String eTag, OffsetDateTime lastModified, boolean isServerEncrypted, FileSmbProperties smbProperties, - FilePosixProperties posixProperties) { + FilePosixProperties posixProperties, String fileName) { // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the // application accesses ShareDirectoryProperties which triggers the accessor to be configured. So, if the accessor // is null this effectively pokes the class to set up the accessor. @@ -72,6 +75,7 @@ public static ShareDirectoryProperties create(Map metadata, Stri } assert accessor != null; - return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties); + return accessor.create(metadata, eTag, lastModified, isServerEncrypted, smbProperties, posixProperties, + fileName); } } 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 f5cf3277ea3a5..2f2f13c28482d 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 @@ -599,16 +599,16 @@ public static Response mapGetStatisticsResponse(Response(response, shareDirectoryInfo); } - public static Response - mapShareDirectoryPropertiesResponse(ResponseBase response) { - Map metadata = response.getDeserializedHeaders().getXMsMeta(); - String eTag = response.getDeserializedHeaders().getETag(); - OffsetDateTime offsetDateTime = response.getDeserializedHeaders().getLastModified(); - boolean isServerEncrypted = response.getDeserializedHeaders().isXMsServerEncrypted(); + public static Response mapShareDirectoryPropertiesResponse(Response response) { + DirectoriesGetPropertiesHeaders headers = new DirectoriesGetPropertiesHeaders(response.getHeaders()); + Map metadata = headers.getXMsMeta(); + String eTag = headers.getETag(); + OffsetDateTime offsetDateTime = headers.getLastModified(); + boolean isServerEncrypted = headers.isXMsServerEncrypted(); FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders()); FilePosixProperties posixProperties = FilePosixPropertiesHelper.create(response.getHeaders()); ShareDirectoryProperties shareDirectoryProperties = ShareDirectoryPropertiesHelper.create(metadata, eTag, - offsetDateTime, isServerEncrypted, smbProperties, posixProperties); + offsetDateTime, isServerEncrypted, smbProperties, posixProperties, headers.getXMsFileName()); return new SimpleResponse<>(response, shareDirectoryProperties); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java index b70915b269370..bbae2cb5e3169 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareDirectoryProperties.java @@ -21,6 +21,7 @@ public final class ShareDirectoryProperties { private final boolean isServerEncrypted; private final FileSmbProperties smbProperties; private final FilePosixProperties posixProperties; + private final String fileName; /** * Creates an instance of properties information about a specific Directory. @@ -40,17 +41,20 @@ public ShareDirectoryProperties(Map metadata, String eTag, Offse this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = null; + this.fileName = null; } //Internal constructor to support FilePosixProperties class. private ShareDirectoryProperties(Map metadata, String eTag, OffsetDateTime lastModified, - boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties) { + boolean isServerEncrypted, FileSmbProperties smbProperties, FilePosixProperties posixProperties, + String fileName) { this.metadata = metadata; this.eTag = eTag; this.lastModified = lastModified; this.isServerEncrypted = isServerEncrypted; this.smbProperties = smbProperties; this.posixProperties = posixProperties; + this.fileName = fileName; } static { @@ -113,4 +117,13 @@ public FileSmbProperties getSmbProperties() { public FilePosixProperties getPosixProperties() { return posixProperties; } + + /** + * Gets the directory name returned by the service, or {@code null} when it was not returned. + * + * @return The directory name. + */ + public String getFileName() { + return fileName; + } } diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 744becc454830..8218c5ccc3a56 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/25afaa4b9194ad7fa1af0b8816c07ad0a39d322d/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/74d5b5955847c39b2dce9dceadf051badc506bf4/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share diff --git a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java index a416e0b0a5b1b..a8219584cd5af 100644 --- a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java +++ b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java @@ -42,10 +42,11 @@ public void customize(LibraryCustomization customization, Logger logger) { + "@see ShareFileItem#getFileType()"))); updateImplToMapInternalException(customization.getPackage("com.azure.storage.file.share.implementation")); - reusePropertyHeaders(customization.getRawEditor(), "Files"); + reusePropertyHeaders(customization.getRawEditor(), "Directories", logger); + reusePropertyHeaders(customization.getRawEditor(), "Files", logger); } - private static void reusePropertyHeaders(Editor editor, String operationGroup) { + private static void reusePropertyHeaders(Editor editor, String operationGroup, Logger logger) { String implementationPath = "src/main/java/com/azure/storage/file/share/implementation/"; String headersName = operationGroup + "GetPropertiesHeaders"; String fileIdHeadersName = operationGroup + "GetPropertiesByFileIdHeaders"; @@ -58,15 +59,16 @@ private static void reusePropertyHeaders(Editor editor, String operationGroup) { if (headers == null || fileIdHeaders == null || client == null) { throw new IllegalStateException("Missing generated sources for " + operationGroup + " property headers."); } + if (!client.contains(fileIdHeadersName)) { + throw new IllegalStateException(clientPath + " no longer references " + fileIdHeadersName + "."); + } // Compare the entire model, including parsing, before discarding the operation-specific copy. if (!headers.replace("\r\n", "\n") .equals(fileIdHeaders.replace(fileIdHeadersName, headersName).replace("\r\n", "\n"))) { - throw new IllegalStateException(fileIdHeadersName + " differs from " + headersName - + ". Review the response headers before reusing the existing model."); - } - if (!client.contains(fileIdHeadersName)) { - throw new IllegalStateException(clientPath + " no longer references " + fileIdHeadersName + "."); + logger.warn("{} differs from {}; preserving both generated response header models.", + fileIdHeadersName, headersName); + return; } editor.replaceFile(clientPath, client.replace(fileIdHeadersName, headersName)); From 7a56dbfaade9fc4378be9fa3a091237faf00e821 Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 14:14:16 -0400 Subject: [PATCH 17/39] add tests with recordings --- .../azure-storage-file-share/assets.json | 2 +- .../file/share/ShareDirectoryClient.java | 1 - .../storage/file/share/DirectoryApiTests.java | 126 +++++++++++++++++ .../file/share/DirectoryAsyncApiTests.java | 133 ++++++++++++++++++ 4 files changed, 260 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 10d27376b90d9..51b5dee863330 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_9d5e1b5425" + "Tag": "java/storage/azure-storage-file-share_1096d61b58" } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 846b3debc5775..ef5db8424d0f8 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -27,7 +27,6 @@ import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesForceCloseHandlesHeaders; -import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesListHandlesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetMetadataHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetPropertiesHeaders; diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index aec882df83ab3..0276b6de89413 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -5,6 +5,7 @@ import com.azure.core.http.HttpHeader; import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpMethod; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; @@ -57,6 +58,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import java.io.File; @@ -122,6 +124,130 @@ public void getDirectoryUrl() { assertEquals(expectURL, directoryURL); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void directoryPropertiesByFileId(boolean snapshot) { + primaryDirectoryClient.createWithResponse(new ShareDirectoryCreateOptions().setMetadata(testMetadata), null, + null); + ShareDirectoryProperties expected = primaryDirectoryClient.getProperties(); + String fileId = expected.getSmbProperties().getFileId(); + assertNotNull(fileId); + ShareClient source = shareClient; + if (snapshot) { + source = shareClient.getSnapshotClient(shareClient.createSnapshot().getSnapshot()); + primaryDirectoryClient.setMetadata(Collections.singletonMap("changed", "after-snapshot")); + } + + ShareDirectoryClient directoryClient = source.getDirectoryClientByFileId(fileId); + Response response = directoryClient.getPropertiesWithResponse(null, Context.NONE); + ShareDirectoryProperties actual = response.getValue(); + assertEquals(200, response.getStatusCode()); + assertEquals(fileId, directoryClient.getFileId()); + assertEquals(directoryPath, actual.getFileName()); + assertEquals(expected.getMetadata(), actual.getMetadata()); + assertEquals(expected.getETag(), actual.getETag()); + assertEquals(expected.getLastModified(), actual.getLastModified()); + assertEquals(expected.isServerEncrypted(), actual.isServerEncrypted()); + assertEquals(fileId, actual.getSmbProperties().getFileId()); + assertEquals(expected.getSmbProperties().getParentId(), actual.getSmbProperties().getParentId()); + assertEquals(expected.getSmbProperties().getFileCreationTime(), + actual.getSmbProperties().getFileCreationTime()); + assertEquals(expected.getSmbProperties().getFileLastWriteTime(), + actual.getSmbProperties().getFileLastWriteTime()); + assertTrue(directoryClient.exists()); + } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void directoryPropertiesByFileIdMapServiceErrors() { + ShareStorageException exception = assertThrows(ShareStorageException.class, + () -> shareClient.getDirectoryClientByFileId("invalid-file-id").getProperties()); + assertEquals(400, exception.getStatusCode()); + assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void directoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + assertEquals(HttpMethod.GET, request.getHttpMethod()); + assertEquals("/" + FileIdTestHelper.SHARE_NAME, request.getUrl().getPath()); + String query = request.getUrl().getQuery(); + assertTrue(query.contains("restype=directory")); + assertTrue(query.contains("fileid=" + FileIdTestHelper.FILE_ID)); + assertEquals(snapshot, query.contains("sharesnapshot=snapshot")); + return Mono.just(new MockHttpResponse(request, 200, + FileIdTestHelper.fileHeaders("directory") + .set(HttpHeaderName.fromString("x-ms-type"), "directory") + .set(HttpHeaderName.fromString("x-ms-server-encrypted"), "true"))); + }).build(); + ShareClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + if (snapshot) { + source = source.getSnapshotClient("snapshot"); + } + ShareDirectoryClient directoryClient = source.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); + assertEquals("", directoryClient.getDirectoryPath()); + assertEquals(ShareServiceVersion.V2027_03_07, directoryClient.getServiceVersion()); + assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + (snapshot ? "?sharesnapshot=snapshot&" : "?") + "fileid=" + FileIdTestHelper.FILE_ID, + directoryClient.getDirectoryUrl()); + + ShareDirectoryProperties properties = directoryClient.getProperties(); + assertEquals("directory", properties.getFileName()); + assertEquals("value", properties.getMetadata().get("key")); + assertEquals("\"0x8DEAF1479E1C087\"", properties.getETag()); + assertEquals(OffsetDateTime.parse("2015-10-21T07:28:00Z"), properties.getLastModified()); + assertTrue(properties.isServerEncrypted()); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @NullAndEmptySource + @ValueSource(strings = { " ", "\t", "\n" }) + public void directoryClientByFileIdRejectsBlankIds(String fileId) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Invalid file IDs must be rejected before sending a request."); + }).build(); + ShareClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + assertThrows(IllegalArgumentException.class, () -> source.getDirectoryClientByFileId(fileId)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void directoryPropertiesWithoutFileName() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + HttpHeaders headers = FileIdTestHelper.fileHeaders("directory"); + headers.remove(HttpHeaderName.fromString("x-ms-file-name")); + return Mono.just(new MockHttpResponse(request, 200, headers)); + }).build(); + ShareDirectoryClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .resourcePath("directory") + .pipeline(pipeline) + .buildDirectoryClient(); + assertEquals("", directoryClient.getFileId()); + ShareDirectoryProperties properties = directoryClient.getProperties(); + assertNull(properties.getFileName()); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + assertNull(new ShareDirectoryProperties(Collections.emptyMap(), properties.getETag(), + properties.getLastModified(), false, properties.getSmbProperties()).getFileName()); + } + @DoNotRecord @Tag("file-id-mock") @ParameterizedTest diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index df518515674c7..1c4516bf31290 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -4,6 +4,8 @@ package com.azure.storage.file.share; import com.azure.core.http.HttpHeader; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpMethod; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; @@ -45,6 +47,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -111,6 +114,136 @@ public void getDirectoryURL() { assertEquals(expectURL, directoryURL); } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncDirectoryPropertiesByFileId(boolean snapshot) { + primaryDirectoryAsyncClient.createWithResponse(new ShareDirectoryCreateOptions().setMetadata(testMetadata)) + .block(); + ShareDirectoryProperties expected = primaryDirectoryAsyncClient.getProperties().block(); + String fileId = expected.getSmbProperties().getFileId(); + assertNotNull(fileId); + ShareAsyncClient source = shareBuilderHelper(shareName).buildAsyncClient(); + if (snapshot) { + source = source.getSnapshotClient(source.createSnapshot().block().getSnapshot()); + primaryDirectoryAsyncClient.setMetadata(Collections.singletonMap("changed", "after-snapshot")).block(); + } + + ShareDirectoryAsyncClient directoryClient = source.getDirectoryClientByFileId(fileId); + assertEquals(fileId, directoryClient.getFileId()); + StepVerifier.create(directoryClient.getPropertiesWithResponse()).assertNext(response -> { + ShareDirectoryProperties actual = response.getValue(); + assertEquals(200, response.getStatusCode()); + assertEquals(directoryPath, actual.getFileName()); + assertEquals(expected.getMetadata(), actual.getMetadata()); + assertEquals(expected.getETag(), actual.getETag()); + assertEquals(expected.getLastModified(), actual.getLastModified()); + assertEquals(expected.isServerEncrypted(), actual.isServerEncrypted()); + assertEquals(fileId, actual.getSmbProperties().getFileId()); + assertEquals(expected.getSmbProperties().getParentId(), actual.getSmbProperties().getParentId()); + assertEquals(expected.getSmbProperties().getFileCreationTime(), + actual.getSmbProperties().getFileCreationTime()); + assertEquals(expected.getSmbProperties().getFileLastWriteTime(), + actual.getSmbProperties().getFileLastWriteTime()); + }).verifyComplete(); + StepVerifier.create(directoryClient.exists()).expectNext(true).verifyComplete(); + } + + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void asyncDirectoryPropertiesByFileIdMapServiceErrors() { + ShareAsyncClient source = shareBuilderHelper(shareName).buildAsyncClient(); + StepVerifier.create(source.getDirectoryClientByFileId("invalid-file-id").getProperties()) + .verifyErrorSatisfies(error -> { + ShareStorageException exception = assertInstanceOf(ShareStorageException.class, error); + assertEquals(400, exception.getStatusCode()); + assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); + }); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncDirectoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + assertEquals(HttpMethod.GET, request.getHttpMethod()); + assertEquals("/" + FileIdTestHelper.SHARE_NAME, request.getUrl().getPath()); + String query = request.getUrl().getQuery(); + assertTrue(query.contains("restype=directory")); + assertTrue(query.contains("fileid=" + FileIdTestHelper.FILE_ID)); + assertEquals(snapshot, query.contains("sharesnapshot=snapshot")); + return Mono.just(new MockHttpResponse(request, 200, + FileIdTestHelper.fileHeaders("directory") + .set(HttpHeaderName.fromString("x-ms-type"), "directory") + .set(HttpHeaderName.fromString("x-ms-server-encrypted"), "true"))); + }).build(); + ShareAsyncClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + if (snapshot) { + source = source.getSnapshotClient("snapshot"); + } + ShareDirectoryAsyncClient original = source.getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + ShareDirectoryAsyncClient directoryClient = new ShareDirectoryAsyncClient(original); + assertEquals(original.getDirectoryUrl(), directoryClient.getDirectoryUrl()); + assertEquals(FileIdTestHelper.FILE_ID, directoryClient.getFileId()); + assertEquals("", directoryClient.getDirectoryPath()); + assertEquals(ShareServiceVersion.V2027_03_07, directoryClient.getServiceVersion()); + assertEquals( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + (snapshot ? "?sharesnapshot=snapshot&" : "?") + "fileid=" + FileIdTestHelper.FILE_ID, + directoryClient.getDirectoryUrl()); + + StepVerifier.create(directoryClient.getProperties()).assertNext(properties -> { + assertEquals("directory", properties.getFileName()); + assertEquals("value", properties.getMetadata().get("key")); + assertEquals("\"0x8DEAF1479E1C087\"", properties.getETag()); + assertEquals(OffsetDateTime.parse("2015-10-21T07:28:00Z"), properties.getLastModified()); + assertTrue(properties.isServerEncrypted()); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + }).verifyComplete(); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @NullAndEmptySource + @ValueSource(strings = { " ", "\t", "\n" }) + public void asyncDirectoryClientByFileIdRejectsBlankIds(String fileId) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Invalid file IDs must be rejected before sending a request."); + }).build(); + ShareAsyncClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + Assertions.assertThrows(IllegalArgumentException.class, () -> source.getDirectoryClientByFileId(fileId)); + } + + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncDirectoryPropertiesWithoutFileName() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + HttpHeaders headers = FileIdTestHelper.fileHeaders("directory"); + headers.remove(HttpHeaderName.fromString("x-ms-file-name")); + return Mono.just(new MockHttpResponse(request, 200, headers)); + }).build(); + ShareDirectoryAsyncClient directoryClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .resourcePath("directory") + .pipeline(pipeline) + .buildDirectoryAsyncClient(); + assertEquals("", directoryClient.getFileId()); + StepVerifier.create(directoryClient.getProperties()).assertNext(properties -> { + assertNull(properties.getFileName()); + FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); + }).verifyComplete(); + } + @DoNotRecord @Tag("file-id-mock") @ParameterizedTest From 1f549ac494beb4a9ca03d0cd45f6df0e8e862b76 Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 17:17:18 -0400 Subject: [PATCH 18/39] add recordings for prev features that were missing --- sdk/storage/azure-storage-file-share/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 51b5dee863330..95f4e88276e86 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_1096d61b58" + "Tag": "java/storage/azure-storage-file-share_c861318b2a" } From 46949f8d1f3d13e8dfdc5a0f8d9838f0021b87ac Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 18:24:38 -0400 Subject: [PATCH 19/39] move check to validatePathOperation to encapsulate teh policy --- .../file/share/ShareFileAsyncClient.java | 46 ++++++++--------- .../storage/file/share/ShareFileClient.java | 50 +++++++++---------- .../share/implementation/ShareErrors.java | 11 ++++ 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index 58f807df952b2..80696b9d67d65 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -339,7 +339,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "exists"); + ShareErrors.validatePathOperation(fileId, "exists"); return this.getPropertiesWithResponse(null, context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -543,7 +543,7 @@ Mono> createWithResponse(long maxSize, ShareFileHttpHead FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties filePosixProperties, Map metadata, ShareRequestConditions requestConditions, FilePropertySemantics filePropertySemantics, BinaryData binaryData, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "create"); + ShareErrors.validatePathOperation(fileId, "create"); final Context contextLocal = context == null ? Context.NONE : context; final ShareRequestConditions requestConditionsLocal = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -732,7 +732,7 @@ public PollerFlux beginCopy(String sourceUrl, FileSmbPr */ public PollerFlux beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { - ShareErrors.assertNotFileIdAddressed(fileId, "beginCopy"); + ShareErrors.validatePathOperation(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() @@ -959,7 +959,7 @@ public Mono> abortCopyWithResponse(String copyId, ShareRequestCon Mono> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "abortCopy"); + ShareErrors.validatePathOperation(fileId, "abortCopy"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .abortCopyNoCustomHeadersWithResponseAsync(shareName, filePath, copyId, null, @@ -1089,7 +1089,7 @@ public Mono> downloadToFileWithResponse(String dow Mono> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "downloadToFile"); + ShareErrors.validatePathOperation(fileId, "downloadToFile"); return Mono.using(() -> channelSetup(downloadFilePath, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW), channel -> getPropertiesWithResponse(requestConditions, context) .flatMap(response -> downloadResponseInChunk(response, channel, range, requestConditions, context)), @@ -1268,7 +1268,7 @@ public Mono downloadWithResponse(ShareFileDownlo } Mono downloadWithResponse(ShareFileDownloadOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "download"); + ShareErrors.validatePathOperation(fileId, "download"); options = options == null ? new ShareFileDownloadOptions() : options; ShareFileRange range = options.getRange() == null ? new ShareFileRange(0) : options.getRange(); ShareRequestConditions requestConditions @@ -1433,7 +1433,7 @@ public Mono> deleteWithResponse(ShareRequestConditions requestCon } Mono> deleteWithResponse(ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "delete"); + ShareErrors.validatePathOperation(fileId, "delete"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return azureFileStorageClient.getFiles() .deleteNoCustomHeadersWithResponseAsync(shareName, filePath, null, requestConditions.getLeaseId(), context); @@ -1870,7 +1870,7 @@ public Mono> setPropertiesWithResponse(ShareFileSetPrope Mono> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties fileposixProperties, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); + ShareErrors.validatePathOperation(fileId, "setProperties"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; @@ -2014,7 +2014,7 @@ public Mono> setMetadataWithResponse(Map> setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); + ShareErrors.validatePathOperation(fileId, "setMetadata"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; context = context == null ? Context.NONE : context; try { @@ -2225,7 +2225,7 @@ public Mono> uploadWithResponse(ShareFileUploadOpt } Mono> uploadWithResponse(ShareFileUploadOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "upload"); + ShareErrors.validatePathOperation(fileId, "upload"); try { StorageImplUtils.assertNotNull("options", options); ShareRequestConditions validatedRequestConditions = options.getRequestConditions() == null @@ -2395,7 +2395,7 @@ public Mono> uploadRangeWithResponse(ShareFileUplo * One-shot upload range. */ Mono> uploadRangeWithResponse(ShareFileUploadRangeOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "uploadRange"); + ShareErrors.validatePathOperation(fileId, "uploadRange"); ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); long rangeOffset = (options.getOffset() == null) ? 0L : options.getOffset(); @@ -2560,7 +2560,7 @@ public Mono> uploadRangeFromUrlWithRes Mono> uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "uploadRangeFromUrl"); + ShareErrors.validatePathOperation(fileId, "uploadRangeFromUrl"); ShareRequestConditions modifiedRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2684,7 +2684,7 @@ public Mono> clearRangeWithResponse(long length, l Mono> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "clearRange"); + ShareErrors.validatePathOperation(fileId, "clearRange"); requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); context = context == null ? Context.NONE : context; @@ -3055,7 +3055,7 @@ PagedFlux listAllRangesInternal(ShareFileRange range, ShareR Mono> listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); + ShareErrors.validatePathOperation(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -3122,7 +3122,7 @@ public PagedFlux listHandles(Integer maxResultsPerPage) { } PagedFlux listHandlesWithOptionalTimeout(Integer maxResultsPerPage, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); + ShareErrors.validatePathOperation(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getFiles() .listHandlesWithResponseAsync(shareName, filePath, marker, maxResultsPerPage, null, snapshot, context), @@ -3194,7 +3194,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); + ShareErrors.validatePathOperation(fileId, "forceCloseHandle"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getFiles() .forceCloseHandlesWithResponseAsync(shareName, filePath, handleId, null, null, snapshot, context) @@ -3236,7 +3236,7 @@ public Mono forceCloseAllHandles() { } PagedFlux forceCloseAllHandlesWithOptionalTimeout(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.validatePathOperation(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout( this.azureFileStorageClient.getFiles() @@ -3322,7 +3322,7 @@ public Mono> renameWithResponse(ShareFileRenameOp } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "rename"); + ShareErrors.validatePathOperation(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -3541,7 +3541,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); + ShareErrors.validatePathOperation(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3593,7 +3593,7 @@ public Mono> createHardLinkWithResponse(ShareFileCreateH Mono> createHardLinkWithResponse(String targetFile, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "createHardLink"); + ShareErrors.validatePathOperation(fileId, "createHardLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; return this.azureFileStorageClient.getFiles() @@ -3649,7 +3649,7 @@ public Mono> createSymbolicLinkWithResponse(ShareFileCre Mono> createSymbolicLinkWithResponse(String linkText, Map metadata, OffsetDateTime fileCreationTime, OffsetDateTime fileLastWriteTime, String owner, String group, ShareRequestConditions requestConditions, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "createSymbolicLink"); + ShareErrors.validatePathOperation(fileId, "createSymbolicLink"); context = context == null ? Context.NONE : context; requestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String fileCreationTimeString = FileSmbProperties.parseFileSMBDate(fileCreationTime); @@ -3701,7 +3701,7 @@ public Mono> getSymbolicLinkWithResponse() { } Mono> getSymbolicLinkWithResponse(Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "getSymbolicLink"); + ShareErrors.validatePathOperation(fileId, "getSymbolicLink"); context = context == null ? Context.NONE : context; return this.azureFileStorageClient.getFiles() .getSymbolicLinkWithResponseAsync(shareName, filePath, null, snapshot, null, context) @@ -3736,7 +3736,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateUserDelegationSas"); + ShareErrors.validatePathOperation(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index a96a5bdb0df3c..f868a670055f6 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -317,7 +317,7 @@ public final StorageFileInputStream openInputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileInputStream openInputStream(ShareFileRange range) { - ShareErrors.assertNotFileIdAddressed(fileId, "openInputStream"); + ShareErrors.validatePathOperation(fileId, "openInputStream"); return new StorageFileInputStream(shareFileAsyncClient, range.getStart(), range.getEnd() == null ? null : (range.getEnd() - range.getStart() + 1)); } @@ -342,7 +342,7 @@ public final StorageFileOutputStream getFileOutputStream() { * @throws ShareStorageException If a storage service error occurred. */ public final StorageFileOutputStream getFileOutputStream(long offset) { - ShareErrors.assertNotFileIdAddressed(fileId, "getFileOutputStream"); + ShareErrors.validatePathOperation(fileId, "getFileOutputStream"); return new StorageFileOutputStream(shareFileAsyncClient, offset); } @@ -352,7 +352,7 @@ public final StorageFileOutputStream getFileOutputStream(long offset) { * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByteChannelWriteOptions options) { - ShareErrors.assertNotFileIdAddressed(fileId, "getFileSeekableByteChannelWrite"); + ShareErrors.validatePathOperation(fileId, "getFileSeekableByteChannelWrite"); Objects.requireNonNull(options, "'options' cannot be null."); if (options.isOverwriteMode()) { @@ -373,7 +373,7 @@ public SeekableByteChannel getFileSeekableByteChannelWrite(ShareFileSeekableByte * @return The opened channel. */ public SeekableByteChannel getFileSeekableByteChannelRead(ShareFileSeekableByteChannelReadOptions options) { - ShareErrors.assertNotFileIdAddressed(fileId, "getFileSeekableByteChannelRead"); + ShareErrors.validatePathOperation(fileId, "getFileSeekableByteChannelRead"); ShareRequestConditions conditions = options != null ? options.getRequestConditions() : null; Long configuredChunkSize = options != null ? options.getChunkSizeInBytes() : null; int chunkSize @@ -418,7 +418,7 @@ public Boolean exists() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "exists"); + ShareErrors.validatePathOperation(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -624,7 +624,7 @@ public Response createWithResponse(long maxSize, ShareFileHttpHea @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareFileCreateOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "create"); + ShareErrors.validatePathOperation(fileId, "create"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -815,7 +815,7 @@ public SyncPoller beginCopy(String sourceUrl, FileSmbPr */ public SyncPoller beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) { - ShareErrors.assertNotFileIdAddressed(fileId, "beginCopy"); + ShareErrors.validatePathOperation(fileId, "beginCopy"); final ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -1031,7 +1031,7 @@ public Response abortCopyWithResponse(String copyId, Duration timeout, Con @ServiceMethod(returns = ReturnType.SINGLE) public Response abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "abortCopy"); + ShareErrors.validatePathOperation(fileId, "abortCopy"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1406,7 +1406,7 @@ public Response deleteWithResponse(Duration timeout, Context context) { @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(ShareRequestConditions requestConditions, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "delete"); + ShareErrors.validatePathOperation(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -1817,7 +1817,7 @@ public Response setPropertiesWithResponse(long newFileSize, Share @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareFileSetPropertiesOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setProperties"); + ShareErrors.validatePathOperation(fileId, "setProperties"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions @@ -1971,7 +1971,7 @@ public Response setMetadataWithResponse(Map setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "setMetadata"); + ShareErrors.validatePathOperation(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2379,7 +2379,7 @@ public Response uploadRangeFromUrlWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Response uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "uploadRangeFromUrl"); + ShareErrors.validatePathOperation(fileId, "uploadRangeFromUrl"); ShareRequestConditions finalRequestConditions = options.getDestinationRequestConditions() == null ? new ShareRequestConditions() : options.getDestinationRequestConditions(); @@ -2494,7 +2494,7 @@ public Response clearRangeWithResponse(long length, long of @ServiceMethod(returns = ReturnType.SINGLE) public Response clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "clearRange"); + ShareErrors.validatePathOperation(fileId, "clearRange"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; ShareFileRange range = new ShareFileRange(offset, offset + length - 1); @@ -2651,7 +2651,7 @@ public PagedIterable listRanges(ShareFileRange range, Duration t @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listRanges(ShareFileRange range, ShareRequestConditions requestConditions, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); + ShareErrors.validatePathOperation(fileId, "listRanges"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; @@ -2841,7 +2841,7 @@ public ShareFileRangeList listRangesDiff(String previousSnapshot) { @ServiceMethod(returns = ReturnType.SINGLE) public Response listRangesDiffWithResponse(ShareFileListRangesDiffOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listRangesDiff"); + ShareErrors.validatePathOperation(fileId, "listRangesDiff"); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions = options.getRequestConditions() == null ? new ShareRequestConditions() : options.getRequestConditions(); @@ -2905,7 +2905,7 @@ public PagedIterable listHandles() { */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listHandles(Integer maxResultsPerPage, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listHandles"); + ShareErrors.validatePathOperation(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -2984,7 +2984,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseHandle"); + ShareErrors.validatePathOperation(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> azureFileStorageClient.getFiles() .forceCloseHandlesWithResponse(shareName, filePath, handleId, null, null, snapshot, finalContext); @@ -3022,7 +3022,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "forceCloseAllHandles"); + ShareErrors.validatePathOperation(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; try { Callable> operation @@ -3111,7 +3111,7 @@ public ShareFileClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "rename"); + ShareErrors.validatePathOperation(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions sourceRequestConditions = options.getSourceRequestConditions() == null @@ -3334,7 +3334,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur */ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateSas"); + ShareErrors.validatePathOperation(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } @@ -3379,7 +3379,7 @@ public ShareFileInfo createHardLink(String targetFile) { @ServiceMethod(returns = ReturnType.SINGLE) public Response createHardLinkWithResponse(ShareFileCreateHardLinkOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "createHardLink"); + ShareErrors.validatePathOperation(fileId, "createHardLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3431,7 +3431,7 @@ public ShareFileInfo createSymbolicLink(String linkText) { */ public Response createSymbolicLinkWithResponse(ShareFileCreateSymbolicLinkOptions options, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "createSymbolicLink"); + ShareErrors.validatePathOperation(fileId, "createSymbolicLink"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; ShareRequestConditions requestConditions @@ -3482,7 +3482,7 @@ public ShareFileSymbolicLinkInfo getSymbolicLink() { * describing the symbolic link. */ public Response getSymbolicLinkWithResponse(Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "getSymbolicLink"); + ShareErrors.validatePathOperation(fileId, "getSymbolicLink"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -3520,7 +3520,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ */ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, UserDelegationKey userDelegationKey, Consumer stringToSignHandler, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "generateUserDelegationSas"); + ShareErrors.validatePathOperation(fileId, "generateUserDelegationSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getFilePath()) .generateUserDelegationSas(userDelegationKey, accountName, stringToSignHandler, context); } @@ -3528,7 +3528,7 @@ public String generateUserDelegationSas(ShareServiceSasSignatureValues shareServ ResponseBase listRangesWithResponse(ShareFileRange range, ShareRequestConditions requestConditions, String previousSnapshot, Boolean supportRename, String marker, Integer maxResultsPerPage, Duration timeout, Context context) { - ShareErrors.assertNotFileIdAddressed(fileId, "listRanges"); + ShareErrors.validatePathOperation(fileId, "listRanges"); ShareRequestConditions finalRequestConditions = requestConditions == null ? new ShareRequestConditions() : requestConditions; String rangeString = range == null ? null : range.toString(); diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java index 4db7358cdd418..ec64cd446089b 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java @@ -43,6 +43,17 @@ public static void assertFileIdAddressed(String fileId, String operationName) { } } + /** + * Validates that the client can perform a path-based operation. + * + * @param fileId The client's file ID. + * @param operationName The operation name to report on failure. + * @throws IllegalStateException If the client is file-ID-addressed. + */ + public static void validatePathOperation(String fileId, String operationName) { + assertNotFileIdAddressed(fileId, operationName); + } + /** * Throws if the client addresses its resource by file ID. * From cf75a446ea81fedc05da60220d4db4d204e145bc Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 18:26:28 -0400 Subject: [PATCH 20/39] spotless apply --- .../azure/storage/file/share/ShareDirectoryAsyncClient.java | 4 ++-- .../com/azure/storage/file/share/ShareDirectoryClient.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index 746bc62e76478..244d7cfc4687d 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -131,8 +131,8 @@ public class ShareDirectoryAsyncClient { ShareDirectoryAsyncClient(ShareDirectoryAsyncClient directoryAsyncClient) { this(directoryAsyncClient.azureFileStorageClient, directoryAsyncClient.shareName, Utility.urlEncode(directoryAsyncClient.directoryPath), directoryAsyncClient.fileId, - directoryAsyncClient.snapshot, - directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, directoryAsyncClient.sasToken); + directoryAsyncClient.snapshot, directoryAsyncClient.accountName, directoryAsyncClient.serviceVersion, + directoryAsyncClient.sasToken); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index ef5db8424d0f8..5c636b03f336f 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -650,8 +650,8 @@ public Response getPropertiesWithResponse(Duration tim : () -> this.azureFileStorageClient.getDirectories() .getPropertiesByFileIdWithResponse(shareName, fileId, snapshot, null, null, finalContext); - return ModelHelper.mapShareDirectoryPropertiesResponse( - sendRequest(operation, timeout, ShareStorageException.class)); + return ModelHelper + .mapShareDirectoryPropertiesResponse(sendRequest(operation, timeout, ShareStorageException.class)); } /** From a45e03fdd69c6562ced38d227986e6ad5d751542 Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 6 Oct 2026 21:38:16 -0400 Subject: [PATCH 21/39] restrict more paths when using file id --- .../file/share/ShareDirectoryAsyncClient.java | 22 ++++ .../file/share/ShareDirectoryClient.java | 21 ++++ .../file/share/ShareFileAsyncClient.java | 3 + .../storage/file/share/ShareFileClient.java | 2 + .../storage/file/share/DirectoryApiTests.java | 69 +++++++++- .../file/share/DirectoryAsyncApiTests.java | 76 ++++++++++- .../storage/file/share/FileApiTests.java | 118 ++++++++++++++++++ .../storage/file/share/FileAsyncApiTests.java | 105 ++++++++++++++++ 8 files changed, 414 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index 244d7cfc4687d..763c36c23c4a0 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -23,6 +23,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.ListFilesIncludeType; @@ -68,6 +69,10 @@ * Service. Operations allowed by the client are creating, deleting and listing subdirectory and file, retrieving * properties, setting metadata and list or force close handles of the directory or file. * + *

Clients addressed by file ID support property retrieval. Other service operations, including existence checks, + * and child-client creation throw {@link IllegalStateException} or signal it through the returned publisher. + * Use a path-addressed client for these operations.

+ * *

Instantiating an Asynchronous Directory Client

* * @@ -183,8 +188,10 @@ public ShareServiceVersion getServiceVersion() { * * @param fileName Name of the file * @return a ShareFileAsyncClient that interacts with the specified share + * @throws IllegalStateException If this client is addressed by file ID. */ public ShareFileAsyncClient getFileClient(String fileName) { + ShareErrors.validatePathOperation(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -202,8 +209,10 @@ public ShareFileAsyncClient getFileClient(String fileName) { * * @param subdirectoryName Name of the directory * @return a ShareDirectoryAsyncClient that interacts with the specified directory + * @throws IllegalStateException If this client is addressed by file ID. */ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) { + ShareErrors.validatePathOperation(fileId, "getSubdirectoryClient"); StringBuilder directoryPathBuilder = new StringBuilder().append(this.directoryPath); if (!this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/")) { directoryPathBuilder.append("/"); @@ -225,6 +234,7 @@ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) * * * @return Flag indicating existence of the directory. + * @throws IllegalStateException If this client is addressed by file ID, emitted through the returned publisher. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono exists() { @@ -243,6 +253,7 @@ public Mono exists() { * * * @return Flag indicating existence of the directory. + * @throws IllegalStateException If this client is addressed by file ID, emitted through the returned publisher. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> existsWithResponse() { @@ -254,6 +265,7 @@ public Mono> existsWithResponse() { } Mono> existsWithResponse(Context context) { + ShareErrors.validatePathOperation(fileId, "exists"); return this.getPropertiesWithResponse(context) .map(cp -> (Response) new SimpleResponse<>(cp, true)) .onErrorResume(ModelHelper::checkDoesNotExistStatusCode, t -> { @@ -379,6 +391,7 @@ public Mono> createWithResponse(ShareDirectoryCreat Mono> createWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Map metadata, FilePropertySemantics filePropertySemantics, Context context) { + ShareErrors.validatePathOperation(fileId, "create"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -546,6 +559,7 @@ public Mono> deleteWithResponse() { } Mono> deleteWithResponse(Context context) { + ShareErrors.validatePathOperation(fileId, "delete"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponseAsync(shareName, directoryPath, null, context); @@ -798,6 +812,7 @@ public Mono> setPropertiesWithResponse(ShareDirecto Mono> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission, FilePermissionFormat filePermissionFormat, FilePosixProperties posixProperties, Context context) { + ShareErrors.validatePathOperation(fileId, "setProperties"); context = context == null ? Context.NONE : context; smbProperties = smbProperties == null ? new FileSmbProperties() : smbProperties; posixProperties = posixProperties == null ? new FilePosixProperties() : posixProperties; @@ -898,6 +913,7 @@ public Mono> setMetadataWithResponse(Map Mono> setMetadataWithResponse(Map metadata, Context context) { + ShareErrors.validatePathOperation(fileId, "setMetadata"); context = context == null ? Context.NONE : context; return azureFileStorageClient.getDirectories() .setMetadataWithResponseAsync(shareName, directoryPath, null, metadata, context) @@ -1005,6 +1021,7 @@ public PagedFlux listFilesAndDirectories(ShareListFilesAndDirecto PagedFlux listFilesAndDirectoriesWithOptionalTimeout(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "listFilesAndDirectories"); final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; @@ -1059,6 +1076,7 @@ public PagedFlux listHandles(Integer maxResultPerPage, boolean recur PagedFlux listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "listHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .listHandlesWithResponseAsync(shareName, directoryPath, marker, maxResultPerPage, null, snapshot, @@ -1131,6 +1149,7 @@ public Mono> forceCloseHandleWithResponse(String hand } Mono> forceCloseHandleWithResponse(String handleId, Context context) { + ShareErrors.validatePathOperation(fileId, "forceCloseHandle"); return this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, handleId, null, null, snapshot, false, context) @@ -1174,6 +1193,7 @@ public Mono forceCloseAllHandles(boolean recursive) { } PagedFlux forceCloseAllHandlesWithTimeout(boolean recursive, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "forceCloseAllHandles"); Function>> retriever = marker -> StorageImplUtils .applyOptionalTimeout(this.azureFileStorageClient.getDirectories() .forceCloseHandlesWithResponseAsync(shareName, directoryPath, "*", null, marker, snapshot, recursive, @@ -1255,6 +1275,7 @@ public Mono> renameWithResponse(ShareFileRen } Mono> renameWithResponse(ShareFileRenameOptions options, Context context) { + ShareErrors.validatePathOperation(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); context = context == null ? Context.NONE : context; @@ -2169,6 +2190,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + ShareErrors.validatePathOperation(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 5c636b03f336f..3ddb2965955e3 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -23,6 +23,7 @@ import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.implementation.models.CopyFileSmbInfo; import com.azure.storage.file.share.implementation.models.DestinationLeaseAccessConditions; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; @@ -73,6 +74,9 @@ * Service. Operations allowed by the client are creating, deleting and listing subdirectory and file, retrieving * properties, setting metadata and list or force close handles of the directory or file. * + *

Clients addressed by file ID support property retrieval. Other service operations, including existence checks, + * and child-client creation throw {@link IllegalStateException}. Use a path-addressed client for these operations.

+ * *

Instantiating an Synchronous Directory Client

* * @@ -185,8 +189,10 @@ public ShareServiceVersion getServiceVersion() { * * @param fileName Name of the file * @return a ShareFileClient that interacts with the specified share + * @throws IllegalStateException If this client is addressed by file ID. */ public ShareFileClient getFileClient(String fileName) { + ShareErrors.validatePathOperation(fileId, "getFileClient"); String filePath = directoryPath + "/" + fileName; // Support for root directory if (directoryPath.isEmpty()) { @@ -205,8 +211,10 @@ public ShareFileClient getFileClient(String fileName) { * * @param subdirectoryName Name of the directory * @return a ShareDirectoryClient that interacts with the specified directory + * @throws IllegalStateException If this client is addressed by file ID. */ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { + ShareErrors.validatePathOperation(fileId, "getSubdirectoryClient"); boolean needPathDelimiter = !this.directoryPath.isEmpty() && !this.directoryPath.endsWith("/"); String subDirectoryPath = this.directoryPath + (needPathDelimiter ? "/" : "") + subdirectoryName; return new ShareDirectoryClient(azureFileStorageClient, shareName, subDirectoryPath, snapshot, accountName, @@ -225,6 +233,7 @@ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { * * * @return Flag indicating existence of the directory. + * @throws IllegalStateException If this client is addressed by file ID. */ @ServiceMethod(returns = ReturnType.SINGLE) public Boolean exists() { @@ -246,9 +255,11 @@ public Boolean exists() { * @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised. * @param context Additional context that is passed through the Http pipeline during the service call. * @return Flag indicating existence of the directory. + * @throws IllegalStateException If this client is addressed by file ID. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response existsWithResponse(Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "exists"); try { Response response = getPropertiesWithResponse(timeout, context); return new SimpleResponse<>(response, true); @@ -363,6 +374,7 @@ public Response createWithResponse(FileSmbProperties smbProp @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(ShareDirectoryCreateOptions options, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "create"); Context finalContext = context == null ? Context.NONE : context; ShareDirectoryCreateOptions finalOptions = options == null ? new ShareDirectoryCreateOptions() : options; @@ -515,6 +527,7 @@ public void delete() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "delete"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() .deleteNoCustomHeadersWithResponse(shareName, directoryPath, null, finalContext); @@ -747,6 +760,7 @@ public Response setPropertiesWithResponse(FileSmbProperties @ServiceMethod(returns = ReturnType.SINGLE) public Response setPropertiesWithResponse(ShareDirectorySetPropertiesOptions options, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "setProperties"); Context finalContext = context == null ? Context.NONE : context; ShareDirectorySetPropertiesOptions finalOptions = options == null ? new ShareDirectorySetPropertiesOptions() : options; @@ -854,6 +868,7 @@ public ShareDirectorySetMetadataInfo setMetadata(Map metadata) { @ServiceMethod(returns = ReturnType.SINGLE) public Response setMetadataWithResponse(Map metadata, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "setMetadata"); Context finalContext = context == null ? Context.NONE : context; Callable> operation = () -> this.azureFileStorageClient.getDirectories() @@ -964,6 +979,7 @@ public PagedIterable listFilesAndDirectories(String prefix, Integ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "listFilesAndDirectories"); Context finalContext = context == null ? Context.NONE : context; final ShareListFilesAndDirectoriesOptions modifiedOptions @@ -1024,6 +1040,7 @@ public PagedIterable listHandles(Integer maxResultsPerPage, boolean PagedIterable listHandlesWithOptionalTimeout(Integer maxResultPerPage, boolean recursive, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "listHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { Callable> operation @@ -1100,6 +1117,7 @@ public CloseHandlesInfo forceCloseHandle(String handleId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response forceCloseHandleWithResponse(String handleId, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "forceCloseHandle"); Context finalContext = context == null ? Context.NONE : context; Callable> operation @@ -1143,6 +1161,7 @@ public Response forceCloseHandleWithResponse(String handleId, */ @ServiceMethod(returns = ReturnType.SINGLE) public CloseHandlesInfo forceCloseAllHandles(boolean recursive, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "forceCloseAllHandles"); Context finalContext = context == null ? Context.NONE : context; Function> retriever = (marker) -> { @@ -1229,6 +1248,7 @@ public ShareDirectoryClient rename(String destinationPath) { @ServiceMethod(returns = ReturnType.SINGLE) public Response renameWithResponse(ShareFileRenameOptions options, Duration timeout, Context context) { + ShareErrors.validatePathOperation(fileId, "rename"); StorageImplUtils.assertNotNull("options", options); Context finalContext = context == null ? Context.NONE : context; @@ -2064,6 +2084,7 @@ public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatur @Deprecated public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context) { + ShareErrors.validatePathOperation(fileId, "generateSas"); return new ShareSasImplUtil(shareServiceSasSignatureValues, getShareName(), getDirectoryPath()) .generateSas(SasImplUtils.extractSharedKeyCredential(getHttpPipeline()), stringToSignHandler, context); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index 80696b9d67d65..a68d702a16686 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -2719,6 +2719,7 @@ Mono> clearRangeWithResponse(long length, long off * @param uploadFilePath The path where store the source file to upload * @return An empty response. * @throws UncheckedIOException If an I/O error occurs. + * @throws IllegalStateException If this client is addressed by file ID, emitted through the returned publisher. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono uploadFromFile(String uploadFilePath) { @@ -2752,10 +2753,12 @@ public Mono uploadFromFile(String uploadFilePath) { * @param requestConditions {@link ShareRequestConditions} * @return An empty response. * @throws UncheckedIOException If an I/O error occurs. + * @throws IllegalStateException If this client is addressed by file ID, emitted through the returned publisher. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono uploadFromFile(String uploadFilePath, ShareRequestConditions requestConditions) { try { + ShareErrors.validatePathOperation(fileId, "uploadFromFile"); return Mono.using(() -> channelSetup(uploadFilePath, StandardOpenOption.READ), channel -> Flux.fromIterable(sliceFile(uploadFilePath)) .flatMap(chunk -> uploadWithResponse( diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index f868a670055f6..535a262ce6dba 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -2525,6 +2525,7 @@ public Response clearRangeWithResponse(long length, long of * Azure Docs Upload.

* * @param uploadFilePath The path where store the source file to upload + * @throws IllegalStateException If this client is addressed by file ID. */ @ServiceMethod(returns = ReturnType.SINGLE) public void uploadFromFile(String uploadFilePath) { @@ -2552,6 +2553,7 @@ public void uploadFromFile(String uploadFilePath) { * * @param uploadFilePath The path where store the source file to upload * @param requestConditions {@link ShareRequestConditions} + * @throws IllegalStateException If this client is addressed by file ID. */ @ServiceMethod(returns = ReturnType.SINGLE) public void uploadFromFile(String uploadFilePath, ShareRequestConditions requestConditions) { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 0276b6de89413..4985aac3c6abe 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -155,7 +155,7 @@ public void directoryPropertiesByFileId(boolean snapshot) { actual.getSmbProperties().getFileCreationTime()); assertEquals(expected.getSmbProperties().getFileLastWriteTime(), actual.getSmbProperties().getFileLastWriteTime()); - assertTrue(directoryClient.exists()); + assertThrows(IllegalStateException.class, directoryClient::exists); } @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @@ -210,6 +210,71 @@ public void directoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); } + @DoNotRecord + @Tag("file-id-mock") + @Test + public void directoryFileIdClientsRejectPathOperations() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Path operations must be rejected before sending a request."); + }).build(); + ShareDirectoryClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + IllegalStateException existsException = assertThrows(IllegalStateException.class, directoryClient::exists); + assertEquals("exists is not supported for a file-ID-addressed client.", existsException.getMessage()); + assertThrows(IllegalStateException.class, () -> directoryClient.existsWithResponse(null, Context.NONE)); + IllegalStateException exception + = assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); + assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); + assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); + assertThrows(IllegalStateException.class, directoryClient::create); + assertThrows(IllegalStateException.class, directoryClient::createIfNotExists); + assertThrows(IllegalStateException.class, directoryClient::delete); + assertThrows(IllegalStateException.class, directoryClient::deleteIfExists); + assertThrows(IllegalStateException.class, () -> directoryClient.setProperties(null, null)); + assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); + assertThrows(IllegalStateException.class, () -> directoryClient.listFilesAndDirectories().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> directoryClient.listHandles(null, true, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseHandle("handle")); + assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseAllHandles(true, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); + assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectory("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectoryIfNotExists("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectory("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectoryIfExists("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.createFile("child", 1024)); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteFile("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteFileIfExists("child")); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void directoryPathClientsAllowMutations(String path) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + assertEquals(HttpMethod.PUT, request.getHttpMethod()); + assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, Utility.urlDecode(request.getUrl().getPath())); + assertFalse(request.getUrl().getQuery().contains("fileid=")); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory") + .set(HttpHeaderName.fromString("x-ms-request-server-encrypted"), "true"))); + }).build(); + ShareDirectoryClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClient(path); + + directoryClient.setMetadata(Collections.singletonMap("key", "value")); + assertEquals((path.isEmpty() ? "" : path + "/") + "child", + directoryClient.getFileClient("child").getFilePath()); + } + @DoNotRecord @Tag("file-id-mock") @ParameterizedTest @@ -282,6 +347,8 @@ public void directoryPropertiesUsePath(String path) { Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); + assertTrue(directoryClient.exists()); + assertTrue(directoryClient.existsWithResponse(null, Context.NONE).getValue()); } @DoNotRecord diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 1c4516bf31290..e81e2f28265b3 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -146,7 +146,7 @@ public void asyncDirectoryPropertiesByFileId(boolean snapshot) { assertEquals(expected.getSmbProperties().getFileLastWriteTime(), actual.getSmbProperties().getFileLastWriteTime()); }).verifyComplete(); - StepVerifier.create(directoryClient.exists()).expectNext(true).verifyComplete(); + StepVerifier.create(directoryClient.exists()).verifyError(IllegalStateException.class); } @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @@ -207,6 +207,76 @@ public void asyncDirectoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) }).verifyComplete(); } + @DoNotRecord + @Tag("file-id-mock") + @Test + public void asyncDirectoryFileIdClientsRejectPathOperations() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Path operations must be rejected before sending a request."); + }).build(); + ShareDirectoryAsyncClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + StepVerifier.create(directoryClient.exists()).verifyErrorSatisfies(error -> { + assertInstanceOf(IllegalStateException.class, error); + assertEquals("exists is not supported for a file-ID-addressed client.", error.getMessage()); + }); + StepVerifier.create(directoryClient.existsWithResponse()).verifyError(IllegalStateException.class); + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); + assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); + StepVerifier.create(directoryClient.create()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createIfNotExists()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.delete()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteIfExists()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.setProperties(null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.setMetadata(null)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.listFilesAndDirectories()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.listHandles(null, true)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.forceCloseAllHandles(true)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.rename("destination")).verifyError(IllegalStateException.class); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + StepVerifier.create(directoryClient.createSubdirectory("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createSubdirectoryIfNotExists("child")) + .verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteSubdirectory("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteSubdirectoryIfExists("child")) + .verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createFile("child", 1024)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteFile("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteFileIfExists("child")).verifyError(IllegalStateException.class); + } + + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(strings = { "", "parent/directory" }) + public void asyncDirectoryPathClientsAllowMutations(String path) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + assertEquals(HttpMethod.PUT, request.getHttpMethod()); + assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, Utility.urlDecode(request.getUrl().getPath())); + assertFalse(request.getUrl().getQuery().contains("fileid=")); + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory") + .set(HttpHeaderName.fromString("x-ms-request-server-encrypted"), "true"))); + }).build(); + ShareDirectoryAsyncClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClient(path); + + StepVerifier.create(directoryClient.setMetadata(Collections.singletonMap("key", "value"))) + .expectNextCount(1) + .verifyComplete(); + assertEquals((path.isEmpty() ? "" : path + "/") + "child", + directoryClient.getFileClient("child").getFilePath()); + } + @DoNotRecord @Tag("file-id-mock") @ParameterizedTest @@ -279,6 +349,10 @@ public void asyncDirectoryPropertiesUsePath(String path) { Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); + StepVerifier.create(directoryClient.exists()).expectNext(true).verifyComplete(); + StepVerifier.create(directoryClient.existsWithResponse()) + .assertNext(response -> assertTrue(response.getValue())) + .verifyComplete(); } @DoNotRecord diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index 45f39b9a2109c..e2c88396422ec 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -323,6 +323,72 @@ public void fileIdClientsRejectPathOperations() { Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination")); Assertions.assertThrows(IllegalStateException.class, fileClient::getFileOutputStream); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); + assertThrows(IllegalStateException.class, () -> fileClient.existsWithResponse(null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.createWithResponse(new ShareFileCreateOptions(1024), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.deleteWithResponse(null, null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::deleteIfExists); + assertThrows(IllegalStateException.class, + () -> fileClient.deleteIfExistsWithResponse(null, null, Context.NONE)); + String sourceUrl = FileIdTestHelper.ENDPOINT + "/share/source"; + assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null).poll()); + assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null).poll()); + assertThrows(IllegalStateException.class, () -> fileClient.abortCopy("copy-id")); + assertThrows(IllegalStateException.class, + () -> fileClient.abortCopyWithResponse("copy-id", null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.setProperties(1024, null, null, null)); + assertThrows(IllegalStateException.class, + () -> fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024), null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.setMetadataWithResponse(null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)); + assertThrows(IllegalStateException.class, () -> fileClient + .uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.clearRange(1)); + assertThrows(IllegalStateException.class, + () -> fileClient.clearRangeWithResponse(1, 0, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.listRanges().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listRanges(new ShareFileRange(0, 0L), null, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listRangesDiff("snapshot")); + assertThrows(IllegalStateException.class, () -> fileClient + .listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.listAllRanges().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listAllRanges(new ShareFileListRangesOptions(), null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listAllRangesDiff("snapshot").iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE) + .iterator() + .hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listHandles().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listHandles(1, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.forceCloseHandle("handle")); + assertThrows(IllegalStateException.class, + () -> fileClient.forceCloseHandleWithResponse("handle", null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles(null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.renameWithResponse(new ShareFileRenameOptions("destination"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.createHardLink("target")); + assertThrows(IllegalStateException.class, () -> fileClient + .createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.createSymbolicLink("target")); + assertThrows(IllegalStateException.class, () -> fileClient + .createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"), null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::getSymbolicLink); + assertThrows(IllegalStateException.class, () -> fileClient.getSymbolicLinkWithResponse(null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); + assertThrows(IllegalStateException.class, + () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::openInputStream); + assertThrows(IllegalStateException.class, () -> fileClient.openInputStream(new ShareFileRange(0, 0L))); + assertThrows(IllegalStateException.class, () -> fileClient.getFileOutputStream(0)); + assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelRead(null)); + assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelWrite(null)); IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks()); Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); @@ -331,6 +397,58 @@ public void fileIdClientsRejectPathOperations() { Assertions.assertFalse(requestSent.get()); } + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(ints = { -1, 0, 3 }) + public void fileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) throws IOException { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("File-ID transfers must not send a request."); + }).build(); + ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .buildFileClient(); + InputStream input = new InputStream() { + @Override + public int read() { + throw new AssertionError("Rejected uploads must not read input."); + } + }; + assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1)); + assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1, new ParallelTransferOptions())); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadWithResponse(input, 1, 0L, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadWithResponse(new ShareFileUploadOptions(input, 1), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadRange(input, 1)); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1), null, Context.NONE)); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + assertThrows(IllegalStateException.class, () -> fileClient.download(output)); + assertThrows(IllegalStateException.class, + () -> fileClient.downloadWithResponse(output, new ShareFileDownloadOptions(), null, Context.NONE)); + assertEquals(0, output.size()); + + Path path = directory.resolve("transfer"); + byte[] content = new byte[Math.max(fileSize, 0)]; + Arrays.fill(content, (byte) 42); + if (fileSize >= 0) { + Files.write(path, content); + } + assertThrows(IllegalStateException.class, () -> fileClient.downloadToFile(path.toString())); + assertThrows(IllegalStateException.class, + () -> fileClient.downloadToFileWithResponse(path.toString(), null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString())); + assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString(), null)); + if (fileSize < 0) { + assertFalse(Files.exists(path)); + } else { + assertArrayEquals(content, Files.readAllBytes(path)); + } + } + @DoNotRecord @Tag("file-id-mock") @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 859a80e6f77e0..2f47373872c7e 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -15,11 +15,13 @@ import com.azure.core.test.TestMode; import com.azure.core.test.http.MockHttpResponse; import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; import com.azure.core.util.FluxUtil; import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollerFlux; import com.azure.storage.blob.BlobServiceVersion; +import com.azure.storage.common.ParallelTransferOptions; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; import com.azure.storage.common.test.shared.extensions.LiveOnly; @@ -51,6 +53,7 @@ import com.azure.storage.file.share.models.ShareFileRangeItem; import com.azure.storage.file.share.models.ShareFileSymbolicLinkInfo; import com.azure.storage.file.share.models.ShareFileUploadInfo; +import com.azure.storage.file.share.models.ShareFileUploadOptions; import com.azure.storage.file.share.models.ShareFileUploadRangeOptions; import com.azure.storage.file.share.models.ShareProtocols; import com.azure.storage.file.share.models.ShareRequestConditions; @@ -62,10 +65,12 @@ import com.azure.storage.file.share.options.ShareFileCreateHardLinkOptions; import com.azure.storage.file.share.options.ShareFileCreateOptions; import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; +import com.azure.storage.file.share.options.ShareFileDownloadOptions; import com.azure.storage.file.share.options.ShareFileListRangesDiffOptions; import com.azure.storage.file.share.options.ShareFileListRangesOptions; import com.azure.storage.file.share.options.ShareFileRenameOptions; import com.azure.storage.file.share.options.ShareFileSetPropertiesOptions; +import com.azure.storage.file.share.options.ShareFileUploadRangeFromUrlOptions; import com.azure.storage.file.share.sas.ShareFileSasPermission; import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues; import com.azure.storage.file.share.specialized.ShareLeaseAsyncClient; @@ -304,12 +309,112 @@ public void asyncFileIdClientsRejectPathOperations() { Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null).block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination").block()); Assertions.assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles().block()); + StepVerifier.create(fileClient.existsWithResponse()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createWithResponse(new ShareFileCreateOptions(1024))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteWithResponse(null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteIfExists()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteIfExistsWithResponse(null)).verifyError(IllegalStateException.class); + String sourceUrl = FileIdTestHelper.ENDPOINT + "/share/source"; + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null)); + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null)); + StepVerifier.create(fileClient.abortCopy("copy-id")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.abortCopyWithResponse("copy-id", null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setProperties(1024, null, null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setMetadataWithResponse(null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)).verifyError(IllegalStateException.class); + StepVerifier + .create(fileClient.uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.clearRange(1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.clearRangeWithResponse(1, 0, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRanges(new ShareFileRange(0, 0L), null)) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRangesDiff("snapshot")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRanges()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRanges(new ShareFileListRangesOptions())) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRangesDiff("snapshot")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listHandles()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listHandles(1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.forceCloseHandleWithResponse("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.renameWithResponse(new ShareFileRenameOptions("destination"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createHardLink("target")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createSymbolicLink("target")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.getSymbolicLink()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.getSymbolicLinkWithResponse()).verifyError(IllegalStateException.class); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks().block()); Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); Assertions.assertFalse(requestSent.get()); } + @DoNotRecord + @Tag("file-id-mock") + @ParameterizedTest + @ValueSource(ints = { -1, 0, 3 }) + public void asyncFileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) + throws IOException { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("File-ID transfers must not send a request."); + }).build(); + ShareFileAsyncClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .buildFileAsyncClient(); + Flux input = Flux.defer(() -> { + throw new AssertionError("Rejected uploads must not subscribe to input."); + }); + StepVerifier.create(fileClient.upload(input, 1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.upload(input, new ParallelTransferOptions())) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadWithResponse(input, 1, 0L, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadWithResponse(new ShareFileUploadOptions(input))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRange(input, 1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.downloadWithResponse(new ShareFileDownloadOptions())) + .verifyError(IllegalStateException.class); + + Path path = directory.resolve("transfer"); + byte[] content = new byte[Math.max(fileSize, 0)]; + Arrays.fill(content, (byte) 42); + if (fileSize >= 0) { + Files.write(path, content); + } + StepVerifier.create(fileClient.downloadToFile(path.toString())).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.downloadToFileWithResponse(path.toString(), null, null)) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadFromFile(path.toString())).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadFromFile(path.toString(), null)).verifyError(IllegalStateException.class); + if (fileSize < 0) { + assertFalse(Files.exists(path)); + } else { + assertArrayEquals(content, Files.readAllBytes(path)); + } + } + @Test public void createFile() { StepVerifier.create(primaryFileAsyncClient.createWithResponse(1024, null, null, null, null)) From 4a6f79333a0c0391c994b9411da8bcc1ce8bdf8f Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 6 Oct 2026 21:53:41 -0400 Subject: [PATCH 22/39] move unsupported operations tests into a separate file --- .../storage/file/share/DirectoryApiTests.java | 71 --- .../file/share/DirectoryAsyncApiTests.java | 74 --- .../storage/file/share/FileApiTests.java | 132 +---- .../storage/file/share/FileAsyncApiTests.java | 120 +---- .../FileIdUnsupportedOperationsTests.java | 466 ++++++++++++++++++ 5 files changed, 468 insertions(+), 395 deletions(-) create mode 100644 sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 4985aac3c6abe..4bb4562a502f2 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -155,7 +155,6 @@ public void directoryPropertiesByFileId(boolean snapshot) { actual.getSmbProperties().getFileCreationTime()); assertEquals(expected.getSmbProperties().getFileLastWriteTime(), actual.getSmbProperties().getFileLastWriteTime()); - assertThrows(IllegalStateException.class, directoryClient::exists); } @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @@ -210,48 +209,6 @@ public void directoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); } - @DoNotRecord - @Tag("file-id-mock") - @Test - public void directoryFileIdClientsRejectPathOperations() { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - throw new AssertionError("Path operations must be rejected before sending a request."); - }).build(); - ShareDirectoryClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME) - .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); - - IllegalStateException existsException = assertThrows(IllegalStateException.class, directoryClient::exists); - assertEquals("exists is not supported for a file-ID-addressed client.", existsException.getMessage()); - assertThrows(IllegalStateException.class, () -> directoryClient.existsWithResponse(null, Context.NONE)); - IllegalStateException exception - = assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); - assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); - assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); - assertThrows(IllegalStateException.class, directoryClient::create); - assertThrows(IllegalStateException.class, directoryClient::createIfNotExists); - assertThrows(IllegalStateException.class, directoryClient::delete); - assertThrows(IllegalStateException.class, directoryClient::deleteIfExists); - assertThrows(IllegalStateException.class, () -> directoryClient.setProperties(null, null)); - assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); - assertThrows(IllegalStateException.class, () -> directoryClient.listFilesAndDirectories().iterator().hasNext()); - assertThrows(IllegalStateException.class, - () -> directoryClient.listHandles(null, true, null, Context.NONE).iterator().hasNext()); - assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseHandle("handle")); - assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseAllHandles(true, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); - assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); - assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectory("child")); - assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectoryIfNotExists("child")); - assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectory("child")); - assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectoryIfExists("child")); - assertThrows(IllegalStateException.class, () -> directoryClient.createFile("child", 1024)); - assertThrows(IllegalStateException.class, () -> directoryClient.deleteFile("child")); - assertThrows(IllegalStateException.class, () -> directoryClient.deleteFileIfExists("child")); - } - @DoNotRecord @Tag("file-id-mock") @ParameterizedTest @@ -351,34 +308,6 @@ public void directoryPropertiesUsePath(String path) { assertTrue(directoryClient.existsWithResponse(null, Context.NONE).getValue()); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void directoryClientBuilderRejectsFileId(boolean fromEndpoint) { - AtomicReference requestSent = new AtomicReference<>(false); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestSent.set(true); - return Mono.just(new MockHttpResponse(request, 200)); - }).build(); - - ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .pipeline(pipeline); - if (fromEndpoint) { - builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" - + FileIdTestHelper.FILE_ID); - } else { - builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); - } - IllegalStateException exception - = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryClient); - Assertions.assertEquals("buildDirectoryClient is not supported for a file-ID-addressed client.", - exception.getMessage()); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileClient().getFileId()); - Assertions.assertFalse(requestSent.get()); - } - @DoNotRecord @Tag("file-id-mock") @ParameterizedTest diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index e81e2f28265b3..2f3d3a4af2d6c 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -146,7 +146,6 @@ public void asyncDirectoryPropertiesByFileId(boolean snapshot) { assertEquals(expected.getSmbProperties().getFileLastWriteTime(), actual.getSmbProperties().getFileLastWriteTime()); }).verifyComplete(); - StepVerifier.create(directoryClient.exists()).verifyError(IllegalStateException.class); } @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @@ -207,51 +206,6 @@ public void asyncDirectoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) }).verifyComplete(); } - @DoNotRecord - @Tag("file-id-mock") - @Test - public void asyncDirectoryFileIdClientsRejectPathOperations() { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - throw new AssertionError("Path operations must be rejected before sending a request."); - }).build(); - ShareDirectoryAsyncClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildAsyncClient() - .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) - .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); - - StepVerifier.create(directoryClient.exists()).verifyErrorSatisfies(error -> { - assertInstanceOf(IllegalStateException.class, error); - assertEquals("exists is not supported for a file-ID-addressed client.", error.getMessage()); - }); - StepVerifier.create(directoryClient.existsWithResponse()).verifyError(IllegalStateException.class); - IllegalStateException exception - = Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); - assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); - StepVerifier.create(directoryClient.create()).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.createIfNotExists()).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.delete()).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.deleteIfExists()).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.setProperties(null, null)).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.setMetadata(null)).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.listFilesAndDirectories()).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.listHandles(null, true)).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.forceCloseAllHandles(true)).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.rename("destination")).verifyError(IllegalStateException.class); - Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); - StepVerifier.create(directoryClient.createSubdirectory("child")).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.createSubdirectoryIfNotExists("child")) - .verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.deleteSubdirectory("child")).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.deleteSubdirectoryIfExists("child")) - .verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.createFile("child", 1024)).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.deleteFile("child")).verifyError(IllegalStateException.class); - StepVerifier.create(directoryClient.deleteFileIfExists("child")).verifyError(IllegalStateException.class); - } - @DoNotRecord @Tag("file-id-mock") @ParameterizedTest @@ -355,34 +309,6 @@ public void asyncDirectoryPropertiesUsePath(String path) { .verifyComplete(); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void asyncDirectoryClientBuilderRejectsFileId(boolean fromEndpoint) { - AtomicReference requestSent = new AtomicReference<>(false); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - requestSent.set(true); - return Mono.just(new MockHttpResponse(request, 200)); - }).build(); - - ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .pipeline(pipeline); - if (fromEndpoint) { - builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" - + FileIdTestHelper.FILE_ID); - } else { - builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); - } - IllegalStateException exception - = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryAsyncClient); - Assertions.assertEquals("buildDirectoryAsyncClient is not supported for a file-ID-addressed client.", - exception.getMessage()); - Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileAsyncClient().getFileId()); - Assertions.assertFalse(requestSent.get()); - } - @DoNotRecord @Tag("file-id-mock") @ParameterizedTest diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index e2c88396422ec..baddc4f11a2bd 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -299,7 +299,7 @@ public void pathPropertiesRetainTimestampMapping(boolean directory) { @DoNotRecord @Tag("file-id-mock") @Test - public void fileIdClientsRejectPathOperations() { + public void fileClientFileIdValidation() { AtomicReference requestSent = new AtomicReference<>(false); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { requestSent.set(true); @@ -311,84 +311,6 @@ public void fileIdClientsRejectPathOperations() { .serviceVersion(ShareServiceVersion.V2027_03_07) .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME); - ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); - - Assertions.assertThrows(IllegalStateException.class, fileClient::exists); - IllegalStateException createException - = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024)); - Assertions.assertEquals("create is not supported for a file-ID-addressed client.", - createException.getMessage()); - Assertions.assertThrows(IllegalStateException.class, fileClient::delete); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null)); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination")); - Assertions.assertThrows(IllegalStateException.class, fileClient::getFileOutputStream); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); - assertThrows(IllegalStateException.class, () -> fileClient.existsWithResponse(null, Context.NONE)); - assertThrows(IllegalStateException.class, - () -> fileClient.createWithResponse(new ShareFileCreateOptions(1024), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.deleteWithResponse(null, null, Context.NONE)); - assertThrows(IllegalStateException.class, fileClient::deleteIfExists); - assertThrows(IllegalStateException.class, - () -> fileClient.deleteIfExistsWithResponse(null, null, Context.NONE)); - String sourceUrl = FileIdTestHelper.ENDPOINT + "/share/source"; - assertThrows(IllegalStateException.class, - () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null).poll()); - assertThrows(IllegalStateException.class, - () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null).poll()); - assertThrows(IllegalStateException.class, () -> fileClient.abortCopy("copy-id")); - assertThrows(IllegalStateException.class, - () -> fileClient.abortCopyWithResponse("copy-id", null, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.setProperties(1024, null, null, null)); - assertThrows(IllegalStateException.class, - () -> fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024), null, Context.NONE)); - assertThrows(IllegalStateException.class, - () -> fileClient.setMetadataWithResponse(null, null, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)); - assertThrows(IllegalStateException.class, () -> fileClient - .uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.clearRange(1)); - assertThrows(IllegalStateException.class, - () -> fileClient.clearRangeWithResponse(1, 0, null, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.listRanges().iterator().hasNext()); - assertThrows(IllegalStateException.class, - () -> fileClient.listRanges(new ShareFileRange(0, 0L), null, null, Context.NONE).iterator().hasNext()); - assertThrows(IllegalStateException.class, () -> fileClient.listRangesDiff("snapshot")); - assertThrows(IllegalStateException.class, () -> fileClient - .listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.listAllRanges().iterator().hasNext()); - assertThrows(IllegalStateException.class, - () -> fileClient.listAllRanges(new ShareFileListRangesOptions(), null, Context.NONE).iterator().hasNext()); - assertThrows(IllegalStateException.class, () -> fileClient.listAllRangesDiff("snapshot").iterator().hasNext()); - assertThrows(IllegalStateException.class, - () -> fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE) - .iterator() - .hasNext()); - assertThrows(IllegalStateException.class, () -> fileClient.listHandles().iterator().hasNext()); - assertThrows(IllegalStateException.class, - () -> fileClient.listHandles(1, null, Context.NONE).iterator().hasNext()); - assertThrows(IllegalStateException.class, () -> fileClient.forceCloseHandle("handle")); - assertThrows(IllegalStateException.class, - () -> fileClient.forceCloseHandleWithResponse("handle", null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles(null, Context.NONE)); - assertThrows(IllegalStateException.class, - () -> fileClient.renameWithResponse(new ShareFileRenameOptions("destination"), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.createHardLink("target")); - assertThrows(IllegalStateException.class, () -> fileClient - .createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.createSymbolicLink("target")); - assertThrows(IllegalStateException.class, () -> fileClient - .createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"), null, Context.NONE)); - assertThrows(IllegalStateException.class, fileClient::getSymbolicLink); - assertThrows(IllegalStateException.class, () -> fileClient.getSymbolicLinkWithResponse(null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); - assertThrows(IllegalStateException.class, - () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); - assertThrows(IllegalStateException.class, fileClient::openInputStream); - assertThrows(IllegalStateException.class, () -> fileClient.openInputStream(new ShareFileRange(0, 0L))); - assertThrows(IllegalStateException.class, () -> fileClient.getFileOutputStream(0)); - assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelRead(null)); - assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelWrite(null)); IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks()); Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); @@ -397,58 +319,6 @@ public void fileIdClientsRejectPathOperations() { Assertions.assertFalse(requestSent.get()); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(ints = { -1, 0, 3 }) - public void fileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) throws IOException { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - throw new AssertionError("File-ID transfers must not send a request."); - }).build(); - ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .buildFileClient(); - InputStream input = new InputStream() { - @Override - public int read() { - throw new AssertionError("Rejected uploads must not read input."); - } - }; - assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1)); - assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1, new ParallelTransferOptions())); - assertThrows(IllegalStateException.class, - () -> fileClient.uploadWithResponse(input, 1, 0L, null, null, Context.NONE)); - assertThrows(IllegalStateException.class, - () -> fileClient.uploadWithResponse(new ShareFileUploadOptions(input, 1), null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.uploadRange(input, 1)); - assertThrows(IllegalStateException.class, - () -> fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1), null, Context.NONE)); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - assertThrows(IllegalStateException.class, () -> fileClient.download(output)); - assertThrows(IllegalStateException.class, - () -> fileClient.downloadWithResponse(output, new ShareFileDownloadOptions(), null, Context.NONE)); - assertEquals(0, output.size()); - - Path path = directory.resolve("transfer"); - byte[] content = new byte[Math.max(fileSize, 0)]; - Arrays.fill(content, (byte) 42); - if (fileSize >= 0) { - Files.write(path, content); - } - assertThrows(IllegalStateException.class, () -> fileClient.downloadToFile(path.toString())); - assertThrows(IllegalStateException.class, - () -> fileClient.downloadToFileWithResponse(path.toString(), null, null, null, Context.NONE)); - assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString())); - assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString(), null)); - if (fileSize < 0) { - assertFalse(Files.exists(path)); - } else { - assertArrayEquals(content, Files.readAllBytes(path)); - } - } - @DoNotRecord @Tag("file-id-mock") @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 2f47373872c7e..4f10bb35ac71a 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -15,13 +15,11 @@ import com.azure.core.test.TestMode; import com.azure.core.test.http.MockHttpResponse; import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; import com.azure.core.util.FluxUtil; import com.azure.core.util.polling.LongRunningOperationStatus; import com.azure.core.util.polling.PollerFlux; import com.azure.storage.blob.BlobServiceVersion; -import com.azure.storage.common.ParallelTransferOptions; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; import com.azure.storage.common.test.shared.extensions.LiveOnly; @@ -53,7 +51,6 @@ import com.azure.storage.file.share.models.ShareFileRangeItem; import com.azure.storage.file.share.models.ShareFileSymbolicLinkInfo; import com.azure.storage.file.share.models.ShareFileUploadInfo; -import com.azure.storage.file.share.models.ShareFileUploadOptions; import com.azure.storage.file.share.models.ShareFileUploadRangeOptions; import com.azure.storage.file.share.models.ShareProtocols; import com.azure.storage.file.share.models.ShareRequestConditions; @@ -65,12 +62,10 @@ import com.azure.storage.file.share.options.ShareFileCreateHardLinkOptions; import com.azure.storage.file.share.options.ShareFileCreateOptions; import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; -import com.azure.storage.file.share.options.ShareFileDownloadOptions; import com.azure.storage.file.share.options.ShareFileListRangesDiffOptions; import com.azure.storage.file.share.options.ShareFileListRangesOptions; import com.azure.storage.file.share.options.ShareFileRenameOptions; import com.azure.storage.file.share.options.ShareFileSetPropertiesOptions; -import com.azure.storage.file.share.options.ShareFileUploadRangeFromUrlOptions; import com.azure.storage.file.share.sas.ShareFileSasPermission; import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues; import com.azure.storage.file.share.specialized.ShareLeaseAsyncClient; @@ -284,7 +279,7 @@ public void asyncPathPropertiesRetainTimestampMapping(boolean directory) { @DoNotRecord @Tag("file-id-mock") @Test - public void asyncFileIdClientsRejectPathOperations() { + public void asyncFileLinksRequireFileId() { AtomicReference requestSent = new AtomicReference<>(false); HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { requestSent.set(true); @@ -296,125 +291,12 @@ public void asyncFileIdClientsRejectPathOperations() { .serviceVersion(ShareServiceVersion.V2027_03_07) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - ShareFileAsyncClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); - - IllegalStateException createException - = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024).block()); - Assertions.assertEquals("create is not supported for a file-ID-addressed client.", - createException.getMessage()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.delete().block()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.exists().block()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.download().blockFirst()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.listRanges().blockFirst()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null).block()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination").block()); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles().block()); - StepVerifier.create(fileClient.existsWithResponse()).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.createWithResponse(new ShareFileCreateOptions(1024))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.deleteWithResponse(null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.deleteIfExists()).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.deleteIfExistsWithResponse(null)).verifyError(IllegalStateException.class); - String sourceUrl = FileIdTestHelper.ENDPOINT + "/share/source"; - Assertions.assertThrows(IllegalStateException.class, - () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null)); - Assertions.assertThrows(IllegalStateException.class, - () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null)); - StepVerifier.create(fileClient.abortCopy("copy-id")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.abortCopyWithResponse("copy-id", null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.setProperties(1024, null, null, null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.setMetadataWithResponse(null, null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)).verifyError(IllegalStateException.class); - StepVerifier - .create(fileClient.uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.clearRange(1)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.clearRangeWithResponse(1, 0, null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listRanges(new ShareFileRange(0, 0L), null)) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listRangesDiff("snapshot")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listAllRanges()).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listAllRanges(new ShareFileListRangesOptions())) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listAllRangesDiff("snapshot")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listHandles()).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.listHandles(1)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.forceCloseHandleWithResponse("handle")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.renameWithResponse(new ShareFileRenameOptions("destination"))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.createHardLink("target")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.createSymbolicLink("target")).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.getSymbolicLink()).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.getSymbolicLinkWithResponse()).verifyError(IllegalStateException.class); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); - Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); - Assertions.assertThrows(IllegalStateException.class, - () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); IllegalStateException linksException = Assertions.assertThrows(IllegalStateException.class, () -> testShareClient.getFileClient("path/file").getFileLinks().block()); Assertions.assertEquals("getFileLinks requires a file-ID-addressed client.", linksException.getMessage()); Assertions.assertFalse(requestSent.get()); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(ints = { -1, 0, 3 }) - public void asyncFileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) - throws IOException { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - throw new AssertionError("File-ID transfers must not send a request."); - }).build(); - ShareFileAsyncClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .shareName(FileIdTestHelper.SHARE_NAME) - .fileId(FileIdTestHelper.FILE_ID) - .pipeline(pipeline) - .buildFileAsyncClient(); - Flux input = Flux.defer(() -> { - throw new AssertionError("Rejected uploads must not subscribe to input."); - }); - StepVerifier.create(fileClient.upload(input, 1)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.upload(input, new ParallelTransferOptions())) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadWithResponse(input, 1, 0L, null)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadWithResponse(new ShareFileUploadOptions(input))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadRange(input, 1)).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1))) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.downloadWithResponse(new ShareFileDownloadOptions())) - .verifyError(IllegalStateException.class); - - Path path = directory.resolve("transfer"); - byte[] content = new byte[Math.max(fileSize, 0)]; - Arrays.fill(content, (byte) 42); - if (fileSize >= 0) { - Files.write(path, content); - } - StepVerifier.create(fileClient.downloadToFile(path.toString())).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.downloadToFileWithResponse(path.toString(), null, null)) - .verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadFromFile(path.toString())).verifyError(IllegalStateException.class); - StepVerifier.create(fileClient.uploadFromFile(path.toString(), null)).verifyError(IllegalStateException.class); - if (fileSize < 0) { - assertFalse(Files.exists(path)); - } else { - assertArrayEquals(content, Files.readAllBytes(path)); - } - } - @Test public void createFile() { StepVerifier.create(primaryFileAsyncClient.createWithResponse(1024, null, null, null, null)) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java new file mode 100644 index 0000000000000..044983ea059b3 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java @@ -0,0 +1,466 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.test.annotation.DoNotRecord; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.core.util.Context; +import com.azure.storage.common.ParallelTransferOptions; +import com.azure.storage.file.share.models.ShareFileRange; +import com.azure.storage.file.share.models.ShareFileUploadOptions; +import com.azure.storage.file.share.models.ShareFileUploadRangeOptions; +import com.azure.storage.file.share.options.ShareFileCopyOptions; +import com.azure.storage.file.share.options.ShareFileCreateHardLinkOptions; +import com.azure.storage.file.share.options.ShareFileCreateOptions; +import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; +import com.azure.storage.file.share.options.ShareFileDownloadOptions; +import com.azure.storage.file.share.options.ShareFileListRangesDiffOptions; +import com.azure.storage.file.share.options.ShareFileListRangesOptions; +import com.azure.storage.file.share.options.ShareFileRenameOptions; +import com.azure.storage.file.share.options.ShareFileSetPropertiesOptions; +import com.azure.storage.file.share.options.ShareFileUploadRangeFromUrlOptions; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicReference; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; + +// Temporary file-ID restrictions; remove the corresponding assertions as operations become supported. +@SuppressWarnings("deprecation") +class FileIdUnsupportedOperationsTests { + @DoNotRecord + @Test + public void fileIdClientsRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + Assertions.assertThrows(IllegalStateException.class, fileClient::exists); + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024)); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); + Assertions.assertThrows(IllegalStateException.class, fileClient::delete); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination")); + Assertions.assertThrows(IllegalStateException.class, fileClient::getFileOutputStream); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); + assertThrows(IllegalStateException.class, () -> fileClient.existsWithResponse(null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.createWithResponse(new ShareFileCreateOptions(1024), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.deleteWithResponse(null, null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::deleteIfExists); + assertThrows(IllegalStateException.class, + () -> fileClient.deleteIfExistsWithResponse(null, null, Context.NONE)); + String sourceUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/source"; + assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null).poll()); + assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null).poll()); + assertThrows(IllegalStateException.class, () -> fileClient.abortCopy("copy-id")); + assertThrows(IllegalStateException.class, + () -> fileClient.abortCopyWithResponse("copy-id", null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.setProperties(1024, null, null, null)); + assertThrows(IllegalStateException.class, + () -> fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024), null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.setMetadataWithResponse(null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)); + assertThrows(IllegalStateException.class, () -> fileClient + .uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.clearRange(1)); + assertThrows(IllegalStateException.class, + () -> fileClient.clearRangeWithResponse(1, 0, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.listRanges().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listRanges(new ShareFileRange(0, 0L), null, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listRangesDiff("snapshot")); + assertThrows(IllegalStateException.class, () -> fileClient + .listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.listAllRanges().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listAllRanges(new ShareFileListRangesOptions(), null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listAllRangesDiff("snapshot").iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"), null, Context.NONE) + .iterator() + .hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.listHandles().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> fileClient.listHandles(1, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> fileClient.forceCloseHandle("handle")); + assertThrows(IllegalStateException.class, + () -> fileClient.forceCloseHandleWithResponse("handle", null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles(null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.renameWithResponse(new ShareFileRenameOptions("destination"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.createHardLink("target")); + assertThrows(IllegalStateException.class, () -> fileClient + .createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.createSymbolicLink("target")); + assertThrows(IllegalStateException.class, () -> fileClient + .createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"), null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::getSymbolicLink); + assertThrows(IllegalStateException.class, () -> fileClient.getSymbolicLinkWithResponse(null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); + assertThrows(IllegalStateException.class, + () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, fileClient::openInputStream); + assertThrows(IllegalStateException.class, () -> fileClient.openInputStream(new ShareFileRange(0, 0L))); + assertThrows(IllegalStateException.class, () -> fileClient.getFileOutputStream(0)); + assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelRead(null)); + assertThrows(IllegalStateException.class, () -> fileClient.getFileSeekableByteChannelWrite(null)); + Assertions.assertFalse(requestSent.get()); + } + + @DoNotRecord + @Test + public void asyncFileIdClientsRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareFileAsyncClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + IllegalStateException createException + = Assertions.assertThrows(IllegalStateException.class, () -> fileClient.create(1024).block()); + Assertions.assertEquals("create is not supported for a file-ID-addressed client.", + createException.getMessage()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.delete().block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.exists().block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.download().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.listRanges().blockFirst()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.setMetadata(null).block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.rename("destination").block()); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.forceCloseAllHandles().block()); + StepVerifier.create(fileClient.existsWithResponse()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createWithResponse(new ShareFileCreateOptions(1024))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteWithResponse(null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteIfExists()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.deleteIfExistsWithResponse(null)).verifyError(IllegalStateException.class); + String sourceUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/source"; + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, Collections.emptyMap(), null)); + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.beginCopy(sourceUrl, new ShareFileCopyOptions(), null)); + StepVerifier.create(fileClient.abortCopy("copy-id")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.abortCopyWithResponse("copy-id", null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setProperties(1024, null, null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setPropertiesWithResponse(new ShareFileSetPropertiesOptions(1024))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.setMetadataWithResponse(null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRangeFromUrl(1, 0, 0, sourceUrl)).verifyError(IllegalStateException.class); + StepVerifier + .create(fileClient.uploadRangeFromUrlWithResponse(new ShareFileUploadRangeFromUrlOptions(1, sourceUrl))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.clearRange(1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.clearRangeWithResponse(1, 0, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRanges(new ShareFileRange(0, 0L), null)) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRangesDiff("snapshot")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("snapshot"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRanges()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRanges(new ShareFileListRangesOptions())) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRangesDiff("snapshot")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listAllRangesDiff(new ShareFileListRangesDiffOptions("snapshot"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listHandles()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.listHandles(1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.forceCloseHandleWithResponse("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.renameWithResponse(new ShareFileRenameOptions("destination"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createHardLink("target")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createHardLinkWithResponse(new ShareFileCreateHardLinkOptions("target"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createSymbolicLink("target")).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.createSymbolicLinkWithResponse(new ShareFileCreateSymbolicLinkOptions("target"))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.getSymbolicLink()).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.getSymbolicLinkWithResponse()).verifyError(IllegalStateException.class); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateSas(null, null, Context.NONE)); + Assertions.assertThrows(IllegalStateException.class, () -> fileClient.generateUserDelegationSas(null, null)); + Assertions.assertThrows(IllegalStateException.class, + () -> fileClient.generateUserDelegationSas(null, null, null, Context.NONE)); + Assertions.assertFalse(requestSent.get()); + } + + @DoNotRecord + @ParameterizedTest + @ValueSource(ints = { -1, 0, 3 }) + public void fileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) throws IOException { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("File-ID transfers must not send a request."); + }).build(); + ShareFileClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .buildFileClient(); + InputStream input = new InputStream() { + @Override + public int read() { + throw new AssertionError("Rejected uploads must not read input."); + } + }; + assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1)); + assertThrows(IllegalStateException.class, () -> fileClient.upload(input, 1, new ParallelTransferOptions())); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadWithResponse(input, 1, 0L, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadWithResponse(new ShareFileUploadOptions(input, 1), null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadRange(input, 1)); + assertThrows(IllegalStateException.class, + () -> fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1), null, Context.NONE)); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + assertThrows(IllegalStateException.class, () -> fileClient.download(output)); + assertThrows(IllegalStateException.class, + () -> fileClient.downloadWithResponse(output, new ShareFileDownloadOptions(), null, Context.NONE)); + assertEquals(0, output.size()); + + Path path = directory.resolve("transfer"); + byte[] content = new byte[Math.max(fileSize, 0)]; + Arrays.fill(content, (byte) 42); + if (fileSize >= 0) { + Files.write(path, content); + } + assertThrows(IllegalStateException.class, () -> fileClient.downloadToFile(path.toString())); + assertThrows(IllegalStateException.class, + () -> fileClient.downloadToFileWithResponse(path.toString(), null, null, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString())); + assertThrows(IllegalStateException.class, () -> fileClient.uploadFromFile(path.toString(), null)); + if (fileSize < 0) { + assertFalse(Files.exists(path)); + } else { + assertArrayEquals(content, Files.readAllBytes(path)); + } + } + + @DoNotRecord + @ParameterizedTest + @ValueSource(ints = { -1, 0, 3 }) + public void asyncFileIdTransfersRejectBeforeAccessingData(int fileSize, @TempDir Path directory) + throws IOException { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("File-ID transfers must not send a request."); + }).build(); + ShareFileAsyncClient fileClient = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .fileId(FileIdTestHelper.FILE_ID) + .pipeline(pipeline) + .buildFileAsyncClient(); + Flux input = Flux.defer(() -> { + throw new AssertionError("Rejected uploads must not subscribe to input."); + }); + StepVerifier.create(fileClient.upload(input, 1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.upload(input, new ParallelTransferOptions())) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadWithResponse(input, 1, 0L, null)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadWithResponse(new ShareFileUploadOptions(input))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRange(input, 1)).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadRangeWithResponse(new ShareFileUploadRangeOptions(input, 1))) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.downloadWithResponse(new ShareFileDownloadOptions())) + .verifyError(IllegalStateException.class); + + Path path = directory.resolve("transfer"); + byte[] content = new byte[Math.max(fileSize, 0)]; + Arrays.fill(content, (byte) 42); + if (fileSize >= 0) { + Files.write(path, content); + } + StepVerifier.create(fileClient.downloadToFile(path.toString())).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.downloadToFileWithResponse(path.toString(), null, null)) + .verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadFromFile(path.toString())).verifyError(IllegalStateException.class); + StepVerifier.create(fileClient.uploadFromFile(path.toString(), null)).verifyError(IllegalStateException.class); + if (fileSize < 0) { + assertFalse(Files.exists(path)); + } else { + assertArrayEquals(content, Files.readAllBytes(path)); + } + } + + @DoNotRecord + @Test + public void directoryFileIdClientsRejectPathOperations() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Path operations must be rejected before sending a request."); + }).build(); + ShareDirectoryClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + IllegalStateException existsException = assertThrows(IllegalStateException.class, directoryClient::exists); + assertEquals("exists is not supported for a file-ID-addressed client.", existsException.getMessage()); + assertThrows(IllegalStateException.class, () -> directoryClient.existsWithResponse(null, Context.NONE)); + IllegalStateException exception + = assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); + assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); + assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); + assertThrows(IllegalStateException.class, directoryClient::create); + assertThrows(IllegalStateException.class, directoryClient::createIfNotExists); + assertThrows(IllegalStateException.class, directoryClient::delete); + assertThrows(IllegalStateException.class, directoryClient::deleteIfExists); + assertThrows(IllegalStateException.class, () -> directoryClient.setProperties(null, null)); + assertThrows(IllegalStateException.class, () -> directoryClient.setMetadata(null)); + assertThrows(IllegalStateException.class, () -> directoryClient.listFilesAndDirectories().iterator().hasNext()); + assertThrows(IllegalStateException.class, + () -> directoryClient.listHandles(null, true, null, Context.NONE).iterator().hasNext()); + assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseHandle("handle")); + assertThrows(IllegalStateException.class, () -> directoryClient.forceCloseAllHandles(true, null, Context.NONE)); + assertThrows(IllegalStateException.class, () -> directoryClient.rename("destination")); + assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectory("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.createSubdirectoryIfNotExists("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectory("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteSubdirectoryIfExists("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.createFile("child", 1024)); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteFile("child")); + assertThrows(IllegalStateException.class, () -> directoryClient.deleteFileIfExists("child")); + } + + @DoNotRecord + @Test + public void asyncDirectoryFileIdClientsRejectPathOperations() { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + throw new AssertionError("Path operations must be rejected before sending a request."); + }).build(); + ShareDirectoryAsyncClient directoryClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) + .getDirectoryClientByFileId(FileIdTestHelper.FILE_ID); + + StepVerifier.create(directoryClient.exists()).verifyErrorSatisfies(error -> { + assertInstanceOf(IllegalStateException.class, error); + assertEquals("exists is not supported for a file-ID-addressed client.", error.getMessage()); + }); + StepVerifier.create(directoryClient.existsWithResponse()).verifyError(IllegalStateException.class); + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getFileClient("child")); + assertEquals("getFileClient is not supported for a file-ID-addressed client.", exception.getMessage()); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.getSubdirectoryClient("child")); + StepVerifier.create(directoryClient.create()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createIfNotExists()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.delete()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteIfExists()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.setProperties(null, null)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.setMetadata(null)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.listFilesAndDirectories()).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.listHandles(null, true)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.forceCloseHandle("handle")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.forceCloseAllHandles(true)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.rename("destination")).verifyError(IllegalStateException.class); + Assertions.assertThrows(IllegalStateException.class, () -> directoryClient.generateSas(null)); + StepVerifier.create(directoryClient.createSubdirectory("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createSubdirectoryIfNotExists("child")) + .verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteSubdirectory("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteSubdirectoryIfExists("child")) + .verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.createFile("child", 1024)).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteFile("child")).verifyError(IllegalStateException.class); + StepVerifier.create(directoryClient.deleteFileIfExists("child")).verifyError(IllegalStateException.class); + } + + @DoNotRecord + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void directoryClientBuilderRejectsFileId(boolean fromEndpoint) { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .pipeline(pipeline); + if (fromEndpoint) { + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" + + FileIdTestHelper.FILE_ID); + } else { + builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); + } + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryClient); + Assertions.assertEquals("buildDirectoryClient is not supported for a file-ID-addressed client.", + exception.getMessage()); + Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileClient().getFileId()); + Assertions.assertFalse(requestSent.get()); + } + + @DoNotRecord + @ParameterizedTest + @ValueSource(booleans = { false, true }) + public void asyncDirectoryClientBuilderRejectsFileId(boolean fromEndpoint) { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .shareName(FileIdTestHelper.SHARE_NAME) + .pipeline(pipeline); + if (fromEndpoint) { + builder.endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/directory?fileid=" + + FileIdTestHelper.FILE_ID); + } else { + builder.resourcePath("directory").fileId(FileIdTestHelper.FILE_ID); + } + IllegalStateException exception + = Assertions.assertThrows(IllegalStateException.class, builder::buildDirectoryAsyncClient); + Assertions.assertEquals("buildDirectoryAsyncClient is not supported for a file-ID-addressed client.", + exception.getMessage()); + Assertions.assertEquals(FileIdTestHelper.FILE_ID, builder.buildFileAsyncClient().getFileId()); + Assertions.assertFalse(requestSent.get()); + } +} From c9793c8185b59cf625e9e53b550ade5e0bd78ace Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 6 Oct 2026 22:02:13 -0400 Subject: [PATCH 23/39] remove redundant cases --- .../storage/file/share/DirectoryApiTests.java | 66 +++-------------- .../file/share/DirectoryAsyncApiTests.java | 70 +++---------------- .../storage/file/share/FileApiTests.java | 26 ------- .../storage/file/share/FileAsyncApiTests.java | 27 ------- 4 files changed, 16 insertions(+), 173 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 4bb4562a502f2..c87ec6315ae45 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -18,7 +18,6 @@ import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.Utility; import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.test.shared.extensions.LiveOnly; import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; @@ -72,7 +71,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; import reactor.core.publisher.Mono; @@ -170,21 +168,8 @@ public void directoryPropertiesByFileIdMapServiceErrors() { @Tag("file-id-mock") @ParameterizedTest @ValueSource(booleans = { false, true }) - public void directoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - assertEquals(HttpMethod.GET, request.getHttpMethod()); - assertEquals("/" + FileIdTestHelper.SHARE_NAME, request.getUrl().getPath()); - String query = request.getUrl().getQuery(); - assertTrue(query.contains("restype=directory")); - assertTrue(query.contains("fileid=" + FileIdTestHelper.FILE_ID)); - assertEquals(snapshot, query.contains("sharesnapshot=snapshot")); - return Mono.just(new MockHttpResponse(request, 200, - FileIdTestHelper.fileHeaders("directory") - .set(HttpHeaderName.fromString("x-ms-type"), "directory") - .set(HttpHeaderName.fromString("x-ms-server-encrypted"), "true"))); - }).build(); + public void directoryClientByFileIdUrl(boolean snapshot) { ShareClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) .serviceVersion(ShareServiceVersion.V2027_03_07) .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME); @@ -199,24 +184,15 @@ public void directoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + (snapshot ? "?sharesnapshot=snapshot&" : "?") + "fileid=" + FileIdTestHelper.FILE_ID, directoryClient.getDirectoryUrl()); - - ShareDirectoryProperties properties = directoryClient.getProperties(); - assertEquals("directory", properties.getFileName()); - assertEquals("value", properties.getMetadata().get("key")); - assertEquals("\"0x8DEAF1479E1C087\"", properties.getETag()); - assertEquals(OffsetDateTime.parse("2015-10-21T07:28:00Z"), properties.getLastModified()); - assertTrue(properties.isServerEncrypted()); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); } @DoNotRecord @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(strings = { "", "parent/directory" }) - public void directoryPathClientsAllowMutations(String path) { + @Test + public void rootDirectoryAllowsMetadataUpdates() { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { assertEquals(HttpMethod.PUT, request.getHttpMethod()); - assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, Utility.urlDecode(request.getUrl().getPath())); + assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/", request.getUrl().getPath()); assertFalse(request.getUrl().getQuery().contains("fileid=")); return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory") .set(HttpHeaderName.fromString("x-ms-request-server-encrypted"), "true"))); @@ -225,11 +201,9 @@ public void directoryPathClientsAllowMutations(String path) { .pipeline(pipeline) .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME) - .getDirectoryClient(path); + .getRootDirectoryClient(); directoryClient.setMetadata(Collections.singletonMap("key", "value")); - assertEquals((path.isEmpty() ? "" : path + "/") + "child", - directoryClient.getFileClient("child").getFilePath()); } @DoNotRecord @@ -274,16 +248,8 @@ public void directoryPropertiesWithoutFileName() { @Tag("file-id-mock") @ParameterizedTest @ValueSource(strings = { "", "parent/directory" }) - public void directoryPropertiesUsePath(String path) { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); - }).build(); - + public void directoryPathClientSnapshotUrls(String path) { ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) .serviceVersion(ShareServiceVersion.V2027_03_07) .buildClient() .getShareClient(FileIdTestHelper.SHARE_NAME); @@ -293,19 +259,10 @@ public void directoryPropertiesUsePath(String path) { Assertions.assertEquals( FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?sharesnapshot=snapshot", directoryClient.getDirectoryUrl()); - ShareDirectoryProperties properties = directoryClient.getProperties(); - Assertions.assertEquals("value", properties.getMetadata().get("key")); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertTrue(Utility.urlDecode(requestUrl.get()) - .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?")); - Assertions.assertTrue(requestUrl.get().contains("restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot")); - Assertions.assertFalse(requestUrl.get().contains("fileid=")); + assertEquals("", directoryClient.getFileId()); Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); - assertTrue(directoryClient.exists()); - assertTrue(directoryClient.existsWithResponse(null, Context.NONE).getValue()); } @DoNotRecord @@ -313,19 +270,12 @@ public void directoryPropertiesUsePath(String path) { @ParameterizedTest @ValueSource(strings = { "", "parent/directory" }) public void directoryClientBuilderClearsFileIdForPath(String path) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, - Utility.urlDecode(request.getUrl().getPath())); - Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); - }).build(); ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) - .pipeline(pipeline) .fileId(FileIdTestHelper.FILE_ID); ShareDirectoryClient directoryClient = builder.resourcePath(path).buildDirectoryClient(); Assertions.assertEquals(path, directoryClient.getDirectoryPath()); - FileIdTestHelper.assertSmbProperties(directoryClient.getProperties().getSmbProperties()); + assertEquals("", directoryClient.getFileId()); String expectedUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path; Assertions.assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); Assertions.assertEquals(expectedUrl + (path.isEmpty() ? "" : "/") + "file.txt", diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 2f3d3a4af2d6c..246cfc1c39107 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -15,7 +15,6 @@ import com.azure.storage.blob.BlobServiceVersion; import com.azure.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; -import com.azure.storage.common.Utility; import com.azure.storage.common.test.shared.extensions.LiveOnly; import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion; import com.azure.storage.file.share.models.FilePropertySemantics; @@ -64,7 +63,6 @@ import java.util.Map; import java.util.Objects; import java.util.Queue; -import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import static com.azure.storage.common.implementation.Constants.HeaderConstants.ERROR_CODE_HEADER_NAME; @@ -164,21 +162,8 @@ public void asyncDirectoryPropertiesByFileIdMapServiceErrors() { @Tag("file-id-mock") @ParameterizedTest @ValueSource(booleans = { false, true }) - public void asyncDirectoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - assertEquals(HttpMethod.GET, request.getHttpMethod()); - assertEquals("/" + FileIdTestHelper.SHARE_NAME, request.getUrl().getPath()); - String query = request.getUrl().getQuery(); - assertTrue(query.contains("restype=directory")); - assertTrue(query.contains("fileid=" + FileIdTestHelper.FILE_ID)); - assertEquals(snapshot, query.contains("sharesnapshot=snapshot")); - return Mono.just(new MockHttpResponse(request, 200, - FileIdTestHelper.fileHeaders("directory") - .set(HttpHeaderName.fromString("x-ms-type"), "directory") - .set(HttpHeaderName.fromString("x-ms-server-encrypted"), "true"))); - }).build(); + public void asyncDirectoryClientByFileIdUrl(boolean snapshot) { ShareAsyncClient source = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) .serviceVersion(ShareServiceVersion.V2027_03_07) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); @@ -195,25 +180,15 @@ public void asyncDirectoryPropertiesByFileIdRouteAndMapHeaders(boolean snapshot) FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + (snapshot ? "?sharesnapshot=snapshot&" : "?") + "fileid=" + FileIdTestHelper.FILE_ID, directoryClient.getDirectoryUrl()); - - StepVerifier.create(directoryClient.getProperties()).assertNext(properties -> { - assertEquals("directory", properties.getFileName()); - assertEquals("value", properties.getMetadata().get("key")); - assertEquals("\"0x8DEAF1479E1C087\"", properties.getETag()); - assertEquals(OffsetDateTime.parse("2015-10-21T07:28:00Z"), properties.getLastModified()); - assertTrue(properties.isServerEncrypted()); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - }).verifyComplete(); } @DoNotRecord @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(strings = { "", "parent/directory" }) - public void asyncDirectoryPathClientsAllowMutations(String path) { + @Test + public void asyncRootDirectoryAllowsMetadataUpdates() { HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { assertEquals(HttpMethod.PUT, request.getHttpMethod()); - assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, Utility.urlDecode(request.getUrl().getPath())); + assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/", request.getUrl().getPath()); assertFalse(request.getUrl().getQuery().contains("fileid=")); return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory") .set(HttpHeaderName.fromString("x-ms-request-server-encrypted"), "true"))); @@ -222,13 +197,11 @@ public void asyncDirectoryPathClientsAllowMutations(String path) { .pipeline(pipeline) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) - .getDirectoryClient(path); + .getRootDirectoryClient(); StepVerifier.create(directoryClient.setMetadata(Collections.singletonMap("key", "value"))) .expectNextCount(1) .verifyComplete(); - assertEquals((path.isEmpty() ? "" : path + "/") + "child", - directoryClient.getFileClient("child").getFilePath()); } @DoNotRecord @@ -272,16 +245,8 @@ public void asyncDirectoryPropertiesWithoutFileName() { @Tag("file-id-mock") @ParameterizedTest @ValueSource(strings = { "", "parent/directory" }) - public void asyncDirectoryPropertiesUsePath(String path) { - AtomicReference requestUrl = new AtomicReference<>(); - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals(HttpMethod.GET, request.getHttpMethod()); - requestUrl.set(request.getUrl().toString()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); - }).build(); - + public void asyncDirectoryPathClientSnapshotUrls(String path) { ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) .serviceVersion(ShareServiceVersion.V2027_03_07) .buildAsyncClient() .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); @@ -291,22 +256,10 @@ public void asyncDirectoryPropertiesUsePath(String path) { Assertions.assertEquals( FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?sharesnapshot=snapshot", directoryClient.getDirectoryUrl()); - ShareDirectoryProperties properties = directoryClient.getProperties().block(); - - Assertions.assertEquals("value", properties.getMetadata().get("key")); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertTrue(Utility.urlDecode(requestUrl.get()) - .startsWith(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path + "?")); - Assertions.assertTrue(requestUrl.get().contains("restype=directory")); - Assertions.assertTrue(requestUrl.get().contains("sharesnapshot=snapshot")); - Assertions.assertFalse(requestUrl.get().contains("fileid=")); + assertEquals("", directoryClient.getFileId()); Assertions.assertEquals(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + (path.isEmpty() ? "" : path + "/") + "child?sharesnapshot=snapshot", directoryClient.getSubdirectoryClient("child").getDirectoryUrl()); - StepVerifier.create(directoryClient.exists()).expectNext(true).verifyComplete(); - StepVerifier.create(directoryClient.existsWithResponse()) - .assertNext(response -> assertTrue(response.getValue())) - .verifyComplete(); } @DoNotRecord @@ -314,19 +267,12 @@ public void asyncDirectoryPropertiesUsePath(String path) { @ParameterizedTest @ValueSource(strings = { "", "parent/directory" }) public void asyncDirectoryClientBuilderClearsFileIdForPath(String path) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals("/" + FileIdTestHelper.SHARE_NAME + "/" + path, - Utility.urlDecode(request.getUrl().getPath())); - Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("directory"))); - }).build(); ShareFileClientBuilder builder = new ShareFileClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) .shareName(FileIdTestHelper.SHARE_NAME) - .pipeline(pipeline) .fileId(FileIdTestHelper.FILE_ID); ShareDirectoryAsyncClient directoryClient = builder.resourcePath(path).buildDirectoryAsyncClient(); Assertions.assertEquals(path, directoryClient.getDirectoryPath()); - FileIdTestHelper.assertSmbProperties(directoryClient.getProperties().block().getSmbProperties()); + assertEquals("", directoryClient.getFileId()); String expectedUrl = FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "/" + path; Assertions.assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); Assertions.assertEquals(expectedUrl + (path.isEmpty() ? "" : "/") + "file.txt", diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index baddc4f11a2bd..615161cfacd0f 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -270,32 +270,6 @@ public void propertiesByIdMapServiceErrors() { assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void pathPropertiesRetainTimestampMapping(boolean directory) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals("/share/item", request.getUrl().getPath()); - Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); - Assertions.assertEquals(directory ? HttpMethod.GET : HttpMethod.HEAD, request.getHttpMethod()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("item"))); - }).build(); - ShareClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildClient() - .getShareClient(FileIdTestHelper.SHARE_NAME); - - if (directory) { - FileIdTestHelper.assertSmbProperties(client.getDirectoryClient("item").getProperties().getSmbProperties()); - } else { - ShareFileProperties properties = client.getFileClient("item").getProperties(); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertEquals(1024, properties.getContentLength()); - Assertions.assertEquals("value", properties.getMetadata().get("key")); - } - } - @DoNotRecord @Tag("file-id-mock") @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 4f10bb35ac71a..2645132d25188 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -249,33 +249,6 @@ public void asyncPropertiesByIdMapServiceErrors() { assertEquals(ShareErrorCode.INVALID_QUERY_PARAMETER_VALUE, exception.getErrorCode()); } - @DoNotRecord - @Tag("file-id-mock") - @ParameterizedTest - @ValueSource(booleans = { false, true }) - public void asyncPathPropertiesRetainTimestampMapping(boolean directory) { - HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { - Assertions.assertEquals("/share/item", request.getUrl().getPath()); - Assertions.assertFalse(request.getUrl().toString().contains("fileid=")); - Assertions.assertEquals(directory ? HttpMethod.GET : HttpMethod.HEAD, request.getHttpMethod()); - return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("item"))); - }).build(); - ShareAsyncClient client = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) - .pipeline(pipeline) - .buildAsyncClient() - .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); - - if (directory) { - FileIdTestHelper - .assertSmbProperties(client.getDirectoryClient("item").getProperties().block().getSmbProperties()); - } else { - ShareFileProperties properties = client.getFileClient("item").getProperties().block(); - FileIdTestHelper.assertSmbProperties(properties.getSmbProperties()); - Assertions.assertEquals(1024, properties.getContentLength()); - Assertions.assertEquals("value", properties.getMetadata().get("key")); - } - } - @DoNotRecord @Tag("file-id-mock") @Test From 44dea7e68976caba54b80756ae9915024358b7e5 Mon Sep 17 00:00:00 2001 From: browndav Date: Fri, 9 Oct 2026 12:10:08 -0400 Subject: [PATCH 24/39] update javadocs to reflect smb vs file operations --- .../storage/file/share/ShareAsyncClient.java | 17 +++++++++++++++++ .../azure/storage/file/share/ShareClient.java | 17 +++++++++++++++++ .../file/share/ShareDirectoryAsyncClient.java | 5 +++++ .../file/share/ShareDirectoryClient.java | 5 +++++ .../file/share/ShareFileAsyncClient.java | 17 +++++++++++++---- .../storage/file/share/ShareFileClient.java | 19 ++++++++++++++----- .../file/share/ShareFileClientBuilder.java | 5 +++++ 7 files changed, 76 insertions(+), 9 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 bc27781f5c8b2..bfd25016a7a78 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 @@ -177,6 +177,14 @@ public ShareDirectoryAsyncClient getDirectoryClient(String directoryName) { /** * Creates a directory client that addresses a directory by its file ID. * + *

Call {@link ShareDirectoryAsyncClient#getProperties()} on the returned client to retrieve properties without + * knowing the directory path. Obtain the ID from {@link FileSmbProperties#getFileId()} in a path-based properties + * response. Other service operations require a path-addressed client.

+ * + *
{@code
+     * Mono properties = shareAsyncClient.getDirectoryClientByFileId(fileId).getProperties();
+     * }
+ * * @param fileId The file ID of the directory. * @return A client for interacting with the directory by ID. * @throws IllegalArgumentException If {@code fileId} is null or blank. @@ -204,6 +212,15 @@ public ShareFileAsyncClient getFileClient(String filePath) { /** * Creates a file client that addresses a file by its file ID. * + *

Call {@link ShareFileAsyncClient#getProperties()} on the returned client to retrieve properties without knowing + * the file path. Obtain the ID from {@link FileSmbProperties#getFileId()} in a path-based properties response. + * The returned client supports property retrieval and {@link ShareFileAsyncClient#getFileLinks()} (SMB only). + * Other service operations require a path-addressed client.

+ * + *
{@code
+     * Mono properties = shareAsyncClient.getFileClientByFileId(fileId).getProperties();
+     * }
+ * * @param fileId The file ID of the file. * @return A client for interacting with the file by ID. * @throws IllegalArgumentException If {@code fileId} is null or blank. diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java index bbb0428045448..cc7d1006acc00 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java @@ -184,6 +184,14 @@ public ShareDirectoryClient getDirectoryClient(String directoryName) { /** * Creates a directory client that addresses a directory by its file ID. * + *

Call {@link ShareDirectoryClient#getProperties()} on the returned client to retrieve properties without + * knowing the directory path. Obtain the ID from {@link FileSmbProperties#getFileId()} in a path-based properties + * response. Other service operations require a path-addressed client.

+ * + *
{@code
+     * ShareDirectoryProperties properties = shareClient.getDirectoryClientByFileId(fileId).getProperties();
+     * }
+ * * @param fileId The file ID of the directory. * @return A client for interacting with the directory by ID. * @throws IllegalArgumentException If {@code fileId} is null or blank. @@ -213,6 +221,15 @@ public ShareFileClient getFileClient(String filePath) { /** * Creates a file client that addresses a file by its file ID. * + *

Call {@link ShareFileClient#getProperties()} on the returned client to retrieve properties without knowing + * the file path. Obtain the ID from {@link FileSmbProperties#getFileId()} in a path-based properties response. + * The returned client supports property retrieval and {@link ShareFileClient#getFileLinks()} (SMB only). + * Other service operations require a path-addressed client.

+ * + *
{@code
+     * ShareFileProperties properties = shareClient.getFileClientByFileId(fileId).getProperties();
+     * }
+ * * @param fileId The file ID of the file. * @return A client for interacting with the file by ID. * @throws IllegalArgumentException If {@code fileId} is null or blank. diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index 763c36c23c4a0..73fe1e754028a 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -648,6 +648,11 @@ Mono> deleteIfExistsWithResponse(Context context) { * *

Retrieve directory properties

* + *

This operation accepts path-addressed and file-ID-addressed clients. To retrieve properties without knowing + * the directory path, use {@link ShareAsyncClient#getDirectoryClientByFileId(String)}. Service availability determines + * whether a file-ID request succeeds; the client does not check the share protocol. If the service does not + * support property retrieval by ID for the share, use a path-addressed client.

+ * * *
      * shareDirectoryAsyncClient.getProperties().subscribe(properties -> {
diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java
index 3ddb2965955e3..5486d21ee1d63 100644
--- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java
+++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java
@@ -612,6 +612,11 @@ public Response deleteIfExistsWithResponse(Duration timeout, Context co
      *
      * 

Retrieve directory properties

* + *

This operation accepts path-addressed and file-ID-addressed clients. To retrieve properties without knowing + * the directory path, use {@link ShareClient#getDirectoryClientByFileId(String)}. Service availability determines + * whether a file-ID request succeeds; the client does not check the share protocol. If the service does not + * support property retrieval by ID for the share, use a path-addressed client.

+ * * *
      * ShareDirectoryProperties response = shareDirectoryClient.getProperties();
diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java
index a68d702a16686..be329781a464e 100644
--- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java
+++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java
@@ -127,6 +127,10 @@
  * Service. Operations allowed by the client are creating, copying, uploading, downloading, deleting and listing on a
  * file, retrieving properties, setting metadata and list or force close handles of the file.
  *
+ * 

Use {@link ShareAsyncClient#getFileClientByFileId(String)} to retrieve properties without knowing the file path. + * File-ID clients support {@link #getProperties()} and {@link #getFileLinks()} (SMB only). + * Other service operations require a path-addressed client.

+ * *

Instantiating an Asynchronous File Client

* * @@ -244,7 +248,7 @@ AzureSasCredential getSasToken() { } /** - * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * * @return A response containing the file properties and hard links. */ @@ -254,7 +258,7 @@ public Mono> getFileLinksWithResponse() { } /** - * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * * @param requestConditions Conditions to apply to the request. * @return A response containing the file properties and hard links. @@ -278,7 +282,7 @@ Mono> getFileLinksWithResponse(ShareRequestConditions r } /** - * Gets the file links. + * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. * * @return The file properties and hard links. */ @@ -288,7 +292,7 @@ public Mono getFileLinks() { } /** - * Gets the file links. + * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. * * @param requestConditions Conditions to apply to the request. * @return The file properties and hard links. @@ -1530,6 +1534,11 @@ Mono> deleteIfExistsWithResponse(ShareRequestConditions reques * *

Retrieve file properties

* + *

This operation accepts path-addressed and file-ID-addressed clients. To address a file by ID, use + * {@link ShareAsyncClient#getFileClientByFileId(String)}. Service availability determines whether a file-ID request + * succeeds; the client does not check the share protocol. If the service does not support property retrieval by ID + * for the share, use a path-addressed client.

+ * * *
      * shareFileAsyncClient.getProperties()
diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java
index 535a262ce6dba..db123eec688e0 100644
--- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java
+++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java
@@ -123,6 +123,10 @@
  * This class provides a client that contains all the operations for interacting files under Azure Storage File Service.
  * Operations allowed by the client are creating, uploading, copying, listing, downloading, and deleting files.
  *
+ * 

Use {@link ShareClient#getFileClientByFileId(String)} to retrieve properties without knowing the file path. + * File-ID clients support {@link #getProperties()} and {@link #getFileLinks()} (SMB only). + * Other service operations require a path-addressed client.

+ * *

Instantiating a synchronous File Client

* * @@ -239,7 +243,7 @@ public ShareServiceVersion getServiceVersion() { } /** - * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * * @return A response containing the file properties and hard links. */ @@ -248,7 +252,7 @@ public Response getFileLinksWithResponse() { } /** - * Gets the hard links to this file. + * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * * @param requestConditions Conditions to apply to the request. * @return A response containing the file properties and hard links. @@ -258,7 +262,7 @@ public Response getFileLinksWithResponse(ShareRequestConditions } /** - * Gets the hard links to this file. This operation is available only for a file-ID-addressed client. + * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * * @param requestConditions Conditions to apply to the request. * @param timeout An optional timeout applied to the operation. @@ -279,7 +283,7 @@ public Response getFileLinksWithResponse(ShareRequestConditions } /** - * Gets the file links. + * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. * * @return The file properties and hard links. */ @@ -289,7 +293,7 @@ public ShareFileLinks getFileLinks() { } /** - * Gets the file links. + * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. * * @param requestConditions Conditions to apply to the request. * @return The file properties and hard links. @@ -1495,6 +1499,11 @@ public Response deleteIfExistsWithResponse(ShareRequestConditions reque * *

Retrieve file properties

* + *

This operation accepts path-addressed and file-ID-addressed clients. To address a file by ID, use + * {@link ShareClient#getFileClientByFileId(String)}. Service availability determines whether a file-ID request + * succeeds; the client does not check the share protocol. If the service does not support property retrieval by ID + * for the share, use a path-addressed client.

+ * * *
      * ShareFileProperties properties = fileClient.getProperties();
diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java
index 3e7c63e7a5fc7..7c37e593cc591 100644
--- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java
+++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java
@@ -383,6 +383,11 @@ public ShareFileClientBuilder shareName(String shareName) {
     /**
      * Sets the file ID used to address a file.
      *
+     * 

Call {@link ShareFileClient#getProperties()} or {@link ShareFileAsyncClient#getProperties()} on the + * resulting client to retrieve properties without supplying the file path. File-ID clients also support + * {@link ShareFileClient#getFileLinks()} and {@link ShareFileAsyncClient#getFileLinks()} (SMB only). + * Other service operations require a path-addressed client.

+ * *

Setting a file ID clears the resource path. The file ID can also be read from the {@code fileid} query * parameter when supplied in the endpoint. File IDs are supported only for file clients; building a directory * client with a file ID configured throws {@link IllegalStateException}. Use {@link #resourcePath(String)} to From a42179d80e17ba73f69870b4151b3af945c1d12e Mon Sep 17 00:00:00 2001 From: browndav Date: Tue, 13 Oct 2026 13:58:53 -0400 Subject: [PATCH 25/39] Revert "Storage - STG105 NFS List V2 Files and Directories (#50036)" This reverts commit 83dc6e28852ace9e902975682ab5510671ca56e2. --- .../azure-storage-file-share/CHANGELOG.md | 9 - .../azure-storage-file-share/assets.json | 2 +- .../file/share/ShareDirectoryAsyncClient.java | 18 +- .../file/share/ShareDirectoryClient.java | 18 +- .../ShareFileItemConstructorProxy.java | 88 ------ .../models/BlockDeviceItem.java | 268 ------------------ .../implementation/models/CharDeviceItem.java | 268 ------------------ .../implementation/models/DirectoryItem.java | 31 -- .../share/implementation/models/FifoItem.java | 205 -------------- .../share/implementation/models/FileItem.java | 63 ---- .../implementation/models/FileProperty.java | 93 ------ .../FilesAndDirectoriesListSegment.java | 177 ------------ .../InternalShareFileItemProperties.java | 49 ---- .../models/ListFilesIncludeType.java | 22 +- .../implementation/models/SocketItem.java | 205 -------------- .../implementation/models/SymLinkItem.java | 237 ---------------- .../implementation/util/ModelHelper.java | 134 ++------- .../file/share/models/NfsFileType.java | 39 +-- .../file/share/models/ShareFileItem.java | 81 +----- .../share/models/ShareFileItemProperties.java | 27 -- .../ShareListFilesAndDirectoriesOptions.java | 84 ------ .../storage/file/share/DirectoryApiTests.java | 146 ---------- .../file/share/DirectoryAsyncApiTests.java | 151 ---------- .../DirectoryListingDeserializationTests.java | 169 ----------- .../ListFilesAndDirectoriesResponse.xml | 121 -------- .../swagger/README.md | 2 +- .../main/java/ShareStorageCustomization.java | 8 - 27 files changed, 61 insertions(+), 2654 deletions(-) delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFileItemConstructorProxy.java delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/BlockDeviceItem.java delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/CharDeviceItem.java delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FifoItem.java delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SocketItem.java delete mode 100644 sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SymLinkItem.java delete mode 100644 sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryListingDeserializationTests.java delete mode 100644 sdk/storage/azure-storage-file-share/src/test/resources/testfiles/ListFilesAndDirectoriesResponse.xml diff --git a/sdk/storage/azure-storage-file-share/CHANGELOG.md b/sdk/storage/azure-storage-file-share/CHANGELOG.md index 4a0436ad7c62d..2a0f298b45393 100644 --- a/sdk/storage/azure-storage-file-share/CHANGELOG.md +++ b/sdk/storage/azure-storage-file-share/CHANGELOG.md @@ -3,15 +3,6 @@ ## 12.32.0-beta.2 (Unreleased) ### Features Added -- Added support for NFS List Files and Directories V2. `ShareDirectoryClient.listFilesAndDirectories` now returns - symbolic links, block devices, character devices, FIFOs and sockets in addition to files and directories. -- Added `ShareFileItem.getLinkCount()`, `ShareFileItem.getFileType()`, `ShareFileItem.getLinkText()`, - `ShareFileItem.getDeviceMajor()` and `ShareFileItem.getDeviceMinor()`. -- Added `ShareFileItemProperties.getOwner()`, `ShareFileItemProperties.getGroup()` and - `ShareFileItemProperties.getFileMode()`. -- Added `NfsFileType.BLOCK_DEVICE`, `NfsFileType.CHARACTER_DEVICE`, `NfsFileType.SOCKET` and `NfsFileType.FIFO`. -- Added `ShareListFilesAndDirectoriesOptions.setIncludePermissions`, `setIncludeLinkCount`, `setIncludeNfsAttributes` - and `setIncludeAll`. ### Breaking Changes diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index eabc0bb2c022e..2096399e6a768 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_741d1f4fbd" + "Tag": "java/storage/azure-storage-file-share_1e9eb49640" } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index da521421629a9..575d1d9f9b912 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -51,6 +51,7 @@ import reactor.core.publisher.Mono; import java.time.Duration; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -979,7 +980,22 @@ PagedFlux listFilesAndDirectoriesWithOptionalTimeout(ShareListFil final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; - final List finalIncludeTypes = ModelHelper.getListFilesIncludeTypes(modifiedOptions); + List includeTypes = new ArrayList<>(); + if (modifiedOptions.includeAttributes()) { + includeTypes.add(ListFilesIncludeType.ATTRIBUTES); + } + if (modifiedOptions.includeETag()) { + includeTypes.add(ListFilesIncludeType.ETAG); + } + if (modifiedOptions.includeTimestamps()) { + includeTypes.add(ListFilesIncludeType.TIMESTAMPS); + } + if (modifiedOptions.includePermissionKey()) { + includeTypes.add(ListFilesIncludeType.PERMISSION_KEY); + } + + // these options must be absent from request if empty or false + final List finalIncludeTypes = includeTypes.isEmpty() ? null : includeTypes; BiFunction>> retriever = (marker, pageSize) -> StorageImplUtils diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 3780bc4143750..416626a7113e8 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -58,6 +58,7 @@ import com.azure.storage.file.share.sas.ShareServiceSasSignatureValues; import java.time.Duration; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -945,7 +946,22 @@ public PagedIterable listFilesAndDirectories(ShareListFilesAndDir final ShareListFilesAndDirectoriesOptions modifiedOptions = options == null ? new ShareListFilesAndDirectoriesOptions() : options; - final List finalIncludeTypes = ModelHelper.getListFilesIncludeTypes(modifiedOptions); + List includeTypes = new ArrayList<>(); + if (modifiedOptions.includeAttributes()) { + includeTypes.add(ListFilesIncludeType.ATTRIBUTES); + } + if (modifiedOptions.includeETag()) { + includeTypes.add(ListFilesIncludeType.ETAG); + } + if (modifiedOptions.includeTimestamps()) { + includeTypes.add(ListFilesIncludeType.TIMESTAMPS); + } + if (modifiedOptions.includePermissionKey()) { + includeTypes.add(ListFilesIncludeType.PERMISSION_KEY); + } + + // these options must be absent from request if empty or false + final List finalIncludeTypes = includeTypes.isEmpty() ? null : includeTypes; BiFunction> retriever = (marker, pageSize) -> { Callable> operation diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFileItemConstructorProxy.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFileItemConstructorProxy.java deleted file mode 100644 index 102cfaa712c6e..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/accesshelpers/ShareFileItemConstructorProxy.java +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.file.share.implementation.accesshelpers; - -import com.azure.storage.file.share.models.NfsFileType; -import com.azure.storage.file.share.models.NtfsFileAttributes; -import com.azure.storage.file.share.models.ShareFileItem; -import com.azure.storage.file.share.models.ShareFileItemProperties; - -import java.util.EnumSet; - -/** - * Helper class to access private values of {@link ShareFileItem} across package boundaries. - */ -public final class ShareFileItemConstructorProxy { - private static ShareFileItemConstructorAccessor accessor; - - private ShareFileItemConstructorProxy() { - } - - /** - * Type defining the methods to create a {@link ShareFileItem} instance with non-public properties. - */ - public interface ShareFileItemConstructorAccessor { - /** - * Creates a new instance of {@link ShareFileItem}. - * - * @param name Name of the file or the directory. - * @param isDirectory A boolean set to true if the reference is a directory, false if the reference is a file. - * @param id ID of the file or directory. - * @param properties Properties of the file or directory. - * @param fileAttributes NTFS attributes of the file or directory. - * @param permissionKey Permission key of the file or directory. - * @param fileSize Size of a file. - * @param linkCount The number of hard links to the file or directory. - * @param fileType The type of the file or directory. - * @param linkText The target path of the symbolic link. - * @param deviceMajor The major device number. - * @param deviceMinor The minor device number. - * @return A new instance of {@link ShareFileItem}. - */ - ShareFileItem create(String name, boolean isDirectory, String id, ShareFileItemProperties properties, - EnumSet fileAttributes, String permissionKey, Long fileSize, Long linkCount, - NfsFileType fileType, String linkText, Long deviceMajor, Long deviceMinor); - } - - /** - * The method called from {@link ShareFileItem} to set its accessor. - * - * @param accessor The accessor. - */ - public static void setAccessor(final ShareFileItemConstructorAccessor accessor) { - ShareFileItemConstructorProxy.accessor = accessor; - } - - /** - * Creates a new instance of {@link ShareFileItem}. - * - * @param name Name of the file or the directory. - * @param isDirectory A boolean set to true if the reference is a directory, false if the reference is a file. - * @param id ID of the file or directory. - * @param properties Properties of the file or directory. - * @param fileAttributes NTFS attributes of the file or directory. - * @param permissionKey Permission key of the file or directory. - * @param fileSize Size of a file. - * @param linkCount The number of hard links to the file or directory. - * @param fileType The type of the file or directory. - * @param linkText The target path of the symbolic link. - * @param deviceMajor The major device number. - * @param deviceMinor The minor device number. - * @return A new instance of {@link ShareFileItem}. - */ - public static ShareFileItem create(String name, boolean isDirectory, String id, ShareFileItemProperties properties, - EnumSet fileAttributes, String permissionKey, Long fileSize, Long linkCount, - NfsFileType fileType, String linkText, Long deviceMajor, Long deviceMinor) { - // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the - // application accesses ShareFileItem which triggers the accessor to be configured. So, if the accessor - // is null this effectively pokes the class to set up the accessor. - if (accessor == null) { - new ShareFileItem(null, false, null); - } - - assert accessor != null; - return accessor.create(name, isDirectory, id, properties, fileAttributes, permissionKey, fileSize, linkCount, - fileType, linkText, deviceMajor, deviceMinor); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/BlockDeviceItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/BlockDeviceItem.java deleted file mode 100644 index 3e9ae98f8d4ad..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/BlockDeviceItem.java +++ /dev/null @@ -1,268 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A listed block device item. - */ -@Fluent -public final class BlockDeviceItem implements XmlSerializable { - /* - * The Name property. - */ - @Generated - private StringEncoded name; - - /* - * The FileId property. - */ - @Generated - private String fileId; - - /* - * File properties. - */ - @Generated - private FileProperty properties; - - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /* - * The DeviceMajor property. - */ - @Generated - private Long deviceMajor; - - /* - * The DeviceMinor property. - */ - @Generated - private Long deviceMinor; - - /** - * Creates an instance of BlockDeviceItem class. - */ - @Generated - public BlockDeviceItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - @Generated - public StringEncoded getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setName(StringEncoded name) { - this.name = name; - return this; - } - - /** - * Get the fileId property: The FileId property. - * - * @return the fileId value. - */ - @Generated - public String getFileId() { - return this.fileId; - } - - /** - * Set the fileId property: The FileId property. - * - * @param fileId the fileId value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setFileId(String fileId) { - this.fileId = fileId; - return this; - } - - /** - * Get the properties property: File properties. - * - * @return the properties value. - */ - @Generated - public FileProperty getProperties() { - return this.properties; - } - - /** - * Set the properties property: File properties. - * - * @param properties the properties value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setProperties(FileProperty properties) { - this.properties = properties; - return this; - } - - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - /** - * Get the deviceMajor property: The DeviceMajor property. - * - * @return the deviceMajor value. - */ - @Generated - public Long getDeviceMajor() { - return this.deviceMajor; - } - - /** - * Set the deviceMajor property: The DeviceMajor property. - * - * @param deviceMajor the deviceMajor value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setDeviceMajor(Long deviceMajor) { - this.deviceMajor = deviceMajor; - return this; - } - - /** - * Get the deviceMinor property: The DeviceMinor property. - * - * @return the deviceMinor value. - */ - @Generated - public Long getDeviceMinor() { - return this.deviceMinor; - } - - /** - * Set the deviceMinor property: The DeviceMinor property. - * - * @param deviceMinor the deviceMinor value to set. - * @return the BlockDeviceItem object itself. - */ - @Generated - public BlockDeviceItem setDeviceMinor(Long deviceMinor) { - this.deviceMinor = deviceMinor; - return this; - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = rootElementName == null || rootElementName.isEmpty() ? "BlockDevice" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeStringElement("FileId", this.fileId); - xmlWriter.writeXml(this.properties, "Properties"); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - xmlWriter.writeNumberElement("DeviceMajor", this.deviceMajor); - xmlWriter.writeNumberElement("DeviceMinor", this.deviceMinor); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of BlockDeviceItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of BlockDeviceItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockDeviceItem. - */ - @Generated - public static BlockDeviceItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of BlockDeviceItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of BlockDeviceItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the BlockDeviceItem. - */ - @Generated - public static BlockDeviceItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = rootElementName == null || rootElementName.isEmpty() ? "BlockDevice" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - BlockDeviceItem deserializedBlockDeviceItem = new BlockDeviceItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.name = StringEncoded.fromXml(reader, "Name"); - } else if ("FileId".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.fileId = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.properties = FileProperty.fromXml(reader, "Properties"); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.linkCount = reader.getNullableElement(Long::parseLong); - } else if ("DeviceMajor".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.deviceMajor = reader.getNullableElement(Long::parseLong); - } else if ("DeviceMinor".equals(elementName.getLocalPart())) { - deserializedBlockDeviceItem.deviceMinor = reader.getNullableElement(Long::parseLong); - } else { - reader.skipElement(); - } - } - - return deserializedBlockDeviceItem; - }); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/CharDeviceItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/CharDeviceItem.java deleted file mode 100644 index a77395bcaa283..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/CharDeviceItem.java +++ /dev/null @@ -1,268 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A listed character device item. - */ -@Fluent -public final class CharDeviceItem implements XmlSerializable { - /* - * The Name property. - */ - @Generated - private StringEncoded name; - - /* - * The FileId property. - */ - @Generated - private String fileId; - - /* - * File properties. - */ - @Generated - private FileProperty properties; - - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /* - * The DeviceMajor property. - */ - @Generated - private Long deviceMajor; - - /* - * The DeviceMinor property. - */ - @Generated - private Long deviceMinor; - - /** - * Creates an instance of CharDeviceItem class. - */ - @Generated - public CharDeviceItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - @Generated - public StringEncoded getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setName(StringEncoded name) { - this.name = name; - return this; - } - - /** - * Get the fileId property: The FileId property. - * - * @return the fileId value. - */ - @Generated - public String getFileId() { - return this.fileId; - } - - /** - * Set the fileId property: The FileId property. - * - * @param fileId the fileId value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setFileId(String fileId) { - this.fileId = fileId; - return this; - } - - /** - * Get the properties property: File properties. - * - * @return the properties value. - */ - @Generated - public FileProperty getProperties() { - return this.properties; - } - - /** - * Set the properties property: File properties. - * - * @param properties the properties value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setProperties(FileProperty properties) { - this.properties = properties; - return this; - } - - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - /** - * Get the deviceMajor property: The DeviceMajor property. - * - * @return the deviceMajor value. - */ - @Generated - public Long getDeviceMajor() { - return this.deviceMajor; - } - - /** - * Set the deviceMajor property: The DeviceMajor property. - * - * @param deviceMajor the deviceMajor value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setDeviceMajor(Long deviceMajor) { - this.deviceMajor = deviceMajor; - return this; - } - - /** - * Get the deviceMinor property: The DeviceMinor property. - * - * @return the deviceMinor value. - */ - @Generated - public Long getDeviceMinor() { - return this.deviceMinor; - } - - /** - * Set the deviceMinor property: The DeviceMinor property. - * - * @param deviceMinor the deviceMinor value to set. - * @return the CharDeviceItem object itself. - */ - @Generated - public CharDeviceItem setDeviceMinor(Long deviceMinor) { - this.deviceMinor = deviceMinor; - return this; - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = rootElementName == null || rootElementName.isEmpty() ? "CharDevice" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeStringElement("FileId", this.fileId); - xmlWriter.writeXml(this.properties, "Properties"); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - xmlWriter.writeNumberElement("DeviceMajor", this.deviceMajor); - xmlWriter.writeNumberElement("DeviceMinor", this.deviceMinor); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of CharDeviceItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of CharDeviceItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the CharDeviceItem. - */ - @Generated - public static CharDeviceItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of CharDeviceItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of CharDeviceItem if the XmlReader was pointing to an instance of it, or null if it was - * pointing to XML null. - * @throws XMLStreamException If an error occurs while reading the CharDeviceItem. - */ - @Generated - public static CharDeviceItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = rootElementName == null || rootElementName.isEmpty() ? "CharDevice" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - CharDeviceItem deserializedCharDeviceItem = new CharDeviceItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.name = StringEncoded.fromXml(reader, "Name"); - } else if ("FileId".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.fileId = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.properties = FileProperty.fromXml(reader, "Properties"); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.linkCount = reader.getNullableElement(Long::parseLong); - } else if ("DeviceMajor".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.deviceMajor = reader.getNullableElement(Long::parseLong); - } else if ("DeviceMinor".equals(elementName.getLocalPart())) { - deserializedCharDeviceItem.deviceMinor = reader.getNullableElement(Long::parseLong); - } else { - reader.skipElement(); - } - } - - return deserializedCharDeviceItem; - }); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoryItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoryItem.java index d5f7362025ebb..5b72c5ea86d4d 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoryItem.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/DirectoryItem.java @@ -48,12 +48,6 @@ public final class DirectoryItem implements XmlSerializable { @Generated private String permissionKey; - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - /** * Creates an instance of DirectoryItem class. */ @@ -171,28 +165,6 @@ public DirectoryItem setPermissionKey(String permissionKey) { return this; } - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the DirectoryItem object itself. - */ - @Generated - public DirectoryItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - @Generated @Override public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { @@ -209,7 +181,6 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt xmlWriter.writeXml(this.properties, "Properties"); xmlWriter.writeStringElement("Attributes", this.attributes); xmlWriter.writeStringElement("PermissionKey", this.permissionKey); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); return xmlWriter.writeEndElement(); } @@ -255,8 +226,6 @@ public static DirectoryItem fromXml(XmlReader xmlReader, String rootElementName) deserializedDirectoryItem.attributes = reader.getStringElement(); } else if ("PermissionKey".equals(elementName.getLocalPart())) { deserializedDirectoryItem.permissionKey = reader.getStringElement(); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedDirectoryItem.linkCount = reader.getNullableElement(Long::parseLong); } else { reader.skipElement(); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FifoItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FifoItem.java deleted file mode 100644 index e5c65219909e2..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FifoItem.java +++ /dev/null @@ -1,205 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A listed FIFO item. - */ -@Fluent -public final class FifoItem implements XmlSerializable { - /* - * The Name property. - */ - @Generated - private StringEncoded name; - - /* - * The FileId property. - */ - @Generated - private String fileId; - - /* - * File properties. - */ - @Generated - private FileProperty properties; - - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /** - * Creates an instance of FifoItem class. - */ - @Generated - public FifoItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - @Generated - public StringEncoded getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the FifoItem object itself. - */ - @Generated - public FifoItem setName(StringEncoded name) { - this.name = name; - return this; - } - - /** - * Get the fileId property: The FileId property. - * - * @return the fileId value. - */ - @Generated - public String getFileId() { - return this.fileId; - } - - /** - * Set the fileId property: The FileId property. - * - * @param fileId the fileId value to set. - * @return the FifoItem object itself. - */ - @Generated - public FifoItem setFileId(String fileId) { - this.fileId = fileId; - return this; - } - - /** - * Get the properties property: File properties. - * - * @return the properties value. - */ - @Generated - public FileProperty getProperties() { - return this.properties; - } - - /** - * Set the properties property: File properties. - * - * @param properties the properties value to set. - * @return the FifoItem object itself. - */ - @Generated - public FifoItem setProperties(FileProperty properties) { - this.properties = properties; - return this; - } - - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the FifoItem object itself. - */ - @Generated - public FifoItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = rootElementName == null || rootElementName.isEmpty() ? "Fifo" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeStringElement("FileId", this.fileId); - xmlWriter.writeXml(this.properties, "Properties"); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of FifoItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of FifoItem if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the FifoItem. - */ - @Generated - public static FifoItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of FifoItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of FifoItem if the XmlReader was pointing to an instance of it, or null if it was pointing to - * XML null. - * @throws XMLStreamException If an error occurs while reading the FifoItem. - */ - @Generated - public static FifoItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = rootElementName == null || rootElementName.isEmpty() ? "Fifo" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - FifoItem deserializedFifoItem = new FifoItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedFifoItem.name = StringEncoded.fromXml(reader, "Name"); - } else if ("FileId".equals(elementName.getLocalPart())) { - deserializedFifoItem.fileId = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedFifoItem.properties = FileProperty.fromXml(reader, "Properties"); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedFifoItem.linkCount = reader.getNullableElement(Long::parseLong); - } else { - reader.skipElement(); - } - } - - return deserializedFifoItem; - }); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileItem.java index 7b81cef5460cb..c8338e96372d3 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileItem.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileItem.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.azure.storage.file.share.models.NfsFileType; import com.azure.xml.XmlReader; import com.azure.xml.XmlSerializable; import com.azure.xml.XmlToken; @@ -49,18 +48,6 @@ public final class FileItem implements XmlSerializable { @Generated private String permissionKey; - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /* - * Type of the file. - */ - @Generated - private NfsFileType fileType; - /** * Creates an instance of FileItem class. */ @@ -178,50 +165,6 @@ public FileItem setPermissionKey(String permissionKey) { return this; } - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the FileItem object itself. - */ - @Generated - public FileItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - /** - * Get the fileType property: Type of the file. - * - * @return the fileType value. - */ - @Generated - public NfsFileType getFileType() { - return this.fileType; - } - - /** - * Set the fileType property: Type of the file. - * - * @param fileType the fileType value to set. - * @return the FileItem object itself. - */ - @Generated - public FileItem setFileType(NfsFileType fileType) { - this.fileType = fileType; - return this; - } - @Generated @Override public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { @@ -238,8 +181,6 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt xmlWriter.writeXml(this.properties, "Properties"); xmlWriter.writeStringElement("Attributes", this.attributes); xmlWriter.writeStringElement("PermissionKey", this.permissionKey); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - xmlWriter.writeStringElement("FileType", this.fileType == null ? null : this.fileType.toString()); return xmlWriter.writeEndElement(); } @@ -284,10 +225,6 @@ public static FileItem fromXml(XmlReader xmlReader, String rootElementName) thro deserializedFileItem.attributes = reader.getStringElement(); } else if ("PermissionKey".equals(elementName.getLocalPart())) { deserializedFileItem.permissionKey = reader.getStringElement(); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedFileItem.linkCount = reader.getNullableElement(Long::parseLong); - } else if ("FileType".equals(elementName.getLocalPart())) { - deserializedFileItem.fileType = NfsFileType.fromString(reader.getStringElement()); } else { reader.skipElement(); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileProperty.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileProperty.java index 1ab9a4d68a6cd..7bf07bbc0a4d3 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileProperty.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FileProperty.java @@ -67,24 +67,6 @@ public final class FileProperty implements XmlSerializable { @Generated private String etag; - /* - * The Uid property. - */ - @Generated - private String uid; - - /* - * The Gid property. - */ - @Generated - private String gid; - - /* - * The Mode property. - */ - @Generated - private String mode; - /** * Creates an instance of FileProperty class. */ @@ -257,72 +239,6 @@ public FileProperty setEtag(String etag) { return this; } - /** - * Get the uid property: The Uid property. - * - * @return the uid value. - */ - @Generated - public String getUid() { - return this.uid; - } - - /** - * Set the uid property: The Uid property. - * - * @param uid the uid value to set. - * @return the FileProperty object itself. - */ - @Generated - public FileProperty setUid(String uid) { - this.uid = uid; - return this; - } - - /** - * Get the gid property: The Gid property. - * - * @return the gid value. - */ - @Generated - public String getGid() { - return this.gid; - } - - /** - * Set the gid property: The Gid property. - * - * @param gid the gid value to set. - * @return the FileProperty object itself. - */ - @Generated - public FileProperty setGid(String gid) { - this.gid = gid; - return this; - } - - /** - * Get the mode property: The Mode property. - * - * @return the mode value. - */ - @Generated - public String getMode() { - return this.mode; - } - - /** - * Set the mode property: The Mode property. - * - * @param mode the mode value to set. - * @return the FileProperty object itself. - */ - @Generated - public FileProperty setMode(String mode) { - this.mode = mode; - return this; - } - @Generated @Override public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { @@ -345,9 +261,6 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt this.changeTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.changeTime)); xmlWriter.writeStringElement("Last-Modified", Objects.toString(this.lastModified, null)); xmlWriter.writeStringElement("Etag", this.etag); - xmlWriter.writeStringElement("Uid", this.uid); - xmlWriter.writeStringElement("Gid", this.gid); - xmlWriter.writeStringElement("Mode", this.mode); return xmlWriter.writeEndElement(); } @@ -401,12 +314,6 @@ public static FileProperty fromXml(XmlReader xmlReader, String rootElementName) deserializedFileProperty.lastModified = reader.getNullableElement(DateTimeRfc1123::new); } else if ("Etag".equals(elementName.getLocalPart())) { deserializedFileProperty.etag = reader.getStringElement(); - } else if ("Uid".equals(elementName.getLocalPart())) { - deserializedFileProperty.uid = reader.getStringElement(); - } else if ("Gid".equals(elementName.getLocalPart())) { - deserializedFileProperty.gid = reader.getStringElement(); - } else if ("Mode".equals(elementName.getLocalPart())) { - deserializedFileProperty.mode = reader.getStringElement(); } else { reader.skipElement(); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesAndDirectoriesListSegment.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesAndDirectoriesListSegment.java index 7c7d7ba082d9d..db47d0b499b2a 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesAndDirectoriesListSegment.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/FilesAndDirectoriesListSegment.java @@ -32,36 +32,6 @@ public final class FilesAndDirectoriesListSegment implements XmlSerializable fileItems = new ArrayList<>(); - /* - * The SymLinkItems property. - */ - @Generated - private List symLinkItems = new ArrayList<>(); - - /* - * The BlockDeviceItems property. - */ - @Generated - private List blockDeviceItems = new ArrayList<>(); - - /* - * The CharDeviceItems property. - */ - @Generated - private List charDeviceItems = new ArrayList<>(); - - /* - * The FifoItems property. - */ - @Generated - private List fifoItems = new ArrayList<>(); - - /* - * The SocketItems property. - */ - @Generated - private List socketItems = new ArrayList<>(); - /** * Creates an instance of FilesAndDirectoriesListSegment class. */ @@ -113,116 +83,6 @@ public FilesAndDirectoriesListSegment setFileItems(List fileItems) { return this; } - /** - * Get the symLinkItems property: The SymLinkItems property. - * - * @return the symLinkItems value. - */ - @Generated - public List getSymLinkItems() { - return this.symLinkItems; - } - - /** - * Set the symLinkItems property: The SymLinkItems property. - * - * @param symLinkItems the symLinkItems value to set. - * @return the FilesAndDirectoriesListSegment object itself. - */ - @Generated - public FilesAndDirectoriesListSegment setSymLinkItems(List symLinkItems) { - this.symLinkItems = symLinkItems; - return this; - } - - /** - * Get the blockDeviceItems property: The BlockDeviceItems property. - * - * @return the blockDeviceItems value. - */ - @Generated - public List getBlockDeviceItems() { - return this.blockDeviceItems; - } - - /** - * Set the blockDeviceItems property: The BlockDeviceItems property. - * - * @param blockDeviceItems the blockDeviceItems value to set. - * @return the FilesAndDirectoriesListSegment object itself. - */ - @Generated - public FilesAndDirectoriesListSegment setBlockDeviceItems(List blockDeviceItems) { - this.blockDeviceItems = blockDeviceItems; - return this; - } - - /** - * Get the charDeviceItems property: The CharDeviceItems property. - * - * @return the charDeviceItems value. - */ - @Generated - public List getCharDeviceItems() { - return this.charDeviceItems; - } - - /** - * Set the charDeviceItems property: The CharDeviceItems property. - * - * @param charDeviceItems the charDeviceItems value to set. - * @return the FilesAndDirectoriesListSegment object itself. - */ - @Generated - public FilesAndDirectoriesListSegment setCharDeviceItems(List charDeviceItems) { - this.charDeviceItems = charDeviceItems; - return this; - } - - /** - * Get the fifoItems property: The FifoItems property. - * - * @return the fifoItems value. - */ - @Generated - public List getFifoItems() { - return this.fifoItems; - } - - /** - * Set the fifoItems property: The FifoItems property. - * - * @param fifoItems the fifoItems value to set. - * @return the FilesAndDirectoriesListSegment object itself. - */ - @Generated - public FilesAndDirectoriesListSegment setFifoItems(List fifoItems) { - this.fifoItems = fifoItems; - return this; - } - - /** - * Get the socketItems property: The SocketItems property. - * - * @return the socketItems value. - */ - @Generated - public List getSocketItems() { - return this.socketItems; - } - - /** - * Set the socketItems property: The SocketItems property. - * - * @param socketItems the socketItems value to set. - * @return the FilesAndDirectoriesListSegment object itself. - */ - @Generated - public FilesAndDirectoriesListSegment setSocketItems(List socketItems) { - this.socketItems = socketItems; - return this; - } - @Generated @Override public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { @@ -244,31 +104,6 @@ public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLSt xmlWriter.writeXml(element, "File"); } } - if (this.symLinkItems != null) { - for (SymLinkItem element : this.symLinkItems) { - xmlWriter.writeXml(element, "SymLink"); - } - } - if (this.blockDeviceItems != null) { - for (BlockDeviceItem element : this.blockDeviceItems) { - xmlWriter.writeXml(element, "BlockDevice"); - } - } - if (this.charDeviceItems != null) { - for (CharDeviceItem element : this.charDeviceItems) { - xmlWriter.writeXml(element, "CharDevice"); - } - } - if (this.fifoItems != null) { - for (FifoItem element : this.fifoItems) { - xmlWriter.writeXml(element, "Fifo"); - } - } - if (this.socketItems != null) { - for (SocketItem element : this.socketItems) { - xmlWriter.writeXml(element, "Socket"); - } - } return xmlWriter.writeEndElement(); } @@ -311,18 +146,6 @@ public static FilesAndDirectoriesListSegment fromXml(XmlReader xmlReader, String .add(DirectoryItem.fromXml(reader, "Directory")); } else if ("File".equals(elementName.getLocalPart())) { deserializedFilesAndDirectoriesListSegment.fileItems.add(FileItem.fromXml(reader, "File")); - } else if ("SymLink".equals(elementName.getLocalPart())) { - deserializedFilesAndDirectoriesListSegment.symLinkItems.add(SymLinkItem.fromXml(reader, "SymLink")); - } else if ("BlockDevice".equals(elementName.getLocalPart())) { - deserializedFilesAndDirectoriesListSegment.blockDeviceItems - .add(BlockDeviceItem.fromXml(reader, "BlockDevice")); - } else if ("CharDevice".equals(elementName.getLocalPart())) { - deserializedFilesAndDirectoriesListSegment.charDeviceItems - .add(CharDeviceItem.fromXml(reader, "CharDevice")); - } else if ("Fifo".equals(elementName.getLocalPart())) { - deserializedFilesAndDirectoriesListSegment.fifoItems.add(FifoItem.fromXml(reader, "Fifo")); - } else if ("Socket".equals(elementName.getLocalPart())) { - deserializedFilesAndDirectoriesListSegment.socketItems.add(SocketItem.fromXml(reader, "Socket")); } else { reader.skipElement(); } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/InternalShareFileItemProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/InternalShareFileItemProperties.java index cd22b208c175d..bf3520e8f0885 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/InternalShareFileItemProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/InternalShareFileItemProperties.java @@ -14,9 +14,6 @@ public class InternalShareFileItemProperties implements ShareFileItemProperties private final OffsetDateTime changedOn; private final OffsetDateTime lastModified; private final String eTag; - private final String owner; - private final String group; - private final String fileMode; /** * Creates an instance of share item properties. @@ -30,34 +27,12 @@ public class InternalShareFileItemProperties implements ShareFileItemProperties */ public InternalShareFileItemProperties(OffsetDateTime createdOn, OffsetDateTime lastAccessedOn, OffsetDateTime lastWrittenOn, OffsetDateTime changedOn, OffsetDateTime lastModified, String eTag) { - this(createdOn, lastAccessedOn, lastWrittenOn, changedOn, lastModified, eTag, null, null, null); - } - - /** - * Creates an instance of share item properties. - * - * @param createdOn Datetime the item was created. - * @param lastAccessedOn Datetime the item was last accessed. - * @param lastWrittenOn Datetime the item was last written. - * @param changedOn Datetime the item was last changed. - * @param lastModified Datetime the item was last modified. - * @param eTag ETag of the item. - * @param owner Owner user identifier (UID) of the item. - * @param group Owning group identifier (GID) of the item. - * @param fileMode POSIX file mode of the item. - */ - public InternalShareFileItemProperties(OffsetDateTime createdOn, OffsetDateTime lastAccessedOn, - OffsetDateTime lastWrittenOn, OffsetDateTime changedOn, OffsetDateTime lastModified, String eTag, String owner, - String group, String fileMode) { this.createdOn = createdOn; this.lastAccessedOn = lastAccessedOn; this.lastWrittenOn = lastWrittenOn; this.changedOn = changedOn; this.lastModified = lastModified; this.eTag = eTag; - this.owner = owner; - this.group = group; - this.fileMode = fileMode; } /** @@ -101,28 +76,4 @@ public OffsetDateTime getLastModified() { public String getETag() { return eTag; } - - /** - * @return Owner user identifier (UID) of this item. - */ - @Override - public String getOwner() { - return owner; - } - - /** - * @return Owning group identifier (GID) of this item. - */ - @Override - public String getGroup() { - return group; - } - - /** - * @return POSIX file mode of this item. - */ - @Override - public String getFileMode() { - return fileMode; - } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/ListFilesIncludeType.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/ListFilesIncludeType.java index ae0fc295e9256..183e5958cebbf 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/ListFilesIncludeType.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/ListFilesIncludeType.java @@ -26,27 +26,7 @@ public enum ListFilesIncludeType { /** * Enum value PermissionKey. */ - PERMISSION_KEY("PermissionKey"), - - /** - * Enum value Permissions. - */ - PERMISSIONS("Permissions"), - - /** - * Enum value LinkCount. - */ - LINK_COUNT("LinkCount"), - - /** - * Enum value NfsAttributes. - */ - NFS_ATTRIBUTES("NfsAttributes"), - - /** - * Enum value All. - */ - ALL("All"); + PERMISSION_KEY("PermissionKey"); /** * The actual serialized value for a ListFilesIncludeType instance. diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SocketItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SocketItem.java deleted file mode 100644 index 823076df0e8f1..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SocketItem.java +++ /dev/null @@ -1,205 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A listed socket item. - */ -@Fluent -public final class SocketItem implements XmlSerializable { - /* - * The Name property. - */ - @Generated - private StringEncoded name; - - /* - * The FileId property. - */ - @Generated - private String fileId; - - /* - * File properties. - */ - @Generated - private FileProperty properties; - - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /** - * Creates an instance of SocketItem class. - */ - @Generated - public SocketItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - @Generated - public StringEncoded getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the SocketItem object itself. - */ - @Generated - public SocketItem setName(StringEncoded name) { - this.name = name; - return this; - } - - /** - * Get the fileId property: The FileId property. - * - * @return the fileId value. - */ - @Generated - public String getFileId() { - return this.fileId; - } - - /** - * Set the fileId property: The FileId property. - * - * @param fileId the fileId value to set. - * @return the SocketItem object itself. - */ - @Generated - public SocketItem setFileId(String fileId) { - this.fileId = fileId; - return this; - } - - /** - * Get the properties property: File properties. - * - * @return the properties value. - */ - @Generated - public FileProperty getProperties() { - return this.properties; - } - - /** - * Set the properties property: File properties. - * - * @param properties the properties value to set. - * @return the SocketItem object itself. - */ - @Generated - public SocketItem setProperties(FileProperty properties) { - this.properties = properties; - return this; - } - - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the SocketItem object itself. - */ - @Generated - public SocketItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = rootElementName == null || rootElementName.isEmpty() ? "Socket" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeStringElement("FileId", this.fileId); - xmlWriter.writeXml(this.properties, "Properties"); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of SocketItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of SocketItem if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the SocketItem. - */ - @Generated - public static SocketItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of SocketItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of SocketItem if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the SocketItem. - */ - @Generated - public static SocketItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName = rootElementName == null || rootElementName.isEmpty() ? "Socket" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - SocketItem deserializedSocketItem = new SocketItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedSocketItem.name = StringEncoded.fromXml(reader, "Name"); - } else if ("FileId".equals(elementName.getLocalPart())) { - deserializedSocketItem.fileId = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedSocketItem.properties = FileProperty.fromXml(reader, "Properties"); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedSocketItem.linkCount = reader.getNullableElement(Long::parseLong); - } else { - reader.skipElement(); - } - } - - return deserializedSocketItem; - }); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SymLinkItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SymLinkItem.java deleted file mode 100644 index 5b0b95ed93e48..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/models/SymLinkItem.java +++ /dev/null @@ -1,237 +0,0 @@ -// 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.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.xml.XmlReader; -import com.azure.xml.XmlSerializable; -import com.azure.xml.XmlToken; -import com.azure.xml.XmlWriter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -/** - * A listed symbolic link item. - */ -@Fluent -public final class SymLinkItem implements XmlSerializable { - /* - * The Name property. - */ - @Generated - private StringEncoded name; - - /* - * The FileId property. - */ - @Generated - private String fileId; - - /* - * File properties. - */ - @Generated - private FileProperty properties; - - /* - * The LinkCount property. - */ - @Generated - private Long linkCount; - - /* - * The LinkText property. - */ - @Generated - private String linkText; - - /** - * Creates an instance of SymLinkItem class. - */ - @Generated - public SymLinkItem() { - } - - /** - * Get the name property: The Name property. - * - * @return the name value. - */ - @Generated - public StringEncoded getName() { - return this.name; - } - - /** - * Set the name property: The Name property. - * - * @param name the name value to set. - * @return the SymLinkItem object itself. - */ - @Generated - public SymLinkItem setName(StringEncoded name) { - this.name = name; - return this; - } - - /** - * Get the fileId property: The FileId property. - * - * @return the fileId value. - */ - @Generated - public String getFileId() { - return this.fileId; - } - - /** - * Set the fileId property: The FileId property. - * - * @param fileId the fileId value to set. - * @return the SymLinkItem object itself. - */ - @Generated - public SymLinkItem setFileId(String fileId) { - this.fileId = fileId; - return this; - } - - /** - * Get the properties property: File properties. - * - * @return the properties value. - */ - @Generated - public FileProperty getProperties() { - return this.properties; - } - - /** - * Set the properties property: File properties. - * - * @param properties the properties value to set. - * @return the SymLinkItem object itself. - */ - @Generated - public SymLinkItem setProperties(FileProperty properties) { - this.properties = properties; - return this; - } - - /** - * Get the linkCount property: The LinkCount property. - * - * @return the linkCount value. - */ - @Generated - public Long getLinkCount() { - return this.linkCount; - } - - /** - * Set the linkCount property: The LinkCount property. - * - * @param linkCount the linkCount value to set. - * @return the SymLinkItem object itself. - */ - @Generated - public SymLinkItem setLinkCount(Long linkCount) { - this.linkCount = linkCount; - return this; - } - - /** - * Get the linkText property: The LinkText property. - * - * @return the linkText value. - */ - @Generated - public String getLinkText() { - return this.linkText; - } - - /** - * Set the linkText property: The LinkText property. - * - * @param linkText the linkText value to set. - * @return the SymLinkItem object itself. - */ - @Generated - public SymLinkItem setLinkText(String linkText) { - this.linkText = linkText; - return this; - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter) throws XMLStreamException { - return toXml(xmlWriter, null); - } - - @Generated - @Override - public XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) throws XMLStreamException { - rootElementName = rootElementName == null || rootElementName.isEmpty() ? "SymLink" : rootElementName; - xmlWriter.writeStartElement(rootElementName); - xmlWriter.writeXml(this.name, "Name"); - xmlWriter.writeStringElement("FileId", this.fileId); - xmlWriter.writeXml(this.properties, "Properties"); - xmlWriter.writeNumberElement("LinkCount", this.linkCount); - xmlWriter.writeStringElement("LinkText", this.linkText); - return xmlWriter.writeEndElement(); - } - - /** - * Reads an instance of SymLinkItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @return An instance of SymLinkItem if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the SymLinkItem. - */ - @Generated - public static SymLinkItem fromXml(XmlReader xmlReader) throws XMLStreamException { - return fromXml(xmlReader, null); - } - - /** - * Reads an instance of SymLinkItem from the XmlReader. - * - * @param xmlReader The XmlReader being read. - * @param rootElementName Optional root element name to override the default defined by the model. Used to support - * cases where the model can deserialize from different root element names. - * @return An instance of SymLinkItem if the XmlReader was pointing to an instance of it, or null if it was pointing - * to XML null. - * @throws XMLStreamException If an error occurs while reading the SymLinkItem. - */ - @Generated - public static SymLinkItem fromXml(XmlReader xmlReader, String rootElementName) throws XMLStreamException { - String finalRootElementName - = rootElementName == null || rootElementName.isEmpty() ? "SymLink" : rootElementName; - return xmlReader.readObject(finalRootElementName, reader -> { - SymLinkItem deserializedSymLinkItem = new SymLinkItem(); - while (reader.nextElement() != XmlToken.END_ELEMENT) { - QName elementName = reader.getElementName(); - - if ("Name".equals(elementName.getLocalPart())) { - deserializedSymLinkItem.name = StringEncoded.fromXml(reader, "Name"); - } else if ("FileId".equals(elementName.getLocalPart())) { - deserializedSymLinkItem.fileId = reader.getStringElement(); - } else if ("Properties".equals(elementName.getLocalPart())) { - deserializedSymLinkItem.properties = FileProperty.fromXml(reader, "Properties"); - } else if ("LinkCount".equals(elementName.getLocalPart())) { - deserializedSymLinkItem.linkCount = reader.getNullableElement(Long::parseLong); - } else if ("LinkText".equals(elementName.getLocalPart())) { - deserializedSymLinkItem.linkText = reader.getStringElement(); - } else { - reader.skipElement(); - } - } - - return deserializedSymLinkItem; - }); - } -} 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 dd398752a1cd0..a6830e7cb854a 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 @@ -23,21 +23,14 @@ import com.azure.storage.file.share.implementation.accesshelpers.ShareDirectoryPropertiesHelper; import com.azure.storage.file.share.implementation.accesshelpers.ShareFileDownloadHeadersConstructorProxy; import com.azure.storage.file.share.implementation.accesshelpers.ShareFileInfoHelper; -import com.azure.storage.file.share.implementation.accesshelpers.ShareFileItemConstructorProxy; import com.azure.storage.file.share.implementation.accesshelpers.ShareFilePropertiesHelper; import com.azure.storage.file.share.implementation.accesshelpers.ShareFileSymbolicLinkInfoHelper; -import com.azure.storage.file.share.implementation.models.BlockDeviceItem; -import com.azure.storage.file.share.implementation.models.CharDeviceItem; import com.azure.storage.file.share.implementation.models.DeleteSnapshotsOptionType; import com.azure.storage.file.share.implementation.models.DirectoriesCreateHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesGetPropertiesHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetMetadataHeaders; import com.azure.storage.file.share.implementation.models.DirectoriesSetPropertiesHeaders; -import com.azure.storage.file.share.implementation.models.DirectoryItem; -import com.azure.storage.file.share.implementation.models.FifoItem; import com.azure.storage.file.share.implementation.models.FileProperty; -import com.azure.storage.file.share.implementation.models.FileItem; -import com.azure.storage.file.share.implementation.models.FilesAndDirectoriesListSegment; import com.azure.storage.file.share.implementation.models.FilesCreateHardLinkHeaders; import com.azure.storage.file.share.implementation.models.FilesCreateHeaders; import com.azure.storage.file.share.implementation.models.FilesCreateSymbolicLinkHeaders; @@ -50,7 +43,6 @@ import com.azure.storage.file.share.implementation.models.FilesUploadRangeHeaders; import com.azure.storage.file.share.implementation.models.InternalShareFileItemProperties; import com.azure.storage.file.share.implementation.models.ListFilesAndDirectoriesSegmentResponse; -import com.azure.storage.file.share.implementation.models.ListFilesIncludeType; import com.azure.storage.file.share.implementation.models.ServicesListSharesSegmentHeaders; import com.azure.storage.file.share.implementation.models.ShareItemInternal; import com.azure.storage.file.share.implementation.models.SharePropertiesInternal; @@ -58,9 +50,7 @@ import com.azure.storage.file.share.implementation.models.ShareStorageExceptionInternal; import com.azure.storage.file.share.implementation.models.SharesCreateSnapshotHeaders; import com.azure.storage.file.share.implementation.models.SharesGetPropertiesHeaders; -import com.azure.storage.file.share.implementation.models.SocketItem; import com.azure.storage.file.share.implementation.models.StringEncoded; -import com.azure.storage.file.share.implementation.models.SymLinkItem; import com.azure.storage.file.share.models.ClearRange; import com.azure.storage.file.share.models.CopyStatusType; import com.azure.storage.file.share.models.CopyableFileSmbPropertiesList; @@ -70,7 +60,6 @@ import com.azure.storage.file.share.models.LeaseDurationType; import com.azure.storage.file.share.models.LeaseStateType; import com.azure.storage.file.share.models.LeaseStatusType; -import com.azure.storage.file.share.models.NfsFileType; import com.azure.storage.file.share.models.NtfsFileAttributes; import com.azure.storage.file.share.models.ShareDirectoryInfo; import com.azure.storage.file.share.models.ShareDirectoryProperties; @@ -98,7 +87,6 @@ import com.azure.storage.file.share.models.ShareStatistics; import com.azure.storage.file.share.models.ShareStorageException; import com.azure.storage.file.share.options.ShareFileCopyOptions; -import com.azure.storage.file.share.options.ShareListFilesAndDirectoriesOptions; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -113,7 +101,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; -import java.util.function.Function; import static com.azure.core.http.HttpHeaderName.LAST_MODIFIED; @@ -316,8 +303,7 @@ public static ShareFileItemProperties transformFileProperty(FileProperty propert return null; } return new InternalShareFileItemProperties(property.getCreationTime(), property.getLastAccessTime(), - property.getLastWriteTime(), property.getChangeTime(), property.getLastModified(), property.getEtag(), - property.getUid(), property.getGid(), property.getMode()); + property.getLastWriteTime(), property.getChangeTime(), property.getLastModified(), property.getEtag()); } public static HandleItem @@ -630,110 +616,26 @@ public static Response mapGetStatisticsResponse(Response res) { Set shareFileItems = new TreeSet<>(Comparator.comparing(ShareFileItem::getName)); if (res.getValue().getSegment() != null) { - FilesAndDirectoriesListSegment segment = res.getValue().getSegment(); - - addShareFileItems(shareFileItems, segment.getDirectoryItems(), ModelHelper::createDirectoryShareItem); - addShareFileItems(shareFileItems, segment.getFileItems(), ModelHelper::createFileShareItem); - addShareFileItems(shareFileItems, segment.getSymLinkItems(), ModelHelper::createSymLinkShareItem); - addShareFileItems(shareFileItems, segment.getBlockDeviceItems(), ModelHelper::createBlockDeviceShareItem); - addShareFileItems(shareFileItems, segment.getCharDeviceItems(), ModelHelper::createCharDeviceShareItem); - addShareFileItems(shareFileItems, segment.getFifoItems(), ModelHelper::createFifoShareItem); - addShareFileItems(shareFileItems, segment.getSocketItems(), ModelHelper::createSocketShareItem); - } - - return new ArrayList<>(shareFileItems); - } - - private static void addShareFileItems(Set shareFileItems, List items, - Function mapper) { - if (items != null) { - items.forEach(item -> shareFileItems.add(mapper.apply(item))); - } - } - - public static void addOptionToList(List includeTypes, boolean isInOptionsBag, T type) { - if (isInOptionsBag) { - includeTypes.add(type); - } - } - - private static ShareFileItem toShareFileItem(StringEncoded name, boolean isDirectory, String fileId, - FileProperty properties, String attributes, String permissionKey, Long fileSize, Long linkCount, - NfsFileType fileType, String linkText, Long deviceMajor, Long deviceMinor) { - return ShareFileItemConstructorProxy.create(ModelHelper.decodeName(name), isDirectory, fileId, - ModelHelper.transformFileProperty(properties), NtfsFileAttributes.toAttributes(attributes), permissionKey, - fileSize, linkCount, fileType, linkText, deviceMajor, deviceMinor); - } - - private static Long getContentLength(FileProperty properties) { - return properties == null ? null : properties.getContentLength(); - } - - private static NfsFileType getDirectoryFileType() { - return NfsFileType.DIRECTORY; - } - - public static List getListFilesIncludeTypes(ShareListFilesAndDirectoriesOptions options) { - if (options == null) { - return null; - } - List includeTypes = new ArrayList<>(); - - if (options.includeAll()) { - includeTypes.add(ListFilesIncludeType.ALL); - } else { - addOptionToList(includeTypes, options.includeAttributes(), ListFilesIncludeType.ATTRIBUTES); - addOptionToList(includeTypes, options.includeETag(), ListFilesIncludeType.ETAG); - addOptionToList(includeTypes, options.includeTimestamps(), ListFilesIncludeType.TIMESTAMPS); - addOptionToList(includeTypes, options.includePermissionKey(), ListFilesIncludeType.PERMISSION_KEY); - addOptionToList(includeTypes, options.includeLinkCount(), ListFilesIncludeType.LINK_COUNT); - addOptionToList(includeTypes, options.includePermissions(), ListFilesIncludeType.PERMISSIONS); - addOptionToList(includeTypes, options.includeNfsAttributes(), ListFilesIncludeType.NFS_ATTRIBUTES); + res.getValue() + .getSegment() + .getDirectoryItems() + .forEach(directoryItem -> shareFileItems + .add(new ShareFileItem(ModelHelper.decodeName(directoryItem.getName()), true, + directoryItem.getFileId(), ModelHelper.transformFileProperty(directoryItem.getProperties()), + NtfsFileAttributes.toAttributes(directoryItem.getAttributes()), + directoryItem.getPermissionKey(), null))); + + res.getValue() + .getSegment() + .getFileItems() + .forEach(fileItem -> shareFileItems.add(new ShareFileItem(ModelHelper.decodeName(fileItem.getName()), + false, fileItem.getFileId(), ModelHelper.transformFileProperty(fileItem.getProperties()), + NtfsFileAttributes.toAttributes(fileItem.getAttributes()), fileItem.getPermissionKey(), + fileItem.getProperties().getContentLength()))); } - return includeTypes.isEmpty() ? null : includeTypes; - } - - private static boolean hasPosixProperties(FileProperty properties) { - return properties != null - && (properties.getUid() != null || properties.getGid() != null || properties.getMode() != null); - } - - private static ShareFileItem createDirectoryShareItem(DirectoryItem item) { - return toShareFileItem(item.getName(), true, item.getFileId(), item.getProperties(), item.getAttributes(), - item.getPermissionKey(), null, item.getLinkCount(), getDirectoryFileType(), null, null, null); - } - - private static ShareFileItem createFileShareItem(FileItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), item.getAttributes(), - item.getPermissionKey(), getContentLength(item.getProperties()), item.getLinkCount(), - item.getFileType() == null ? NfsFileType.REGULAR : item.getFileType(), null, null, null); - } - - private static ShareFileItem createSymLinkShareItem(SymLinkItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), null, null, null, - item.getLinkCount(), NfsFileType.SYM_LINK, item.getLinkText(), null, null); - } - - private static ShareFileItem createBlockDeviceShareItem(BlockDeviceItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), null, null, null, - item.getLinkCount(), NfsFileType.BLOCK_DEVICE, null, item.getDeviceMajor(), item.getDeviceMinor()); - } - - private static ShareFileItem createCharDeviceShareItem(CharDeviceItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), null, null, null, - item.getLinkCount(), NfsFileType.CHARACTER_DEVICE, null, item.getDeviceMajor(), item.getDeviceMinor()); - } - - private static ShareFileItem createFifoShareItem(FifoItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), null, null, null, - item.getLinkCount(), NfsFileType.FIFO, null, null, null); - } - - private static ShareFileItem createSocketShareItem(SocketItem item) { - return toShareFileItem(item.getName(), false, item.getFileId(), item.getProperties(), null, null, null, - item.getLinkCount(), NfsFileType.SOCKET, null, null, null); + return new ArrayList<>(shareFileItems); } public static Response diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/NfsFileType.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/NfsFileType.java index 407f7e3f92710..c252495b5def1 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/NfsFileType.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/NfsFileType.java @@ -1,6 +1,7 @@ // 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; import com.azure.core.annotation.Generated; @@ -8,15 +9,9 @@ import java.util.Collection; /** - * Type of the file. - *

- * This enumeration represents the type of file item in Azure Files shares. The file type is populated for all item - * types in both SMB and NFS-enabled shares. - * - * @see ShareFileItem#getFileType() + * Defines values for NfsFileType. */ public final class NfsFileType extends ExpandableStringEnum { - /** * Static value Regular for NfsFileType. */ @@ -35,33 +30,9 @@ public final class NfsFileType extends ExpandableStringEnum { @Generated public static final NfsFileType SYM_LINK = fromString("SymLink"); - /** - * Static value BlockDevice for NfsFileType. - */ - @Generated - public static final NfsFileType BLOCK_DEVICE = fromString("BlockDevice"); - - /** - * Static value CharacterDevice for NfsFileType. - */ - @Generated - public static final NfsFileType CHARACTER_DEVICE = fromString("CharacterDevice"); - - /** - * Static value Socket for NfsFileType. - */ - @Generated - public static final NfsFileType SOCKET = fromString("Socket"); - - /** - * Static value Fifo for NfsFileType. - */ - @Generated - public static final NfsFileType FIFO = fromString("Fifo"); - /** * Creates a new instance of NfsFileType value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @@ -71,7 +42,7 @@ public NfsFileType() { /** * Creates or finds a NfsFileType from its string representation. - * + * * @param name a name to look for. * @return the corresponding NfsFileType. */ @@ -82,7 +53,7 @@ public static NfsFileType fromString(String name) { /** * Gets known NfsFileType values. - * + * * @return known NfsFileType values. */ @Generated diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItem.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItem.java index db04361e6ea58..991cdf61f3e81 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItem.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItem.java @@ -4,7 +4,6 @@ package com.azure.storage.file.share.models; import com.azure.core.annotation.Immutable; -import com.azure.storage.file.share.implementation.accesshelpers.ShareFileItemConstructorProxy; import java.util.EnumSet; @@ -20,15 +19,6 @@ public final class ShareFileItem { private final EnumSet fileAttributes; private final String permissionKey; private final Long fileSize; - private final Long linkCount; - private final NfsFileType fileType; - private final String linkText; - private final Long deviceMajor; - private final Long deviceMinor; - - static { - ShareFileItemConstructorProxy.setAccessor(ShareFileItem::new); - } /** * Creates an instance of file or directory reference information about a specific Share. @@ -38,7 +28,7 @@ public final class ShareFileItem { * @param fileSize Size of a file. Pass {@code null} if the reference is a directory. */ public ShareFileItem(String name, boolean isDirectory, Long fileSize) { - this(name, isDirectory, null, null, null, null, fileSize, null, null, null, null, null); + this(name, isDirectory, null, null, null, null, fileSize); } /** @@ -54,12 +44,6 @@ public ShareFileItem(String name, boolean isDirectory, Long fileSize) { */ public ShareFileItem(String name, boolean isDirectory, String id, ShareFileItemProperties properties, EnumSet fileAttributes, String permissionKey, Long fileSize) { - this(name, isDirectory, id, properties, fileAttributes, permissionKey, fileSize, null, null, null, null, null); - } - - private ShareFileItem(String name, boolean isDirectory, String id, ShareFileItemProperties properties, - EnumSet fileAttributes, String permissionKey, Long fileSize, Long linkCount, - NfsFileType fileType, String linkText, Long deviceMajor, Long deviceMinor) { this.name = name; this.isDirectory = isDirectory; this.id = id; @@ -67,11 +51,6 @@ private ShareFileItem(String name, boolean isDirectory, String id, ShareFileItem this.fileAttributes = fileAttributes; this.permissionKey = permissionKey; this.fileSize = fileSize; - this.linkCount = linkCount; - this.fileType = fileType; - this.linkText = linkText; - this.deviceMajor = deviceMajor; - this.deviceMinor = deviceMinor; } /** @@ -136,62 +115,4 @@ public EnumSet getFileAttributes() { public String getPermissionKey() { return permissionKey; } - - /** - * Gets the count of hard links for this item. - * Applicable to all item types in NFS shares: files, directories, symbolic links, block devices, character - * devices, FIFOs, and sockets. - * Supported in version 2026-12-06 and above. - * - * @return The count of hard links for this item. - */ - public Long getLinkCount() { - return linkCount; - } - - /** - * Gets the file type for this item. - * In SMB shares, this field is populated for files and directories. - * In NFS-enabled shares, this field is populated for files, directories, symbolic links, block devices, - * character devices, FIFOs, and sockets. - * Supported in version 2026-12-06 and above. - * - * @return The file type for this item. - */ - public NfsFileType getFileType() { - return fileType; - } - - /** - * Gets the link text for this item. - * Only applicable to symbolic links in NFS shares. - * Supported in version 2026-12-06 and above. - * - * @return The link text for this item. - */ - public String getLinkText() { - return linkText; - } - - /** - * Gets the major device number for this item. - * Only applicable to block devices and character devices in NFS shares. - * Supported in version 2026-12-06 and above. - * - * @return The major device number for this item. - */ - public Long getDeviceMajor() { - return deviceMajor; - } - - /** - * Gets the minor device number for this item. - * Only applicable to block devices and character devices in NFS shares. - * Supported in version 2026-12-06 and above. - * - * @return The minor device number for this item. - */ - public Long getDeviceMinor() { - return deviceMinor; - } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItemProperties.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItemProperties.java index cbff26d7baa3e..5a817fe23ff96 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItemProperties.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/models/ShareFileItemProperties.java @@ -51,31 +51,4 @@ public interface ShareFileItemProperties { * @return ETag of this item. */ String getETag(); - - /** - * Gets the owner user identifier (UID) for this item. - * - * @return The owner user identifier (UID), or {@code null} if not returned by the service. - */ - default String getOwner() { - return null; - } - - /** - * Gets the owning group identifier (GID) for this item. - * - * @return The owning group identifier (GID), or {@code null} if not returned by the service. - */ - default String getGroup() { - return null; - } - - /** - * Gets the POSIX file mode for this item. - * - * @return The POSIX file mode, or {@code null} if not returned by the service. - */ - default String getFileMode() { - return null; - } } diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareListFilesAndDirectoriesOptions.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareListFilesAndDirectoriesOptions.java index 0c063ab0aab90..0b5138331c401 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareListFilesAndDirectoriesOptions.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/options/ShareListFilesAndDirectoriesOptions.java @@ -14,10 +14,6 @@ public final class ShareListFilesAndDirectoriesOptions { private boolean includeAttributes; private boolean includePermissionKey; private Boolean includeExtendedInfo; - private boolean includePermissions; - private boolean includeLinkCount; - private boolean includeNfsAttributes; - private boolean includeAll; /** * Creates a new instance of {@link ShareListFilesAndDirectoriesOptions}. @@ -175,84 +171,4 @@ public ShareListFilesAndDirectoriesOptions setIncludePermissionKey(boolean inclu this.includePermissionKey = includePermissionKey; return this; } - - /** - * Gets whether to include the permissions on a listing operation. - * - * @return Whether to include the permissions on this listing operation. - */ - public boolean includePermissions() { - return includePermissions; - } - - /** - * Sets whether to include the permissions on a listing operation. - * - * @param includePermissions Whether to include the permissions on this listing operation. - * @return Updated options. - */ - public ShareListFilesAndDirectoriesOptions setIncludePermissions(boolean includePermissions) { - this.includePermissions = includePermissions; - return this; - } - - /** - * Gets whether to include NFS attributes on a listing operation. - * - * @return Whether to include NFS attributes on this listing operation. - */ - public boolean includeNfsAttributes() { - return includeNfsAttributes; - } - - /** - * Sets whether to include NFS attributes on a listing operation. - * - * @param includeNfsAttributes Whether to include NFS attributes on this listing operation. - * @return Updated options. - */ - public ShareListFilesAndDirectoriesOptions setIncludeNfsAttributes(boolean includeNfsAttributes) { - this.includeNfsAttributes = includeNfsAttributes; - return this; - } - - /** - * Gets whether to include the link count on a listing operation. - * - * @return Whether to include the link count on this listing operation. - */ - public boolean includeLinkCount() { - return includeLinkCount; - } - - /** - * Sets whether to include the link count on a listing operation. - * - * @param includeLinkCount Whether to include the link count on this listing operation. - * @return Updated options. - */ - public ShareListFilesAndDirectoriesOptions setIncludeLinkCount(boolean includeLinkCount) { - this.includeLinkCount = includeLinkCount; - return this; - } - - /** - * Gets whether to include all optional values on a listing operation. - * - * @return Whether to include all optional values on this listing operation. - */ - public boolean includeAll() { - return includeAll; - } - - /** - * Sets whether to include all optional values on a listing operation. - * - * @param includeAll Whether to include all optional values on this listing operation. - * @return Updated options. - */ - public ShareListFilesAndDirectoriesOptions setIncludeAll(boolean includeAll) { - this.includeAll = includeAll; - return this; - } } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 19944f3fbb34e..6f3ff54d53ee1 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -36,8 +36,6 @@ import com.azure.storage.file.share.models.ShareTokenIntent; import com.azure.storage.file.share.options.ShareDirectoryCreateOptions; import com.azure.storage.file.share.options.ShareDirectorySetPropertiesOptions; -import com.azure.storage.file.share.options.ShareFileCreateOptions; -import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; import com.azure.storage.file.share.options.ShareFileRenameOptions; import com.azure.storage.file.share.options.ShareListFilesAndDirectoriesOptions; import com.azure.storage.file.share.sas.ShareFileSasPermission; @@ -917,150 +915,6 @@ public void listFilesAndDirectoriesExtendedInfoResults() { assertFalse(FileShareTestHelper.isAllWhitespace(fileListItem.getProperties().getETag())); } - @Test - @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2026-12-06") - public void listFilesAndDirectoriesAllTraitsSmb() { - ShareDirectoryClient parentDir = primaryDirectoryClient; - parentDir.create(); - ShareFileClient file = parentDir.createFile(generatePathName(), Constants.KB); - ShareDirectoryClient subDir = parentDir.createSubdirectory(generatePathName()); - ShareListFilesAndDirectoriesOptions allOptions - = new ShareListFilesAndDirectoriesOptions().setIncludeExtendedInfo(true).setIncludeAll(true); - - List listResults - = parentDir.listFilesAndDirectories(allOptions, null, null).stream().collect(Collectors.toList()); - - String expectedFileName = new File(file.getFilePath()).getName(); - ShareFileItem fileItem = listResults.stream() - .filter(item -> expectedFileName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + expectedFileName)); - - assertEquals(2, listResults.size()); - assertFalse(fileItem.isDirectory()); - assertNotNull(fileItem.getId()); - assertEquals(EnumSet.of(NtfsFileAttributes.ARCHIVE), fileItem.getFileAttributes()); - assertNotNull(fileItem.getPermissionKey()); - assertNotNull(fileItem.getProperties()); - assertNotNull(fileItem.getProperties().getCreatedOn()); - assertNotNull(fileItem.getProperties().getLastAccessedOn()); - assertNotNull(fileItem.getProperties().getLastWrittenOn()); - assertNotNull(fileItem.getProperties().getChangedOn()); - assertNotNull(fileItem.getProperties().getLastModified()); - assertNotNull(fileItem.getProperties().getETag()); - - assertNull(fileItem.getLinkCount()); - assertEquals(NfsFileType.REGULAR, fileItem.getFileType()); - assertNull(fileItem.getProperties().getOwner()); - assertNull(fileItem.getProperties().getGroup()); - assertNull(fileItem.getProperties().getFileMode()); - - String expectedDirectoryName = new File(subDir.getDirectoryPath()).getName(); - ShareFileItem dirItem = listResults.stream() - .filter(item -> expectedDirectoryName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + expectedDirectoryName)); - assertTrue(dirItem.isDirectory()); - assertNotNull(dirItem.getId()); - assertEquals(EnumSet.of(NtfsFileAttributes.DIRECTORY), dirItem.getFileAttributes()); - assertNotNull(dirItem.getPermissionKey()); - assertNotNull(dirItem.getProperties()); - assertNotNull(dirItem.getProperties().getCreatedOn()); - assertNotNull(dirItem.getProperties().getLastAccessedOn()); - assertNotNull(dirItem.getProperties().getLastWrittenOn()); - assertNotNull(dirItem.getProperties().getChangedOn()); - assertNotNull(dirItem.getProperties().getLastModified()); - assertNotNull(dirItem.getProperties().getETag()); - - assertNull(dirItem.getLinkCount()); - assertNull(dirItem.getProperties().getOwner()); - assertNull(dirItem.getProperties().getGroup()); - assertNull(dirItem.getProperties().getFileMode()); - } - - @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2026-12-06") - @Test - public void listFilesAndDirectoriesNfs() { - ShareClient premiumShareClient = getPremiumNFSShareClient(generateShareName()); - - try { - ShareDirectoryClient parent = premiumShareClient.getDirectoryClient(generatePathName()); - parent.create(); - - String owner = "345"; - String group = "123"; - String fileMode = "7777"; - FilePosixProperties posixProperties - = new FilePosixProperties().setOwner(owner).setGroup(group).setFileMode(fileMode); - - String fileName = generatePathName(); - ShareFileClient file = parent.getFileClient(fileName); - file.createWithResponse(new ShareFileCreateOptions(Constants.MB).setPosixProperties(posixProperties), null, - null); - - String subdirName = generatePathName(); - ShareDirectoryClient subdir = parent.getSubdirectoryClient(subdirName); - subdir.createWithResponse(new ShareDirectoryCreateOptions().setPosixProperties(posixProperties), null, - null); - - String symlinkName = generatePathName(); - ShareFileClient symlink = parent.getFileClient(symlinkName); - symlink.createSymbolicLinkWithResponse( - new ShareFileCreateSymbolicLinkOptions(file.getFileUrl()).setOwner(owner).setGroup(group), null, null); - - ShareListFilesAndDirectoriesOptions options - = new ShareListFilesAndDirectoriesOptions().setIncludeExtendedInfo(true) - .setIncludeTimestamps(true) - .setIncludeETag(true) - .setIncludePermissions(true) - .setIncludeLinkCount(true) - .setIncludeNfsAttributes(true); - List items - = parent.listFilesAndDirectories(options, null, null).stream().collect(Collectors.toList()); - - assertEquals(3, items.size()); - - ShareFileItem fileItem = items.stream() - .filter(item -> fileName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + fileName)); - assertFalse(fileItem.isDirectory()); - assertEquals(NfsFileType.REGULAR, fileItem.getFileType()); - assertNotNull(fileItem.getLinkCount()); - assertNotNull(fileItem.getProperties()); - assertEquals(owner, fileItem.getProperties().getOwner()); - assertEquals(group, fileItem.getProperties().getGroup()); - assertEquals(fileMode, fileItem.getProperties().getFileMode()); - - ShareFileItem dirItem = items.stream() - .filter(item -> subdirName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + subdirName)); - assertTrue(dirItem.isDirectory()); - assertEquals(NfsFileType.DIRECTORY, dirItem.getFileType()); - assertNotNull(dirItem.getLinkCount()); - assertNotNull(dirItem.getProperties()); - assertEquals(owner, dirItem.getProperties().getOwner()); - assertEquals(group, dirItem.getProperties().getGroup()); - assertEquals(fileMode, dirItem.getProperties().getFileMode()); - - ShareFileItem symlinkItem = items.stream() - .filter(item -> symlinkName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + symlinkName)); - assertFalse(symlinkItem.isDirectory()); - assertEquals(NfsFileType.SYM_LINK, symlinkItem.getFileType()); - assertNotNull(symlinkItem.getLinkCount()); - assertNotNull(symlinkItem.getLinkText()); - assertFalse(FileShareTestHelper.isAllWhitespace(symlinkItem.getLinkText())); - assertNotNull(symlinkItem.getProperties()); - assertEquals(owner, symlinkItem.getProperties().getOwner()); - assertEquals(group, symlinkItem.getProperties().getGroup()); - } finally { - premiumShareClient.delete(); - } - } - @Test @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2021-12-02") public void listFilesAndDirectoriesEncoded() { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 749addc8e4b46..e4329f218fca0 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -27,10 +27,7 @@ import com.azure.storage.file.share.models.ShareTokenIntent; import com.azure.storage.file.share.options.ShareDirectoryCreateOptions; import com.azure.storage.file.share.options.ShareDirectorySetPropertiesOptions; -import com.azure.storage.file.share.options.ShareFileCreateOptions; -import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; import com.azure.storage.file.share.options.ShareFileRenameOptions; -import com.azure.storage.file.share.options.ShareListFilesAndDirectoriesOptions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -539,154 +536,6 @@ private static Stream listFilesAndDirectoriesArgsSupplier() { return Stream.of(Arguments.of("", null, 3), Arguments.of("", 1, 3), Arguments.of("noops", 3, 0)); } - @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2026-12-06") - @Test - public void listFilesAndDirectoriesAllTraitsSmb() { - String fileName = generatePathName(); - String subdirName = generatePathName(); - Mono> listResults = primaryDirectoryAsyncClient.create() - .then(primaryDirectoryAsyncClient.createFile(fileName, Constants.KB)) - .then(primaryDirectoryAsyncClient.createSubdirectory(subdirName)) - .thenMany(primaryDirectoryAsyncClient.listFilesAndDirectories( - new ShareListFilesAndDirectoriesOptions().setIncludeExtendedInfo(true).setIncludeAll(true))) - .collectList(); - - StepVerifier.create(listResults).assertNext(items -> { - assertEquals(2, items.size()); - - ShareFileItem fileItem = items.stream() - .filter(item -> fileName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + fileName)); - assertFalse(fileItem.isDirectory()); - assertNotNull(fileItem.getId()); - assertEquals(EnumSet.of(NtfsFileAttributes.ARCHIVE), fileItem.getFileAttributes()); - assertNotNull(fileItem.getPermissionKey()); - assertNotNull(fileItem.getProperties()); - assertNotNull(fileItem.getProperties().getCreatedOn()); - assertNotNull(fileItem.getProperties().getLastAccessedOn()); - assertNotNull(fileItem.getProperties().getLastWrittenOn()); - assertNotNull(fileItem.getProperties().getChangedOn()); - assertNotNull(fileItem.getProperties().getLastModified()); - assertNotNull(fileItem.getProperties().getETag()); - assertNull(fileItem.getLinkCount()); - assertEquals(NfsFileType.REGULAR, fileItem.getFileType()); - assertNull(fileItem.getProperties().getOwner()); - assertNull(fileItem.getProperties().getGroup()); - assertNull(fileItem.getProperties().getFileMode()); - - ShareFileItem dirItem = items.stream() - .filter(item -> subdirName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + subdirName)); - assertTrue(dirItem.isDirectory()); - assertNotNull(dirItem.getId()); - assertEquals(EnumSet.of(NtfsFileAttributes.DIRECTORY), dirItem.getFileAttributes()); - assertNotNull(dirItem.getPermissionKey()); - assertNotNull(dirItem.getProperties()); - assertNotNull(dirItem.getProperties().getCreatedOn()); - assertNotNull(dirItem.getProperties().getLastAccessedOn()); - assertNotNull(dirItem.getProperties().getLastWrittenOn()); - assertNotNull(dirItem.getProperties().getChangedOn()); - assertNotNull(dirItem.getProperties().getLastModified()); - assertNotNull(dirItem.getProperties().getETag()); - assertNull(dirItem.getLinkCount()); - - assertNull(dirItem.getProperties().getOwner()); - assertNull(dirItem.getProperties().getGroup()); - assertNull(dirItem.getProperties().getFileMode()); - }).verifyComplete(); - } - - @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2026-12-06") - @Test - public void listFilesAndDirectoriesNfs() { - String premiumShareName = generateShareName(); - String fileName = generatePathName(); - String subdirName = generatePathName(); - String symlinkName = generatePathName(); - String owner = "345"; - String group = "123"; - String fileMode = "7777"; - - Mono> createAndList - = getPremiumNFSShareAsyncClient(premiumShareName).flatMap(premiumShareClient -> { - ShareDirectoryAsyncClient parent = premiumShareClient.getDirectoryClient(generatePathName()); - FilePosixProperties posixProperties - = new FilePosixProperties().setOwner(owner).setGroup(group).setFileMode(fileMode); - - ShareFileAsyncClient file = parent.getFileClient(fileName); - ShareDirectoryAsyncClient subdir = parent.getSubdirectoryClient(subdirName); - ShareFileAsyncClient symlink = parent.getFileClient(symlinkName); - - ShareFileCreateOptions fileOptions - = new ShareFileCreateOptions(Constants.MB).setPosixProperties(posixProperties); - ShareDirectoryCreateOptions subdirOptions - = new ShareDirectoryCreateOptions().setPosixProperties(posixProperties); - ShareFileCreateSymbolicLinkOptions symlinkOptions - = new ShareFileCreateSymbolicLinkOptions(file.getFileUrl()).setOwner(owner).setGroup(group); - ShareListFilesAndDirectoriesOptions listOptions - = new ShareListFilesAndDirectoriesOptions().setIncludeExtendedInfo(true) - .setIncludeTimestamps(true) - .setIncludeETag(true) - .setIncludePermissions(true) - .setIncludeLinkCount(true) - .setIncludeNfsAttributes(true); - - return parent.create() - .then(file.createWithResponse(fileOptions)) - .then(subdir.createWithResponse(subdirOptions)) - .then(symlink.createSymbolicLinkWithResponse(symlinkOptions)) - .thenMany(parent.listFilesAndDirectories(listOptions)) - .collectList(); - }); - - try { - StepVerifier.create(createAndList).assertNext(items -> { - assertEquals(3, items.size()); - - ShareFileItem fileItem = items.stream() - .filter(item -> fileName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + fileName)); - assertFalse(fileItem.isDirectory()); - assertEquals(NfsFileType.REGULAR, fileItem.getFileType()); - assertNotNull(fileItem.getLinkCount()); - assertNotNull(fileItem.getProperties()); - assertEquals(owner, fileItem.getProperties().getOwner()); - assertEquals(group, fileItem.getProperties().getGroup()); - assertEquals(fileMode, fileItem.getProperties().getFileMode()); - - ShareFileItem dirItem = items.stream() - .filter(item -> subdirName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + subdirName)); - assertTrue(dirItem.isDirectory()); - assertEquals(NfsFileType.DIRECTORY, dirItem.getFileType()); - assertNotNull(dirItem.getLinkCount()); - assertNotNull(dirItem.getProperties()); - assertEquals(owner, dirItem.getProperties().getOwner()); - assertEquals(group, dirItem.getProperties().getGroup()); - assertEquals(fileMode, dirItem.getProperties().getFileMode()); - - ShareFileItem symlinkItem = items.stream() - .filter(item -> symlinkName.equals(item.getName())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found: " + symlinkName)); - assertFalse(symlinkItem.isDirectory()); - assertEquals(NfsFileType.SYM_LINK, symlinkItem.getFileType()); - assertNotNull(symlinkItem.getLinkCount()); - assertNotNull(symlinkItem.getLinkText()); - assertFalse(FileShareTestHelper.isAllWhitespace(symlinkItem.getLinkText())); - assertNotNull(symlinkItem.getProperties()); - assertEquals(owner, symlinkItem.getProperties().getOwner()); - assertEquals(group, symlinkItem.getProperties().getGroup()); - }).verifyComplete(); - } finally { - premiumFileServiceAsyncClient.getShareAsyncClient(premiumShareName).delete().block(); - } - } - @ParameterizedTest @MethodSource("listHandlesSupplier") public void listHandles(Integer maxResults, boolean recursive) { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryListingDeserializationTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryListingDeserializationTests.java deleted file mode 100644 index a1e2e8df330e7..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryListingDeserializationTests.java +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.file.share; - -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.storage.file.share.models.NfsFileType; -import com.azure.storage.file.share.models.ShareFileItem; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; - -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class DirectoryListingDeserializationTests { - private static final String LIST_FILES_AND_DIRECTORIES_RESPONSE = "testfiles/ListFilesAndDirectoriesResponse.xml"; - - @Test - public void listFilesAndDirectoriesNfsAllItemTypes() throws Exception { - String xml = readResource(LIST_FILES_AND_DIRECTORIES_RESPONSE); - HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just( - new MockHttpResponse(request, 200, new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/xml"), - xml.getBytes(StandardCharsets.UTF_8)))) - .build(); - - ShareDirectoryClient directory = new ShareFileClientBuilder().endpoint("https://account.file.core.windows.net") - .shareName("myshare") - .resourcePath("mydir") - .serviceVersion(ShareServiceVersion.V2027_03_07) - .pipeline(httpPipeline) - .buildDirectoryClient(); - - List items = directory.listFilesAndDirectories().stream().collect(Collectors.toList()); - - assertAllNfsItemTypes(items); - } - - @Test - public void listFilesAndDirectoriesNfsAllItemTypesAsync() throws Exception { - String xml = readResource(LIST_FILES_AND_DIRECTORIES_RESPONSE); - HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(request -> Mono.just( - new MockHttpResponse(request, 200, new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/xml"), - xml.getBytes(StandardCharsets.UTF_8)))) - .build(); - - ShareDirectoryAsyncClient directory - = new ShareFileClientBuilder().endpoint("https://account.file.core.windows.net") - .shareName("myshare") - .resourcePath("mydir") - .serviceVersion(ShareServiceVersion.V2027_03_07) - .pipeline(httpPipeline) - .buildDirectoryAsyncClient(); - - List items = directory.listFilesAndDirectories().collectList().block(); - - assertAllNfsItemTypes(items); - } - - private static void assertAllNfsItemTypes(List items) { - assertEquals(10, items.size()); - - ShareFileItem dir = getItemByFileType(items, NfsFileType.DIRECTORY); - assertTrue(dir.isDirectory()); - assertEquals("subdir", dir.getName()); - assertEquals("12682206919419625485", dir.getId()); - assertEquals(Long.valueOf(2), dir.getLinkCount()); - assertNull(dir.getFileSize()); - assertPosixProperties(dir, "1000", "1000", "0755"); - assertEquals("\"0x8DEAF1479E1C087\"", dir.getProperties().getETag()); - - List files = items.stream() - .filter(item -> !item.isDirectory() && item.getFileType() == NfsFileType.REGULAR) - .collect(Collectors.toList()); - assertEquals(4, files.size()); - files.forEach(file -> { - assertFalse(file.isDirectory()); - assertPosixProperties(file, "1000", "1000", "0644"); - }); - - assertListedFileItem(files.get(0), "hardlink.txt", "13835128424026472451", 80L, 2L); - assertListedFileItem(files.get(1), "regular.txt", "13835128424026472451", 80L, 2L); - assertListedFileItem(files.get(2), "regularClose.txt", "9799903157902508049", 14L, 1L); - assertListedFileItem(files.get(3), "regularOpen.txt", "17293892937847013391", 14L, 1L); - - ShareFileItem symlink = getItemByFileType(items, NfsFileType.SYM_LINK); - assertFalse(symlink.isDirectory()); - assertEquals("symlink.txt", symlink.getName()); - assertEquals("10376363910205931529", symlink.getId()); - assertEquals(Long.valueOf(1), symlink.getLinkCount()); - assertEquals("/mnt/s2/dir2/regular.txt", symlink.getLinkText()); - assertPosixProperties(symlink, "1000", "1000", "0777"); - - ShareFileItem block = getItemByFileType(items, NfsFileType.BLOCK_DEVICE); - assertEquals("block_device", block.getName()); - assertEquals("10952824662509355033", block.getId()); - assertEquals(Long.valueOf(1), block.getLinkCount()); - assertEquals(Long.valueOf(8), block.getDeviceMajor()); - assertEquals(Long.valueOf(0), block.getDeviceMinor()); - assertPosixProperties(block, "0", "0", "0640"); - - ShareFileItem charDev = getItemByFileType(items, NfsFileType.CHARACTER_DEVICE); - assertEquals("char_device", charDev.getName()); - assertEquals("16717432185543589911", charDev.getId()); - assertEquals(Long.valueOf(1), charDev.getLinkCount()); - assertEquals(Long.valueOf(1), charDev.getDeviceMajor()); - assertEquals(Long.valueOf(7), charDev.getDeviceMinor()); - assertPosixProperties(charDev, "0", "0", "0644"); - - ShareFileItem fifo = getItemByFileType(items, NfsFileType.FIFO); - assertEquals("fifo_pipe", fifo.getName()); - assertEquals("14988049928633319435", fifo.getId()); - assertEquals(Long.valueOf(1), fifo.getLinkCount()); - assertNull(fifo.getDeviceMajor()); - assertNull(fifo.getDeviceMinor()); - assertNull(fifo.getLinkText()); - assertPosixProperties(fifo, "1000", "1000", "0644"); - - ShareFileItem socket = getItemByFileType(items, NfsFileType.SOCKET); - assertEquals("unix_socket", socket.getName()); - assertEquals("16429201809391878183", socket.getId()); - assertEquals(Long.valueOf(1), socket.getLinkCount()); - assertNull(socket.getDeviceMajor()); - assertNull(socket.getDeviceMinor()); - assertNull(socket.getLinkText()); - assertPosixProperties(socket, "0", "0", "0755"); - } - - private static ShareFileItem getItemByFileType(List items, NfsFileType fileType) { - return items.stream() - .filter(item -> fileType.equals(item.getFileType())) - .findFirst() - .orElseThrow(() -> new AssertionError("Expected listed item not found for type: " + fileType)); - } - - private static void assertListedFileItem(ShareFileItem item, String name, String id, long fileSize, - long linkCount) { - assertEquals(name, item.getName()); - assertEquals(id, item.getId()); - assertEquals(Long.valueOf(fileSize), item.getFileSize()); - assertEquals(Long.valueOf(linkCount), item.getLinkCount()); - } - - private static void assertPosixProperties(ShareFileItem item, String owner, String group, String fileMode) { - assertNotNull(item.getProperties()); - assertEquals(owner, item.getProperties().getOwner()); - assertEquals(group, item.getProperties().getGroup()); - assertEquals(fileMode, item.getProperties().getFileMode()); - } - - private static String readResource(String resourceName) throws Exception { - URL resource = DirectoryListingDeserializationTests.class.getClassLoader().getResource(resourceName); - assertNotNull(resource); - return new String(Files.readAllBytes(Paths.get(resource.toURI())), StandardCharsets.UTF_8); - } -} diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/testfiles/ListFilesAndDirectoriesResponse.xml b/sdk/storage/azure-storage-file-share/src/test/resources/testfiles/ListFilesAndDirectoriesResponse.xml deleted file mode 100644 index df6e051b2063a..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/test/resources/testfiles/ListFilesAndDirectoriesResponse.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - subdir - 12682206919419625485 - - 2025-10-01T00:00:00Z - 2025-10-01T00:00:00Z - 2025-10-01T00:00:00Z - 2025-10-01T00:00:00Z - Wed, 01 Oct 2025 00:00:00 GMT - "0x8DEAF1479E1C087" - 1000 - 1000 - 0755 - - 2 - - - hardlink.txt - 13835128424026472451 - - 80 - 1000 - 1000 - 0644 - - 2 - - - regular.txt - 13835128424026472451 - - 80 - 1000 - 1000 - 0644 - - 2 - - - regularClose.txt - 9799903157902508049 - - 14 - 1000 - 1000 - 0644 - - 1 - - - regularOpen.txt - 17293892937847013391 - - 14 - 1000 - 1000 - 0644 - - 1 - - - symlink.txt - 10376363910205931529 - - 1000 - 1000 - 0777 - - 1 - /mnt/s2/dir2/regular.txt - - - block_device - 10952824662509355033 - - 0 - 0 - 0640 - - 1 - 8 - 0 - - - char_device - 16717432185543589911 - - 0 - 0 - 0644 - - 1 - 1 - 7 - - - fifo_pipe - 14988049928633319435 - - 1000 - 1000 - 0644 - - 1 - - - unix_socket - 16429201809391878183 - - 0 - 0 - 0755 - - 1 - - - - diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 223d605db8f0d..8a6b604a43fbf 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/seanmcc-msft/azure-rest-api-specs/e38b4c39072e9c00e3607cde729cea2e8d237b92/specification/storage/data-plane/Microsoft.FileStorage/stable/2026-12-06/file.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/15d7f54a5389d5906ffb4e56bb2f38fe5525c0d3/specification/storage/data-plane/Microsoft.FileStorage/stable/2026-06-06/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share diff --git a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java index e106aa49f0684..74f8922fbf89e 100644 --- a/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java +++ b/sdk/storage/azure-storage-file-share/swagger/src/main/java/ShareStorageCustomization.java @@ -32,14 +32,6 @@ public void customize(LibraryCustomization customization, Logger logger) { + "that all file/directory ACLs are bypassed and full permissions are granted. User must also have " + "required RBAC permission."))); - customization.getClass("com.azure.storage.file.share.models", "NfsFileType") - .customizeAst(ast -> ast.getClassByName("NfsFileType").ifPresent(clazz -> clazz.setJavadocComment( - - "Type of the file.\n

\n" - + "This enumeration represents the type of file item in Azure Files shares. " - + "The file type is populated for all item types in both SMB and NFS-enabled shares.\n\n" - + "@see ShareFileItem#getFileType()"))); - updateImplToMapInternalException(customization.getPackage("com.azure.storage.file.share.implementation")); } From 1711153aabfa1a0b88343a06a63ff9bd2133c62a Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 1 Oct 2026 17:17:18 -0400 Subject: [PATCH 26/39] add recordings for prev features that were missing --- sdk/storage/azure-storage-file-share/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 2096399e6a768..95f4e88276e86 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_1e9eb49640" + "Tag": "java/storage/azure-storage-file-share_c861318b2a" } From febff5553b755551a35adcacf62abf067b147b31 Mon Sep 17 00:00:00 2001 From: browndav Date: Wed, 14 Oct 2026 20:46:09 -0400 Subject: [PATCH 27/39] remove public apis for sharefileasync client and sync client --- .../file/share/ShareFileAsyncClient.java | 23 +------------------ .../storage/file/share/ShareFileClient.java | 11 --------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index be329781a464e..ac7b128b08b12 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -247,16 +247,6 @@ AzureSasCredential getSasToken() { return sasToken; } - /** - * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. - * - * @return A response containing the file properties and hard links. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getFileLinksWithResponse() { - return getFileLinksWithResponse(null); - } - /** * SMB only. Gets the hard links to this file. This operation is available only for a file-ID-addressed client. * @@ -288,18 +278,7 @@ Mono> getFileLinksWithResponse(ShareRequestConditions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getFileLinks() { - return getFileLinks(null); - } - - /** - * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. - * - * @param requestConditions Conditions to apply to the request. - * @return The file properties and hard links. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getFileLinks(ShareRequestConditions requestConditions) { - return getFileLinksWithResponse(requestConditions).flatMap(FluxUtil::toMono); + return getFileLinksWithResponse(null, null).flatMap(FluxUtil::toMono); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index db123eec688e0..1da15c91dff72 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -292,17 +292,6 @@ public ShareFileLinks getFileLinks() { return getFileLinksWithResponse().getValue(); } - /** - * SMB only. Gets the file links. This operation is available only for a file-ID-addressed client. - * - * @param requestConditions Conditions to apply to the request. - * @return The file properties and hard links. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public ShareFileLinks getFileLinks(ShareRequestConditions requestConditions) { - return getFileLinksWithResponse(requestConditions, null, Context.NONE).getValue(); - } - /** * Opens a file input stream to download the file. * From 3952d1a5747280d22753107e89d2c8d7297723be Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 15 Oct 2026 12:55:22 -0400 Subject: [PATCH 28/39] Update File Share Swagger input --- sdk/storage/azure-storage-file-share/swagger/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 8218c5ccc3a56..8066adea00630 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/74d5b5955847c39b2dce9dceadf051badc506bf4/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json +input-file: https://raw.githubusercontent.com/browndav-msft/azure-rest-api-specs/07f71db82db9fb100b4097666db6fddff84fd0a3/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share From 9a38abc98fcf6d490b0952809ac976f895915add Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 15 Oct 2026 13:52:26 -0400 Subject: [PATCH 29/39] fix sharefileasyncclient convenience method --- .../java/com/azure/storage/file/share/ShareFileAsyncClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index ac7b128b08b12..10e161561d114 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -278,7 +278,7 @@ Mono> getFileLinksWithResponse(ShareRequestConditions r */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono getFileLinks() { - return getFileLinksWithResponse(null, null).flatMap(FluxUtil::toMono); + return getFileLinksWithResponse(null).flatMap(FluxUtil::toMono); } /** From 3ca83e01ba2d111d0f38e431c8a2691893dc8676 Mon Sep 17 00:00:00 2001 From: browndav Date: Sun, 18 Oct 2026 19:17:05 -0400 Subject: [PATCH 30/39] update filesimpl to reflect that hardlinks are smb only --- .../file/share/implementation/FilesImpl.java | 18 +++++++++--------- .../azure-storage-file-share/swagger/README.md | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java index 27f4bd0670274..b0f43d2413ee3 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/FilesImpl.java @@ -1613,7 +1613,7 @@ Response createHardLinkNoCustomHeadersSync(@HostParam("url") String url, /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1642,7 +1642,7 @@ public Mono> getHardLinksWi /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1675,7 +1675,7 @@ public Mono> getHardLinksWi /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1702,7 +1702,7 @@ public Mono getHardLinksAsync(String shareName, String fileId, Str /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1730,7 +1730,7 @@ public Mono getHardLinksAsync(String shareName, String fileId, Str /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1758,7 +1758,7 @@ public Mono> getHardLinksNoCustomHeadersWithResponseAsync /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1790,7 +1790,7 @@ public Mono> getHardLinksNoCustomHeadersWithResponseAsync /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1824,7 +1824,7 @@ public ResponseBase getHardLinksWithResp /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. @@ -1854,7 +1854,7 @@ public HardLinkList getHardLinks(String shareName, String fileId, String sharesn /** * Returns the hard links of a file, along with all user-defined metadata, content properties, and system properties - * for the file. NFS only. + * for the file. SMB only. * * @param shareName The name of the target share. * @param fileId The file ID of the file whose hard links are returned. diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 8066adea00630..40f95eafe312b 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/browndav-msft/azure-rest-api-specs/07f71db82db9fb100b4097666db6fddff84fd0a3/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json +input-file: C:\repos\azure-rest-api-specs\specification\storage\data-plane\Microsoft.FileStorage\stable\2027-03-07\file.json java: true output-folder: ../ namespace: com.azure.storage.file.share From d92e197029ccd1b13186d02abf45a6410bbcdb73 Mon Sep 17 00:00:00 2001 From: browndav Date: Sun, 18 Oct 2026 20:32:43 -0400 Subject: [PATCH 31/39] add changelog entry --- sdk/storage/azure-storage-file-share/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/storage/azure-storage-file-share/CHANGELOG.md b/sdk/storage/azure-storage-file-share/CHANGELOG.md index 0948c61e756b4..29c86d3e24e0f 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 support for retrieving file and directory properties by file ID +- Added support for retrieving a file's hard links by file ID on SMB shares. ### Breaking Changes From c6b5f8210cb852b60c40c2ac0b5571432cd029dc Mon Sep 17 00:00:00 2001 From: browndav Date: Mon, 19 Oct 2026 12:43:08 -0400 Subject: [PATCH 32/39] add error logging for ShareError in othe rplaces in code --- .../azure/storage/file/share/ShareFileClientBuilder.java | 4 +--- .../java/com/azure/storage/file/share/FileApiTests.java | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index 7c37e593cc591..43f05de9bd111 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -347,9 +347,7 @@ public ShareFileClientBuilder endpoint(String endpoint) { this.fileId = ""; String[] fileIdArray = queryParamsMap.remove("fileid"); if (fileIdArray != null) { - if (CoreUtils.isNullOrEmpty(fileIdArray[0])) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException("'fileId' cannot be empty.")); - } + ShareErrors.validateFileId(fileIdArray[0]); this.fileId = fileIdArray[0]; this.resourcePath = ""; } diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index 615161cfacd0f..caf0f0d2d5254 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -322,6 +322,12 @@ public void fileClientBuilderParsesFileIdFromEndpointQuery() { Assertions.assertEquals("file.txt", pathClient.getFilePath()); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(" ")); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(null)); + Assertions.assertThrows(IllegalArgumentException.class, + () -> new ShareFileClientBuilder().endpoint( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=")); + Assertions.assertThrows(IllegalArgumentException.class, + () -> new ShareFileClientBuilder().endpoint( + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=%20")); } @Test From 5cdebe2957a5c282f22e5022e40b4a022478d6fa Mon Sep 17 00:00:00 2001 From: browndav Date: Mon, 19 Oct 2026 13:16:03 -0400 Subject: [PATCH 33/39] url encode fileId --- .../file/share/ShareDirectoryAsyncClient.java | 17 +++--- .../file/share/ShareDirectoryClient.java | 18 +++---- .../file/share/ShareFileAsyncClient.java | 16 +++--- .../storage/file/share/ShareFileClient.java | 16 +++--- .../file/share/BuilderHelperTests.java | 54 +++++++++++++++++++ 5 files changed, 83 insertions(+), 38 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java index ede83986756a3..5b273b90b4614 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryAsyncClient.java @@ -147,20 +147,17 @@ public class ShareDirectoryAsyncClient { * @return the URL of the storage directory client */ public String getDirectoryUrl() { - StringBuilder directoryUrlString - = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + String directoryUrlString = azureFileStorageClient.getUrl() + "/" + shareName; if (fileId.isEmpty()) { - directoryUrlString.append("/").append(directoryPath); + directoryUrlString += "/" + directoryPath; } if (snapshot != null) { - directoryUrlString.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - directoryUrlString.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - directoryUrlString.append("?fileid=").append(fileId); + directoryUrlString = Utility.appendQueryParameter(directoryUrlString, "sharesnapshot", snapshot); } - return directoryUrlString.toString(); + if (!fileId.isEmpty()) { + directoryUrlString = Utility.appendQueryParameter(directoryUrlString, "fileid", Utility.urlEncode(fileId)); + } + return directoryUrlString; } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java index 707c54f2773b2..69f94cc0001cd 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareDirectoryClient.java @@ -20,6 +20,7 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import com.azure.storage.common.StorageSharedKeyCredential; +import com.azure.storage.common.Utility; import com.azure.storage.common.implementation.SasImplUtils; import com.azure.storage.common.implementation.StorageImplUtils; import com.azure.storage.file.share.implementation.AzureFileStorageImpl; @@ -139,20 +140,17 @@ public class ShareDirectoryClient { this.serviceVersion = serviceVersion; this.sasToken = sasToken; - StringBuilder directoryUrlString - = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + String directoryUrlString = azureFileStorageClient.getUrl() + "/" + shareName; if (fileId.isEmpty()) { - directoryUrlString.append("/").append(directoryPath); + directoryUrlString += "/" + directoryPath; } if (snapshot != null) { - directoryUrlString.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - directoryUrlString.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - directoryUrlString.append("?fileid=").append(fileId); + directoryUrlString = Utility.appendQueryParameter(directoryUrlString, "sharesnapshot", snapshot); + } + if (!fileId.isEmpty()) { + directoryUrlString = Utility.appendQueryParameter(directoryUrlString, "fileid", Utility.urlEncode(fileId)); } - this.directoryUrl = directoryUrlString.toString(); + this.directoryUrl = directoryUrlString; } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java index 10e161561d114..67dc5c906881f 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileAsyncClient.java @@ -210,19 +210,17 @@ public String getAccountUrl() { * @return the URL of the storage file client */ public String getFileUrl() { - StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + String fileUrlstring = azureFileStorageClient.getUrl() + "/" + shareName; if (fileId.isEmpty()) { - fileUrlstring.append("/").append(filePath); + fileUrlstring += "/" + filePath; } if (snapshot != null) { - fileUrlstring.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - fileUrlstring.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - fileUrlstring.append("?fileid=").append(fileId); + fileUrlstring = Utility.appendQueryParameter(fileUrlstring, "sharesnapshot", snapshot); + } + if (!fileId.isEmpty()) { + fileUrlstring = Utility.appendQueryParameter(fileUrlstring, "fileid", Utility.urlEncode(fileId)); } - return fileUrlstring.toString(); + return fileUrlstring; } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java index 1da15c91dff72..c97912c2fa606 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClient.java @@ -191,19 +191,17 @@ public class ShareFileClient { this.serviceVersion = serviceVersion; this.sasToken = sasToken; - StringBuilder fileUrlstring = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName); + String fileUrlstring = azureFileStorageClient.getUrl() + "/" + shareName; if (fileId.isEmpty()) { - fileUrlstring.append("/").append(filePath); + fileUrlstring += "/" + filePath; } if (snapshot != null) { - fileUrlstring.append("?sharesnapshot=").append(snapshot); - if (!fileId.isEmpty()) { - fileUrlstring.append("&fileid=").append(fileId); - } - } else if (!fileId.isEmpty()) { - fileUrlstring.append("?fileid=").append(fileId); + fileUrlstring = Utility.appendQueryParameter(fileUrlstring, "sharesnapshot", snapshot); + } + if (!fileId.isEmpty()) { + fileUrlstring = Utility.appendQueryParameter(fileUrlstring, "fileid", Utility.urlEncode(fileId)); } - this.fileUrlString = fileUrlstring.toString(); + this.fileUrlString = fileUrlstring; } /** diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java index 607cd78fd05d3..6a8c6600633bc 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java @@ -56,6 +56,60 @@ public class BuilderHelperTests { private static final RetryOptions CORE_RETRY_OPTIONS = new RetryOptions(new FixedDelayOptions(1, Duration.ofSeconds(2))); + @ParameterizedTest + @MethodSource("fileIdUrls") + void syncFileIdUrls(String fileId, String snapshot, String expectedUrl) { + ShareClient shareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME) + .getSnapshotClient(snapshot); + ShareFileClient fileClient = shareClient.getFileClientByFileId(fileId); + ShareDirectoryClient directoryClient = shareClient.getDirectoryClientByFileId(fileId); + + assertEquals(fileId, fileClient.getFileId()); + assertEquals(expectedUrl, fileClient.getFileUrl()); + assertEquals(fileId, directoryClient.getFileId()); + assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); + + ShareFileClient rebuiltClient + = new ShareFileClientBuilder().endpoint(fileClient.getFileUrl()).buildFileClient(); + assertEquals(fileId, rebuiltClient.getFileId()); + assertEquals(expectedUrl, rebuiltClient.getFileUrl()); + } + + @ParameterizedTest + @MethodSource("fileIdUrls") + void asyncFileIdUrls(String fileId, String snapshot, String expectedUrl) { + ShareAsyncClient shareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME) + .getSnapshotClient(snapshot); + ShareFileAsyncClient fileClient = shareClient.getFileClientByFileId(fileId); + ShareDirectoryAsyncClient directoryClient = shareClient.getDirectoryClientByFileId(fileId); + + assertEquals(fileId, fileClient.getFileId()); + assertEquals(expectedUrl, fileClient.getFileUrl()); + assertEquals(fileId, directoryClient.getFileId()); + assertEquals(expectedUrl, directoryClient.getDirectoryUrl()); + + ShareFileAsyncClient rebuiltClient + = new ShareFileClientBuilder().endpoint(fileClient.getFileUrl()).buildFileAsyncClient(); + assertEquals(fileId, rebuiltClient.getFileId()); + assertEquals(expectedUrl, rebuiltClient.getFileUrl()); + } + + // These are not realistic file IDs, but are here for defensive testing + private static Stream fileIdUrls() { + return Stream + .of(new String[] { FileIdTestHelper.FILE_ID, FileIdTestHelper.FILE_ID }, new String[] { "a&b", "a%26b" }, + new String[] { "a%26b", "a%2526b" }, new String[] { "a +/=?#%", "a%20%2B%2F%3D%3F%23%25" }, + new String[] { "caf\u00e9", "caf%C3%A9" }) + .flatMap(pair -> Stream.of(null, "2026-09-29T12:34:56.1234567Z") + .map(snapshot -> Arguments.of(pair[0], snapshot, + FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + + (snapshot == null ? "?" : "?sharesnapshot=" + snapshot + "&") + "fileid=" + pair[1]))); + } + private static HttpRequest request(String url) { return new HttpRequest(HttpMethod.HEAD, url) .setHeaders(new HttpHeaders().set(HttpHeaderName.CONTENT_LENGTH, "0")) From c1d93c8fd07f2da92cf66a0fc34de1971b9e6d5d Mon Sep 17 00:00:00 2001 From: browndav Date: Mon, 19 Oct 2026 13:24:14 -0400 Subject: [PATCH 34/39] change null and empty checks to use code from common package --- .../azure/storage/file/share/implementation/ShareErrors.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java index ec64cd446089b..2a7090c1dda4d 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/ShareErrors.java @@ -3,6 +3,7 @@ package com.azure.storage.file.share.implementation; +import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; /** @@ -37,7 +38,7 @@ public static void validateFileId(String fileId) { * @throws IllegalStateException If the client is not file-ID-addressed. */ public static void assertFileIdAddressed(String fileId, String operationName) { - if (fileId == null || fileId.isEmpty()) { + if (CoreUtils.isNullOrEmpty(fileId)) { throw LOGGER.logExceptionAsError( new IllegalStateException(operationName + " requires a file-ID-addressed client.")); } @@ -62,7 +63,7 @@ public static void validatePathOperation(String fileId, String operationName) { * @throws IllegalStateException If the client is file-ID-addressed. */ public static void assertNotFileIdAddressed(String fileId, String operationName) { - if (fileId != null && !fileId.isEmpty()) { + if (!CoreUtils.isNullOrEmpty(fileId)) { throw LOGGER.logExceptionAsError( new IllegalStateException(operationName + " is not supported for a file-ID-addressed client.")); } From d1b9bcc07a7d8d2cba419e45acd49f149f11732b Mon Sep 17 00:00:00 2001 From: browndav Date: Mon, 19 Oct 2026 13:42:51 -0400 Subject: [PATCH 35/39] spotless apply --- .../com/azure/storage/file/share/FileApiTests.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index caf0f0d2d5254..277fd8a330da8 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -322,12 +322,10 @@ public void fileClientBuilderParsesFileIdFromEndpointQuery() { Assertions.assertEquals("file.txt", pathClient.getFilePath()); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(" ")); Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder().fileId(null)); - Assertions.assertThrows(IllegalArgumentException.class, - () -> new ShareFileClientBuilder().endpoint( - FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=")); - Assertions.assertThrows(IllegalArgumentException.class, - () -> new ShareFileClientBuilder().endpoint( - FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=%20")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new ShareFileClientBuilder() + .endpoint(FileIdTestHelper.ENDPOINT + "/" + FileIdTestHelper.SHARE_NAME + "?fileid=%20")); } @Test From 78a1359badeab4848a8103922841e43bd88ec53e Mon Sep 17 00:00:00 2001 From: browndav Date: Mon, 19 Oct 2026 16:37:59 -0400 Subject: [PATCH 36/39] add liveonly tests --- .../storage/file/share/DirectoryApiTests.java | 15 ++++++++++++ .../file/share/DirectoryAsyncApiTests.java | 18 ++++++++++++++ .../storage/file/share/FileApiTests.java | 24 +++++++++++++++++++ .../storage/file/share/FileAsyncApiTests.java | 24 +++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java index 5d434e817a589..b268fd71bae4a 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryApiTests.java @@ -153,6 +153,21 @@ public void directoryPropertiesByFileId(boolean snapshot) { actual.getSmbProperties().getFileLastWriteTime()); } + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void directoryPropertiesByFileIdLive() { + primaryDirectoryClient.create(); + ShareDirectoryProperties expected = primaryDirectoryClient.getProperties(); + String fileId = expected.getSmbProperties().getFileId(); + + ShareDirectoryProperties actual = shareClient.getDirectoryClientByFileId(fileId).getProperties(); + + assertEquals(directoryPath, actual.getFileName()); + assertEquals(fileId, actual.getSmbProperties().getFileId()); + assertEquals(expected.getSmbProperties().getParentId(), actual.getSmbProperties().getParentId()); + } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test public void directoryPropertiesByFileIdMapServiceErrors() { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java index 4413901419577..5f519b80cada5 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAsyncApiTests.java @@ -143,6 +143,24 @@ public void asyncDirectoryPropertiesByFileId(boolean snapshot) { }).verifyComplete(); } + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void asyncDirectoryPropertiesByFileIdLive() { + StepVerifier.create(primaryDirectoryAsyncClient.create() + .then(primaryDirectoryAsyncClient.getProperties()) + .flatMap(expected -> shareBuilderHelper(shareName).buildAsyncClient() + .getDirectoryClientByFileId(expected.getSmbProperties().getFileId()) + .getProperties() + .doOnNext(actual -> { + assertEquals(directoryPath, actual.getFileName()); + assertEquals(expected.getSmbProperties().getFileId(), actual.getSmbProperties().getFileId()); + assertEquals(expected.getSmbProperties().getParentId(), actual.getSmbProperties().getParentId()); + }))) + .expectNextCount(1) + .verifyComplete(); + } + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") @Test public void asyncDirectoryPropertiesByFileIdMapServiceErrors() { diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java index 277fd8a330da8..11e85476ea030 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileApiTests.java @@ -228,6 +228,30 @@ public void fileLinksById() { assertEquals(links.getProperties().getSmbProperties().getParentId(), links.getLinks().get(0).getParentId()); } + @Tag("file-id-integration") + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void filePropertiesByIdLive() { + ShareFileProperties properties = shareClient.getFileClientByFileId(fileId).getProperties(); + + assertEquals(filePath, properties.getFileName()); + assertEquals(FILE_ID_TEST_CONTENT.length(), properties.getContentLength()); + assertEquals(fileId, properties.getSmbProperties().getFileId()); + } + + @Tag("file-id-integration") + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void fileLinksByIdLive() { + ShareFileLinks links = shareClient.getFileClientByFileId(fileId).getFileLinks(); + + assertEquals(fileId, links.getProperties().getSmbProperties().getFileId()); + assertEquals(1, links.getLinks().size()); + assertEquals(filePath, links.getLinks().get(0).getName()); + } + @DoNotRecord @Tag("file-id-mock") @Test diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java index 2645132d25188..11c6b93f8648e 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAsyncApiTests.java @@ -207,6 +207,30 @@ public void asyncFileLinksById() { assertEquals(links.getProperties().getSmbProperties().getParentId(), links.getLinks().get(0).getParentId()); } + @Tag("file-id-integration") + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void asyncFilePropertiesByIdLive() { + StepVerifier.create(shareAsyncClient.getFileClientByFileId(fileId).getProperties()).assertNext(properties -> { + assertEquals(filePath, properties.getFileName()); + assertEquals(FILE_ID_TEST_CONTENT.length(), properties.getContentLength()); + assertEquals(fileId, properties.getSmbProperties().getFileId()); + }).verifyComplete(); + } + + @Tag("file-id-integration") + @LiveOnly + @RequiredServiceVersion(clazz = ShareServiceVersion.class, min = "2027-03-07") + @Test + public void asyncFileLinksByIdLive() { + StepVerifier.create(shareAsyncClient.getFileClientByFileId(fileId).getFileLinks()).assertNext(links -> { + assertEquals(fileId, links.getProperties().getSmbProperties().getFileId()); + assertEquals(1, links.getLinks().size()); + assertEquals(filePath, links.getLinks().get(0).getName()); + }).verifyComplete(); + } + @DoNotRecord @Tag("file-id-mock") @Test From 24294305a0e324f5bcfe803898bc571070f6b349 Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 22 Oct 2026 11:43:51 -0400 Subject: [PATCH 37/39] block creation of lease clients with file-id based clients --- .../specialized/ShareLeaseClientBuilder.java | 14 ++++++ .../FileIdUnsupportedOperationsTests.java | 45 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/specialized/ShareLeaseClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/specialized/ShareLeaseClientBuilder.java index 7d7d799303608..d71d7f098e228 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/specialized/ShareLeaseClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/specialized/ShareLeaseClientBuilder.java @@ -11,7 +11,9 @@ import com.azure.storage.file.share.ShareClient; import com.azure.storage.file.share.ShareFileAsyncClient; import com.azure.storage.file.share.ShareFileClient; +import com.azure.storage.file.share.ShareFileClientBuilder; import com.azure.storage.file.share.ShareServiceVersion; +import com.azure.storage.file.share.implementation.ShareErrors; import com.azure.storage.file.share.models.ShareTokenIntent; import java.net.URL; @@ -116,12 +118,18 @@ public ShareLeaseAsyncClient buildAsyncClient() { * Configures the builder based on the passed {@link ShareFileClient}. This will set the {@link HttpPipeline} and * {@link URL} that are used to interact with the service. * + *

File-ID-addressed clients are not supported for lease operations. A client created via + * {@link ShareFileClient#getFileId()} or {@link ShareFileClientBuilder#fileId(String)} must be rejected before any + * request is sent.

+ * * @param fileClient ShareFileClient used to configure the builder. * @return the updated ShareLeaseClientBuilder object * @throws NullPointerException If {@code fileClient} is {@code null}. + * @throws IllegalStateException If {@code fileClient} is file-ID-addressed. */ public ShareLeaseClientBuilder fileClient(ShareFileClient fileClient) { Objects.requireNonNull(fileClient); + ShareErrors.validatePathOperation(fileClient.getFileId(), "fileClient"); this.pipeline = fileClient.getHttpPipeline(); this.url = fileClient.getAccountUrl(); this.shareName = fileClient.getShareName(); @@ -136,12 +144,18 @@ public ShareLeaseClientBuilder fileClient(ShareFileClient fileClient) { * Configures the builder based on the passed {@link ShareFileAsyncClient}. This will set the {@link HttpPipeline} * and {@link URL} that are used to interact with the service. * + *

File-ID-addressed clients are not supported for lease operations. A client created via + * {@link ShareFileAsyncClient#getFileId()} or {@link ShareFileClientBuilder#fileId(String)} must be rejected before + * any request is sent.

+ * * @param fileAsyncClient ShareFileAsyncClient used to configure the builder. * @return the updated ShareLeaseClientBuilder object * @throws NullPointerException If {@code fileAsyncClient} is {@code null}. + * @throws IllegalStateException If {@code fileAsyncClient} is file-ID-addressed. */ public ShareLeaseClientBuilder fileAsyncClient(ShareFileAsyncClient fileAsyncClient) { Objects.requireNonNull(fileAsyncClient); + ShareErrors.validatePathOperation(fileAsyncClient.getFileId(), "fileAsyncClient"); this.pipeline = fileAsyncClient.getHttpPipeline(); this.url = fileAsyncClient.getAccountUrl(); this.shareName = fileAsyncClient.getShareName(); diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java index 044983ea059b3..8341cc51b0c5c 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileIdUnsupportedOperationsTests.java @@ -15,6 +15,7 @@ import com.azure.storage.file.share.options.ShareFileCopyOptions; import com.azure.storage.file.share.options.ShareFileCreateHardLinkOptions; import com.azure.storage.file.share.options.ShareFileCreateOptions; +import com.azure.storage.file.share.specialized.ShareLeaseClientBuilder; import com.azure.storage.file.share.options.ShareFileCreateSymbolicLinkOptions; import com.azure.storage.file.share.options.ShareFileDownloadOptions; import com.azure.storage.file.share.options.ShareFileListRangesDiffOptions; @@ -145,6 +146,50 @@ public void fileIdClientsRejectPathOperations() { Assertions.assertFalse(requestSent.get()); } + @DoNotRecord + @Test + public void fileIdLeaseBuildersRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildClient() + .getShareClient(FileIdTestHelper.SHARE_NAME); + ShareFileClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + IllegalStateException buildException + = assertThrows(IllegalStateException.class, () -> new ShareLeaseClientBuilder().fileClient(fileClient)); + assertEquals("fileClient is not supported for a file-ID-addressed client.", buildException.getMessage()); + assertFalse(requestSent.get()); + } + + @DoNotRecord + @Test + public void asyncFileIdLeaseBuildersRejectPathOperations() { + AtomicReference requestSent = new AtomicReference<>(false); + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + requestSent.set(true); + return Mono.just(new MockHttpResponse(request, 200)); + }).build(); + + ShareAsyncClient testShareClient = new ShareServiceClientBuilder().endpoint(FileIdTestHelper.ENDPOINT) + .pipeline(pipeline) + .serviceVersion(ShareServiceVersion.V2027_03_07) + .buildAsyncClient() + .getShareAsyncClient(FileIdTestHelper.SHARE_NAME); + ShareFileAsyncClient fileClient = testShareClient.getFileClientByFileId(FileIdTestHelper.FILE_ID); + + IllegalStateException buildException = assertThrows(IllegalStateException.class, + () -> new ShareLeaseClientBuilder().fileAsyncClient(fileClient)); + assertEquals("fileAsyncClient is not supported for a file-ID-addressed client.", buildException.getMessage()); + assertFalse(requestSent.get()); + } + @DoNotRecord @Test public void asyncFileIdClientsRejectPathOperations() { From 10d46389698d924d98674c5221d73d05563d2e7e Mon Sep 17 00:00:00 2001 From: browndav Date: Thu, 22 Oct 2026 11:53:22 -0400 Subject: [PATCH 38/39] add remote swagger link --- sdk/storage/azure-storage-file-share/swagger/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/swagger/README.md b/sdk/storage/azure-storage-file-share/swagger/README.md index 40f95eafe312b..4f97fee868227 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: C:\repos\azure-rest-api-specs\specification\storage\data-plane\Microsoft.FileStorage\stable\2027-03-07\file.json +input-file: https://raw.githubusercontent.com/browndav-msft/azure-rest-api-specs/672abf88f9686ec82cb07259f782a1b59d891ec5/specification/storage/data-plane/Microsoft.FileStorage/stable/2027-03-07/file.json java: true output-folder: ../ namespace: com.azure.storage.file.share From 411de94ac841fd03a9950e5a0b71c7a9a6597f02 Mon Sep 17 00:00:00 2001 From: Isabelle Date: Thu, 22 Oct 2026 14:18:25 -0700 Subject: [PATCH 39/39] preserveConfiguredFileID --- .../file/share/ShareFileClientBuilder.java | 4 +- .../file/share/BuilderHelperTests.java | 68 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java index 43f05de9bd111..44dbb88d833bd 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareFileClientBuilder.java @@ -344,7 +344,9 @@ public ShareFileClientBuilder endpoint(String endpoint) { this.shareSnapshot = snapshotArray[0]; } - this.fileId = ""; + if (length >= 2) { + this.fileId = ""; + } String[] fileIdArray = queryParamsMap.remove("fileid"); if (fileIdArray != null) { ShareErrors.validateFileId(fileIdArray[0]); diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java index 6a8c6600633bc..3625365082c10 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/BuilderHelperTests.java @@ -9,6 +9,7 @@ import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpMethod; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.HttpRequest; import com.azure.core.http.HttpResponse; import com.azure.core.http.policy.FixedDelayOptions; @@ -44,6 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BuilderHelperTests { private static final ClientLogger LOGGER = new ClientLogger(BuilderHelperTests.class); @@ -98,6 +100,72 @@ void asyncFileIdUrls(String fileId, String snapshot, String expectedUrl) { assertEquals(expectedUrl, rebuiltClient.getFileUrl()); } + @ParameterizedTest + @MethodSource("fileIdEndpointSetters") + void syncFileIdEndpointSetters(boolean connectionString, String endpointSuffix, String expectedFileId, + String expectedPath) { + ShareFileClient fileClient + = fileIdEndpointBuilder(connectionString, endpointSuffix, expectedFileId, expectedPath).buildFileClient(); + + assertEquals(expectedFileId, fileClient.getFileId()); + assertEquals(expectedPath, fileClient.getFilePath()); + fileClient.getProperties(); + if (!expectedFileId.isEmpty()) { + assertThrows(IllegalStateException.class, fileClient::exists); + } + } + + @ParameterizedTest + @MethodSource("fileIdEndpointSetters") + void asyncFileIdEndpointSetters(boolean connectionString, String endpointSuffix, String expectedFileId, + String expectedPath) { + ShareFileAsyncClient fileClient + = fileIdEndpointBuilder(connectionString, endpointSuffix, expectedFileId, expectedPath) + .buildFileAsyncClient(); + + assertEquals(expectedFileId, fileClient.getFileId()); + assertEquals(expectedPath, fileClient.getFilePath()); + StepVerifier.create(fileClient.getProperties()).expectNextCount(1).verifyComplete(); + if (!expectedFileId.isEmpty()) { + StepVerifier.create(fileClient.exists()).verifyError(IllegalStateException.class); + } + } + + private static ShareFileClientBuilder fileIdEndpointBuilder(boolean connectionString, String endpointSuffix, + String expectedFileId, String expectedPath) { + HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(request -> { + assertEquals(HttpMethod.HEAD, request.getHttpMethod()); + assertEquals( + "/" + FileIdTestHelper.SHARE_NAME + + (expectedFileId.isEmpty() ? "/" + expectedPath.replace("/", "%2F") : ""), + request.getUrl().getPath()); + if (expectedFileId.isEmpty()) { + assertNull(request.getUrl().getQuery()); + } else { + assertTrue(request.getUrl().getQuery().contains("fileid=" + expectedFileId)); + } + return Mono.just(new MockHttpResponse(request, 200, FileIdTestHelper.fileHeaders("file.txt"))); + }).build(); + ShareFileClientBuilder builder = new ShareFileClientBuilder().fileId(FileIdTestHelper.FILE_ID); + String endpoint = FileIdTestHelper.ENDPOINT + endpointSuffix; + if (connectionString) { + builder.connectionString("FileEndpoint=" + endpoint + ";SharedAccessSignature=sv=2027-03-07&sig=test"); + } else { + builder.endpoint(endpoint); + } + return builder.shareName(FileIdTestHelper.SHARE_NAME).pipeline(pipeline); + } + + private static Stream fileIdEndpointSetters() { + return Stream.of(false, true) + .flatMap(connectionString -> Stream.of(Arguments.of(connectionString, "", FileIdTestHelper.FILE_ID, ""), + Arguments.of(connectionString, "/", FileIdTestHelper.FILE_ID, ""), + Arguments.of(connectionString, "/share", "", ""), Arguments.of(connectionString, "/share/", "", ""), + Arguments.of(connectionString, "/share/directory/file.txt", "", "directory/file.txt"), + Arguments.of(connectionString, "?fileid=replacement-id", "replacement-id", ""), Arguments + .of(connectionString, "/share/directory/file.txt?fileid=replacement-id", "replacement-id", ""))); + } + // These are not realistic file IDs, but are here for defensive testing private static Stream fileIdUrls() { return Stream