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.
Calling Method
For details, see Calling APIs.
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/{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 value. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
tags |
No |
Array of PublicTag objects |
The resources to be queried contain tags listed in tags. Each resource to be queried contains a maximum of 20 keys. Each tag key can have a maximum of 20 tag 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 in a tag must be unique. Resources that contain the tags listed in tags will be returned. Keys are in the AND relationship, and values in a tag are in the OR relationship. If this parameter is not specified, all resources will be returned. |
|
tags_any |
No |
Array of PublicTag objects |
The resources to be queried contain any tag listed in tags_any. Each resource to be queried contains a maximum of 20 keys. Each tag key can have a maximum of 20 tag 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 in a tag must be unique. Resources that contain any tag listed in tags_any will be returned. Keys are in the AND relationship, and values in a tag are in the OR relationship. If this parameter is not specified, all resources will be returned. |
|
not_tags |
No |
Array of PublicTag objects |
The resources to be queried do not contain tags listed in not_tags. Each resource to be queried contains a maximum of 20 keys. Each tag key can have a maximum of 20 tag 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 in a tag must be unique. Resources that do not contain the tags listed in not_tags will be returned. Keys are in the AND relationship, and values in a tag are in the OR relationship. If this parameter is not specified, all resources will be returned. |
|
not_tags_any |
No |
Array of PublicTag objects |
The resources to be queried do not contain any tag listed in not_tags_any. Each resource to be queried contains a maximum of 20 keys. Each tag key can have a maximum of 20 tag 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 in a tag must be unique. Resources that do not contain any tag listed in not_tags_any will be returned. Keys are in the AND relationship, and values in a tag are in the OR relationship. If this parameter is not specified, all resources will be returned. |
|
limit |
No |
String |
Specifies the number of records to be queried. This parameter is not available when action is set to count. If 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 offset. 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 |
Specifies the operation to perform. The value can be: filter indicates pagination query. count indicates that the total number of query results meeting the search criteria will be returned. |
|
matches |
No |
Array of PublicMatch objects |
|
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
resources |
Array of PublicResource objects |
Specifies the resource object list. For details, see the Resource field description. |
|
total_count |
Integer |
Specifies the total number of resources. |
|
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 PublicResourceTag 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 non-printable ASCII characters (0–31) or the following special 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 non-printable ASCII characters (0–31) or the following special characters: *<>\=\ |
Example Requests
-
Querying public NAT gateways by tag (Setting action to filter and limit to 1000)
POST https://{NAT_endpoint}/v3/9ad601814ac94c80bf7bb9073ded66fc/nat_gateways/resource_instances/action { "offset" : "0", "limit" : "1000", "action" : "filter", "matches" : [ { "key" : "resource_name", "value" : "nat_gateways" } ], "not_tags" : [ { "key" : "key1", "values" : [ "value2" ] } ], "tags" : [ { "key" : "key2", "values" : [ "value4" ] } ], "tags_any" : [ { "key" : "key3", "values" : [ "value6" ] } ], "not_tags_any" : [ { "key" : "key4", "values" : [ "value8" ] } ] } -
Querying public NAT gateways (Setting action to count)
POST https://{NAT_endpoint}/v3/9ad601814ac94c80bf7bb9073ded66fc/nat_gateways/resource_instances/action { "action" : "count", "matches" : [ { "key" : "resource_name", "value" : "nat_gateways" } ], "not_tags" : [ { "key" : "key1", "values" : [ "value2" ] } ], "tags" : [ { "key" : "key2", "values" : [ "value4" ] } ], "tags_any" : [ { "key" : "key3", "values" : [ "value6" ] } ], "not_tags_any" : [ { "key" : "key4", "values" : [ "value8" ] } ] }
Example Responses
Status code: 200
-
{ "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 } -
{ "total_count" : 1000 }
Status Codes
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.