Querying VPCs

Function

After a VPC is created, you can call this API to query all information about the VPC, including the VPC name, ID, and CIDR block.

Constraints

This API is used to query all VPCs accessible to the tenant submitting the request. A maximum of 2000 records can be returned for each query. If the number of records exceeds 2000, the pagination marker will be returned.

URI

GET /v3/{project_id}/vpc/vpcs

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • Definition: ID of the project that a VPC belongs to.

  • Range: None

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

  • Definition: Number of records returned on each page.

  • Range: 0-2000

marker

No

String

  • Definition: ID of the resource from which the pagination query starts. If the parameter is left blank, only resources on the first page are queried.

  • Range: VPC ID.

id

No

Array of strings

  • Definition: VPC ID, which can be used to filter VPCs.

  • Range: None

name

No

Array of strings

  • Definition: VPC name, which can be used to filter VPCs.

  • Range: None

description

No

Array of strings

  • Definition: VPC description, which can be used to filter VPCs.

  • Range: None

cidr

No

Array of strings

  • Definition: CIDR block of a VPC, which can be used to filter VPCs.

  • Range: None

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

request_id

String

  • Definition: Request ID.

  • Range: None

vpcs

Array of Vpc objects

  • Definition: Response body for querying VPCs.

  • Range: None

page_info

PageInfo object

  • Definition: Pagination information.

  • Range: None

Table 4 Vpc

Parameter

Type

Description

id

String

  • Definition: VPC ID. After a VPC is created, a VPC ID is generated, which uniquely identifies the VPC.

  • Range: The value is in UUID format with hyphens (-).

name

String

  • Definition: VPC name.

  • Range: The value can contain 0 to 64 characters. It can include letters, digits, underscores (_), hyphens (-), and periods (.).

description

String

  • Definition: Description of a VPC.

  • Range: The value can contain no more than 255 characters and cannot contain angle brackets (< or >).

cidr

String

  • Definition: Available subnets in a VPC.

  • Range:

    • 10.0.0.0/8-24: The IP address ranges from 10.0.0.0 to 10.255.255.255, and the netmask ranges from 8 to 24.

    • 172.16.0.0/12-24: The IP address ranges from 172.16.0.0 to 172.31.255.255, and the netmask ranges from 12 to 24.

    • 192.168.0.0/16-24: The IP address ranges from 192.168.0.0 to 192.168.255.255, and the netmask ranges from 16 to 24.

    • If cidr is not specified, the default value is "".

extend_cidrs

Array of strings

  • Definition: Secondary CIDR blocks of a VPC.

  • Range: The following CIDR blocks are not supported:

    • 10.0.0.0/8: The IP address range is 10.0.0.0-10.255.255.255.

    • 172.16.0.0/12: The IP address range is 172.16.0.0-172.31.255.255.

    • 192.168.0.0/16: The IP address range is 192.168.0.0-192.168.255.255.

    • 172.31.0.0/16: The IP address range is 172.31.0.0-172.31.255.255.

    • 100.64.0.0/10: The IP address range is 100.64.0.0-100.127.255.255.

    • 214.0.0.0/7: The IP address range is 214.0.0.0-215.255.255.255.

    • 198.18.0.0/15: The IP address range is 198.18.0.0-198.19.255.255.

    • 169.254.0.0/16: The IP address range is 169.254.0.0-169.254.255.255.

    • 0.0.0.0/8: The IP address range is 0.0.0.0-0.255.255.255.

    • 127.0.0.0/8: The IP address range is 127.0.0.0-127.255.255.255.

    • 240.0.0.0/4: The IP address range is 240.0.0.0-255.255.255.255.

status

String

  • Definition: VPC status.

  • Range:

    • PENDING: The VPC is being created.

    • ACTIVE: The VPC is created.

project_id

String

  • Definition: ID of the project that a VPC belongs to.

  • Range: None

enterprise_project_id

String

  • Definition: ID of the enterprise project that a VPC belongs to.

  • Range: The value is 0 or a string that contains a maximum of 36 characters in UUID format with hyphens (-). 0 indicates the default enterprise project.

created_at

String

  • Definition: Time when a VPC was created.

  • Range: UTC time in the format of yyyy-MM-ddTHH:mm:ssZ

updated_at

String

  • Definition: Time when a VPC was updated.

  • Range: UTC time in the format of yyyy-MM-ddTHH:mm:ssZ

cloud_resources

Array of CloudResource objects

  • Definition: Type and number of resources associated with a VPC. For example, subnets and route tables.

  • Range: None

tags

Array of ResponseTag objects

  • Definition: Tags of a VPC, including tag keys and tag values, which can be used to classify and identify resources. For details, see the tag objects.

  • Range: None

