Obtaining the List of Files from a Specified Directory
Function
This API is used to obtain the list of files from a specified directory in an MRS cluster.
URI
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Explanation Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Constraints N/A Value range The value must consist of 1 to 64 characters. Only letters and digits are allowed. Default value N/A |
cluster_id |
Yes |
String |
Explanation Cluster ID. If this parameter is specified, the latest metadata of the cluster that has been patched will be obtained. For details about how to obtain the cluster ID, see Obtaining a Cluster ID. Constraints N/A Value range The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-). Default value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
path |
Yes |
String |
Explanation File category. For example, to access the /tmp/test directory, the value must be a directory. The URI is /v2/{project_id}/clusters/{cluster_id}/files?path=%2Ftmp %2Ftest. Constraints N/A Value range A single-level directory must comply with the following rules:
Default value N/A |
offset |
No |
String |
Explanation Pagination parameter. The file list is queried from the offset. Constraints N/A Value range N/A Default value 1 |
limit |
No |
String |
Explanation Maximum number of records displayed on a page. Constraints N/A Value range ≤1000 Default value 100 |
sort_key |
No |
String |
Explanation Attribute used for sorting the list. Constraints N/A Value range
Default value path_suffix |
order |
No |
String |
Explanation List sorting method. Constraints N/A Value range
Default value desc |
Request Parameters
None
Response Parameters
Parameter |
Type |
Description |
---|---|---|
total_count |
Integer |
Explanation The total number of files, which is irrelevant to pagination. Value range N/A |
files |
Array of FileStatusV2 objects |
Explanation File list. For details, see Table 4. |
Parameter |
Type |
Description |
---|---|---|
path_suffix |
String |
Explanation The file name extension in the current directory. For example, if you obtain the /tmp/test file in the /tmp directory, the value of path_suffix is test. Value range N/A |
owner |
String |
Explanation File owner. Value range N/A |
group |
String |
Explanation File owner group. Value range N/A |
permission |
String |
Explanation Permission information. Value range N/A |
replication |
Integer |
Explanation Number of replicas. Value range N/A |
block_size |
Integer |
Explanation Block size. Value range N/A |
length |
Integer |
Explanation File length. Value range N/A |
type |
String |
Explanation File type Value range
|
children_num |
Integer |
Explanation Number of files in the directory. Value range N/A |
access_time |
Long |
Explanation File access time. Value range N/A |
modification_time |
Long |
Explanation File modification time Value range N/A |
Example Request
Obtain the list of files from a specified directory.
GET /v2/{project_id}/clusters/{cluster_id}/files?path={directory}&offset={offset}&limit={limit}&sort_key={sort_key}&order={order}
Example Response
Status code: 200
{ "total_count": 2, "files": [ { "access_time": 0, "block_size": 0, "children_num": 0, "group": "hadoop", "length": 0, "modification_time": 1587179516623, "owner": "hdfs", "path_suffix": "app-logs", "permission": "777", "replication": 0, "type": "DIRECTORY" }, { "access_time": 1587267212761, "block_size": 134217728, "children_num": 0, "group": "hadoop", "length": 23666188, "modification_time": 1587222156003, "owner": "root", "path_suffix": "data-m-00000", "permission": "644", "replication": 3, "type": "FILE" } ] }
Status Codes
See Status Codes.
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot