Sdílet prostřednictvím


DataLakeFileSystemClient Class

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

public class DataLakeFileSystemClient

Client to a file system. It may only be instantiated through a DataLakeFileSystemClientBuilder or via the method getFileSystemClient(String fileSystemName). 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 getFileClient(String fileName) and getDirectoryClient(String directoryName) respectively, and operations on the service are available on DataLakeServiceClient.

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

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
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.

DataLakeDirectoryClient createDirectoryIfNotExists(String directoryName)

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

Response<DataLakeDirectoryClient> createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

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

Response<DataLakeDirectoryClient> createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new directory within a file system.

Response<DataLakeDirectoryClient> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, 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.

DataLakeFileClient createFileIfNotExists(String fileName)

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

Response<DataLakeFileClient> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, Context context)

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

Response<DataLakeFileClient> createFileWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new file within a file system.

Response<DataLakeFileClient> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Creates a new file within a file system.

boolean createIfNotExists()

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

Response<Boolean> createIfNotExistsWithResponse(Map<String,String> metadata, PublicAccessType accessType, Duration timeout, Context context)

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

Response<Void> createWithResponse(Map<String,String> metadata, PublicAccessType accessType, Duration timeout, 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.

boolean deleteDirectoryIfExists(String directoryName)

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

Response<Boolean> deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options, Duration timeout, Context context)

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

Response<Void> deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified directory in the file system.

void deleteFile(String fileName)

Deletes the specified file in the file system.

boolean deleteFileIfExists(String fileName)

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

Response<Boolean> deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options, Duration timeout, Context context)

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

Response<Void> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the file system.

boolean deleteIfExists()

Marks the specified file system for deletion if it exists.

Response<Boolean> deleteIfExistsWithResponse(DataLakePathDeleteOptions options, Duration timeout, Context context)

Marks the specified file system for deletion if it exists.

Response<Void> deleteWithResponse(DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Marks the specified file system for deletion.

boolean exists()

Determines if the file system exists in the cloud.

Response<Boolean> existsWithResponse(Duration timeout, Context context)

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 generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Consumer<String> stringToSignHandler, 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.

String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, Context context)

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

FileSystemAccessPolicies getAccessPolicy()

Returns the file system's permissions.

Response<FileSystemAccessPolicies> getAccessPolicyWithResponse(String leaseId, Duration timeout, Context context)

Returns the file system's permissions.

String getAccountName()

Get associated account name.

String getAccountUrl()

Get the url of the storage account.

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.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

FileSystemProperties getProperties()

Returns the file system's metadata and system properties.

Response<FileSystemProperties> getPropertiesWithResponse(String leaseId, Duration timeout, Context context)

Returns the file system's metadata and system properties.

DataLakeServiceVersion getServiceVersion()

Gets the service version the client is using.

PagedIterable<PathDeletedItem> listDeletedPaths()

Returns a lazy loaded list of files/directories recently soft deleted in this file system.

PagedIterable<PathDeletedItem> listDeletedPaths(String prefix, Duration timeout, Context context)

Returns a lazy loaded list of files/directories recently soft deleted in this account.

PagedIterable<PathItem> listPaths()

Returns a lazy loaded list of files/directories in this account.

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.

Response<Void> setAccessPolicyWithResponse(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Sets the file system's permissions.

void setMetadata(Map<String,String> metadata)

Sets the file system's metadata.

Response<Void> setMetadataWithResponse(Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Sets the file system's metadata.

DataLakePathClient undeletePath(String deletedPath, String deletionId)

Restores a soft deleted path in the file system.

Response<DataLakePathClient> undeletePathWithResponse(String deletedPath, String deletionId, Duration timeout, Context context)

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 void 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

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

createDirectory

public DataLakeDirectoryClient 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

DataLakeDirectoryClient 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 DataLakeDirectoryClient used to interact with the directory created.

createDirectory

public DataLakeDirectoryClient 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. */
 DataLakeDirectoryClient dClient = client.createDirectory(fileName, 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 DataLakeDirectoryClient used to interact with the directory created.

createDirectoryIfNotExists

public DataLakeDirectoryClient 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

DataLakeDirectoryClient directoryClient = client.createDirectoryIfNotExists(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 DataLakeDirectoryClient used to interact with the subdirectory created.

createDirectoryIfNotExistsWithResponse

public Response createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

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

 Response<DataLakeDirectoryClient> response = client.createDirectoryIfNotExistsWithResponse(directoryName,
     options, timeout, new Context(key1, value1));
 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     System.out.printf("Create completed with status %d%n", response.getStatusCode());
 }

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.
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.

Returns:

A Response<T> whose value contains the DataLakeDirectoryClient 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 Response createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

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 = CoreUtils.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);

 Response<DataLakeDirectoryClient> newDirectoryClient = client.createDirectoryWithResponse(directoryName,
     options, timeout, new Context(key1, value1));

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.
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.

Returns:

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

createDirectoryWithResponse

public Response createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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";
 Response<DataLakeDirectoryClient> newDirectoryClient = client.createDirectoryWithResponse(directoryName,
     permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions,
     timeout, new Context(key1, value1));

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
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.

Returns:

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

createFile

public DataLakeFileClient 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

DataLakeFileClient 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 DataLakeFileClient used to interact with the file created.

createFile

public DataLakeFileClient 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. */
 DataLakeFileClient 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 DataLakeFileClient used to interact with the file created.

createFileIfNotExists

public DataLakeFileClient 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

DataLakeFileClient 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 DataLakeFileClient used to interact with the file created.

createFileIfNotExistsWithResponse

public Response createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, Context context)

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

 Response<DataLakeFileClient> response = client.createFileIfNotExistsWithResponse(fileName, options, timeout,
     new Context(key1, value1));
 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     System.out.printf("Create completed with status %d%n", response.getStatusCode());
 }

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.
options - DataLakePathCreateOptions metadata key or value, it must be removed or encoded.
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.

Returns:

A Response<T> whose value contains the DataLakeFileClient 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 Response createFileWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, Context context)

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 = CoreUtils.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);

 Response<DataLakeFileClient> newFileClient = client.createFileWithResponse(fileName, options, timeout,
     new Context(key1, value1));

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.
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.

Returns:

A Response<T> whose value contains the DataLakeFileClient used to interact with the file created.

createFileWithResponse

public Response createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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";
 Response<DataLakeFileClient> newFileClient = client.createFileWithResponse(fileName, permissions, umask, httpHeaders,
     Collections.singletonMap("metadata", "value"), requestConditions,
     timeout, new Context(key1, value1));

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
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.

Returns:

A Response<T> whose value contains the DataLakeFileClient used to interact with the file created.

createIfNotExists

public boolean createIfNotExists()

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

Code Samples

boolean result = client.createIfNotExists();
 System.out.println("file system created: " + result);

Returns:

true if file system is successfully created, false if file system already exists.

createIfNotExistsWithResponse

public Response createIfNotExistsWithResponse(Map metadata, PublicAccessType accessType, Duration timeout, Context context)

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");
 Context context = new Context("Key", "Value");

 Response<Boolean> response = client.createIfNotExistsWithResponse(metadata, PublicAccessType.CONTAINER, timeout,
     context);
 if (response.getStatusCode() == 409) {
     System.out.println("Already existed.");
 } else {
     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.
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.

Returns:

A response containing status code and HTTP headers. 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 Response createWithResponse(Map metadata, PublicAccessType accessType, Duration timeout, Context context)

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");
 Context context = new Context("Key", "Value");

 System.out.printf("Create completed with status %d%n",
     client.createWithResponse(metadata, PublicAccessType.CONTAINER, timeout, context).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.
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.

Returns:

A response containing status code and HTTP headers

delete

public void 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

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

deleteDirectory

public void 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);
 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.

deleteDirectoryIfExists

public boolean deleteDirectoryIfExists(String directoryName)

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

Code Samples

boolean result = client.deleteDirectoryIfExists(directoryName);
 System.out.println("Delete request completed: " + result);

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:

true if the directory is successfully deleted, false if the directory does not exist.

deleteDirectoryIfExistsWithResponse

public Response deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options, Duration timeout, Context context)

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

 Response<Boolean> response = client.deleteDirectoryIfExistsWithResponse(directoryName, options,
     timeout, new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

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.
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.

Returns:

A response containing status code and HTTP headers. If Response<T>'s status code is 200, the directory was successfully deleted. If status code is 404, the directory does not exist.

deleteDirectoryWithResponse

public Response deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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, timeout,
     new Context(key1, value1));
 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
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.

Returns:

A response containing status code and HTTP headers

deleteFile

public void 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);
 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.

deleteFileIfExists

public boolean deleteFileIfExists(String fileName)

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

Code Samples

boolean result = client.deleteFileIfExists(fileName);
 System.out.println("Delete request completed: " + result);

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:

true if the file is successfully deleted, false if the file does not exist.

deleteFileIfExistsWithResponse

public Response deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options, Duration timeout, Context context)

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().setRequestConditions(requestConditions);

 Response<Boolean> response = client.deleteFileIfExistsWithResponse(fileName, options, timeout,
     new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

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.
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.

Returns:

A response containing status code and HTTP headers. 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 Response deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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, timeout, new Context(key1, value1));
 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
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.

Returns:

A response containing status code and HTTP headers

deleteIfExists

public boolean 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();

Returns:

true if file system is successfully deleted, false if the file system does not exist.

deleteIfExistsWithResponse

public Response deleteIfExistsWithResponse(DataLakePathDeleteOptions options, Duration timeout, Context context)

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));
 Context context = new Context("Key", "Value");
 DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(false)
     .setRequestConditions(requestConditions);

 Response<Boolean> response = client.deleteIfExistsWithResponse(options, timeout, context);
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

Parameters:

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.

Returns:

A response containing status code and HTTP headers. The presence of a Response<T> indicates the file system was deleted successfully, null indicates the file system does not exist at this location.

