DescribeSecurityGroups

Last updated: 2020-03-06 20:26:29

PDF

1. API Description

Domain name for API request: vpc.tencentcloudapi.com.

This API (DescribeSecurityGroups) is used to query security groups.

A maximum of 100 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: vpc.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: DescribeSecurityGroups.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
SecurityGroupIds.N No Array of String The security group instance ID, such as sg-33ocnj9n. It can be obtained through DescribeSecurityGroups. Each request can have a maximum of 100 instances. SecurityGroupIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filter conditions. SecurityGroupIds and Filters cannot be specified at the same time.
  • security-group-id - String - (Filter condition) The security group ID.
  • project-id - Integer - (Filter condition) The project ID.
  • security-group-name - String - (Filter condition) The security group name.
  • tag-key - String - Required: no - (Filter condition) Filters by tag key. For more information, see Example 2.
  • tag:tag-key - String - Required: no - (Filter condition) Filters by tag key pair. For this parameter, tag-key will be replaced with a specific tag key. For more information, see Example 3.
  • Offset No String Offset.
    Limit No String The returned quantity.

    3. Output Parameters

    Parameter Name Type Description
    SecurityGroupSet Array of SecurityGroup Security group object.
    TotalCount Integer The number of instances meeting the filter condition.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Example 1. Querying a security group

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSecurityGroups
    &Version=2017-03-12
    &Limit=1
    &Filters.0.Name=project-id
    &Filters.0.Values.0=0
    &Filters.1.Name=security-group-name
    &Filters.1.Values.0=TestGroup
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "SecurityGroupSet": [
          {
            "SecurityGroupId": "sg-05bb4upy",
            "SecurityGroupName": "TestGroup",
            "SecurityGroupDesc": "test-group-desc",
            "ProjectId": "0",
            "CreateTime": "2017-04-18 21:02:30"
          }
        ],
        "TotalCount": 1,
        "RequestId": "74883e1b-5901-46de-ae1e-d6e2cf591c5b"
      }
    }

    Example2 Example 2. Querying security groups that are bound to tags

    Query a security group by tag-key.

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSecurityGroups
    &Version=2017-03-12
    &Filters.0.Name=tag-key
    &Filters.0.Values.0=Version
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "SecurityGroupSet": [
          {
            "SecurityGroupId": "sg-2got2lcz",
            "SecurityGroupName": "test",
            "SecurityGroupDesc": "Exposing all ports to the Internet and private network may introduce security risks",
            "ProjectId": "0",
            "IsDefault": false,
            "CreatedTime": "2019-07-23 12:32:24",
            "TagSet": [
              {
                "Key": "Tag key",
                "Value": "Tag value"
              },
              {
                "Key": "Version",
                "Value": "TEST"
              },
              {
                "Key": "Version",
                "Value": "DEV"
              }
            ]
          }
        ],
        "TotalCount": 1,
        "RequestId": "85cda7d1-6608-4eca-8d02-19937c12dd84"
      }
    }

    Example3 Example 3. Querying security groups bound to tags

    Query security groups by tag:tag-key.

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSecurityGroups
    &Version=2017-03-12
    &Filters.0.Name=tag:Version
    &Filters.0.Values.0=TEST
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "SecurityGroupSet": [
          {
            "SecurityGroupId": "sg-2got2lcz",
            "SecurityGroupName": "test",
            "SecurityGroupDesc": "Exposing all ports to the Internet and private network may introduce security risks",
            "ProjectId": "0",
            "IsDefault": false,
            "CreatedTime": "2019-07-23 12:32:24",
            "TagSet": [
              {
                "Key": "Tag key",
                "Value": "Tag value"
              },
              {
                "Key": "Version",
                "Value": "TEST"
              },
              {
                "Key": "Version",
                "Value": "DEV"
              }
            ]
          }
        ],
        "TotalCount": 1,
        "RequestId": "85cda7d1-6608-4eca-8d02-19937c12dd84"
      }
    }

    5. Developer Resources

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InvalidParameterValue.Malformed Invalid input parameter format.
    ResourceNotFound The resource does not exist.