ChangeSecurityGroupRuleState
Headers
Authorization: OAuth the-session-uuidBody
{
"changeSecurityGroupRuleState": {
"ruleUuids": [
"c895848e49763a85a74d0a8cee5a0720"
],
"state": "Enabled"
},
"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 '{"changeSecurityGroupRuleState":{"ruleUuids":["c895848e49763a85a74d0a8cee5a0720"],"state":"Enabled"}}'
http://localhost:8080/zstack/v1/security-groups/fbd126afdf6b32caab55327d2901170f/rules/state/actionsParameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
securityGroupUuid | String | url | The UUID of the security group, uniquely identifying the resource |
| 4.7.21 |
ruleUuids | List | body (included in the changeSecurityGroupRuleState structure) | The list of rule UUIDs |
| 4.7.21 |
state | String | body (included in the changeSecurityGroupRuleState structure) | The state 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": "7c95c623cc983a548dcf3c9a257f23ae",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Sep 15, 2023 9:58:00 AM",
"lastOpDate": "Sep 15, 2023 9:58:00 AM",
"internalId": 0
}
}| 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 |
| name | String | The resource name | 4.7.21 |
| description | String | The detailed description of the resource | 4.7.21 |
| state | String | 4.7.21 | |
| ipVersion | Integer | The IP version number | 4.7.21 |
| createDate | Timestamp | The creation time | 4.7.21 |
| lastOpDate | Timestamp | The last modification time | 4.7.21 |
| attachedL3NetworkUuids | Set | 4.7.21 | |
| rules | List | See rules | 4.7.21 |
rules
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 | 4.7.21 |
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
ChangeSecurityGroupRuleStateAction action = new ChangeSecurityGroupRuleStateAction();
action.securityGroupUuid = "fbd126afdf6b32caab55327d2901170f";
action.ruleUuids = asList("c895848e49763a85a74d0a8cee5a0720");
action.state = "Enabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeSecurityGroupRuleStateAction.Result res = action.call();Python SDK
ChangeSecurityGroupRuleStateAction action = ChangeSecurityGroupRuleStateAction()
action.securityGroupUuid = "fbd126afdf6b32caab55327d2901170f"
action.ruleUuids = [c895848e49763a85a74d0a8cee5a0720]
action.state = "Enabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeSecurityGroupRuleStateAction.Result res = action.call()