DataLakeDirectoryAsyncClient Class
- java.
lang. Object - com.
azure. storage. file. datalake. DataLakePathAsyncClient - com.
azure. storage. file. datalake. DataLakeDirectoryAsyncClient
- com.
- com.
public final class DataLakeDirectoryAsyncClient
extends DataLakePathAsyncClient
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 getDirectoryAsyncClient(String directoryName).
Please refer to the Azure Docs for more information.
Method Summary
Methods inherited from DataLakePathAsyncClient
Methods inherited from java.lang.Object
Method Details
createFile
public Mono
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
DataLakeFileAsyncClient fileClient = client.createFile(fileName).block();
Parameters:
Returns:
createFile
public Mono
Creates a new file within a directory. For more information, see the Azure Docs.
Code Samples
boolean overwrite = false; /* Default value. */
DataLakeFileAsyncClient fClient = client.createFile(fileName, overwrite).block();
Parameters:
Returns:
createFileIfNotExists
public Mono
Creates a new file within a directory if it does not exist. By default this method will not overwrite an existing file. For more information, see the Azure Docs.
Code Samples
DataLakeFileAsyncClient fileClient = client.createFileIfNotExists(fileName).block();
Parameters:
Returns:
createFileIfNotExistsWithResponse
public Mono
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"));
client.createFileIfNotExistsWithResponse(fileName, options).subscribe(response -> {
if (response.getStatusCode() == 409) {
System.out.println("Already exists.");
} else {
System.out.println("successfully created.");
}
});
Parameters:
Returns:
createFileWithResponse
public Mono
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);
DataLakeFileAsyncClient newFileClient = client.createFileWithResponse(fileName, options).block().getValue();
Parameters:
Returns:
createFileWithResponse
public Mono
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";
DataLakeFileAsyncClient newFileClient = client.createFileWithResponse(fileName,
permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions
).block().getValue();
Parameters:
Returns:
createSubdirectory
public Mono
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
DataLakeDirectoryAsyncClient directoryClient = client.createSubdirectory(directoryName).block();
Parameters:
Returns:
createSubdirectory
public Mono
Creates a new sub-directory within a directory. For more information, see the Azure Docs.
Code Samples
boolean overwrite = false; /* Default value. */
DataLakeDirectoryAsyncClient dClient = client.createSubdirectory(directoryName, overwrite).block();
Parameters:
Returns:
createSubdirectoryIfNotExists
public Mono
Creates a new subdirectory within a directory if it does not exist. For more information, see the Azure Docs.
Code Samples
DataLakeDirectoryAsyncClient subdirectoryClient = client.createSubdirectoryIfNotExists(directoryName).block();
Parameters:
Returns:
createSubdirectoryIfNotExistsWithResponse
public Mono
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"));
client.createSubdirectoryIfNotExistsWithResponse(directoryName, options).subscribe(response -> {
if (response.getStatusCode() == 409) {
System.out.println("Already exists.");
} else {
System.out.println("successfully created.");
}
});
Parameters:
Returns:
createSubdirectoryWithResponse
public Mono
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);
DataLakeDirectoryAsyncClient newDirectoryClient = client.createSubdirectoryWithResponse(directoryName, options)
.block().getValue();
Parameters:
Returns:
createSubdirectoryWithResponse
public Mono
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";
DataLakeDirectoryAsyncClient newDirectoryClient = client.createSubdirectoryWithResponse(
directoryName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"),
requestConditions
).block().getValue();
Parameters:
Returns:
delete
public Mono
Deletes a directory.
Code Samples
client.delete().subscribe(response ->
System.out.println("Delete request completed"));
For more information see the Azure Docs
Returns:
deleteFile
public Mono
Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.
Code Samples
client.deleteFile(fileName).subscribe(response ->
System.out.println("Delete request completed"));
Parameters:
Returns:
deleteFileIfExists
public Mono
Deletes the specified file in the file system if it exists. For more information see the Azure Docs.
Code Samples
client.deleteFileIfExists(fileName).subscribe(deleted -> {
if (deleted) {
System.out.println("successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
Parameters:
Returns:
true
indicates that the specified file was successfully
deleted, false
indicates that the specified file did not exist.deleteFileIfExistsWithResponse
public Mono
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);
client.deleteFileIfExistsWithResponse(fileName, options).subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
Parameters:
Returns:
deleteFileWithResponse
public Mono
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)
.subscribe(response -> System.out.println("Delete request completed"));
Parameters:
Returns:
deleteIfExists
public Mono
Deletes a directory if it exists.
Code Samples
client.deleteIfExists().subscribe(deleted -> {
if (deleted) {
System.out.println("Successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
For more information see the Azure Docs
Overrides:
DataLakeDirectoryAsyncClient.deleteIfExists()Returns:
true
indicates that the directory was successfully
deleted, true
indicates that the directory did not exist.deleteIfExistsWithResponse
public Mono
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);
client.deleteIfExistsWithResponse(options).subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
For more information see the Azure Docs
Overrides:
DataLakeDirectoryAsyncClient.deleteIfExistsWithResponse(DataLakePathDeleteOptions options)Parameters:
Returns:
deleteRecursively
public Mono
Recursively deletes a directory and all contents within the directory.
Code Samples
client.deleteRecursively().subscribe(response ->
System.out.println("Delete request completed"));
For more information see the Azure Docs
Returns:
deleteRecursivelyWithResponse
public Mono
Recursively deletes a directory and all contents within the directory.
Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
.setLeaseId(leaseId);
boolean recursive = false; // Default value
client.deleteWithResponse(recursive, requestConditions)
.subscribe(response -> System.out.println("Delete request completed"));
For more information see the Azure Docs
Parameters:
Returns:
deleteSubdirectory
public Mono
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).subscribe(response ->
System.out.println("Delete request completed"));
Parameters:
Returns:
deleteSubdirectoryIfExists
public Mono
Deletes the specified subdirectory in the directory if it exists. For more information see the Azure Docs.
Code Samples
client.deleteSubdirectoryIfExists(directoryName).subscribe(deleted -> {
if (deleted) {
System.out.println("Successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
Parameters:
Returns:
true
indicates that the subdirectory was deleted.
false
indicates the specified subdirectory does not exist.deleteSubdirectoryIfExistsWithResponse
public Mono
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);
client.deleteSubdirectoryIfExistsWithResponse(directoryName, options).subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
Parameters:
Returns:
deleteSubdirectoryWithResponse
public Mono
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)
.subscribe(response -> System.out.println("Delete request completed"));
Parameters:
Returns:
deleteWithResponse
public Mono
Deletes a directory.
Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
.setLeaseId(leaseId);
boolean recursive = false; // Default value
client.deleteWithResponse(recursive, requestConditions)
.subscribe(response -> System.out.println("Delete request completed"));
For more information see the Azure Docs
Parameters:
Returns:
getCustomerProvidedKeyAsyncClient
public DataLakeDirectoryAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)
Creates a new DataLakeDirectoryAsyncClient with the specified customerProvidedKey
.
Overrides:
DataLakeDirectoryAsyncClient.getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)Parameters:
null
to use no customer provided key.
Returns:
customerProvidedKey
.getDirectoryName
public String getDirectoryName()
Gets the name of this directory, not including its full path.
Returns:
getDirectoryPath
public String getDirectoryPath()
Gets the path of this directory, not including the name of the resource itself.
Returns:
getDirectoryUrl
public String getDirectoryUrl()
Gets the URL of the directory represented by this client on the Data Lake service.
Returns:
getFileAsyncClient
public DataLakeFileAsyncClient getFileAsyncClient(String fileName)
Creates a new DataLakeFileAsyncClient object by concatenating fileName to the end of DataLakeDirectoryAsyncClient's URL. The new DataLakeFileAsyncClient uses the same request policy pipeline as the DataLakeDirectoryAsyncClient.
Code Samples
DataLakeFileAsyncClient dataLakeFileClient = client.getFileAsyncClient(fileName);
Parameters:
String
representing the name of the file.
Returns:
getSubdirectoryAsyncClient
public DataLakeDirectoryAsyncClient getSubdirectoryAsyncClient(String subdirectoryName)
Creates a new DataLakeDirectoryAsyncClient object by concatenating subdirectoryName to the end of DataLakeDirectoryAsyncClient's URL. The new DataLakeDirectoryAsyncClient uses the same request policy pipeline as the DataLakeDirectoryAsyncClient.
Code Samples
DataLakeDirectoryAsyncClient dataLakeDirectoryClient = client.getSubdirectoryAsyncClient(directoryName);
Parameters:
String
representing the name of the sub-directory.
Returns:
listPaths
public PagedFlux
Returns a reactive Publisher emitting all the files/directories in this directory lazily as needed. For more information, see the Azure Docs.
Code Samples
client.listPaths().subscribe(path -> System.out.printf("Name: %s%n", path.getName()));
Returns:
listPaths
public PagedFlux
Returns a reactive Publisher emitting all the files/directories in this directory lazily as needed. For more information, see the Azure Docs.
Code Samples
client.listPaths(false, false, 10)
.subscribe(path -> System.out.printf("Name: %s%n", path.getName()));
Parameters:
Returns:
rename
public Mono
Moves the directory to another location within the file system. For more information see the Azure Docs.
Code Samples
DataLakeDirectoryAsyncClient renamedClient = client.rename(fileSystemName, destinationPath).block();
System.out.println("Directory Client has been renamed");
Parameters:
null
for the current file system.
Returns:
renameWithResponse
public Mono
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();
DataLakeDirectoryAsyncClient newRenamedClient = client.renameWithResponse(fileSystemName, destinationPath,
sourceRequestConditions, destinationRequestConditions).block().getValue();
System.out.println("Directory Client has been renamed");
Parameters:
null
for the current file system.
Returns:
Applies to
Azure SDK for Java