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.
Constraints
None
Debugging
You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.
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 Default value N/A |
files |
Array of FileStatusV2 objects |
Explanation File list. For details, see Table 4. Constraints N/A Value range N/A Default value N/A |
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. Constraints N/A Value range N/A Default value N/A |
owner |
String |
Explanation File owner. Constraints N/A Value range N/A Default value N/A |
group |
String |
Explanation File owner group. Constraints N/A Value range N/A Default value N/A |
permission |
String |
Explanation Permission information. Constraints N/A Value range N/A Default value N/A |
replication |
Integer |
Explanation Number of replicas. Constraints N/A Value range N/A Default value N/A |
block_size |
Integer |
Explanation Block size. Constraints N/A Value range N/A Default value N/A |
length |
Integer |
Explanation File length. Constraints N/A Value range N/A Default value N/A |
type |
String |
Explanation File type Constraints N/A Value range
Default value N/A |
children_num |
Integer |
Explanation Number of files in the directory. Constraints N/A Value range N/A Default value N/A |
access_time |
Long |
Explanation File access time. Constraints N/A Value range N/A Default value N/A |
modification_time |
Long |
Explanation File modification time Constraints N/A Value range N/A Default value 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