Skip to content

12.云手机操控

1. 下载文件

接口地址:/v2/command/instance

请求方式:POST

请求数据类型:application/json

响应数据类型:*/*,application/json

支持版本:v1.1.1

callbackUrl 由 v1.7.4 版本提供

接口描述:

批量操作容器:下载文件到容器指定路径下,只能下载到/data/下已存在目录

请求参数:

参数名称 参数说明 位置 是否必须 数据类型 描述
instanceUuids 一个或多个容器 uuid body true List<string>
command 操作命令 body true string 固定填写 [ download ]
content 操作内容对象 body true object
  url 下载源地址 body true string 容器下可访问到的 http 地址
  dest 目标存储地址 body true string
callbackUrl 通知回调地址 body false string POST请求

请求示例:

POST "/openapi/v2/command/instance"
body:
{
    "command": "download",
    "content": {
        "dest": "/data/StressTest.apk",
        "url": "http://192.168.50.40/ext_files/StressTest.apk"
    },
    "instanceUuids": [
        "0248c04cfb5a4442a636c903fa003dc8",
        "0c70e660f6ee4590ad4b65112f4d7af0"
    ]
}

响应参数:

参数名称 参数说明 类型 描述
code 返回代码 integer(int32)
message 返回处理消息 string
result 返回数据对象 List 处理请求的具体数据对象
  jobId 任务ID string
  code 任务提交状态码 integer 任务提交成功时为200,其他为任务提交失败
  message 任务提交描述 string
  uuid 容器uuid string
  command 指令 string
  nodeUuid 节点UUID string
timestamp 时间戳 integer(int64)
traceId 请求处理ID string 请求ID,可用此traceId批量查询该请求下任务结果

响应示例:

{
    "message": "操作成功",
    "code": 200,
    "result": [
        {
            "jobId": "ad66f40e900b45328f4923774f73abfb",
            "code": 200,
            "message": "success",
            "uuid": "0248c04cfb5a4442a636c903fa003dc8",
            "command": "download",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        },
        {
            "jobId": "7926d167cbfe435684adc41b522fad05",
            "code": 200,
            "message": "success",
            "uuid": "0c70e660f6ee4590ad4b65112f4d7af0",
            "command": "download",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        }
    ],
    "timestamp": 1691370725547,
    "traceId": "E75620230807091205505"
}

2. 写文件

接口地址:/v2/command/instance

请求方式:POST

请求数据类型:application/json

响应数据类型:*/*,application/json

支持版本:v1.1.1

callbackUrl 由 v1.7.4 版本提供

接口描述:

批量操作容器:写文件内容到容器指定路径下

请求参数:

参数名称 参数说明 位置 是否必须 数据类型 描述
instanceUuids 一个或多个容器 uuid body true List<string>
command 操作命令 body true string 固定填写 [ write_file ]
content 操作内容对象 body true object
  data 数据内容,字符串 body true string 数据内容不超过64K
  dest 目标存储地址 body true string 注意:只能写进/data或/sdcard/目录下
  chmod 目标文件权限 body false string 可选
  chown 目标文件用户组 body false string 可选
callbackUrl 通知回调地址 body false string POST请求

请求示例:

POST "/openapi/v2/command/instance"
body:
{
    "command": "write_file",
    "content": {
        "dest": "/data/test.sh",
        "data": "cd /data;curl -h http://192.168.50.40/ext_files/StressTest.apk",
        "chmod": "a+x",
        "chown": "root:root"
    },
    "instanceUuids": [
        "0248c04cfb5a4442a636c903fa003dc8",
        "0c70e660f6ee4590ad4b65112f4d7af0"
    ]
}

响应参数:

参数名称 参数说明 类型 描述
code 返回代码 integer(int32) integer(int32)
message 返回处理消息 string
result 返回数据对象 List 处理请求的具体数据对象
  jobId 任务ID string
  code 任务提交状态码 integer 任务提交成功时为200,其他为任务提交失败
  message 任务提交描述 string
  uuid 容器uuid string
  command 指令 string
  nodeUuid 节点UUID string
timestamp 时间戳 integer(int64) integer(int64)
traceId 请求处理ID string 请求ID,可用此traceId批量查询该请求下任务结果

响应示例:

{
    "message": "操作成功",
    "code": 200,
    "result": [
        {
            "jobId": "ad66f40e900b45328f4923774f73abfb",
            "code": 200,
            "message": "success",
            "uuid": "0248c04cfb5a4442a636c903fa003dc8",
            "command": "write_file",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        },
        {
            "jobId": "7926d167cbfe435684adc41b522fad05",
            "code": 200,
            "message": "success",
            "uuid": "0c70e660f6ee4590ad4b65112f4d7af0",
            "command": "write_file",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        }
    ],
    "timestamp": 1691370725547,
    "traceId": "E75620230807091205505"
}

3. 执行异步adb命令

接口地址:/v2/command/instance

请求方式:POST

请求数据类型:application/json

