Function
This API is used to associate multiple NIC ports to or disassociate them from a specified security group at a time.
Restrictions
- A maximum of 20 ports can be associated to or disassociated from a security group at a time. Therefore, the ports can contain a maximum of 20 values.
- No error message is displayed if a port is repeatedly associated with a security group.
URI
POST /v2.0/{project_id}/security-groups/{security_group_id}/instance/action
Table 1 describes the parameters.
Table 1 Parameter descriptionParameter
|
Mandatory
|
Description
|
project_id
|
Yes
|
Specifies the project ID.
|
security_group_id
|
Yes
|
Specifies the security group ID, which uniquely identifies the security group.
|
Request Message
- Request parameter
Table 2 Request parameterParameter
|
Mandatory
|
Type
|
Description
|
ports
|
Yes
|
Array of Port objects
|
Specifies the port list. A maximum of 20 ports are supported. For details, see Table 3.
|
action
|
Yes
|
String
|
Specifies the operation. The value can be add (associate) or remove (disassociate). The values are case-insensitive.
|
Table 3 Description of field PortParameter
|
Mandatory
|
Type
|
Description
|
id
|
Yes
|
String
|
Specifies the port ID that uniquely identifies the port.
|
- Example request
POST https://{Endpoint}/v1/{project_id}/security-groups/0c4a2336-b036-4fa2-bc3c-1a291ed4c431/instance/action
{
"ports": [
{
"id": "b9ac5247-c4ca-4c9b-b8fa-7d19132e560a"
},
{
"id": "aa2f8625-0042-4627-a05c-61500b604cc3"
}
],
"action": "add"
}
Response Message
- Response parameter
Table 4 Response parameterParameter
|
Type
|
Description
|
fail
|
fail object
|
Specifies the failed ports. For details, see Table 5.
If all ports are associated with or disassociated from the security group successfully, the fail list in the response body is blank.
|
Table 5 fail objectsParameter
|
Type
|
Description
|
id
|
String
|
Specifies the ID of the failed port, which uniquely identifies the port.
|
error_code
|
String
|
Specifies the error code.
|
error_msg
|
String
|
Specifies the error message.
|
- Example normal response 1
Multiple NIC ports are successfully associated to or disassociated from a security group at a time.
{
"fail": []
}
- Example normal response 2
Some NIC ports fail to be associated to or disassociated from a security group at a time.
{
"fail": [
{
"id": "99d9d709-8478-4b46-9f3f-2206b1023fd3",
"error_code": "VPC.0608",
"error_msg": "{\"NeutronError\":{\"message\":\"Port 99d9d709-8478-4b46-9f3f-2206b1023fd3 could not be found.\",\"type\":\"PortNotFound\",\"detail\":\"\"}}"
},
{
"id": "aa2f8625-0042-4627-a05c-61500b604cc3",
"error_code": "VPC.0607",
"error_msg": "An instance must belong to at least one security group"
}
]
}