You can call the DescribeVSwitches operation to query the details about vSwitches that belong to a virtual private cloud (VPC).

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeVSwitches

The operation that you want to perform. Set the value to DescribeVSwitches.

RegionId String No cn-hangzhou

The ID of the region to which the vSwitch belongs. You can call the DescribeRegions operation to query the most recent region list.

VpcId String No vpc-bp1opxu1zkhn**********

The ID of the VPC to which the vSwitch belongs.

Note You must specify this parameter or the DedicatedHostGroupId parameter.
ZoneId String No cn-hangzhou-i

The ID of the zone to which the vSwitch belongs. You can call the DescribeAvailableZones operation to query the ID of the zone. If you specify this parameter, the query results are filtered based on the value of this parameter and only the details about the vSwitches that are deployed in the specified zone are returned.

DedicatedHostGroupId String No dhg-7a9********

The ID of the dedicated cluster. You can call the DescribeDedicatedHostGroups operation to query the ID of the dedicated cluster. If you specify this parameter, the details about all vSwitches in the VPC to which the dedicated cluster belongs are returned.

Note You must specify this parameter or the VpcId parameter.
PageNumber Integer No 1

The number of the page to return. Default value: 1.

PageSize Integer No 30

The number of entries to return on each page. Valid values: 1 to 50. Default value: 30.

ResourceGroupId String No rg-bp67acfmxazb4p****

The ID of the resource group.

Response parameters

Parameter Type Example Description
RequestId String 8A68AEA1-AFBD-53F8-9BBB-06555EAE5C0E

The ID of the request.

TotalCount Integer 2

The total number of returned entries.

PageNumber Integer 1

The page number of the returned page.

PageSize Integer 30

The number of entries returned on each page. The value of this parameter is the same as the value of the PageSize parameter in the request parameters.

VSwitchs Array of VSwitch

The details about the vSwitches.

CidrBlock String 172.16.0.0/24

The CIDR block of the vSwitches.

Description String VSwitchDescription

The description of the vSwitches.

IsDefault Boolean true

Indicates whether the vSwitch is the default vSwitch. Valid values:

  • true: The vSwitch is the default vSwitch.
  • false: The vSwitch is not the default vSwitch.
IzNo String cn-hangzhou-h

The ID of the zone to which the vSwitch belongs.

Status String Available

The status of the vSwitch. Valid values:

  • Pending: The vSwitch is being configured.
  • Available: The vSwitch is available.
VSwitchId String vsw-bp1pnaz94xc**********

The ID of the vSwitch

VSwitchName String test

The name of the vSwitch.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=DescribeVSwitches
&ResourceOwnerId=0
&RegionId=cn-hangzhou
&VpcId=vpc-bp1opxu1zkhn**********
&ZoneId=cn-hangzhou-h
&PageNumber=1
&PageSize=30
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeVSwitchesResponse>
    <VSwitchs>
        <IsDefault>false</IsDefault>
        <Status>Available</Status>
        <IzNo>cn-hangzhou-h</IzNo>
        <Description/>
        <VSwitchId>vsw-bp1pnaz94xc**********</VSwitchId>
        <CidrBlock>192.168.0.1/24</CidrBlock>
        <VSwitchName>test</VSwitchName>
    </VSwitchs>
    <VSwitchs>
        <IsDefault>true</IsDefault>
        <Status>Available</Status>
        <IzNo>cn-hangzhou-h</IzNo>
        <Description>System created default virtual switch.</Description>
        <VSwitchId>vsw-bp10aqj6o4l**********</VSwitchId>
        <CidrBlock>172.16.0.1/20</CidrBlock>
        <VSwitchName/>
    </VSwitchs>
    <TotalCount>2</TotalCount>
    <RequestId>A5362A78-1B78-53D7-AFBA-E375D9C26F2F</RequestId>
    <PageSize>30</PageSize>
    <PageNumber>1</PageNumber>
</DescribeVSwitchesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "VSwitchs" : [ {
    "IsDefault" : false,
    "Status" : "Available",
    "IzNo" : "cn-hangzhou-h",
    "Description" : "",
    "VSwitchId" : "vsw-bp1pnaz94xc**********",
    "CidrBlock" : "192.168.0.1/24",
    "VSwitchName" : "test"
  }, {
    "IsDefault" : true,
    "Status" : "Available",
    "IzNo" : "cn-hangzhou-h",
    "Description" : "System created default virtual switch.",
    "VSwitchId" : "vsw-bp10aqj6o4l**********",
    "CidrBlock" : "172.16.0.1/20",
    "VSwitchName" : ""
  } ],
  "TotalCount" : 2,
  "RequestId" : "A5362A78-1B78-53D7-AFBA-E375D9C26F2F",
  "PageSize" : 30,
  "PageNumber" : 1
}

Error codes

HTTP status code Error code Error message Description
400 InvalidVSwitchId.NotFound Specified virtual switch is not found in specified VPC. The error message returned because no vSwitches are available in the VPC.
400 IncorrecttVpcId The specified parameter VPCId is not valid. The error message returned because the value of the VpcId parameter is invalid. Specify a valid value for the VpcId parameter.
400 InvalidIzNo.NotSupported Specified VPC zone is not supported. The error message returned because the zone is not supported by the specified VPC. Specify a valid zone ID and try again.

For a list of error codes, visit the API Error Center.