文档首页/ 容器镜像服务 SWR/ API参考(企业版)/ API/ 制品版本管理/ 获取制品版本详情 - ShowInstanceArtifact
更新时间:2025-11-28 GMT+08:00

获取制品版本详情 - ShowInstanceArtifact

功能介绍

获取制品版本详情

接口约束

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项
  • 如果使用身份策略授权,需具备如下身份策略权限。

    授权项

    访问级别

    资源类型(*为必须)

    条件键

    别名

    依赖的授权项

    swr:repository:getArtifact

    Read

    repository *

    • g:ResourceTag/<tag-key>

    • g:EnterpriseProjectId

    -

    -

URI

GET /v2/{project_id}/instances/{instance_id}/namespaces/{namespace_name}/repositories/{repository_name}/artifacts/{reference}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

instance_id

String

企业仓库实例ID

namespace_name

String

命名空间名称

repository_name

String

制品仓库名称, 如果您的镜像名称repository_name参数中有/,请先把 / 替换成 %2F 再进行请求。注意:使用curl命令请求,需要把 / 替换成 %252F(即 %2F 的 % 被编码为 %25)再次请求。

reference

String

制品摘要

表2 Query参数

参数

是否必选

参数类型

描述

with_scan_overview

Boolean

是否返回制品扫描摘要

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。

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

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

digest

String

制品摘要

id

Integer

制品ID

repository_id

Integer

仓库ID

repository_name

String

仓库名称

type

String

制品类型

取值范围:

  • IMAGE:镜像制品

namespace_id

Integer

命名空间ID

media_type

String

制品MIME类型

manifest_media_type

String

制品元数据MIME类型

pull_time

String

最近一次拉取时间

push_time

String

最近一次上传时间

size

Integer

制品大小,单位:Byte

tags

Array of ArtifactTag objects

制品版本的Tag列表

scan_overview

ScanOverview object

制品扫描摘要

表5 ArtifactTag

参数

参数类型

描述

id

Long

Tag ID

repository_id

Long

制品仓库ID

artifact_id

Long

制品版本ID

name

String

tag名称

push_time

String

tag的上传时间

pull_time

String

tag的下载时间

表6 ScanOverview

参数

参数类型

描述

{自定义key}

Map<String,NativeReportSummary>

制品扫描摘要,支持制品扫描报告类型为application/vnd.security.vulnerability.report; version=1.1的制品扫描摘要

表7 NativeReportSummary

参数

参数类型

描述

report_id

String

报告ID

scan_status

String

制品扫描状态,Pending(扫描等待中)、Running(扫描中)、Error(扫描失败)、Success(扫描成功)

severity

String

制品扫描报告的总体严重程度,None(无评分), Low(低危), Medium(中危), High(高危), Critical(严重), Security(安全)

duration

Integer

生成报告所花费的秒数时间

summary

VulnerabilitySummary object

漏洞信息摘要

start_time

String

报告生成的开始时间

end_time

String

报告生成的结束时间

complete_percent

Integer

扫描的完成百分比,该值介于0和100之间

scanner

Scanner object

扫描器的信息

表8 VulnerabilitySummary

参数

参数类型

描述

total

Integer

发现的漏洞总数

fixable

Integer

可修复漏洞的数量

summary

Map<String,Integer>

不同级别的漏洞数量

表9 Scanner

参数

参数类型

描述

name

String

扫描器的名称

vendor

String

扫描器的提供商

version

String

扫描器的版本号

状态码:400

表10 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

encoded_authorization_message

String

加密后的详细拒绝原因,用户可以自行调用STS服务的decode-authorization-message接口进行解密。

状态码:401

表11 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

encoded_authorization_message

String

加密后的详细拒绝原因,用户可以自行调用STS服务的decode-authorization-message接口进行解密。

状态码:403

表12 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

encoded_authorization_message

String

加密后的详细拒绝原因,用户可以自行调用STS服务的decode-authorization-message接口进行解密。

状态码:404

表13 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

encoded_authorization_message

String

加密后的详细拒绝原因,用户可以自行调用STS服务的decode-authorization-message接口进行解密。

状态码:500

表14 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误信息

encoded_authorization_message

String

加密后的详细拒绝原因,用户可以自行调用STS服务的decode-authorization-message接口进行解密。

请求示例

GET https://{endpoint}/v2/{project_id}/instances/{instance_id}/namespaces/{namespace_name}/repositories/{repository_name}/artifacts/{reference}

响应示例

状态码:200

查询制品版本详情成功

{
  "digest" : "sha256:d086845138397686ea70e11f069031370534dcc1617d02ae9b501504f91af50a",
  "id" : 448,
  "manifest_media_type" : "application/vnd.docker.distribution.manifest.v2+json",
  "media_type" : "application/vnd.docker.container.image.v1+json",
  "pull_time" : "2022-11-12T00:53:48.696Z",
  "push_time" : "2022-11-03T10:20:23.753Z",
  "repository_id" : 49,
  "size" : 127999644,
  "tags" : [ {
    "artifact_id" : 448,
    "id" : 352,
    "name" : "v1.0.3.test1",
    "pull_time" : "2022-11-12T00:53:48.696Z",
    "push_time" : "2022-11-03T10:20:23.870Z",
    "repository_id" : 49
  } ],
  "type" : "IMAGE"
}

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
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.swr.v2.region.SwrRegion;
import com.huaweicloud.sdk.swr.v2.*;
import com.huaweicloud.sdk.swr.v2.model.*;


public class ShowInstanceArtifactSolution {

    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");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        SwrClient client = SwrClient.newBuilder()
                .withCredential(auth)
                .withRegion(SwrRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowInstanceArtifactRequest request = new ShowInstanceArtifactRequest();
        request.withInstanceId("{instance_id}");
        request.withNamespaceName("{namespace_name}");
        request.withRepositoryName("{repository_name}");
        request.withReference("{reference}");
        try {
            ShowInstanceArtifactResponse response = client.showInstanceArtifact(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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkswr.v2.region.swr_region import SwrRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkswr.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"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = SwrClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(SwrRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowInstanceArtifactRequest()
        request.instance_id = "{instance_id}"
        request.namespace_name = "{namespace_name}"
        request.repository_name = "{repository_name}"
        request.reference = "{reference}"
        response = client.show_instance_artifact(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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    swr "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/swr/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/swr/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/swr/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")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := swr.NewSwrClient(
        swr.SwrClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowInstanceArtifactRequest{}
	request.InstanceId = "{instance_id}"
	request.NamespaceName = "{namespace_name}"
	request.RepositoryName = "{repository_name}"
	request.Reference = "{reference}"
	response, err := client.ShowInstanceArtifact(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

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

状态码

状态码

描述

200

查询制品版本详情成功

400

错误的请求

401

鉴权失败

403

禁止访问

404

未找到资源

500

内部错误

错误码

请参见错误码