Class DataLakeFileSystemAsyncClient
DataLakeFileSystemClientBuilder or via the
method DataLakeServiceAsyncClient.getFileSystemAsyncClient(String). This class does not hold any state about
a particular blob but is instead a convenient way of sending off appropriate requests to the resource on the service.
It may also be used to construct clients for files/directories.
This client contains operations on a file system. Operations on a path are available on
DataLakeFileAsyncClient and DataLakeDirectoryAsyncClient through getFileAsyncClient(String)
and getDirectoryAsyncClient(String) respectively, and operations on the service are available on
DataLakeServiceAsyncClient.
Please refer to the Azure Docs for more information on file systems.
Note this client is an async client that returns reactive responses from Spring Reactor Core project
(https://projectreactor.io/). Calling the methods in this client will NOT start the actual network
operation, until .subscribe() is called on the reactive response. You can simply convert one of these
responses to a CompletableFuture object through Mono.toFuture().
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates a new file system within a storage account.createDirectory(String directoryName) Creates a new directory within a file system.createDirectory(String directoryName, boolean overwrite) Creates a new directory within a file system.createDirectoryIfNotExists(String directoryName) Creates a new directory within a file system if it does not exist.Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options) Creates a new directory within a file system if it does not exist.Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options) Creates a new directory within a file system.Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions) Creates a new directory within a file system.createFile(String fileName) Creates a new file within a file system.createFile(String fileName, boolean overwrite) Creates a new file within a file system.createFileIfNotExists(String fileName) Creates a new file within a file system if it does not exist.Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options) Creates a new file within a file system if it does not exist.Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, DataLakePathCreateOptions options) Creates a new file within a file system.Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions) Creates a new file within a file system.Creates a new file system within a storage account if it does not exist.createIfNotExistsWithResponse(Map<String, String> metadata, PublicAccessType accessType) Creates a new file system within a storage account if it does not exist.createWithResponse(Map<String, String> metadata, PublicAccessType accessType) Creates a new file system within a storage account.delete()Marks the specified file system for deletion.deleteDirectory(String directoryName) Deletes the specified directory in the file system.deleteDirectoryIfExists(String directoryName) Deletes the specified directory in the file system if it exists.deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options) Deletes the specified directory in the file system if it exists.deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions) Deletes the specified directory in the file system.deleteFile(String fileName) Deletes the specified file in the file system.deleteFileIfExists(String fileName) Deletes the specified file in the file system if it exists.deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options) Deletes the specified file in the file system if it exists.deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions) Deletes the specified file in the file system.Marks the specified file system for deletion if it exists.Marks the specified file system for deletion if it exists.deleteWithResponse(DataLakeRequestConditions requestConditions) Marks the specified file system for deletion.exists()Determines if the file system exists in the cloud.Determines if the file system exists in the cloud.generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues) Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesgenerateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, com.azure.core.util.Context context) Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesgenerateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesgenerateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, com.azure.core.util.Context context) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.Returns the file system's permissions.Mono<com.azure.core.http.rest.Response<FileSystemAccessPolicies>> getAccessPolicyWithResponse(String leaseId) Returns the file system's permissions.Get associated account name.Get the url of the storage account.getDirectoryAsyncClient(String directoryName) Initializes a new DataLakeDirectoryAsyncClient object by concatenating directoryName to the end of DataLakeFileSystemAsyncClient's URL.getFileAsyncClient(String fileName) Initializes a new DataLakeFileAsyncClient object by concatenating fileName to the end of DataLakeFileSystemAsyncClient's URL.Get the file system name.Gets the URL of the file system represented by this client.com.azure.core.http.HttpPipelineGets theHttpPipelinepowering this client.Returns the file system's metadata and system properties.Mono<com.azure.core.http.rest.Response<FileSystemProperties>> getPropertiesWithResponse(String leaseId) Returns the file system's metadata and system properties.Gets the service version the client is using.com.azure.core.http.rest.PagedFlux<PathDeletedItem> Returns a reactive Publisher emitting all the files/directories in this filesystem that have been recently soft deleted lazily as needed.com.azure.core.http.rest.PagedFlux<PathDeletedItem> listDeletedPaths(String prefix) Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.com.azure.core.http.rest.PagedFlux<PathItem> Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.com.azure.core.http.rest.PagedFlux<PathItem> listPaths(ListPathsOptions options) Returns a reactive Publisher emitting all the files/directories in this account lazily as needed.setAccessPolicy(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers) Sets the file system's permissions.setAccessPolicyWithResponse(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions) Sets the file system's permissions.setMetadata(Map<String, String> metadata) Sets the file system's metadata.setMetadataWithResponse(Map<String, String> metadata, DataLakeRequestConditions requestConditions) Sets the file system's metadata.undeletePath(String deletedPath, String deletionId) Restores a soft deleted path in the file system.Mono<com.azure.core.http.rest.Response<DataLakePathAsyncClient>> undeletePathWithResponse(String deletedPath, String deletionId) Restores a soft deleted path in the file system.
-
Field Details
-
ROOT_FILESYSTEM_NAME
Special file system name for the root file system in the Storage account.- See Also:
-
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.
- See Also:
-
-
Method Details
-
getFileAsyncClient
Initializes a new DataLakeFileAsyncClient object by concatenating fileName to the end of DataLakeFileSystemAsyncClient's URL. The new DataLakeFileAsyncClient uses the same request policy pipeline as the DataLakeFileSystemAsyncClient.Code Samples
DataLakeFileAsyncClient dataLakeFileAsyncClient = client.getFileAsyncClient(fileName);
- Parameters:
fileName- AStringrepresenting the name of the file. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A new
DataLakeFileAsyncClientobject which references the file with the specified name in this file system.
-
getDirectoryAsyncClient
Initializes a new DataLakeDirectoryAsyncClient object by concatenating directoryName to the end of DataLakeFileSystemAsyncClient's URL. The new DataLakeDirectoryAsyncClient uses the same request policy pipeline as the DataLakeFileSystemAsyncClient.Code Samples
DataLakeDirectoryAsyncClient dataLakeDirectoryAsyncClient = client.getDirectoryAsyncClient(directoryName);
- Parameters:
directoryName- AStringrepresenting the name of the directory. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A new
DataLakeDirectoryAsyncClientobject which references the directory with the specified name in this file system.
-
getAccountUrl
Get the url of the storage account.- Returns:
- the URL of the storage account
-
getFileSystemUrl
Gets the URL of the file system represented by this client.- Returns:
- the URL.
-
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.
-
getAccountName
Get associated account name.- Returns:
- account name associated with this storage resource.
-
getServiceVersion
Gets the service version the client is using.- Returns:
- the service version the client is using.
-
getHttpPipeline
public com.azure.core.http.HttpPipeline getHttpPipeline()Gets theHttpPipelinepowering this client.- Returns:
- The pipeline.
-
create
Creates a new file system within a storage account. If a file system with the same name already exists, the operation fails. For more information, see the Azure Docs.Code Samples
client.create().subscribe( response -> System.out.printf("Create completed%n"), error -> System.out.printf("Error while creating file system %s%n", error));- Returns:
- A reactive response signalling completion.
-
createWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> createWithResponse(Map<String, String> metadata, PublicAccessType accessType) Creates a new file system within a storage account. If a file system with the same name already exists, the operation fails. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); client.createWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> System.out.printf("Create completed with status %d%n", response.getStatusCode()));- Parameters:
metadata- Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.accessType- Specifies how the data in this file system is available to the public. See the x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.- Returns:
- A reactive response signalling completion.
-
createIfNotExists
Creates a new file system within a storage account if it does not exist. For more information, see the Azure Docs.Code Samples
client.createIfNotExists().subscribe(created -> { if (created) { System.out.println("Successfully created."); } else { System.out.println("Already exists."); } });- Returns:
- A reactive response signalling completion.
trueindicates that a new file system was created.falseindicates that a file system already existed at this location.
-
createIfNotExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> createIfNotExistsWithResponse(Map<String, String> metadata, PublicAccessType accessType) Creates a new file system within a storage account if it does not exist. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); client.createIfNotExistsWithResponse(metadata, PublicAccessType.CONTAINER).subscribe(response -> { if (response.getStatusCode() == 409) { System.out.println("Already exists."); } else { System.out.println("successfully created."); } });- Parameters:
metadata- Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.accessType- Specifies how the data in this file system is available to the public. See the x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.- Returns:
- A reactive response signaling completion. If
Response'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.
-
delete
Marks the specified file system for deletion. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
client.delete().subscribe( response -> System.out.printf("Delete completed%n"), error -> System.out.printf("Delete failed: %s%n", error));- Returns:
- A reactive response signalling completion.
-
deleteWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse(DataLakeRequestConditions requestConditions) Marks the specified file system for deletion. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.deleteWithResponse(requestConditions).subscribe(response -> System.out.printf("Delete completed with status %d%n", response.getStatusCode()));- Parameters:
requestConditions-DataLakeRequestConditions- Returns:
- A reactive response signalling completion.
- Throws:
UnsupportedOperationException- If eitherMatchConditions.getIfMatch()orMatchConditions.getIfNoneMatch()is set.
-
deleteIfExists
Marks the specified file system for deletion if it exists. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
client.deleteIfExists().subscribe(deleted -> { if (deleted) { System.out.println("Successfully deleted."); } else { System.out.println("Does not exist."); } });- Returns:
- a reactive response signaling completion.
trueindicates that the file system was successfully deleted,falseindicates that the file system did not exist.
-
deleteIfExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> deleteIfExistsWithResponse(DataLakePathDeleteOptions options) Marks the specified file system for deletion if it exists. The file system and any files/directories contained within it are later deleted during garbage collection. For more information, see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(false) .setRequestConditions(requestConditions); client.deleteIfExistsWithResponse(options).subscribe(response -> { if (response.getStatusCode() == 404) { System.out.println("Does not exist."); } else { System.out.println("successfully deleted."); } });- Parameters:
options-DataLakePathDeleteOptions- Returns:
- A reactive response signaling completion. If
Response's status code is 202, the file system was successfully deleted. If status code is 404, the file system does not exist. - Throws:
UnsupportedOperationException- If eitherMatchConditions.getIfMatch()orMatchConditions.getIfNoneMatch()is set.
-
getProperties
Returns the file system's metadata and system properties. For more information, see the Azure Docs.Code Samples
client.getProperties().subscribe(response -> System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", response.getDataLakePublicAccess(), response.hasLegalHold(), response.hasImmutabilityPolicy()));- Returns:
- A
Monocontaining aResponsewhosevaluecontaining the file system properties.
-
getPropertiesWithResponse
public Mono<com.azure.core.http.rest.Response<FileSystemProperties>> getPropertiesWithResponse(String leaseId) Returns the file system's metadata and system properties. For more information, see the Azure Docs.Code Samples
client.getPropertiesWithResponse(leaseId).subscribe(response -> System.out.printf("Public Access Type: %s, Legal Hold? %b, Immutable? %b%n", response.getValue().getDataLakePublicAccess(), response.getValue().hasLegalHold(), response.getValue().hasImmutabilityPolicy()));- Parameters:
leaseId- The lease ID the active lease on the file system must match.- Returns:
- A reactive response containing the file system properties.
-
exists
Determines if the file system exists in the cloud.Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));- Returns:
- true if the path exists, false if it doesn't
-
existsWithResponse
Determines if the file system exists in the cloud.Code Samples
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));- Returns:
- true if the path exists, false if it doesn't
-
setMetadata
Sets the file system's metadata. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); client.setMetadata(metadata).subscribe( response -> System.out.printf("Set metadata completed%n"), error -> System.out.printf("Set metadata failed: %s%n", error));- Parameters:
metadata- Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.- Returns:
- A reactive response signalling completion.
-
setMetadataWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> setMetadataWithResponse(Map<String, String> metadata, DataLakeRequestConditions requestConditions) Sets the file system's metadata. For more information, see the Azure Docs.Code Samples
Map<String, String> metadata = Collections.singletonMap("metadata", "value"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfModifiedSince(OffsetDateTime.now().minusDays(3)); client.setMetadataWithResponse(metadata, requestConditions).subscribe(response -> System.out.printf("Set metadata completed with status %d%n", response.getStatusCode()));- Parameters:
metadata- Metadata to associate with the file system. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.requestConditions-DataLakeRequestConditions- Returns:
- A
Monocontaining aResponsewhosevaluecontains signalling completion. - Throws:
UnsupportedOperationException- If one ofMatchConditions.getIfMatch(),MatchConditions.getIfNoneMatch(), orRequestConditions.getIfUnmodifiedSince()is set.
-
listPaths
Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs.Code Samples
client.listPaths().subscribe(path -> System.out.printf("Name: %s%n", path.getName()));- Returns:
- A reactive response emitting the list of files/directories.
-
listPaths
Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs.Code Samples
ListPathsOptions options = new ListPathsOptions() .setPath("PathNamePrefixToMatch") .setMaxResults(10); client.listPaths(options).subscribe(path -> System.out.printf("Name: %s%n", path.getName()));- Parameters:
options- AListPathsOptionswhich specifies what data should be returned by the service.- Returns:
- A reactive response emitting the list of files/directories.
-
listDeletedPaths
Returns a reactive Publisher emitting all the files/directories in this filesystem that have been recently soft deleted lazily as needed. For more information, see the Azure Docs.Code Samples
client.listDeletedPaths().subscribe(path -> System.out.printf("Name: %s%n", path.getPath()));- Returns:
- A reactive response emitting the list of files/directories.
-
listDeletedPaths
Returns a reactive Publisher emitting all the files/directories in this account lazily as needed. For more information, see the Azure Docs. Note: You can specify the page size by using byPaged methods that accept an integer such asContinuablePagedFluxCore.byPage(int). Please refer to the REST docs above for limitations on page sizeCode Samples
int pageSize = 10; client.listDeletedPaths("PathNamePrefixToMatch") .byPage(pageSize) .subscribe(page -> page.getValue().forEach(path -> System.out.printf("Name: %s%n", path.getPath())));- Parameters:
prefix- Specifies the path to filter the results to.- Returns:
- A reactive response emitting the list of files/directories.
-
createFile
Creates a new file within a file system. By default, this method will not overwrite an existing file. For more information, see the Azure Docs.Code Samples
Mono<DataLakeFileAsyncClient> fileClient = client.createFile(fileName);
- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A
Monocontaining aDataLakeFileAsyncClientused to interact with the file created.
-
createFile
Creates a new file within a file system. For more information, see the Azure Docs.Code Samples
boolean overwrite = false; /* Default value. */ Mono<DataLakeFileAsyncClient> fClient = client.createFile(fileName, overwrite);
- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.overwrite- Whether to overwrite, should a file exist.- Returns:
- A
Monocontaining aDataLakeFileAsyncClientused to interact with the file created.
-
createFileWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions) Creates a new file within a file system. If a file with the same name already exists, the file will be overwritten. For more information, see the Azure Docs.Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); String permissions = "permissions"; String umask = "umask"; Mono<Response<DataLakeFileAsyncClient>> newFileClient = client.createFileWithResponse(fileName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions);- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.permissions- POSIX access permissions for the file owner, the file owning group, and others.umask- Restricts permissions of the file to be created.headers-PathHttpHeadersmetadata- Metadata to associate with the file. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.requestConditions-DataLakeRequestConditions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeFileAsyncClientused to interact with the file created.
-
createFileWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileWithResponse(String fileName, DataLakePathCreateOptions options) Creates a new file within a file system. If a file with the same name already exists, the file will be overwritten. For more information, see the Azure Docs.Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); Map<String, String> metadata = Collections.singletonMap("metadata", "value"); String permissions = "permissions"; String umask = "umask"; String owner = "rwx"; String group = "r--"; String leaseId = 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); Mono<Response<DataLakeFileAsyncClient>> newFileClient = client.createFileWithResponse(fileName, options);- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathCreateOptions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeFileAsyncClientused to interact with the file created.
-
createFileIfNotExists
Creates a new file within a file system if it does not exist. For more information, see the Azure Docs.Code Samples
DataLakeFileAsyncClient fileAsyncClient = client.createFileIfNotExists(fileName).block();
- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A
Monocontaining aDataLakeFileAsyncClientused to interact with the file created.
-
createFileIfNotExistsWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeFileAsyncClient>> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options) Creates a new file within a file system if it does not exist. For more information, see the Azure Docs.Code Samples
PathHttpHeaders headers = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); String permissions = "permissions"; String umask = "umask"; DataLakePathCreateOptions options = new DataLakePathCreateOptions() .setPermissions(permissions) .setUmask(umask) .setPathHttpHeaders(headers) .setMetadata(Collections.singletonMap("metadata", "value")); client.createFileIfNotExistsWithResponse(fileName, options).subscribe(response -> { if (response.getStatusCode() == 409) { System.out.println("Already exists."); } else { System.out.println("successfully created."); } });- Parameters:
fileName- Name of the file to create. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathCreateOptions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeFileAsyncClientused to interact with the file created. IfResponse'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.
-
deleteFile
Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.Code Samples
client.deleteFile(fileName).subscribe(response -> System.out.println("Delete request completed"));- Parameters:
fileName- Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A reactive response signalling completion.
-
deleteFileWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions) Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); client.deleteFileWithResponse(fileName, requestConditions) .subscribe(response -> System.out.println("Delete request completed"));- Parameters:
fileName- Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.requestConditions-DataLakeRequestConditions- Returns:
- A
Monocontaining status code and HTTP headers
-
deleteFileIfExists
Deletes the specified file in the file system if it exists. For more information see the Azure Docs.Code Samples
client.deleteFileIfExists(fileName).subscribe(deleted -> { if (deleted) { System.out.println("Successfully deleted."); } else { System.out.println("Does not exist."); } });- Parameters:
fileName- Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- a reactive response signaling completion.
trueindicates that the specified file was successfully deleted,falseindicates that the specified file did not exist.
-
deleteFileIfExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options) Deletes the specified file in the file system if it exists. For more information see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(false) .setRequestConditions(requestConditions); client.deleteFileIfExistsWithResponse(fileName, options).subscribe(response -> { if (response.getStatusCode() == 404) { System.out.println("Does not exist."); } else { System.out.println("successfully deleted."); } });- Parameters:
fileName- Name of the file to delete. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathDeleteOptions- Returns:
- A reactive response signaling completion. If
Response's status code is 200, the file was successfully deleted. If status code is 404, the file does not exist.
-
createDirectory
Creates a new directory within a file system. By default, this method will not overwrite an existing directory. For more information, see the Azure Docs.Code Samples
Mono<DataLakeDirectoryAsyncClient> directoryClient = client.createDirectory(directoryName);
- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A
Monocontaining aDataLakeDirectoryAsyncClientused to interact with the directory created.
-
createDirectory
Creates a new directory within a file system. For more information, see the Azure Docs.Code Samples
boolean overwrite = false; /* Default value. */ Mono<DataLakeDirectoryAsyncClient> dClient = client.createDirectory(directoryName, overwrite);
- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.overwrite- Whether to overwrite, should a directory exist.- Returns:
- A
Monocontaining aDataLakeDirectoryAsyncClientused to interact with the directory created.
-
createDirectoryWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions) Creates a new directory within a file system. If a directory with the same name already exists, the directory will be overwritten. For more information, see the Azure Docs.Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); String permissions = "permissions"; String umask = "umask"; Mono<Response<DataLakeDirectoryAsyncClient>> newDirectoryClient = client.createDirectoryWithResponse( directoryName, permissions, umask, httpHeaders, Collections.singletonMap("metadata", "value"), requestConditions);- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.permissions- POSIX access permissions for the directory owner, the directory owning group, and others.umask- Restricts permissions of the directory to be created.headers-PathHttpHeadersmetadata- Metadata to associate with the resource. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.requestConditions-DataLakeRequestConditions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeDirectoryAsyncClientused to interact with the directory created.
-
createDirectoryWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryWithResponse(String directoryName, DataLakePathCreateOptions options) Creates a new directory within a file system. If a directory with the same name already exists, the directory will be overwritten. For more information, see the Azure Docs.Code Samples
PathHttpHeaders httpHeaders = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); Map<String, String> metadata = Collections.singletonMap("metadata", "value"); String permissions = "permissions"; String umask = "umask"; String owner = "rwx"; String group = "r--"; String leaseId = 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); Mono<Response<DataLakeDirectoryAsyncClient>> newDirectoryClient = client.createDirectoryWithResponse( directoryName, options);- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathCreateOptions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeDirectoryAsyncClientused to interact with the directory created.
-
createDirectoryIfNotExists
Creates a new directory within a file system if it does not exist. For more information, see the Azure Docs.Code Samples
DataLakeDirectoryAsyncClient directoryAsyncClient = client.createDirectoryIfNotExists(directoryName).block();
- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A
Monocontaining aDataLakeDirectoryAsyncClientused to interact with the directory created.
-
createDirectoryIfNotExistsWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName, DataLakePathCreateOptions options) Creates a new directory within a file system if it does not exist. For more information, see the Azure Docs.Code Samples
PathHttpHeaders headers = new PathHttpHeaders() .setContentLanguage("en-US") .setContentType("binary"); String permissions = "permissions"; String umask = "umask"; DataLakePathCreateOptions options = new DataLakePathCreateOptions() .setPermissions(permissions) .setUmask(umask) .setPathHttpHeaders(headers) .setMetadata(Collections.singletonMap("metadata", "value")); client.createDirectoryIfNotExistsWithResponse(directoryName, options).subscribe(response -> { if (response.getStatusCode() == 409) { System.out.println("Already exists."); } else { System.out.println("successfully created."); } });- Parameters:
directoryName- Name of the directory to create. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathCreateOptions- Returns:
- A
Monocontaining aResponsewhosevaluecontains aDataLakeDirectoryAsyncClientused to interact with the directory created. IfResponse'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.
-
deleteDirectory
Deletes the specified directory in the file system. If the directory doesn't exist the operation fails. For more information see the Azure Docs.Code Samples
client.deleteDirectory(directoryName).subscribe(response -> System.out.println("Delete request completed"));- Parameters:
directoryName- Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- A reactive response signalling completion.
-
deleteDirectoryWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> deleteDirectoryWithResponse(String directoryName, boolean recursive, DataLakeRequestConditions requestConditions) Deletes the specified directory in the file system. If the directory doesn't exist the operation fails. For more information see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); boolean recursive = false; // Default value client.deleteDirectoryWithResponse(directoryName, recursive, requestConditions) .subscribe(response -> System.out.println("Delete request completed"));- Parameters:
directoryName- Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.recursive- Whether to delete all paths beneath the directory.requestConditions-DataLakeRequestConditions- Returns:
- A
Monocontaining status code and HTTP headers
-
deleteDirectoryIfExists
Deletes the specified directory in the file system if it exists. For more information see the Azure Docs.Code Samples
client.deleteDirectoryIfExists(fileName).subscribe(deleted -> { if (deleted) { System.out.println("Successfully deleted."); } else { System.out.println("Does not exist."); } });- Parameters:
directoryName- Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.- Returns:
- a reactive response signaling completion.
trueindicates that the specified directory was successfully deleted,falseindicates that the specified directory did not exist.
-
deleteDirectoryIfExistsWithResponse
public Mono<com.azure.core.http.rest.Response<Boolean>> deleteDirectoryIfExistsWithResponse(String directoryName, DataLakePathDeleteOptions options) Deletes the specified directory in the file system if it exists. For more information see the Azure Docs.Code Samples
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId); boolean recursive = false; // Default value DataLakePathDeleteOptions options = new DataLakePathDeleteOptions().setIsRecursive(recursive) .setRequestConditions(requestConditions); client.deleteDirectoryIfExistsWithResponse(directoryName, options).subscribe(response -> { if (response.getStatusCode() == 404) { System.out.println("Does not exist."); } else { System.out.println("successfully deleted."); } });- Parameters:
directoryName- Name of the directory to delete. If the path name contains special characters, pass in the url encoded version of the path name.options-DataLakePathDeleteOptions- Returns:
- A reactive response signaling completion. If
Response's status code is 200, the file was successfully deleted. If status code is 404, the file does not exist.
-
undeletePath
Restores a soft deleted path in the file system. For more information see the Azure Docs.Code Samples
client.undeletePath(deletedPath, deletionId).doOnSuccess(response -> System.out.println("Completed undelete"));- Parameters:
deletedPath- The deleted pathdeletionId- 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 withlistDeletedPaths().- Returns:
- A reactive response signalling completion.
- Throws:
NullPointerException- if deletedPath or deletionId is null.
-
undeletePathWithResponse
public Mono<com.azure.core.http.rest.Response<DataLakePathAsyncClient>> undeletePathWithResponse(String deletedPath, String deletionId) Restores a soft deleted path in the file system. For more information see the Azure Docs.Code Samples
client.undeletePathWithResponse(deletedPath, deletionId) .doOnSuccess(response -> System.out.println("Completed undelete"));- Parameters:
deletedPath- The deleted pathdeletionId- 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 withlistDeletedPaths().- Returns:
- A reactive response signalling completion.
- Throws:
NullPointerException- if deletedPath or deletionId is null.
-
setAccessPolicy
public Mono<Void> setAccessPolicy(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers) Sets the file system's permissions. The permissions indicate whether paths in a file system may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.Code Samples
DataLakeSignedIdentifier identifier = new DataLakeSignedIdentifier() .setId("name") .setAccessPolicy(new DataLakeAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); client.setAccessPolicy(PublicAccessType.CONTAINER, Collections.singletonList(identifier)).subscribe( response -> System.out.printf("Set access policy completed%n"), error -> System.out.printf("Set access policy failed: %s%n", error));- Parameters:
accessType- Specifies how the data in this file system is available to the public. See the x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.identifiers- A list ofDataLakeSignedIdentifierobjects that specify the permissions for the file system. Please see here for more information. Passing null will clear all access policies.- Returns:
- A reactive response signalling completion.
-
setAccessPolicyWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> setAccessPolicyWithResponse(PublicAccessType accessType, List<DataLakeSignedIdentifier> identifiers, DataLakeRequestConditions requestConditions) Sets the file system's permissions. The permissions indicate whether paths in a file system may be accessed publicly. Note that, for each signed identifier, we will truncate the start and expiry times to the nearest second to ensure the time formatting is compatible with the service. For more information, see the Azure Docs.Code Samples
DataLakeSignedIdentifier identifier = new DataLakeSignedIdentifier() .setId("name") .setAccessPolicy(new DataLakeAccessPolicy() .setStartsOn(OffsetDateTime.now()) .setExpiresOn(OffsetDateTime.now().plusDays(7)) .setPermissions("permissionString")); DataLakeRequestConditions requestConditions = new DataLakeRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.setAccessPolicyWithResponse(PublicAccessType.CONTAINER, Collections.singletonList(identifier), requestConditions) .subscribe(response -> System.out.printf("Set access policy completed with status %d%n", response.getStatusCode()));- Parameters:
accessType- Specifies how the data in this file system is available to the public. See the x-ms-blob-public-access header in the Azure Docs for more information. Pass null for no public access.identifiers- A list ofDataLakeSignedIdentifierobjects that specify the permissions for the file system. Please see here for more information. Passing null will clear all access policies.requestConditions-DataLakeRequestConditions- Returns:
- A reactive response signalling completion.
- Throws:
UnsupportedOperationException- If eitherMatchConditions.getIfMatch()orMatchConditions.getIfNoneMatch()is set.
-
getAccessPolicy
Returns the file system's permissions. The permissions indicate whether file system's paths may be accessed publicly. For more information, see the Azure Docs.Code Samples
client.getAccessPolicy().subscribe(response -> { System.out.printf("Data Lake Access Type: %s%n", response.getDataLakeAccessType()); for (DataLakeSignedIdentifier identifier : response.getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); } });- Returns:
- A reactive response containing the file system access policy.
-
getAccessPolicyWithResponse
public Mono<com.azure.core.http.rest.Response<FileSystemAccessPolicies>> getAccessPolicyWithResponse(String leaseId) Returns the file system's permissions. The permissions indicate whether file system's paths may be accessed publicly. For more information, see the Azure Docs.Code Samples
client.getAccessPolicyWithResponse(leaseId).subscribe(response -> { System.out.printf("Data Lake Access Type: %s%n", response.getValue().getDataLakeAccessType()); for (DataLakeSignedIdentifier identifier : response.getValue().getIdentifiers()) { System.out.printf("Identifier Name: %s, Permissions %s%n", identifier.getId(), identifier.getAccessPolicy().getPermissions()); } });- Parameters:
leaseId- The lease ID the active lease on the file system must match.- Returns:
- A reactive response containing the file system access policy.
-
generateUserDelegationSas
public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.See
DataLakeServiceSasSignatureValuesfor 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-DataLakeServiceSasSignatureValuesuserDelegationKey- AUserDelegationKeyobject used to sign the SAS values. SeeDataLakeServiceAsyncClient.getUserDelegationKey(OffsetDateTime, OffsetDateTime)for more information on how to get a user delegation key.- Returns:
- A
Stringrepresenting the SAS query parameters.
-
generateUserDelegationSas
public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, com.azure.core.util.Context context) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.See
DataLakeServiceSasSignatureValuesfor 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-DataLakeServiceSasSignatureValuesuserDelegationKey- AUserDelegationKeyobject used to sign the SAS values. SeeDataLakeServiceAsyncClient.getUserDelegationKey(OffsetDateTime, OffsetDateTime)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
Stringrepresenting the SAS query parameters.
-
generateUserDelegationSas
public String generateUserDelegationSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates a user delegation SAS for the file system using the specifiedDataLakeServiceSasSignatureValues.See
DataLakeServiceSasSignatureValuesfor more information on how to construct a user delegation SAS.- Parameters:
dataLakeServiceSasSignatureValues-DataLakeServiceSasSignatureValuesuserDelegationKey- AUserDelegationKeyobject used to sign the SAS values. SeeDataLakeServiceAsyncClient.getUserDelegationKey(OffsetDateTime, OffsetDateTime)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
Stringrepresenting the SAS query parameters.
-
generateSas
Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesNote : The client must be authenticated via
StorageSharedKeyCredentialSee
DataLakeServiceSasSignatureValuesfor 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
Stringrepresenting the SAS query parameters.
-
generateSas
public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, com.azure.core.util.Context context) Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesNote : The client must be authenticated via
StorageSharedKeyCredentialSee
DataLakeServiceSasSignatureValuesfor 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-DataLakeServiceSasSignatureValuescontext- Additional context that is passed through the code when generating a SAS.- Returns:
- A
Stringrepresenting the SAS query parameters.
-
generateSas
public String generateSas(DataLakeServiceSasSignatureValues dataLakeServiceSasSignatureValues, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates a service SAS for the file system using the specifiedDataLakeServiceSasSignatureValuesNote : The client must be authenticated via
StorageSharedKeyCredentialSee
DataLakeServiceSasSignatureValuesfor more information on how to construct a service SAS.- Parameters:
dataLakeServiceSasSignatureValues-DataLakeServiceSasSignatureValuesstringToSignHandler- 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
Stringrepresenting the SAS query parameters.
-