Class DataLakeDirectoryClient
This client is instantiated through DataLakePathClientBuilder
or retrieved via
getDirectoryClient
.
Please refer to the Azure Docs for more information.
-
Method Summary
Modifier and TypeMethodDescriptioncreateFile
(String fileName) Creates a new file within a directory.createFile
(String fileName, boolean overwrite) Creates a new file within a directory.createFileIfNotExists
(String fileName) Creates a new file within a directory if it does not exist.com.azure.core.http.rest.Response
<DataLakeFileClient> createFileIfNotExistsWithResponse
(String fileName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new file within a directory if it does not exist.com.azure.core.http.rest.Response
<DataLakeFileClient> createFileWithResponse
(String fileName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new file within a directory.com.azure.core.http.rest.Response
<DataLakeFileClient> createFileWithResponse
(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Creates a new file within a directory.createSubdirectory
(String subdirectoryName) Creates a new sub-directory within a directory.createSubdirectory
(String subdirectoryName, boolean overwrite) Creates a new sub-directory within a directory.createSubdirectoryIfNotExists
(String subdirectoryName) Creates a new sub-directory if it does not exist within a directory.com.azure.core.http.rest.Response
<DataLakeDirectoryClient> createSubdirectoryIfNotExistsWithResponse
(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new sub-directory within a directory if it does not exist.com.azure.core.http.rest.Response
<DataLakeDirectoryClient> createSubdirectoryWithResponse
(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new sub-directory within a directory.com.azure.core.http.rest.Response
<DataLakeDirectoryClient> createSubdirectoryWithResponse
(String subdirectoryName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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.com.azure.core.http.rest.Response
<Boolean> deleteFileIfExistsWithResponse
(String fileName, DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.Context context) Deletes the specified file in the directory if it exists.com.azure.core.http.rest.Response
<Void> deleteFileWithResponse
(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Deletes the specified file in the directory.boolean
Deletes a directory if it exists.com.azure.core.http.rest.Response
<Boolean> deleteIfExistsWithResponse
(DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.Context context) Deletes a directory if it exists.void
Recursively deletes a directory and all contents within the directory.com.azure.core.http.rest.Response
<Void> deleteRecursivelyWithResponse
(DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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.com.azure.core.http.rest.Response
<Boolean> deleteSubdirectoryIfExistsWithResponse
(String subdirectoryName, DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.Context context) Deletes the specified subdirectory in the directory if it exists.com.azure.core.http.rest.Response
<Void> deleteSubdirectoryWithResponse
(String subdirectoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Deletes the specified sub-directory in the directory.com.azure.core.http.rest.Response
<Void> deleteWithResponse
(boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Deletes a directory.getCustomerProvidedKeyClient
(CustomerProvidedKey customerProvidedKey) Creates a newDataLakeDirectoryClient
with the specifiedcustomerProvidedKey
.Gets the name of this directory, not including its full path.Gets the path of this directory, not including the name of the resource itself.Gets the URL of the directory represented by this client on the Data Lake service.getFileClient
(String fileName) Initializes a new DataLakeFileClient object by concatenating fileName to the end of DataLakeDirectoryClient's URL.getSubdirectoryClient
(String subdirectoryName) Initializes a new DataLakeDirectoryClient object by concatenating directoryName to the end of DataLakeDirectoryClient's URL.com.azure.core.http.rest.PagedIterable
<PathItem> Returns a lazy loaded list of files/directories in this directory.com.azure.core.http.rest.PagedIterable
<PathItem> listPaths
(boolean recursive, boolean userPrincipleNameReturned, Integer maxResults, Duration timeout) Returns a lazy loaded list of files/directories in this directory.Moves the directory to another location within the file system.com.azure.core.http.rest.Response
<DataLakeDirectoryClient> renameWithResponse
(String destinationFileSystem, String destinationPath, DataLakeRequestConditions sourceRequestConditions, DataLakeRequestConditions destinationRequestConditions, Duration timeout, com.azure.core.util.Context context) Moves the directory to another location within the file system.Methods inherited from class com.azure.storage.file.datalake.DataLakePathClient
create, create, createIfNotExists, createIfNotExistsWithResponse, createWithResponse, createWithResponse, exists, existsWithResponse, generateSas, generateSas, generateSas, generateUserDelegationSas, generateUserDelegationSas, generateUserDelegationSas, getAccessControl, getAccessControlWithResponse, getAccountName, getCustomerProvidedKey, getFileSystemName, getHttpPipeline, getProperties, getProperties, getPropertiesWithResponse, getServiceVersion, removeAccessControlRecursive, removeAccessControlRecursiveWithResponse, setAccessControlList, setAccessControlListWithResponse, setAccessControlRecursive, setAccessControlRecursiveWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setMetadata, setMetadataWithResponse, setPermissions, setPermissionsWithResponse, updateAccessControlRecursive, updateAccessControlRecursiveWithResponse
-
Method Details
-
getDirectoryUrl
Gets the URL of the directory represented by this client on the Data Lake service.- Returns:
- the URL.
-
getDirectoryPath
Gets the path of this directory, not including the name of the resource itself.- Returns:
- The path of the directory.
-
getDirectoryName
Gets the name of this directory, not including its full path.- Returns:
- The name of the directory.
-
getCustomerProvidedKeyClient
public DataLakeDirectoryClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) Creates a newDataLakeDirectoryClient
with the specifiedcustomerProvidedKey
.- Overrides:
getCustomerProvidedKeyClient
in classDataLakePathClient
- Parameters:
customerProvidedKey
- theCustomerProvidedKey
for the directory, passnull
to use no customer provided key.- Returns:
- a
DataLakeDirectoryClient
with the specifiedcustomerProvidedKey
.
-
delete
public void delete()Deletes a directory.Code Samples
client.delete(); System.out.println("Delete request completed");
For more information see the Azure Docs
-
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 com.azure.core.http.rest.Response<Void> deleteRecursivelyWithResponse(DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A reactive response signalling completion.
-
deleteWithResponse
public com.azure.core.http.rest.Response<Void> deleteWithResponse(boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A reactive response signalling completion.
-
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:
deleteIfExists
in classDataLakePathClient
- Returns:
true
if directory is successfully deleted,false
if directory does not exist.
-
deleteIfExistsWithResponse
public com.azure.core.http.rest.Response<Boolean> deleteIfExistsWithResponse(DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.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:
deleteIfExistsWithResponse
in classDataLakePathClient
- Parameters:
options
-DataLakePathDeleteOptions
timeout
- An optional timeout value beyond which aRuntimeException
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
's status code is 200, the directory was successfully deleted. If status code is 404, the directory does not exist.
-
getFileClient
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
- AString
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.
-
createFile
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
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.
-
createFileWithResponse
public com.azure.core.http.rest.Response<DataLakeFileClient> createFileWithResponse(String fileName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theDataLakeFileClient
used to interact with the file created.
-
createFileWithResponse
public com.azure.core.http.rest.Response<DataLakeFileClient> createFileWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.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.options
-DataLakePathCreateOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theDataLakeFileClient
used to interact with the file created.
-
createFileIfNotExists
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 com.azure.core.http.rest.Response<DataLakeFileClient> createFileIfNotExistsWithResponse(String fileName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theDataLakeFileAsyncClient
used 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 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.
-
deleteFileWithResponse
public com.azure.core.http.rest.Response<Void> deleteFileWithResponse(String fileName, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
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
-
deleteFileIfExists
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 com.azure.core.http.rest.Response<Boolean> deleteFileIfExistsWithResponse(String fileName, DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.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.options
-DataLakePathDeleteOptions
timeout
- An optional timeout value beyond which aRuntimeException
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
's status code is 200, the specified file was successfully deleted. If status code is 404, the specified file does not exist.
-
getSubdirectoryClient
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
- AString
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
-
createSubdirectory
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
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.
-
createSubdirectoryWithResponse
public com.azure.core.http.rest.Response<DataLakeDirectoryClient> createSubdirectoryWithResponse(String subdirectoryName, String permissions, String umask, PathHttpHeaders headers, Map<String, String> metadata, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains aDataLakeDirectoryClient
used to interact with the sub-directory created.
-
createSubdirectoryWithResponse
public com.azure.core.http.rest.Response<DataLakeDirectoryClient> createSubdirectoryWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.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.options
-DataLakePathCreateOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains aDataLakeDirectoryClient
used to interact with the sub-directory created.
-
createSubdirectoryIfNotExists
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 com.azure.core.http.rest.Response<DataLakeDirectoryClient> createSubdirectoryIfNotExistsWithResponse(String subdirectoryName, DataLakePathCreateOptions options, Duration timeout, com.azure.core.util.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.options
-DataLakePathCreateOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theDataLakeDirectoryClient
used to interact with the subdirectory created. IfResponse
'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.
-
deleteSubdirectory
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.
-
deleteSubdirectoryWithResponse
public com.azure.core.http.rest.Response<Void> deleteSubdirectoryWithResponse(String subdirectoryName, boolean recursive, DataLakeRequestConditions requestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
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
-
deleteSubdirectoryIfExists
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 com.azure.core.http.rest.Response<Boolean> deleteSubdirectoryIfExistsWithResponse(String subdirectoryName, DataLakePathDeleteOptions options, Duration timeout, com.azure.core.util.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.options
-DataLakePathDeleteOptions
timeout
- An optional timeout value beyond which aRuntimeException
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
's status code is 200, the specified subdirectory was successfully deleted. If status code is 404, the specified subdirectory does not exist.
-
rename
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 com.azure.core.http.rest.Response<DataLakeDirectoryClient> renameWithResponse(String destinationFileSystem, String destinationPath, DataLakeRequestConditions sourceRequestConditions, DataLakeRequestConditions destinationRequestConditions, Duration timeout, com.azure.core.util.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 aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
that contains aDataLakeDirectoryClient
used to interact with the directory created.
-
listPaths
Returns a lazy loaded list of files/directories in this directory. The returnedPagedIterable
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 com.azure.core.http.rest.PagedIterable<PathItem> listPaths(boolean recursive, boolean userPrincipleNameReturned, Integer maxResults, Duration timeout) Returns a lazy loaded list of files/directories in this directory. The returnedPagedIterable
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 asContinuablePagedIterable.iterableByPage(int)
will be preferred over this value.timeout
- An optional timeout value beyond which aRuntimeException
will be raised.- Returns:
- The list of files/directories.
-