QuerySecurityGroup
API Request
URLs
GET zstack/v1/security-groups
GET zstack/v1/security-groups/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 1f3fcf6a885148b69702e52d22de9606" \
-X GET http://localhost:8080/zstack/v1/security-groups?q=name=web&q=state=Enabled
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth a0c4c995a9e34c639cc72732bcd7bd2f" \
-X GET http://localhost:8080/zstack/v1/security-groups/af0d90237c084afaa16f997847579152
Queryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QuerySecurityGroup
, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "6f757e65fed243babeac0be896e77caf",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:20:34 PM",
"lastOpDate": "Jun 7, 2017 9:20:34 PM",
"internalId": 0.0
}
]
}
Name | Type | Description | Starting Version |
---|---|---|---|
error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
inventories | List | See inventories. | 0.6 |
#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. | 0.6 |
description | String | The brief description of the error. | 0.6 |
details | String | The details about the error. | 0.6 |
elaboration | String | The reserved field. Default value: null. | 0.6 |
opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventories
Name | Type | Description | Starting Version |
---|---|---|---|
uuid | String | The resource UUID. | 0.6 |
name | String | The resource name. | 0.6 |
description | String | The detailed description of the resource. | 0.6 |
state | String | 0.6 | |
ipVersion | Integer | The IP version. | 3.1.0 |
createDate | Timestamp | The creation date. | 0.6 |
lastOpDate | Timestamp | The last operation date. | 0.6 |
attachedL3NetworkUuids | Set | 0.6 | |
rules | List | See rules. | 0.6 |
#rules
Name | Type | Description | Starting Version |
---|---|---|---|
uuid | String | The resource UUID. | 0.6 |
securityGroupUuid | String | The security group UUID. | 0.6 |
type | String | The traffic type. | 0.6 |
ipVersion | Integer | The IP version. | 3.1.0 |
startPort | Integer |
|
0.6 |
endPort | Integer |
|
0.6 |
protocol | String | The traffic protocol type. | 0.6 |
state | String | The rule state, which is not implemented in the current version. | 0.6 |
allowedCidr | String |
|
0.6 |
remoteSecurityGroupUuid | String | 0.6 | |
createDate | Timestamp | The creation date. | 0.6 |
lastOpDate | Timestamp | The last operation date. | 0.6 |
SDK Sample
Java
SDK
QuerySecurityGroupAction action = new QuerySecurityGroupAction();
action.conditions = asList("name=web","state=Enabled");
action.sessionId = "604cf540e620468fa3fad7098196bb96";
QuerySecurityGroupAction.Result res = action.call();
Python
SDK
QuerySecurityGroupAction action = QuerySecurityGroupAction()
action.conditions = ["name=web","state=Enabled"]
action.sessionId = "55a3657d35f14ee4b41401bd7ada15a7"
QuerySecurityGroupAction.Result res = action.call()