deleteWithResponse

public Response deleteWithResponse(DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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));
 Context context = new Context("Key", "Value");

 System.out.printf("Delete completed with status %d%n", client.deleteWithResponse(
     requestConditions, timeout, context).getStatusCode());

Parameters:

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.

Returns:

A response containing status code and HTTP headers

exists

public boolean exists()

Determines if the file system exists in the cloud.

Code Samples

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

Returns:

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

existsWithResponse

public Response existsWithResponse(Duration timeout, Context context)

Determines if the file system exists in the cloud.

Code Samples

System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context("Key", "Value")).getValue());

Parameters:

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.

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.

generateSas

public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Consumer stringToSignHandler, 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.

Parameters:

dataLakeServiceSasSignatureValues - DataLakeServiceSasSignatureValues
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
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.

generateUserDelegationSas

public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, 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.

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.
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccessPolicy

public FileSystemAccessPolicies 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

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

Returns:

The file system access policy.

getAccessPolicyWithResponse

public Response getAccessPolicyWithResponse(String leaseId, Duration timeout, Context context)

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

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

Parameters:

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.

Returns:

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

getDirectoryClient

public DataLakeDirectoryClient getDirectoryClient(String directoryName)

Initializes a new DataLakeDirectoryClient object by concatenating directoryName to the end of DataLakeFileSystemClient's URL. The new DataLakeDirectoryClient uses the same request policy pipeline as the DataLakeFileSystemClient.

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. Code Samples
 DataLakeDirectoryClient dataLakeDirectoryClient = client.getDirectoryClient(directoryName);
 

Returns:

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

getFileClient

public DataLakeFileClient getFileClient(String fileName)

Initializes a new DataLakeFileClient object by concatenating fileName to the end of DataLakeFileSystemClient's URL. The new DataLakeFileClient uses the same request policy pipeline as the DataLakeFileSystemClient.

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. Code Samples
 DataLakeFileClient dataLakeFileClient = client.getFileClient(fileName);
 

Returns:

A new DataLakeFileClient 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 FileSystemProperties getProperties()

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

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

Returns:

The file system properties.

getPropertiesWithResponse

public Response getPropertiesWithResponse(String leaseId, Duration timeout, Context context)

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

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

Parameters:

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.

Returns:

A 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 PagedIterable listDeletedPaths()

Returns a lazy loaded list of files/directories recently soft deleted in this file system. The returned PagedIterable<T> can be consumed while new items are automatically retrieved as needed. For more information, see the Azure Docs.

Code Samples

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

Returns:

The list of files/directories.

listDeletedPaths

public PagedIterable listDeletedPaths(String prefix, Duration timeout, Context context)

Returns a lazy loaded list of files/directories recently soft deleted in this account. The returned PagedIterable<T> can be consumed while new items are automatically retrieved as needed. For more information, see the Azure Docs.

Code Samples

Context context = new Context("Key", "Value");
 int pageSize = 10;

 client.listDeletedPaths("PathPrefixToMatch", timeout, context)
     .iterableByPage(pageSize)
     .forEach(page ->
         page.getValue().forEach(path ->
             System.out.printf("Name: %s%n", path.getPath())));

Parameters:

prefix - Specifies the path to filter the results to.
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.

Returns:

The list of files/directories.

listPaths

public PagedIterable listPaths()

Returns a lazy loaded list of files/directories in this account. The returned PagedIterable<T> 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()));

Returns:

The list of files/directories.

listPaths

public PagedIterable listPaths(ListPathsOptions options, Duration timeout)

Returns a lazy loaded list of files/directories in this account. The returned PagedIterable<T> 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()));

Parameters:

options - A ListPathsOptions which specifies what data should be returned by the service. If iterating by page, the page size passed to byPage methods such as PagedIterable#iterableByPage(int) will be preferred over the value set on these options.
timeout - An optional timeout value beyond which a RuntimeException will be raised.

Returns:

The list of files/directories.

setAccessPolicy

public void 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"));

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

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.

setAccessPolicyWithResponse

public Response setAccessPolicyWithResponse(PublicAccessType accessType, List identifiers, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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

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

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
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.

Returns:

A response containing status code and HTTP headers

setMetadata

public void 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");
 try {
     client.setMetadata(metadata);
     System.out.printf("Set metadata completed with status %n");
 } catch (UnsupportedOperationException error) {
     System.out.printf("Fail while setting metadata %n");
 }

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.

setMetadataWithResponse

public Response setMetadataWithResponse(Map metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

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

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
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.

Returns:

A response containing status code and HTTP headers

undeletePath

public DataLakePathClient 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);
 System.out.println("Delete request completed");

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 client pointing to the restored resource.

undeletePathWithResponse

public Response undeletePathWithResponse(String deletedPath, String deletionId, Duration timeout, Context context)

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

Code Samples

client.undeletePathWithResponse(deletedPath, deletionId, timeout, new Context(key1, value1));
 System.out.println("Delete request completed");

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().
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.

Returns:

A response containing a client pointing to the restored resource.

Applies to