文档目录

防火墙相关接口

创建防火墙(CreateVpcFirewall)

API请求

URLs
POST zstack/v1/vpcfirewalls
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "vpcUuid": "bc370cafacc83fad8f3ad583dea8da12",
    "description": "example-des",
    "name": "example-name"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vpcUuid":"bc370cafacc83fad8f3ad583dea8da12","description":"example-des","name":"example-name"}}' http://localhost:8080/zstack/v1/vpcfirewalls
参数列表
名字 类型 位置 描述 可选值 起始版本
vpcUuid String body(包含在params结构中) VPC路由器UUID 4.0.0
description (可选) String body(包含在params结构中) 资源的详细描述 3.6.0
name String body(包含在params结构中) 资源名称 3.6.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.0.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.6.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

返回示例
{
  "inventory": {
    "name": "name",
    "refs": [
      {
        "id": 1.0,
        "ruleSetUuid": "06fc56b0483a3bf487b9cdfeaa6c4be2",
        "l3NetworkUuid": "27e1a95342083ce4a790d4f9dcf7f9bd",
        "packetsForwardType": "in",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "description": "example-des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
description String 资源的详细描述 3.6.0
refs List 详情参考refs 3.6.0
#refs
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3NetworkUuid String 4.0.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
CreateVpcFirewallAction action = new CreateVpcFirewallAction();
action.vpcUuid = "bc370cafacc83fad8f3ad583dea8da12";
action.description = "example-des";
action.name = "example-name";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVpcFirewallAction.Result res = action.call();
Python SDK
CreateVpcFirewallAction action = CreateVpcFirewallAction()
action.vpcUuid = "bc370cafacc83fad8f3ad583dea8da12"
action.description = "example-des"
action.name = "example-name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVpcFirewallAction.Result res = action.call()

查询防火墙(QueryVpcFirewall)

API请求

URLs
GET zstack/v1/vpcfirewalls
GET zstack/v1/vpcfirewalls/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/98631b6cb2b33384b780e1ef61aff0d0

可查询字段

运行CLI命令行工具,输入QueryVpcFirewall并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "name": "name",
      "refs": [
        {
          "id": 1.0,
          "ruleSetUuid": "01a959eec095396eaed841c886219eec",
          "l3NetworkUuid": "76cbd34de351334bbd0f51ee0653d0ab",
          "packetsForwardType": "in",
          "createDate": "Nov 14, 2017 10:20:57 PM",
          "lastOpDate": "Nov 14, 2017 10:20:57 PM"
        }
      ],
      "description": "example-des"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventories List 详情参考inventories 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
description String 资源的详细描述 3.6.0
refs List 详情参考refs 3.6.0
#refs
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3NetworkUuid String 4.0.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
QueryVpcFirewallAction action = new QueryVpcFirewallAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVpcFirewallAction.Result res = action.call();
Python SDK
QueryVpcFirewallAction action = QueryVpcFirewallAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryVpcFirewallAction.Result res = action.call()

更新防火墙(UpdateVpcFirewall)

API请求

URLs
PUT zstack/v1/vpcfirewalls/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateVpcFirewall": {
    "description": "example-des",
    "name": "example-name"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateVpcFirewall":{"description":"example-des","name":"example-name"}}' http://localhost:8080/zstack/v1/vpcfirewalls/822689d1957d30378fe0c200df72f33a/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
description (可选) String body(包含在updateVpcFirewall结构中) 资源的详细描述 3.6.0
name (可选) String body(包含在updateVpcFirewall结构中) 资源名称 3.6.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

返回示例
{
  "inventory": {
    "name": "example-name",
    "refs": [
      {
        "id": 1.0,
        "ruleSetUuid": "b3074e9040ef3a2ea30d5843a85b3cdb",
        "l3NetworkUuid": "a53439b32bc133b2a95bd09c9a8c5b67",
        "packetsForwardType": "in",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "description": "example-des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
description String 资源的详细描述 3.6.0
refs List 详情参考refs 3.6.0
#ruleSets
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
vpcFirewallUuid String 3.6.0
description String 资源的详细描述 3.6.0
isDefault boolean 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
actionType ActionType 详情参考actionType 3.6.0
#actionType
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#refs
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3Uuid String 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
UpdateVpcFirewallAction action = new UpdateVpcFirewallAction();
action.uuid = "822689d1957d30378fe0c200df72f33a";
action.description = "example-des";
action.name = "example-name";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVpcFirewallAction.Result res = action.call();
Python SDK
UpdateVpcFirewallAction action = UpdateVpcFirewallAction()
action.uuid = "822689d1957d30378fe0c200df72f33a"
action.description = "example-des"
action.name = "example-name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateVpcFirewallAction.Result res = action.call()

刷新防火墙配置(RefreshFirewall)

API请求

URLs
PUT zstack/v1/vpcfirewalls/refresh/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "refreshFirewall": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"refreshFirewall":{}}' http://localhost:8080/zstack/v1/vpcfirewalls/refresh/f461b936af043aa89aa2bdeb221085e7/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

返回示例
{
  "inventory": {
    "name": "name",
    "refs": [
      {
        "id": 1.0,
        "ruleSetUuid": "05cc1e225ef83107b6075d758c8dcee2",
        "l3NetworkUuid": "178e23cc9fdc3673b90ee258fe60395f",
        "packetsForwardType": "in",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "description": "example-des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
description String 资源的详细描述 3.6.0
refs List 详情参考refs 3.6.0
#refs
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3NetworkUuid String 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
RefreshFirewallAction action = new RefreshFirewallAction();
action.uuid = "f461b936af043aa89aa2bdeb221085e7";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RefreshFirewallAction.Result res = action.call();
Python SDK
RefreshFirewallAction action = RefreshFirewallAction()
action.uuid = "f461b936af043aa89aa2bdeb221085e7"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RefreshFirewallAction.Result res = action.call()

删除防火墙(DeleteFirewall)

API请求

URLs
DELETE zstack/v1/vpcfirewalls/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/09b37275fd073e4db292628ea260dd20?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
deleteMode (可选) String body 删除模式
  • Permissive
  • Enforcing
4.0.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteFirewallAction action = new DeleteFirewallAction();
action.uuid = "09b37275fd073e4db292628ea260dd20";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFirewallAction.Result res = action.call();
Python SDK
DeleteFirewallAction action = DeleteFirewallAction()
action.uuid = "09b37275fd073e4db292628ea260dd20"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFirewallAction.Result res = action.call()

创建防火墙规则集(CreateFirewallRuleSet)

API请求

URLs
POST zstack/v1/vpcfirewalls/ruleSets
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"name","vpcFirewallUuid":"e9a77f42bdbb3b5692012c6007a5893a","actionType":"drop","description":"example-des"}}' http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 3.6.0
actionType (可选) String body(包含在params结构中) 动作
  • drop
  • accept
  • reject
3.6.0
description (可选) String body(包含在params结构中) 资源的详细描述 3.6.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 3.6.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.6.0
systemTags (可选) List body 系统标签 3.6.0
userTags (可选) List body 用户标签 3.6.0

API返回

返回示例
{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleSetInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
description String 资源的详细描述 3.6.0
isDefault boolean 3.6.0
isApplied boolean 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
actionType ActionType 详情参考actionType 3.6.0
rules List 详情参考rules 3.6.0
#actionType
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#rules
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isDefault boolean 是否为系统规则 3.6.0
isApplied boolean 是否已在使用 4.0.0
expired boolean 是否是过期规则 4.0.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
CreateFirewallRuleSetAction action = new CreateFirewallRuleSetAction();
action.name = "name";
action.vpcFirewallUuid = "e9a77f42bdbb3b5692012c6007a5893a";
action.actionType = "drop";
action.description = "example-des";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFirewallRuleSetAction.Result res = action.call();
Python SDK
CreateFirewallRuleSetAction action = CreateFirewallRuleSetAction()
action.name = "name"
action.vpcFirewallUuid = "e9a77f42bdbb3b5692012c6007a5893a"
action.actionType = "drop"
action.description = "example-des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFirewallRuleSetAction.Result res = action.call()

查询防火墙规则集(QueryFirewallRuleSet)

API请求

URLs
GET zstack/v1/vpcfirewalls/ruleSets
GET zstack/v1/vpcfirewalls/ruleSets/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets/a26016d5c50a3908a0692d57d033c154

可查询字段

运行CLI命令行工具,输入QueryFirewallRuleSet并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "name": "name",
      "actionType": "drop",
      "description": "example-des",
      "enableDefaultLog": false,
      "isDefault": false,
      "isApplied": false
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventories List 详情参考inventories 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
description String 资源的详细描述 3.6.0
isDefault boolean 3.6.0
isApplied boolean 4.0.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
actionType ActionType 详情参考actionType 3.6.0
rules List 详情参考rules 3.6.0
#actionType
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#rules
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isDefault boolean 是否为系统规则 3.6.0
isApplied boolean 是否已在使用 4.0.0
expired boolean 是否是过期规则 4.0.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
QueryFirewallRuleSetAction action = new QueryFirewallRuleSetAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleSetAction.Result res = action.call();
Python SDK
QueryFirewallRuleSetAction action = QueryFirewallRuleSetAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFirewallRuleSetAction.Result res = action.call()

更新防火墙规则集(UpdateFirewallRuleSet)

API请求

URLs
PUT zstack/v1/vpcfirewalls/ruleSets/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateFirewallRuleSet": {
    "description": "example-des",
    "actionType": "drop"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFirewallRuleSet":{"description":"example-des","actionType":"drop"}}' http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets/6b93eca80a9032c3a567b2e3af0f03db/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
name (可选) String body(包含在updateFirewallRuleSet结构中) 资源名称 3.6.0
description (可选) String body(包含在updateFirewallRuleSet结构中) 资源的详细描述 3.6.0
actionType (可选) String body(包含在updateFirewallRuleSet结构中)
  • drop
  • accept
  • reject
3.6.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

返回示例
{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleSetInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
name String 资源名称 3.6.0
description String 资源的详细描述 3.6.0
isDefault boolean 3.6.0
isApplied boolean 4.0.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
actionType ActionType 详情参考actionType 3.6.0
rules List See rules 3.6.0
#actionType
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isApplied boolean 是否已在使用 4.0.0
expired boolean 是否是过期规则 4.0.0
isDefault boolean 是否为系统规则 3.6.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
UpdateFirewallRuleSetAction action = new UpdateFirewallRuleSetAction();
action.uuid = "6b93eca80a9032c3a567b2e3af0f03db";
action.description = "example-des";
action.actionType = "drop";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFirewallRuleSetAction.Result res = action.call();
Python SDK
UpdateFirewallRuleSetAction action = UpdateFirewallRuleSetAction()
action.uuid = "6b93eca80a9032c3a567b2e3af0f03db"
action.description = "example-des"
action.actionType = "drop"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFirewallRuleSetAction.Result res = action.call()

删除防火墙规则集(DeleteFirewallRuleSet)

API请求

URLs
DELETE zstack/v1/vpcfirewalls/ruleSets/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets/62b6ef32f6573f01929c5020d976bd66?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
deleteMode (可选) String body 删除模式
  • Permissive
  • Enforcing
4.0.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteFirewallRuleSetAction action = new DeleteFirewallRuleSetAction();
action.uuid = "62b6ef32f6573f01929c5020d976bd66";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFirewallRuleSetAction.Result res = action.call();
Python SDK
DeleteFirewallRuleSetAction action = DeleteFirewallRuleSetAction()
action.uuid = "62b6ef32f6573f01929c5020d976bd66"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFirewallRuleSetAction.Result res = action.call()

网络加载防火墙规则集(AttachFirewallRuleSetToL3)

API请求

URLs
POST zstack/v1/vpcfirewalls/ruleSets/{ruleSetUuid}/l3networks/{l3Uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "vpcFirewallUuid": "d5a0a7ce8bdf315a87189bb3f1c12f98",
    "forward": "in"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vpcFirewallUuid":"d5a0a7ce8bdf315a87189bb3f1c12f98","forward":"in"}}' http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets/c9ada0bdf0ec3b0a87e534030e4d9b8c/l3networks/b552d497789f3609a764e03fbdf535ad
参数列表
名字 类型 位置 描述 可选值 起始版本
vpcFirewallUuid String body(包含在params结构中) 3.6.0
l3Uuid String url 3.6.0
forward String body(包含在params结构中)
  • in
  • out
3.6.0
ruleSetUuid String url 3.6.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

返回示例
{
  "inventory": {
    "id": 1.0,
    "ruleSetUuid": "91e9fed42a113c0395a81920c4179a43",
    "l3NetworkUuid": "ad2bbeb82973334fa0ab243f52088fea",
    "packetsForwardType": "in",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleSetL3RefInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3NetworkUuid String 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
AttachFirewallRuleSetToL3Action action = new AttachFirewallRuleSetToL3Action();
action.vpcFirewallUuid = "d5a0a7ce8bdf315a87189bb3f1c12f98";
action.l3Uuid = "b552d497789f3609a764e03fbdf535ad";
action.forward = "in";
action.ruleSetUuid = "c9ada0bdf0ec3b0a87e534030e4d9b8c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachFirewallRuleSetToL3Action.Result res = action.call();
Python SDK
AttachFirewallRuleSetToL3Action action = AttachFirewallRuleSetToL3Action()
action.vpcFirewallUuid = "d5a0a7ce8bdf315a87189bb3f1c12f98"
action.l3Uuid = "b552d497789f3609a764e03fbdf535ad"
action.forward = "in"
action.ruleSetUuid = "c9ada0bdf0ec3b0a87e534030e4d9b8c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachFirewallRuleSetToL3Action.Result res = action.call()

网络卸载防火墙规则集(DetachFirewallRuleSetFromL3)

API请求

URLs
POST zstack/v1/vpcfirewalls/l3networks/{l3Uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "vpcFirewallUuid": "582cdc20cf313b8696da15f67f71c38f",
    "forward": "in"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vpcFirewallUuid":"582cdc20cf313b8696da15f67f71c38f","forward":"in"}}' http://localhost:8080/zstack/v1/vpcfirewalls/l3networks/912cc5a14b193c2fa76290eac7046230
参数列表
名字 类型 位置 描述 可选值 起始版本
vpcFirewallUuid String body(包含在params结构中) 防火墙uuid 3.6.0
l3Uuid String url 三层网络uuid 4.0.0
forward String body(包含在params结构中) 方向
  • in
  • out
4.0.0
ruleSetUuid String url 4.0.0
systemTags (可选) List body 系统标签 3.6.0
userTags (可选) List body 用标签 3.6.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DetachFirewallRuleSetFromL3Action action = new DetachFirewallRuleSetFromL3Action();
action.vpcFirewallUuid = "582cdc20cf313b8696da15f67f71c38f";
action.l3Uuid = "912cc5a14b193c2fa76290eac7046230";
action.forward = "in";
action.ruleSetUuid = "a54a917869733b5590053eb3f4505089";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachFirewallRuleSetFromL3Action.Result res = action.call();
Python SDK
DetachFirewallRuleSetFromL3Action action = DetachFirewallRuleSetFromL3Action()
action.vpcFirewallUuid = "582cdc20cf313b8696da15f67f71c38f"
action.l3Uuid = "912cc5a14b193c2fa76290eac7046230"
action.forward = "in"
action.ruleSetUuid = "a54a917869733b5590053eb3f4505089"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachFirewallRuleSetFromL3Action.Result res = action.call()

查询防火墙规则集与三层网络关联关系(QueryFirewallRuleSetL3Ref)

API请求

URLs
GET zstack/v1/vpcfirewalls/l3networks/rulesets/refs
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/l3networks/rulesets/refs

可查询字段

运行CLI命令行工具,输入QueryFirewallRuleSetL3Ref并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "id": 1.0,
      "ruleSetUuid": "f4575926f7a13c82a0d610dfac995ffa",
      "l3NetworkUuid": "85044a1e0ccb3c859c0b024e967fb191",
      "packetsForwardType": "in",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventories List 详情参考inventories 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventories
名字 类型 描述 起始版本
id long 3.6.0
ruleSetUuid String 3.6.0
l3NetworkUuid String 3.6.0
vpcFirewallUuid String 3.6
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
packetsForwardType PacketsForwardType 详情参考packetsForwardType 3.6.0
#packetsForwardType
名字 类型 描述 起始版本
in PacketsForwardType 3.6.0
out PacketsForwardType 3.6.0
local PacketsForwardType 3.6.0

SDK示例

Java SDK
QueryFirewallRuleSetL3RefAction action = new QueryFirewallRuleSetL3RefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleSetL3RefAction.Result res = action.call();
Python SDK
QueryFirewallRuleSetL3RefAction action = QueryFirewallRuleSetL3RefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFirewallRuleSetL3RefAction.Result res = action.call()

创建防火墙规则(CreateFirewallRule)

API请求

URLs
POST /v1/vpcfirewalls/rules
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "ruleSetUuid": "0079c9339a7f32d69c289119ff223d81",
    "action": "accept",
    "protocol": "tcp",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "description": "example rule des"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vpcFirewallUuid":"bd79e42aa97f360585e91a8defa639e2","ruleSetUuid":"0e453dd8d6543540ac4ae293806c9d04","action":"accept","protocol":"tcp","destPort":"22","sourcePort":"22","sourceIp":"192.168.1.2","destIp":"192.168.1.1","allowStates":"invalid,new","tcpFlag":"SYN","icmpTypeName":"echo-reply","ruleNumber":1001.0,"enableLog":false,"state":"disable","description":"example rule des"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules
参数列表
名字 类型 位置 描述 可选值 起始版本
ruleSetUuid String body(包含在params结构中) 规则集uuid 3.6.0
action String body(包含在params结构中) 动作
  • drop
  • accept
  • reject
3.6.0
protocol (可选) String body(包含在params结构中) 协议 3.6.0
destPort (可选) String body(包含在params结构中) 目标端口 3.6.0
sourcePort (可选) String body(包含在params结构中) 源端口 3.6.0
sourceIp (可选) String body(包含在params结构中) 源ip 3.6.0
destIp (可选) String body(包含在params结构中) 目标ip 3.6.0
allowStates (可选) String body(包含在params结构中) 允许状态 3.6.0
tcpFlag (可选) String body(包含在params结构中) tcp flag 3.6.0
icmpTypeName (可选) String body(包含在params结构中) icmpType 3.6.0
ruleNumber Integer body(包含在params结构中) 优先级 3.6.0
enableLog (可选) boolean body(包含在params结构中) 是否开启日志 3.6.0
state String body(包含在params结构中) 状态
  • enable
  • disable
3.6.0
description (可选) String body(包含在params结构中) 资源的详细描述 3.6.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 3.6.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.6.0
systemTags (可选) List body 系统标签 3.6.0
userTags (可选) List body 用户标签 3.6.0

API返回

返回示例
{
  "inventory": {
    "ruleSetUuid": "34db2df69d593f0b893a2cc9035bd2f3",
    "action": "accept",
    "protocol": "TCP",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "ruleNumber": 1001.0,
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "enableLog": false,
    "isApplied": true,
    "expired": false,
    "state": "disable",
    "isDefault": false,
    "description": "example rule des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isApplied boolean 是否为系统规则 4.0.0
expired boolean 是否已在使用 4.0.0
isDefault boolean 是否是过期规则 3.6.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
CreateFirewallRuleAction action = new CreateFirewallRuleAction();
action.vpcFirewallUuid = "bd79e42aa97f360585e91a8defa639e2";
action.ruleSetUuid = "0e453dd8d6543540ac4ae293806c9d04";
action.action = "accept";
action.protocol = "tcp";
action.destPort = "22";
action.sourcePort = "22";
action.sourceIp = "192.168.1.2";
action.destIp = "192.168.1.1";
action.allowStates = "invalid,new";
action.tcpFlag = "SYN";
action.icmpTypeName = "echo-reply";
action.ruleNumber = 1001.0;
action.enableLog = false;
action.state = "disable";
action.description = "example rule des";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFirewallRuleAction.Result res = action.call();
Python SDK
CreateFirewallRuleAction action = CreateFirewallRuleAction()
action.vpcFirewallUuid = "bd79e42aa97f360585e91a8defa639e2"
action.ruleSetUuid = "0e453dd8d6543540ac4ae293806c9d04"
action.action = "accept"
action.protocol = "tcp"
action.destPort = "22"
action.sourcePort = "22"
action.sourceIp = "192.168.1.2"
action.destIp = "192.168.1.1"
action.allowStates = "invalid,new"
action.tcpFlag = "SYN"
action.icmpTypeName = "echo-reply"
action.ruleNumber = 1001.0
action.enableLog = false
action.state = "disable"
action.description = "example rule des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFirewallRuleAction.Result res = action.call()

通过文件创建防火墙规则(CreateFirewallRuleFromConfigFile)

API请求

URLs
POST zstack/v1/vpcfirewalls/rules/from-file
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "ruleInfo": "[{\"ruleNumber\":1004,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ICMP\",\"tcpFlag\":null,\"icmpTypeName\":\"echo-reply\",\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.41\",\"destIp\":\"192.168.0.50\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1003,\"action\":\"reject\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"UDP\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":\"77\",\"destPort\":\"88\",\"sourceIp\":\"192.168.0.31\",\"destIp\":\"192.168.0.40\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1002,\"action\":\"drop\",\"allowStates\":\"new,invalid,related\",\"protocol\":\"TCP\",\"tcpFlag\":\"SYN,ACK\",\"icmpTypeName\":null,\"sourcePort\":\"55\",\"destPort\":\"66\",\"sourceIp\":\"192.168.0.21\",\"destIp\":\"192.168.0.30\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1001,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ALL\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.10\",\"destIp\":\"192.168.0.20\",\"description\":null,\"state\":\"enable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"}]"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"params":{"ruleInfo":"[{\"ruleNumber\":1004,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ICMP\",\"tcpFlag\":null,\"icmpTypeName\":\"echo-reply\",\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.41\",\"destIp\":\"192.168.0.50\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1003,\"action\":\"reject\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"UDP\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":\"77\",\"destPort\":\"88\",\"sourceIp\":\"192.168.0.31\",\"destIp\":\"192.168.0.40\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1002,\"action\":\"drop\",\"allowStates\":\"new,invalid,related\",\"protocol\":\"TCP\",\"tcpFlag\":\"SYN,ACK\",\"icmpTypeName\":null,\"sourcePort\":\"55\",\"destPort\":\"66\",\"sourceIp\":\"192.168.0.21\",\"destIp\":\"192.168.0.30\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1001,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ALL\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.10\",\"destIp\":\"192.168.0.20\",\"description\":null,\"state\":\"enable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"}]"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/from-file
参数列表
名字 类型 位置 描述 可选值 起始版本
ruleInfo String body(包含在params结构中) 防火墙规则信息 4.4.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.4.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.4.0
systemTags (可选) List body 4.4.0
userTags (可选) List body 4.4.0

API返回

返回示例
{
  "inventory": [
    {
      "name": "name",
      "actionType": "drop",
      "description": "example-des",
      "enableDefaultLog": false,
      "isDefault": false,
      "isApplied": true
    }
  ]
}
名字 类型 描述 起始版本
success boolean 4.4.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.4.0
inventory VpcFirewallRuleSetInventory 详情参考inventory 4.4.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.4.0
description String 错误的概要描述 4.4.0
details String 错误的详细信息 4.4.0
elaboration String 保留字段,默认为null 4.4.0
opaque LinkedHashMap 保留字段,默认为null 4.4.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.4.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.4.0
name String 资源名称 4.4.0
description String 资源的详细描述 4.4.0
isDefault boolean 4.4.0
isApplied boolean 4.4.0
createDate Timestamp 创建时间 4.4.0
lastOpDate Timestamp 最后一次修改时间 4.4.0
actionType ActionType 详情参考actionType 4.4.0
#actionType
名字 类型 描述 起始版本
drop ActionType 4.4.0
reject ActionType 4.4.0
accept ActionType 4.4.0

SDK示例

Java SDK
CreateFirewallRuleFromConfigFileAction action = new CreateFirewallRuleFromConfigFileAction();
action.ruleInfo = "[{"ruleNumber":1004,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ICMP","tcpFlag":null,"icmpTypeName":"echo-reply","sourcePort":null,"destPort":null,"sourceIp":"192.168.0.41","destIp":"192.168.0.50","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1003,"action":"reject","allowStates":"new,established,invalid,related","protocol":"UDP","tcpFlag":null,"icmpTypeName":null,"sourcePort":"77","destPort":"88","sourceIp":"192.168.0.31","destIp":"192.168.0.40","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1002,"action":"drop","allowStates":"new,invalid,related","protocol":"TCP","tcpFlag":"SYN,ACK","icmpTypeName":null,"sourcePort":"55","destPort":"66","sourceIp":"192.168.0.21","destIp":"192.168.0.30","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1001,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ALL","tcpFlag":null,"icmpTypeName":null,"sourcePort":null,"destPort":null,"sourceIp":"192.168.0.10","destIp":"192.168.0.20","description":null,"state":"enable", "ruleSetUuid": "${defaultRuleSet.uuid}"}]";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFirewallRuleFromConfigFileAction.Result res = action.call();
Python SDK
CreateFirewallRuleFromConfigFileAction action = CreateFirewallRuleFromConfigFileAction()
action.ruleInfo = "[{"ruleNumber":1004,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ICMP","tcpFlag":null,"icmpTypeName":"echo-reply","sourcePort":null,"destPort":null,"sourceIp":"192.168.0.41","destIp":"192.168.0.50","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1003,"action":"reject","allowStates":"new,established,invalid,related","protocol":"UDP","tcpFlag":null,"icmpTypeName":null,"sourcePort":"77","destPort":"88","sourceIp":"192.168.0.31","destIp":"192.168.0.40","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1002,"action":"drop","allowStates":"new,invalid,related","protocol":"TCP","tcpFlag":"SYN,ACK","icmpTypeName":null,"sourcePort":"55","destPort":"66","sourceIp":"192.168.0.21","destIp":"192.168.0.30","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1001,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ALL","tcpFlag":null,"icmpTypeName":null,"sourcePort":null,"destPort":null,"sourceIp":"192.168.0.10","destIp":"192.168.0.20","description":null,"state":"enable", "ruleSetUuid": "${defaultRuleSet.uuid}"}]"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFirewallRuleFromConfigFileAction.Result res = action.call()

查询防火墙规则(QueryFirewallRule)

API请求

URLs
GET zstack/v1/vpcfirewalls/rules
GET zstack/v1/vpcfirewalls/rules/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/rules
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/rules/ace430872549342fbaca32f1d4c333e1

可查询字段

运行CLI命令行工具,输入QueryFirewallRule并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "ruleSetUuid": "9fe12b6d1b3d38dbab13405722ccf264",
      "action": "accept",
      "protocol": "TCP",
      "destPort": "22",
      "sourcePort": "22",
      "sourceIp": "192.168.1.2",
      "destIp": "192.168.1.1",
      "ruleNumber": 1001.0,
      "allowStates": "invalid,new",
      "tcpFlag": "SYN",
      "icmpTypeName": "echo-reply",
      "enableLog": false,
      "isApplied": true,
      "expired": false,
      "state": "disable",
      "isDefault": false,
      "description": "example rule des"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventories List 详情参考inventories 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isApplied boolean 是否为系统规则 4.0.0
expired boolean 是否已在使用 4.0.0
isDefault boolean 是否是过期规则 3.6.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
QueryFirewallRuleAction action = new QueryFirewallRuleAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleAction.Result res = action.call();
Python SDK
QueryFirewallRuleAction action = QueryFirewallRuleAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFirewallRuleAction.Result res = action.call()

更新防火墙规则(UpdateFirewallRule)

API请求

URLs
PUT zstack/v1/vpcfirewalls/rules/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateFirewallRule": {
    "ruleSetUuid": "c7b605d7c7e037f8b4df43bfe5a26d0f",
    "action": "accept",
    "protocol": "tcp",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "description": "example rule des"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFirewallRule":{"vpcFirewallUuid":"181da73e752432b283d3096bb29afb59","ruleSetUuid":"cb6db506c523354282aecf56acd4b78d","action":"accept","protocol":"tcp","destPort":"22","sourcePort":"22","sourceIp":"192.168.1.2","destIp":"192.168.1.1","allowStates":"invalid,new","tcpFlag":"SYN","icmpTypeName":"echo-reply","ruleNumber":1001.0,"enableLog":false,"state":"disable","description":"example rule des"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/7e9bd2ad1f48320d8782d737b262abb1/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
ruleSetUuid String body(包含在updateFirewallRule结构中) 规则集uuid 4.0.0
uuid String url 资源的UUID,唯一标示该资源 3.6.0
action String body(包含在updateFirewallRule结构中) 动作
  • drop
  • reject
  • accept
3.6.0
protocol (可选) String body(包含在updateFirewallRule结构中) 协议 3.6.0
destPort (可选) String body(包含在updateFirewallRule结构中) 目标端口 3.6.0
sourcePort (可选) String body(包含在updateFirewallRule结构中) 源端口 3.6.0
sourceIp (可选) String body(包含在updateFirewallRule结构中) 源ip 3.6.0
destIp (可选) String body(包含在updateFirewallRule结构中) 目标ip 3.6.0
allowStates (可选) String body(包含在updateFirewallRule结构中) 允许状态 3.6.0
tcpFlag (可选) String body(包含在updateFirewallRule结构中) tcp flag 3.6.0
icmpTypeName (可选) String body(包含在updateFirewallRule结构中) icmpType 3.6.0
ruleNumber Integer body(包含在updateFirewallRule结构中) 优先级 3.6.0
enableLog (可选) boolean body(包含在updateFirewallRule结构中) 是否开启日志 3.6.0
state String body(包含在updateFirewallRule结构中) 状态
  • enable
  • disable
3.6.0
description (可选) String body(包含在updateFirewallRule结构中) 资源的详细描述 3.6.0
systemTags (可选) List body 系统标签 3.6.0
userTags (可选) List body 标签UUID列表 3.6.0

API返回

返回示例
{
  "inventory": {
    "ruleSetUuid": "52099ab881ba30a09589fa0040a1b6a2",
    "action": "accept",
    "protocol": "TCP",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "ruleNumber": 1001.0,
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "enableLog": false,
    "isApplied": true,
    "expired": false,
    "state": "disable",
    "isDefault": false,
    "description": "example rule des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isApplied boolean 是否已在使用 4.0.0
expired boolean 是否是过期规则 4.0.0
isDefault boolean 是否为系统规则 3.6.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
UpdateFirewallRuleAction action = new UpdateFirewallRuleAction();
action.ruleSetUuid = "c7b605d7c7e037f8b4df43bfe5a26d0f";
action.uuid = "7e9bd2ad1f48320d8782d737b262abb1";
action.action = "accept";
action.protocol = "tcp";
action.destPort = "22";
action.sourcePort = "22";
action.sourceIp = "192.168.1.2";
action.destIp = "192.168.1.1";
action.allowStates = "invalid,new";
action.tcpFlag = "SYN";
action.icmpTypeName = "echo-reply";
action.ruleNumber = 1001.0;
action.enableLog = false;
action.state = "disable";
action.description = "example rule des";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFirewallRuleAction.Result res = action.call();
Python SDK
UpdateFirewallRuleAction action = UpdateFirewallRuleAction()
action.ruleSetUuid = "c7b605d7c7e037f8b4df43bfe5a26d0f"
action.uuid = "7e9bd2ad1f48320d8782d737b262abb1"
action.action = "accept"
action.protocol = "tcp"
action.destPort = "22"
action.sourcePort = "22"
action.sourceIp = "192.168.1.2"
action.destIp = "192.168.1.1"
action.allowStates = "invalid,new"
action.tcpFlag = "SYN"
action.icmpTypeName = "echo-reply"
action.ruleNumber = 1001.0
action.enableLog = false
action.state = "disable"
action.description = "example rule des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFirewallRuleAction.Result res = action.call()

删除防火墙规则(DeleteFirewallRule)

API请求

URLs
DELETE zstack/v1/vpcfirewalls/rules/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/rules/6238605440b535dd9f7d5d033a732659?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
deleteMode (可选) String body 删除模式
  • Permissive
  • Enforcing
4.0.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteFirewallRuleAction action = new DeleteFirewallRuleAction();
action.uuid = "6238605440b535dd9f7d5d033a732659";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFirewallRuleAction.Result res = action.call();
Python SDK
DeleteFirewallRuleAction action = DeleteFirewallRuleAction()
action.uuid = "6238605440b535dd9f7d5d033a732659"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFirewallRuleAction.Result res = action.call()

检查添加防火墙规则文件合法性(CheckFirewallRuleConfigFile)

API请求

URLs
POST zstack/v1/vpcfirewalls/rules/from-file/check
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "ruleInfo": "[{\"ruleNumber\":1004,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ICMP\",\"tcpFlag\":null,\"icmpTypeName\":\"echo-reply\",\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.41\",\"destIp\":\"192.168.0.50\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1003,\"action\":\"reject\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"UDP\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":\"77\",\"destPort\":\"88\",\"sourceIp\":\"192.168.0.31\",\"destIp\":\"192.168.0.40\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1002,\"action\":\"drop\",\"allowStates\":\"new,invalid,related\",\"protocol\":\"TCP\",\"tcpFlag\":\"SYN,ACK\",\"icmpTypeName\":null,\"sourcePort\":\"55\",\"destPort\":\"66\",\"sourceIp\":\"192.168.0.21\",\"destIp\":\"192.168.0.30\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1001,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ALL\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.10\",\"destIp\":\"192.168.0.20\",\"description\":null,\"state\":\"enable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"}]"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"params":{"ruleInfo":"[{\"ruleNumber\":1004,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ICMP\",\"tcpFlag\":null,\"icmpTypeName\":\"echo-reply\",\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.41\",\"destIp\":\"192.168.0.50\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1003,\"action\":\"reject\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"UDP\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":\"77\",\"destPort\":\"88\",\"sourceIp\":\"192.168.0.31\",\"destIp\":\"192.168.0.40\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1002,\"action\":\"drop\",\"allowStates\":\"new,invalid,related\",\"protocol\":\"TCP\",\"tcpFlag\":\"SYN,ACK\",\"icmpTypeName\":null,\"sourcePort\":\"55\",\"destPort\":\"66\",\"sourceIp\":\"192.168.0.21\",\"destIp\":\"192.168.0.30\",\"description\":null,\"state\":\"disable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"},{\"ruleNumber\":1001,\"action\":\"accept\",\"allowStates\":\"new,established,invalid,related\",\"protocol\":\"ALL\",\"tcpFlag\":null,\"icmpTypeName\":null,\"sourcePort\":null,\"destPort\":null,\"sourceIp\":\"192.168.0.10\",\"destIp\":\"192.168.0.20\",\"description\":null,\"state\":\"enable\", \"ruleSetUuid\": \"${defaultRuleSet.uuid}\"}]"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/from-file/check
参数列表
名字 类型 位置 描述 可选值 起始版本
ruleInfo String body(包含在params结构中) 防火墙规则信息 4.4.0
systemTags (可选) List body 4.4.0
userTags (可选) List body 4.4.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
CheckFirewallRuleConfigFileAction action = new CheckFirewallRuleConfigFileAction();
action.ruleInfo = "[{"ruleNumber":1004,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ICMP","tcpFlag":null,"icmpTypeName":"echo-reply","sourcePort":null,"destPort":null,"sourceIp":"192.168.0.41","destIp":"192.168.0.50","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1003,"action":"reject","allowStates":"new,established,invalid,related","protocol":"UDP","tcpFlag":null,"icmpTypeName":null,"sourcePort":"77","destPort":"88","sourceIp":"192.168.0.31","destIp":"192.168.0.40","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1002,"action":"drop","allowStates":"new,invalid,related","protocol":"TCP","tcpFlag":"SYN,ACK","icmpTypeName":null,"sourcePort":"55","destPort":"66","sourceIp":"192.168.0.21","destIp":"192.168.0.30","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1001,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ALL","tcpFlag":null,"icmpTypeName":null,"sourcePort":null,"destPort":null,"sourceIp":"192.168.0.10","destIp":"192.168.0.20","description":null,"state":"enable", "ruleSetUuid": "${defaultRuleSet.uuid}"}]";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckFirewallRuleConfigFileAction.Result res = action.call();
Python SDK
CheckFirewallRuleConfigFileAction action = CheckFirewallRuleConfigFileAction()
action.ruleInfo = "[{"ruleNumber":1004,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ICMP","tcpFlag":null,"icmpTypeName":"echo-reply","sourcePort":null,"destPort":null,"sourceIp":"192.168.0.41","destIp":"192.168.0.50","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1003,"action":"reject","allowStates":"new,established,invalid,related","protocol":"UDP","tcpFlag":null,"icmpTypeName":null,"sourcePort":"77","destPort":"88","sourceIp":"192.168.0.31","destIp":"192.168.0.40","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1002,"action":"drop","allowStates":"new,invalid,related","protocol":"TCP","tcpFlag":"SYN,ACK","icmpTypeName":null,"sourcePort":"55","destPort":"66","sourceIp":"192.168.0.21","destIp":"192.168.0.30","description":null,"state":"disable", "ruleSetUuid": "${defaultRuleSet.uuid}"},{"ruleNumber":1001,"action":"accept","allowStates":"new,established,invalid,related","protocol":"ALL","tcpFlag":null,"icmpTypeName":null,"sourcePort":null,"destPort":null,"sourceIp":"192.168.0.10","destIp":"192.168.0.20","description":null,"state":"enable", "ruleSetUuid": "${defaultRuleSet.uuid}"}]"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CheckFirewallRuleConfigFileAction.Result res = action.call()

更改防火墙规则状态(ChangeFirewallRuleState)

API请求

URLs
PUT zstack/v1/vpcfirewalls/rules/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changeFirewallRuleState": {
    "state": "disable"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeFirewallRuleState":{"state":"disable"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/4eef3024e5bd36f38be22b5af9807b20/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.6.0
state String body(包含在changeFirewallRuleState结构中) 状态
  • enable
  • disable
3.6.0
systemTags (可选) List body 3.6.0
userTags (可选) List body 3.6.0

API返回

返回示例
{
  "inventory": {
    "ruleSetUuid": "387ccd99cb2b3374a24f86108c3b8653",
    "action": "accept",
    "protocol": "TCP",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "ruleNumber": 1001.0,
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "enableLog": false,
    "isApplied": true,
    "expired": false,
    "isDefault": false,
    "description": "example rule des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventory VpcFirewallRuleInventory 详情参考inventory 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.6.0
ruleSetUuid String 防火墙规则集uuid 3.6.0
destPort String 目标端口 3.6.0
sourcePort String 源端口 3.6.0
sourceIp String 源ip 3.6.0
destIp String 目的ip 3.6.0
ruleNumber Integer 优先级 3.6.0
allowStates String 检测报文状态 3.6.0
tcpFlag String tcpFlag 3.6.0
icmpTypeName String icmpType 3.6.0
isDefault boolean 是否为系统规则 3.6.0
isApplied boolean 是否已在使用 4.0.0
expired boolean 是否是过期规则 4.0.0
description String 资源的详细描述 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0
action ActionType 详情参考action 3.6.0
protocol ProtocolType 详情参考protocol 3.6.0
state FirewallRuleState 详情参考state 3.6.0
#action
名字 类型 描述 起始版本
drop ActionType 3.6.0
reject ActionType 3.6.0
accept ActionType 3.6.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 3.6.0
all ProtocolType 3.6.0
ah ProtocolType 3.6.0
ax.25 ProtocolType 3.6.0
dccp ProtocolType 3.6.0
ddp ProtocolType 3.6.0
egp ProtocolType 3.6.0
eigrp ProtocolType 3.6.0
encap ProtocolType 3.6.0
esp ProtocolType 3.6.0
etherip ProtocolType 3.6.0
fc ProtocolType 3.6.0
ggp ProtocolType 3.6.0
gre ProtocolType 3.6.0
hip ProtocolType 3.6.0
hmp ProtocolType 3.6.0
icmp ProtocolType 3.6.0
ipdr-cmtp ProtocolType 3.6.0
idpr ProtocolType 3.6.0
igmp ProtocolType 3.6.0
igp ProtocolType 3.6.0
ip ProtocolType 3.6.0
ipcomp ProtocolType 3.6.0
ipencap ProtocolType 3.6.0
ipip ProtocolType 3.6.0
isis ProtocolType 3.6.0
iso-tp4 ProtocolType 3.6.0
l2tp ProtocolType 3.6.0
manet ProtocolType 3.6.0
mpls-in-ip ProtocolType 3.6.0
ospf ProtocolType 3.6.0
pim ProtocolType 3.6.0
pup ProtocolType 3.6.0
rdp ProtocolType 3.6.0
rohc ProtocolType 3.6.0
rspf ProtocolType 3.6.0
rsvp ProtocolType 3.6.0
sctp ProtocolType 3.6.0
skip ProtocolType 3.6.0
st ProtocolType 3.6.0
tcp ProtocolType 3.6.0
udp ProtocolType 3.6.0
udplite ProtocolType 3.6.0
vmtp ProtocolType 3.6.0
vrrp ProtocolType 3.6.0
wesp ProtocolType 3.6.0
xns-idp ProtocolType 3.6.0
xtp ProtocolType 3.6.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 3.6.0
enable FirewallRuleState 3.6.0

SDK示例

Java SDK
ChangeFirewallRuleStateAction action = new ChangeFirewallRuleStateAction();
action.uuid = "4eef3024e5bd36f38be22b5af9807b20";
action.state = "disable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeFirewallRuleStateAction.Result res = action.call();
Python SDK
ChangeFirewallRuleStateAction action = ChangeFirewallRuleStateAction()
action.uuid = "4eef3024e5bd36f38be22b5af9807b20"
action.state = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeFirewallRuleStateAction.Result res = action.call()

创建防火墙规则模板(CreateFirewallRuleTemplate)

API请求

URLs
POST zstack/v1/vpcfirewalls/rules/template
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "action": "accept",
    "protocol": "tcp",
    "name": "rule-template",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "description": "example rule des"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"action":"accept","protocol":"tcp","name":"rule-template","destPort":"22","sourcePort":"22","sourceIp":"192.168.1.2","destIp":"192.168.1.1","allowStates":"invalid,new","tcpFlag":"SYN","icmpTypeName":"echo-reply","ruleNumber":1001.0,"enableLog":false,"state":"disable","description":"example rule des"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/template
参数列表
名字 类型 位置 描述 可选值 起始版本
action String body(包含在params结构中)
  • drop
  • reject
  • accept
4.0.0
protocol (可选) String body(包含在params结构中) 4.0.0
name String body(包含在params结构中) 资源名称 4.0.0
destPort (可选) String body(包含在params结构中) 4.0.0
sourcePort (可选) String body(包含在params结构中) 4.0.0
sourceIp (可选) String body(包含在params结构中) 4.0.0
destIp (可选) String body(包含在params结构中) 4.0.0
allowStates (可选) String body(包含在params结构中) 4.0.0
tcpFlag (可选) String body(包含在params结构中) 4.0.0
icmpTypeName (可选) String body(包含在params结构中) 4.0.0
ruleNumber Integer body(包含在params结构中) 4.0.0
enableLog (可选) boolean body(包含在params结构中) 4.0.0
state (可选) String body(包含在params结构中) 4.0.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.0.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.0.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

返回示例
{
  "inventory": {
    "action": "accept",
    "protocol": "TCP",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "isDefault": false,
    "description": "example rule des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallRuleTemplateInventory 详情参考inventory 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.0.0
destPort String 4.0.0
sourcePort String 4.0.0
sourceIp String 4.0.0
destIp String 4.0.0
allowStates String 4.0.0
tcpFlag String 4.0.0
icmpTypeName String 4.0.0
ruleNumber int 4.0.0
enableLog boolean 4.0.0
isDefault boolean 4.0.0
description String 资源的详细描述 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
action ActionType 详情参考action 4.0.0
protocol ProtocolType 详情参考protocol 4.0.0
state FirewallRuleState 详情参考state 4.0.0
#action
名字 类型 描述 起始版本
drop ActionType 4.0.0
reject ActionType 4.0.0
accept ActionType 4.0.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 4.0.0
all ProtocolType 4.0.0
ah ProtocolType 4.0.0
ax.25 ProtocolType 4.0.0
dccp ProtocolType 4.0.0
ddp ProtocolType 4.0.0
egp ProtocolType 4.0.0
eigrp ProtocolType 4.0.0
encap ProtocolType 4.0.0
esp ProtocolType 4.0.0
etherip ProtocolType 4.0.0
fc ProtocolType 4.0.0
ggp ProtocolType 4.0.0
gre ProtocolType 4.0.0
hip ProtocolType 4.0.0
hmp ProtocolType 4.0.0
icmp ProtocolType 4.0.0
ipdr-cmtp ProtocolType 4.0.0
idpr ProtocolType 4.0.0
igmp ProtocolType 4.0.0
igp ProtocolType 4.0.0
ip ProtocolType 4.0.0
ipcomp ProtocolType 4.0.0
ipencap ProtocolType 4.0.0
ipip ProtocolType 4.0.0
isis ProtocolType 4.0.0
iso-tp4 ProtocolType 4.0.0
l2tp ProtocolType 4.0.0
manet ProtocolType 4.0.0
pls-in-ip ProtocolType 4.0.0
ospf ProtocolType 4.0.0
pim ProtocolType 4.0.0
pup ProtocolType 4.0.0
rdp ProtocolType 4.0.0
rohc ProtocolType 4.0.0
rspf ProtocolType 4.0.0
rsvp ProtocolType 4.0.0
sctp ProtocolType 4.0.0
skip ProtocolType 4.0.0
st ProtocolType 4.0.0
tcp ProtocolType 4.0.0
udp ProtocolType 4.0.0
udplite ProtocolType 4.0.0
vmtp ProtocolType 4.0.0
vrrp ProtocolType 4.0.0
wesp ProtocolType 4.0.0
xns-idp ProtocolType 4.0.0
xtp ProtocolType 4.0.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 4.0.0
enable FirewallRuleState 4.0.0

SDK示例

Java SDK
CreateFirewallRuleTemplateAction action = new CreateFirewallRuleTemplateAction();
action.action = "accept";
action.protocol = "tcp";
action.name = "rule-template";
action.destPort = "22";
action.sourcePort = "22";
action.sourceIp = "192.168.1.2";
action.destIp = "192.168.1.1";
action.allowStates = "invalid,new";
action.tcpFlag = "SYN";
action.icmpTypeName = "echo-reply";
action.ruleNumber = 1001.0;
action.enableLog = false;
action.state = "disable";
action.description = "example rule des";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFirewallRuleTemplateAction.Result res = action.call();
Python SDK
CreateFirewallRuleTemplateAction action = CreateFirewallRuleTemplateAction()
action.action = "accept"
action.protocol = "tcp"
action.name = "rule-template"
action.destPort = "22"
action.sourcePort = "22"
action.sourceIp = "192.168.1.2"
action.destIp = "192.168.1.1"
action.allowStates = "invalid,new"
action.tcpFlag = "SYN"
action.icmpTypeName = "echo-reply"
action.ruleNumber = 1001.0
action.enableLog = false
action.state = "disable"
action.description = "example rule des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFirewallRuleTemplateAction.Result res = action.call()

删除防火墙规则模板(DeleteFirewallRuleTemplate)

API请求

URLs
DELETE zstack/v1/vpcfirewalls/ipset/templates/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/rules/templates/8de197dab6af3e30b7131bc6d50f935d?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
deleteMode (可选) String body 删除模式
  • Permissive
  • Enforcing
4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteFirewallRuleTemplateAction action = new DeleteFirewallRuleTemplateAction();
action.uuid = "8de197dab6af3e30b7131bc6d50f935d";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFirewallRuleTemplateAction.Result res = action.call();
Python SDK
DeleteFirewallRuleTemplateAction action = DeleteFirewallRuleTemplateAction()
action.uuid = "8de197dab6af3e30b7131bc6d50f935d"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFirewallRuleTemplateAction.Result res = action.call()

更新防火墙规则模板(UpdateFirewallRuleTemplate)

API请求

URLs
PUT zstack/v1/vpcfirewalls/rules/template/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateFirewallRuleTemplate": {
    "name": "rule-template-name",
    "action": "accept",
    "protocol": "tcp",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "description": "example rule des"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFirewallRuleTemplate":{"name":"rule-template-name","action":"accept","protocol":"tcp","destPort":"22","sourcePort":"22","sourceIp":"192.168.1.2","destIp":"192.168.1.1","allowStates":"invalid,new","tcpFlag":"SYN","icmpTypeName":"echo-reply","ruleNumber":1001.0,"enableLog":false,"state":"disable","description":"example rule des"}}' http://localhost:8080/zstack/v1/vpcfirewalls/rules/template/0e85a35457763de9bc0a4d19d15e4630/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
name String body(包含在updateFirewallRuleTemplate结构中) 资源名称 4.0.0
action String body(包含在updateFirewallRuleTemplate结构中)
  • drop
  • reject
  • accept
4.0.0
protocol (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
destPort (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
sourcePort (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
sourceIp (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
destIp (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
allowStates (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
tcpFlag (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
icmpTypeName (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
ruleNumber Integer body(包含在updateFirewallRuleTemplate结构中) 4.0.0
enableLog (可选) boolean body(包含在updateFirewallRuleTemplate结构中) 4.0.0
state (可选) String body(包含在updateFirewallRuleTemplate结构中) 4.0.0
description (可选) String body(包含在updateFirewallRuleTemplate结构中) 资源的详细描述 4.0.0
resourceUuid (可选) String body(包含在updateFirewallRuleTemplate结构中) 资源UUID 4.0.0
tagUuids (可选) List body(包含在updateFirewallRuleTemplate结构中) 标签UUID列表 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

返回示例
{
  "inventory": {
    "action": "accept",
    "protocol": "TCP",
    "destPort": "22",
    "sourcePort": "22",
    "sourceIp": "192.168.1.2",
    "destIp": "192.168.1.1",
    "allowStates": "invalid,new",
    "tcpFlag": "SYN",
    "icmpTypeName": "echo-reply",
    "ruleNumber": 1001.0,
    "enableLog": false,
    "state": "disable",
    "isDefault": false,
    "description": "example rule des"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallRuleTemplateInventory 详情参考inventory 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.0.0
destPort String 4.0.0
sourcePort String 4.0.0
sourceIp String 4.0.0
destIp String 4.0.0
allowStates String 4.0.0
tcpFlag String 4.0.0
icmpTypeName String 4.0.0
ruleNumber int 4.0.0
enableLog boolean 4.0.0
isDefault boolean 4.0.0
description String 资源的详细描述 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
action ActionType 详情参考action 4.0.0
protocol ProtocolType 详情参考protocol 4.0.0
state FirewallRuleState 详情参考state 4.0.0
#action
名字 类型 描述 起始版本
drop ActionType 4.0.0
reject ActionType 4.0.0
accept ActionType 4.0.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 4.0.0
all ProtocolType 4.0.0
ah ProtocolType 4.0.0
ax.25 ProtocolType 4.0.0
dccp ProtocolType 4.0.0
ddp ProtocolType 4.0.0
egp ProtocolType 4.0.0
eigrp ProtocolType 4.0.0
encap ProtocolType 4.0.0
esp ProtocolType 4.0.0
etherip ProtocolType 4.0.0
fc ProtocolType 4.0.0
ggp ProtocolType 4.0.0
gre ProtocolType 4.0.0
hip ProtocolType 4.0.0
hmp ProtocolType 4.0.0
icmp ProtocolType 4.0.0
ipdr-cmtp ProtocolType 4.0.0
idpr ProtocolType 4.0.0
igmp ProtocolType 4.0.0
igp ProtocolType 4.0.0
ip ProtocolType 4.0.0
ipcomp ProtocolType 4.0.0
ipencap ProtocolType 4.0.0
ipip ProtocolType 4.0.0
isis ProtocolType 4.0.0
iso-tp4 ProtocolType 4.0.0
l2tp ProtocolType 4.0.0
manet ProtocolType 4.0.0
pls-in-ip ProtocolType 4.0.0
ospf ProtocolType 4.0.0
pim ProtocolType 4.0.0
pup ProtocolType 4.0.0
rdp ProtocolType 4.0.0
rohc ProtocolType 4.0.0
rspf ProtocolType 4.0.0
rsvp ProtocolType 4.0.0
sctp ProtocolType 4.0.0
skip ProtocolType 4.0.0
st ProtocolType 4.0.0
tcp ProtocolType 4.0.0
udp ProtocolType 4.0.0
udplite ProtocolType 4.0.0
vmtp ProtocolType 4.0.0
vrrp ProtocolType 4.0.0
wesp ProtocolType 4.0.0
xns-idp ProtocolType 4.0.0
xtp ProtocolType 4.0.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 4.0.0
enable FirewallRuleState 4.0.0

SDK示例

Java SDK
UpdateFirewallRuleTemplateAction action = new UpdateFirewallRuleTemplateAction();
action.uuid = "0e85a35457763de9bc0a4d19d15e4630";
action.name = "rule-template-name";
action.action = "accept";
action.protocol = "tcp";
action.destPort = "22";
action.sourcePort = "22";
action.sourceIp = "192.168.1.2";
action.destIp = "192.168.1.1";
action.allowStates = "invalid,new";
action.tcpFlag = "SYN";
action.icmpTypeName = "echo-reply";
action.ruleNumber = 1001.0;
action.enableLog = false;
action.state = "disable";
action.description = "example rule des";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFirewallRuleTemplateAction.Result res = action.call();
Python SDK
UpdateFirewallRuleTemplateAction action = UpdateFirewallRuleTemplateAction()
action.uuid = "0e85a35457763de9bc0a4d19d15e4630"
action.name = "rule-template-name"
action.action = "accept"
action.protocol = "tcp"
action.destPort = "22"
action.sourcePort = "22"
action.sourceIp = "192.168.1.2"
action.destIp = "192.168.1.1"
action.allowStates = "invalid,new"
action.tcpFlag = "SYN"
action.icmpTypeName = "echo-reply"
action.ruleNumber = 1001.0
action.enableLog = false
action.state = "disable"
action.description = "example rule des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFirewallRuleTemplateAction.Result res = action.call()

查询防火墙规则模板(QueryFirewallRuleTemplate)

API请求

URLs
GET zstack/v1/vpcfirewalls/rules/templates
GET zstack/v1/vpcfirewalls/rules/templates/uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/rules/templates
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/rules/templates/uuid}

可查询字段

运行CLI命令行工具,输入QueryVpcFirewallVRouterRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例:
{
  "inventories": [
    {
      "action": "accept",
      "protocol": "TCP",
      "destPort": "22",
      "sourcePort": "22",
      "sourceIp": "192.168.1.2",
      "destIp": "192.168.1.1",
      "allowStates": "invalid,new",
      "tcpFlag": "SYN",
      "icmpTypeName": "echo-reply",
      "ruleNumber": 1001.0,
      "enableLog": false,
      "state": "disable",
      "isDefault": false,
      "description": "example rule des"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory List 详情参考inventories 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventories
名字 类型 描述 起始版本
name String 资源名称 4.0.0
destPort String 4.0.0
sourcePort String 4.0.0
sourceIp String 4.0.0
destIp String 4.0.0
allowStates String 4.0.0
tcpFlag String 4.0.0
icmpTypeName String 4.0.0
ruleNumber int 4.0.0
enableLog boolean 4.0.0
isDefault boolean 4.0.0
description String 资源的详细描述 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
action ActionType 详情参考action 4.0.0
protocol ProtocolType 详情参考protocol 4.0.0
state FirewallRuleState 详情参考state 4.0.0
#action
名字 类型 描述 起始版本
drop ActionType 4.0.0
reject ActionType 4.0.0
accept ActionType 4.0.0
#protocol
名字 类型 描述 起始版本
tcp_udp ProtocolType 4.0.0
all ProtocolType 4.0.0
ah ProtocolType 4.0.0
ax.25 ProtocolType 4.0.0
dccp ProtocolType 4.0.0
ddp ProtocolType 4.0.0
egp ProtocolType 4.0.0
eigrp ProtocolType 4.0.0
encap ProtocolType 4.0.0
esp ProtocolType 4.0.0
etherip ProtocolType 4.0.0
fc ProtocolType 4.0.0
ggp ProtocolType 4.0.0
gre ProtocolType 4.0.0
hip ProtocolType 4.0.0
hmp ProtocolType 4.0.0
icmp ProtocolType 4.0.0
ipdr-cmtp ProtocolType 4.0.0
idpr ProtocolType 4.0.0
igmp ProtocolType 4.0.0
igp ProtocolType 4.0.0
ip ProtocolType 4.0.0
ipcomp ProtocolType 4.0.0
ipencap ProtocolType 4.0.0
ipip ProtocolType 4.0.0
isis ProtocolType 4.0.0
iso-tp4 ProtocolType 4.0.0
l2tp ProtocolType 4.0.0
manet ProtocolType 4.0.0
pls-in-ip ProtocolType 4.0.0
ospf ProtocolType 4.0.0
pim ProtocolType 4.0.0
pup ProtocolType 4.0.0
rdp ProtocolType 4.0.0
rohc ProtocolType 4.0.0
rspf ProtocolType 4.0.0
rsvp ProtocolType 4.0.0
sctp ProtocolType 4.0.0
skip ProtocolType 4.0.0
st ProtocolType 4.0.0
tcp ProtocolType 4.0.0
udp ProtocolType 4.0.0
udplite ProtocolType 4.0.0
vmtp ProtocolType 4.0.0
vrrp ProtocolType 4.0.0
wesp ProtocolType 4.0.0
xns-idp ProtocolType 4.0.0
xtp ProtocolType 4.0.0
#state
名字 类型 描述 起始版本
disable FirewallRuleState 4.0.0
enable FirewallRuleState 4.0.0

SDK示例

Java SDK
QueryFirewallRuleTemplateAction action = new QueryFirewallRuleTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleTemplateAction.Result res = action.call();
Python SDK
QueryFirewallRuleTemplateAction action = QueryFirewallRuleTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFirewallRuleTemplateAction.Result res = action.call()

查询防火墙与单节点路由器关联关系(QueryVpcFirewallVRouterRef)

API请求

URLs
GET zstack/v1/vpcfirewalls/vrouters/refs
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/vrouters/refs?

可查询字段

运行CLI命令行工具,输入QueryVpcFirewallVRouterRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "id": 1.0,
      "vpcFirewallUuid": "cd7ab20e4768316c86230f2d982ae5a5",
      "vRouterUuid": "7013faeb3b4736d1800749b1e910a845",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.6.0
inventories List 详情参考inventories 3.6.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.6.0
description String 错误的概要描述 3.6.0
details String 错误的详细信息 3.6.0
elaboration String 保留字段,默认为null 3.6.0
opaque LinkedHashMap 保留字段,默认为null 3.6.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.6.0
#inventories
名字 类型 描述 起始版本
id long 3.6.0
vpcFirewallUuid String 3.6.0
vRouterUuid String 3.6.0
createDate Timestamp 创建时间 3.6.0
lastOpDate Timestamp 最后一次修改时间 3.6.0

SDK示例

Java SDK
QueryVpcFirewallVRouterRefAction action = new QueryVpcFirewallVRouterRefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVpcFirewallVRouterRefAction.Result res = action.call();
Python SDK
QueryVpcFirewallVRouterRefAction action = QueryVpcFirewallVRouterRefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryVpcFirewallVRouterRefAction.Result res = action.call()

下发规则集更改内容到路由器(ApplyRuleSetChanges)

API请求

URLs
PUT zstack/v1/vpcfirewalls/ruleSets/apply/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "applyRuleSetChanges": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"applyRuleSetChanges":{}}' http://localhost:8080/zstack/v1/vpcfirewalls/ruleSets/apply/e78b0b5ebe1c33159b0faa2d88a41b21/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
systemTags (可选) List body 4.0.0
userTags (可选) List body 4.0.0

API返回

返回示例
{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallRuleSetInventory 详情参考inventory 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.0.0
name String 资源名称 4.0.0
description String 资源的详细描述 4.0.0
isDefault boolean 4.0.0
isApplied boolean 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
actionType ActionType 详情参考actionType 4.0.0
#actionType
名字 类型 描述 起始版本
drop ActionType 4.0.0
reject ActionType 4.0.0
accept ActionType 4.0.0

SDK示例

Java SDK
ApplyRuleSetChangesAction action = new ApplyRuleSetChangesAction();
action.uuid = "e78b0b5ebe1c33159b0faa2d88a41b21";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ApplyRuleSetChangesAction.Result res = action.call();
Python SDK
ApplyRuleSetChangesAction action = ApplyRuleSetChangesAction()
action.uuid = "e78b0b5ebe1c33159b0faa2d88a41b21"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ApplyRuleSetChangesAction.Result res = action.call()

创建防火墙IP或端口模板(CreateFirewallIpSetTemplate)

API请求

URLs
POST zstack/v1/vpcfirewalls/ipset/templates
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"ipset-template","sourceValue":"192.168.1.2","destValue":"192.168.1.1,10.0.0.1/24","type":"ip"}}' http://localhost:8080/zstack/v1/vpcfirewalls/ipset/templates
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.0.0
sourceValue (可选) String body(包含在params结构中) 4.0.0
destValue (可选) String body(包含在params结构中) 4.0.0
type IpSetType body(包含在params结构中)
  • ip
  • port
4.0.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.0.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

返回示例
{
  "inventory": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallIpSetTemplateInventory 详情参考inventory 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.0.0
sourceValue String 4.0.0
destValue String 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
type IpSetType 详情参考type 4.0.0
#type
名字 类型 描述 起始版本
ip IpSetType 4.0.0
port IpSetType 4.0.0

SDK示例

Java SDK
CreateFirewallIpSetTemplateAction action = new CreateFirewallIpSetTemplateAction();
action.name = "ipset-template";
action.sourceValue = "192.168.1.2";
action.destValue = "192.168.1.1,10.0.0.1/24";
action.type = "ip";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFirewallIpSetTemplateAction.Result res = action.call();
Python SDK
CreateFirewallIpSetTemplateAction action = CreateFirewallIpSetTemplateAction()
action.name = "ipset-template"
action.sourceValue = "192.168.1.2"
action.destValue = "192.168.1.1,10.0.0.1/24"
action.type = "ip"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFirewallIpSetTemplateAction.Result res = action.call()

删除防火墙IP或端口模板(DeleteFirewallIpSetTemplate)

API请求

URLs
DELETE /v1/vpcfirewalls/ipset/templates/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/ipset/templates/e84fbe6b5a9c31a1b4b83cfde4028893?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
deleteMode (可选) String body 删除模式
  • Permissive
  • Enforcing
4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteFirewallIpSetTemplateAction action = new DeleteFirewallIpSetTemplateAction();
action.uuid = "e84fbe6b5a9c31a1b4b83cfde4028893";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFirewallIpSetTemplateAction.Result res = action.call();
Python SDK
DeleteFirewallIpSetTemplateAction action = DeleteFirewallIpSetTemplateAction()
action.uuid = "e84fbe6b5a9c31a1b4b83cfde4028893"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFirewallIpSetTemplateAction.Result res = action.call()

更新防火墙IP或端口模板(UpdateFirewallIpSetTemplate)

API请求

URLs
PUT zstack/v1/vpcfirewalls/ipset/templates/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateFirewallIpSetTemplate": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFirewallIpSetTemplate":{"name":"ipset-template","sourceValue":"192.168.1.2","destValue":"192.168.1.1,10.0.0.1/24","type":"ip"}}' http://localhost:8080/zstack/v1/vpcfirewalls/ipset/templates/c7df801f021e334f9d548eac2eb2cd47/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
name(可选) String body(包含在updateFirewallIpSetTemplate结构中) 资源名称 4.0.0
sourceValue (可选) String body(包含在updateFirewallIpSetTemplate结构中) 4.0.0
destValue (可选) String body(包含在updateFirewallIpSetTemplate结构中) 4.0.0
type IpSetType body(包含在updateFirewallIpSetTemplate结构中)
  • ip
  • port
4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

返回示例
{
  "inventory": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallRuleTemplateInventory 详情参考inventory 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventory
名字 类型 描述 起始版本
name String 资源名称 4.0.0
sourceValue String 4.0.0
destValue String 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
type IpSetType 详情参考type 4.0.0
#type
名字 类型 描述 起始版本
ip IpSetType 4.0.0
port IpSetType 4.0.0

SDK示例

Java SDK
UpdateFirewallIpSetTemplateAction action = new UpdateFirewallIpSetTemplateAction();
action.uuid = "c7df801f021e334f9d548eac2eb2cd47";
action.name = "ipset-template";
action.sourceValue = "192.168.1.2";
action.destValue = "192.168.1.1,10.0.0.1/24";
action.type = "ip";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFirewallIpSetTemplateAction.Result res = action.call();
Python SDK
UpdateFirewallIpSetTemplateAction action = UpdateFirewallIpSetTemplateAction()
action.uuid = "c7df801f021e334f9d548eac2eb2cd47"
action.name = "ipset-template"
action.sourceValue = "192.168.1.2"
action.destValue = "192.168.1.1,10.0.0.1/24"
action.type = "ip"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFirewallIpSetTemplateAction.Result res = action.call()

查询防火墙IP或端口模板(QueryFirewallIpSetTemplate)

API请求

URLs
GET zstack/v1/vpcfirewalls/ipset/templates
GET zstack/v1/vpcfirewalls/ipset/templates/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/ipset/templates
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/ipset/templates/fe6b68e5315035d88b02dd423de0342c

可查询字段

运行CLI命令行工具,输入QueryVpcFirewallVRouterRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例:
{
  "inventories": [
    {
      "name": "ipset-template",
      "sourceValue": "192.168.1.2",
      "destValue": "192.168.1.1,10.0.0.1/24",
      "type": "ip"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.0.0
inventory VpcFirewallIpSetTemplateInventory 详情参考inventories 4.0.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.0.0
description String 错误的概要描述 4.0.0
details String 错误的详细信息 4.0.0
elaboration String 保留字段,默认为null 4.0.0
opaque LinkedHashMap 保留字段,默认为null 4.0.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.0.0
#inventories
名字 类型 描述 起始版本
name long 资源名称 4.0.0
sourceValue String 4.0.0
destValue String 4.0.0
createDate Timestamp 创建时间 4.0.0
lastOpDate Timestamp 最后一次修改时间 4.0.0
accountUuid String 账户UUID 4.0.0
uuid String 资源的UUID,唯一标示该资源 4.0.0
type IpSetType 详情参考type 4.0.0
#type
名字 类型 描述 起始版本
ip IpSetType 4.0.0
port IpSetType 4.0.0

SDK示例

Java SDK
QueryFirewallIpSetTemplateAction action = new QueryFirewallIpSetTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallIpSetTemplateAction.Result res = action.call();
Python SDK
QueryFirewallIpSetTemplateAction action = QueryFirewallIpSetTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFirewallIpSetTemplateAction.Result res = action.call()
开发手册 | 4.8.38 | ZStack Cloud · ZCF | ZStack 资源中心