Updated on 2024-04-15 GMT+08:00

Associating Subnets with a Route Table

Function

This API is used to associate a subnet with a route table.

If a subnet has already been associated with route table A, you can associate the subnet with route table B directly without disassociating it from route table A first.

URI

POST /v1/{project_id}/routetables/{routetable_id}/action

Table 1 describes the parameters.

Table 1 Parameter description

Name

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

routetable_id

Yes

String

Specifies the route table ID, which uniquely identifies a route table.

Request Parameters

Table 2 Request parameter

Name

Mandatory

Type

Description

routetable

Yes

routetable object

Specifies the route table. For details, see Table 3.

Table 3 Description of the routetable field

Name

Mandatory

Type

Description

subnets

Yes

subnet object

  • Specifies the subnets associated with the route table.
  • Only subnets in the VPC that the route table belongs to can be associated with the route table.
Table 4 Description of the subnet field

Name

Mandatory

Type

Description

associate

No

Array of strings

Specifies a list of IDs of the subnets to be associated with the route table.

disassociate

No

Array of strings

Specifies a list of IDs of the subnets to be disassociated from the route table.

Example Request

  • Associate route table 3d42a0d4-a980-4613-ae76-a2cddecff054 with subnet 1a8b8c98-3976-401b-a735-8b058109268c.
    POST https://{Endpoint}/v1/6fbe9263116a4b68818cf1edce16bc4f/routetables/3d42a0d4-a980-4613-ae76-a2cddecff054/action
    
    {
        "routetable": {
            "subnets": {
                "associate": [
                    "1a8b8c98-3976-401b-a735-8b058109268c"
                ]
            }
        }
    }

Response Parameters

Table 5 Response parameter

Name

Type

Description

routetable

routetable object

Specifies the route table. For details, see Table 6.

Table 6 Description of the routetable field

Parameter

Type

Description

id

String

  • Specifies the route table ID, which uniquely identifies the route table.
  • The value must be in standard UUID format.

name

String

  • Specifies the route table name.
  • The value can contain no more than 64 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

default

Boolean

  • Specifies whether the route table is the default one.
  • The value can be true (default route table) or false (custom route table).

routes

Array of route objects

  • Specifies the route list. For details, see Table 7.
  • Each route table can have a maximum of 200 routes.

subnets

Array of subnet objects

  • Specifies the subnets associated with the route table. For details, see Table 8.
  • Only subnets in the VPC to which the route table belongs can be associated with the route table.

tenant_id

String

  • Specifies the project ID.

vpc_id

String

  • Specifies the ID of the VPC associated with the route table.

description

String

  • Provides supplementary information about the route table.
  • The value can contain no more than 255 characters and cannot contain angle brackets (< or >).
Table 7 Description of the route field

Name

Type

Description

type

String

  • Specifies the route type.
  • Values:
    • ecs (ECS)
    • eni (NIC)
    • vip (Virtual IP address)
    • nat (NAT gateway)
    • peering (VPC peering connection)
    • egw: VPC endpoint node

destination

String

  • Specifies the destination CIDR block of a route.
  • The value must be in the valid CIDR format.

nexthop

String

  • Specifies the ID of the next hop in the route.
  • Values:
    • When type is ecs, the value is an ECS ID.
    • When type is eni, the value is an extension NIC ID.
    • When type is vip, the value is a virtual IP address.
    • When type is nat, the value a NAT gateway ID.
    • When type is peering, the value is a VPC peering connection ID.
    • When type is cc, the value is a Cloud Connect connection ID.
    • When type is set to egw, the value is a VPC endpoint ID.

description

String

  • Provides supplementary information about the route.
  • The value can contain up to 255 characters and cannot contain angle brackets (< or >).
Table 8 Description of the subnet field

Name

Type

Description

id

String

Specifies the ID of the subnet associated with the route table.

Example Response

{
    "routetable": {
        "id": "3d42a0d4-a980-4613-ae76-a2cddecff054",
        "vpc_id": "ab78be2d-782f-42a5-aa72-35879f6890ff",
        "description": "abc",
        "routes": [
            {
                "type": "ecs",
                "destination": "10.10.10.0/24",
                "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341",
                "description": "abc"
            }
        ],
        "subnets": [
            {
                "id": "8d4ce32f-d68a-4c4c-9f18-c68d8a5c7f2f"
            }
        ],
        "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f"
    }
}

Status Code

See Status Codes.

Error Code

See Error Codes.