tencent cloud

文档反馈

DescribeSecurityGroups

最后更新时间:2023-08-23 14:11:17

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.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

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 Params. The value used for this API: DescribeSecurityGroups.
Version Yes String Common Params. The value used for this API: 2017-03-12.
Region No String Common Params. This parameter is not required for this API.
SecurityGroupIds.N No Array of String Security group ID, such as sg-33ocnj9n. Each request can contain up to 100 instances at a time. 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. Default value: 0.
    Limit No String Number of returned results. Default value: 20. Maximum value: 100.
    OrderField No String Sorting field. Values: CreatedTime, UpdateTime Note: This field does not have default value.
    OrderDirection No String Sorting method Order methods. Ascending: ASC, Descending: DESC. Default: ASC

    3. Output Parameters

    Parameter Name Type Description
    SecurityGroupSet Array of SecurityGroup Security group object.
    Note: this field may return null, indicating that no valid values can be obtained.
    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 Querying security groups

    This example shows you how to query security groups.

    Input Example

    POST / HTTP/1.1
    Host: vpc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeSecurityGroups
    <Common request parameters>
    
    {
        "Limit": "1",
        "Filters": [
            {
                "Values": [
                    "TestGroup"
                ],
                "Name": "security-group-name"
            },
            {
                "Values": [
                    "0"
                ],
                "Name": "project-id"
            }
        ]
    }
    

    Output Example

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

    Example2 Querying security groups bound with the specific tag

    This example shows you how to query by tag:tag-key.

    Input Example

    POST / HTTP/1.1
    Host: vpc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeSecurityGroups
    <Common request parameters>
    
    {
        "Filters": [
            {
                "Values": [
                    "TEST"
                ],
                "Name": "tag:Version"
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "SecurityGroupSet": [
                {
                    "SecurityGroupId": "sg-2got2lcz",
                    "SecurityGroupName": "test",
                    "SecurityGroupDesc": "All ports are opened to the public and private networks. This may present security isks.",
                    "ProjectId": "0",
                    "IsDefault": false,
                    "CreatedTime": "2019-07-23 12:32:24",
                    "TagSet": [
                        {
                            "Key": "u200dTag key",
                            "Value": "Tag value"
                        },
                        {
                            "Key": "Version",
                            "Value": "TEST"
                        },
                        {
                            "Key": "Version",
                            "Value": "DEV"
                        }
                    ]
                }
            ],
            "TotalCount": 1,
            "RequestId": "85cda7d1-6608-4eca-8d02-19937c12dd84"
        }
    }
    

    5. Developer Resources

    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
    InvalidParameter.Coexist The parameters cannot be specified at the same time.
    InvalidParameter.FilterInvalidKey The specified filter condition does not exist.
    InvalidParameter.FilterNotDict The specified filter condition should be a key-value pair.
    InvalidParameter.FilterValuesNotList The specified filter value should be a list.
    InvalidParameterValue.LimitExceeded The parameter value exceeds the limit.
    InvalidParameterValue.Malformed Invalid input parameter format.
    InvalidParameterValue.Range The parameter value is not in the specified range.
    ResourceNotFound The resource does not exist.
    UnsupportedOperation Unsupported operation.
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持