- 获取阿里云服务器列表的API接口示例:
GET /api/servers
Request:
{
"apiKey": "your-api-key",
"secretKey": "your-secret-key"
}
Response:
{
"servers": [
{
"serverId": "server1",
"serverName": "Test Server 1",
"ipAddress": "192.168.1.1",
"status": "running"
},
{
"serverId": "server2",
"serverName": "Test Server 2",
"ipAddress": "192.168.1.2",
"status": "stopped"
}
]
}
- 开启阿里云服务器的API接口示例:
POST /api/server/start
Request:
{
"apiKey": "your-api-key",
"secretKey": "your-secret-key",
"serverId": "server1"
}
Response:
{
"message": "Server server1 started successfully"
}
- 关闭阿里云服务器的API接口示例:
POST /api/server/stop
Request:
{
"apiKey": "your-api-key",
"secretKey": "your-secret-key",
"serverId": "server1"
}
Response:
{
"message": "Server server1 stopped successfully"
}
- 获取全部实例信息接口:
请求方式:GET
接口地址:https://api.aliyun.com/instances
请求参数:无
返回结果示例:
{
“code”: 200,
“message”: “获取实例信息成功”,
“data”: [
{
"instance_id": "123456",
"instance_name": "example_instance",
"instance_type": "t5.large",
"instance_status": "running"
},
{
"instance_id": "789012",
"instance_name": "example_instance_2",
"instance_type": "t5.medium",
"instance_status": "stopped"
}
]
}
- 创建实例接口:
请求方式:POST
接口地址:https://api.aliyun.com/create_instance
请求参数:
{
“instance_name”: “new_instance”,
“instance_type”: “t5.small”,
“region_id”: “cn-hangzhou”,
“image_id”: “ubuntu_20_04”,
“security_group_id”: “sg-123456”
}
返回结果示例:
{
“code”: 200,
“message”: “创建实例成功”,
“instance_id”: “345678”
}
- 停止实例接口:
请求方式:POST
接口地址:https://api.aliyun.com/stop_instance
请求参数:
{
“instance_id”: “123456”
}
返回结果示例:
{
“code”: 200,
“message”: “停止实例成功”,
“instance_id”: “123456”
}
发布者:luotuoemo,转转请注明出处:https://www.jintuiyun.com/156901.html