镜像列表
该接口通过鉴权接口颁发的token作为访问令牌,获取镜像列表,拥有镜像信息是创建主机的必要前置条件。
1.接口描述
接口请求地址:GET v1/pve/open/image
2.输入参数
| 参数名称 | 描述 | 是否必选 | 类型 | Location |
|---|---|---|---|---|
| Finovy-Access-Token | 令牌-口令 | yes | string | header |
3.输出参数
| 参数名称 | 描述 | 类型 |
|---|---|---|
| imageId | 镜像ID | string |
| type | 镜像类型 | string |
| systemImageName | 镜像系统 | string |
| systemImageVersion | 镜像系统版本 | string |
4.示例
示例1:请求成功示例
输入示例
GET https://client.xuandashi.com/v1/pve/open/image
Finovy-Access-Token: 4vL4rcNGNcgx5v0RLCcFew
<公共请求参数>
输出示例
{
"code":0,
"data":[
{
"imageId": "4005",
"type": "BL",
"systemImageName": "Ubuntu Server",
"systemImageVersion": "20.04 x64"
}
],
"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/image");
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);
}
}