Add IP Access Control Rule

POST/zstack/v1/login-control/access-control/rules

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "rule1",
    "description": "this is a rule",
    "rule": "172.20.1.1,172.20.1.2",
    "controlStrategy": "ACCEPT"
  },
  "systemTags": [],
  "userTags": []
}

The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"rule1","description":"this is a rule","rule":"172.20.1.1,172.20.1.2","controlStrategy":"ACCEPT"}}' http://localhost:8080/zstack/v1/login-control/access-control/rules

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
nameStringbody (contained in the params structure)Resource name 3.5.1
description (optional)Stringbody (contained in the params structure)Detailed description of the resource 3.5.1
ruleStringbody (contained in the params structure)  3.5.1
controlStrategyStringbody (contained in the params structure)  3.5.1
resourceUuid (optional)Stringbody (contained in the params structure)  3.5.1
tagUuids (optional)Listbody (contained in the params structure)Tag UUID list 3.5.1
systemTags (optional)Listbody  3.5.1
userTags (optional)Listbody  3.5.1

API Response

On success, this API returns an empty JSON structure {}. On failure, the returned JSON structure contains 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 Examples

Java SDK

AddAccessControlRuleAction action = new AddAccessControlRuleAction();
action.name = "rule1";
action.description = "this is a rule";
action.rule = "172.20.1.1,172.20.1.2";
action.controlStrategy = "ACCEPT";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddAccessControlRuleAction.Result res = action.call();

Python SDK

AddAccessControlRuleAction action = AddAccessControlRuleAction()
action.name = "rule1"
action.description = "this is a rule"
action.rule = "172.20.1.1,172.20.1.2"
action.controlStrategy = "ACCEPT"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddAccessControlRuleAction.Result res = action.call()