Querying Public NAT Gateways by Tag
Function
-
This API is used to query public NAT gateways by tag.
-
Tag Management Service (TMS) uses this API to filter and list public NAT gateways.
-
By default, public NAT gateways and their tags are sorted by creation time in descending order.
Constraints
-
You need to add the VPC domain name when calling the API for managing public NAT gateway tags.
Calling Method
For details, see Calling APIs.
URI
POST /v2.0/{project_id}/nat_gateways/resource_instances/action
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the user token. It is a response to the API for obtaining a user token. This API is the only one that does not require authentication. The value of X-Subject-Token in the response header is the token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tags |
No |
Array of Tag objects |
Specifies the included tags. Each tag has a maximum of 10 keys, and each key has a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and each tag value for a tag key must be unique. Resources that contain all keys and one or multiple values listed in tags will be found and returned. If no tag filtering criteria is specified, full data is returned. Array Length: 1 - 10 |
tags_any |
No |
Array of Tag objects |
Specifies any included tags. Each tag has a maximum of 10 keys, and each key has a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and each tag value for a tag key must be unique. Resources identified by different keys are in OR relationship, and values in one tag are in OR relationship. If no tag filtering criteria is specified, full data is returned. |
not_tags |
No |
Array of Tag objects |
Specifies the excluded tags. Each tag has a maximum of 10 keys, and each key has a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and each tag value for a tag key must be unique. Resources not identified by different keys are in AND relationship, and values in one tag are in OR relationship. If no tag filtering criteria is specified, full data is returned. |
not_tags_any |
No |
Array of Tag objects |
Specifies any excluded tags. Each tag has a maximum of 10 keys, and each key has a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and each tag value for a tag key must be unique. Resources not identified by different keys are in OR relationship, and values in one tag are in OR relationship. If no tag filtering criteria is specified, full data is returned. |
limit |
No |
String |
Specifies the number of records to be queried. This parameter is not available when action is set to count. When action is set to filter, the default value is 1000, which is also the maximum value. The minimum value is 1. The value cannot be a negative number. |
offset |
No |
String |
Specifies the index position. The query starts from the next piece of data indexed by this parameter. This parameter is not required when you query data on the first page. The value in the response returned for querying data on the previous page will be included in this parameter for querying data on subsequent pages. This parameter is not available when action is set to count. When action is set to filter, the value must be a positive number, and the default value is 0. |
action |
Yes |
String |
|
matches |
No |
Array of Match objects |
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the tag key. A key can contain up to 128 Unicode characters. (The system does not verify key when searching for resources.) key cannot be left blank, be an empty string, or be only spaces. Before using key, delete spaces before and after the value. |
values |
Yes |
Array of strings |
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
resources |
Array of Resource objects |
Specifies the resource object list. For details, see the Resource field description. |
total_count |
Integer |
Specifies the total number of records. |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
Specifies the resource ID. |
resource_detail |
Object |
Specifies resource details. The value is a resource object used for extension. This parameter is left blank by default. |
tags |
Array of ResourceTag objects |
Specifies the list of queried tags. If no tag is matched, an empty array is returned. For details, see the ResourceTag field description. |
resource_name |
String |
Specifies the resource name. This parameter is an empty string by default if there is no resource name. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the tag key. A key can contain up to 128 Unicode characters. key cannot be left blank. A key cannot contain ASCII characters (0–31 decimal) nor the following characters: *<>= |
value |
String |
Specifies the tag value. Each value can contain up to 255 Unicode characters and can be an empty string. A value cannot contain ASCII characters (0–31 decimal) nor the following characters: *<>= |
Example Requests
-
Querying public NAT gateways (Setting limit to 100 and action to filter)
POST https://{VPC_endpoint}/v2.0/9ad601814ac94c80bf7bb9073ded66fc/nat_gateways/resource_instances/action { "offset" : "100", "limit" : "100", "action" : "filter", "matches" : [ { "key" : "resource_name", "value" : "nat_gateways" } ], "not_tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags" : [ { "key" : "key2", "values" : [ "*value3", "value4" ] } ], "tags_any" : [ { "key" : "key3", "values" : [ "*value5", "value6" ] } ], "not_tags_any" : [ { "key" : "key4", "values" : [ "*value7", "value8" ] } ] }
-
Querying public NAT gateways (Setting action to count)
POST https://{VPC_endpoint}/v2.0/9ad601814ac94c80bf7bb9073ded66fc/nat_gateways/resource_instances/action { "action" : "count", "matches" : [ { "key" : "resource_name", "value" : "nat_gateways" } ], "not_tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags" : [ { "key" : "key2", "values" : [ "*value3", "value4" ] } ], "tags_any" : [ { "key" : "key3", "values" : [ "*value5", "value6" ] } ], "not_tags_any" : [ { "key" : "key4", "values" : [ "*value7", "value8" ] } ] }
Example Responses
Status code: 200
-
Query operation succeeded.
-
Example 1: the response body when action is set to filter
-
Example 2: the response body when action is set to count
-
Example 1
{ "resources" : [ { "resource_detail" : null, "resource_id" : "e5ad289f-9c56-4daf-b08b-2e53a983473a", "resource_name" : "nat_gateways", "tags" : [ { "key" : "key2", "value" : "value4" }, { "key" : "key2", "value" : "value3" } ] } ], "total_count" : 1000 }
-
Example 2
{ "total_count" : 1000 }
Status Codes
Status Code |
Description |
---|---|
200 |
|
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