更新时间:2026-07-13 GMT+08:00
分享

查询文件/项目列表 - ListFiles

功能介绍

查询文件/项目列表

调用方法

请参见如何调用API

授权信息

账号根用户具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备如下身份策略权限,更多的权限说明请参见权限和授权项

授权项

访问级别

资源类型(*为必须)

条件键

别名

依赖的授权项

codeartsartifact:releaseRepo:read

Read

-

-

-

-

URI

POST /devreposerver/v5/files/list

请求参数

表1 请求Header参数

参数

是否必选

参数类型

描述

x-auth-token

String

参数解释:

用户token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值),调用详情请参考章节。

约束限制:

不涉及。

取值范围:

字符串长度为1-100000。

默认取值:

不涉及。

表2 请求Body参数

参数

是否必选

参数类型

描述

page_no

Integer

参数解释:

分页查询的页数。

约束限制:

(page_no - 1) * page_size < 2147483647。

取值范围:

1-2147483647。

默认取值:

1。

page_size

Integer

参数解释:

每页大小。

约束限制:

(page_no - 1) * page_size < 2147483647。

取值范围:

1-100。

默认取值:

10。

parent_id

String

参数解释:

父级目录id。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

project_id

String

参数解释:

项目id,可以从调用API处获取,也可以从控制台获取。获取方式请参考获取项目id

约束限制:

不涉及。

取值范围:

只能使用小写英文字符及数字,字符串长度为32位。

默认取值:

不涉及。

search_name

String

参数解释:

搜索关键字。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

search_type

String

参数解释:

搜索类型。

约束限制:

不涉及。

取值范围:

  • project: 搜索项目。

  • file: 搜索文件。

  • folder: 搜索文件夹。

默认取值:

不涉及。

extension

String

参数解释:

后缀名。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

order_by

String

参数解释:

排序字段。

约束限制:

不涉及。

取值范围:

  • modifiedUserName:按修改人排序。

  • modifiedTime:按修改时间排序。

  • name:按名称排序。

  • category:按发布包状态排序。

默认取值:

不涉及。

sort

String

参数解释:

排序方式。

约束限制:

order_by参数有值时,该参数必填。

取值范围:

  • asc: 升序。

  • desc: 降序。

默认取值:

不涉及。

status

String

参数解释:

文件状态。

约束限制:

不涉及。

取值范围:

  • active: 正常。

  • trash: 已回收。

默认取值:

不涉及。

category

String

参数解释:

发布包状态。

查询类型为file或者folder时可以使用。

取值范围:

  • prod:已发布。

  • test:未测试。

  • testing:测试中。

  • tested:已测试。

  • xray:未杀毒。

  • xrayed:已杀毒。

  • sign:未签名。

  • signed:已签名

默认取值:

不涉及。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

status

String

参数解释:

请求成功或失败状态。

取值范围:

  • success:请求成功。

  • error:请求失败。

trace_id

String

参数解释:

请求id,当前请求的唯一标识。

取值范围:

数字及中划线(-)组成的字符串。

result

RepoFileDOV5Page object

参数解释:

文件列表。

取值范围:

不涉及。

表4 RepoFileDOV5Page

参数

参数类型

描述

total_records

Integer

参数解释:

总记录数。

取值范围:

不涉及。

total_pages

Integer

参数解释:

总页数。

取值范围:

不涉及。

data

Array of RepoFileDOV5 objects

参数解释:

文件列表。

取值范围:

不涉及。

表5 RepoFileDOV5

参数

参数类型

描述

category

String

参数解释

发布库版本的状态。

取值范围

  • test:未测试。

  • testing: 测试中。

  • tested: 已测试。

  • xray: 未杀毒。

  • xrayed: 已杀毒。

  • sign: 未签名。

  • signed: 已签名。

  • prod:已发布。

id

String

参数解释:

id。

取值范围:

不涉及。

file_id

String

参数解释:

文件id。

取值范围:

不涉及。

repo_name

String

参数解释:

仓库id。

取值范围:

不涉及。

project_id

String

参数解释:

项目id。

取值范围:

不涉及。

parent_id

String

参数解释:

父级目录ID。

取值范围:

不涉及。

name

String

参数解释:

文件名。

取值范围:

不涉及。

file_name

String

参数解释:

文件名。

取值范围:

不涉及。

type

String

参数解释:

文件类型, folder代表是目录,file代表文件。

取值范围:

不涉及。

extension

String

参数解释:

文件扩展名。

取值范围:

不涉及。

path

String

参数解释:

文件路径。

取值范围:

不涉及。

full_path

String

参数解释:

文件路径(含项目)。

取值范围:

不涉及。

size

Long

参数解释:

文件大小,单位为byte。

取值范围:

不涉及。

md5

String

参数解释:

md5校验和。

取值范围:

不涉及。

sha256

String

参数解释:

sha256校验和。

取值范围:

不涉及。

download_url

String

参数解释:

下载地址。

取值范围:

不涉及。

download_url_with_id

String

参数解释:

带有id的下载地址。

取值范围:

不涉及。

web_url

String

参数解释:

历史版本遗留字段,请忽略。

取值范围:

不涉及。

version_enable

Boolean

参数解释:

判断当前文件或文件夹父目录是否为版本路径,即仓库下第一层子目录。

取值范围:

  • true:父目录是版本路径。

  • false:父目录不是版本路径。

migrated_state

Integer

参数解释:

migrated_state。

取值范围:

该参数为内部数据改造参数,无业务含义,请忽略。

upload_id

String

参数解释:

该参数无返回值,请忽略。

取值范围:

不涉及。

请求示例

  • 查询项目列表

    https://artifact.example-1.com/devreposerver/v5/files/list
    
    {
      "project_id" : "",
      "search_name" : "",
      "search_type" : "project",
      "sort" : "",
      "order_by" : "",
      "parent_id" : "",
      "page_size" : 1,
      "page_no" : 1
    }
  • 查询指定项目的文件/文件夹列表

    https://artifact.example-1.com/devreposerver/v5/files/list
    
    {
      "project_id" : "bef3419620d743eca6a57881a0f006fd",
      "parent_id" : "79328e649313467f86e57be9e8aeadac",
      "folder_path" : "/folder1/folder2/targetFolder",
      "page_size" : 10,
      "page_no" : 1,
      "order_by" : "modifiedTime",
      "sort" : "asc"
    }

响应示例

状态码:200

OK

{
  "status" : "success",
  "trace_id" : "0d7af913dfb4462db4580fc486d91ce1",
  "result" : {
    "data" : [ {
      "region" : "xx-xxxxx-x",
      "id" : "",
      "name" : "testjk1",
      "type" : "project",
      "created_time" : "2025-07-04 16:17:17",
      "modified_time" : "2025-07-04 16:17:17",
      "created_user_id" : "09d2ca2ffd00d3c21ff8c00a4dd1e080",
      "created_user_name" : "devcloud_devcloud_y00226182_05",
      "created_user_nick_name" : "仓库小能手",
      "created_user_domain_name" : "devcloud_devcloud_y00226182_05",
      "modified_user_id" : "09d2ca2ffd00d3c21ff8c00a4dd1e080",
      "modified_user_name" : "devcloud_devcloud_y00226182_05",
      "modified_user_nick_name" : "仓库小能手",
      "modified_user_domain_name" : "devcloud_devcloud_y00226182_05",
      "project_id" : "8de56c5a10894ad3aaef9e6558f17ea3",
      "repo_name" : "xx-xxxxx-x_8de56c5a10894ad3aaef9e6558f17ea3_generic_0",
      "parent_id" : "0",
      "download_url_with_id" : "DevRepoServer/v1/files/download?file_id=null&type=archive",
      "web_url" : "releaseman/project/8de56c5a10894ad3aaef9e6558f17ea3/private/general?parentId=0",
      "version_enable" : false,
      "migrated_state" : 0,
      "repo_same_trash_file_name" : "trash_null_testjk1",
      "repo_file_path" : "nulltestjk1"
    } ],
    "total_records" : 1,
    "total_pages" : 1
  }
}

SDK代码示例

SDK代码示例如下。

