Skip to content

Commit

Permalink
Added root directory in file system (Azure#7511)
Browse files Browse the repository at this point in the history
  • Loading branch information
gapra-msft authored Jan 22, 2020
1 parent e85d6cc commit 30a4206
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 2 deletions.
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 @@
# Release History

## 12.0.0-beta.11 (Unreleased)
- Added DataLakeFileSystem.getRootDirectory methods to get the root directory in a file system.

## 12.0.0-beta.10 (2020-01-15)
This package's
[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-file-datalake_12.0.0-beta.10/sdk/storage/azure-storage-file-datalake/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class DataLakeFileSystemAsyncClient {

public static final String ROOT_FILESYSTEM_NAME = "$root";

private static final String ROOT_DIRECTORY_NAME = "";

// public static final String STATIC_WEBSITE_FILESYSTEM_NAME = "$web";

// public static final String LOG_FILESYSTEM_NAME = "$logs";
Expand Down Expand Up @@ -110,7 +112,7 @@ public class DataLakeFileSystemAsyncClient {
}

/**
* Creates a new DataLakeFileAsyncClient object by concatenating fileName to the end of
* Initializes a new DataLakeFileAsyncClient object by concatenating fileName to the end of
* DataLakeFileSystemAsyncClient's URL. The new DataLakeFileAsyncClient uses the same request policy pipeline as
* the DataLakeFileSystemAsyncClient.
*
Expand All @@ -135,7 +137,7 @@ public DataLakeFileAsyncClient getFileAsyncClient(String fileName) {
}

/**
* Creates a new DataLakeDirectoryAsyncClient object by concatenating directoryName to the end of
* Initializes a new DataLakeDirectoryAsyncClient object by concatenating directoryName to the end of
* DataLakeFileSystemAsyncClient's URL. The new DataLakeDirectoryAsyncClient uses the same request policy pipeline
* as the DataLakeFileSystemAsyncClient.
*
Expand All @@ -158,6 +160,22 @@ public DataLakeDirectoryAsyncClient getDirectoryAsyncClient(String directoryName
blockBlobAsyncClient);
}

/**
* Initializes a new DataLakeDirectoryAsyncClient object by concatenating {@code ""} to the end of
* DataLakeFileSystemAsyncClient's URL. The new DataLakeDirectoryAsyncClient uses the same request policy pipeline
* as the DataLakeFileSystemAsyncClient.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakeFileSystemAsyncClient.getRootDirectoryAsyncClient}
*
* @return A new {@link DataLakeDirectoryAsyncClient} object which references the root directory
* in this file system.
*/
public DataLakeDirectoryAsyncClient getRootDirectoryAsyncClient() {
return getDirectoryAsyncClient(DataLakeFileSystemAsyncClient.ROOT_DIRECTORY_NAME);
}

/**
* Gets the URL of the file system represented by this client.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class DataLakeFileSystemClient {

public static final String ROOT_FILESYSTEM_NAME = DataLakeFileSystemAsyncClient.ROOT_FILESYSTEM_NAME;

private static final String ROOT_DIRECTORY_NAME = "";

// public static final String STATIC_WEBSITE_FILESYSTEM_NAME =
// DataLakeFileSystemAsyncClient.STATIC_WEBSITE_FILESYSTEM_NAME;

Expand Down Expand Up @@ -114,6 +116,21 @@ public DataLakeDirectoryClient getDirectoryClient(String directoryName) {
blobContainerClient.getBlobClient(directoryName).getBlockBlobClient());
}

/**
* Initializes a new DataLakeDirectoryClient object by concatenating {@code ""} to the end of
* DataLakeFileSystemClient's URL. The new DataLakeDirectoryClient uses the same request policy pipeline as the
* DataLakeFileSystemClient.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.file.datalake.DataLakeFileSystemClient.getRootDirectoryClient}
*
* @return A new {@link DataLakeDirectoryClient} object which references the root directory in this file system.
*/
public DataLakeDirectoryClient getRootDirectoryClient() {
return getDirectoryClient(DataLakeFileSystemClient.ROOT_DIRECTORY_NAME);
}

/**
* Get the file system name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public void getDirectoryAsyncClient() {
// END: com.azure.storage.file.datalake.DataLakeFileSystemAsyncClient.getDirectoryAsyncClient#String
}

/**
* Code snippet for {@link DataLakeFileSystemAsyncClient#getRootDirectoryAsyncClient}
*/
public void getRootDirectoryAsyncClient() {
// BEGIN: com.azure.storage.file.datalake.DataLakeFileSystemAsyncClient.getRootDirectoryAsyncClient
DataLakeDirectoryAsyncClient dataLakeDirectoryAsyncClient = client.getRootDirectoryAsyncClient();
// END: com.azure.storage.file.datalake.DataLakeFileSystemAsyncClient.getRootDirectoryAsyncClient
}

/**
* Generates a code sample for using {@link DataLakeFileSystemAsyncClient#getFileSystemName()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public void getDirectoryClient() {
// END: com.azure.storage.file.datalake.DataLakeFileSystemClient.getDirectoryClient#String
}

/**
* Code snippet for {@link DataLakeFileSystemClient#getRootDirectoryClient}
*/
public void getRootDirectoryClient() {
// BEGIN: com.azure.storage.file.datalake.DataLakeFileSystemClient.getRootDirectoryClient
DataLakeDirectoryClient dataLakeDirectoryClient = client.getRootDirectoryClient();
// END: com.azure.storage.file.datalake.DataLakeFileSystemClient.getRootDirectoryClient
}

/**
* Generates a code sample for using {@link DataLakeFileSystemClient#getFileSystemName()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,4 +1157,19 @@ class FileSystemAPITest extends APISpec {
items.hasNext()
}

def "Set ACL root directory"() {
setup:
def dc = fsc.getRootDirectoryClient()

List<PathAccessControlEntry> pathAccessControlEntries = PathAccessControlEntry.parseList("user::rwx,group::r--,other::---,mask::rwx")

when:
def resp = dc.setAccessControlList(pathAccessControlEntries, null, null)

then:
notThrown(DataLakeStorageException)
resp.getETag()
resp.getLastModified()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://gaprahnsstg.blob.core.windows.net/jtfssetaclrootdirectory0189950540ae13b82e4cefa?restype=container",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.3.0 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "b8e42656-811a-4d38-ae61-ec28993a68d2"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D79AE0DA9C08AC",
"Last-Modified" : "Fri, 17 Jan 2020 00:04:42 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "05ff334f-201e-002e-3cc9-ccc02c000000",
"Date" : "Fri, 17 Jan 2020 00:04:42 GMT",
"x-ms-client-request-id" : "b8e42656-811a-4d38-ae61-ec28993a68d2"
},
"Exception" : null
}, {
"Method" : "PATCH",
"Uri" : "https://gaprahnsstg.dfs.core.windows.net/jtfssetaclrootdirectory0189950540ae13b82e4cefa/?action=setAccessControl",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.0.0-beta.10 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "e6f1f660-3528-40eb-99e6-8d84d24d32ed"
},
"Response" : {
"x-ms-namespace-enabled" : "true",
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D79AE0DB191293",
"Last-Modified" : "Fri, 17 Jan 2020 00:04:43 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "3faf36d3-f01f-002d-18c9-cc2148000000",
"Date" : "Fri, 17 Jan 2020 00:04:42 GMT",
"x-ms-client-request-id" : "e6f1f660-3528-40eb-99e6-8d84d24d32ed"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://gaprahnsstg.blob.core.windows.net?prefix=jtfssetaclrootdirectory&comp=list",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.3.0 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "cd51756a-7584-47d0-99b5-98f1e220aa66"
},
"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" : "05ff335d-201e-002e-46c9-ccc02c000000",
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://gaprahnsstg.blob.core.windows.net/\"><Prefix>jtfssetaclrootdirectory</Prefix><Containers><Container><Name>jtfssetaclrootdirectory0189950540ae13b82e4cefa</Name><Properties><Last-Modified>Fri, 17 Jan 2020 00:04:42 GMT</Last-Modified><Etag>\"0x8D79AE0DA9C08AC\"</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" : "Fri, 17 Jan 2020 00:04:43 GMT",
"x-ms-client-request-id" : "cd51756a-7584-47d0-99b5-98f1e220aa66",
"Content-Type" : "application/xml"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://gaprahnsstg.blob.core.windows.net/jtfssetaclrootdirectory0189950540ae13b82e4cefa?restype=container",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.3.0 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "b89e1d2b-9d7e-419a-8a65-0cd3a529849e"
},
"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" : "05ff335e-201e-002e-47c9-ccc02c000000",
"Date" : "Fri, 17 Jan 2020 00:04:43 GMT",
"x-ms-client-request-id" : "b89e1d2b-9d7e-419a-8a65-0cd3a529849e"
},
"Exception" : null
} ],
"variables" : [ "jtfssetaclrootdirectory0189950540ae13b82e4cefa" ]
}

0 comments on commit 30a4206

Please sign in to comment.