Network ServicesSecurity Group

ChangeSecurityGroupState

PUT/zstack/v1/security-groups/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "changeSecurityGroupState": {
    "stateEvent": "disable"
  },
  "systemTags": [],
  "userTags": []
}

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

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeSecurityGroupState":{"stateEvent":"disable"}}' \
http://localhost:8080/zstack/v1/security-groups/85a1d77188d836eab47b34e7129fb5fb/actions

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
uuidStringurlThe UUID of the resource, uniquely identifying the resource 0.6
stateEventStringbody (included in the changeSecurityGroupState structure)The security group stateenabledisable0.6
systemTags (Optional)ListbodySystem tags 0.6
userTags (Optional)ListbodyUser tags 0.6

API Response

Response Example

{
  "inventory": {
    "uuid": "eebb81d825214555a61567f8811fca15",
    "name": "web",
    "description": "for test",
    "state": "Enabled",
    "createDate": "Jun 7, 2017 9:20:16 PM",
    "lastOpDate": "Jun 7, 2017 9:20:16 PM",
    "internalId": 0.0
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See error0.6
inventorySecurityGroupInventorySee inventory0.6

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot error: the source error that caused the current error. If there is no original error, this field is null0.6

inventory

NameTypeDescriptionStarting Version
uuidStringThe UUID of the resource, uniquely identifying the resource0.6
nameStringThe resource name0.6
descriptionStringThe detailed description of the resource0.6
stateString 0.6
ipVersionIntegerThe IP version number3.1.0
createDateTimestampThe creation time0.6
lastOpDateTimestampThe last modification time0.6
attachedL3NetworkUuidsSet 0.6
rulesListSee rules0.6

rules

Name

Type

Description

Starting Version

uuid

String

The UUID of the resource, uniquely identifying the resource

0.6

securityGroupUuid

String

The security group UUID

0.6

type

String

The traffic type

0.6

ipVersion

Integer

The IP version number

3.1.0

startPort

Integer

  • For TCP/UDP, it is the start port number of the port range
  • For ICMP, it is the ICMP type

0.6

endPort

Integer

  • For TCP/UDP, it is the end port number of the port range
  • For ICMP, it is the ICMP code

0.6

protocol

String

The traffic protocol type

0.6

state

String

The availability state of the rule, not implemented in the current version

0.6

allowedCidr

String

  • The allowed CIDR. It has different meanings depending on the traffic type.
  • For Ingress, it is the source CIDR allowed to access the VM NIC
  • For Egress, it is the destination CIDR that traffic is allowed to reach from the VM NIC

0.6

remoteSecurityGroupUuid

String

 

0.6

createDate

Timestamp

The creation time

0.6

lastOpDate

Timestamp

The last modification time

0.6

SDK Examples

Java SDK

ChangeSecurityGroupStateAction action = new ChangeSecurityGroupStateAction();
action.uuid = "9389a923cd8c4cacb12e57b979fa1e5f";
action.stateEvent = "disable";
action.sessionId = "772deba87e7847459e5b1f428531bee2";
ChangeSecurityGroupStateAction.Result res = action.call();

Python SDK

ChangeSecurityGroupStateAction action = ChangeSecurityGroupStateAction()
action.uuid = "1ecf0093245b4a6a948d5d09983f0193"
action.stateEvent = "disable"
action.sessionId = "eb76404af2f140f993ae68bb22a80781"
ChangeSecurityGroupStateAction.Result res = action.call()