响应数据类型:*/*,application/json

支持版本:v1.1.1

callbackUrl 由 v1.7.4 版本提供

接口描述:

容器执行shell命令, 返回jobId, 根据traceId或者jobId请求任务执行状态查询接口查询任务结果,输出结果最多支持8K字节

请求参数:

参数名称 参数说明 位置 是否必须 数据类型 描述
instanceUuids 容器uuid body true List<string>
command 操作命令 body true string 固定填写 [ shell ]
content 具体执行命令 body true object
  command shell命令 body true string 最大长度为1024字节,例如:find . -name \*.log -exec grep -i user {} +
callbackUrl 通知回调地址 body false string POST请求

请求示例:

POST "/openapi/v2/command/instance"
body:
{
    "command": "shell",
    "content": {
        "command": "pwd"
    },
    "instanceUuids": [
        "165b41ce26fd406cab7cac868262df44",
        "20271b8ef9674bd2ab59cededc9d3e49"
    ]
}

响应参数:

参数名称 参数说明 类型 描述
code 返回代码 integer(int32)
message 返回处理消息 string
result 返回数据对象 List 处理请求的具体数据对象
  jobId 任务ID string
  code 任务提交状态码 integer 任务提交成功时为200,其他为任务提交失败
  message 任务提交描述 string
  uuid 容器uuid string
  command 指令 string
  nodeUuid 节点UUID string
timestamp 时间戳 integer(int64)
traceId 请求处理ID string 请求ID,可用此traceId批量查询该请求下任务结果

响应示例:

{
    "message": "操作成功",
    "code": 200,
    "result": [
        {
            "jobId": "ec1c2ac1d5e544428c66a0f4f0d9f603",
            "code": 200,
            "message": "success",
            "uuid": "165b41ce26fd406cab7cac868262df44",
            "command": "shell",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        },
        {
            "jobId": "43c7740d8f484b36b08623adac3f6f1d",
            "code": 200,
            "message": "success",
            "uuid": "20271b8ef9674bd2ab59cededc9d3e49",
            "command": "shell",
            "nodeUuid": "7a3eacab1939fefec0c1998e37d87ae2"
        }
    ],
    "timestamp": 1691371028402,
    "traceId": "E75920230807091708379"
}

4. 执行同步adb命令

接口地址:/v2/command/instance/sync

请求方式:POST

请求数据类型:application/json

响应数据类型:*/*,application/json

支持版本:v1.1.1

接口描述:

容器同步执行shell命令

请求参数:

参数名称 参数说明 位置 是否必须 数据类型 描述
instanceUuids 容器 uuid body true List<string>
command 操作命令 body true string 此处固定填写 [ shell ]
content 具体执行命令 body true object
  command shell命令具体内容 body true string 最大长度为1024字节,例如:find . -name \*.log -exec grep -i user {} +

请求示例:

POST "/openapi/v2/command/instance/sync"
body:
{
    "command": "shell",
    "content": {
        "command": "pwd"
    },
    "instanceUuids": [
        "1735cbd34ce3459db9cc8e7ada96a8d7",
        "173d456c59cf40e684c3f40793883913"
    ]
}

响应参数:

参数名称 参数说明 类型 描述
code 返回代码 integer(int32)
message 返回处理消息 string
result 返回数据对象 list<object>
  jobId 任务ID string
  message 任务提交描述 string
  uuid 容器唯一 uuid string
  status 任务执行状态 string 1:执行中 2:执行成功 -1:执行失败
  data 任务执行输出封装对象 string
    stdOut 执行内容输出 list
    stdErr 执行异常输出 list
  command 指令 string
  beginTime 任务开始时间 string 格式为 UTC [ YYYY-MM-DD HH:MM:SS]
  endTime 任务结束时间 string 格式与 [ 任务开始时间 ] 一致
timestamp 时间戳 integer(int64)
traceId 请求处理ID string

响应示例:

{
    "message": "操作成功",
    "code": 200,
    "result": [
        {
            "jobId": "90596a7833cb400b898efe4d90509a56",
            "data": {
                "stdOut": [
                    "/"
                ],
                "stdErr": [
                    ""
                ]
            },
            "beginTime": "2023-08-07 09:19:13",
            "endTime": "2023-08-07 09:19:13",
            "message": "任务执行成功",
            "uuid": "1735cbd34ce3459db9cc8e7ada96a8d7",
            "status": 2,
            "command": "shell"
        },
        {
            "jobId": "6ffc5573f74a434a96b8e777e9a9be79",
            "data": {
                "stdOut": [
                    "/"
                ],
                "stdErr": [
                    ""
                ]
            },
            "beginTime": "2023-08-07 09:19:13 ",
            "endTime": "2023-08-07 09:19:13 ",
            "message": "任务执行成功",
            "uuid": "173d456c59cf40e684c3f40793883913",
            "status": 2,
            "command": "shell"
        }
    ],
    "timestamp": 1691371153352,
    "traceId": "E76120230807091913091"
}