ChangeSecurityGroupRule
Headers
Authorization: OAuth the-session-uuidBody
{
"changeSecurityGroupRule": {
"description": "test",
"remoteSecurityGroupUuid": "bd2dcc93fbd73999bf920aeaab3c9e4e",
"action": "DROP",
"state": "Enabled",
"priority": 1,
"protocol": "TCP",
"srcIpRange": "1.1.1.1,2.2.2.0/24,3.3.3.1-3.3.3.10",
"dstPortRange": "1001,2000-2023,6001"
},
"systemTags": [],
"userTags": []
}In the preceding sample, both systemTags and userTags are optional. They are listed here to indicate that these two fields can be included in the body.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X PUT -d '{"changeSecurityGroupRule":{"description":"test","remoteSecurityGroupUuid":"bd2dcc93fbd73999bf920aeaab3c9e4e","action":"DROP","state":"Enabled","priority":1,"protocol":"TCP","srcIpRange":"1.1.1.1,2.2.2.0/24,3.3.3.1-3.3.3.10","dstPortRange":"1001,2000-2023,6001"}}'
http://localhost:8080/zstack/v1/security-groups/85a1d77188d836eab47b34e7129fb5fb/actionsParameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
uuid | String | url | The UUID of the security group rule, uniquely identifying the resource |
| 4.7.21 |
description (Optional) | String | body (included in the changeSecurityGroupState structure) | The rule description |
| 4.7.21 |
remoteSecurityGroupUuid (Optional) | String | body (included in the changeSecurityGroupState structure) | The remote security group UUID for inter-group policies | enabledisable | 4.7.21 |
action (Optional) | String | body (included in the changeSecurityGroupState structure) | The default action of the rule |
| 4.7.21 |
state (Optional) | String | body (included in the changeSecurityGroupState structure) | The state of the rule |
| 4.7.21 |
priority (Optional) | Integer | body (included in the changeSecurityGroupState structure) | The priority of the rule |
| 4.7.21 |
protocol (Optional) | String | body (included in the changeSecurityGroupState structure) | The protocol type of the rule |
| 4.7.21 |
srcIpRange (Optional) | String | body (included in the changeSecurityGroupState structure) | The source IP range of the rule |
| 4.7.21 |
dstIpRange (Optional) | String | body (included in the changeSecurityGroupState structure) | The destination IP range of the rule |
| 4.7.21 |
dstPortRange (Optional) | String | body (included in the changeSecurityGroupState structure) | The destination port range of the rule |
| 4.7.21 |
systemTags (Optional) | List | body | System tags |
| 4.7.21 |
userTags (Optional) | List | body | User tags |
| 4.7.21 |
API Response
Response Example
{
"inventory": {
"uuid": "68e4f4b48b51369c8c2ada5cb6c2c3c3",
"securityGroupUuid": "c80ad90499213d3b9989afdbfe498390",
"type": "ingress",
"protocol": "tcp",
"state": "enable",
"srcIpRange": "10.10.10.1-10.10.10.10",
"dstPortRange": "2001-2023",
"action": "RETURN",
"createDate": "Sep 15, 2023 9:57:59 AM",
"lastOpDate": "Sep 15, 2023 9:57:59 AM"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.21 | |
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 4.7.21 |
| inventory | SecurityGroupInventory | See inventory | 4.7.21 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 4.7.21 |
| description | String | Brief description of the error | 4.7.21 |
| details | String | Detailed error information | 4.7.21 |
| elaboration | String | Reserved field, defaults to null | 4.7.21 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 4.7.21 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 4.7.21 |
inventory
Name | Type | Description | Starting Version |
|---|---|---|---|
uuid | String | The UUID of the resource, uniquely identifying the resource | 4.7.21 |
securityGroupUuid | String | The security group UUID | 4.7.21 |
type | String | The traffic type | 4.7.21 |
ipVersion | Integer | The IP version number | 3.1.0 |
protocol | String | The traffic protocol type | 4.7.21 |
state | String | The availability state of the rule | 4.7.21 |
priority | Integer | The rule priority | 4.7.21 |
description | String | The rule description | 4.7.21 |
srcIpRange | String | The source IP range | 4.7.21 |
dstIpRange | String | The destination IP range | 4.7.21 |
srcPortRange | String | The source port range, not implemented in the current version | 4.7.21 |
dstPortRange | String | The destination port range | 4.7.21 |
action | String | The default action of the rule | 4.7.21 |
remoteSecurityGroupUuid | String |
| 4.7.21 |
allowedCidr | String | The allowed CIDR. The meaning of the allowed CIDR varies depending on the traffic type- For Ingress traffic, the allowed CIDR is the source CIDR that is permitted to access the VM NIC
| 4.7.21 |
startPort | Integer |
| 4.7.21 |
endPort | Integer |
| 4.7.21 |
createDate | Timestamp | The creation time | 4.7.21 |
lastOpDate | Timestamp | The last modification time | 4.7.21 |
SDK Examples
Java SDK
ChangeSecurityGroupRuleAction action = new ChangeSecurityGroupRuleAction();
action.uuid = "33869c6c323d30599da314fe1e46b01c";
action.description = "test";
action.remoteSecurityGroupUuid = "bd2dcc93fbd73999bf920aeaab3c9e4e";
action.action = "DROP";
action.state = "Enabled";
action.priority = 1;
action.protocol = "TCP";
action.srcIpRange = "1.1.1.1,2.2.2.0/24,3.3.3.1-3.3.3.10";
action.dstPortRange = "1001,2000-2023,6001";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeSecurityGroupRuleAction.Result res = action.call();
Python SDK
ChangeSecurityGroupRuleAction action = ChangeSecurityGroupRuleAction()
action.uuid = "33869c6c323d30599da314fe1e46b01c"
action.description = "test"
action.remoteSecurityGroupUuid = "bd2dcc93fbd73999bf920aeaab3c9e4e"
action.action = "DROP"
action.state = "Enabled"
action.priority = 1
action.protocol = "TCP"
action.srcIpRange = "1.1.1.1,2.2.2.0/24,3.3.3.1-3.3.3.10"
action.dstPortRange = "1001,2000-2023,6001"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeSecurityGroupRuleAction.Result res = action.call()