主机配置列表
该接口通过鉴权接口颁发的token作为访问令牌,获取主机配置列表,拥有主机配置信息是创建主机的必要前置条件。
1.接口描述
接口请求地址:GET v1/pve/open/packAge/{type}
2.输入参数
| 参数名称 | 描述 | 是否必选 | 类型 | Location |
|---|---|---|---|---|
| Finovy-Access-Token | 令牌-口令 | yes | string | header |
| type | 模板类型(0按量、1包时段) | yes | string | path |
3.输出参数
| 参数名称 | 描述 | 类型 |
|---|---|---|
| packageId | 主机配置ID | string |
| name | 主机配置名称 | string |
| gpuNumber | GPU数,为0则不支持使用显卡 | int |
| gpuName | GPU名,为空则不支持使用显卡 | string |
| memoryNumber | 内存数 | int |
| rigidDiskNumber | 硬盘数 | int |
| cpuNumber | cpu数 | int |
| bandWidth | 带宽 | int |
| amount | 金额(单价/小时) | string |
| discount | 折扣,如1表示不打折,0.8表示打8折 | string |
| type | 主机配置类型 | string |
| pveMachineType | 主机用途(0普通办公、1图像处理、2算法区域) | string |
| area | 数据中心(0华南、1华西、2国际) | string |
| useType | 主机使用类型(0仅支持按量、1仅支持包时段、2支持按量和包时段) | string |
4.示例
示例1:请求成功示例
输入示例
GET https://client.xuandashi.com/v1/pve/open/packAge/0
Finovy-Access-Token: 4vL4rcNGNcgx5v0RLCcFew
<公共请求参数>
输出示例
{
"code":0,
"data":[
{
"packageId": "Wy1KiMqtPO",
"name": "T使用---显卡*1",
"gpuNumber": 1,
"gpuName": null,
"memoryNumber": 4,
"rigidDiskNumber": 128,
"amount": 1.10,
"cpuNumber": 4,
"bandWidth": 30,
"type": "ceph",
"pveMachineType": "1",
"area": "0",
"useType": "2",
"discount": 1.00
}
],
"msg":"success",
"success":true,
"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/pve/open/packAge/0");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("GET");
httpConn.setRequestProperty("Content-Type", "application/json");
httpConn.setRequestProperty("Finovy-Access-Token", "3V41hUWEwlwKH44m7SpJOs");
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);
}
}