容器

获取镜像列表

1.接口说明

接口路径:/ai/openapi/v2/instance-service/images

请求方式:GET

请求数据类型:

接口描述:获取镜像列表

2.请求消息

请求参数:

Headers:

名称 类型 必填 描述 示例
tokenstring接口凭证eyJhbGciOiJIUzI1...

参数:

名称 类型 必填 描述 示例
acceleratorTypestring加速器类型dcu
imageTypestring镜像类型Base\JupyterLab

3.请求示例

cURL请求示例

curl --location --request GET 'https://api01.xxx.com:65106/ai/openapi/v2/instance-service/images' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc4NDY2MTM5NTIiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.IuX4GaOdwG-wpvuhJHXfIOne8YY9tM1XOhn0B2vLUpI' \
--header 'Content-Type: application/json' \
--data '{
    "acceleratorType": "dcu",
    "imageType": "Base"
}'

Java请求示例

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;

import java.net.*;


public class GetImagesDemo {

    public static class HttpGetWithEntity extends HttpEntityEnclosingRequestBase {
        public final static String METHOD_NAME = "GET";

        @Override
        public String getMethod() {
            return METHOD_NAME;
        }
    }

    public static void main(String[] args) throws Exception {
        String token = "sdfI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6ImpzeWFkbWluIiwiYWNjb3VudFN0YXR1cyI6Ik93ZSIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE3MDAwOTc1MzYxNjQiLCJjbHVzdGVySWQiOiIxMTI1MCIsImludm9rZXIiOiJiN2I5NjViNjZkM2IzNWJjMTQ0ZDI5YWY1MWUxNjFhMSIsInVzZXIiOiJqc3lhZG1pbiIsInVzZXJJZCI6IjIxOTI1OTExMzgwIn0.0lfIs4G8jvrcVI4804pvI3fDJ4uVwFs6AkXgJvuUGF4";
        String url = "https://ai01.xxx.com:65011/ai/openapi/v2/instance-service/images";
        String params = "{\n    \"acceleratorType\": \"dcu\",\n    \"imageType\": \"Base\"\n}";
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
        HttpGetWithEntity e = new HttpGetWithEntity();
        e.setURI(new URI(url));
        e.setHeader("token", token);
        e.setHeader("Content-Type", "application/json");
        HttpEntity yourEntity = new StringEntity(params, ContentType.APPLICATION_JSON);
        e.setEntity(yourEntity);
        CloseableHttpResponse response = httpClient.execute(e);
        HttpEntity entity = response.getEntity();
        String body = "";
        if (entity != null) {
            body = EntityUtils.toString(entity, "UTF-8");
        }
        System.out.println(body);
        response.close();
    }

}

Python请求示例

import requests
import json

url = "https://api01.xxx.com:65106/ai/openapi/v2/instance-service/images"

payload = json.dumps({
  "acceleratorType": "dcu",
  "imageType": "Base"
})
headers = {
  'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc4NDY2MTM5NTIiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.IuX4GaOdwG-wpvuhJHXfIOne8YY9tM1XOhn0B2vLUpI',
  'Content-Type': 'application/json'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

4.响应消息

返回参数:

名称 类型 描述 示例
msgstring信息操作成功
codestring状态码0
dataList<Imagesvo>镜像列表
acceleratorTypestring加速器类型gpu,cpu
accessstring权限private,public
appIconstring图标图标路径
createTimestring创建时间2022-10-31 17:00:47
idstringid0141ea661e26458c9098907b20170b26
imageIdstring镜像层idsha256:a459747da8ca823d0067def6dac5ac46a446fa37a1c184e114e462c30f0d541e
isPresetImagebool是否预置镜像true,false
namestring镜像名jupyterlab
pathstring镜像路径ip:5000/dcu/admin/base/jupyterlab:3.2.9-python3.8.3-dtk22.04.1
tagstring标签3.2.9-python3.8.3-dtk22.04.1
typestring镜像类型Base,JupyterLab
userstring上传用户admin
versionstring版本jupyterlab:3.2.9-python3.8.3-dtk22.04.1

返回示例:

{
    "code":"0",
    "msg":"success",
    "data":"{"acceleratorType":"dcu","access":"private","appIcon":"/global_resource/appIcon/appicon_base.png","createTime":"2022-10-31 17:00:47","id":"0141ea661e26458c9098907b20170b26","imageId":"sha256:a459747da8ca823d0067def6dac5ac46a446fa37a1c184e114e462c30f0d541e","isPresetImage":true,"name":"jupyterlab","path":"ip:5000/dcu/admin/base/jupyterlab:3.2.9-python3.8.3-dtk22.04.1","tag":"3.2.9-python3.8.3-dtk22.04.1","type":"Base","user":"admin","version":"jupyterlab:3.2.9-python3.8.3-dtk22.04.1"}"
}

5.错误码

错误码 说明
0 成功
10001 内部异常(其他异常)
10003 参数不全
10004 参数无效
10007 用户已被冻结
10008 权限不足
10009 没有权限访问接口
10010 文件校验失败
10011 文件过大
10012 连接中断

results matching ""

    No results matching ""