Class DataLakeDirectoryAsyncClient


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

    Please refer to the Azure Docs for more information.

    • Method Detail

      • getDirectoryUrl

        public String getDirectoryUrl()
        Gets the URL of the directory represented by this client on the Data Lake service.
        Returns:
        the URL.
      • getDirectoryPath

        public String getDirectoryPath()
        Gets the path of this directory, not including the name of the resource itself.
        Returns:
        The path of the directory.
      • getDirectoryName

        public String getDirectoryName()
        Gets the name of this directory, not including its full path.
        Returns:
        The name of the directory.
      • delete

        public Mono<Void> delete()
        Deletes a directory.

        Code Samples

         client.delete().subscribe(response ->
             System.out.println("Delete request completed"));
         

        For more information see the Azure Docs

        Returns:
        A reactive response signalling completion.
      • deleteWithResponse

        public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse​(boolean recursive,
                                                                                DataLakeRequestConditions requestConditions)
        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:
        recursive - Whether to delete all paths beneath the directory.
        requestConditions - DataLakeRequestConditions
        Returns:
        A reactive response signalling completion.
      • deleteIfExists

        public Mono<Boolean> deleteIfExists()
        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:
        deleteIfExists in class DataLakePathAsyncClient
        Returns:
        a reactive response signaling completion. true indicates that the directory was successfully deleted, true indicates that the directory did not exist.
      • deleteIfExistsWithResponse

        public Mono<com.azure.core.http.rest.Response<Void>> deleteIfExistsWithResponse​(DataLakePathDeleteOptions options)
        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:
        deleteIfExistsWithResponse in class DataLakePathAsyncClient
        Parameters:
        options - DataLakePathDeleteOptions
        Returns:
        A reactive response signaling completion. If Response's status code is 200, the directory was successfully deleted. If status code is 404, the directory does not exist.
      • 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:
        fileName - A String representing the name of the file.
        Returns:
        A new DataLakeFileAsyncClient object which references the file with the specified name in this file system.
      • createFile

        public Mono<DataLakeFileAsyncClient> createFile​(String fileName)
        Creates a new file within a directory. By default, this method will not overwrite an existing file. For more information, see the Azure Docs.

        Code Samples

         DataLakeFileAsyncClient fileClient = client.createFile(fileName).block();
         
        Parameters:
        fileName - Name of the file to create.
        Returns:
        A Mono containing a DataLakeFileAsyncClient used to interact with the file created.
      • createFile

        public Mono<DataLakeFileAsyncClient> createFile​(String fileName,
                                                        boolean overwrite)
        Creates a new file within a directory. For more information, see the Azure Docs.

        Code Samples

         boolean overwrite = false; /* Default value. */
         DataLakeFileAsyncClient fClient = client.createFile(fileName, overwrite).block();
         
        Parameters:
        fileName - Name of the file to create.
        overwrite - Whether to overwrite, should the file exist.
        Returns:
        A Mono containing a DataLakeFileAsyncClient used 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 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:
        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
        Returns:
        A Mono containing a Response whose value contains a DataLakeFileAsyncClient used to interact with the file created.
      • createFileIfNotExists

        public Mono<DataLakeFileAsyncClient> createFileIfNotExists​(String fileName)
        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:
        fileName - Name of the file to create.
        Returns:
        A Mono containing a DataLakeFileAsyncClient used 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 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().setPathHttpHeaders(headers)
             .setPermissions(permissions).setUmask(umask).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.
        options - DataLakePathCreateOptions metadata key or value, it must be removed or encoded.
        Returns:
        A Mono containing a Response whose value contains a DataLakeFileAsyncClient used to interact with the file created. If Response'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

        public Mono<Void> deleteFile​(String fileName)
        Deletes the specified file in the file system. If the file doesn't exist the operation fails. For more information see the Azure Docs.

        Code Samples

         client.deleteFile(fileName).subscribe(response ->
             System.out.println("Delete request completed"));
         
        Parameters:
        fileName - Name of the file to delete.
        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 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:
        fileName - Name of the file to delete.
        requestConditions - DataLakeRequestConditions
        Returns:
        A Mono containing status code and HTTP headers
      • deleteFileIfExists

        public Mono<Boolean> deleteFileIfExists​(String fileName)
        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.
        Returns:
        a reactive response signaling completion. true indicates that the specified file was successfully deleted, false indicates that the specified file did not exist.
      • deleteFileIfExistsWithResponse

        public Mono<com.azure.core.http.rest.Response<Void>> deleteFileIfExistsWithResponse​(String fileName,
                                                                                            DataLakePathDeleteOptions options)
        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:
        fileName - Name of the file to delete.
        options - DataLakePathDeleteOptions
        Returns:
        A reactive response signaling completion. If Response's status code is 200, the specified file was successfully deleted. If status code is 404, the specified file does not exist.
      • 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:
        subdirectoryName - A String representing the name of the sub-directory.
        Returns:
        A new DataLakeDirectoryAsyncClient object which references the directory with the specified name in this file system.
      • createSubdirectory

        public Mono<DataLakeDirectoryAsyncClient> createSubdirectory​(String subdirectoryName)
        Creates a new sub-directory within a directory. By default, this method will not overwrite an existing sub-directory. For more information, see the Azure Docs.

        Code Samples

         DataLakeDirectoryAsyncClient directoryClient = client.createSubdirectory(directoryName).block();
         
        Parameters:
        subdirectoryName - Name of the sub-directory to create.
        Returns:
        A Mono containing a DataLakeDirectoryAsyncClient used to interact with the directory created.
      • createSubdirectory

        public Mono<DataLakeDirectoryAsyncClient> createSubdirectory​(String subdirectoryName,
                                                                     boolean overwrite)
        Creates a new sub-directory within a directory. For more information, see the Azure Docs.

        Code Samples

         boolean overwrite = false; /* Default value. */
         DataLakeDirectoryAsyncClient dClient = client.createSubdirectory(directoryName, overwrite).block();
         
        Parameters:
        subdirectoryName - Name of the sub-directory to create.
        overwrite - Whether to overwrite, should the subdirectory exist.
        Returns:
        A Mono containing a DataLakeDirectoryAsyncClient used to interact with the directory created.
      • createSubdirectoryWithResponse

        public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createSubdirectoryWithResponse​(String subdirectoryName,
                                                                                                                    String permissions,
                                                                                                                    String umask,
                                                                                                                    PathHttpHeaders headers,
                                                                                                                    Map<String,​String> metadata,
                                                                                                                    DataLakeRequestConditions requestConditions)
        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:
        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
        Returns:
        A Mono containing a Response whose value contains a DataLakeDirectoryAsyncClient used to interact with the sub-directory created.
      • createSubdirectoryIfNotExists

        public Mono<DataLakeDirectoryAsyncClient> createSubdirectoryIfNotExists​(String subdirectoryName)
        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:
        subdirectoryName - Name of the sub-directory to create.
        Returns:
        A Mono containing a DataLakeDirectoryAsyncClient used to interact with the subdirectory created.
      • createSubdirectoryIfNotExistsWithResponse

        public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> createSubdirectoryIfNotExistsWithResponse​(String subdirectoryName,
                                                                                                                               DataLakePathCreateOptions options)
        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().setPathHttpHeaders(headers)
             .setPermissions(permissions).setUmask(umask).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:
        subdirectoryName - Name of the subdirectory to create.
        options - DataLakePathCreateOptions
        Returns:
        A Mono containing a Response whose value contains a DataLakeDirectoryAsyncClient used to interact with the subdirectory created. If Response'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

        public Mono<Void> deleteSubdirectory​(String subdirectoryName)
        Deletes the specified sub-directory in the directory. If the sub-directory doesn't exist or is not empty the operation fails. For more information see the Azure Docs.

        Code Samples

         client.deleteSubdirectory(directoryName).subscribe(response ->
             System.out.println("Delete request completed"));
         
        Parameters:
        subdirectoryName - Name of the sub-directory to delete.
        Returns:
        A reactive response signalling completion.
      • deleteSubdirectoryWithResponse

        public Mono<com.azure.core.http.rest.Response<Void>> deleteSubdirectoryWithResponse​(String directoryName,
                                                                                            boolean recursive,
                                                                                            DataLakeRequestConditions requestConditions)
        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:
        directoryName - Name of the sub-directory to delete.
        recursive - Whether to delete all paths beneath the sub-directory.
        requestConditions - DataLakeRequestConditions
        Returns:
        A Mono containing status code and HTTP headers
      • deleteSubdirectoryIfExists

        public Mono<Boolean> deleteSubdirectoryIfExists​(String subdirectoryName)
        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:
        subdirectoryName - Name of the subdirectory to delete.
        Returns:
        A reactive response signaling completion. true indicates that the subdirectory was deleted. false indicates the specified subdirectory does not exist.
      • deleteSubdirectoryIfExistsWithResponse

        public Mono<com.azure.core.http.rest.Response<Void>> deleteSubdirectoryIfExistsWithResponse​(String directoryName,
                                                                                                    DataLakePathDeleteOptions options)
        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:
        directoryName - Name of the subdirectory to delete.
        options - DataLakePathDeleteOptions
        Returns:
        A reactive response signaling completion. 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

        public Mono<DataLakeDirectoryAsyncClient> rename​(String destinationFileSystem,
                                                         String destinationPath)
        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:
        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 Mono containing a DataLakeDirectoryAsyncClient used to interact with the new directory created.
      • renameWithResponse

        public Mono<com.azure.core.http.rest.Response<DataLakeDirectoryAsyncClient>> renameWithResponse​(String destinationFileSystem,
                                                                                                        String destinationPath,
                                                                                                        DataLakeRequestConditions sourceRequestConditions,
                                                                                                        DataLakeRequestConditions destinationRequestConditions)
        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:
        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.
        Returns:
        A Mono containing a Response whose value contains a DataLakeDirectoryAsyncClient used to interact with the directory created.
      • listPaths

        public com.azure.core.http.rest.PagedFlux<PathItem> listPaths()
        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:
        A reactive response emitting the list of files/directories.
      • listPaths

        public com.azure.core.http.rest.PagedFlux<PathItem> listPaths​(boolean recursive,
                                                                      boolean userPrincipleNameReturned,
                                                                      Integer maxResults)
        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:
        recursive - Specifies if the call should recursively include all paths.
        userPrincipleNameReturned - If "true", the user identity values returned by 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.
        Returns:
        A reactive response emitting the list of files/directories.