public class DataLakeFileSystemClient extends Object
DataLakeFileSystemClientBuilder
or via the
method DataLakeServiceClient.getFileSystemClient(String)
. This class does not hold any state about a
particular file system but is instead a convenient way of sending off appropriate requests to the resource on the
service. It may also be used to construct URLs to files/directories.
This client contains operations on a file system. Operations on a path are available on DataLakeFileClient
and DataLakeDirectoryClient
through DataLakeFileSystemClient.getFileClient(String)
and DataLakeFileSystemClient.getDirectoryClient(String)
respectively, and operations on the service are available on DataLakeServiceClient
.
Please refer to the Azure Docs for more information on file systems.
Modifier and Type | Field and Description |
---|---|
static String |
ROOT_FILESYSTEM_NAME |
Modifier and Type | Method and Description |
---|---|
void |
create()
Creates a new file system within a storage account.
|
DataLakeDirectoryClient |
createDirectory(String directoryName)
Creates a new directory within a file system.
|
DataLakeDirectoryClient |
createDirectory(String directoryName,
boolean overwrite)
Creates a new directory within a file system.
|
com.azure.core.http.rest.Response<DataLakeDirectoryClient> |
createDirectoryWithResponse(String directoryName,
String permissions,
String umask,
PathHttpHeaders headers,
Map<String,String> metadata,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Creates a new directory within a file system.
|
DataLakeFileClient |
createFile(String fileName)
Creates a new file within a file system.
|
DataLakeFileClient |
createFile(String fileName,
boolean overwrite)
Creates a new file within a file system.
|
com.azure.core.http.rest.Response<DataLakeFileClient> |
createFileWithResponse(String fileName,
String permissions,
String umask,
PathHttpHeaders headers,
Map<String,String> metadata,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Creates a new file within a file system.
|
com.azure.core.http.rest.Response<Void> |
createWithResponse(Map<String,String> metadata,
PublicAccessType accessType,
Duration timeout,
com.azure.core.util.Context context)
Creates a new file system within a storage account.
|
void |
delete()
Marks the specified file system for deletion.
|
void |
deleteDirectory(String directoryName)
Deletes the specified directory in the file system.
|
com.azure.core.http.rest.Response<Void> |
deleteDirectoryWithResponse(String directoryName,
boolean recursive,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Deletes the specified directory in the file system.
|
void |
deleteFile(String fileName)
Deletes the specified file in the file system.
|
com.azure.core.http.rest.Response<Void> |
deleteFileWithResponse(String fileName,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Deletes the specified file in the file system.
|
com.azure.core.http.rest.Response<Void> |
deleteWithResponse(DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Marks the specified file system for deletion.
|
String |
generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues)
Generates a service SAS for the file system using the specified
DataLakeServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential |
String |
generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues,
UserDelegationKey userDelegationKey)
Generates a user delegation SAS for the file system using the specified
DataLakeServiceSasSignatureValues . |
FileSystemAccessPolicies |
getAccessPolicy()
Returns the file system's permissions.
|
com.azure.core.http.rest.Response<FileSystemAccessPolicies> |
getAccessPolicyWithResponse(String leaseId,
Duration timeout,
com.azure.core.util.Context context)
Returns the file system's permissions.
|
String |
getAccountName()
Get associated account name.
|
DataLakeDirectoryClient |
getDirectoryClient(String directoryName)
Initializes a new DataLakeDirectoryClient object by concatenating directoryName to the end of
DataLakeFileSystemClient's URL.
|
DataLakeFileClient |
getFileClient(String fileName)
Initializes a new DataLakeFileClient object by concatenating fileName to the end of DataLakeFileSystemClient's
URL.
|
String |
getFileSystemName()
Get the file system name.
|
String |
getFileSystemUrl()
Gets the URL of the file system represented by this client.
|
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
FileSystemProperties |
getProperties()
Returns the file system's metadata and system properties.
|
com.azure.core.http.rest.Response<FileSystemProperties> |
getPropertiesWithResponse(String leaseId,
Duration timeout,
com.azure.core.util.Context context)
Returns the file system's metadata and system properties.
|
DataLakeServiceVersion |
getServiceVersion()
Gets the service version the client is using.
|
com.azure.core.http.rest.PagedIterable<PathItem> |
listPaths()
Returns a lazy loaded list of files/directories in this account.
|
com.azure.core.http.rest.PagedIterable<PathItem> |
listPaths(ListPathsOptions options,
Duration timeout)
Returns a lazy loaded list of files/directories in this account.
|
void |
setAccessPolicy(PublicAccessType accessType,
List<DataLakeSignedIdentifier> identifiers)
Sets the file system's permissions.
|
com.azure.core.http.rest.Response<Void> |
setAccessPolicyWithResponse(PublicAccessType accessType,
List<DataLakeSignedIdentifier> identifiers,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Sets the file system's permissions.
|
void |
setMetadata(Map<String,String> metadata)
Sets the file system's metadata.
|
com.azure.core.http.rest.Response<Void> |
setMetadataWithResponse(Map<String,String> metadata,
DataLakeRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Sets the file system's metadata.
|
public static final String ROOT_FILESYSTEM_NAME
public DataLakeFileClient getFileClient(String fileName)
fileName
- A String
representing the name of the file.
Code Samples
DataLakeFileClient dataLakeFileClient = client.getFileClient(fileName);
DataLakeFileClient
object which references the file with the specified name in this file
system.public DataLakeDirectoryClient getDirectoryClient(String directoryName)
directoryName
- A String
representing the name of the directory.
Code Samples
DataLakeDirectoryClient dataLakeDirectoryClient = client.getDirectoryClient(directoryName);
DataLakeDirectoryClient
object which references the directory with the specified name in
this file system.public String getFileSystemName()
Code Samples
String fileSystemName = client.getFileSystemName(); System.out.println("The name of the file system is " + fileSystemName);
public String getFileSystemUrl()
public String getAccountName()
public DataLakeServiceVersion getServiceVersion()
public com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline
powering this client.public void create()
Code Samples
try { client.create(); System.out.printf("Create completed%n"); } catch (BlobStorageException error) { if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_ALREADY_EXISTS)) { System.out.printf("Can't create file system. It already exists %n"); } }
public com.azure.core.http.rest.Response<Void> createWithResponse(Map<String,String> metadata, PublicAccessType accessType, Duration timeout, com.azure.core.util.Context context)
Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); Context context = new Context("Key", "Value"); System.out.printf("Create completed with status %d%n", client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).getStatusCode());
metadata
- Metadata to associate with the file system.accessType
- Specifies how the data in this file system is available to the public. See the
x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public void delete()
Code Samples
try { client.delete(); System.out.printf("Delete completed%n"); } catch (BlobStorageException error) { if (error.getErrorCode().equals(BlobErrorCode.CONTAINER_NOT_FOUND)) { System.out.printf("Delete failed. File System was not found %n"); } }
public com.azure.core.http.rest.Response<Void> deleteWithResponse(DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("Key", "Value"); System.out.printf("Delete completed with status %d%n", client.deleteWithResponse( requestConditions, timeout, context).getStatusCode());
requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public FileSystemProperties getProperties()
Code Samples
FileSystemProperties properties = client.getProperties(); System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", properties.getDataLakePublicAccess(), properties.hasLegalHold(), properties.hasImmutabilityPolicy());
public com.azure.core.http.rest.Response<FileSystemProperties> getPropertiesWithResponse(String leaseId, Duration timeout, com.azure.core.util.Context context)
Code Samples
Context context = new Context("Key", "Value"); FileSystemProperties properties = client.getPropertiesWithResponse(leaseId, timeout, context) .getValue(); System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", properties.getDataLakePublicAccess(), properties.hasLegalHold(), properties.hasImmutabilityPolicy());
leaseId
- The lease ID the active lease on the file system must match.timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public void setMetadata(Map<String,String> metadata)
Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); try { client.setMetadata(metadata); System.out.printf("Set metadata completed with status %n"); } catch (UnsupportedOperationException error) { System.out.printf("Fail while setting metadata %n"); }
metadata
- Metadata to associate with the file system.public com.azure.core.http.rest.Response<Void> setMetadataWithResponse(Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("Key", "Value"); System.out.printf("Set metadata completed with status %d%n", client.setMetadataWithResponse(metadata, requestConditions, timeout, context).getStatusCode());
metadata
- Metadata to associate with the file system.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public com.azure.core.http.rest.PagedIterable<PathItem> listPaths()
PagedIterable
can be
consumed while new items are automatically retrieved as needed. For more information, see the
Azure Docs.
Code Samples
client.listPaths().forEach(path -> System.out.printf("Name: %s%n", path.getName()));
public com.azure.core.http.rest.PagedIterable<PathItem> listPaths(ListPathsOptions options, Duration timeout)
PagedIterable
can be
consumed while new items are automatically retrieved as needed. For more information, see the
Azure Docs.
Code Samples
ListPathsOptions options = new ListPathsOptions() .setPath("pathPrefixToMatch") .setMaxResults(10); client.listPaths(options, timeout).forEach(path -> System.out.printf("Name: %s%n", path.getName()));
options
- A ListPathsOptions
which specifies what data should be returned by the service.timeout
- An optional timeout value beyond which a RuntimeException
will be raised.public DataLakeFileClient createFile(String fileName)
Code Samples
DataLakeFileClient fileClient = client.createFile(fileName);
fileName
- Name of the file to create.DataLakeFileClient
used to interact with the file created.public DataLakeFileClient createFile(String fileName, boolean overwrite)
Code Samples
boolean overwrite = false; /* Default value. */ DataLakeFileClient fClient = client.createFile(fileName, overwrite);
fileName
- Name of the file to create.overwrite
- Whether or not to overwrite, should a file exist.DataLakeFileClient
used to interact with the file created.public com.azure.core.http.rest.Response<DataLakeFileClient> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); String permissions = "permissions"; String umask = "umask"; Response<DataLakeFileClient> newFileClient = client.createFileWithResponse(fileName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions, timeout, new Context(key1, value1));
fileName
- Name of the file to create.permissions
- POSIX access permissions for the file owner, the file owning group, and others.umask
- Restricts permissions of the file to be created.headers
- PathHttpHeaders
metadata
- Metadata to associate with the file.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Response
whose value
contains the DataLakeFileClient
used
to interact with the file created.public void deleteFile(String fileName)
Code Samples
client.deleteFile(fileName); System.out.println("Delete request completed");
fileName
- Name of the file to delete.public com.azure.core.http.rest.Response<Void> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); client.deleteFileWithResponse(fileName, requestConditions, timeout, new Context(key1, value1)); System.out.println("Delete request completed");
fileName
- Name of the file to delete.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public DataLakeDirectoryClient createDirectory(String directoryName)
Code Samples
DataLakeDirectoryClient directoryClient = client.createDirectory(directoryName);
directoryName
- Name of the directory to create.DataLakeDirectoryClient
used to interact with the directory created.public DataLakeDirectoryClient createDirectory(String directoryName, boolean overwrite)
Code Samples
boolean overwrite = false; /* Default value. */ DataLakeDirectoryClient dClient = client.createDirectory(fileName, overwrite);
directoryName
- Name of the directory to create.overwrite
- Whether or not to overwrite, should a directory exist.DataLakeDirectoryClient
used to interact with the directory created.public com.azure.core.http.rest.Response<DataLakeDirectoryClient> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); String permissions = "permissions"; String umask = "umask"; Response<DataLakeDirectoryClient> newDirectoryClient = client.createDirectoryWithResponse(directoryName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions, timeout, new Context(key1, value1));
directoryName
- Name of the directory to create.permissions
- POSIX access permissions for the directory owner, the directory owning group, and others.umask
- Restricts permissions of the directory to be created.headers
- PathHttpHeaders
metadata
- Metadata to associate with the directory.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Response
whose value
contains a DataLakeDirectoryClient
used to interact with the directory created.public void deleteDirectory(String directoryName)
Code Samples
client.deleteDirectory(directoryName); System.out.println("Delete request completed");
directoryName
- Name of the directory to delete.public com.azure.core.http.rest.Response<Void> deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); boolean recursive = false; // Default value client.deleteDirectoryWithResponse(directoryName, recursive, requestConditions, timeout, new Context(key1, value1)); System.out.println("Delete request completed");
directoryName
- Name of the directory to delete.recursive
- Whether or not to delete all paths beneath the directory.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public FileSystemAccessPolicies getAccessPolicy()
Code Samples
FileSystemAccessPolicies accessPolicies = client.getAccessPolicy(); System.out.printf("Data Lake Access Type: %s%n", accessPolicies.getDataLakeAccessType()); for (DataLakeSignedIdentifier identifier : accessPolicies.getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); }
public com.azure.core.http.rest.Response<FileSystemAccessPolicies> getAccessPolicyWithResponse(String leaseId, Duration timeout, com.azure.core.util.Context context)
Code Samples
Context context = new Context("Key", "Value"); FileSystemAccessPolicies accessPolicies = client.getAccessPolicyWithResponse(leaseId, timeout, context) .getValue(); System.out.printf("Data Lake Access Type: %s%n", accessPolicies.getDataLakeAccessType()); for (DataLakeSignedIdentifier identifier : accessPolicies.getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); }
leaseId
- The lease ID the active lease on the file system must match.timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public void setAccessPolicy(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers)
Code Samples
DataLakeSignedIdentifier identifier = new DataLakeSignedIdentifier() .setId("name") .setAccessPolicy(new DataLakeAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); try { client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)); System.out.printf("Set Access Policy completed %n"); } catch (UnsupportedOperationException error) { System.out.printf("Set Access Policy completed %s%n", error); }
accessType
- Specifies how the data in this file system is available to the public. See the
x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.identifiers
- A list of DataLakeSignedIdentifier
objects that specify the permissions for the file
system.
Please see
here
for more information. Passing null will clear all access policies.public com.azure.core.http.rest.Response<Void> setAccessPolicyWithResponse(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
DataLakeSignedIdentifier identifier = new DataLakeSignedIdentifier() .setId("name") .setAccessPolicy(new DataLakeAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("Key", "Value"); System.out.printf("Set access policy completed with status %d%n", client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions, timeout, context).getStatusCode());
accessType
- Specifies how the data in this file system is available to the public. See the
x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.identifiers
- A list of DataLakeSignedIdentifier
objects that specify the permissions for the file
system.
Please see
here
for more information. Passing null will clear all access policies.requestConditions
- DataLakeRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey)
DataLakeServiceSasSignatureValues
.
See DataLakeServiceSasSignatureValues
for more information on how to construct a user delegation SAS.
Code Samples
OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1); FileSystemSasPermission myPermission = new FileSystemSasPermission().setReadPermission(true); DataLakeServiceSasSignatureValues myValues = new DataLakeServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); client.generateUserDelegationSas(values, userDelegationKey);
dataLakeServiceSasSignatureValues
- DataLakeServiceSasSignatureValues
userDelegationKey
- A UserDelegationKey
object used to sign the SAS values.String
representing all SAS query parameters.for more information on how to
get a user delegation key.
public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues)
DataLakeServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential
See DataLakeServiceSasSignatureValues
for more information on how to construct a service SAS.
Code Samples
OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); FileSystemSasPermission permission = new FileSystemSasPermission().setReadPermission(true); DataLakeServiceSasSignatureValues values = new DataLakeServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
dataLakeServiceSasSignatureValues
- DataLakeServiceSasSignatureValues
String
representing all SAS query parameters.Copyright © 2020 Microsoft Corporation. All rights reserved.