DataLakeFileSystemAsyncClient Class

  • java.lang.Object
    • com.azure.storage.file.datalake.DataLakeFileSystemAsyncClient

public class DataLakeFileSystemAsyncClient

Client to a file system. It may only be instantiated through a DataLakeFileSystemClientBuilder or via the method getFileSystemAsyncClient(String fileSystemName). This class does not hold any state about a particular blob but is instead a convenient way of sending off appropriate requests to the resource on the service. It may also be used to construct clients for files/directories.

This client contains operations on a file system. Operations on a path are available on DataLakeFileAsyncClient and DataLakeDirectoryAsyncClient through getFileAsyncClient(String fileName) and getDirectoryAsyncClient(String directoryName) respectively, and operations on the service are available on DataLakeServiceAsyncClient.

Please refer to the Azure Docs for more information on file systems.

Note this client is an async client that returns reactive responses from Spring Reactor Core project (https://projectreactor.io/). Calling the methods in this client will NOT start the actual network operation, until .subscribe() is called on the reactive response. You can simply convert one of these responses to a CompletableFuture object through Mono#toFuture().

Field Summary

Modifier and Type Field and Description
static final String ROOT_DIRECTORY_NAME

Special directory name for the root directory of the file system.

static final String ROOT_FILESYSTEM_NAME

Special file system name for the root file system in the Storage account.

Method Summary

Modifier and Type Method and Description
Mono<Void> create()

Creates a new file system within a storage account.

Mono<DataLakeDirectoryAsyncClient> createDirectory(String directoryName)

Creates a new directory within a file system.

Mono<DataLakeDirectoryAsyncClient> createDirectory(String directoryName, boolean overwrite)

Creates a new directory within a file system.

Mono<DataLakeDirectoryAsyncClient> createDirectoryIfNotExists(String directoryName)

Creates a new directory within a file system if it does not exist.

Mono<Response<DataLakeDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options)

Creates a new directory within a file system if it does not exist.

Mono<Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options)

Creates a new directory within a file system.

Mono<Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions)

Creates a new directory within a file system.

Mono<DataLakeFileAsyncClient> createFile(String fileName)

Creates a new file within a file system.

Mono<DataLakeFileAsyncClient> createFile(String fileName, boolean overwrite)

Creates a new file within a file system.

Mono<DataLakeFileAsyncClient> createFileIfNotExists(String fileName)

Creates a new file within a file system if it does not exist.

Mono<Response<DataLakeFileAsyncClient>> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options)

Creates a new file within a file system if it does not exist.

Mono<Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, DataLakePathCreateOptions options)

Creates a new file within a file system.

Mono<Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions)

Creates a new file within a file system.

Mono<Boolean> createIfNotExists()

Creates a new file system within a storage account if it does not exist.

Mono<Response<Boolean>> createIfNotExistsWithResponse(Map<String,String> metadata, PublicAccessType accessType)

Creates a new file system within a storage account if it does not exist.

Mono<Response<Void>> createWithResponse(Map<String,String> metadata, PublicAccessType accessType)

Creates a new file system within a storage account.

Mono<Void> delete()

Marks the specified file system for deletion.

Mono<Void> deleteDirectory(String directoryName)

Deletes the specified directory in the file system.

Mono<Boolean> deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the file system if it exists.

Mono<Response<Boolean>> deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options)

Deletes the specified directory in the file system if it exists.

Mono<Response<Void>> deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions)

Deletes the specified directory in the file system.

Mono<Void> deleteFile(String fileName)

Deletes the specified file in the file system.

Mono<Boolean> deleteFileIfExists(String fileName)

Deletes the specified file in the file system if it exists.

Mono<Response<Boolean>> deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options)

Deletes the specified file in the file system if it exists.

Mono<Response<Void>> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions)

Deletes the specified file in the file system.

Mono<Boolean> deleteIfExists()

Marks the specified file system for deletion if it exists.

Mono<Response<Boolean>> deleteIfExistsWithResponse(DataLakePathDeleteOptions options)