Table 5 CloudResource

Parameter

Type

Description

resource_type

String

  • Definition: Resource type.

  • Range: None

resource_count

Integer

  • Definition: Number of resources.

  • Range: None

Table 6 ResponseTag

Parameter

Type

Description

key

String

  • Definition: Tag key.

  • Range:

    • Each key can contain up to 36 Unicode characters and cannot be left blank.

    • Each key value of a resource must be unique.

    • The value can contain:

      • Letters

      • Digits

      • Special characters: underscores (_) ,at signs (@), and hyphens (-)

value

String

  • Definition: Tag value.

  • Range:

    • Each value can contain up to 43 Unicode characters and can be left blank.

    • The value can contain:

      • Letters

      • Digits

      • Special characters: underscore (_), at signs (@), and hyphen (-)

Table 7 PageInfo

Parameter

Type

Description

previous_marker

String

  • Definition: The first record on the current page.

  • Range: None

current_count

Integer

  • Definition: Total number of records on the current page.

  • Range: None

next_marker

String

  • Definition: The last record on the current page. The parameter next_marker does not exist if the page is the last one.

  • Range: None

Example Requests

  • Querying VPCs

    GET https://{Endpoint}/v3/{project_id}/vpc/vpcs
    
  • Querying VPCs by VPC ID

    GET https://{Endpoint}/v3/{project_id}/vpc/vpcs?id=01ab4be1-4447-45fb-94be-3ee787ed4ebe&id=02cd5ef2-4447-36fb-75be-3ee787ed6adf
    
  • Querying VPCs by VPC name

    GET https://{Endpoint}/v3/{project_id}/vpc/vpcs?name=vpc-test
    
  • Querying VPCs by page

    GET https://{Endpoint}/v3/{project_id}/vpc/vpcs?limit=2&marker=01ab4be1-4447-45fb-94be-3ee787ed4ebe
    

Example Responses

Status code: 200

Normal response to the GET operation. For more status codes, see Status Code.

{
  "request_id" : "9c1838ba498249547be43dd618b58d27",
  "vpcs" : [ {
    "id" : "01da5a65-0bb9-4638-8ab7-74c64e24a9a7",
    "name" : "API-PERF-TEST-14bd44c121",
    "description" : "",
    "cidr" : "192.168.0.0/16",
    "extend_cidrs" : [ ],
    "status" : "ACTIVE",
    "project_id" : "087679f0aa80d32a2f4ec0172f5e902b",
    "enterprise_project_id" : "0",
    "tags" : [ ],
    "created_at" : "2020-06-16T02:32:18Z",
    "updated_at" : "2020-06-16T02:32:18Z",
    "cloud_resources" : [ {
      "resource_type" : "routetable",
      "resource_count" : 1
    }, {
      "resource_type" : "virsubnet",
      "resource_count" : 0
    } ]
  }, {
    "id" : "43fd79b0-f7d7-4e9b-828b-2d4d7bfae428",
    "name" : "API-PERF-TEST_m2n33",
    "description" : "",
    "cidr" : "192.168.0.0/16",
    "extend_cidrs" : [ ],
    "status" : "ACTIVE",
    "project_id" : "087679f0aa80d32a2f4ec0172f5e902b",
    "enterprise_project_id" : "0",
    "tags" : [ ],
    "created_at" : "2020-06-15T06:29:40Z",
    "updated_at" : "2020-06-15T06:29:41Z",
    "cloud_resources" : [ {
      "resource_type" : "routetable",
      "resource_count" : 1
    }, {
      "resource_type" : "virsubnet",
      "resource_count" : 1
    } ]
  }, {
    "id" : "5ed053ba-b46c-4dce-a1ae-e9d8a7015f21",
    "name" : "API-PERF-TEST-c34b1c4b12",
    "description" : "",
    "cidr" : "192.168.0.0/16",
    "extend_cidrs" : [ ],
    "status" : "ACTIVE",
    "project_id" : "087679f0aa80d32a2f4ec0172f5e902b",
    "enterprise_project_id" : "0",
    "tags" : [ ],
    "created_at" : "2020-06-16T02:32:33Z",
    "updated_at" : "2020-06-16T02:32:33Z",
    "cloud_resources" : [ {
      "resource_type" : "routetable",
      "resource_count" : 1
    }, {
      "resource_type" : "virsubnet",
      "resource_count" : 0
    } ]
  } ],
  "page_info" : {
    "previous_marker" : "01da5a65-0bb9-4638-8ab7-74c64e24a9a7",
    "current_count" : 3
  }
}

Status Codes

Status Code

Description

200

Normal response to the GET operation. For more status codes, see Status Code.

Error Codes

See Error Codes.