Skip to content

容器

获取镜像列表

1.接口说明

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

请求方式:GET

请求数据类型:

接口描述:获取镜像列表

2.请求消息

请求参数:

Headers:

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

参数:

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

3.请求示例

cURL请求示例

shell
curl --location --request GET 'https://scnet-demo.accloud.cn/ai/openapi/v2/instance-service/images' \
--header 'token: <Token>' \
--header 'Content-Type: application/json' \
--data '{
  "acceleratorType": "dcu",
  "imageType": "Base"
}'

Java请求示例

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请求示例

python
import requests
import json

url = "https://scnet-demo.accloud.cn/ai/openapi/v2/instance-service/images"
payload = json.dumps({
  "acceleratorType": "dcu",
  "imageType": "Base"
})
headers = {
  "token": "<Token>",
  "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

返回示例:

json
{
  "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连接中断