Marks the specified file system for deletion if it exists.

Mono<Response<Void>> deleteWithResponse(DataLakeRequestConditions requestConditions)

Marks the specified file system for deletion.

Mono<Boolean> exists()

Determines if the file system exists in the cloud.

Mono<Response<Boolean>> existsWithResponse()

Determines if the file system exists in the cloud.

String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues)

Generates a service SAS for the file system using the specified DataLakeServiceSasSignatureValues

String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Context context)

Generates a service SAS for the file system using the specified DataLakeServiceSasSignatureValues

String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey)

Generates a user delegation SAS for the file system using the specified DataLakeServiceSasSignatureValues.

String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Context context)

Generates a user delegation SAS for the file system using the specified DataLakeServiceSasSignatureValues.

Mono<FileSystemAccessPolicies> getAccessPolicy()

Returns the file system's permissions.

Mono<Response<FileSystemAccessPolicies>> getAccessPolicyWithResponse(String leaseId)

Returns the file system's permissions.

String getAccountName()

Get associated account name.

String getAccountUrl()

Get the url of the storage account.

DataLakeDirectoryAsyncClient getDirectoryAsyncClient(String directoryName)

Initializes a new DataLakeDirectoryAsyncClient object by concatenating directoryName to the end of DataLakeFileSystemAsyncClient's URL.

DataLakeFileAsyncClient getFileAsyncClient(String fileName)

Initializes a new DataLakeFileAsyncClient object by concatenating fileName to the end of DataLakeFileSystemAsyncClient's URL.

String getFileSystemName()

Get the file system name.

String getFileSystemUrl()

Gets the URL of the file system represented by this client.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Mono<FileSystemProperties> getProperties()

Returns the file system's metadata and system properties.

Mono<Response<FileSystemProperties>> getPropertiesWithResponse(String leaseId)

Returns the file system's metadata and system properties.

DataLakeServiceVersion getServiceVersion()

Gets the service version the client is using.

PagedFlux<PathDeletedItem> listDeletedPaths()

Returns a reactive Publisher emitting all the files/directories in this filesystem that have been recently soft deleted lazily as needed.

PagedFlux<PathDeletedItem> listDeletedPaths(String prefix)

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.

PagedFlux<PathItem> listPaths()

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.

PagedFlux<PathItem> listPaths(ListPathsOptions options)

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.

Mono<Void> setAccessPolicy(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers)

Sets the file system's permissions.

Mono<Response<Void>> setAccessPolicyWithResponse(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions)

Sets the file system's permissions.

Mono<Void> setMetadata(Map<String,String> metadata)

Sets the file system's metadata.

Mono<Response<Void>> setMetadataWithResponse(Map<String,String> metadata, DataLakeRequestConditions requestConditions)

Sets the file system's metadata.

Mono<DataLakePathAsyncClient> undeletePath(String deletedPath, String deletionId)

Restores a soft deleted path in the file system.

Mono<Response<DataLakePathAsyncClient>> undeletePathWithResponse(String deletedPath, String deletionId)

Restores a soft deleted path in the file system.

Methods inherited from java.lang.Object

Field Details

ROOT_DIRECTORY_NAME

public static final String ROOT_DIRECTORY_NAME

Special directory name for the root directory of the file system.

This should only be used while getting the root directory from the file system client.

ROOT_FILESYSTEM_NAME

public static final String ROOT_FILESYSTEM_NAME

Special file system name for the root file system in the Storage account.

Method Details

create

public Mono create()

Creates a new file system within a storage account. If a file system with the same name already exists, the operation fails. For more information, see the Azure Docs.

Code Samples

client.create().subscribe(
     response -> System.out.printf("Create completed%n"),
     error -> System.out.printf("Error while creating file system %s%n", error));

Returns:

A reactive response signalling completion.

createDirectory

public Mono createDirectory(String directoryName)

Creates a new directory within a file system. By default, this method will not overwrite an existing directory. For more information, see the Azure Docs.

Code Samples

