容器

更新资源规格

1.接口说明

接口路径:/ai/openapi/v2/instance-service/resource-spec/actions/update

请求方式:POST

请求数据类型:

接口描述:更新资源规格,当任务状态为非运行状态时可修改

2.请求消息

请求参数:

Headers:

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

参数:

名称 类型 必填 描述 示例
cpuNumberintCPU数量3
gpuNumberintGPU数量1
idstring容器实例ID4c1f43ddb030483e89b55413bee6c004
ramSizeint内存,单位为MB15360

3.请求示例

cURL请求示例

curl --location 'https://api01.xxx.com:65106/ai/openapi/v2/instance-service/resource-spec/actions/update' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYxMjMzNDY1NjgiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.iQUBzN32jiCeeFuJ9lFS_XjBpxenEEupQRiyA3Ef334' \
--header 'Content-Type: application/json' \
--data '{
    "id": "4c1f43ddb030483e89b55413bee6c004",
    "cpuNumber": 3,
    "gpuNumber": 1,
    "ramSize": 15360
}'

Java请求示例

import okhttp3.*;

public class UpdateResourceDemo {

    public static final String TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4";
    public static final String URL = "https://api01.xxx.com:65106/ai/openapi/v2/instance-service/resource-spec/actions/update";

    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n    \"id\": \"4c1f43ddb030483e89b55413bee6c004\",\n    \"cpuNumber\": 3,\n    \"gpuNumber\": 1,\n    \"ramSize\": 15360\n}");
        Request request = new Request.Builder()
                .url(URL)
                .method("POST", body)
                .addHeader("token", TOKEN)
                .addHeader("Content-Type", "application/json")
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

Python请求示例

import requests
import json

url = "https://api01.xxx.com:65106/ai/openapi/v2/instance-service/resource-spec/actions/update"

payload = json.dumps({
  "id": "4c1f43ddb030483e89b55413bee6c004",
  "cpuNumber": 3,
  "gpuNumber": 1,
  "ramSize": 15360
})
headers = {
  'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYxMjMzNDY1NjgiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.iQUBzN32jiCeeFuJ9lFS_XjBpxenEEupQRiyA3Ef334',
  'Content-Type': 'application/json'
}

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

print(response.text)

4.响应消息

返回参数:

名称 类型 描述 示例
msgstring信息操作成功
codestring状态码0
datastring返回值

返回示例:

{
    "code":"0",
    "msg":"success",
    "data":""
}

5.错误码

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

results matching ""

    No results matching ""