容器

批量执行脚本

1.接口说明

接口路径:/ai/openapi/v2/instance-service/task/actions/execute-script

请求方式:POST

请求数据类型:

接口描述:批量执行脚本

2.请求消息

请求参数:

Headers:

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

参数:

名称 类型 必填 描述 示例
startScriptActionScopestring批量执行脚本范围all(代表所有容器)、 header(代表首个容器)
startScriptContentstring批量执行脚本的内容;多行命令时需在每行末尾加入\n换行转义符echo \"hello world\"
idstring容器实例ID7d64e73803de4a6e9a15a8c79c7da015

3.请求示例

cURL请求示例

curl --location 'https://api01.xxx.com:65106/ai/openapi/v2/instance-service/task/actions/execute-script' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYxMjMzNDY1NjgiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.iQUBzN32jiCeeFuJ9lFS_XjBpxenEEupQRiyA3Ef334' \
--header 'Content-Type: application/json' \
--data '{
    "startScriptActionScope": "all",
    "startScriptContent": "echo \"hello world\"",
    "id": "7d64e73803de4a6e9a15a8c79c7da015"
}'

Java请求示例

import okhttp3.*;

public class BatchExecuteScriptDemo {

    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/task/actions/execute-script";

    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    \"startScriptActionScope\": \"all\",\n    \"startScriptContent\": \"echo \\\"hello world\\\"\",\n    \"id\": \"7d64e73803de4a6e9a15a8c79c7da015\"\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/task/actions/execute-script"

payload = json.dumps({
  "startScriptActionScope": "all",
  "startScriptContent": "echo \"hello world\"",
  "id": "7d64e73803de4a6e9a15a8c79c7da015"
})
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": null
}

5.错误码

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

results matching ""

    No results matching ""