Java

  • 查询项目列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.codeartsartifact.v2.region.CodeArtsArtifactRegion;
    import com.huaweicloud.sdk.codeartsartifact.v2.*;
    import com.huaweicloud.sdk.codeartsartifact.v2.model.*;
    
    
    public class ListFilesSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
    
            ICredential auth = new BasicCredentials()
                    .withAk(ak)
                    .withSk(sk);
    
            CodeArtsArtifactClient client = CodeArtsArtifactClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(CodeArtsArtifactRegion.valueOf("<YOUR REGION>"))
                    .build();
            ListFilesRequest request = new ListFilesRequest();
            RepoFileQueryDTOV5 body = new RepoFileQueryDTOV5();
            body.withPageSize(1);
            body.withSearchType("project");
            body.withSort("");
            body.withSearchName("");
            body.withPageNo(1);
            body.withOrderBy("");
            body.withParentId("");
            body.withProjectId("");
            request.withBody(body);
            try {
                ListFilesResponse response = client.listFiles(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 查询指定项目的文件/文件夹列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.codeartsartifact.v2.region.CodeArtsArtifactRegion;
    import com.huaweicloud.sdk.codeartsartifact.v2.*;
    import com.huaweicloud.sdk.codeartsartifact.v2.model.*;
    
    
    public class ListFilesSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
    
            ICredential auth = new BasicCredentials()
                    .withAk(ak)
                    .withSk(sk);
    
            CodeArtsArtifactClient client = CodeArtsArtifactClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(CodeArtsArtifactRegion.valueOf("<YOUR REGION>"))
                    .build();
            ListFilesRequest request = new ListFilesRequest();
            RepoFileQueryDTOV5 body = new RepoFileQueryDTOV5();
            body.withPageSize(10);
            body.withSort("asc");
            body.withPageNo(1);
            body.withOrderBy("modifiedTime");
            body.withParentId("79328e649313467f86e57be9e8aeadac");
            body.withProjectId("bef3419620d743eca6a57881a0f006fd");
            request.withBody(body);
            try {
                ListFilesResponse response = client.listFiles(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    

Python

  • 查询项目列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkcodeartsartifact.v2.region.codeartsartifact_region import CodeArtsArtifactRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkcodeartsartifact.v2 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
    
        credentials = BasicCredentials(ak, sk)
    
        client = CodeArtsArtifactClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(CodeArtsArtifactRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ListFilesRequest()
            request.body = RepoFileQueryDTOV5(
                page_size=1,
                search_type="project",
                sort="",
                search_name="",
                page_no=1,
                order_by="",
                parent_id="",
                project_id=""
            )
            response = client.list_files(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 查询指定项目的文件/文件夹列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkcodeartsartifact.v2.region.codeartsartifact_region import CodeArtsArtifactRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkcodeartsartifact.v2 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
    
        credentials = BasicCredentials(ak, sk)
    
        client = CodeArtsArtifactClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(CodeArtsArtifactRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ListFilesRequest()
            request.body = RepoFileQueryDTOV5(
                page_size=10,
                sort="asc",
                page_no=1,
                order_by="modifiedTime",
                parent_id="79328e649313467f86e57be9e8aeadac",
                project_id="bef3419620d743eca6a57881a0f006fd"
            )
            response = client.list_files(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    

Go

  • 查询项目列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        codeartsartifact "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := codeartsartifact.CodeArtsArtifactClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := codeartsartifact.NewCodeArtsArtifactClient(hcClient)
    
        request := &model.ListFilesRequest{}
    	pageSizeRepoFileQueryDtov5:= int32(1)
    	searchTypeRepoFileQueryDtov5:= "project"
    	sortRepoFileQueryDtov5:= ""
    	searchNameRepoFileQueryDtov5:= ""
    	pageNoRepoFileQueryDtov5:= int32(1)
    	orderByRepoFileQueryDtov5:= ""
    	parentIdRepoFileQueryDtov5:= ""
    	projectIdRepoFileQueryDtov5:= ""
    	request.Body = &model.RepoFileQueryDtov5{
    		PageSize: &pageSizeRepoFileQueryDtov5,
    		SearchType: &searchTypeRepoFileQueryDtov5,
    		Sort: &sortRepoFileQueryDtov5,
    		SearchName: &searchNameRepoFileQueryDtov5,
    		PageNo: &pageNoRepoFileQueryDtov5,
    		OrderBy: &orderByRepoFileQueryDtov5,
    		ParentId: &parentIdRepoFileQueryDtov5,
    		ProjectId: &projectIdRepoFileQueryDtov5,
    	}
    	response, err := client.ListFiles(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 查询指定项目的文件/文件夹列表

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        codeartsartifact "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsartifact/v2/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := codeartsartifact.CodeArtsArtifactClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := codeartsartifact.NewCodeArtsArtifactClient(hcClient)
    
        request := &model.ListFilesRequest{}
    	pageSizeRepoFileQueryDtov5:= int32(10)
    	sortRepoFileQueryDtov5:= "asc"
    	pageNoRepoFileQueryDtov5:= int32(1)
    	orderByRepoFileQueryDtov5:= "modifiedTime"
    	parentIdRepoFileQueryDtov5:= "79328e649313467f86e57be9e8aeadac"
    	projectIdRepoFileQueryDtov5:= "bef3419620d743eca6a57881a0f006fd"
    	request.Body = &model.RepoFileQueryDtov5{
    		PageSize: &pageSizeRepoFileQueryDtov5,
    		Sort: &sortRepoFileQueryDtov5,
    		PageNo: &pageNoRepoFileQueryDtov5,
    		OrderBy: &orderByRepoFileQueryDtov5,
    		ParentId: &parentIdRepoFileQueryDtov5,
    		ProjectId: &projectIdRepoFileQueryDtov5,
    	}
    	response, err := client.ListFiles(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

错误码

请参见错误码

相关文档