Listing Subnets
Function
Lists subnets.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
workspace:networks:listSubnets
List
-
-
-
- vpc:subnets:list
- vpc:subnets:get
URI
GET /v2/{project_id}/subnets
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Project ID. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
vpc_id |
No |
String |
VPC ID. |
|
availability_zone_id |
No |
String |
AZ ID. |
Request Parameters
None
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
subnets |
Array of SingleSubnetInfo objects |
Subnet list. |
|
subnet_size |
Integer |
Number of subnets. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Subnet ID. |
|
unused |
Boolean |
Whether the subnet is not used by Workspace. If the subnet is not used, it can be deleted from Workspace. |
|
checked |
Boolean |
Whether the subnet is used by Workspace. |
|
vpc_id |
String |
VPC ID. |
|
name |
String |
Subnet name. |
|
cidr |
String |
Subnet CIDR block. |
|
gateway_ip |
String |
Subnet gateway. |
|
dhcp_enable |
Boolean |
Whether DHCP is supported. |
|
ipv6_enable |
Boolean |
Whether IPV6 is supported. |
|
primary_dns |
String |
Primary DNS. |
|
secondary_dns |
String |
Secondary DNS. |
|
status |
String |
Subnet status. |
|
availability_zone |
String |
AZ. |
|
neutron_subnet_id |
String |
Network ID. |
|
neutron_ipv6_subnet_id |
String |
IPv6 network ID. |
|
description |
String |
Description. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 404
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 405
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Status code: 503
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_msg |
String |
Error message. |
|
encoded_authorization_message |
String |
Encrypted detailed reason for rejection. You can call the API decode-authorization-message of STS to decrypt the reason. |
Example Requests
GET /v2/0e3f393ae380f5d12facc005678bcd4b/subnets?vpc_id=dec4a11c-717e-4337-8985-81425133dc32
Example Responses
Status code: 200
Response to the request for listing subnets.
{
"subnets" : [ {
"id" : "63cdf62c-6114-469d-a16d-9b8128e75106",
"vpc_id" : "210a7165-439f-46ea-96a8-3ba3981b6f49",
"name" : "subnet-cyctest",
"cidr" : "192.168.2.0/24",
"gateway_ip" : "192.168.2.1",
"dhcp_enable" : "true",
"ipv6_enable" : "false",
"primary_dns" : "100.79.1.250",
"status" : "ACTIVE",
"availability_zone" : "cn-north-7a",
"neutron_subnet_id" : "6081c420-23cb-4741-9bfd-743e71372604",
"description" : "aabb"
}, {
"id" : "7f8022b3-937d-4259-8459-b58ce160dca5",
"vpc_id" : "46eddaf2-fb03-4645-8d23-5f741aee76ed",
"name" : "subnet-sce01",
"cidr" : "192.168.0.0/24",
"gateway_ip" : "192.168.0.1",
"dhcp_enable" : true,
"ipv6_enable" : false,
"primary_dns" : "100.79.1.250",
"status" : "ACTIVE",
"availability_zone" : "cn-north-7a",
"neutron_subnet_id" : "f002b78d-bba3-4e78-95ad-60448b5c5d56",
"description" : "test"
} ]
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Response to the request for listing subnets. |
|
400 |
The request cannot be understood by the server due to malformed syntax. |
|
401 |
Authentication failed. |
|
403 |
No operation permissions. |
|
404 |
No resources found. |
|
405 |
The method specified in the request is not allowed. |
|
500 |
An internal service error occurred. For details about the error code, see the error code description. |
|
503 |
Service unavailable. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot