查询个人镜像
curl --request GET \
--url https://www.chenyu.cn/api/open/v2/image/private/list \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.chenyu.cn/api/open/v2/image/private/list"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.chenyu.cn/api/open/v2/image/private/list', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.chenyu.cn/api/open/v2/image/private/list",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.chenyu.cn/api/open/v2/image/private/list"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.chenyu.cn/api/open/v2/image/private/list")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chenyu.cn/api/open/v2/image/private/list")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 123,
"msg": "<string>",
"data": {
"image_list": [
{
"title": "<string>",
"uuid": "<string>",
"remark": "<string>",
"layer_count": 123,
"size": 123,
"pod_uuid": "<string>",
"pod_tag": "<string>",
"save_image_status": 123,
"create_time": 123
}
],
"total": 123
}
}镜像管理
查询个人镜像
查询用户的个人镜像列表
GET
/
api
/
open
/
v2
/
image
/
private
/
list
查询个人镜像
curl --request GET \
--url https://www.chenyu.cn/api/open/v2/image/private/list \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.chenyu.cn/api/open/v2/image/private/list"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.chenyu.cn/api/open/v2/image/private/list', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.chenyu.cn/api/open/v2/image/private/list",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.chenyu.cn/api/open/v2/image/private/list"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.chenyu.cn/api/open/v2/image/private/list")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chenyu.cn/api/open/v2/image/private/list")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 123,
"msg": "<string>",
"data": {
"image_list": [
{
"title": "<string>",
"uuid": "<string>",
"remark": "<string>",
"layer_count": 123,
"size": 123,
"pod_uuid": "<string>",
"pod_tag": "<string>",
"save_image_status": 123,
"create_time": 123
}
],
"total": 123
}
}查询个人镜像
获取当前用户的所有个人镜像列表。请求参数
此接口不需要任何请求参数。响应参数
integer
响应编码
0: 成功2: 未登录-2: 系统异常
string
返回消息,非0显示错误原因
object
代码示例
import requests
from datetime import datetime
url = "https://www.chenyu.cn/api/open/v2/image/private/list"
headers = {
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
result = response.json()
if result['code'] == 0:
print(f"总共有 {result['data']['total']} 个个人镜像")
for image in result['data']['image_list']:
status_map = {1: "上传中", 2: "上传成功", 3: "上传失败"}
create_time = datetime.fromtimestamp(image['create_time'])
print(f"镜像名称: {image['title']}")
print(f"描述: {image['remark']}")
print(f"大小: {image['size']} GB")
print(f"状态: {status_map.get(image['save_image_status'], '未知')}")
print(f"创建时间: {create_time.strftime('%Y-%m-%d %H:%M:%S')}")
print("---")
else:
print(f"查询失败: {result['msg']}")
const axios = require('axios');
const url = 'https://www.chenyu.cn/api/open/v2/image/private/list';
const headers = {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
};
axios.get(url, { headers })
.then(response => {
const result = response.data;
if (result.code === 0) {
console.log(`总共有 ${result.data.total} 个个人镜像`);
const statusMap = {1: "上传中", 2: "上传成功", 3: "上传失败"};
result.data.image_list.forEach(image => {
const createTime = new Date(image.create_time * 1000);
console.log(`镜像名称: ${image.title}`);
console.log(`描述: ${image.remark}`);
console.log(`大小: ${image.size} GB`);
console.log(`状态: ${statusMap[image.save_image_status] || '未知'}`);
console.log(`创建时间: ${createTime.toLocaleString()}`);
console.log('---');
});
} else {
console.log(`查询失败: ${result.msg}`);
}
})
.catch(error => {
console.error('Error:', error.response.data);
});
curl -X GET "https://www.chenyu.cn/api/open/v2/image/private/list" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json"
响应示例
{
"code": 0,
"msg": "success",
"data": {
"image_list": [
{
"title": "我的PyTorch环境",
"uuid": "img_12345678-1234-1234-1234-123456789012",
"remark": "基于PyTorch 2.0的深度学习环境,已安装常用库",
"layer_count": 15,
"size": 12.5,
"pod_uuid": "pod_87654321-4321-4321-4321-210987654321",
"pod_tag": "v2.0",
"save_image_status": 2,
"create_time": 1703145600
}
],
"total": 1
}
}
⌘I