Help Center/ Virtual Private Cloud/ API Reference/ VPC APIs (V3)/ VPC/ Querying the Details of a VPC
Updated on 2025-08-19 GMT+08:00

Querying the Details of a VPC

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.

Calling Method

For details, see Calling APIs.

URI

GET /v3/{project_id}/vpc/vpcs/{vpc_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • Definition: ID of the project that a VPC belongs to. For details about how to obtain a project ID, see Obtaining a Project ID.

  • Range: None

vpc_id

Yes

String

  • Definition: VPC ID, which uniquely identifies the VPC.

  • Range: None

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

request_id

String

  • Definition: Request ID.

  • Range: None

vpc

Vpc object

  • Definition: Response body for querying details about a VPC.

  • Range: None

Table 3 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 4 CloudResource

Parameter

Type

Description

resource_type

String

  • Definition: Resource type.

  • Range: None

resource_count

Integer

  • Definition: Number of resources.

  • Range: None

Table 5 ResponseTag

Parameter

Type

Description

key

String

Definition:

Tag key.

Range:

  • A tag key can contain a maximum of 128 Unicode characters and cannot be left blank.

  • Each tag key of a resource must be unique.

  • The value can contain:

    • Letters

    • Digits

    • Special characters: underscores (_), hyphens (-)

    • Chinese characters

value

String

Definition:

Tag value.

Range:

  • Each value can contain a maximum of 255 Unicode characters and can be left blank.

  • The value can contain:

    • Letters

    • Digits

    • Special characters: underscores (_), hyphens (-), periods (.)

    • Chinese characters

Example Requests

Querying the details of a VPC

GET https://{Endpoint}/v3/{project_id}/vpc/vpcs/0552091e-b83a-49dd-88a7-4a5c86fd9ec3

Example Responses

Status code: 200

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

{
  "request_id" : "84eb4f775d66dd916db121768ec55626",
  "vpc" : {
    "id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3",
    "name" : "name-test",
    "description" : "description-test",
    "cidr" : "192.168.0.0/16",
    "extend_cidrs" : [ "21.8.0.0/16" ],
    "enterprise_project_id" : "0",
    "tags" : [ {
      "key" : "key",
      "value" : "value"
    } ],
    "cloud_resources" : [ {
      "resource_type" : "routetable",
      "resource_count" : 1
    } ],
    "status" : "ACTIVE",
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "created_at" : "2018-03-23T09:26:08",
    "updated_at" : "2018-08-24T08:49:53"
  }
}

SDK Sample Code

The SDK sample code is as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.vpc.v3.region.VpcRegion;
import com.huaweicloud.sdk.vpc.v3.*;
import com.huaweicloud.sdk.vpc.v3.model.*;


public class ShowVpcSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        VpcClient client = VpcClient.newBuilder()
                .withCredential(auth)
                .withRegion(VpcRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowVpcRequest request = new ShowVpcRequest();
        request.withVpcId("{vpc_id}");
        try {
            ShowVpcResponse response = client.showVpc(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkvpc.v3.region.vpc_region import VpcRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkvpc.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = VpcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(VpcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowVpcRequest()
        request.vpc_id = "{vpc_id}"
        response = client.show_vpc(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    vpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := vpc.NewVpcClient(
        vpc.VpcClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowVpcRequest{}
	request.VpcId = "{vpc_id}"
	response, err := client.ShowVpc(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

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

Error Codes

See Error Codes.