Mono<DataLakeDirectoryAsyncClient> directoryClient = client.createDirectory(directoryName);

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a DataLakeDirectoryAsyncClient used to interact with the directory created.

createDirectory

public Mono createDirectory(String directoryName, boolean overwrite)

Creates a new directory within a file system. For more information, see the Azure Docs.

Code Samples

boolean overwrite = false; /* Default value. */
 Mono<DataLakeDirectoryAsyncClient> dClient = client.createDirectory(directoryName, overwrite);

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.
overwrite - Whether to overwrite, should a directory exist.

Returns:

A Mono containing a DataLakeDirectoryAsyncClient used to interact with the directory created.

createDirectoryIfNotExists

public Mono createDirectoryIfNotExists(String directoryName)

Creates a new directory within a file system if it does not exist. For more information, see the Azure Docs.

Code Samples

DataLakeDirectoryAsyncClient directoryAsyncClient = client.createDirectoryIfNotExists(directoryName).block();

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a DataLakeDirectoryAsyncClient used to interact with the directory created.

createDirectoryIfNotExistsWithResponse

public Mono<>> createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options)

Creates a new directory within a file system if it does not exist. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders headers = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 String permissions = "permissions";
 String umask = "umask";
 DataLakePathCreateOptions options = new DataLakePathCreateOptions()
     .setPermissions(permissions)
     .setUmask(umask)
     .setPathHttpHeaders(headers)
     .setMetadata(Collections.singletonMap("metadata", "value"));

 client.createDirectoryIfNotExistsWithResponse(directoryName, options).subscribe(response -> {
     if (response.getStatusCode() == 409) {
         System.out.println("Already exists.");
     } else {
         System.out.println("successfully created.");
     }
 });

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a Response<T> whose value contains a DataLakeDirectoryAsyncClient used to interact with the directory created. If Response<T>'s status code is 201, a new directory was successfully created. If status code is 409, a directory with the same name already existed at this location.

createDirectoryWithResponse

public Mono<>> createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options)

Creates a new directory within a file system. If a directory with the same name already exists, the directory will be overwritten. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders httpHeaders = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 String permissions = "permissions";
 String umask = "umask";
 String owner = "rwx";
 String group = "r--";
 String leaseId = UUID.randomUUID().toString();
 Integer duration = 15;

 DataLakePathCreateOptions options = new DataLakePathCreateOptions()
     .setPermissions(permissions)
     .setUmask(umask)
     .setOwner(owner)
     .setGroup(group)
     .setPathHttpHeaders(httpHeaders)
     .setRequestConditions(requestConditions)
     .setMetadata(metadata)
     .setProposedLeaseId(leaseId)
     .setLeaseDuration(duration);

 Mono<Response<DataLakeDirectoryAsyncClient>> newDirectoryClient = client.createDirectoryWithResponse(
     directoryName, options);

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a Response<T> whose value contains a DataLakeDirectoryAsyncClient used to interact with the directory created.

createDirectoryWithResponse

public Mono<>> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map metadata, DataLakeRequestConditions requestConditions)

Creates a new directory within a file system. If a directory with the same name already exists, the directory will be overwritten. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders httpHeaders = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 String permissions = "permissions";
 String umask = "umask";
 Mono<Response<DataLakeDirectoryAsyncClient>> newDirectoryClient = client.createDirectoryWithResponse(
     directoryName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"),
     requestConditions);

Parameters:

directoryName - Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.
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 resource. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - DataLakeRequestConditions

Returns:

A Mono containing a Response<T> whose value contains a DataLakeDirectoryAsyncClient used to interact with the directory created.

createFile

public Mono createFile(String fileName)

Creates a new file within a file system. By default, this method will not overwrite an existing file. For more information, see the Azure Docs.

Code Samples

Mono<DataLakeFileAsyncClient> fileClient = client.createFile(fileName);

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a DataLakeFileAsyncClient used to interact with the file created.

createFile

public Mono createFile(String fileName, boolean overwrite)

Creates a new file within a file system. For more information, see the Azure Docs.

Code Samples

