文档首页/ 代码托管 CodeArts Repo/ API参考/ API/ Repository/ 获取分支目录下的文件
更新时间:2024-09-02 GMT+08:00
分享

获取分支目录下的文件

功能介绍

通过调用此接口,您可以获取某分支目录下的文件。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

GET /v1/repositories/{repository_uuid}/branch/{branch_name}/sub-files

表1 路径参数

参数

是否必选

参数类型

描述

repository_uuid

String

参数解释:

仓库UUID(由CreateRepository接口返回)。

约束限制:

必传。

取值范围:

由数字和字母组成,且长度为32个字符。

默认取值:

不涉及

branch_name

String

参数解释:

用户想要查询的分支名称。

约束限制:

必传。

取值范围:

最小长度:1

最大长度:200

默认取值:

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

path

String

参数解释:

用户想要查询的分支路径。示例:“src/main/java”

约束限制:

无。

取值范围:

不涉及。

默认取值:

无。

offset

Integer

参数解释:

分页索引。

约束限制:

无。

取值范围:

最小值:1

最大值:2147483647

默认取值:

1

limit

Integer

参数解释:

每页条目数。

约束限制:

无。

取值范围:

最小值:1

最大值:100

默认取值:

100

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

error

Error object

参数解释:

响应错误码。

result

LogsTreeList object

参数解释:

响应结果。

status

String

参数解释:

调用此接口的响应状态。

取值范围:

  • success,表示接口调用成功。
  • error,表示接口调用失败。
表5 Error

参数

参数类型

描述

code

String

参数解释:

错误码。

取值范围:

符合错误码格式字符串,长度[0,100]。

message

String

参数解释:

错误信息。

取值范围:

不涉及。

表6 LogsTreeList

参数

参数类型

描述

trees

Array of LogsTree objects

参数解释:

文件日志树。

total

Integer

参数解释:

记录总数。

表7 LogsTree

参数

参数类型

描述

blob_id

String

参数解释:

存储块ID。

commit

Commit object

参数解释:

提交信息。

file_name

String

参数解释:

文件名称。

file_path

String

参数解释:

文件路径。

md5

String

参数解释:

MD5。

type

String

参数解释:

存储类型。

表8 Commit

参数

参数类型

描述

author_email

String

参数解释:

作者邮箱。

author_name

String

参数解释:

作者。

authored_date

String

参数解释:

作者提交时间。

committed_date

String

参数解释:

提交时间。

committer_email

String

参数解释:

提交作者邮箱。

committer_name

String

参数解释:

提交作者。

format

Object

参数解释:

文件变更的详情信息,其格式由请求查询参数 stat_format 决定。

id

String

参数解释:

提交对应的SHA ID。

message

String

参数解释:

提交的信息。

parent_ids

Array of strings

参数解释:

父提交ID。

请求示例

GET https://{endpoint}/v1/repositories/{repository_uuid}/branch/{branch_name}/sub-files

响应示例

状态码: 200

OK

{
  "result" : {
    "trees" : [ {
      "blob_id" : "ef69ef5dc0c53022fe52a4d02de15f73d96e055c",
      "file_name" : "csharpDemo.png",
      "file_path" : "images/csharpDemo.png",
      "md5" : "8830d25fe6b4e2cd14d75ddb5cae73a7",
      "type" : "blob",
      "commit" : {
        "id" : "1cfd6d81fff948828c7f59bda74c0ef80e53def0",
        "message" : "init",
        "parent_ids" : [ ],
        "author_name" : "repo",
        "author_email" : "repo@test.com",
        "committed_date" : "2019-11-13 11:29:26",
        "committer_name" : "repo",
        "committer_email" : "repo@test.com"
      }
    } ],
    "total" : 5
  },
  "status" : "success"
}

状态码

状态码

描述

200

OK

错误码

请参见错误码

相关文档