Help Center/ CodeArts Repo/ API Reference/ APIs/ Repository/ Obtaining Files in a Branch Directory
Updated on 2025-01-14 GMT+08:00

Obtaining Files in a Branch Directory

Function

This API is used to obtain files in a branch directory.

URI

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_uuid

Yes

String

Explanation:

Repository UUID returned by the CreateRepository API.

Constraints:

Mandatory

Range:

32 digits and letters.

Default value:

None

branch_name

Yes

String

Explanation:

Name of the target branch to be queried.

Constraints:

Mandatory

Range:

Minimum length: 1

Maximum length: 200

Default value:

None

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

path

No

String

Explanation:

Branch path to be queried. For example, src/main/java.

Constraints:

None

Range:

None

Default value:

None

offset

No

Integer

Explanation:

Page index.

Constraints:

None

Range:

Minimum value: 1

Maximum value: 2,147,483,647

Default value:

1

limit

No

Integer

Explanation:

Number of records on each page.

Constraints:

None

Range:

Minimum value: 1

Maximum value: 100

Default value:

100

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation:

User token. It can be obtained by calling the corresponding IAM API. The value of X-Subject-Token in the response header is the user token.

Constraints:

Mandatory

Range:

1–100,000 characters.

Default value:

None

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error code.

result

LogsTreeList object

Explanation:

Response result.

status

String

Explanation:

Response status of the API.

Range:

  • success: The API call is successful.
  • failed: The API call failed.
Table 5 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

Max. 100 characters in the error code format.

message

String

Explanation:

Error message.

Range:

None

Table 6 LogsTreeList

Parameter

Type

Description

trees

Array of LogsTree objects

Explanation:

File log tree.

total

Integer

Explanation:

Total number of records.

Table 7 LogsTree

Parameter

Type

Description

blob_id

String

Explanation:

Storage block ID.

commit

Commit object

Explanation:

Commit message.

file_name

String

Explanation:

File name.

file_path

String

Explanation:

File path.

md5

String

Explanation:

MD5.

type

String

Explanation:

Storage type.

Table 8 Commit

Parameter

Type

Description

author_email

String

Explanation:

Author's email address.

author_name

String

Explanation:

Author.

authored_date

String

Explanation:

Author's submission time.

committed_date

String

Explanation:

Commit time.

committer_email

String

Explanation:

Committer's email address.

committer_name

String

Explanation:

Committer.

format

Object

Explanation:

File change details. The format is specified in the stat_format parameter.

id

String

Explanation:

SHA ID of a commit.

message

String

Explanation:

Commit message.

parent_ids

Array of strings

Explanation:

Parent commit ID.

Example Requests

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

Example Responses

Status code: 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"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.