Filesharing Service List FIles Task¤
task api name:
list_files
The list_files task lists the contents of a directory at the specified URL path in a non-recursive manner. This task returns only the immediate files and subdirectories within the given path, without descending into nested directories. It's useful for browsing the structure of your file sharing repository one level at a time.
Using it from Python¤
from norfab.core.nfapi import NorFab
with NorFab(inventory="./inventory.yaml") as nf:
client = nf.make_client()
reply = client.run_job(
service="filesharing",
task="list_files",
workers="any",
kwargs={"url": "nf://"},
)
print(reply)
Using it from nfcli¤
NORFAB CLI exposes File Sharing under the file command group.
nf#man tree file.list
root
└── file: File sharing service
└── list: List files
└── url: Directory to list content for, default 'nf://'
nf#
API Reference¤
List files in a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL path starting with 'nf://' to list files from |
required |
Returns:
| Type | Description |
|---|---|
Result
|
Result containing list of files or error message |
Source code in norfab\workers\filesharing_worker\filesharing_worker.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |