接口功能介绍
该接口提供用户查询用户安全组列表的功能
准备工作:
构造请求:在调用前需要了解如何构造请求,详情查看构造请求
认证鉴权:openapi请求需要进行加密调用,详细查看认证鉴权
注意事项:
分页查询:当前查询结果以分页形式进行展示,单次查询最多显示50条数据
接口约束
无
URI
GET /v4/ecs/vpc/query-security-groups
路径参数
无
Query参数
参数 | 是否必填 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|---|
regionID | 是 | String | 资源池ID,您可以查看地域和可用区来了解资源池 获取: 查 资源池列表查询 |
bb9fdb42056f11eda1610242ac110002 | |
vpcID | 否 | String | 虚拟私有云ID,您可以查看产品定义-虚拟私有云来了解虚拟私有云 获取: 查 查询VPC列表 创 创建VPC 注:在多可用区类型资源池下,vpcID通常以“vpc-”开头,非多可用区类型资源池vpcID为uuid格式 |
vpc-qfnsjbkrls | |
queryContent | 否 | String | 模糊匹配查询内容(匹配字段:id、name) | Default-Security-Group | |
projectID | 否 | String | 企业项目ID,企业项目管理服务提供统一的云资源按企业项目管理,以及企业项目内的资源管理,成员管理。您可以通过查看创建企业项目了解如何创建企业项目 | 0 | |
instanceID | 否 | String | 云主机ID,您可以查看弹性云主机了解云主机的相关信息 获取: 查 查询云主机列表 创 创建一台按量付费或包年包月的云主机 创 批量创建按量付费或包年包月云主机 |
adc614e0-e838-d73f-0618-a6d51d09070a | |
pageNumber | 否 | Integer | 页码,取值范围:正整数(≥1),注:旧字段,后续可能废弃;默认值为1 | 1 | |
pageNo | 否 | Integer | 页码,取值范围:正整数(≥1),注:默认值为1 | 1 | |
pageSize | 否 | Integer | 每页记录数目,取值范围:[1, 50],注:默认值为10 | 10 |
请求参数
请求头header参数
无
请求体body参数
无
响应参数
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
totalCount | Integer | 列表条目数 | 20 | |
currentCount | Integer | 分页查询时每页的行数 | 4 | |
totalPage | Integer | 总页数 | 5 | |
statusCode | Integer | 返回状态码(800为成功,900为失败) | 800 | |
returnObj | Array of Objects | 详细结果 | returnObj | |
errorCode | String | 错误码,为product.module.code三段式码 | Openapi.PatternCheck.NotValid | |
error | String | 错误码,为product.module.code三段式码 | Openapi.PatternCheck.NotValid | |
message | String | 错误信息的英文描述 | success | |
description | String | 失败时的错误描述,一般为中文描述。 | 请求为空 |
表 returnObj
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
securityGroupName | String | 安全组名称 | Default-Security-Group | |
id | String | 安全组id | 4fc90292-5ab4-59bb-xxxx-8b9410df41f5 | |
vmNum | String | 相关云主机 | 10 | |
origin | String | 表示是否是默认安全组 | 0 | |
vpcName | String | vpc名称 | vpc-pm0628 | |
vpcID | String | 安全组所属的专有网络 | 86fff760-d78c-xxxx-8730-9c04c932eefd | |
creationTime | String | 创建时间 | 2022-06-28T12:19:43Z | |
description | String | 安全组描述信息 | dasfsdf | |
securityGroupRuleList | Array of Objects | 安全组规则信息 | securityGroupRuleList |
表 securityGroupRuleList
参数 | 参数类型 | 说明 | 示例 | 下级对象 |
---|---|---|---|---|
direction | String | 出方向-egress、入方向-ingress | egress | |
action | String | 拒绝策略:允许-accept 拒绝-drop | accept | |
origin | String | 来源 | user | |
priority | Integer | 优先级:0~100 | 100 | |
ethertype | String | IP类型:IPv4、IPv6 | IPv4 | |
protocol | String | 协议: ANY、TCP、UDP、ICMP、ICMP6 | ANY | |
range | String | 接口范围/ICMP类型:1-65535 | 20-30 | |
destCidrIp | String | 远端地址:0.0.0.0/0 | 0.0.0.0/0 | |
description | String | 安全组规则描述信息 | 出方向 | |
createTime | String | 创建时间,UTC时间 | 2022-06-28T20:19:43Z | |
id | String | 唯一标识ID | 6135ab21-84f6-xxxx-89aa-a654f01389d6 | |
securityGroupID | String | 安全组ID | 4fc90292-5ab4-59bb-xxxx-8b9410df41f5 |
枚举参数
无
请求示例
请求url
示例1:指定每页记录数目,指定页安全组信息
华东1指定每页记录数目为3,查看第2页安全组信息
GET “{endpoint}/v4/ecs/vpc/query-security-groups?regionID=bb9fdb42056f11eda1610242ac110002&pageNo=2&pageSize=3”
示例2:查询指定虚拟私有云下安全组信息
华东1查询vpcID为vpc-qfnsjbkrls下的安全组信息
GET “{endpoint}/v4/ecs/vpc/query-security-groups?regionID=bb9fdb42056f11eda1610242ac110002&vpcID=vpc-qfnsjbkrls”
示例3:模糊查询安全组信息
华东1查询名称或id中含有test的安全组信息
GET “{endpoint}/v4/ecs/vpc/query-security-groups?regionID=bb9fdb42056f11eda1610242ac110002&queryContent=test”
示例4:查询指定企业项目下的安全组信息
华东1查询企业项目ID为6732237e53bc4591b0e67d750030ebe3的安全组信息
GET “{endpoint}/v4/ecs/vpc/query-security-groups?regionID=bb9fdb42056f11eda1610242ac110002&projectID=6732237e53bc4591b0e67d750030ebe3”
示例5:查询指定弹性云主机下的安全组信息
华东1查询云主机ID为adc614e0-e838-d73f-0618-a6d51d09070a的安全组信息
GET “{endpoint}/v4/ecs/vpc/query-security-groups?regionID=bb9fdb42056f11eda1610242ac110002&instanceID=adc614e0-e838-d73f-0618-a6d51d09070a”
请求头header
无
请求体body
无
响应示例
{
"statusCode": 800,
"errorCode": "SUCCESS",
"message": "SUCCESS",
"description": "成功",
"returnObj": [
{
"securityGroupName": "Default-Security-Group",
"id": "sg-8hikg37xjs",
"vmNum": 0,
"origin": "0",
"vpcName": "vpc-yf-openapi",
"vpcID": "vpc-3piveayzqx",
"creationTime": "2022-10-11T06:53:52Z",
"description": "",
"securityGroupRuleList": [
{
"direction": "egress",
"priority": 100,
"ethertype": "IPv4",
"protocol": "ANY",
"range": "1-65535",
"destCidrIp": "0.0.0.0/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-g2v16hdklm",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "egress",
"priority": 100,
"ethertype": "IPv6",
"protocol": "ANY",
"range": "1-65535",
"destCidrIp": "::/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-a0rwrecd04",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 100,
"ethertype": "IPv4",
"protocol": "ANY",
"range": "1-65535",
"destCidrIp": "0.0.0.0/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-rwqm90qry6",
"action": "drop",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 100,
"ethertype": "IPv6",
"protocol": "ANY",
"range": "1-65535",
"destCidrIp": "::/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-7netutxpa9",
"action": "drop",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv4",
"protocol": "ICMP",
"range": "1-65535",
"destCidrIp": "0.0.0.0/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-r3jwcp5n4p",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv6",
"protocol": "ICMP6",
"range": "1-65535",
"destCidrIp": "::/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-q7g0gg8njc",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv4",
"protocol": "TCP",
"range": "22",
"destCidrIp": "0.0.0.0/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-5rfaasqkxw",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv6",
"protocol": "TCP",
"range": "22",
"destCidrIp": "::/0",
"description": "成功",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-8t1zfipv5k",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv4",
"protocol": "TCP",
"range": "3389",
"destCidrIp": "0.0.0.0/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-70zg4a497q",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
},
{
"direction": "ingress",
"priority": 99,
"ethertype": "IPv6",
"protocol": "TCP",
"range": "3389",
"destCidrIp": "::/0",
"description": "",
"origin": "user",
"createTime": "2022-10-11T14:53:52Z",
"id": "sgrule-x033ueqlce",
"action": "accept",
"securityGroupID": "sg-8hikg37xjs"
}
]
},
{
"securityGroupName": "yypostman01",
"id": "sg-t8c9e3v3pj",
"vmNum": 0,
"origin": "1",
"vpcName": "vipvpc231",
"vpcID": "vpc-qfnsjbkrls",
"creationTime": "2022-10-10T07:03:13Z",
"description": "1010yypostman01",
"securityGroupRuleList": [],
"projectID": "0"
}
],
"currentCount": 10,
"totalCount": 74,
"totalPage": 8
}
状态码
请参考 状态码
错误码
请参考 错误码