boolean overwrite = false; /* Default value. */
 Mono<DataLakeFileAsyncClient> fClient = client.createFile(fileName, overwrite);

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.
overwrite - Whether to overwrite, should a file exist.

Returns:

A Mono containing a DataLakeFileAsyncClient used to interact with the file created.

createFileIfNotExists

public Mono createFileIfNotExists(String fileName)

Creates a new file within a file system if it does not exist. For more information, see the Azure Docs.

Code Samples

DataLakeFileAsyncClient fileAsyncClient = client.createFileIfNotExists(fileName).block();

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a DataLakeFileAsyncClient used to interact with the file created.

createFileIfNotExistsWithResponse

public Mono<>> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options)

Creates a new file within a file system if it does not exist. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders headers = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 String permissions = "permissions";
 String umask = "umask";
 DataLakePathCreateOptions options = new DataLakePathCreateOptions()
     .setPermissions(permissions)
     .setUmask(umask)
     .setPathHttpHeaders(headers)
     .setMetadata(Collections.singletonMap("metadata", "value"));

 client.createFileIfNotExistsWithResponse(fileName, options).subscribe(response -> {
     if (response.getStatusCode() == 409) {
         System.out.println("Already exists.");
     } else {
         System.out.println("successfully created.");
     }
 });

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a Response<T> whose value contains a DataLakeFileAsyncClient used to interact with the file created. If Response<T>'s status code is 201, a new file was successfully created. If status code is 409, a file with the same name already existed at this location.

createFileWithResponse

public Mono<>> createFileWithResponse(String fileName, DataLakePathCreateOptions options)

Creates a new file within a file system. If a file with the same name already exists, the file will be overwritten. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders httpHeaders = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 String permissions = "permissions";
 String umask = "umask";
 String owner = "rwx";
 String group = "r--";
 String leaseId = UUID.randomUUID().toString();
 Integer duration = 15;
 DataLakePathCreateOptions options = new DataLakePathCreateOptions()
     .setPermissions(permissions)
     .setUmask(umask)
     .setOwner(owner)
     .setGroup(group)
     .setPathHttpHeaders(httpHeaders)
     .setRequestConditions(requestConditions)
     .setMetadata(metadata)
     .setProposedLeaseId(leaseId)
     .setLeaseDuration(duration);

 Mono<Response<DataLakeFileAsyncClient>> newFileClient = client.createFileWithResponse(fileName, options);

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A Mono containing a Response<T> whose value contains a DataLakeFileAsyncClient used to interact with the file created.

createFileWithResponse

public Mono<>> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map metadata, DataLakeRequestConditions requestConditions)

Creates a new file within a file system. If a file with the same name already exists, the file will be overwritten. For more information, see the Azure Docs.

Code Samples

PathHttpHeaders httpHeaders = new PathHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary");
 DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 String permissions = "permissions";
 String umask = "umask";
 Mono<Response<DataLakeFileAsyncClient>> newFileClient = client.createFileWithResponse(fileName, permissions,
     umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions);

Parameters:

fileName - Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.
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. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - DataLakeRequestConditions

Returns:

A Mono containing a Response<T> whose value contains a DataLakeFileAsyncClient used to interact with the file created.

createIfNotExists

public Mono createIfNotExists()

Creates a new file system within a storage account if it does not exist. For more information, see the Azure Docs.

Code Samples

client.createIfNotExists().subscribe(created -> {
     if (created) {
         System.out.println("Successfully created.");
     } else {
         System.out.println("Already exists.");
     }
 });

Returns:

A reactive response signalling completion. true indicates that a new file system was created. false indicates that a file system already existed at this location.

createIfNotExistsWithResponse

public Mono<>> createIfNotExistsWithResponse(Map metadata, PublicAccessType accessType)

Creates a new file system within a storage account if it does not exist. For more information, see the Azure Docs.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 client.createIfNotExistsWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> {
     if (response.getStatusCode() == 409) {
         System.out.println("Already exists.");
     } else {
         System.out.println("successfully created.");
     }
 });

