diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java index aa16f30eddd33..850ec4be88248 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobClientBase.java @@ -205,20 +205,20 @@ public final BlobInputStream openInputStream(BlobRange range, BlobRequestConditi } /** - * Gets if the container this client represents exists in the cloud. + * Gets if the blob this client represents exists in the cloud. * *

Code Samples

* * {@codesnippet com.azure.storage.blob.specialized.BlobClientBase.exists} * - * @return true if the container exists, false if it doesn't + * @return true if the blob exists, false if it doesn't */ public Boolean exists() { return existsWithResponse(null, Context.NONE).getValue(); } /** - * Gets if the container this client represents exists in the cloud. + * Gets if the blob this client represents exists in the cloud. * *

Code Samples

* @@ -226,7 +226,7 @@ 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 true if the container exists, false if it doesn't + * @return true if the blob exists, false if it doesn't */ public Response existsWithResponse(Duration timeout, Context context) { Mono> response = client.existsWithResponse(context); 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 7e725274cd4ae..81022bcff29b9 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 @@ -5,6 +5,7 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; @@ -24,6 +25,7 @@ import com.azure.storage.file.share.implementation.models.SharesGetPropertiesResponse; import com.azure.storage.file.share.implementation.models.SharesGetStatisticsResponse; import com.azure.storage.file.share.implementation.util.ShareSasImplUtil; +import com.azure.storage.file.share.models.ShareErrorCode; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareRequestConditions; import com.azure.storage.file.share.models.ShareSignedIdentifier; @@ -152,6 +154,49 @@ public ShareFileAsyncClient getFileClient(String filePath) { serviceVersion); } + /** + * Determines if the share this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareAsyncClient.exists} + * + * @return Flag indicating existence of the share. + */ + public Mono exists() { + return existsWithResponse().flatMap(FluxUtil::toMono); + } + + /** + * Determines if the share this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareAsyncClient.existsWithResponse} + * + * @return Flag indicating existence of the share. + */ + public Mono> existsWithResponse() { + try { + return withContext(this::existsWithResponse); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> existsWithResponse(Context context) { + return this.getPropertiesWithResponse(context) + .map(cp -> (Response) new SimpleResponse<>(cp, true)) + .onErrorResume(t -> + t instanceof ShareStorageException && ((ShareStorageException) t).getStatusCode() == 404 + && ((ShareStorageException) t).getErrorCode() == ShareErrorCode.SHARE_NOT_FOUND, + t -> { + HttpResponse response = ((ShareStorageException) t).getResponse(); + return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), + response.getHeaders(), false)); + }); + } + /** * Creates the share in the storage account. * 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 cdedd0b5cc0a2..6ac4924b8be4b 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 @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; +import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; + /** * This class provides a client that contains all the operations for interacting with a share in Azure Storage Share. * Operations allowed by the client are creating and deleting the share, creating snapshots for the share, creating and @@ -105,6 +107,36 @@ public ShareFileClient getFileClient(String filePath) { return new ShareFileClient(client.getFileClient(filePath)); } + /** + * Determines if the share this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareClient.exists} + * + * @return Flag indicating existence of the share. + */ + public Boolean exists() { + return existsWithResponse(null, Context.NONE).getValue(); + } + + /** + * Determines if the share this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareClient.existsWithResponse#Duration-Context} + * + * @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 share. + */ + public Response existsWithResponse(Duration timeout, Context context) { + Mono> response = client.existsWithResponse(context); + + return blockWithOptionalTimeout(response, timeout); + } + /** * Creates the share in the storage account. * 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 da4bbc9c5aa18..5149de6d0fa22 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 @@ -5,6 +5,7 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; @@ -28,6 +29,7 @@ import com.azure.storage.file.share.models.ShareDirectoryInfo; import com.azure.storage.file.share.models.ShareDirectoryProperties; import com.azure.storage.file.share.models.ShareDirectorySetMetadataInfo; +import com.azure.storage.file.share.models.ShareErrorCode; import com.azure.storage.file.share.models.ShareFileHttpHeaders; import com.azure.storage.file.share.models.ShareRequestConditions; import com.azure.storage.file.share.models.ShareStorageException; @@ -158,6 +160,54 @@ public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName) serviceVersion); } + /** + * Determines if the directory this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareDirectoryAsyncClient.exists} + * + * @return Flag indicating existence of the directory. + */ + public Mono exists() { + return existsWithResponse().flatMap(FluxUtil::toMono); + } + + /** + * Determines if the directory this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareDirectoryAsyncClient.existsWithResponse} + * + * @return Flag indicating existence of the directory. + */ + public Mono> existsWithResponse() { + try { + return withContext(this::existsWithResponse); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> existsWithResponse(Context context) { + return this.getPropertiesWithResponse(context) + .map(cp -> (Response) new SimpleResponse<>(cp, true)) + .onErrorResume(this::checkDoesNotExistStatusCode, + t -> { + HttpResponse response = ((ShareStorageException) t).getResponse(); + return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), + response.getHeaders(), false)); + }); + } + + private boolean checkDoesNotExistStatusCode(Throwable t) { + return t instanceof ShareStorageException + && ((ShareStorageException) t).getStatusCode() == 404 + && (((ShareStorageException) t).getErrorCode() == ShareErrorCode.RESOURCE_NOT_FOUND + || ((ShareStorageException) t).getErrorCode() == ShareErrorCode.SHARE_NOT_FOUND); + } + /** * Creates this directory in the file share and returns a response of {@link ShareDirectoryInfo} to interact * with it. 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 cc238c7cd7dee..93dc4e1a430bf 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,6 +27,8 @@ import java.time.Duration; import java.util.Map; +import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; + /** * This class provides a client that contains all the operations for interacting with directory in Azure Storage File * Service. Operations allowed by the client are creating, deleting and listing subdirectory and file, retrieving @@ -100,6 +102,36 @@ public ShareDirectoryClient getSubdirectoryClient(String subdirectoryName) { return new ShareDirectoryClient(shareDirectoryAsyncClient.getSubdirectoryClient(subdirectoryName)); } + /** + * Determines if the directory this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareDirectoryClient.exists} + * + * @return Flag indicating existence of the directory. + */ + public Boolean exists() { + return existsWithResponse(null, Context.NONE).getValue(); + } + + /** + * Determines if the directory this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareDirectoryClient.existsWithResponse#Duration-Context} + * + * @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. + */ + public Response existsWithResponse(Duration timeout, Context context) { + Mono> response = shareDirectoryAsyncClient.existsWithResponse(context); + + return blockWithOptionalTimeout(response, timeout); + } + /** * Creates a directory in the file share and returns a response of {@link ShareDirectoryInfo} to interact with it. * 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 de694528fb98d..e36e3857957b3 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 @@ -4,7 +4,9 @@ package com.azure.storage.file.share; import com.azure.core.annotation.ServiceClient; +import com.azure.core.exception.HttpResponseException; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedResponse; import com.azure.core.http.rest.Response; @@ -42,6 +44,7 @@ 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.ShareErrorCode; import com.azure.storage.file.share.models.ShareFileCopyInfo; import com.azure.storage.file.share.models.ShareFileDownloadAsyncResponse; import com.azure.storage.file.share.models.ShareFileHttpHeaders; @@ -159,6 +162,66 @@ public ShareServiceVersion getServiceVersion() { return serviceVersion; } + /** + * Determines if the file this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareFileAsyncClient.exists} + * + * @return Flag indicating existence of the file. + */ + public Mono exists() { + return existsWithResponse().flatMap(FluxUtil::toMono); + } + + /** + * Determines if the file this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareFileAsyncClient.existsWithResponse} + * + * @return Flag indicating existence of the file. + */ + public Mono> existsWithResponse() { + try { + return withContext(this::existsWithResponse); + } catch (RuntimeException ex) { + return monoError(logger, ex); + } + } + + Mono> existsWithResponse(Context context) { + return this.getPropertiesWithResponse(null, context) + .map(cp -> (Response) new SimpleResponse<>(cp, true)) + .onErrorResume(this::checkDoesNotExistStatusCode, + t -> { + HttpResponse response = t instanceof ShareStorageException + ? ((ShareStorageException) t).getResponse() + : ((HttpResponseException) t).getResponse(); + return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), + response.getHeaders(), false)); + }); + } + + private boolean checkDoesNotExistStatusCode(Throwable t) { + // ShareStorageException + return (t instanceof ShareStorageException + && ((ShareStorageException) t).getStatusCode() == 404 + && (((ShareStorageException) t).getErrorCode() == ShareErrorCode.RESOURCE_NOT_FOUND + || ((ShareStorageException) t).getErrorCode() == ShareErrorCode.SHARE_NOT_FOUND)) + + /* HttpResponseException - file get properties is a head request so a body is not returned. Error + conversion logic does not properly handle errors that don't return XML. */ + || (t instanceof HttpResponseException + && ((HttpResponseException) t).getResponse().getStatusCode() == 404 + && (((HttpResponseException) t).getResponse().getHeaderValue("x-ms-error-code") + .equals(ShareErrorCode.RESOURCE_NOT_FOUND.toString()) + || (((HttpResponseException) t).getResponse().getHeaderValue("x-ms-error-code") + .equals(ShareErrorCode.SHARE_NOT_FOUND.toString())))); + } + /** * Creates a file in the storage account and returns a response of {@link ShareFileInfo} to interact with it. * 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 c5c514cf18dad..738689f09e4e4 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,8 @@ import java.util.Map; import java.util.Objects; +import static com.azure.storage.common.implementation.StorageImplUtils.blockWithOptionalTimeout; + /** * 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. @@ -134,6 +136,36 @@ public final StorageFileOutputStream getFileOutputStream(long offset) { return new StorageFileOutputStream(shareFileAsyncClient, offset); } + /** + * Determines if the file this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareFileClient.exists} + * + * @return Flag indicating existence of the file. + */ + public Boolean exists() { + return existsWithResponse(null, Context.NONE).getValue(); + } + + /** + * Determines if the file this client represents exists in the cloud. + * + *

Code Samples

+ * + * {@codesnippet com.azure.storage.file.share.ShareFileClient.existsWithResponse#Duration-Context} + * + * @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 file. + */ + public Response existsWithResponse(Duration timeout, Context context) { + Mono> response = shareFileAsyncClient.existsWithResponse(context); + + return blockWithOptionalTimeout(response, timeout); + } + /** * Creates a file in the storage account and returns a response of {@link ShareFileInfo} to interact with it. * diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareAsyncJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareAsyncJavaDocCodeSamples.java index 303d9b4561c8f..0f9704e93f2c9 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareAsyncJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareAsyncJavaDocCodeSamples.java @@ -24,6 +24,7 @@ */ public class ShareAsyncJavaDocCodeSamples { private String leaseId = "leaseId"; + ShareAsyncClient client = createAsyncClientWithSASToken(); /** * Generates code sample for {@link ShareAsyncClient} instantiation. @@ -37,6 +38,24 @@ public void asyncInitialization() { // END: com.azure.storage.file.share.ShareAsyncClient.instantiation } + /** + * Code snippet for {@link ShareAsyncClient#exists()} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareAsyncClient.exists + client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); + // END: com.azure.storage.file.share.ShareAsyncClient.exists + } + + /** + * Code snippet for {@link ShareAsyncClient#existsWithResponse()} + */ + public void existsWithResponse() { + // BEGIN: com.azure.storage.file.share.ShareAsyncClient.existsWithResponse + client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); + // END: com.azure.storage.file.share.ShareAsyncClient.existsWithResponse + } + /** * Generates code sample for creating a {@link ShareAsyncClient} with SAS token. * diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryAsyncJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryAsyncJavaDocCodeSamples.java index 9ed9c6d713a9c..a9928d0aaaa15 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryAsyncJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryAsyncJavaDocCodeSamples.java @@ -23,6 +23,7 @@ public class ShareDirectoryAsyncJavaDocCodeSamples { private String leaseId = "leaseId"; + ShareDirectoryAsyncClient client = createAsyncClientWithSASToken(); /** * Generates code sample for {@link ShareDirectoryAsyncClient} instantiation. @@ -86,6 +87,24 @@ public ShareDirectoryAsyncClient createAsyncClientWithConnectionString() { return shareDirectoryAsyncClient; } + /** + * Code snippet for {@link ShareDirectoryAsyncClient#exists()} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareDirectoryAsyncClient.exists + client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); + // END: com.azure.storage.file.share.ShareDirectoryAsyncClient.exists + } + + /** + * Code snippet for {@link ShareDirectoryAsyncClient#existsWithResponse()} + */ + public void existsWithResponse() { + // BEGIN: com.azure.storage.file.share.ShareDirectoryAsyncClient.existsWithResponse + client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); + // END: com.azure.storage.file.share.ShareDirectoryAsyncClient.existsWithResponse + } + /** * Generates a code sample for using {@link ShareDirectoryAsyncClient#create} diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryJavaDocCodeSamples.java index 8dd9a9169c233..cca51484b5c6e 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareDirectoryJavaDocCodeSamples.java @@ -33,6 +33,8 @@ public class ShareDirectoryJavaDocCodeSamples { private String value1 = "val1"; private String leaseId = "leaseId"; + ShareDirectoryClient client = createClientWithSASToken(); + private Duration timeout = Duration.ofSeconds(30); /** * Generates code sample for {@link ShareDirectoryClient} instantiation. @@ -99,6 +101,21 @@ public ShareDirectoryClient createClientWithConnectionString() { return shareDirectoryClient; } + /** + * Code snippets for {@link ShareDirectoryClient#exists()} and {@link ShareDirectoryClient#existsWithResponse( + * Duration, Context)} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareDirectoryClient.exists + System.out.printf("Exists? %b%n", client.exists()); + // END: com.azure.storage.file.share.ShareDirectoryClient.exists + + // BEGIN: com.azure.storage.file.share.ShareDirectoryClient.existsWithResponse#Duration-Context + Context context = new Context("Key", "Value"); + System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue()); + // END: com.azure.storage.file.share.ShareDirectoryClient.existsWithResponse#Duration-Context + } + /** * Generates a code sample for using {@link ShareDirectoryClient#create()} */ diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileAsyncJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileAsyncJavaDocCodeSamples.java index 4e375c0044f3b..a2818e1f0a00b 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileAsyncJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileAsyncJavaDocCodeSamples.java @@ -32,6 +32,7 @@ */ public class ShareFileAsyncJavaDocCodeSamples { String leaseId = "leaseId"; + ShareFileAsyncClient client = createAsyncClientWithSASToken(); /** * Generates code sample for {@link ShareFileAsyncClient} instantiation. @@ -106,6 +107,24 @@ public void createFileAsync() { // END: com.azure.storage.file.share.ShareFileAsyncClient.create } + /** + * Code snippet for {@link ShareFileAsyncClient#exists()} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareFileAsyncClient.exists + client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response)); + // END: com.azure.storage.file.share.ShareFileAsyncClient.exists + } + + /** + * Code snippet for {@link ShareFileAsyncClient#existsWithResponse()} + */ + public void existsWithResponse() { + // BEGIN: com.azure.storage.file.share.ShareFileAsyncClient.existsWithResponse + client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue())); + // END: com.azure.storage.file.share.ShareFileAsyncClient.existsWithResponse + } + /** * Generates a code sample for using {@link ShareFileAsyncClient#createWithResponse(long, ShareFileHttpHeaders, FileSmbProperties, String, Map)} */ diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileJavaDocCodeSamples.java index 286b8a3a343ff..639e6653d9896 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareFileJavaDocCodeSamples.java @@ -45,6 +45,8 @@ public class ShareFileJavaDocCodeSamples { private String key1 = "key1"; private String value1 = "val1"; private String leaseId = "leaseId"; + ShareFileClient client = createClientWithSASToken(); + private Duration timeout = Duration.ofSeconds(30); /** * Generates code sample for {@link ShareFileClient} instantiation. @@ -110,6 +112,21 @@ public ShareFileClient createClientWithConnectionString() { return fileClient; } + /** + * Code snippets for {@link ShareFileClient#exists()} and {@link ShareFileClient#existsWithResponse( + * Duration, Context)} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareFileClient.exists + System.out.printf("Exists? %b%n", client.exists()); + // END: com.azure.storage.file.share.ShareFileClient.exists + + // BEGIN: com.azure.storage.file.share.ShareFileClient.existsWithResponse#Duration-Context + Context context = new Context("Key", "Value"); + System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue()); + // END: com.azure.storage.file.share.ShareFileClient.existsWithResponse#Duration-Context + } + /** * Generates a code sample for using {@link ShareFileClient#create(long)} */ diff --git a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareJavaDocCodeSamples.java b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareJavaDocCodeSamples.java index 6f4b4828e64e6..5a921f2c7255f 100644 --- a/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareJavaDocCodeSamples.java +++ b/sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareJavaDocCodeSamples.java @@ -35,6 +35,8 @@ public class ShareJavaDocCodeSamples { private String value1 = "val1"; private String leaseId = "leaseId"; + ShareClient client = createClientWithSASToken(); + private Duration timeout = Duration.ofSeconds(30); /** * Generates code sample for {@link ShareClient} instantiation. @@ -95,6 +97,21 @@ public ShareClient createClientWithConnectionString() { return shareClient; } + /** + * Code snippets for {@link ShareClient#exists()} and {@link ShareClient#existsWithResponse( + * Duration, Context)} + */ + public void exists() { + // BEGIN: com.azure.storage.file.share.ShareClient.exists + System.out.printf("Exists? %b%n", client.exists()); + // END: com.azure.storage.file.share.ShareClient.exists + + // BEGIN: com.azure.storage.file.share.ShareClient.existsWithResponse#Duration-Context + Context context = new Context("Key", "Value"); + System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue()); + // END: com.azure.storage.file.share.ShareClient.existsWithResponse#Duration-Context + } + /** * Generates a code sample for using {@link ShareClient#create()} */ diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy index b9a0f05d1be72..12debbecfe24a 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/DirectoryAPITests.groovy @@ -79,6 +79,32 @@ class DirectoryAPITests extends APISpec { fileClient instanceof ShareFileClient } + def "Exists"() { + when: + primaryDirectoryClient.create() + + then: + primaryDirectoryClient.exists() + } + + def "Does not exist"() { + expect: + !primaryDirectoryClient.exists() + } + + def "Exists error"() { + setup: + primaryDirectoryClient = directoryBuilderHelper(interceptorManager, shareName, directoryPath) + .sasToken("sig=dummyToken").buildDirectoryClient() + + when: + primaryDirectoryClient.exists() + + then: + def e = thrown(ShareStorageException) + FileTestHelper.assertExceptionStatusCodeAndMessage(e, 403, ShareErrorCode.AUTHENTICATION_FAILED) + } + def "Create directory"() { expect: FileTestHelper.assertResponseStatusCode(primaryDirectoryClient.createWithResponse(null, null, null, null, null), 201) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy index 0b08f192fc929..25ba8311d1438 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileAPITests.groovy @@ -83,6 +83,32 @@ class FileAPITests extends APISpec { expectURL == fileURL } + def "Exists"() { + when: + primaryFileClient.create(Constants.KB) + + then: + primaryFileClient.exists() + } + + def "Does not exist"() { + expect: + !primaryFileClient.exists() + } + + def "Exists error"() { + setup: + primaryFileClient = fileBuilderHelper(interceptorManager, shareName, filePath) + .sasToken("sig=dummyToken").buildFileClient() + + when: + primaryFileClient.exists() + + then: + def e = thrown(HttpResponseException) + e.getResponse().getStatusCode() == 403 + } + def "Create file"() { expect: FileTestHelper.assertResponseStatusCode(primaryFileClient.createWithResponse(1024, null, null, null, null, null, null), 201) diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy index 51c266ac38a53..9fbc48628be5f 100644 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy +++ b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/ShareAPITests.groovy @@ -78,6 +78,32 @@ class ShareAPITests extends APISpec { fileClient instanceof ShareFileClient } + def "Exists"() { + when: + primaryShareClient.create() + + then: + primaryShareClient.exists() + } + + def "Does not exist"() { + expect: + !primaryShareClient.exists() + } + + def "Exists error"() { + setup: + primaryShareClient = shareBuilderHelper(interceptorManager, shareName) + .sasToken("sig=dummyToken").buildClient() + + when: + primaryShareClient.exists() + + then: + def e = thrown(ShareStorageException) + FileTestHelper.assertExceptionStatusCodeAndMessage(e, 403, ShareErrorCode.AUTHENTICATION_FAILED) + } + def "Create share"() { expect: FileTestHelper.assertResponseStatusCode(primaryShareClient.createWithResponse(null, null, null, null), 201) diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsDoesNotExist.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsDoesNotExist.json new file mode 100644 index 0000000000000..3a897f746b71f --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsDoesNotExist.json @@ -0,0 +1,47 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsdoesnotexist46686c195ea9ff13c4?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "3e73b8dd-702c-409d-b6b0-0ac0cb71f135" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2D0A3F5F8F", + "Last-Modified" : "Tue, 25 Feb 2020 19:58:10 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "9e306bcc-c01a-0044-1115-ec1804000000", + "Date" : "Tue, 25 Feb 2020 19:58:09 GMT", + "x-ms-client-request-id" : "3e73b8dd-702c-409d-b6b0-0ac0cb71f135" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsdoesnotexist46686c195ea9ff13c4/directoryapitestsdoesnotexist6588888ea37663e3a4?restype=directory", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "a57df443-9045-4226-a7ae-588e5fd6142e" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "ResourceNotFound", + "retry-after" : "0", + "Content-Length" : "223", + "StatusCode" : "404", + "x-ms-request-id" : "9e306bcf-c01a-0044-1215-ec1804000000", + "Body" : "ResourceNotFoundThe specified resource does not exist.\nRequestId:9e306bcf-c01a-0044-1215-ec1804000000\nTime:2020-02-25T19:58:10.6304724Z", + "Date" : "Tue, 25 Feb 2020 19:58:10 GMT", + "x-ms-client-request-id" : "a57df443-9045-4226-a7ae-588e5fd6142e", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "directoryapitestsdoesnotexist46686c195ea9ff13c4", "directoryapitestsdoesnotexist6588888ea37663e3a4" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExists.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExists.json new file mode 100644 index 0000000000000..e8663ddbce801 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExists.json @@ -0,0 +1,83 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsexistsdirectoryapitestsexistsb3a06738038?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "1707e72a-dd79-4a5b-92da-4c80849a9443" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2C9F3275AA", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:10 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "679e3831-b01a-003c-1815-ecbbfc000000", + "Date" : "Tue, 25 Feb 2020 19:55:10 GMT", + "x-ms-client-request-id" : "1707e72a-dd79-4a5b-92da-4c80849a9443" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsexistsdirectoryapitestsexistsb3a06738038/directoryapitestsexistsdirectoryapitestsexistsb3a666858c6?restype=directory", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "bf51aac4-0e63-4016-a1f6-92bf5b9ab3be" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "x-ms-file-permission-key" : "1887593946193683302*8280205063999649007", + "x-ms-file-id" : "13835128424026341376", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-file-creation-time" : "2020-02-25T19:55:11.0685581Z", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:11 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Tue, 25 Feb 2020 19:55:10 GMT", + "ETag" : "0x8D7BA2C9F54EF8D", + "x-ms-file-attributes" : "Directory", + "x-ms-file-change-time" : "2020-02-25T19:55:11.0685581Z", + "x-ms-file-parent-id" : "0", + "Content-Length" : "0", + "x-ms-request-id" : "679e3834-b01a-003c-1915-ecbbfc000000", + "x-ms-client-request-id" : "bf51aac4-0e63-4016-a1f6-92bf5b9ab3be", + "x-ms-file-last-write-time" : "2020-02-25T19:55:11.0685581Z" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsexistsdirectoryapitestsexistsb3a06738038/directoryapitestsexistsdirectoryapitestsexistsb3a666858c6?restype=directory", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "e92a182f-cffc-4f1b-90f9-44f7e93b7467" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "x-ms-file-permission-key" : "1887593946193683302*8280205063999649007", + "x-ms-file-id" : "13835128424026341376", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-file-creation-time" : "2020-02-25T19:55:11.0685581Z", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:11 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Tue, 25 Feb 2020 19:55:11 GMT", + "x-ms-server-encrypted" : "true", + "ETag" : "0x8D7BA2C9F54EF8D", + "x-ms-file-attributes" : "Directory", + "x-ms-file-change-time" : "2020-02-25T19:55:11.0685581Z", + "x-ms-file-parent-id" : "0", + "Content-Length" : "0", + "x-ms-request-id" : "679e3835-b01a-003c-1a15-ecbbfc000000", + "x-ms-client-request-id" : "e92a182f-cffc-4f1b-90f9-44f7e93b7467", + "x-ms-file-last-write-time" : "2020-02-25T19:55:11.0685581Z" + }, + "Exception" : null + } ], + "variables" : [ "directoryapitestsexistsdirectoryapitestsexistsb3a06738038", "directoryapitestsexistsdirectoryapitestsexistsb3a666858c6" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExistsError.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExistsError.json new file mode 100644 index 0000000000000..b4ae6ecfe765d --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/DirectoryAPITestsExistsError.json @@ -0,0 +1,45 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsexistserror25512a9751292fd264?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "6e1eaa6c-4492-4695-ab34-0300a39b51fd" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2D0DC93929", + "Last-Modified" : "Tue, 25 Feb 2020 19:58:16 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "36779641-001a-0029-4615-ecac4f000000", + "Date" : "Tue, 25 Feb 2020 19:58:15 GMT", + "x-ms-client-request-id" : "6e1eaa6c-4492-4695-ab34-0300a39b51fd" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/directoryapitestsexistserror25512a9751292fd264/directoryapitestsexistserror3710024d91b79e9e44?restype=directory&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "7dd454c5-4d45-40ea-b421-32b17c4c19e1" + }, + "Response" : { + "Server" : "Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthenticationFailed", + "retry-after" : "0", + "Content-Length" : "407", + "StatusCode" : "403", + "x-ms-request-id" : "36779646-001a-0029-4815-ecac4f000000", + "Body" : "AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:36779646-001a-0029-4815-ecac4f000000\nTime:2020-02-25T19:58:16.6199877Zsr is mandatory. Cannot be empty", + "Date" : "Tue, 25 Feb 2020 19:58:16 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "directoryapitestsexistserror25512a9751292fd264", "directoryapitestsexistserror3710024d91b79e9e44" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsDoesNotExist.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsDoesNotExist.json new file mode 100644 index 0000000000000..f39594d32d838 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsDoesNotExist.json @@ -0,0 +1,44 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsdoesnotexistfileapitestsdoesnotexist24b2077934?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "0437c444-e0d4-4a6e-aec0-79e814c6bd48" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2CFD137A95", + "Last-Modified" : "Tue, 25 Feb 2020 19:57:48 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "ab77f685-f01a-0012-5c15-ece9eb000000", + "Date" : "Tue, 25 Feb 2020 19:57:47 GMT", + "x-ms-client-request-id" : "0437c444-e0d4-4a6e-aec0-79e814c6bd48" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsdoesnotexistfileapitestsdoesnotexist24b2077934/fileapitestsdoesnotexistfileapitestsdoesnotexist24b19747c9", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "52dfbc7a-1dcf-41cb-bd7a-eef16908823b" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "ResourceNotFound", + "retry-after" : "0", + "StatusCode" : "404", + "x-ms-request-id" : "ab77f688-f01a-0012-5d15-ece9eb000000", + "Date" : "Tue, 25 Feb 2020 19:57:48 GMT", + "x-ms-client-request-id" : "52dfbc7a-1dcf-41cb-bd7a-eef16908823b" + }, + "Exception" : null + } ], + "variables" : [ "fileapitestsdoesnotexistfileapitestsdoesnotexist24b2077934", "fileapitestsdoesnotexistfileapitestsdoesnotexist24b19747c9" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExists.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExists.json new file mode 100644 index 0000000000000..dcfeb16fc5fd8 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExists.json @@ -0,0 +1,87 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsexistsfileapitestsexists2d7030946befeede?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "0c85d2be-f9b3-4e66-9ede-c268b3d9bcfd" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2D01FF1041", + "Last-Modified" : "Tue, 25 Feb 2020 19:57:56 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "b219cb4c-a01a-001f-3815-ec213f000000", + "Date" : "Tue, 25 Feb 2020 19:57:55 GMT", + "x-ms-client-request-id" : "0c85d2be-f9b3-4e66-9ede-c268b3d9bcfd" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsexistsfileapitestsexists2d7030946befeede/fileapitestsexistsfileapitestsexists2d707963ef5baa58", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "254e4f45-7995-4f4c-bc61-a78c7d2d8b96" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "x-ms-file-permission-key" : "15729343842853002337*8280205063999649007", + "x-ms-file-id" : "13835128424026341376", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-file-creation-time" : "2020-02-25T19:57:56.8062567Z", + "Last-Modified" : "Tue, 25 Feb 2020 19:57:56 GMT", + "retry-after" : "0", + "StatusCode" : "201", + "x-ms-request-server-encrypted" : "true", + "Date" : "Tue, 25 Feb 2020 19:57:55 GMT", + "ETag" : "0x8D7BA2D021E8067", + "x-ms-file-attributes" : "Archive", + "x-ms-file-change-time" : "2020-02-25T19:57:56.8062567Z", + "x-ms-file-parent-id" : "0", + "Content-Length" : "0", + "x-ms-request-id" : "b219cb50-a01a-001f-3a15-ec213f000000", + "x-ms-client-request-id" : "254e4f45-7995-4f4c-bc61-a78c7d2d8b96", + "x-ms-file-last-write-time" : "2020-02-25T19:57:56.8062567Z" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsexistsfileapitestsexists2d7030946befeede/fileapitestsexistsfileapitestsexists2d707963ef5baa58", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "0a9674ef-5492-49ed-8376-08ad4f441208" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "x-ms-lease-status" : "unlocked", + "x-ms-file-permission-key" : "15729343842853002337*8280205063999649007", + "x-ms-file-id" : "13835128424026341376", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-file-creation-time" : "2020-02-25T19:57:56.8062567Z", + "x-ms-lease-state" : "available", + "Last-Modified" : "Tue, 25 Feb 2020 19:57:56 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Tue, 25 Feb 2020 19:57:55 GMT", + "x-ms-server-encrypted" : "true", + "x-ms-type" : "File", + "ETag" : "0x8D7BA2D021E8067", + "x-ms-file-attributes" : "Archive", + "x-ms-file-change-time" : "2020-02-25T19:57:56.8062567Z", + "x-ms-file-parent-id" : "0", + "Content-Length" : "1024", + "x-ms-request-id" : "b219cb51-a01a-001f-3b15-ec213f000000", + "x-ms-client-request-id" : "0a9674ef-5492-49ed-8376-08ad4f441208", + "x-ms-file-last-write-time" : "2020-02-25T19:57:56.8062567Z", + "Content-Type" : "application/octet-stream" + }, + "Exception" : null + } ], + "variables" : [ "fileapitestsexistsfileapitestsexists2d7030946befeede", "fileapitestsexistsfileapitestsexists2d707963ef5baa58" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExistsError.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExistsError.json new file mode 100644 index 0000000000000..0d54332f31f6f --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/FileAPITestsExistsError.json @@ -0,0 +1,42 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsexistserrorfileapitestsexistserror3cb595801a3?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "9b8ba67c-d084-4ea0-b1c0-a87b633b17ce" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2CB3233743", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:44 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "b6033d58-001a-0006-4515-eca184000000", + "Date" : "Tue, 25 Feb 2020 19:55:44 GMT", + "x-ms-client-request-id" : "9b8ba67c-d084-4ea0-b1c0-a87b633b17ce" + }, + "Exception" : null + }, { + "Method" : "HEAD", + "Uri" : "https://gaprastg71.file.core.windows.net/fileapitestsexistserrorfileapitestsexistserror3cb595801a3/fileapitestsexistserrorfileapitestsexistserror3cb36019ee6?sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "7ab52b81-756d-4b71-9f39-1b959737050e" + }, + "Response" : { + "Server" : "Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthenticationFailed", + "retry-after" : "0", + "StatusCode" : "403", + "x-ms-request-id" : "b6033d5d-001a-0006-4715-eca184000000", + "Date" : "Tue, 25 Feb 2020 19:55:44 GMT" + }, + "Exception" : null + } ], + "variables" : [ "fileapitestsexistserrorfileapitestsexistserror3cb595801a3", "fileapitestsexistserrorfileapitestsexistserror3cb36019ee6" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsDoesNotExist.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsDoesNotExist.json new file mode 100644 index 0000000000000..81db381660877 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsDoesNotExist.json @@ -0,0 +1,26 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/shareapitestsdoesnotexistshareapitestsdoesnotexist7ac454376?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "8051a442-8340-48af-aea9-804abe7e191f" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "ShareNotFound", + "retry-after" : "0", + "Content-Length" : "217", + "StatusCode" : "404", + "x-ms-request-id" : "4662f66d-601a-0000-3115-ec923b000000", + "Body" : "ShareNotFoundThe specified share does not exist.\nRequestId:4662f66d-601a-0000-3115-ec923b000000\nTime:2020-02-25T19:56:04.5617036Z", + "Date" : "Tue, 25 Feb 2020 19:56:03 GMT", + "x-ms-client-request-id" : "8051a442-8340-48af-aea9-804abe7e191f", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "shareapitestsdoesnotexistshareapitestsdoesnotexist7ac454376" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExists.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExists.json new file mode 100644 index 0000000000000..c7e228f9de794 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExists.json @@ -0,0 +1,49 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://gaprastg71.file.core.windows.net/shareapitestsexistsshareapitestsexistsdb8302586e97016?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "0c28e99a-4e92-4432-a89c-f9b15e7d4a9c" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D7BA2CB9D97EC3", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:55 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "ce12a15d-501a-000b-3d15-ec6950000000", + "Date" : "Tue, 25 Feb 2020 19:55:54 GMT", + "x-ms-client-request-id" : "0c28e99a-4e92-4432-a89c-f9b15e7d4a9c" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/shareapitestsexistsshareapitestsexistsdb8302586e97016?restype=share", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "27e32149-05ea-4ce2-a5e6-211a338da0db" + }, + "Response" : { + "x-ms-version" : "2019-07-07", + "Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "Last-Modified" : "Tue, 25 Feb 2020 19:55:55 GMT", + "retry-after" : "0", + "StatusCode" : "200", + "Date" : "Tue, 25 Feb 2020 19:55:54 GMT", + "x-ms-has-legal-hold" : "false", + "x-ms-share-quota" : "5120", + "ETag" : "0x8D7BA2CB9D97EC3", + "x-ms-has-immutability-policy" : "false", + "Content-Length" : "0", + "x-ms-request-id" : "ce12a161-501a-000b-3f15-ec6950000000", + "x-ms-client-request-id" : "27e32149-05ea-4ce2-a5e6-211a338da0db" + }, + "Exception" : null + } ], + "variables" : [ "shareapitestsexistsshareapitestsexistsdb8302586e97016" ] +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExistsError.json b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExistsError.json new file mode 100644 index 0000000000000..d2bbc92533410 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/test/resources/session-records/ShareAPITestsExistsError.json @@ -0,0 +1,24 @@ +{ + "networkCallRecords" : [ { + "Method" : "GET", + "Uri" : "https://gaprastg71.file.core.windows.net/shareapitestsexistserrorshareapitestsexistserror7705721712?restype=share&sig=REDACTED", + "Headers" : { + "x-ms-version" : "2019-07-07", + "User-Agent" : "azsdk-java-azure-storage-file-share/12.3.0-beta.1 (11.0.4; Windows 10 10.0)", + "x-ms-client-request-id" : "2477077d-e269-4303-a31a-271ea8f39d10" + }, + "Response" : { + "Server" : "Microsoft-HTTPAPI/2.0", + "x-ms-error-code" : "AuthenticationFailed", + "retry-after" : "0", + "Content-Length" : "407", + "StatusCode" : "403", + "x-ms-request-id" : "b6033dee-001a-0006-0815-eca184000000", + "Body" : "AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:b6033dee-001a-0006-0815-eca184000000\nTime:2020-02-25T19:56:51.6656717Zsr is mandatory. Cannot be empty", + "Date" : "Tue, 25 Feb 2020 19:56:51 GMT", + "Content-Type" : "application/xml" + }, + "Exception" : null + } ], + "variables" : [ "shareapitestsexistserrorshareapitestsexistserror7705721712" ] +} \ No newline at end of file