describe_vswitches
Query and list VSwitches in Alibaba Cloud RDS environments using region, VPC, or specific identifiers to manage network configurations.
Instructions
Query VSwitch list.
Args:
region_id: The region ID of the VSwitch. At least one of region_id or vpc_id must be specified.
vpc_id: The ID of the VPC to which the VSwitch belongs. At least one of region_id or vpc_id must be specified.
vswitch_id: The ID of the VSwitch to query.
zone_id: The zone ID of the VSwitch.
vswitch_name: The name of the VSwitch.
resource_group_id: The resource group ID of the VSwitch.
page_number: The page number of the list. Default: 1.
page_size: The number of entries per page. Maximum value: 50. Default: 10.
Returns:
Dict[str, Any]: The response containing the list of VSwitches.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region_id | No | ||
| vpc_id | No | ||
| vswitch_id | No | ||
| zone_id | No | ||
| vswitch_name | No | ||
| is_default | No | ||
| resource_group_id | No | ||
| page_number | No | ||
| page_size | No |
Implementation Reference
- The handler function that executes the describe_vswitches tool. It queries Alibaba Cloud VPC for VSwitch details using the DescribeVSwitches API, handling parameters like region_id, vpc_id, zone_id, etc., and returns the response.@mcp.tool(annotations=READ_ONLY_TOOL) async def describe_vswitches( region_id: str = None, vpc_id: str = None, vswitch_id: str = None, zone_id: str = None, vswitch_name: str = None, is_default: bool = None, resource_group_id: str = None, page_number: int = 1, page_size: int = 10, ) -> Dict[str, Any]: """Query VSwitch list. Args: region_id: The region ID of the VSwitch. At least one of region_id or vpc_id must be specified. vpc_id: The ID of the VPC to which the VSwitch belongs. At least one of region_id or vpc_id must be specified. vswitch_id: The ID of the VSwitch to query. zone_id: The zone ID of the VSwitch. vswitch_name: The name of the VSwitch. resource_group_id: The resource group ID of the VSwitch. page_number: The page number of the list. Default: 1. page_size: The number of entries per page. Maximum value: 50. Default: 10. Returns: Dict[str, Any]: The response containing the list of VSwitches. """ try: # Initialize the client if not region_id and not vpc_id: raise OpenAPIError("At least one of region_id or vpc_id must be specified") client = get_vpc_client(region_id) # Create request request = vpc_20160428_models.DescribeVSwitchesRequest( page_number=page_number, page_size=page_size ) # Add optional parameters if provided if vpc_id: request.vpc_id = vpc_id if vswitch_id: request.vswitch_id = vswitch_id if zone_id: request.zone_id = zone_id if vswitch_name: request.vswitch_name = vswitch_name if is_default is not None: request.is_default = is_default if resource_group_id: request.resource_group_id = resource_group_id # Make the API request response = client.describe_vswitches(request) return response.body.to_map() except Exception as e: logger.error(f"Error occurred while querying VSwitches: {str(e)}") raise OpenAPIError(f"Failed to query VSwitches: {str(e)}")