Parameters:

metadata - Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
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.

Returns:

A reactive response signaling completion. If Response<T>'s status code is 201, a new file system was successfully created. If status code is 409, a file system already existed at this location.

createWithResponse

public Mono<>> createWithResponse(Map metadata, PublicAccessType accessType)

Creates a new file system within a storage account. If a file system with the same name already exists, the operation fails. For more information, see the Azure Docs.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response ->
     System.out.printf("Create completed with status %d%n", response.getStatusCode()));

Parameters:

metadata - Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
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.

Returns:

A reactive response signalling completion.

delete

public Mono delete()

Marks the specified file system for deletion. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.

Code Samples

client.delete().subscribe(
     response -> System.out.printf("Delete completed%n"),
     error -> System.out.printf("Delete failed: %s%n", error));

Returns:

A reactive response signalling completion.

deleteDirectory

public Mono deleteDirectory(String directoryName)

Deletes the specified directory in the file system. If the directory doesn't exist the operation fails. For more information see the Azure Docs.

Code Samples

client.deleteDirectory(directoryName).subscribe(response ->
     System.out.println("Delete request completed"));

Parameters:

directoryName - Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A reactive response signalling completion.

deleteDirectoryIfExists

public Mono deleteDirectoryIfExists(String directoryName)

Deletes the specified directory in the file system if it exists. For more information see the Azure Docs.

Code Samples

client.deleteDirectoryIfExists(fileName).subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

Parameters:

directoryName - Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

a reactive response signaling completion. true indicates that the specified directory was successfully deleted, false indicates that the specified directory did not exist.

deleteDirectoryIfExistsWithResponse

public Mono<>> deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options)

Deletes the specified directory in the file system if it exists. For more information see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 boolean recursive = false; // Default value
 DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(recursive)
     .setRequestConditions(requestConditions);

 client.deleteDirectoryIfExistsWithResponse(directoryName, options).subscribe(response -> {
     if (response.getStatusCode() == 404) {
         System.out.println("Does not exist.");
     } else {
         System.out.println("successfully deleted.");
     }
 });

Parameters:

directoryName - Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A reactive response signaling completion. If Response<T>'s status code is 200, the file was successfully deleted. If status code is 404, the file does not exist.

deleteDirectoryWithResponse

public Mono<>> deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions)

Deletes the specified directory in the file system. If the directory doesn't exist the operation fails. For more information see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 boolean recursive = false; // Default value

 client.deleteDirectoryWithResponse(directoryName, recursive, requestConditions)
     .subscribe(response -> System.out.println("Delete request completed"));

Parameters:

directoryName - Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.
recursive - Whether to delete all paths beneath the directory.
requestConditions - DataLakeRequestConditions

Returns:

A Mono containing status code and HTTP headers

deleteFile

public Mono deleteFile(String fileName)

Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.

Code Samples

client.deleteFile(fileName).subscribe(response ->
     System.out.println("Delete request completed"));

Parameters:

fileName - Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A reactive response signalling completion.

deleteFileIfExists

public Mono deleteFileIfExists(String fileName)

Deletes the specified file in the file system if it exists. For more information see the Azure Docs.

Code Samples

client.deleteFileIfExists(fileName).subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

Parameters:

fileName - Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

a reactive response signaling completion. true indicates that the specified file was successfully deleted, false indicates that the specified file did not exist.

deleteFileIfExistsWithResponse

public Mono<>> deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options)

Deletes the specified file in the file system if it exists. For more information see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(false)
     .setRequestConditions(requestConditions);

 client.deleteFileIfExistsWithResponse(fileName, options).subscribe(response -> {
     if (response.getStatusCode() == 404) {
         System.out.println("Does not exist.");
     } else {
         System.out.println("successfully deleted.");
     }
 });

Parameters:

fileName - Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A reactive response signaling completion. If Response<T>'s status code is 200, the file was successfully deleted. If status code is 404, the file does not exist.

deleteFileWithResponse

public Mono<>> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions)

Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);

 client.deleteFileWithResponse(fileName, requestConditions)
     .subscribe(response -> System.out.println("Delete request completed"));

