获取指定目录文件列表
功能介绍
在MRS集群中获取指定目录文件列表。
URI
- URI格式
    
GET /v2/{project_id}/clusters/{cluster_id}/files?path={directory}&offset={offset}&limit={limit}&sort_key={sort_key}&order={order}
 - 参数说明 
    
表1 URI参数说明 名称
是否必选
说明
project_id
是
项目编号。获取方法,请参见获取项目ID。
cluster_id
是
集群ID。获取方法,请参见获取集群ID。
path
是
文件目录,比如访问“/tmp/test”目录列表,此处必须是目录,整体URI为
/v2/{project_id}/clusters/{cluster_id}/files?path=%2Ftmp%2Ftest
单层目录要遵循以下规则:
- 不能为空
 - 不能以"."开头或结尾
 - 不能包括下列符号 : /:*?"<>|\;&,'`!{}[]$%+
 - 不能超过255个字节
 
offset
否
分页参数,表示从该偏移量开始查询文件列表,默认值为0。
limit
否
分页参数,列表当前分页的数量限制,默认为100,最大1000。
sort_key
否
列表排序按该属性排序,允许的属性有:
- path_suffix:文件或目录名称
 - length:文件大小
 - modification_time:修改时间
 
默认值为“path_suffix“按照文件或目录名称排序。
order
否
列表排序方式:
- desc:降序
 - asc:升序
 
默认值为“desc”降序排列。
 
请求消息
请求参数
无。
响应参数
| 
        参数名  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|
| 
        total_count  | 
      
        Integer  | 
      
        文件总数,与分页无关。  | 
     
| 
        files  | 
      
        Array of FileStatus  | 
      
        文件列表,请参见表3。  | 
     
| 
        参数名  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|
| 
        path_suffix  | 
      
        String  | 
      
        文件在当前目录下的后缀,如获取“/tmp”目录,下面的“/tmp/test”文件,此处path_suffix内容为“test”。  | 
     
| 
        owner  | 
      
        String  | 
      
        文件拥有者。  | 
     
| 
        group  | 
      
        String  | 
      
        文件属组。  | 
     
| 
        permission  | 
      
        String  | 
      
        权限信息。  | 
     
| 
        replication  | 
      
        Integer  | 
      
        副本数。  | 
     
| 
        block_size  | 
      
        Integer  | 
      
        块大小。  | 
     
| 
        length  | 
      
        Integer  | 
      
        文件长度。  | 
     
| 
        type  | 
      
        String  | 
      
        文件类型: 
  | 
     
| 
        children_num  | 
      
        Integer  | 
      
        该目录下的文件条目数。  | 
     
| 
        access_time  | 
      
        Long  | 
      
        文件访问时间。  | 
     
| 
        modification_time  | 
      
        Long  | 
      
        文件修改时间。  | 
     
示例
- 请求示例
 - 响应示例
    
- 成功示例
      
{ "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" } ] } 
 - 成功示例
      
 
状态码
状态码请参见状态码。