Querying the Certificate List by Tag
Function
Query the certificate list by tag.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
URI
POST /v3/scm/{resource_instances}/action
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
resource_instances |
Yes |
String |
Resource instance. The value is resource_instances. Minimum: 18 Maximum: 18 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. Minimum: 32 Maximum: 2097152 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
without_any_tag |
No |
Boolean |
If this parameter is set to true, all resources without tags are queried. In this case, the tags, tags_any, not_tags, and not_tags_any fields are not required. |
|
tags |
No |
Array of ScsTag objects |
The list of tags. The resources to be queried contain tags specified in this field. Each resource can contain a maximum of 20 keys. Each tag key can have a maximum of 20 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each key must be unique, and each value for a key must be unique. The response returns resources containing all the specified tags. Keys are in the AND relationship and values in each key-value structure are in the OR relationship. If this parameter is not specified, all resources will be returned. Array Length: 1 - 20 |
|
tags_any |
No |
Array of ScsTag objects |
The list of tags. The instances to be queried contain any tag listed in tags_any. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 20 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each key must be unique, and each value for a key must be unique. The response returns resources containing the tags in this list. Keys in this list are in an OR relationship and values in each key-value structure are also in an OR relationship. If no filtering condition is specified, full data is returned. Array Length: 1 - 20 |
|
not_tags |
No |
Array of ScsTag objects |
The list of tags. The instances to be queried do not contain any tag listed in not_tags. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 20 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Keys must be unique and values of a key must be unique. The response returns instances containing no tag in this list. Keys are in the AND relationship and values in each key-value structure is in the OR relationship. If this parameter is not specified, all resources will be returned. Array Length: 1 - 20 |
|
not_tags_any |
No |
Array of ScsTag objects |
The list of tags. The instances to be queried do not contain all tags listed in not_tags_any. Each instance to be queried contains a maximum of 20 keys. Each tag key has a maximum of 20 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each key must be unique, and each value for a key must be unique. The response returns resources containing no tag in this list. Keys in this list are in the OR relationship and values in each key-value structure are also in the OR relationship. If no tag filtering criteria is specified, full data is returned. Array Length: 1 - 20 |
|
limit |
No |
Integer |
Number of certificate records on each page. The options are as follows: Minimum: 10 Maximum: 50 Default: 10 |
|
offset |
No |
Integer |
Specifies the offset. The query starts from the next piece of data indexed by this parameter. Minimum: 0 Default: 0 |
|
action |
No |
String |
Operation type. Possible values are as follows: Minimum: 5 Maximum: 6 |
|
matches |
No |
Array of ScsMatch objects |
Search field. key indicates the field to be matched, for example, resource_name. value indicates the matched value. The key is a fixed dictionary value and cannot contain duplicate keys or unsupported keys. Array Length: 0 - 10 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
No |
String |
Tag key. It can contain UTF-8 letters, digits, spaces, and the following characters: _ . : = + - @ Minimum: 1 Maximum: 128 |
|
values |
No |
Array of strings |
Tag values. It can contain UTF-8 letters, digits, spaces, and the following special characters: _ . : = + - @ Minimum: 0 Maximum: 255 Array Length: 1 - 20 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
No |
String |
Tag key. It can contain UTF-8 letters, digits, spaces, and the following characters: _ . : = + - @ Minimum: 1 Maximum: 128 |
|
value |
No |
String |
Tag value. It can contain UTF-8 letters, digits, spaces, and the following characters: _ . : / = + - @ Minimum: 0 Maximum: 255 |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
total_count |
Integer |
Total number of records Minimum: 0 Maximum: 100 |
|
resources |
Array of TagResource objects |
Resource instance list. For details, see the data structure description of the TagResource field. Array Length: 0 - 100 |
|
Parameter |
Type |
Description |
|---|---|---|
|
resource_id |
String |
Whether the certificate can be unsubscribed. Minimum: 0 Maximum: 63 |
|
tags |
Array of ScsResourceTag objects |
Resource ID of the certificate. Array Length: 0 - 100 |
|
resource_name |
String |
Number of wildcard domain names. Minimum: 0 Maximum: 63 |
|
resource_detail |
resource_detail object |
Certificate resource details. |
|
Parameter |
Type |
Description |
|---|---|---|
|
key |
String |
Tag key. Minimum: 0 Maximum: 128 |
|
value |
String |
Tag value. Minimum: 0 Maximum: 255 |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Example Requests
{
"action" : "filter",
"tags" : [ {
"key" : "key1",
"values" : [ "value1", "value2" ]
} ]
}
Example Responses
Status code: 200
Normal response.
{
"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"
} ]
}
Status code: 401
Authentication failed.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
Status code: 403
Access denied.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
Status code: 500
Failed to complete the request because of an internal server error.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
SDK Sample Code
The SDK sample code is as follows.
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) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Normal response. |
|
401 |
Authentication failed. |
|
403 |
Access denied. |
|
404 |
Access page not found. |
|
500 |
Failed to complete the request because of an internal server error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot