云硬盘列表
该接口通过鉴权接口颁发的token作为访问令牌,获取云硬盘列表,可以列表可以查看云硬盘详情信息,如云硬盘状态。
1.接口描述
接口请求地址:POST v1/PveMachineHardDisk/open/getList
2.输入参数
| 参数名称 | 描述 | 是否必选 | 类型 | Location |
|---|---|---|---|---|
| Finovy-Access-Token | 令牌-口令 | yes | string | header |
| page | 起始页 | yes | integer | body |
| pageSize | 页大小,单次最多只支持查询100条 | yes | integer | body |
| pveId | 主机实例ID | no | string | body |
| area | 云硬盘可用区域(0华南、1华西、2国际) | no | string | body |
| useType | 付费方式(0按量,1包时段) | no | string | body |
| status | 云硬盘状态(0待挂载、1挂载中、2使用中、3欠费停服、4销毁退还中) | no | string | body |
3.输出参数
| 参数名称 | 描述 | 类型 |
|---|---|---|
| id | 云硬盘ID | string |
| uuid | 用户ID | string |
| name | 云硬盘名称 | string |
| pveId | 主机实例ID | string |
| isMount | 是否挂载过(0未挂载、1挂载) | string |
| bus | 磁盘设备 | string |
| area | 云硬盘可用区域(0华南、1华西、2国际) | string |
| memory | 内存 | string |
| useType | 付费方式(0按量,1包时段) | string |
| amount | 价格 | string |
| status | 云硬盘状态(0待挂载、1挂载中、2使用中、3欠费停服、4销毁退还中)) | string |
| createTime | 创建时间 | string |
4.示例
示例1:请求成功示例
输入示例
POST v1/PveMachineHardDisk/getList / HTTP/1.1
Host: client.xuandashi.com
Content-Type: application/json
Finovy-Access-Token: 4vL4rcNGNcgx5v0RLCcFew
<公共请求参数>
{
"page":"1",
"pageSize":"20",
"pveId":"SDJFHZb125863",
"useType":"0"
}
输出示例
{
"code": 0,
"success": true,
"data": {
"data": [
{
"id": "PgOiNCqaJQ",
"uuid": "A76543210",
"pveId": "mtK4hGbKYT",
"name": "HD-PgOiNCqaJQ",
"isMount": 0,
"bus": "scsi",
"area": "0",
"memory": 20,
"amount": 0.02,
"useType": "0",
"status": "0",
"createTime": 1704349228000
},
{
"id": "p5ZvBx6rJn",
"uuid": "A76543210",
"pveId": "mtK4hGbKYT",
"name": "HD-p5ZvBx6rJn",
"isMount": 0,
"bus": "scsi",
"area": "0",
"memory": 20,
"amount": 0.02,
"useType": "0",
"status": "0",
"createTime": 1704349216000
}
],
"totalCounts": 2
},
"msg": "success",
"traceId": "xxxxxxxxxxxxxx"
}
5.错误码
详情可查看通用错误码
6.Java请求示例
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://client.xuandashi.com/v1/PveMachineHardDisk/open/getList");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("Content-Type", "application/json");
httpConn.setRequestProperty("Finovy-Access-Token", "3V41hUWEwlwKH44m7SpJOs");
httpConn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write("{\"page\": \"1\", \"pageSize\": \"20\" }");
writer.flush();
writer.close();
httpConn.getOutputStream().close();
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}