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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/storage/azure-storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log azure-storage-file-datalake

## Version XXXX-X-X-beta.X (XXXX-XX-XX)
- Added support for exists method on FileClients and DirectoryClients

## Version 12.0.0-beta.7 (2019-12-04)
This package's
[documentation](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/storage/azure-storage-file-datalake/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,41 @@ public Mono<Response<PathProperties>> getPropertiesWithResponse(DataLakeRequestC
}
}

/**
* Determines if the path this client represents exists in the cloud.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathAsyncClient.exists}
*
* @return true if the path exists, false if it doesn't
*/
public Mono<Boolean> exists() {
try {
return existsWithResponse().flatMap(FluxUtil::toMono);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Determines if the path this client represents exists in the cloud.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathAsyncClient.existsWithResponse}
*
* @return true if the path exists, false if it doesn't
*/
public Mono<Response<Boolean>> existsWithResponse() {
try {
// TODO (gapra) : Once datalake error mapping is merged, add onErrorMap
return blockBlobAsyncClient.existsWithResponse();
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Changes the access control list, group and/or owner for a resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,35 @@ public Response<PathProperties> getPropertiesWithResponse(DataLakeRequestConditi
return new SimpleResponse<>(response, Transforms.toPathProperties(response.getValue()));
}

/**
* Gets if the path this client represents exists in the cloud.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.exists}
*
* @return true if the path exists, false if it doesn't
*/
public Boolean exists() {
return existsWithResponse(null, Context.NONE).getValue();
}

/**
* Gets if the path this client represents exists in the cloud.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakePathClient.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 true if the path exists, false if it doesn't
*/
public Response<Boolean> existsWithResponse(Duration timeout, Context context) {
// TODO (gapra) : Once error mapping is merged add error mapping
return blockBlobClient.existsWithResponse(timeout, context);
}

/**
* Package-private rename method for use by {@link DataLakeFileClient} and {@link DataLakeDirectoryClient}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ public void getPropertiesWithResponseCodeSnippets() {
// END: com.azure.storage.file.datalake.DataLakePathAsyncClient.getPropertiesWithResponse#DataLakeRequestConditions
}

/**
* Code snippet for {@link DataLakePathAsyncClient#exists()}
*/
public void existsCodeSnippet() {
// BEGIN: com.azure.storage.file.datalake.DataLakePathAsyncClient.exists
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
// END: com.azure.storage.file.datalake.DataLakePathAsyncClient.exists
}

/**
* Code snippet for {@link DataLakePathAsyncClient#existsWithResponse()}
*/
public void existsWithResponseCodeSnippet() {
// BEGIN: com.azure.storage.file.datalake.DataLakePathAsyncClient.existsWithResponse
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
// END: com.azure.storage.file.datalake.DataLakePathAsyncClient.existsWithResponse
}

/**
* Code snippets for {@link DataLakePathAsyncClient#setAccessControlList(List, String, String)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ public void getPropertiesWithResponseCodeSnippets() {
// END: com.azure.storage.file.datalake.DataLakePathClient.getPropertiesWithResponse#DataLakeRequestConditions-Duration-Context
}

/**
* Code snippets for {@link DataLakePathClient#exists()}
*/
public void existsCodeSnippet() {
// BEGIN: com.azure.storage.file.datalake.DataLakePathClient.exists
System.out.printf("Exists? %b%n", client.exists());
// END: com.azure.storage.file.datalake.DataLakePathClient.exists
}

/**
* Code snippet for {@link DataLakePathClient#existsWithResponse(Duration, Context)}
*/
public void existsWithResponseCodeSnippet() {
// BEGIN: com.azure.storage.file.datalake.DataLakePathClient.existsWithResponse#Duration-Context
System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context(key2, value2)).getValue());
// END: com.azure.storage.file.datalake.DataLakePathClient.existsWithResponse#Duration-Context
}

/**
* Code snippets for {@link DataLakePathClient#setAccessControlList(List, String, String)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ class DirectoryAPITest extends APISpec {
thrown(Exception)
}

def "Exists"() {
when:
dc = fsc.getDirectoryClient(generatePathName())
dc.create()

then:
dc.exists()
}

def "Does not exist"() {
expect:
!fsc.getDirectoryClient(generatePathName()).exists()
}

@Unroll
def "Create headers"() {
// Create does not set md5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ class FileAPITest extends APISpec {
thrown(StorageErrorException)
}

def "Exists"() {
when:
fc = fsc.getFileClient(generatePathName())
fc.create()

then:
fc.exists()
}

def "Does not exist"() {
expect:
!fsc.getFileClient(generatePathName()).exists()
}

@Unroll
def "Create headers"() {
// Create does not set md5
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://gaprahns.blob.core.windows.net/jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6?restype=container",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "1529a7a4-981e-4701-82ff-d6359ec045ad"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D77E7D2CA6187F",
"Last-Modified" : "Wed, 11 Dec 2019 21:00:38 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "c14d990b-001e-007d-4566-b0d2b2000000",
"Date" : "Wed, 11 Dec 2019 21:00:37 GMT",
"x-ms-client-request-id" : "1529a7a4-981e-4701-82ff-d6359ec045ad"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://gaprahns.dfs.core.windows.net/jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6/javapathdoesnotexist1directoryapitestdoesnotexistacb73766c26?resource=directory",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.0.0-beta.8 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "8c26ea54-c7b3-48fd-9417-5bf3bbdf42c0"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D77E7D2CE5EE11",
"Last-Modified" : "Wed, 11 Dec 2019 21:00:38 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "7be34692-701f-0050-1666-b05172000000",
"Date" : "Wed, 11 Dec 2019 21:00:38 GMT",
"x-ms-client-request-id" : "8c26ea54-c7b3-48fd-9417-5bf3bbdf42c0"
},
"Exception" : null
}, {
"Method" : "HEAD",
"Uri" : "https://gaprahns.blob.core.windows.net/jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6/javapathdoesnotexist2directoryapitestdoesnotexistacb04530104",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "1f03d86a-429c-4a71-9b6c-ec423c143b1f"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-error-code" : "BlobNotFound",
"retry-after" : "0",
"StatusCode" : "404",
"x-ms-request-id" : "c14d99dd-001e-007d-0166-b0d2b2000000",
"Date" : "Wed, 11 Dec 2019 21:00:38 GMT",
"x-ms-client-request-id" : "1f03d86a-429c-4a71-9b6c-ec423c143b1f"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://gaprahns.blob.core.windows.net?prefix=jtfsdoesnotexist&comp=list",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "5d9f0c9b-6ecb-42c2-a7f2-789a4ffd9cbc"
},
"Response" : {
"Transfer-Encoding" : "chunked",
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "c14d9a00-001e-007d-1b66-b0d2b2000000",
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://gaprahns.blob.core.windows.net/\"><Prefix>jtfsdoesnotexist</Prefix><Containers><Container><Name>jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6</Name><Properties><Last-Modified>Wed, 11 Dec 2019 21:00:38 GMT</Last-Modified><Etag>\"0x8D77E7D2CA6187F\"</Etag><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><DefaultEncryptionScope>$account-encryption-key</DefaultEncryptionScope><DenyEncryptionScopeOverride>false</DenyEncryptionScopeOverride><HasImmutabilityPolicy>false</HasImmutabilityPolicy><HasLegalHold>false</HasLegalHold></Properties></Container></Containers><NextMarker /></EnumerationResults>",
"Date" : "Wed, 11 Dec 2019 21:00:38 GMT",
"x-ms-client-request-id" : "5d9f0c9b-6ecb-42c2-a7f2-789a4ffd9cbc",
"Content-Type" : "application/xml"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://gaprahns.blob.core.windows.net/jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6?restype=container",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "e78e49c7-4709-4341-abfa-d166bd539942"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "202",
"x-ms-request-id" : "c14d9a3b-001e-007d-5466-b0d2b2000000",
"Date" : "Wed, 11 Dec 2019 21:00:38 GMT",
"x-ms-client-request-id" : "e78e49c7-4709-4341-abfa-d166bd539942"
},
"Exception" : null
} ],
"variables" : [ "jtfsdoesnotexist0directoryapitestdoesnotexistacb932268c8d6", "javapathdoesnotexist1directoryapitestdoesnotexistacb73766c26", "javapathdoesnotexist2directoryapitestdoesnotexistacb04530104" ]
}
Loading