Sdílet prostřednictvím


DataLakeDirectoryClient Class

public class DataLakeDirectoryClient
extends DataLakePathClient

This class provides a client that contains directory operations for Azure Storage Data Lake. Operations provided by this client include creating a directory, deleting a directory, renaming a directory, setting metadata and http headers, setting and retrieving access control, getting properties and creating and deleting files and subdirectories.

This client is instantiated through DataLakePathClientBuilder or retrieved via getDirectoryClient(String directoryName).

Please refer to the Azure Docs for more information.

Method Summary

Modifier and Type Method and Description
DataLakeFileClient createFile(String fileName)

Creates a new file within a directory.

DataLakeFileClient createFile(String fileName, boolean overwrite)

Creates a new file within a directory.

DataLakeFileClient createFileIfNotExists(String fileName)

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

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

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

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

Creates a new file within a directory.

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

DataLakeDirectoryClient createSubdirectory(String subdirectoryName)

Creates a new sub-directory within a directory.

DataLakeDirectoryClient createSubdirectory(String subdirectoryName, boolean overwrite)

Creates a new sub-directory within a directory.

DataLakeDirectoryClient createSubdirectoryIfNotExists(String subdirectoryName)

Creates a new sub-directory if it does not exist within a directory.

Response<DataLakeDirectoryClient> createSubdirectoryIfNotExistsWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new sub-directory within a directory if it does not exist.

Response<DataLakeDirectoryClient> createSubdirectoryWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new sub-directory within a directory.

Response<DataLakeDirectoryClient> createSubdirectoryWithResponse(String subdirectoryName, String permissions, String umask, PathHttpHeaders headers, Map<String,String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Creates a new sub-directory within a directory.

void delete()

Deletes a directory.

void deleteFile(String fileName)

Deletes the specified file in the directory.

boolean deleteFileIfExists(String fileName)

Deletes the specified file in the directory if it exists.

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

Deletes the specified file in the directory if it exists.

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

Deletes the specified file in the directory.

boolean deleteIfExists()

Deletes a directory if it exists.

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

Deletes a directory if it exists.

void deleteRecursively()

Recursively deletes a directory and all contents within the directory.

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

Recursively deletes a directory and all contents within the directory.

void deleteSubdirectory(String subdirectoryName)

Deletes the specified sub-directory in the directory.

boolean deleteSubdirectoryIfExists(String subdirectoryName)

Deletes the specified sub-directory in the directory if it exists.

Response<Boolean> deleteSubdirectoryIfExistsWithResponse(String subdirectoryName, DataLakePathDeleteOptions options, Duration timeout, Context context)

Deletes the specified subdirectory in the directory if it exists.

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

Deletes the specified sub-directory in the directory.

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

Deletes a directory.

DataLakeDirectoryClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new DataLakeDirectoryClient with the specified customerProvidedKey.

String getDirectoryName()

Gets the name of this directory, not including its full path.

String getDirectoryPath()

Gets the path of this directory, not including the name of the resource itself.

String getDirectoryUrl()

Gets the URL of the directory represented by this client on the Data Lake service.

DataLakeFileClient getFileClient(String fileName)

Initializes a new DataLakeFileClient object by concatenating fileName to the end of DataLakeDirectoryClient's URL.

DataLakeDirectoryClient getSubdirectoryClient(String subdirectoryName)

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

PagedIterable<PathItem> listPaths()

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

PagedIterable<PathItem> listPaths(boolean recursive, boolean userPrincipleNameReturned, Integer maxResults, Duration timeout)

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

DataLakeDirectoryClient rename(String destinationFileSystem, String destinationPath)

Moves the directory to another location within the file system.

Response<DataLakeDirectoryClient> renameWithResponse(String destinationFileSystem, String destinationPath, DataLakeRequestConditions sourceRequestConditions, DataLakeRequestConditions destinationRequestConditions, Duration timeout, Context context)

Moves the directory to another location within the file system.

Methods inherited from DataLakePathClient

Methods inherited from java.lang.Object

Method Details

createFile

public DataLakeFileClient createFile(String fileName)

Creates a new file within a directory. 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.

Returns:

A DataLakeFileClient used to interact with the file created.

createFile

public DataLakeFileClient createFile(String fileName, boolean overwrite)

Creates a new file within a directory. 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.
overwrite - Whether or not 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 directory if it does not exist. For more information, see the Azure Docs.

Code Samples

DataLakeFileClient fileClient = client.createFileIfNotExists(fileName);

Parameters:

fileName - Name of the file to create.

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 directory 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.
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 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 Response createFileWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new file within a directory. 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.
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 directory. 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.
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.

createSubdirectory

public DataLakeDirectoryClient createSubdirectory(String subdirectoryName)

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

Code Samples

DataLakeDirectoryClient directoryClient = client.createSubdirectory(directoryName);

Parameters:

subdirectoryName - Name of the sub-directory to create.

Returns:

A DataLakeDirectoryClient used to interact with the sub-directory created.

createSubdirectory

public DataLakeDirectoryClient createSubdirectory(String subdirectoryName, boolean overwrite)

Creates a new sub-directory within a directory. For more information, see the Azure Docs.

Code Samples

boolean overwrite = false; /* Default value. */
 DataLakeDirectoryClient dClient = client.createSubdirectory(fileName, overwrite);

Parameters:

subdirectoryName - Name of the sub-directory to create.
overwrite - Whether or not to overwrite, should the sub-directory exist.

Returns:

A DataLakeDirectoryClient used to interact with the sub-directory created.

createSubdirectoryIfNotExists

public DataLakeDirectoryClient createSubdirectoryIfNotExists(String subdirectoryName)

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

Code Samples

DataLakeDirectoryClient directoryClient = client.createSubdirectoryIfNotExists(directoryName);

Parameters:

subdirectoryName - Name of the subdirectory to create.

Returns:

A DataLakeDirectoryClient used to interact with the subdirectory created.

createSubdirectoryIfNotExistsWithResponse

public Response createSubdirectoryIfNotExistsWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new sub-directory within a directory 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.createSubdirectoryIfNotExistsWithResponse(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:

subdirectoryName - Name of the sub-directory to create.
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 subdirectory created. If Response<T>'s status code is 201, a new subdirectory was successfully created. If status code is 409, a subdirectory with the same name already existed at this location.

createSubdirectoryWithResponse

public Response createSubdirectoryWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, Context context)

Creates a new sub-directory within a directory. If a sub-directory with the same name already exists, the sub-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.createSubdirectoryWithResponse(directoryName,
     options, timeout, new Context(key1, value1));

Parameters:

subdirectoryName - Name of the sub-directory to create.
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 sub-directory created.

createSubdirectoryWithResponse

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

Creates a new sub-directory within a directory. If a sub-directory with the same name already exists, the sub-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.createSubdirectoryWithResponse(directoryName,
     permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions, timeout,
     new Context(key1, value1));

Parameters:

subdirectoryName - Name of the sub-directory to create.
permissions - POSIX access permissions for the sub-directory owner, the sub-directory owning group, and others.
umask - Restricts permissions of the sub-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 sub-directory created.

delete

public void delete()

Deletes a directory.

Code Samples

client.delete();
 System.out.println("Delete request completed");

For more information see the Azure Docs

deleteFile

public void deleteFile(String fileName)

Deletes the specified file in the directory. 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.

deleteFileIfExists

public boolean deleteFileIfExists(String fileName)

Deletes the specified file in the directory 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.

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

 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.
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 specified file was successfully deleted. If status code is 404, the specified file does not exist.

deleteFileWithResponse

public Response deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified file in the directory. 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.
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()

Deletes a directory if it exists.

Code Samples

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

For more information see the Azure Docs

Overrides:

DataLakeDirectoryClient.deleteIfExists()

Returns:

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

deleteIfExistsWithResponse

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

Deletes a directory if it exists.

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

For more information see the Azure Docs

Overrides:

DataLakeDirectoryClient.deleteIfExistsWithResponse(DataLakePathDeleteOptions options, Duration timeout, Context context)

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. If Response<T>'s status code is 200, the directory was successfully deleted. If status code is 404, the directory does not exist.

deleteRecursively

public void deleteRecursively()

Recursively deletes a directory and all contents within the directory.

Code Samples

client.deleteRecursively();
 System.out.println("Delete request completed");

For more information see the Azure Docs

deleteRecursivelyWithResponse

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

Recursively deletes a directory and all contents within the directory.

Code Samples

DataLakeRequestConditions deleteRequestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 client.deleteRecursivelyWithResponse(deleteRequestConditions, timeout, new Context(key1, value1));
 System.out.println("Delete request completed");

For more information see the Azure Docs

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 reactive response signalling completion.

deleteSubdirectory

public void deleteSubdirectory(String subdirectoryName)

Deletes the specified sub-directory in the directory. If the sub-directory doesn't exist or is not empty the operation fails. For more information see the Azure Docs.

Code Samples

client.deleteSubdirectory(directoryName);
 System.out.println("Delete request completed");

Parameters:

subdirectoryName - Name of the sub-directory to delete.

deleteSubdirectoryIfExists

public boolean deleteSubdirectoryIfExists(String subdirectoryName)

Deletes the specified sub-directory in the directory if it exists. For more information see the Azure Docs.

Code Samples

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

Parameters:

subdirectoryName - Name of the subdirectory to delete.

Returns:

true if subdirectory is successfully deleted, false if subdirectory does not exist.

deleteSubdirectoryIfExistsWithResponse

public Response deleteSubdirectoryIfExistsWithResponse(String subdirectoryName, DataLakePathDeleteOptions options, Duration timeout, Context context)

Deletes the specified subdirectory in the directory 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.deleteSubdirectoryIfExistsWithResponse(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:

subdirectoryName - Name of the sub-directory to delete.
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 specified subdirectory was successfully deleted. If status code is 404, the specified subdirectory does not exist.

deleteSubdirectoryWithResponse

public Response deleteSubdirectoryWithResponse(String subdirectoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified sub-directory in the directory. If the sub-directory doesn't exist or is not empty the operation fails. For more information see the Azure Docs.

Code Samples

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

 client.deleteSubdirectoryWithResponse(directoryName, recursive, requestConditions, timeout,
     new Context(key1, value1));
 System.out.println("Delete request completed");

Parameters:

subdirectoryName - Name of the sub-directory to delete.
recursive - Whether or not to delete all paths beneath the sub-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

deleteWithResponse

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

Deletes a directory.

Code Samples

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

 client.deleteWithResponse(recursive, requestConditions, timeout, new Context(key1, value1));
 System.out.println("Delete request completed");

For more information see the Azure Docs

Parameters:

recursive - Whether or not to delete all paths beneath the directory.
requestConditions - DataLakeRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A reactive response signalling completion.

getCustomerProvidedKeyClient

public DataLakeDirectoryClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new DataLakeDirectoryClient with the specified customerProvidedKey.

Overrides:

DataLakeDirectoryClient.getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Parameters:

customerProvidedKey - the CustomerProvidedKey for the directory, pass null to use no customer provided key.

Returns:

a DataLakeDirectoryClient with the specified customerProvidedKey.

getDirectoryName

public String getDirectoryName()

Gets the name of this directory, not including its full path.

Returns:

The name of the directory.

getDirectoryPath

public String getDirectoryPath()

Gets the path of this directory, not including the name of the resource itself.

Returns:

The path of the directory.

getDirectoryUrl

public String getDirectoryUrl()

Gets the URL of the directory represented by this client on the Data Lake service.

Returns:

the URL.

getFileClient

public DataLakeFileClient getFileClient(String fileName)

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

Parameters:

fileName - A String representing the name of the file. Code Samples
 DataLakeFileClient dataLakeFileClient = client.getFileClient(fileName);
 

Returns:

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

getSubdirectoryClient

public DataLakeDirectoryClient getSubdirectoryClient(String subdirectoryName)

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

Parameters:

subdirectoryName - A String representing the name of the sub-directory. Code Samples
 DataLakeDirectoryClient dataLakeDirectoryClient = client.getSubdirectoryClient(directoryName);
 

Returns:

A new DataLakeDirectoryClient object which references the sub-directory with the specified name in this directory

listPaths

public PagedIterable listPaths()

Returns a lazy loaded list of files/directories in this directory. 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(boolean recursive, boolean userPrincipleNameReturned, Integer maxResults, Duration timeout)

Returns a lazy loaded list of files/directories in this directory. 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(false, false, 10, timeout)
     .forEach(path -> System.out.printf("Name: %s%n", path.getName()));

Parameters:

recursive - Specifies if the call should recursively include all paths.
userPrincipleNameReturned - If "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If "false", the values will be returned as Azure Active Directory Object IDs. The default value is false. Note that group and application Object IDs are not translated because they do not have unique friendly names.
maxResults - Specifies the maximum number of blobs to return per page, including all BlobPrefix elements. If the request does not specify maxResults or specifies a value greater than 5,000, the server will return up to 5,000 items per page. If iterating by page, the page size passed to byPage methods such as PagedIterable#iterableByPage(int) will be preferred over this value.
timeout - An optional timeout value beyond which a RuntimeException will be raised.

Returns:

The list of files/directories.

rename

public DataLakeDirectoryClient rename(String destinationFileSystem, String destinationPath)

Moves the directory to another location within the file system. For more information see the Azure Docs.

Code Samples

DataLakeDirectoryClient renamedClient = client.rename(fileSystemName, destinationPath);
 System.out.println("Directory Client has been renamed");

Parameters:

destinationFileSystem - The file system of the destination within the account. null for the current file system.
destinationPath - Relative path from the file system to rename the directory to, excludes the file system name. For example if you want to move a directory with fileSystem = "myfilesystem", path = "mydir/mysubdir" to another path in myfilesystem (ex: newdir) then set the destinationPath = "newdir"

Returns:

A DataLakeDirectoryClient used to interact with the new directory created.

renameWithResponse

public Response renameWithResponse(String destinationFileSystem, String destinationPath, DataLakeRequestConditions sourceRequestConditions, DataLakeRequestConditions destinationRequestConditions, Duration timeout, Context context)

Moves the directory to another location within the file system. For more information, see the Azure Docs.

Code Samples

DataLakeRequestConditions sourceRequestConditions = new DataLakeRequestConditions()
     .setLeaseId(leaseId);
 DataLakeRequestConditions destinationRequestConditions = new DataLakeRequestConditions();

 DataLakeDirectoryClient newRenamedClient = client.renameWithResponse(fileSystemName, destinationPath,
     sourceRequestConditions, destinationRequestConditions, timeout, new Context(key1, value1)).getValue();
 System.out.println("Directory Client has been renamed");

Parameters:

destinationFileSystem - The file system of the destination within the account. null for the current file system.
destinationPath - Relative path from the file system to rename the directory to, excludes the file system name. For example if you want to move a directory with fileSystem = "myfilesystem", path = "mydir/mysubdir" to another path in myfilesystem (ex: newdir) then set the destinationPath = "newdir"
sourceRequestConditions - DataLakeRequestConditions against the source.
destinationRequestConditions - DataLakeRequestConditions against the destination.
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 that contains a DataLakeDirectoryClient used to interact with the directory created.

Applies to