分页查询构建归档包列表 - ListFileBuildArchives
功能介绍
当构建归档包数量庞大时,分页查询构建归档包列表,包含文件名、文件大小、下载地址、MD5校验和、构建地址和构建代码分支等信息。
调用方法
请参见如何调用API。
授权信息
账号根用户具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备如下身份策略权限,更多的权限说明请参见权限和授权项。
|
授权项 |
访问级别 |
资源类型(*为必须) |
条件键 |
别名 |
依赖的授权项 |
|---|---|---|---|---|---|
|
codeartsartifact:releaseRepo:read |
Read |
- |
- |
- |
- |
URI
GET /devreposerver/v5/files/archives
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
parent_id |
否 |
String |
父节点id |
|
build_id |
否 |
String |
构建id |
|
build_no |
否 |
String |
构建序号 |
|
page_no |
否 |
Integer |
页数 |
|
page_size |
否 |
Integer |
每页数据量 |
|
repo_branch |
否 |
String |
codehub仓库分支 |
请求参数
无
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
status |
String |
参数解释: 请求成功、失败状态。 取值范围: success: 请求成功。 error:请求失败。 |
|
trace_id |
String |
参数解释: 请求id,当前请求唯一标识。 取值范围: 数字及中划线(-)组成的字符串。 |
|
result |
Object |
参数解释: 请求返回结果,接口不同,返回不同。 取值范围: 根据不同接口有不同范围。 |
请求示例
https://localhost.com/devreposerver/v5/files/archives?build_id=66666603da854239ab51209ea7e27b64&repo_branch=master&parent_id=66666687399849b782b13c9512fbb3b6
响应示例
状态码:200
OK
{
"status" : "success",
"trace_id" : "76629-1718767414372-27337",
"result" : {
"data" : [ {
"domainId" : "09d2ca2f5080d5b60f51c00ae5666666",
"region" : "region",
"createdTime" : "2024-02-27 18:29:19",
"createdUserId" : "09d2ca2ffd00d3c21ff8c00a4d666666",
"createdUserName" : "test-user",
"buildId" : "11236703da854239ab51209ea7666666",
"buildName" : "maven1-23414517",
"buildNo" : "20240227.3",
"buildVersion" : "20240227.3",
"buildUrl" : "https://localhost.com/codeci/project/1bbbdd388234492793eb1bf59e666666/codeci/detail/workspace/11236703da854239ab51209ea7666666/3",
"repoUrl" : "",
"repoBranch" : "master",
"commitId" : "66666683c1590363818225ec649d7cf161f0d49c",
"projectId" : "1bbbdd388234492793eb1bf59e666666",
"fileId" : "666666f9d76f405a8d503b841de02b51",
"repoName" : "region_1bbbdd388234492793eb1bf59e666666_generic_0",
"parentId" : "66666687399849b782b13c9512fbb3b6",
"fileName" : "HelloWorld.class",
"size" : 534,
"md5" : "e06fcae2912a318db12955f37cd9230b",
"sha256" : "96f5666537da969efee5f51f2969771b3743ada63fde57e42ad210c116ceedaf",
"downloadUrlWithId" : "https://localhost.com/DevRepoServer/v1/files/download?file_id=666666f9d76f405a8d503b841de02b51&type=archive",
"webUrl" : "https://localhost.com/cloudartifact/project/1bbbdd388234492793eb1bf59e666666/private/general?parentId=66666687399849b782b13c9512fbb3b6",
"versionEnable" : false,
"migratedState" : 2,
"repoSameTrashFileName" : "trash_e653c9f9d76f405a8d503b841666666"
} ],
"totalRecords" : 1,
"totalPages" : 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 |
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 ListFileBuildArchivesSolution { 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(); ListFileBuildArchivesRequest request = new ListFileBuildArchivesRequest(); try { ListFileBuildArchivesResponse response = client.listFileBuildArchives(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 |
# 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 = ListFileBuildArchivesRequest() response = client.list_file_build_archives(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 |
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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := codeartsartifact.NewCodeArtsArtifactClient( codeartsartifact.CodeArtsArtifactClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListFileBuildArchivesRequest{} response, err := client.ListFileBuildArchives(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
OK |
错误码
请参见错误码。