Network Services
GetNetworkServiceTypes
API Request
GET zstack/v1/network-services/typesAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 8a5a05acd4fb47b7839a9c50a74c3f1a" \
-X GET http://localhost:8080/zstack/v1/network-services/types| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| systemTags (Optional) | List | query | System tags | 0.6 | |
| userTags (Optional) | List | query | User tags | 0.6 |
API Response
{
"serviceAndProviderTypes": {
"SecurityGroup": [
"929ae57afd1b4815b04ecb25bd67fb02"
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| types | Map | The types. | 0.6 |
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error for details. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
SDK Examples
GetNetworkServiceTypesAction action = new GetNetworkServiceTypesAction();
action.sessionId = "bcb01c0891bb48a1974e2004b3397678";
GetNetworkServiceTypesAction.Result res = action.call();GetNetworkServiceTypesAction action = GetNetworkServiceTypesAction()
action.sessionId = "35c50339c05b4d6c9b4461a478c17239"
GetNetworkServiceTypesAction.Result res = action.call()QueryNetworkServiceProvider
API Request
GET zstack/v1/network-services/providersAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 0305524eb18344ea95193f8283a7212f" \
-X GET http://localhost:8080/zstack/v1/network-services/providersQueryable Fields
Run the CLI tool, type QueryNetworkServiceProvider and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
{
"inventories": [
{
"uuid": "3cf04a2c5e1a4c4c8947545323e35d6a",
"name": "SecurityGroup",
"type": "SecurityGroup",
"createDate": "Jun 7, 2017 9:21:03 PM",
"lastOpDate": "Jun 7, 2017 9:21:03 PM",
"networkServiceTypes": [
"SecurityGroup"
],
"attachedL2NetworkUuids": []
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. Seeerror for details. | 0.6 |
| inventories | List | Seeinventories for details. | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| type | String | The resource type. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| networkServiceTypes | Set | The network service types. | 0.6 |
| attachedL2NetworkUuids | Set | The attached L2 network UUIDs. | 0.6 |
SDK Examples
QueryNetworkServiceProviderAction action = new QueryNetworkServiceProviderAction();
action.conditions = asList();
action.sessionId = "3d4bfef1a32241528160058368824670";
QueryNetworkServiceProviderAction.Result res = action.call();QueryNetworkServiceProviderAction action = QueryNetworkServiceProviderAction()
action.conditions = []
action.sessionId = "db50128c5ab745e68c9b30c52d24ebf9"
QueryNetworkServiceProviderAction.Result res = action.call()QueryNetworkServiceL3NetworkRef
API Request
GET zstack/v1/l3-networks/network-services/refsAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth aa530ebc39804e00b3df02b8862eaec3" \
-X GET http://localhost:8080/zstack/v1/l3-networks/network-services/refsQueryable Fields
Run the CLI tool, type QueryNetworkServiceL3NetworkRef and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
{
"inventories": [
{
"l3NetworkUuid": "fc5bd613a8fd45ed9b96ff5d99ae6717",
"networkServiceProviderUuid": "f79573afadc44f4fb83aaf67eeb98cde",
"networkServiceType": "PortForwarding"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| l3NetworkUuid | String | The Distributed Port Group UUID | 0.6 |
| networkServiceProviderUuid | String | The network service provider UUID | 0.6 |
| networkServiceType | String | The network service type. | 0.6 |
SDK Examples
QueryNetworkServiceL3NetworkRefAction action = new QueryNetworkServiceL3NetworkRefAction();
action.conditions = asList();
action.sessionId = "01368722cb7e4c7eac03e7040f8b73e1";
QueryNetworkServiceL3NetworkRefAction.Result res = action.call();QueryNetworkServiceL3NetworkRefAction action = QueryNetworkServiceL3NetworkRefAction()
action.conditions = []
action.sessionId = "237996a7dddf4cf3a42f6ea15893bc76"
QueryNetworkServiceL3NetworkRefAction.Result res = action.call()AttachNetworkServiceToL3Network
API Request
POST zstack/v1/l3-networks/{l3NetworkUuid}/network-servicesAuthorization: OAuth the-session-uuid{
"params": {
"networkServices": {
"95f60161f9d5483dbfe92a10d8795334": [
"PortForwarding"
]
}
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"networkServices":{"41083a0985973a62bf8e6086dff0a2df":["PortForwarding"]}}}' \
http://localhost:8080/zstack/v1/l3-networks/ae8e1e4d66003a08b748363b8ebb0be8/network-services| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| l3NetworkUuid | String | url | The L3 network UUID. | 0.6 | |
| networkServices | Map | body(included in the params structure) | The network services. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
{} when it succeeds, and returns a JSON object containing an error field when it fails. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
AttachNetworkServiceToL3NetworkAction action = new AttachNetworkServiceToL3NetworkAction();
action.l3NetworkUuid = "e1a80b4d97ca442b8f313739de6d7997";
action.networkServices = [a3b86894e3b948288ccb1886a4084f03:[PortForwarding]];
action.sessionId = "4de1ca63ca1a4a0db7d799093b387c76";
AttachNetworkServiceToL3NetworkAction.Result res = action.call();AttachNetworkServiceToL3NetworkAction action = AttachNetworkServiceToL3NetworkAction()
action.l3NetworkUuid = "38daee20c0264e41b58ea573c261f439"
action.networkServices = [7fb4f50bf7c74c30951fb7adbb202a95:[PortForwarding]]
action.sessionId = "4be26def099940f0979b1afaf414bba6"
AttachNetworkServiceToL3NetworkAction.Result res = action.call()DetachNetworkServiceFromL3Network
API Request
DELETE zstack/v1/l3-networks/{l3NetworkUuid}/network-services
DELETE zstack/v1/l3-networks/{l3NetworkUuid}/network-services/{service}Authorization: OAuth the-session-uuid| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| l3NetworkUuid | String | url | The Distributed Port Group UUID | 0.6 | |
| networkServices (Optional) | Map | query | Network services | 0.6 | |
| systemTags (Optional) | List | query | System tags | 0.6 | |
| userTags (Optional) | List | query | User tags | 0.6 | |
| service (Optional) | String | query | The service type | 4.10.16 |
API Response
{} when it succeeds, and returns a JSON object containing an error field when it fails. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
DetachNetworkServiceFromL3NetworkAction action = new DetachNetworkServiceFromL3NetworkAction();
action.l3NetworkUuid = "ce1dedf370494cd4b49c1dd1c845c96b";
action.networkServices = [76b66ca373834d0e8f4011f84dbf6006:[PortForwarding, EIP]];
action.sessionId = "095d243ad49d4717b99b49c6151c25c8";
DetachNetworkServiceFromL3NetworkAction.Result res = action.call();DetachNetworkServiceFromL3NetworkAction action = DetachNetworkServiceFromL3NetworkAction()
action.l3NetworkUuid = "a679835ba20342c5809e1be8ddf5e5c8"
action.networkServices = [b78e8e4ca36b4eefa5c38140c7611ef3:[PortForwarding, EIP]]
action.sessionId = "73aa0dad7996453f80331b833df6f320"
DetachNetworkServiceFromL3NetworkAction.Result res = action.call()Security Group
CreateSecurityGroup
API Request
POST zstack/v1/security-groupsAuthorization: OAuth the-session-uuid{
"params": {
"name": "sp",
"description": "test create security group"
},
"systemTags": [],
"userTags": []
}
Note: 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 POST -d '{"params":{"name":"sp","description":"test create security group"}}' \
http://localhost:8080/zstack/v1/security-groups
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (included in the params structure) | The resource name | 0.6 | |
| description (Optional) | String | body (included in the params structure) | The detailed description of the resource | 0.6 | |
| ipVersion (Optional) | Integer | body (included in the params structure) | The IP version number |
|
3.1.0 |
| resourceUuid (Optional) | String | body (included in the params structure) | User-specified resource UUID. If specified, the system does not randomly assign a UUID to the resource | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "7bb070cdebf44fd8af354f25344d758b",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:21:20 PM",
"lastOpDate": "Jun 7, 2017 9:21:20 PM",
"internalId": 0.0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
CreateSecurityGroupAction action = new CreateSecurityGroupAction();
action.name = "sp";
action.description = "test create security group";
action.sessionId = "b5032c14210c4668a3a2bcd341d80bbf";
CreateSecurityGroupAction.Result res = action.call();CreateSecurityGroupAction action = CreateSecurityGroupAction()
action.name = "sp"
action.description = "test create security group"
action.sessionId = "e34f8139af4548d5ade539ca2a5d7983"
CreateSecurityGroupAction.Result res = action.call()DeleteSecurityGroup
API Request
DELETE zstack/v1/security-groups/{uuid}?deleteMode={deleteMode}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 6674ae438b8646d3b4a99a7fe7a48719" \
-X DELETE http://localhost:8080/zstack/v1/security-groups/6791f54e4fb147d1b26030723efe03bd?deleteMode=Permissive| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource, uniquely identifying the resource | 0.6 | |
| deleteMode (Optional) | String | body |
|
0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{} when it succeeds, and returns a JSON object containing an error field when it fails. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
DeleteSecurityGroupAction action = new DeleteSecurityGroupAction();
action.uuid = "86efff16586b4d82bfea66deba85cc50";
action.deleteMode = "Permissive";
action.sessionId = "079653952584401b997df37fd7044433";
DeleteSecurityGroupAction.Result res = action.call();
DeleteSecurityGroupAction action = DeleteSecurityGroupAction()
action.uuid = "59098134c4214c79a48ced0ed7952ecd"
action.deleteMode = "Permissive"
action.sessionId = "2fb58330c68d46f6aa700740d52b02c0"
DeleteSecurityGroupAction.Result res = action.call()QuerySecurityGroup
API Request
GET zstack/v1/security-groups
GET zstack/v1/security-groups/{uuid}Authorization: OAuth the-session-uuidcurl -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=Enabledcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth a0c4c995a9e34c639cc72732bcd7bd2f" \
-X GET http://localhost:8080/zstack/v1/security-groups/af0d90237c084afaa16f997847579152Queryable Fields
Run the CLI tool, type QuerySecurityGroup and press the Tab key to view all queryable fields and cross-table queryable resource names.
API 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 | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
QuerySecurityGroupAction action = new QuerySecurityGroupAction();
action.conditions = asList("name=web","state=Enabled");
action.sessionId = "604cf540e620468fa3fad7098196bb96";
QuerySecurityGroupAction.Result res = action.call();QuerySecurityGroupAction action = QuerySecurityGroupAction()
action.conditions = ["name=web","state=Enabled"]
action.sessionId = "55a3657d35f14ee4b41401bd7ada15a7"
QuerySecurityGroupAction.Result res = action.call()UpdateSecurityGroup
API Request
PUT zstack/v1/security-groups/{uuid}/actionsAuthorization: OAuth the-session-uuid{
"updateSecurityGroup": {
"name": "new sg",
"description": "for test update"
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateSecurityGroup":{"name":"new sg","description":"for test update"}}' \
http://localhost:8080/zstack/v1/security-groups/549bb03c235a3fa8aa18fb79539d4862/actions| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource, uniquely identifying the resource | 0.6 | |
| name (Optional) | String | body (included in the updateSecurityGroup structure) | The resource name | 0.6 | |
| description (Optional) | String | body (included in the updateSecurityGroup structure) | The detailed description of the resource | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "def8dff9ec5046e39f57193f488d716a",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:20:15 PM",
"lastOpDate": "Jun 7, 2017 9:20:15 PM",
"internalId": 0.0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 |
| 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 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
UpdateSecurityGroupAction action = new UpdateSecurityGroupAction();
action.uuid = "b60e66856f6c4f7ca16854cfd170fb99";
action.name = "new sg";
action.description = "for test update";
action.sessionId = "8c23751364b746628177641202ff0999";
UpdateSecurityGroupAction.Result res = action.call();UpdateSecurityGroupAction action = UpdateSecurityGroupAction()
action.uuid = "f6fc05d6ba854530bd8141733d6db4ad"
action.name = "new sg"
action.description = "for test update"
action.sessionId = "f75e99d861ca4660925d72313692d663"
UpdateSecurityGroupAction.Result res = action.call()ChangeSecurityGroupState
API Request
PUT zstack/v1/security-groups/{uuid}/actionsAuthorization: OAuth the-session-uuid{
"changeSecurityGroupState": {
"stateEvent": "disable"
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.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| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource, uniquely identifying the resource | 0.6 | |
| stateEvent | String | body (included in the changeSecurityGroupState structure) | The security group state | enabledisable | 0.6 |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"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
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 |
|
0.6 |
| endPort | Integer |
|
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 |
|
0.6 |
| remoteSecurityGroupUuid | String | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
ChangeSecurityGroupStateAction action = new ChangeSecurityGroupStateAction();
action.uuid = "9389a923cd8c4cacb12e57b979fa1e5f";
action.stateEvent = "disable";
action.sessionId = "772deba87e7847459e5b1f428531bee2";
ChangeSecurityGroupStateAction.Result res = action.call();ChangeSecurityGroupStateAction action = ChangeSecurityGroupStateAction()
action.uuid = "1ecf0093245b4a6a948d5d09983f0193"
action.stateEvent = "disable"
action.sessionId = "eb76404af2f140f993ae68bb22a80781"
ChangeSecurityGroupStateAction.Result res = action.call()AttachSecurityGroupToL3Network
API Request
POST zstack/v1/security-groups/{securityGroupUuid}/l3-networks/{l3NetworkUuid}Authorization: OAuth the-session-uuid{
"params": {},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/security-groups/0551a95211783295879d083216cb493b/l3-networks/35aa9f6e9a2b3f849d1631ba89d0b27d| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| l3NetworkUuid | String | url | The Distributed Port Group UUID | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "5870eab620d2487d8d0320eabe185718",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:20:28 PM",
"lastOpDate": "Jun 7, 2017 9:20:28 PM",
"internalId": 0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 |
|
0.6 |
| endPort | Integer |
|
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 |
|
0.6 |
| remoteSecurityGroupUuid | String | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
AttachSecurityGroupToL3NetworkAction action = new AttachSecurityGroupToL3NetworkAction();
action.securityGroupUuid = "eef2d772f4e94997816fdf8512a8233a";
action.l3NetworkUuid = "6761570f790c400596839da61767f890";
action.sessionId = "efb745c9a7204e9a941608059f3c3a10";
AttachSecurityGroupToL3NetworkAction.Result res = action.call();AttachSecurityGroupToL3NetworkAction action = AttachSecurityGroupToL3NetworkAction()
action.securityGroupUuid = "ae9aebcc28d1490293382c661d123c16"
action.l3NetworkUuid = "cd2fdc4303e34ead806a492d18d4b5fa"
action.sessionId = "9938bf24e1b24c39ab4dc3edc0aeb38d"
AttachSecurityGroupToL3NetworkAction.Result res = action.call()DetachSecurityGroupFromL3Network
API Request
DELETE/v1/security-groups/{securityGroupUuid}/l3-networks/{l3NetworkUuid}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 6edcc17febe04b9fb77059cf096f2cc5" \
-X DELETE http://localhost:8080/zstack/v1/security-groups/08d569c03f8343168f2ae80861db92f3/l3-networks/af8199498a9e4ab1be6d1fea8ec7fbee?| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| l3NetworkUuid | String | url | The Distributed Port Group UUID | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "6cf7a5c5d89b4094ad912a555319d4d0",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:21:06 PM",
"lastOpDate": "Jun 7, 2017 9:21:06 PM",
"internalId": 0.0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
DetachSecurityGroupFromL3NetworkAction action = new DetachSecurityGroupFromL3NetworkAction();
action.securityGroupUuid = "823d378084fa445c8d180895db4dd8c1";
action.l3NetworkUuid = "cf6dd2bbd5f940d0976e8c2cd2c063c9";
action.sessionId = "915660a10fc74d509d5ef72caf5892bd";
DetachSecurityGroupFromL3NetworkAction.Result res = action.call();DetachSecurityGroupFromL3NetworkAction action = DetachSecurityGroupFromL3NetworkAction()
action.securityGroupUuid = "726d6b2f8a674da681f32c66102494df"
action.l3NetworkUuid = "f32da69be7ce4918bb81b8a7ce891177"
action.sessionId = "933ada040fb14b94941997381877bacc"
DetachSecurityGroupFromL3NetworkAction.Result res = action.call()GetCandidateVmNicForSecurityGroup
API Request
GET zstack/v1/security-groups/{securityGroupUuid}/vm-instances/candidate-nicsAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth aec584233a724de089d05b8090e5a296" \
-X GET http://localhost:8080/zstack/v1/security-groups/584e70f6d3504c7a811df5eeba61839c/vm-instances/candidate-nics| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| systemTags (Optional) | List | query | System tags | 0.6 | |
| userTags (Optional) | List | query | User tags | 0.6 |
API Response
{
"inventories": [
{
"uuid": "80d2eab0354c329b8257e8f9fcd76d43",
"vmInstanceUuid": "e8af62992ec5343facac7c5fc164ddd0",
"l3NetworkUuid": "738cc18ef5003a00937c0e17e6c67a2d",
"ip": "192.168.0.123",
"mac": "fa:ef:34:5c:6c:00",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.0.1",
"internalName": "eth0",
"deviceId": 0.0
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | Whether the operation succeeded. | 0.6 |
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| vmInstanceUuid | String | The virtual machine UUID | 0.6 |
| l3NetworkUuid | String | The Distributed Port Group UUID | 0.6 |
| ip | String | The IP address. | 0.6 |
| mac | String | The MAC address. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| netmask | String | The netmask. | 0.6 |
| gateway | String | The gateway IP address. | 0.6 |
| metaData | String | The metadata. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| driverType | String | The driver type. | 0.6 |
| internalName | String | The internal name. | 0.6 |
| deviceId | Integer | The device ID. | 0.6 |
| type | String | The resource type. | 0.6 |
| state | String | The NIC state | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| usedIps | List | See usedIps | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| ipRangeUuid | String | The IP range UUID | 0.6 |
| l3NetworkUuid | String | The Distributed Port Group UUID | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| ip | String | The IP address | 0.6 |
| netmask | String | The netmask | 0.6 |
| gateway | String | The gateway address | 0.6 |
| usedFor | String | The intended use. | 0.6 |
| ipInLong | long | The IP address represented as a long integer. | 0.6 |
| vmNicUuid | String | The VM NIC UUID | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
GetCandidateVmNicForSecurityGroupAction action = new GetCandidateVmNicForSecurityGroupAction();
action.securityGroupUuid = "d11a80c9d7ba32ad97e2bca9c0dba6a9";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateVmNicForSecurityGroupAction.Result res = action.call();action = GetCandidateVmNicForSecurityGroupAction()
action.securityGroupUuid = "d11a80c9d7ba32ad97e2bca9c0dba6a9"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()AddVmNicToSecurityGroup
API Request
POST zstack/v1/security-groups/{securityGroupUuid}/vm-instances/nicsAuthorization: OAuth the-session-uuid{
"params": {
"vmNicUuids": [
"8432b2608a8a4f639cc56a8c65ee42ef"
]
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vmNicUuids":["c37875cec7133f41adbeb336cdd33ef8"]}}' \
http://localhost:8080/zstack/v1/security-groups/f52566f939f635629a43cd3e27f78dd9/vm-instances/nics| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| vmNicUuids | List | body (included in the params structure) | The list of VM NIC UUIDs | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{} when it succeeds, and returns a JSON object containing an error field when it fails. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
AddVmNicToSecurityGroupAction action = new AddVmNicToSecurityGroupAction();
action.securityGroupUuid = "b651075ffcac475c91d3edaa5e9ade75";
action.vmNicUuids = asList("ff0f6c13311b46ddb186a95c0d18350a");
action.sessionId = "605fca0559284eff95d78e418508ff2f";
AddVmNicToSecurityGroupAction.Result res = action.call();AddVmNicToSecurityGroupAction action = AddVmNicToSecurityGroupAction()
action.securityGroupUuid = "2da1519b9b39451e8742aadaa9241952"
action.vmNicUuids = [bda4ceec2917426cb9ee20b3bcb20653]
action.sessionId = "863d503abfbc4334846d67c1eac375f9"
AddVmNicToSecurityGroupAction.Result res = action.call()DeleteVmNicFromSecurityGroup
Delete VM NICs from a security group. This command is executed asynchronously. After it returns, the rules may not have taken effect on all VM NICs yet.
API Request
DELETE /v1/security-groups/{securityGroupUuid}/vm-instances/nics?vmNicUuids={vmNicUuids}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/security-groups/2c78da48235c3015aa9f9c99e81060b2/vm-instances/nics?vmNicUuids=9aef4c831b1540e7832332972138d78c&vmNicUuids=c40dd02ddf654031aec25346626db553| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| vmNicUuids | List | body | The list of NIC UUIDs | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{} when it succeeds, and returns a JSON object containing an error field when it fails. For example:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Examples
DeleteVmNicFromSecurityGroupAction action = new DeleteVmNicFromSecurityGroupAction();
action.securityGroupUuid = "2c78da48235c3015aa9f9c99e81060b2";
action.vmNicUuids = asList("f8e9c3a73e7c399ca148057f8b2897c3","ae09cd7292913bfe84e467286aaa7a9f");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteVmNicFromSecurityGroupAction.Result res = action.call();DeleteVmNicFromSecurityGroupAction action = DeleteVmNicFromSecurityGroupAction()
action.securityGroupUuid = "2c78da48235c3015aa9f9c99e81060b2"
action.vmNicUuids = [f8e9c3a73e7c399ca148057f8b2897c3, ae09cd7292913bfe84e467286aaa7a9f]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteVmNicFromSecurityGroupAction.Result res = action.call()QueryVmNicInSecurityGroup
API Request
GET zstack/v1/security-groups/vm-instances/nicsAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 3f2df305cc614ecb9d0b93480cf84b33" \
-X GET http://localhost:8080/zstack/v1/security-groups/vm-instances/nicsQueryable Fields
Run the CLI tool, type QueryVmNicInSecurityGroup and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
{
"inventories": [
{
"uuid": "9bac6b3729ae4915bc9f4cee67753774",
"vmNicUuid": "7d0784059df64a11aef748e18b0d5fa7",
"securityGroupUuid": "d3ace95b1236482896f5d1921638ada5",
"vmInstanceUuid": "ace37e89d86c4994942f858a67172a0d",
"createDate": "Jun 7, 2017 9:20:32 PM",
"lastOpDate": "Jun 7, 2017 9:20:32 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| vmNicUuid | String | The VM NIC UUID | 0.6 |
| securityGroupUuid | String | The security group UUID | 0.6 |
| vmInstanceUuid | String | The virtual machine UUID | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
QueryVmNicInSecurityGroupAction action = new QueryVmNicInSecurityGroupAction();
action.conditions = asList();
action.sessionId = "fc82274e695143118923150b6008bef2";
QueryVmNicInSecurityGroupAction.Result res = action.call();QueryVmNicInSecurityGroupAction action = QueryVmNicInSecurityGroupAction()
action.conditions = []
action.sessionId = "32b2bfd366774b67a51ebdeb374df1cc"
QueryVmNicInSecurityGroupAction.Result res = action.call()AddSecurityGroupRule
API Request
POST zstack/v1/security-groups/{securityGroupUuid}/rulesAuthorization: OAuth the-session-uuid{
"params": {
"rules": [
{
"type": "Ingress",
"state": "Enabled",
"description": "test",
"remoteSecurityGroupUuid": "7d4337c2b18339ffb6f5d1023fc2ea42",
"ipVersion": 4,
"protocol": "TCP",
"srcIpRange": "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24",
"dstIpRange": "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24",
"dstPortRange": "1000,1001,1002-1005,1008",
"action": "ACCEPT"
}
],
"priority": -1
},
"systemTags": [],
"userTags": []
}
Note: 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 -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X POST -d '{"params":{"rules":[{"type":"Ingress","state":"Enabled","description":"test","remoteSecurityGroupUuid":"7d4337c2b18339ffb6f5d1023fc2ea42","ipVersion":4,"protocol":"TCP","srcIpRange":"10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24","dstIpRange":"10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24","dstPortRange":"1000,1001,1002-1005,1008","action":"ACCEPT"}],"priority":-1}}'
http://localhost:8080/zstack/v1/security-groups/00fdf47ec62b316a8f17c80d0ee59a01/rules| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The security group UUID | 0.6 | |
| rules | List | body (included in the params structure) | The rules in the security group | 0.6 | |
| remoteSecurityGroupUuids (Optional) | List | body (included in the params structure) | The remote security group UUIDs for inter-group policies | 2.1 | |
| priority (Optional) | Integer | body (included in the params structure) | The rule priority | 4.7.21 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "5949aece9cd64d5a939d6dc5e2c1f327",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Sep 22, 2017 12:24:11 PM",
"lastOpDate": "Sep 22, 2017 12:24:11 PM",
"internalId": 0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 |
| protocol | String | The traffic protocol type | 0.6 |
| state | String | The availability state of the rule | 0.6 |
| 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 | The remote security group UUID. | 0.6 |
| allowedCidr | String | The allowed CIDR. The meaning of the allowed CIDR varies depending on the traffic type
|
0.6 |
| startPort | Integer |
|
0.6 |
| endPort | Integer |
|
0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
AddSecurityGroupRuleAction action = new AddSecurityGroupRuleAction();
action.securityGroupUuid = "00fdf47ec62b316a8f17c80d0ee59a01";
action.rules = asList([type:Ingress, state:Enabled, description:test, remoteSecurityGroupUuid:7d4337c2b18339ffb6f5d1023fc2ea42, ipVersion:4, protocol:TCP, srcIpRange:10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24, dstIpRange:10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24, dstPortRange:1000,1001,1002-1005,1008, action:ACCEPT]);
action.priority = -1;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddSecurityGroupRuleAction.Result res = action.call();
AddSecurityGroupRuleAction action = AddSecurityGroupRuleAction()
action.securityGroupUuid = "00fdf47ec62b316a8f17c80d0ee59a01"
action.rules = [[type:Ingress, state:Enabled, description:test, remoteSecurityGroupUuid:7d4337c2b18339ffb6f5d1023fc2ea42, ipVersion:4, protocol:TCP, srcIpRange:10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24, dstIpRange:10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24, dstPortRange:1000,1001,1002-1005,1008, action:ACCEPT]]
action.priority = -1
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddSecurityGroupRuleAction.Result res = action.call()
DeleteSecurityGroupRule
API Request
DELETE zstack/v1/security-groups/rules?ruleUuids={ruleUuids}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 56ec3e843f8e48d1b3cf9e848885dc81" \
-X DELETE http://localhost:8080/zstack/v1/security-groups/rules?ruleUuids=1f0becde585e39d280acbd6c5b21bd39| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| ruleUuids | List | body | The list of security group rule UUIDs | 0.6 | |
| systemTags (Optional) | List | body | System tags | 0.6 | |
| userTags (Optional) | List | body | User tags | 0.6 |
API Response
{
"inventory": {
"uuid": "06abc64deb0b4c8c9dc8831743e34662",
"name": "web",
"description": "for test",
"state": "Enabled",
"createDate": "Jun 7, 2017 9:20:23 PM",
"lastOpDate": "Jun 7, 2017 9:20:23 PM",
"internalId": 0.0
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | The resource name | 0.6 |
| description | String | The detailed description of the resource | 0.6 |
| state | String | The resource state. | 0.6 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 0.6 |
| rules | List | See rules | 0.6 |
| 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 |
|
0.6 |
| endPort | Integer |
|
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 |
|
0.6 |
| remoteSecurityGroupUuid | String | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
DeleteSecurityGroupRuleAction action = new DeleteSecurityGroupRuleAction();
action.ruleUuids = asList("5a88c1873bbf48e4a018f03f6bd055b6");
action.sessionId = "f42c32dbfc214bc58fb057d2c9cb63b1";
DeleteSecurityGroupRuleAction.Result res = action.call();DeleteSecurityGroupRuleAction action = DeleteSecurityGroupRuleAction()
action.ruleUuids = [a9b41667676244e5b3da07d866869b31]
action.sessionId = "f8b0b8d01d8c4adc8058083e9f48a8a9"
DeleteSecurityGroupRuleAction.Result res = action.call()QuerySecurityGroupRule
API Request
GET zstack/v1/security-groups/rules
GET zstack/v1/security-groups/rules/{uuid}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 9aa7adfe564e4acda956ef90430b0f1b" \
-X GET http://localhost:8080/zstack/v1/security-groups/rules?q=endPort=22&q=state=Enabledcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 36a86c5b46784b169fe82d7c990ae1a7" \
-X GET http://localhost:8080/zstack/v1/security-groups/rules/ae59353d95f744b5b4396e1783ddb918Queryable Fields
Run the CLI tool, type QuerySecurityGroupRule and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
{
"inventories": [
{
"uuid": "b3a99fc1548b41778258153cfd70f4b7",
"securityGroupUuid": "629d55f78c9f4b0e8e3504b9834ca1bb",
"type": "Ingress",
"startPort": 22.0,
"endPort": 22.0,
"protocol": "TCP",
"state": "Enabled",
"allowedCidr": "0.0.0.0/0",
"createDate": "Jun 7, 2017 9:20:25 PM",
"lastOpDate": "Jun 7, 2017 9:20:25 PM"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root error: the source error that caused the current error. If there is no original error, this field is null | 0.6 |
| 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 type | 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. 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. For Egress traffic, the allowed CIDR is the destination CIDR that traffic from the VM NIC is permitted to reach | 0.6 |
| remoteSecurityGroupUuid | String | The remote security group UUID. | 0.6 |
| createDate | Timestamp | The creation time | 0.6 |
| lastOpDate | Timestamp | The last modification time | 0.6 |
SDK Examples
QuerySecurityGroupRuleAction action = new QuerySecurityGroupRuleAction();
action.conditions = asList("endPort=22","state=Enabled");
action.sessionId = "362452e4e8a746ce981a5a54c7390445";
QuerySecurityGroupRuleAction.Result res = action.call();QuerySecurityGroupRuleAction action = QuerySecurityGroupRuleAction()
action.conditions = ["endPort=22","state=Enabled"]
action.sessionId = "37e099aa344c40ca947d11dff7ec2b91"
QuerySecurityGroupRuleAction.Result res = action.call()ValidateSecurityGroupRule
API Request
GET zstack/v1/security-groups/{securityGroupUuid}/rules/validationAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X GET http://localhost:8080/zstack/v1/security-groups/0351d8b796bd3165967f13d1da2f9576/rules/validation?type=Ingress&protocol=TCP&remoteSecurityGroupUuid=f938bc96baae3dc4b18be6bdbf34e783&ipVersion=4&srcIpRange=10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24&dstIpRange=10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24&dstPortRange=1000,1001,1002-1005,1008&action=ACCEPT| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The UUID of the security group, uniquely identifying the resource | 4.7.21 | |
| type | String | query | The direction of the security group rule |
|
4.7.21 |
| protocol | String | query | The protocol type of the security group rule |
|
4.7.21 |
| remoteSecurityGroupUuid (Optional) | String | query | The UUID of the remote security group, uniquely identifying the resource | 4.7.21 | |
| ipVersion (Optional) | Integer | query | The IP version of the security group rule |
|
4.7.21 |
| srcIpRange (Optional) | String | query | The source IP range of the security group rule | 4.7.21 | |
| dstIpRange (Optional) | String | query | The destination IP range of the security group rule | 4.7.21 | |
| dstPortRange (Optional) | String | query | The destination port range of the security group rule | 4.7.21 | |
| action (Optional) | String | query | The action of the security group rule |
|
4.7.21 |
| startPort (Optional) | Integer | query | The start port of the security group rule | 4.7.21 | |
| endPort (Optional) | Integer | query | The end port of the security group rule | 4.7.21 | |
| allowedCidr (Optional) | String | query | The IP range of the security group rule | 4.7.21 | |
| systemTags (Optional) | List | body | System tags | 4.7.21 | |
| userTags (Optional) | List | body | User tags | 4.7.21 |
API Response
{
"available": true,
"code": "SG.2000"
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| available | boolean | Whether the rule is available | 4.7.21 |
| code | String | The rule validation error code | 4.7.21 |
| reason | String | The reason | 4.7.21 |
| success | boolean | Whether the operation succeeded. | 4.7.21 |
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error | 4.7.21 |
| 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 |
SDK Examples
ValidateSecurityGroupRuleAction action = new ValidateSecurityGroupRuleAction();
action.securityGroupUuid = "0351d8b796bd3165967f13d1da2f9576";
action.type = "Ingress";
action.protocol = "TCP";
action.remoteSecurityGroupUuid = "f938bc96baae3dc4b18be6bdbf34e783";
action.ipVersion = 4;
action.srcIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24";
action.dstIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24";
action.dstPortRange = "1000,1001,1002-1005,1008";
action.action = "ACCEPT";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ValidateSecurityGroupRuleAction.Result res = action.call();ValidateSecurityGroupRuleAction action = ValidateSecurityGroupRuleAction()
action.securityGroupUuid = "0351d8b796bd3165967f13d1da2f9576"
action.type = "Ingress"
action.protocol = "TCP"
action.remoteSecurityGroupUuid = "f938bc96baae3dc4b18be6bdbf34e783"
action.ipVersion = 4
action.srcIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24"
action.dstIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24"
action.dstPortRange = "1000,1001,1002-1005,1008"
action.action = "ACCEPT"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ValidateSecurityGroupRuleAction.Result res = action.call()ChangeSecurityGroupRule
API Request
PUT zstack/v1/security-groups/rules/{uuid}/actionsAuthorization: OAuth the-session-uuid{
"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": []
}
Note: 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 -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/actions| 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
{
"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 |
|---|---|---|---|
| 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 |
| 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 | The remote security group UUID. | 4.7.21 |
| allowedCidr | String | The allowed CIDR. The meaning of the allowed CIDR varies depending on the traffic type
|
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
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();
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()
ChangeSecurityGroupRuleState
API Request
PUT zstack/v1/security-groups/{securityGroupUuid}/rules/state/actionsAuthorization: OAuth the-session-uuid{
"changeSecurityGroupRuleState": {
"ruleUuids": [
"c895848e49763a85a74d0a8cee5a0720"
],
"state": "Enabled"
},
"systemTags": [],
"userTags": []
}
Note: 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 -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/actions| 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
{
"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 |
|---|---|---|---|
| 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 |
| 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 | The resource state. | 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 | The attached L3 network UUIDs. | 4.7.21 |
| rules | List | See rules | 4.7.21 |
| 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 | The remote security group UUID. | 4.7.21 |
| allowedCidr | String | The allowed CIDR. The meaning of the allowed CIDR varies depending on the traffic type
|
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
ChangeSecurityGroupRuleStateAction action = new ChangeSecurityGroupRuleStateAction();
action.securityGroupUuid = "fbd126afdf6b32caab55327d2901170f";
action.ruleUuids = asList("c895848e49763a85a74d0a8cee5a0720");
action.state = "Enabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeSecurityGroupRuleStateAction.Result res = action.call();ChangeSecurityGroupRuleStateAction action = ChangeSecurityGroupRuleStateAction()
action.securityGroupUuid = "fbd126afdf6b32caab55327d2901170f"
action.ruleUuids = [c895848e49763a85a74d0a8cee5a0720]
action.state = "Enabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeSecurityGroupRuleStateAction.Result res = action.call()UpdateSecurityGroupRulePriority
API Request
PUT zstack/v1/security-groups/{securityGroupUuid}/rules/priority/actionsAuthorization: OAuth the-session-uuid{
"updateSecurityGroupRulePriority": {
"type": "Ingress",
"rules": [
{
"ruleUuid": "7a73154d5d2331308f462c6bf2f725cb",
"priority": 1
}
]
},
"systemTags": [],
"userTags": []
}
Note: 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 -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X PUT -d '{"updateSecurityGroupRulePriority":{"type":"Ingress","rules":[{"ruleUuid":"7a73154d5d2331308f462c6bf2f725cb","priority":1}]}}'
http://localhost:8080/zstack/v1/security-groups/ea321fd5d0f7388e8efd4427c9fae15f/rules/priority/actions| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| securityGroupUuid | String | url | The UUID of the security group, uniquely identifying the resource | 4.7.21 | |
| type | String | body (included in the updateSecurityGroupRulePriority structure) | The type of the rule |
|
4.7.21 |
| rules | List | body (included in the updateSecurityGroupRulePriority structure) | The rule priorities | 4.7.21 | |
| systemTags (Optional) | List | body | System tags | 4.7.21 | |
| userTags (Optional) | List | body | User tags | 4.7.21 |
API Response
{
"inventory": {
"uuid": "777dbc5ec0cb3b14828096daa9e04133",
"name": "test",
"internalId": 0
}
}| 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 |
| 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 | The resource state. | 4.7.21 |
| ipVersion | Integer | The IP version number | 3.1.0 |
| createDate | Timestamp | The creation time | 4.7.21 |
| lastOpDate | Timestamp | The last modification time | 4.7.21 |
| attachedL3NetworkUuids | Set | The attached L3 network UUIDs. | 4.7.21 |
| rules | List | See rules | 4.7.21 |
| 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 | The remote security group UUID. | 4.7.21 |
| allowedCidr | String | The allowed CIDR. The meaning of the allowed CIDR varies depending on the traffic type
|
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
UpdateSecurityGroupRulePriorityAction action = new UpdateSecurityGroupRulePriorityAction();
action.securityGroupUuid = "ea321fd5d0f7388e8efd4427c9fae15f";
action.type = "Ingress";
action.rules = asList([ruleUuid:7a73154d5d2331308f462c6bf2f725cb, priority:1]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSecurityGroupRulePriorityAction.Result res = action.call();UpdateSecurityGroupRulePriorityAction action = UpdateSecurityGroupRulePriorityAction()
action.securityGroupUuid = "ea321fd5d0f7388e8efd4427c9fae15f"
action.type = "Ingress"
action.rules = [[ruleUuid:7a73154d5d2331308f462c6bf2f725cb, priority:1]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSecurityGroupRulePriorityAction.Result res = action.call()QueryVmNicSecurityPolicy
API Request
GET zstack/v1/security-groups/nics/security-policy
GET zstack/security-groups/nics/{uuid}/security-policyAuthorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X GET http://localhost:8080/zstack/v1/security-groups/nics/security-policy?q=ingressPolicy=DROP&q=egressPolicy=DROPcurl -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X GET http://localhost:8080/zstack/v1/security-groups/nics/a4ef9b72cb66352f9040ce0f8c180b80/security-policyQueryable Fields
Run the CLI tool, type QueryVmNicSecurityPolicy and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
{
"inventories": [
{
"vmNicUuid": "40d02946a770317aa1edac79ef350f3f",
"ingressPolicy": "DROP",
"egressPolicy": "ACCEPT",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 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 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| vmNicUuid | String | The VM NIC UUID | 4.7.21 |
| ingressPolicy | String | The ingress security policy of the NIC | 4.7.21 |
| egressPolicy | String | The egress security policy of the NIC | 4.7.21 |
| createDate | Timestamp | The creation time | 4.7.21 |
| lastOpDate | Timestamp | The last modification time | 4.7.21 |
SDK Examples
QueryVmNicSecurityPolicyAction action = new QueryVmNicSecurityPolicyAction();
action.conditions = asList("ingressPolicy=DROP","egressPolicy=DROP");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVmNicSecurityPolicyAction.Result res = action.call();QueryVmNicSecurityPolicyAction action = QueryVmNicSecurityPolicyAction()
action.conditions = ["ingressPolicy=DROP","egressPolicy=DROP"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryVmNicSecurityPolicyAction.Result res = action.call()ChangeVmNicSecurityPolicy
API Request
PUT zstack/v1/security-groups/nics/{vmNicUuid}/security-policy/actionsAuthorization: OAuth the-session-uuid{
"changeVmNicSecurityPolicy": {
"ingressPolicy": "ALLOW",
"egressPolicy": "DENY"
},
"systemTags": [],
"userTags": []
}
Note: 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 -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X PUT -d '{"changeVmNicSecurityPolicy":{"ingressPolicy":"ALLOW","egressPolicy":"DENY"}}'
http://localhost:8080/zstack/v1/security-groups/nics/5551303bee7037c8848cdb5741be7ff7/security-policy/actions| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| vmNicUuid | String | url | The UUID of the NIC, uniquely identifying the resource | 4.7.21 | |
| ingressPolicy (Optional) | String | body (included in the changeVmNicSecurityPolicy structure) | The ingress security policy of the NIC |
|
4.7.21 |
| egressPolicy (Optional) | String | body (included in the changeVmNicSecurityPolicy structure) | The egress security policy of the NIC |
|
4.7.21 |
| systemTags (Optional) | List | body | System tags | 4.7.21 | |
| userTags (Optional) | List | body | User tags | 4.7.21 |
API Response
{
"inventory": {
"uuid": "2c8164f7e3213f1491640a2f98d0a979",
"vmNicUuid": "c731cb960eb635a997e58d154d3c4252",
"ingressPolicy": "DENY",
"egressPolicy": "ALLOW",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 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 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| vmNicUuid | String | The VM NIC UUID | 4.7.21 |
| ingressPolicy | String | The ingress security policy of the NIC | 4.7.21 |
| egressPolicy | String | The egress security policy of the NIC | 4.7.21 |
| createDate | Timestamp | The creation time | 4.7.21 |
| lastOpDate | Timestamp | The last modification time | 4.7.21 |
SDK Examples
ChangeVmNicSecurityPolicyAction action = new ChangeVmNicSecurityPolicyAction();
action.vmNicUuid = "5551303bee7037c8848cdb5741be7ff7";
action.ingressPolicy = "ALLOW";
action.egressPolicy = "DENY";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmNicSecurityPolicyAction.Result res = action.call();ChangeVmNicSecurityPolicyAction action = ChangeVmNicSecurityPolicyAction()
action.vmNicUuid = "5551303bee7037c8848cdb5741be7ff7"
action.ingressPolicy = "ALLOW"
action.egressPolicy = "DENY"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeVmNicSecurityPolicyAction.Result res = action.call()SetVmNicSecurityGroup
API Request
PUT zstack/v1/security-groups/nics/{vmNicUuid}/actionsAuthorization: OAuth the-session-uuid{
"setVmNicSecurityGroup": {
"refs": [
{
"securityGroupUuid": "a63c3b35a6553b4a912ee60cd06d5066",
"priority": 1
}
]
},
"systemTags": [],
"userTags": []
}
Note: 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 -H "Content-Type: application/json;charset=UTF-8"
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c"
-X PUT -d '{"setVmNicSecurityGroup":{"refs":[{"securityGroupUuid":"a63c3b35a6553b4a912ee60cd06d5066","priority":1}]}}'
http://localhost:8080/zstack/v1/security-groups/nics/6b7ad223ebb2328bb646f2e77b34957b/actions| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| vmNicUuid | String | url | The UUID of the NIC, uniquely identifying the resource | 4.7.21 | |
| refs | List | body (included in the setVmNicSecurityGroup structure) | The security groups attached to the NIC | 4.7.21 | |
| systemTags (Optional) | List | body | System tags | 4.7.21 | |
| userTags (Optional) | List | body | User tags | 4.7.21 |
API Response
{
"inventory": [
{
"uuid": "33aa195b943c3faa87e2c75a787cb7f5",
"priority": 1,
"securityGroupUuid": "63ec5dcb248138968f0153160b5b8b3a"
}
]
}| 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 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| priority | Integer | The security group priority | 4.7.21 |
| vmNicUuid | String | The VM NIC UUID | 4.7.21 |
| securityGroupUuid | String | The security group UUID | 4.7.21 |
| vmInstanceUuid | String | The virtual machine UUID | 4.7.21 |
| createDate | Timestamp | The creation time | 4.7.21 |
| lastOpDate | Timestamp | The last modification time | 4.7.21 |
SDK Examples
SetVmNicSecurityGroupAction action = new SetVmNicSecurityGroupAction();
action.vmNicUuid = "6b7ad223ebb2328bb646f2e77b34957b";
action.refs = asList([securityGroupUuid:a63c3b35a6553b4a912ee60cd06d5066, priority:1]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVmNicSecurityGroupAction.Result res = action.call();SetVmNicSecurityGroupAction action = SetVmNicSecurityGroupAction()
action.vmNicUuid = "6b7ad223ebb2328bb646f2e77b34957b"
action.refs = [[securityGroupUuid:a63c3b35a6553b4a912ee60cd06d5066, priority:1]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetVmNicSecurityGroupAction.Result res = action.call()