Parameters:

fileName - Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.
requestConditions - DataLakeRequestConditions

Returns:

A Mono containing status code and HTTP headers

deleteIfExists

public Mono deleteIfExists()

Marks the specified file system for deletion if it exists. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.

Code Samples

client.deleteIfExists().subscribe(deleted -> {
     if (deleted) {
         System.out.println("Successfully deleted.");
     } else {
         System.out.println("Does not exist.");
     }
 });

Returns:

a reactive response signaling completion. true indicates that the file system was successfully deleted, false indicates that the file system did not exist.

deleteIfExistsWithResponse

public Mono<>> deleteIfExistsWithResponse(DataLakePathDeleteOptions options)

Marks the specified file system for deletion if it exists. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(false)
     .setRequestConditions(requestConditions);

 client.deleteIfExistsWithResponse(options).subscribe(response -> {
     if (response.getStatusCode() == 404) {
         System.out.println("Does not exist.");
     } else {
         System.out.println("successfully deleted.");
     }
 });

Parameters:

Returns:

A reactive response signaling completion. If Response<T>'s status code is 202, the file system was successfully deleted. If status code is 404, the file system does not exist.

deleteWithResponse

public Mono<>> deleteWithResponse(DataLakeRequestConditions requestConditions)

Marks the specified file system for deletion. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.

Code Samples

DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));

 client.deleteWithResponse(requestConditions).subscribe(response ->
     System.out.printf("Delete completed with status %d%n", response.getStatusCode()));

Parameters:

requestConditions - DataLakeRequestConditions

Returns:

A reactive response signalling completion.

exists

public Mono exists()

Determines if the file system exists in the cloud.

Code Samples

client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));

Returns:

true if the path exists, false if it doesn't

existsWithResponse

public Mono<>> existsWithResponse()

Determines if the file system exists in the cloud.

Code Samples

client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));

Returns:

true if the path exists, false if it doesn't

generateSas

public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues)

Generates a service SAS for the file system using the specified 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

Parameters:

dataLakeServiceSasSignatureValues - DataLakeServiceSasSignatureValues

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Context context)

Generates a service SAS for the file system using the specified 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 must be authenticated via StorageSharedKeyCredential
 client.generateSas(values, new Context("key", "value"));

Parameters:

dataLakeServiceSasSignatureValues - DataLakeServiceSasSignatureValues
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

generateUserDelegationSas

public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey)

Generates a user delegation SAS for the file system using the specified 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);

Parameters:

dataLakeServiceSasSignatureValues - DataLakeServiceSasSignatureValues
userDelegationKey - A UserDelegationKey object used to sign the SAS values. See getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) for more information on how to get a user delegation key.

Returns:

A String representing the SAS query parameters.

generateUserDelegationSas

public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Context context)

Generates a user delegation SAS for the file system using the specified 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, accountName, new Context("key", "value"));

Parameters:

dataLakeServiceSasSignatureValues - DataLakeServiceSasSignatureValues
userDelegationKey - A UserDelegationKey object used to sign the SAS values. See getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) for more information on how to get a user delegation key.
accountName - The account name.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccessPolicy

public Mono getAccessPolicy()

Returns the file system's permissions. The permissions indicate whether file system's paths may be accessed publicly. For more information, see the Azure Docs.

Code Samples

client.getAccessPolicy().subscribe(response -> {
     System.out.printf("Data Lake Access Type: %s%n", response.getDataLakeAccessType());

     for (DataLakeSignedIdentifier identifier : response.getIdentifiers()) {
         System.out.printf("Identifier Name: %s, Permissions %s%n",
             identifier.getId(),
             identifier.getAccessPolicy().getPermissions());
     }
 });

Returns:

A reactive response containing the file system access policy.

getAccessPolicyWithResponse

public Mono<>> getAccessPolicyWithResponse(String leaseId)

Returns the file system's permissions. The permissions indicate whether file system's paths may be accessed publicly. For more information, see the Azure Docs.

