• Virtual Private Cloud

vpc
  1. Help Center
  2. Virtual Private Cloud
  3. API Reference
  4. APIs
  5. Security Group
  6. Associating Multiple NIC Ports to or Disassociating Them from a Security Group at a Time

Associating Multiple NIC Ports to or Disassociating Them from a Security Group at a Time

Function

This interface 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 Parameter description

Name

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 parameter

    Name

    Mandatory

    Type

    Description

    ports

    Yes

    List<port>

    Specifies the port list. A maximum of 20 ports are supported.

    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 Port

    Name

    Mandatory

    Type

    Description

    id

    Yes

    String

    Specifies the port ID, which uniquely identifies the port.

  • Example request
    {
        "ports": [
            {
                "id": "b9ac5247-c4ca-4c9b-b8fa-7d19132e560a"
            },
            {
                "id": "aa2f8625-0042-4627-a05c-61500b604cc3"
            }
        ],
        "action": "add"
    }

Response Message

  • Response parameter
    Table 4 Response parameter

    Name

    Type

    Description

    fail

    List<fail>

    Specifies the failed ports. If all ports are associated with or disassociated from the security group successfully, the fail list in the response body is blank.

    Table 5 Failed ports

    Name

    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"
            }
        ]
    }
  • Example abnormal response
    {
        "code": "VPC.0606",
        "message": "Request is invalid"
    }

Status Codes

For details, see section Status Codes.

Error Codes

For details, see section Error Codes.