撤销安全组规则
更新时间:2026-06-22
- 该接口用于撤销安全组中的规则。
- 同一安全组中的规则以remark、protocol、direction、portRange、sourceIp|destIp、sourceGroupId|destGroupId六元组作为唯一性索引。若安全组中不存在对应的规则,将报404错误。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1PUT /v{version}/securityGroup/{securityGroupId}?revokeRule&sgVersion={sgVersion} HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "rule" : {
7 "remark" : remark,
8 "direction" : direction,
9 "ethertype" : ethertype,
10 "portRange" : portRange,
11 "protocol" : protocol,
12 "sourceGroupId" : sourceGroupId,
13 "sourceIp" : sourceIp,
14 "destGroupId" : destGroupId,
15 "destIp" : destIp,
16 "securityGroupId" : securityGroupId,
17 "securityGroupRuleId" : securityGroupRuleId,
18 "createdTime" : createdTime,
19 "updatedTime" : updatedTime
20 }
21}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号 |
| securityGroupId | String | 是 | URL参数 | 待撤销安全组规则的安全组ID |
| sgVersion | int | 否 | Query参数 | 安全组版本号,用于乐观锁控制 |
| rule | SecurityGroupRuleModel | 是 | RequestBody参数 | 待撤销的安全组规则 |
返回头域
除公共头域,无其它特殊头域。
返回参数
无特殊返回参数。
错误码
| 错误码 | 错误描述 | HTTP状态码 | 中文解释 |
|---|---|---|---|
| SecurityGroup.RulePortOrderInvalid | The order of security group rule port is incorrect. | 400 | 安全组规则端口顺序不正确 |
| SecurityGroup.RulePortRangeInvalid | The value of security group rule port is exceeded. | 400 | 安全组规则的端口数字超出允许范围 |
| SecurityGroup.RulePortInvalid | The value of security group rule port must be number. | 400 | 安全组规则端口非数字 |
| VersionMismatch | The sgVersion is mismatch. | 400 | 指定安全组规则版本号和当前最新版本不一致。若请求中没有携带sgVersion参数,则不会返回该错误码。 |
| NoSuchObject | The specified object is not found or resource do not exist. | 404 | 目标安全组不存在 |
| SecurityGroup.RuleNotExist | The Security group rule is not exist. | 404 | 撤销的安全组规则不存在 |
请求示例
Plain Text
1PUT /v2/securityGroup/g-nky7qeom?revokeRule HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4
5{
6 "rule": {
7 "remark": "备注",
8 "protocol": "tcp",
9 "portRange": "1-65535",
10 "direction": "ingress",
11 "sourceIp": "",
12 "sourceGroupId": ""
13 }
14}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
评价此篇文章