Code Samples

client.getAccessPolicyWithResponse(leaseId).subscribe(response -> {
     System.out.printf("Data Lake Access Type: %s%n", response.getValue().getDataLakeAccessType());

     for (DataLakeSignedIdentifier identifier : response.getValue().getIdentifiers()) {
         System.out.printf("Identifier Name: %s, Permissions %s%n",
             identifier.getId(),
             identifier.getAccessPolicy().getPermissions());
     }
 });

Parameters:

leaseId - The lease ID the active lease on the file system must match.

Returns:

A reactive response containing the file system access policy.

getAccountName

public String getAccountName()

Get associated account name.

Returns:

account name associated with this storage resource.

getAccountUrl

public String getAccountUrl()

Get the url of the storage account.

Returns:

the URL of the storage account

getDirectoryAsyncClient

public DataLakeDirectoryAsyncClient getDirectoryAsyncClient(String directoryName)

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.

Code Samples

DataLakeDirectoryAsyncClient dataLakeDirectoryAsyncClient = client.getDirectoryAsyncClient(directoryName);

Parameters:

directoryName - A String representing the name of the directory. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A new DataLakeDirectoryAsyncClient object which references the directory with the specified name in this file system.

getFileAsyncClient

public DataLakeFileAsyncClient getFileAsyncClient(String fileName)

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.

Code Samples

DataLakeFileAsyncClient dataLakeFileAsyncClient = client.getFileAsyncClient(fileName);

Parameters:

fileName - A String representing the name of the file. If the path name contains special characters, pass in the url encoded version of the path name.

Returns:

A new DataLakeFileAsyncClient object which references the file with the specified name in this file system.

getFileSystemName

public String getFileSystemName()

Get the file system name.

Code Samples

String fileSystemName = client.getFileSystemName();
 System.out.println("The name of the file system is " + fileSystemName);

Returns:

The name of file system.

getFileSystemUrl

public String getFileSystemUrl()

Gets the URL of the file system represented by this client.

Returns:

the URL.

getHttpPipeline

public HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Returns:

The pipeline.

getProperties

public Mono getProperties()

Returns the file system's metadata and system properties. For more information, see the Azure Docs.

Code Samples

client.getProperties().subscribe(response ->
     System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
         response.getDataLakePublicAccess(),
         response.hasLegalHold(),
         response.hasImmutabilityPolicy()));

Returns:

A Mono containing a Response<T> whose value containing the file system properties.

getPropertiesWithResponse

public Mono<>> getPropertiesWithResponse(String leaseId)

Returns the file system's metadata and system properties. For more information, see the Azure Docs.

Code Samples

client.getPropertiesWithResponse(leaseId).subscribe(response ->
     System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n",
         response.getValue().getDataLakePublicAccess(),
         response.getValue().hasLegalHold(),
         response.getValue().hasImmutabilityPolicy()));

Parameters:

leaseId - The lease ID the active lease on the file system must match.

Returns:

A reactive response containing the file system properties.

getServiceVersion

public DataLakeServiceVersion getServiceVersion()

Gets the service version the client is using.

Returns:

the service version the client is using.

listDeletedPaths

public PagedFlux listDeletedPaths()

Returns a reactive Publisher emitting all the files/directories in this filesystem that have been recently soft deleted lazily as needed. For more information, see the Azure Docs.

Code Samples

client.listDeletedPaths().subscribe(path -> System.out.printf("Name: %s%n", path.getPath()));

Returns:

A reactive response emitting the list of files/directories.

listDeletedPaths

public PagedFlux listDeletedPaths(String prefix)

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs. Note: You can specify the page size by using byPaged methods that accept an integer such as PagedFlux#byPage(int). Please refer to the REST docs above for limitations on page size

Code Samples

int pageSize = 10;
 client.listDeletedPaths("PathNamePrefixToMatch")
     .byPage(pageSize)
     .subscribe(page ->
         page.getValue().forEach(path ->
             System.out.printf("Name: %s%n", path.getPath())));

Parameters:

