批量添加安全组规则
所有文档
menu

边缘计算节点 BEC

批量添加安全组规则

产品详情立即开通

接口描述

  • 该接口用于向安全组中添加新的安全组规则
  • 同一安全组中的规则以protocol、direction、portRange、sourceIp | destIp六元组作为唯一性索引,若安全组中已存在相同的规则将报409错误。

请求结构

POST /v1/securityGroup/{securityGroupId}/rule/batch/{action} HTTP/1.1
Host: bec.baidubce.com
Authorization: authorization string

{
	"rules": [
		{
			"protocol": protocol,
			"portRange": portRange,
			"direction": direction,
			"sourceIp": sourceIp,
            "remark": "备注"
		}
     ]
}

请求头域

除公共头域外,无其它特殊头域。

请求参数

参数名称 类型 是否必需 参数位置 描述
securityGroupId String URL参数 目标安全组ID
action String Query参数 对安全组执行动作,当前取值add
rules List<SecurityGroupRule> RequestBody参数 待添加的安全组规则列表

返回头域

除公共头域,无其它特殊头域。

返回参数

参数名称 类型 描述
result Boolean 返回结果,true:表示成功;false:表示失败。
action String 操作描述
details Details 返回结果,类型为String

请求示例

POST /v1/securityGroup/sg-nky7qeom/rule/batch/add HTTP/1.1
Host: bec.baidubce.com
Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2021-08-11T04:17:29Z/3600/host/uuid

{
	"rules": [
		{
			"remark": "备注",
			"protocol": "tcp",
			"portRange": "1-65535",
			"direction": "ingress",
			"sourceIp": ""
		}
    ]
}

返回示例

HTTP/1.1 200 OK
x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
Date: Wed, 03 Dec 2014 06:42:19 GMT
Content-Type: application/json;charset=UTF-8
Server: BWS	

{
    "result": true,
    "action": "add",
    "details": {
        "id": "sg-m1pxebfd",
        "name": "test",
        "desc": "",
        "rules": [
            {
                "securityGroupRuleId": "sgr-m1pxebfd-vtlzdbkd",
                "direction": "egress",
                "protocol": "icmp",
                "remark": "PING请求_IPv4",
                "etherType": "IPv4",
                "destIp": "0.0.0.0/0"
            },
            {
                "securityGroupRuleId": "sgr-m1pxebfd-awq69vfm",
                "direction": "ingress",
                "protocol": "tcp",
                "portRange": "1-65535",
                "remark": "备注",
                "etherType": "IPv4",
                "sourceIp": "0.0.0.0/0"
            }
        ],
        "isDefault": false
    }
}

Model对象定义


Details

参数名称 类型 描述
id String 安全组ID
name String 名称
desc String 描述
rules List<SecurityGroupRule> 安全组规则

SecurityGroupRule

参数名称 类型 描述
direction String 入站/出站,取值ingress或egress。
etherType String 网络类型,取值IPv4。暂不支持IPv6
portRange String 端口范围,可以指定80等单个端口,也可以指定范围如80-9000。 值为空时默认取值1-65535
protocol String 协议类型,tcp、udp或icmp,值为空时默认为所有协议
sourceIp String 源IP地址
destIp String 目的IP地址
remark String 备注
上一篇
更新安全组规则
下一篇
查询安全组列表