根据标签查询证书列表 - ListCertificatesByTag
功能介绍
根据标签查询证书列表。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
URI
POST /v3/scm/{resource_instances}/action
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
resource_instances |
是 |
String |
定值为resource_instances。 最小长度:18 最大长度:18 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
without_any_tag |
否 |
Boolean |
不包含任意一个标签,该字段为true时查询所有不带标签的资源,此时忽略 “tags”、“tags_any”、“not_tags”、“not_tags_any”字段。 |
|
tags |
否 |
Array of ScsTag objects |
标签列表。 包含标签,最多包含20个key,每个key下面的value最多20个,每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回包含所有标签的资源列表,key之间是与的关系,key-value结构中value是或的关系。无tag过滤条件时返回全量数据。 数组长度:1 - 20 |
|
tags_any |
否 |
Array of ScsTag objects |
标签列表。 包含任意标签,最多包含20个key,每个key下面的value最多20个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回包含标签的资源列表,key之间是或的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据。 数组长度:1 - 20 |
|
not_tags |
否 |
Array of ScsTag objects |
标签列表。 不包含标签,最多包含20个key,每个key下面的value最多20个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回不包含标签的资源列表,key之间是与的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据。 数组长度:1 - 20 |
|
not_tags_any |
否 |
Array of ScsTag objects |
标签列表。 不包含任意标签,最多包含20个key,每个key下面的value最多20个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回不包含标签的资源列表,key之间是或的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据。 数组长度:1 - 20 |
|
limit |
否 |
Integer |
每页条目数量,取值如下: 最小值:10 最大值:50 缺省值:10 |
|
offset |
否 |
Integer |
索引位置,偏移量,从offset指定的下一条数据开始查询。 最小值:0 缺省值:0 |
|
action |
否 |
String |
操作标识(可设置为“filter”或者“count”)。 最小长度:5 最大长度:6 |
|
matches |
否 |
Array of ScsMatch objects |
搜索字段。 key为要匹配的字段,如resource_name等。value为匹配的值。key为固定字典值,不能包含重复的key或不支持的key。 数组长度:0 - 10 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
total_count |
Integer |
总记录数。 最小值:0 最大值:100 |
|
resources |
Array of TagResource objects |
资源实例列表,详情请参见TagResource字段数据结构说明。 数组长度:0 - 100 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
resource_id |
String |
证书的资源ID。 最小长度:0 最大长度:63 |
|
tags |
Array of ScsResourceTag objects |
标签列表,没有标签默认为空数组。 数组长度:0 - 100 |
|
resource_name |
String |
资源名称,默认为空字符串。 最小长度:0 最大长度:63 |
|
resource_detail |
resource_detail object |
证书资源详情。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
cert_id |
String |
证书ID。 最小长度:16 最大长度:16 |
|
cert_name |
String |
证书名称。字符长度为3~63位。 最小长度:3 最大长度:63 |
|
domain |
String |
该证书绑定的域名。 示例:www.example.com 最小长度:0 最大长度:255 |
|
cert_type |
String |
证书类型。 最小长度:0 最大长度:32 |
|
cert_brand |
String |
证书品牌。GLOBALSIGN:GlobalSign品牌。 最小长度:0 最大长度:32 |
|
domain_type |
String |
域名类型。 最小长度:0 最大长度:32 |
|
purchase_period |
Integer |
证书有效期(年)。 最小值:0 最大值:1000 |
|
expired_time |
String |
证书到期时间,毫秒级时间戳。 最小长度:0 最大长度:32 |
|
order_status |
String |
订单状态。 最小长度:0 最大长度:32 |
|
domain_num |
Integer |
域名数量。 最小值:1 最大值:250 |
|
wildcard_number |
Integer |
泛域名数量。 最小值:1 最大值:100 |
|
sans |
String |
证书绑定的附加域名信息。 最小长度:0 最大长度:4096 |
|
cert_des |
String |
证书描述。 最小长度:0 最大长度:32 |
|
signature_algorithm |
String |
签名算法。 最小长度:0 最大长度:32 |
|
fail_reason |
String |
失败原因。 最小长度:0 最大长度:255 |
|
partner_order_id |
String |
订单流水号。 最小长度:0 最大长度:63 |
|
push_support |
Boolean |
证书是否支持推送。 |
|
cert_issued_time |
String |
证书签发时间,毫秒级时间戳。 最小长度:0 最大长度:32 |
|
resource_id |
String |
资源id。 最小长度:0 最大长度:63 |
|
unsubscribe_support |
Boolean |
证书是否支持退订。 |
|
enterprise_project_id |
String |
企业项目ID,默认为“0”。 对于开通企业项目的用户,表示资源处于默认企业项目下。 对于未开通企业项目的用户,表示资源未处于企业项目下。 最小长度:0 最大长度:36 |
|
origin_cert_id |
String |
初始证书id。 最小长度:0 最大长度:63 |
|
renewal_cert_id |
String |
续费购买证书id。 最小长度:0 最大长度:63 |
|
auto_renew_status |
Integer |
自动续费状态。 最小值:0 最大值:100 |
|
remain_cert_number |
Integer |
剩余证书有效个数。 最小值:0 最大值:100 |
|
auto_deploy_support |
Boolean |
证书是否支持自动部署。 |
状态码:401
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:403
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
状态码:500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误请求返回的错误码。 最小长度:3 最大长度:36 |
|
error_msg |
String |
错误请求返回的错误信息。 最小长度:0 最大长度:1024 |
请求示例
{
"action" : "filter",
"tags" : [ {
"key" : "key1",
"values" : [ "value1", "value2" ]
} ]
}
响应示例
状态码:200
正常返回。
{
"total_count" : 1,
"resources" : [ {
"resource_id" : "scs1664525717891"
}, {
"resource_detail" : [ {
"cert_id" : "scs1664525717891",
"cert_name" : "scm-e409cb",
"auto_deploy_support" : false,
"auto_renew_status" : 0,
"cert_brand" : "CFCA",
"cert_des" : null,
"cert_issued_time" : 1664528641000,
"cert_type" : "OV_SSL_CERT",
"domain" : "www.cfca.com",
"domain_num" : 6,
"domain_type" : "MULTI_DOMAIN",
"enterprise_project_id" : "7c0b1c33-491f-4b87-914a-bb708815b51a",
"expired_time" : 1696064641000,
"fail_reason" : null,
"order_status" : "ISSUED",
"origin_cert_id" : null,
"partner_order_id" : "TA1664528570549_0573",
"purchase_period" : 1,
"push_support" : false,
"remain_cert_number" : 0,
"renewal_cert_id" : null,
"resource_id" : null,
"sans" : "www.test.com;*.test1.com;*.test2.com;www.test3.com;www.test4.com",
"signature_algorithm" : null,
"unsubscribe_support" : false,
"wildcard_number" : 2
} ]
}, {
"tags" : [ {
"key" : "key1",
"value" : "value1"
} ]
}, {
"resource_name" : "scm-e409cb"
} ]
}
状态码:401
认证失败。
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
状态码:403
禁止访问。
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
状态码:500
请求未完成,服务器内部异常。
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
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 56 57 58 59 60 61 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.GlobalCredentials; 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.scm.v3.region.ScmRegion; import com.huaweicloud.sdk.scm.v3.*; import com.huaweicloud.sdk.scm.v3.model.*; import java.util.List; import java.util.ArrayList; public class ListCertificatesByTagSolution { 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 GlobalCredentials() .withAk(ak) .withSk(sk); ScmClient client = ScmClient.newBuilder() .withCredential(auth) .withRegion(ScmRegion.valueOf("<YOUR REGION>")) .build(); ListCertificatesByTagRequest request = new ListCertificatesByTagRequest(); request.withResourceInstances("{resource_instances}"); ListCertificatesByTagRequestBody body = new ListCertificatesByTagRequestBody(); List<String> listTagsValues = new ArrayList<>(); listTagsValues.add("value1"); listTagsValues.add("value2"); List<ScsTag> listbodyTags = new ArrayList<>(); listbodyTags.add( new ScsTag() .withKey("key1") .withValues(listTagsValues) ); body.withAction("filter"); body.withTags(listbodyTags); request.withBody(body); try { ListCertificatesByTagResponse response = client.listCertificatesByTag(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 41 42 43 44 45 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import GlobalCredentials from huaweicloudsdkscm.v3.region.scm_region import ScmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkscm.v3 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 = GlobalCredentials(ak, sk) client = ScmClient.new_builder() \ .with_credentials(credentials) \ .with_region(ScmRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListCertificatesByTagRequest() request.resource_instances = "{resource_instances}" listValuesTags = [ "value1", "value2" ] listTagsbody = [ ScsTag( key="key1", values=listValuesTags ) ] request.body = ListCertificatesByTagRequestBody( action="filter", tags=listTagsbody ) response = client.list_certificates_by_tag(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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" scm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/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 := global.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := scm.NewScmClient( scm.ScmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListCertificatesByTagRequest{} request.ResourceInstances = "{resource_instances}" var listValuesTags = []string{ "value1", "value2", } keyTags:= "key1" var listTagsbody = []model.ScsTag{ { Key: &keyTags, Values: &listValuesTags, }, } actionListCertificatesByTagRequestBody:= "filter" request.Body = &model.ListCertificatesByTagRequestBody{ Action: &actionListCertificatesByTagRequestBody, Tags: &listTagsbody, } response, err := client.ListCertificatesByTag(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
正常返回。 |
|
401 |
认证失败。 |
|
403 |
禁止访问。 |
|
404 |
访问页面未找到。 |
|
500 |
请求未完成,服务器内部异常。 |
错误码
请参见错误码。