Document navigation

VPC Firewall Operations

CreateVpcFirewall

API Request

URLs

POST zstack/v1/vpcfirewalls

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "vpcUuid": "bc370cafacc83fad8f3ad583dea8da12",
    "description": "example-des",
    "name": "example-name"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
vpcUuid String body (contained in the params structure) The VPC UUID. 3.6.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 3.6.0
name String body (contained in the params structure) The resource name. 3.6.0
resourceUuid String body (contained in the params structure) Optional. 3.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
description String The detailed description of the resource. 3.6.0
refs List See refs. 3.6.0

#refs

Name Type Description Starting Version
id long The firewall rule number. 3.6.0
ruleSetUuid String The firewall rule set UUID. 3.6.0
l3Uuid String The L3 network UUID. 3.6.0
vpcFirewallUuid String The firewall UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType Ingress packet. 3.6.0
out PacketsForwardType Egress packet. 3.6.0

SDK Sample

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

action = CreateVpcFirewallAction()
action.vpcUuid = "bc370cafacc83fad8f3ad583dea8da12"
action.description = "example-des"
action.name = "example-name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryVpcFirewall

API Request

URLs

GET zstack/v1/vpcfirewalls
GET zstack/v1/vpcfirewalls/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryVpcFirewall, and pressing the Tab key.

API Response

Sample Response