prefix - Specifies the path to filter the results to.

Returns:

A reactive response emitting the list of files/directories.

listPaths

public PagedFlux listPaths()

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs.

Code Samples

client.listPaths().subscribe(path -> System.out.printf("Name: %s%n", path.getName()));

Returns:

A reactive response emitting the list of files/directories.

listPaths

public PagedFlux listPaths(ListPathsOptions options)

Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs.

Code Samples

ListPathsOptions options = new ListPathsOptions()
     .setPath("PathNamePrefixToMatch")
     .setMaxResults(10);

 client.listPaths(options).subscribe(path -> System.out.printf("Name: %s%n", path.getName()));

Parameters:

options - A ListPathsOptions which specifies what data should be returned by the service.

Returns:

A reactive response emitting the list of files/directories.

setAccessPolicy

public Mono setAccessPolicy(PublicAccessType accessType, List identifiers)

Sets the file system's permissions. The permissions indicate whether paths in a file system may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.

Code Samples

DataLakeSignedIdentifier identifier = new DataLakeSignedIdentifier()
     .setId("name")
     .setAccessPolicy(new DataLakeAccessPolicy()
         .setStartsOn(OffsetDateTime.now())
         .setExpiresOn(OffsetDateTime.now().plusDays(7))
         .setPermissions("permissionString"));

 client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe(
     response -> System.out.printf("Set access policy completed%n"),
     error -> System.out.printf("Set access policy failed: %s%n", error));

Parameters:

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.

Returns:

A reactive response signalling completion.

setAccessPolicyWithResponse

public Mono<>> setAccessPolicyWithResponse(PublicAccessType accessType, List identifiers, DataLakeRequestConditions requestConditions)

Sets the file system's permissions. The permissions indicate whether paths in a file system may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.

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));

 client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions)
     .subscribe(response ->
         System.out.printf("Set access policy completed with status %d%n", response.getStatusCode()));

Parameters:

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

Returns:

A reactive response signalling completion.

setMetadata

public Mono setMetadata(Map metadata)

Sets the file system's metadata. For more information, see the Azure Docs.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 client.setMetadata(metadata).subscribe(
     response -> System.out.printf("Set metadata completed%n"),
     error -> System.out.printf("Set metadata failed: %s%n", error));

Parameters:

metadata - Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.

Returns:

A reactive response signalling completion.

setMetadataWithResponse

public Mono<>> setMetadataWithResponse(Map metadata, DataLakeRequestConditions requestConditions)

Sets the file system's metadata. For more information, see the Azure Docs.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId)
     .setIfModifiedSince(OffsetDateTime.now().minusDays(3));

 client.setMetadataWithResponse(metadata, requestConditions).subscribe(response ->
     System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));

Parameters:

metadata - Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - DataLakeRequestConditions

Returns:

A Mono containing a Response<T> whose value contains signalling completion.

undeletePath

public Mono undeletePath(String deletedPath, String deletionId)

Restores a soft deleted path in the file system. For more information see the Azure Docs.

Code Samples

client.undeletePath(deletedPath, deletionId).doOnSuccess(response -> System.out.println("Completed undelete"));

Parameters:

deletedPath - The deleted path
deletionId - deletion ID associated with the soft deleted path that uniquely identifies a resource if multiple have been soft deleted at this location. You can get soft deleted paths and their associated deletion IDs with listDeletedPaths().

Returns:

A reactive response signalling completion.

undeletePathWithResponse

public Mono<>> undeletePathWithResponse(String deletedPath, String deletionId)

Restores a soft deleted path in the file system. For more information see the Azure Docs.

Code Samples

client.undeletePathWithResponse(deletedPath, deletionId)
     .doOnSuccess(response -> System.out.println("Completed undelete"));

Parameters:

deletedPath - The deleted path
deletionId - deletion ID associated with the soft deleted path that uniquely identifies a resource if multiple have been soft deleted at this location. You can get soft deleted paths and their associated deletion IDs with listDeletedPaths().

Returns:

A reactive response signalling completion.

Applies to