{
  "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"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventories List See inventories. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventories

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
description String The detailed description of the resource. 3.6.0
refs List See refs. 3.6.0

#refs

Name Type Description Starting Version
id long The resource ID. 3.6.0
ruleSetUuid String The rule set UUID. 3.6.0
l3NetworkUuid String The L3 network UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType The in. 3.6.0
out PacketsForwardType The out. 3.6.0
local PacketsForwardType The local. 3.6.0

SDK Sample

Java SDK

QueryVpcFirewallAction action = new QueryVpcFirewallAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVpcFirewallAction.Result res = action.call();

Python SDK

action = QueryVpcFirewallAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdateVpcFirewall

API Request

URLs

PUT zstack/v1/vpcfirewalls/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "updateVpcFirewall": {
    "description": "example-des",
    "name": "example-name"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
description String body (contained in the updateVpcFirewall structure) Optional. The detailed description of the resource. 3.6.0
name String body (contained in the updateVpcFirewall structure) Optional. The resource name. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
description String The detailed description of the resource. 3.6.0
refs List See refs. 3.6.0

#refs

Name Type Description Starting Version
id long The resource ID. 3.6.0
ruleSetUuid String The rule set UUID. 3.6.0
l3Uuid String The L3 UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType The in. 3.6.0
out PacketsForwardType The out. 3.6.0
local PacketsForwardType The local. 3.6.0

SDK Sample

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

action = UpdateVpcFirewallAction()
action.uuid = "822689d1957d30378fe0c200df72f33a"
action.description = "example-des"
action.name = "example-name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

RefreshFirewall

API Request

URLs

PUT zstack/v1/vpcfirewalls/refresh/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "refreshFirewall": {},
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
description String The detailed description of the resource. 3.6.0
refs List See refs. 3.6.0

#refs

Name Type Description Starting Version
id long The resource ID. 3.6.0
ruleSetUuid String The rule set UUID. 3.6.0
l3Uuid String The L3 UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType The in. 3.6.0
out PacketsForwardType The out. 3.6.0
local PacketsForwardType The local. 3.6.0

SDK Sample

Java SDK

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

Python SDK

action = RefreshFirewallAction()
action.uuid = "f461b936af043aa89aa2bdeb221085e7"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

DeleteFirewall

API Request

URLs

DELETE zstack/v1/vpcfirewalls/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vpcfirewalls/09b37275fd073e4db292628ea260dd20?deleteMode=Permissive

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
deleteMode String body Optional. The delete mode.
  • Permissive
  • Enforcing
4.0.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK

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

Python SDK

action = DeleteFirewallAction()
action.uuid = "09b37275fd073e4db292628ea260dd20"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

CreateFirewallRuleSet

API Request

URLs

POST zstack/v1/vpcfirewalls/ruleSets

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The ruleset name. 3.6.0
actionType String body (contained in the params structure) Optional. The action taken against data packets.
  • drop
  • accept
  • reject
3.6.0
description String body (contained in the params structure) Optional. The detailed description of the ruleset. 3.6.0
resourceUuid String body (contained in the params structure) Optional. The ruleset UUID. 3.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUIDs. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleSetInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
description String The detailed description of the resource. 3.6.0
isDefault boolean Whether the resource is default. 3.6.0
isApplied boolean Indicates whether the ruleset is applied. 4.0.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
actionType ActionType See actionType. 3.6.0
rules List See rules. 3.6.0

#actionType

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#rules

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String The allow status of data packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isApplied boolean Indicates whether the rule is applied. 4.0.0
expired boolean Indicates whether the rule is expired. 4.0.0
isDefault boolean Indicates whether the rule is a system rule. 3.6.0
description String The detailed description of the rule. 3.6.0
createDate Timestamp The time when the rule was created. 3.6.0
lastOpDate Timestamp The time when the rule was last modified. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

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

action = CreateFirewallRuleSetAction()
action.name = "name"
action.vpcFirewallUuid = "e9a77f42bdbb3b5692012c6007a5893a"
action.actionType = "drop"
action.description = "example-des"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryFirewallRuleSet

API Request

URLs

GET zstack/v1/vpcfirewalls/ruleSets
GET zstack/v1/vpcfirewalls/ruleSets/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryFirewallRuleSet, and pressing the Tab key.

API Response

Sample Response

{
  "inventories": [
    {
      "name": "name",
      "actionType": "drop",
      "description": "example-des",
      "enableDefaultLog": false,
      "isDefault": false,
      "isApplied": false
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventories List See inventories. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventories

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
description String The detailed description of the resource. 3.6.0
isDefault boolean Whether the resource is default. 3.6.0
isApplied boolean Whether the resource is applied. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
actionType ActionType See actionType. 3.6.0
rules List See rules. 3.6.0

#actionType

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#rules

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String The allow status of data packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isApplied boolean Indicates whether the rule is applied. 4.0.0
expired boolean Indicates whether the rule is expired. 4.0.0
isDefault boolean Indicates whether the rule is a system rule. 3.6.0
description String The detailed description of the rule. 3.6.0
createDate Timestamp The time when the rule was created. 3.6.0
lastOpDate Timestamp The time when the rule was last modified. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

Java SDK

QueryFirewallRuleSetAction action = new QueryFirewallRuleSetAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleSetAction.Result res = action.call();

Python SDK

action = QueryFirewallRuleSetAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdateFirewallRuleSet

API Request

URLs

PUT zstack/v1/vpcfirewalls/ruleSets/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "updateFirewallRuleSet": {
    "description": "example-des",
    "actionType": "drop"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
name String body (contained in the updateFirewallRuleSet structure) Optional. The resource name. 3.6.0
description String body (contained in the updateFirewallRuleSet structure) Optional. The detailed description of the resource. 3.6.0
actionType String body (contained in the updateFirewallRuleSet structure) Optional. The action type.
  • drop
  • accept
  • reject
3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleSetInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
name String The resource name. 3.6.0
description String The detailed description of the resource. 3.6.0
isDefault boolean Whether the resource is default. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
actionType ActionType See actionType. 3.6.0
rules List See rules 3.6.0

#actionType

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#rules

Name Type Description Starting Version
uuid String The resource UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of a rule. 3.6.0
allowStates String The state of packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isApplied boolean Indicates whether the ruleset is applied. 4.0.0
expired boolean Indicates whether the ruleset is expired. 4.0.0
isDefault boolean Indicates whether the ruleset is the default ruleset. 3.6.0
description String The detailed description of the ruleset. 3.6.0
createDate Timestamp The time when the ruleset was created. 3.6.0
lastOpDate Timestamp The time when the ruleset was modified. 3.6.0
action ActionType See action 3.6.0
protocol ProtocolType See protocolprotocol 3.6.0
state FirewallRuleState See state 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

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

action = UpdateFirewallRuleSetAction()
action.uuid = "6b93eca80a9032c3a567b2e3af0f03db"
action.description = "example-des"
action.actionType = "drop"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

DeleteFirewallRuleSet

API Request

URLs

DELETE zstack/v1/vpcfirewalls/ruleSets/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
deleteMode String body Optional. The delete mode.
  • Permissive
  • Enforcing
4.0.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK

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

Python SDK

action = DeleteFirewallRuleSetAction()
action.uuid = "62b6ef32f6573f01929c5020d976bd66"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

AttachFirewallRuleSetToL3

API Request

URLs

POST zstack/v1/vpcfirewalls/ruleSets/{ruleSetUuid}/l3networks/{l3Uuid}

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "vpcFirewallUuid": "d5a0a7ce8bdf315a87189bb3f1c12f98",
    "forward": "in"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
vpcFirewallUuid String body (contained in the params structure) The VPC firewall UUID. 3.6.0
l3Uuid String url The L3 UUID. 3.6.0
forward String body (contained in the params structure) The forward.
  • in
  • out
3.6.0
ruleSetUuid String url The rule set UUID. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleSetL3RefInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
id long The resource ID. 3.6.0
ruleSetUuid String The rule set UUID. 3.6.0
l3NetworkUuid String The L3 network UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType The in. 3.6.0
out PacketsForwardType The out. 3.6.0
local PacketsForwardType The local. 3.6.0

SDK Sample

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

action = AttachFirewallRuleSetToL3Action()
action.vpcFirewallUuid = "d5a0a7ce8bdf315a87189bb3f1c12f98"
action.l3Uuid = "b552d497789f3609a764e03fbdf535ad"
action.forward = "in"
action.ruleSetUuid = "c9ada0bdf0ec3b0a87e534030e4d9b8c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

DetachFirewallRuleSetFromL3

API Request

URLs

POST zstack/v1/vpcfirewalls/l3networks/{l3Uuid}

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "vpcFirewallUuid": "582cdc20cf313b8696da15f67f71c38f",
    "forward": "in"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
vpcFirewallUuid String body (contained in the params structure) The firewall UUID. 3.6.0
l3Uuid String url The L3 network UUID. 3.6.0
forward String body (contained in the params structure) The forwarding direction.
  • in
  • out
3.6.0
ruleSetUuid String url The rule set UUID. 4.0.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

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

action = DetachFirewallRuleSetFromL3Action()
action.vpcFirewallUuid = "582cdc20cf313b8696da15f67f71c38f"
action.l3Uuid = "912cc5a14b193c2fa76290eac7046230"
action.forward = "in"
action.ruleSetUuid = "a54a917869733b5590053eb3f4505089"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryFirewallRuleSetL3Ref

API Request

URLs

GET zstack/v1/vpcfirewalls/l3networks/rulesets/refs

Headers

Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/l3networks/rulesets/refs

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryFirewallRuleSetL3Ref, and pressing the Tab key.

API Response

Sample Response

{
  "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"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventories List See inventories. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventories

Name Type Description Starting Version
id long The resource ID. 3.6.0
ruleSetUuid String The rule set UUID. 3.6.0
l3NetworkUuid String The L3 network UUID. 3.6.0
vpcFirewallUuid String The VPC firewall UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
packetsForwardType PacketsForwardType See packetsForwardType. 3.6.0

#packetsForwardType

Name Type Description Starting Version
in PacketsForwardType The in. 3.6.0
out PacketsForwardType The out. 3.6.0
local PacketsForwardType The local. 3.6.0

SDK Sample

Java SDK

QueryFirewallRuleSetL3RefAction action = new QueryFirewallRuleSetL3RefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleSetL3RefAction.Result res = action.call();

Python SDK

action = QueryFirewallRuleSetL3RefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

CreateFirewallRule

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
ruleSetUuid String body (contained in the params structure) The ruleset UUID. 3.6.0
action String body (contained in the params structure) The action taken against data packets.
  • drop
  • accept
  • reject
3.6.0
protocol String body (contained in the params structure) Optional. The protocol. 3.6.0
destPort String body (contained in the params structure) Optional. The destination port. 3.6.0
sourcePort String body (contained in the params structure) Optional. The source port. 3.6.0
sourceIp String body (contained in the params structure) Optional. The source IP address. 3.6.0
destIp String body (contained in the params structure) Optional. The destination IP address. 3.6.0
allowStates String body (contained in the params structure) Optional. The allow status of packets. 3.6.0
tcpFlag String body (contained in the params structure) Optional. The TCP flag. 3.6.0
icmpTypeName String body (contained in the params structure) Optional. The ICMP type. 3.6.0
ruleNumber Integer body (contained in the params structure) The priority of the rule. 3.6.0
enableLog boolean body (contained in the params structure) Optional. Specifies whether to enable logging. 3.6.0
state String body (contained in the params structure) The action that changes the state of the rule.
  • enable
  • disable
3.6.0
description String body (contained in the params structure) Optional. The detailed description of the rule. 3.6.0
resourceUuid String body (contained in the params structure) Optional. The rule UUID. 3.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUIDs. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String Indicates the allow status of packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isDefault boolean Indicates whether the rule is applied. 3.6.0
expired boolean Indicates whether the rule is expired. 4.0.0
isApplied boolean Indicates whether the rule is a system rule. 4.0.0
description String The detailed description of the rule. 3.6.0
createDate Timestamp The time when the rule was created. 3.6.0
lastOpDate Timestamp The time when the rule was last modified. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

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

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"
res = action.call()

CreateFirewallRuleFromConfigFile

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
ruleInfo String body (contained in the params structure) The firewall rule information. 4.4.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 4.4.0
tagUuids List body (contained in the params structure) Optional. The tag UUID. 4.4.0
systemTags List body Optional. The system tags. 4.4.0
userTags List body Optional. The user tags. 4.4.0

API Response

Sample Response

{
  "inventory": [
    {
      "name": "name",
      "actionType": "drop",
      "description": "example-des",
      "enableDefaultLog": false,
      "isDefault": false,
      "isApplied": true
    }
  ]
}
Name Type Description Starting Version
success boolean Whether the operation succeeded. 4.4.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.4.0
inventory VpcFirewallRuleSetInventory See inventory. 4.4.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.4.0
description String The brief description of the error. 4.4.0
details String The details about the error. 4.4.0
elaboration String The reserved field. Default value: null. 4.4.0
opaque LinkedHashMap The reserved field. Default value: null. 4.4.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.4.0

#inventory

Name Type Description Starting Version
uuid String The resource UUID. 4.4.0
name String The resource name. 4.4.0
description String The detailed description of the resource. 4.4.0
isDefault boolean Whether the resource is default. 4.4.0
isApplied boolean Whether the resource is applied. 4.4.0
createDate Timestamp The creation time. 4.4.0
lastOpDate Timestamp The last operation time. 4.4.0
actionType ActionType See actionType. 4.4.0

#actionType

Name Type Description Starting Version
drop ActionType The drop. 4.4.0
reject ActionType The reject. 4.4.0
accept ActionType The accept. 4.4.0

SDK Sample

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

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"
res = action.call()

QueryFirewallRule

API Request

URLs

GET zstack/v1/vpcfirewalls/rules
GET zstack/v1/vpcfirewalls/rules/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryFirewallRule, and pressing the Tab key.

API Response

Sample Response

{
  "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"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventories List See inventories. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventories

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String The allow status of data packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isDefault boolean Indicates whether the rule is applied. 3.6.0
isApplied boolean Indicates whether the rule is expired. 4.0.0
expired boolean Indicates whether the rule is a system rule. 4.0.0
description String The detailed description of the rule. 3.6.0
createDate Timestamp The time when the rule was created. 3.6.0
lastOpDate Timestamp The time when the rule was last modified. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

Java SDK

QueryFirewallRuleAction action = new QueryFirewallRuleAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleAction.Result res = action.call();

Python SDK

action = QueryFirewallRuleAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdateFirewallRule

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
ruleSetUuid String body (contained in the updateFirewallRule structure) The ruleset UUID. 3.6.0
uuid String url The rule UUID. 3.6.0
action String body (contained in the updateFirewallRule structure) The action taken against data packets.
  • drop
  • reject
  • accept
3.6.0
protocol String body (contained in the updateFirewallRule structure) Optional. The protocol. 3.6.0
destPort String body (contained in the updateFirewallRule structure) Optional. The destination port. 3.6.0
sourcePort String body (contained in the updateFirewallRule structure) Optional. The source port. 3.6.0
sourceIp String body (contained in the updateFirewallRule structure) Optional. The source IP address. 3.6.0
destIp String body (contained in the updateFirewallRule structure) Optional. The destination IP address. 3.6.0
allowStates String body (contained in the updateFirewallRule structure) Optional. The allow status of packets. 3.6.0
tcpFlag String body (contained in the updateFirewallRule structure) Optional. The TCP flag. 3.6.0
icmpTypeName String body (contained in the updateFirewallRule structure) Optional. The ICMP type. 3.6.0
ruleNumber Integer body (contained in the updateFirewallRule structure) The priority of the rule. 3.6.0
enableLog boolean body (contained in the updateFirewallRule structure) Optional. Specifies whether to enable logging. 3.6.0
state String body (contained in the updateFirewallRule structure) The action that changes the state of the rule.
  • enable
  • disable
3.6.0
description String body (contained in the updateFirewallRule structure) Optional. The detailed description of the rule. 3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String Indicates the allow status of packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isApplied boolean Indicates whether the rule is applied. 4.0.0
expired boolean Indicates whether the rule is expired. 4.0.0
isDefault boolean Indicates whether the rule is a default rule. 3.6.0
description String The detailed description of the resource. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

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

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"
res = action.call()

DeleteFirewallRule

API Request

URLs

DELETE zstack/v1/vpcfirewalls/rules/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
deleteMode String body Optional. The delete mode.
  • Permissive
  • Enforcing
4.0.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK

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

Python SDK

action = DeleteFirewallRuleAction()
action.uuid = "6238605440b535dd9f7d5d033a732659"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

ChangeFirewallRuleState

API Request

URLs

PUT zstack/v1/vpcfirewalls/rules/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "changeFirewallRuleState": {
    "state": "disable"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 3.6.0
state String body (contained in the changeFirewallRuleState structure) The action to change the state of the firewall rule.
  • enable
  • disable
3.6.0
systemTags List body Optional. The system tags. 3.6.0
userTags List body Optional. The user tags. 3.6.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventory VpcFirewallRuleInventory See inventory. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventory

Name Type Description Starting Version
uuid String The firewall rule UUID. 3.6.0
ruleSetUuid String The ruleset UUID. 3.6.0
destPort String The destination port. 3.6.0
sourcePort String The source port. 3.6.0
sourceIp String The source IP address. 3.6.0
destIp String The destination IP address. 3.6.0
ruleNumber Integer The priority of the rule. 3.6.0
allowStates String The allow status of data packets. 3.6.0
tcpFlag String The TCP flag. 3.6.0
icmpTypeName String The ICMP type. 3.6.0
isApplied boolean Indicates whether the rule is applied. 4.0.0
expired boolean Indicates whether the rule is expired. 4.0.0
isDefault boolean Indicates whether the rule is a system rule. 3.6.0
description String The detailed description of the rule. 3.6.0
createDate Timestamp The time when the rule was created. 3.6.0
lastOpDate Timestamp The time when the rule was last modified. 3.6.0
action ActionType See action. 3.6.0
protocol ProtocolType See protocol. 3.6.0
state FirewallRuleState See state. 3.6.0

#action

Name Type Description Starting Version
drop ActionType The drop. 3.6.0
reject ActionType The reject. 3.6.0
accept ActionType The accept. 3.6.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 3.6.0
all ProtocolType The all. 3.6.0
ah ProtocolType The ah. 3.6.0
ax.25 ProtocolType The ax 25. 3.6.0
dccp ProtocolType The dccp. 3.6.0
ddp ProtocolType The ddp. 3.6.0
egp ProtocolType The egp. 3.6.0
eigrp ProtocolType The eigrp. 3.6.0
encap ProtocolType The encap. 3.6.0
esp ProtocolType The esp. 3.6.0
etherip ProtocolType The etherip. 3.6.0
fc ProtocolType The fc. 3.6.0
ggp ProtocolType The ggp. 3.6.0
gre ProtocolType The gre. 3.6.0
hip ProtocolType The hip. 3.6.0
hmp ProtocolType The hmp. 3.6.0
icmp ProtocolType The icmp. 3.6.0
ipdr-cmtp ProtocolType The ipdr cmtp. 3.6.0
idpr ProtocolType The idpr. 3.6.0
igmp ProtocolType The igmp. 3.6.0
igp ProtocolType The igp. 3.6.0
ip ProtocolType The IP address. 3.6.0
ipcomp ProtocolType The ipcomp. 3.6.0
ipencap ProtocolType The ipencap. 3.6.0
ipip ProtocolType The ipip. 3.6.0
isis ProtocolType The isis. 3.6.0
iso-tp4 ProtocolType The ISO tp 4. 3.6.0
l2tp ProtocolType The L2 tp. 3.6.0
manet ProtocolType The manet. 3.6.0
mpls-in-ip ProtocolType The mpls in IP. 3.6.0
ospf ProtocolType The ospf. 3.6.0
pim ProtocolType The pim. 3.6.0
pup ProtocolType The pup. 3.6.0
rdp ProtocolType The rdp. 3.6.0
rohc ProtocolType The rohc. 3.6.0
rspf ProtocolType The rspf. 3.6.0
rsvp ProtocolType The rsvp. 3.6.0
sctp ProtocolType The sctp. 3.6.0
skip ProtocolType The skip. 3.6.0
st ProtocolType The st. 3.6.0
tcp ProtocolType The tcp. 3.6.0
udp ProtocolType The udp. 3.6.0
udplite ProtocolType The udplite. 3.6.0
vmtp ProtocolType The vmtp. 3.6.0
vrrp ProtocolType The vrrp. 3.6.0
wesp ProtocolType The wesp. 3.6.0
xns-idp ProtocolType The xns idp. 3.6.0
xtp ProtocolType The xtp. 3.6.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 3.6.0
enable FirewallRuleState Whether the feature is enabled. 3.6.0

SDK Sample

Java SDK

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

Python SDK

action = ChangeFirewallRuleStateAction()
action.uuid = "4eef3024e5bd36f38be22b5af9807b20"
action.state = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

CheckFirewallRuleConfigFile

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Optional Value Starting Version
ruleInfo String body (contained in the params structure) The firewall rule information. 4.4.0
systemTags List body Optional. The system tags. 4.4.0
userTags List body Optional. The user tags. 4.4.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

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

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"
res = action.call()

CreateFirewallRuleTemplate

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
action String body (contained in the params structure) The action.
  • drop
  • reject
  • accept
4.0.0
protocol String body (contained in the params structure) Optional. 4.0.0
name String body (contained in the params structure) The name of the template. 4.0.0
destPort String body (contained in the params structure) Optional. 4.0.0
sourcePort String body (contained in the params structure) Optional. 4.0.0
sourceIp String body (contained in the params structure) Optional. 4.0.0
destIp String body (contained in the params structure) Optional. 4.0.0
allowStates String body (contained in the params structure) Optional. 4.0.0
tcpFlag String body (contained in the params structure) Optional. 4.0.0
icmpTypeName String body (contained in the params structure) Optional. 4.0.0
ruleNumber Integer body (contained in the params structure) The number of rule. 4.0.0
enableLog boolean body (contained in the params structure) Optional. 4.0.0
state String body (contained in the params structure) Optional. 4.0.0
description String body (contained in the params structure) Optional. The detailed description of the template. 4.0.0
resourceUuid String body (contained in the params structure) Optional. The UUID of the template. 4.0.0
tagUuids List body (contained in the params structure) Optional. The user tags. 4.0.0
systemTags List body Optional. The system tags. 4.0.0
userTags List body Optional. The user tags. 4.0.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallRuleTemplateInventory See inventory 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventory

Name Type Description Starting Version
name String The name of the template. 4.0.0
destPort String The dest port. 4.0.0
sourcePort String The source port. 4.0.0
sourceIp String The source IP. 4.0.0
destIp String The dest IP. 4.0.0
allowStates String Whether states is enabled. 4.0.0
tcpFlag String The tcp flag. 4.0.0
icmpTypeName String The icmp type name. 4.0.0
ruleNumber int The number of rule. 4.0.0
enableLog boolean Whether log is enabled. 4.0.0
isDefault boolean Whether the resource is default. 4.0.0
description String The detailed description of the template. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the template was last modified. 4.0.0
accountUuid String The account UUID. 4.0.0
uuid String The UUID of the template. 4.0.0
action ActionType See action 4.0.0
protocol ProtocolType See protocol 4.0.0
state FirewallRuleState See state 4.0.0

#action

Name Type Description Starting Version
drop ActionType The drop. 4.0.0
reject ActionType The reject. 4.0.0
accept ActionType The accept. 4.0.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 4.0.0
all ProtocolType The all. 4.0.0
ah ProtocolType The ah. 4.0.0
ax.25 ProtocolType The ax 25. 4.0.0
dccp ProtocolType The dccp. 4.0.0
ddp ProtocolType The ddp. 4.0.0
egp ProtocolType The egp. 4.0.0
eigrp ProtocolType The eigrp. 4.0.0
encap ProtocolType The encap. 4.0.0
esp ProtocolType The esp. 4.0.0
etherip ProtocolType The etherip. 4.0.0
fc ProtocolType The fc. 4.0.0
ggp ProtocolType The ggp. 4.0.0
gre ProtocolType The gre. 4.0.0
hip ProtocolType The hip. 4.0.0
hmp ProtocolType The hmp. 4.0.0
icmp ProtocolType The icmp. 4.0.0
ipdr-cmtp ProtocolType The ipdr cmtp. 4.0.0
idpr ProtocolType The idpr. 4.0.0
igmp ProtocolType The igmp. 4.0.0
igp ProtocolType The igp. 4.0.0
ip ProtocolType The IP address. 4.0.0
ipcomp ProtocolType The ipcomp. 4.0.0
ipencap ProtocolType The ipencap. 4.0.0
ipip ProtocolType The ipip. 4.0.0
isis ProtocolType The isis. 4.0.0
iso-tp4 ProtocolType The ISO tp 4. 4.0.0
l2tp ProtocolType The L2 tp. 4.0.0
manet ProtocolType The manet. 4.0.0
pls-in-ip ProtocolType The pls in IP. 4.0.0
ospf ProtocolType The ospf. 4.0.0
pim ProtocolType The pim. 4.0.0
pup ProtocolType The pup. 4.0.0
rdp ProtocolType The rdp. 4.0.0
rohc ProtocolType The rohc. 4.0.0
rspf ProtocolType The rspf. 4.0.0
rsvp ProtocolType The rsvp. 4.0.0
sctp ProtocolType The sctp. 4.0.0
skip ProtocolType The skip. 4.0.0
st ProtocolType The st. 4.0.0
tcp ProtocolType The tcp. 4.0.0
udp ProtocolType The udp. 4.0.0
udplite ProtocolType The udplite. 4.0.0
vmtp ProtocolType The vmtp. 4.0.0
vrrp ProtocolType The vrrp. 4.0.0
wesp ProtocolType The wesp. 4.0.0
xns-idp ProtocolType The xns idp. 4.0.0
xtp ProtocolType The xtp. 4.0.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 4.0.0
enable FirewallRuleState Whether the feature is enabled. 4.0.0

SDK Sample

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

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"
res = action.call()

DeleteFirewallRuleTemplate

API Request

URLs

DELETE zstack/v1/vpcfirewalls/ipset/templates/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
uuid String url The UUID of the rule template. 4.0.0
deleteMode String body Optional. The deletion mode.
  • Permissive
  • Enforcing
4.0.0
systemTags List body Optional. The system tags. 4.0.0
userTags List body Optional. The user tags. 4.0.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK

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

Python SDK

action = DeleteFirewallRuleTemplateAction()
action.uuid = "8de197dab6af3e30b7131bc6d50f935d"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdateFirewallRuleTemplate

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
uuid String url The UUID of the template. 4.0.0
name String body (contained in theupdateFirewallRuleTemplate structure) Optional. The name of the rule template. 4.0.0
action String body (contained in theupdateFirewallRuleTemplate structure) The action.
  • drop
  • reject
  • accept
4.0.0
protocol String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
destPort String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
sourcePort String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
sourceIp String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
destIp String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
allowStates String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
tcpFlag String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
icmpTypeName String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
ruleNumber Integer body (contained in theupdateFirewallRuleTemplate structure) The number of rule. 4.0.0
enableLog boolean body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
state String body (contained in theupdateFirewallRuleTemplate structure) Optional. 4.0.0
description String body (contained in theupdateFirewallRuleTemplate structure) Optional. The detailed description of the template. 4.0.0
resourceUuid String body (contained in theupdateFirewallRuleTemplate structure) Optional. The UUID of the template. 4.0.0
tagUuids List body (contained in theupdateFirewallRuleTemplate structure) Optional. The tag tags. 4.0.0
systemTags List body Optional. The system tags. 4.0.0
userTags List body Optional. The user tags. 4.0.0

API Response

Sample Response

{
  "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"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallRuleTemplateInventory See inventory 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventory

Name Type Description Starting Version
name String The name of the template. 4.0.0
destPort String The dest port. 4.0.0
sourcePort String The source port. 4.0.0
sourceIp String The source IP. 4.0.0
destIp String The dest IP. 4.0.0
allowStates String Whether states is enabled. 4.0.0
tcpFlag String The tcp flag. 4.0.0
icmpTypeName String The icmp type name. 4.0.0
ruleNumber int The number of rule. 4.0.0
enableLog boolean Whether log is enabled. 4.0.0
isDefault boolean Whether the resource is default. 4.0.0
description String The detailed description of the template. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the template was last modified. 4.0.0
accountUuid String The account UUID. 4.0.0
uuid String The UUID of the template. 4.0.0
action ActionType See action 4.0.0
protocol ProtocolType See protocol 4.0.0
state FirewallRuleState See state 4.0.0

#action

Name Type Description Starting Version
drop ActionType The drop. 4.0.0
reject ActionType The reject. 4.0.0
accept ActionType The accept. 4.0.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 4.0.0
all ProtocolType The all. 4.0.0
ah ProtocolType The ah. 4.0.0
ax.25 ProtocolType The ax 25. 4.0.0
dccp ProtocolType The dccp. 4.0.0
ddp ProtocolType The ddp. 4.0.0
egp ProtocolType The egp. 4.0.0
eigrp ProtocolType The eigrp. 4.0.0
encap ProtocolType The encap. 4.0.0
esp ProtocolType The esp. 4.0.0
etherip ProtocolType The etherip. 4.0.0
fc ProtocolType The fc. 4.0.0
ggp ProtocolType The ggp. 4.0.0
gre ProtocolType The gre. 4.0.0
hip ProtocolType The hip. 4.0.0
hmp ProtocolType The hmp. 4.0.0
icmp ProtocolType The icmp. 4.0.0
ipdr-cmtp ProtocolType The ipdr cmtp. 4.0.0
idpr ProtocolType The idpr. 4.0.0
igmp ProtocolType The igmp. 4.0.0
igp ProtocolType The igp. 4.0.0
ip ProtocolType The IP address. 4.0.0
ipcomp ProtocolType The ipcomp. 4.0.0
ipencap ProtocolType The ipencap. 4.0.0
ipip ProtocolType The ipip. 4.0.0
isis ProtocolType The isis. 4.0.0
iso-tp4 ProtocolType The ISO tp 4. 4.0.0
l2tp ProtocolType The L2 tp. 4.0.0
manet ProtocolType The manet. 4.0.0
pls-in-ip ProtocolType The pls in IP. 4.0.0
ospf ProtocolType The ospf. 4.0.0
pim ProtocolType The pim. 4.0.0
pup ProtocolType The pup. 4.0.0
rdp ProtocolType The rdp. 4.0.0
rohc ProtocolType The rohc. 4.0.0
rspf ProtocolType The rspf. 4.0.0
rsvp ProtocolType The rsvp. 4.0.0
sctp ProtocolType The sctp. 4.0.0
skip ProtocolType The skip. 4.0.0
st ProtocolType The st. 4.0.0
tcp ProtocolType The tcp. 4.0.0
udp ProtocolType The udp. 4.0.0
udplite ProtocolType The udplite. 4.0.0
vmtp ProtocolType The vmtp. 4.0.0
vrrp ProtocolType The vrrp. 4.0.0
wesp ProtocolType The wesp. 4.0.0
xns-idp ProtocolType The xns idp. 4.0.0
xtp ProtocolType The xtp. 4.0.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 4.0.0
enable FirewallRuleState Whether the feature is enabled. 4.0.0

SDK Sample

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

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"
res = action.call()

QueryFirewallRuleTemplate

API Request

URLs

GET zstack/v1/vpcfirewalls/rules/templates
GET zstack/v1/vpcfirewalls/rules/templates/uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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}

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryFirewallRuleTemplate, and pressing the Tab key.

API Response

Sample Response:

{
  "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"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory List See inventories 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventories

Name Type Description Starting Version
name String The name of the template. 4.0.0
destPort String The dest port. 4.0.0
sourcePort String The source port. 4.0.0
sourceIp String The source IP. 4.0.0
destIp String The dest IP. 4.0.0
allowStates String Whether states is enabled. 4.0.0
tcpFlag String The tcp flag. 4.0.0
icmpTypeName String The icmp type name. 4.0.0
ruleNumber int The number of rule. 4.0.0
enableLog boolean Whether log is enabled. 4.0.0
isDefault boolean Whether the resource is default. 4.0.0
description String The detailed description of the template. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the rule template was last modified. 4.0.0
accountUuid String The account UUID. 4.0.0
uuid String The UUID of the template. 4.0.0
action ActionType See action 4.0.0
protocol ProtocolType See protocol 4.0.0
state FirewallRuleState See state 4.0.0

#action

Name Type Description Starting Version
drop ActionType The drop. 4.0.0
reject ActionType The reject. 4.0.0
accept ActionType The accept. 4.0.0

#protocol

Name Type Description Starting Version
tcp_udp ProtocolType The tcp udp. 4.0.0
all ProtocolType The all. 4.0.0
ah ProtocolType The ah. 4.0.0
ax.25 ProtocolType The ax 25. 4.0.0
dccp ProtocolType The dccp. 4.0.0
ddp ProtocolType The ddp. 4.0.0
egp ProtocolType The egp. 4.0.0
eigrp ProtocolType The eigrp. 4.0.0
encap ProtocolType The encap. 4.0.0
esp ProtocolType The esp. 4.0.0
etherip ProtocolType The etherip. 4.0.0
fc ProtocolType The fc. 4.0.0
ggp ProtocolType The ggp. 4.0.0
gre ProtocolType The gre. 4.0.0
hip ProtocolType The hip. 4.0.0
hmp ProtocolType The hmp. 4.0.0
icmp ProtocolType The icmp. 4.0.0
ipdr-cmtp ProtocolType The ipdr cmtp. 4.0.0
idpr ProtocolType The idpr. 4.0.0
igmp ProtocolType The igmp. 4.0.0
igp ProtocolType The igp. 4.0.0
ip ProtocolType The IP address. 4.0.0
ipcomp ProtocolType The ipcomp. 4.0.0
ipencap ProtocolType The ipencap. 4.0.0
ipip ProtocolType The ipip. 4.0.0
isis ProtocolType The isis. 4.0.0
iso-tp4 ProtocolType The ISO tp 4. 4.0.0
l2tp ProtocolType The L2 tp. 4.0.0
manet ProtocolType The manet. 4.0.0
pls-in-ip ProtocolType The pls in IP. 4.0.0
ospf ProtocolType The ospf. 4.0.0
pim ProtocolType The pim. 4.0.0
pup ProtocolType The pup. 4.0.0
rdp ProtocolType The rdp. 4.0.0
rohc ProtocolType The rohc. 4.0.0
rspf ProtocolType The rspf. 4.0.0
rsvp ProtocolType The rsvp. 4.0.0
sctp ProtocolType The sctp. 4.0.0
skip ProtocolType The skip. 4.0.0
st ProtocolType The st. 4.0.0
tcp ProtocolType The tcp. 4.0.0
udp ProtocolType The udp. 4.0.0
udplite ProtocolType The udplite. 4.0.0
vmtp ProtocolType The vmtp. 4.0.0
vrrp ProtocolType The vrrp. 4.0.0
wesp ProtocolType The wesp. 4.0.0
xns-idp ProtocolType The xns idp. 4.0.0
xtp ProtocolType The xtp. 4.0.0

#state

Name Type Description Starting Version
disable FirewallRuleState Whether the feature is disabled. 4.0.0
enable FirewallRuleState Whether the feature is enabled. 4.0.0

SDK Sample

Java SDK

QueryFirewallRuleTemplateAction action = new QueryFirewallRuleTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallRuleTemplateAction.Result res = action.call();

Python SDK

action = QueryFirewallRuleTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

QueryVpcFirewallVRouterRef

API Request

URLs

GET zstack/v1/vpcfirewalls/vrouters/refs

Headers

Authorization: OAuth the-session-uuid

Curl Sample

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vpcfirewalls/vrouters/refs?

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryVpcFirewallVRouterRef, and pressing the Tab key.

API Response

Sample Response

{
  "inventories": [
    {
      "id": 1.0,
      "vpcFirewallUuid": "cd7ab20e4768316c86230f2d982ae5a5",
      "vRouterUuid": "7013faeb3b4736d1800749b1e910a845",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.6.0
inventories List See inventories. 3.6.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 3.6.0
description String The brief description of the error. 3.6.0
details String The details about the error. 3.6.0
elaboration String The reserved field. Default value: null. 3.6.0
opaque LinkedHashMap The reserved field. Default value: null. 3.6.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.6.0

#inventories

Name Type Description Starting Version
id long The resource ID. 3.6.0
vpcFirewallUuid String The VPC firewall UUID. 3.6.0
vRouterUuid String The v router UUID. 3.6.0
createDate Timestamp The creation date. 3.6.0
lastOpDate Timestamp The last operation date. 3.6.0

SDK Sample

Java SDK

QueryVpcFirewallVRouterRefAction action = new QueryVpcFirewallVRouterRefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVpcFirewallVRouterRefAction.Result res = action.call();

Python SDK

action = QueryVpcFirewallVRouterRefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

ApplyRuleSetChanges

API Request

URLs

PUT zstack/v1/vpcfirewalls/ruleSets/apply/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "applyRuleSetChanges": {},
  "systemTags": [],
  "userTags": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
uuid String url The UUID of the action. 4.0.0
systemTags List body Optional. 4.0.0
userTags List body Optional. 4.0.0

API Response

Sample Response

{
  "inventory": {
    "name": "name",
    "actionType": "drop",
    "description": "example-des",
    "enableDefaultLog": false,
    "isDefault": false,
    "isApplied": true
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallRuleSetInventory See inventory 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventory

Name Type Description Starting Version
uuid String The UUID of the VPC firewall ruleset. 4.0.0
name String The name of the VPC firewall ruleset. 4.0.0
description String The detailed description of the VPC firewall ruleset. 4.0.0
isDefault boolean Whether the resource is default. 4.0.0
isApplied boolean Whether the resource is applied. 4.0.0
createDate Timestamp The time when the VPC firewall ruleset was created. 4.0.0
lastOpDate Timestamp The time when the VPC firewall ruleset was last modified. 4.0.0
actionType ActionType See actionType 4.0.0

#actionType

Name Type Description Starting Version
drop ActionType The drop. 4.0.0
reject ActionType The reject. 4.0.0
accept ActionType The accept. 4.0.0

SDK Sample

Java SDK

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

Python SDK

action = ApplyRuleSetChangesAction()
action.uuid = "e78b0b5ebe1c33159b0faa2d88a41b21"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

CreateFirewallIpSetTemplate

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
name String body (contained in the params structure) The name of the template. 4.0.0
sourceValue String body (contained in the params structure) Optional. 4.0.0
destValue String body (contained in the params structure) Optional. 4.0.0
type IpSetType body (contained in the params structure) The resource type.
  • ip
  • port
4.0.0
resourceUuid String body (contained in the params structure) Optional. The UUID of the template. 4.0.0
tagUuids List body (contained in the params structure) Optional. The user tags. 4.0.0
systemTags List body Optional. The system tags. 4.0.0
userTags List body Optional. The user tags. 4.0.0

API Response

Sample Response

{
  "inventory": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallIpSetTemplateInventory See inventory 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventory

Name Type Description Starting Version
name String The name of the template. 4.0.0
sourceValue String The source value. 4.0.0
destValue String The dest value. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the template was last modified. 4.0.0
accountUuid String The account UUID. 4.0.0
uuid String The template UUID. 4.0.0
type IpSetType See type 4.0.0

#type

Name Type Description Starting Version
ip IpSetType The IP address. 4.0.0
port IpSetType The port. 4.0.0

SDK Sample

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

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"
res = action.call()

DeleteFirewallIpSetTemplate

API Request

URLs

DELETE /v1/vpcfirewalls/ipset/templates/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
uuid String url The UUID of the template. 4.0.0
deleteMode String body Optional. The deletion mode.
  • Permissive
  • Enforcing
4.0.0
Optional. The system tags. List body Optional. The system tags. 4.0.0
Optional. The user tags. List body Optional. The user tags. 4.0.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,

{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK

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

Python SDK

action = DeleteFirewallIpSetTemplateAction()
action.uuid = "e84fbe6b5a9c31a1b4b83cfde4028893"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

UpdateFirewallIpSetTemplate

API Request

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": []
}

In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.

Curl Sample

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

Request Parameters

Name Type Location Description Valid Value Starting Version
uuid String url The UUID of the template. 4.0.0
name String body (contained in the updateFirewallIpSetTemplate structure) Optional. The name of the template. 4.0.0
sourceValue String body (contained in the updateFirewallIpSetTemplate structure) Optional. 4.0.0
destValue String body (contained in the updateFirewallIpSetTemplate structure) Optional. 4.0.0
type IpSetType body (contained in the updateFirewallIpSetTemplate structure) The resource type.
  • ip
  • port
4.0.0
systemTags List body Optional. The system tags. 4.0.0
userTags List body Optional. The user tags. 4.0.0

API Response

Sample Response

{
  "inventory": {
    "name": "ipset-template",
    "sourceValue": "192.168.1.2",
    "destValue": "192.168.1.1,10.0.0.1/24",
    "type": "ip"
  }
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallRuleTemplateInventory See inventory 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventory

Name Type Description Starting Version
name String The name of the template. 4.0.0
sourceValue String The source value. 4.0.0
destValue String The dest value. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the template was last modified. 4.0.0
accountUuid String The account UUID. 4.0.0
uuid String The UUID of the template. 4.0.0
type IpSetType See type 4.0.0

#type

Name Type Description Starting Version
ip IpSetType The IP address. 4.0.0
port IpSetType The port. 4.0.0

SDK Sample

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

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"
res = action.call()

QueryFirewallIpSetTemplate

API Request

URLs

GET zstack/v1/vpcfirewalls/ipset/templates
GET zstack/v1/vpcfirewalls/ipset/templates/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl Sample

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

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryFirewallIpSetTemplate, and pressing the Tab key.

API Response

Sample Response:

{
  "inventories": [
    {
      "name": "ipset-template",
      "sourceValue": "192.168.1.2",
      "destValue": "192.168.1.1,10.0.0.1/24",
      "type": "ip"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.0.0
inventory VpcFirewallIpSetTemplateInventory See inventories 4.0.0

#error

Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 4.0.0
description String The brief description of the error. 4.0.0
details String The details about the error. 4.0.0
elaboration String The reserved field. Default value: null. 4.0.0
opaque LinkedHashMap The reserved field. Default value: null. 4.0.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.0.0

#inventories

Name Type Description Starting Version
name long The name of the template. 4.0.0
sourceValue String The source value. 4.0.0
destValue String The dest value. 4.0.0
createDate Timestamp The time when the template was created. 4.0.0
lastOpDate Timestamp The time when the template was last modified. 4.0.0
accountUuid String The account UUID 4.0.0
uuid String The template UUID. 4.0.0
type IpSetType See type 4.0.0

#type

Name Type Description Starting Version
ip IpSetType The IP address. 4.0.0
port IpSetType The port. 4.0.0

SDK Sample

Java SDK

QueryFirewallIpSetTemplateAction action = new QueryFirewallIpSetTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFirewallIpSetTemplateAction.Result res = action.call();

Python SDK

action = QueryFirewallIpSetTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()