12.Cloud phone control
1. Download file
API address:/v2/command/instance
Request method:POST
Request data type:application/json
Response data type:*/*,application/json
Supported version:v1.1.1
callbackUrl provided by version v1.7.4
API description:
Batch container operation: download files to the specified path in the container; can only download to existing directories under /data/
Request parameters:
| Parameter name | Parameter description | Location | Whether required | Data type | Description |
|---|---|---|---|---|---|
| instanceUuids | one or more container uuid | body | true | List<string> | |
| command | Operation command | body | true | string | Fixed value [ download ] |
| content | Operation content object | body | true | object | |
| url | download source address | body | true | string | http address accessible from within the container |
| dest | Target storage address | body | true | string | |
| callbackUrl | Notification callback address | body | false | string | POST request |
Request example:
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"
]
}
Response parameters:
| Parameter name | Parameter description | Type | Description |
|---|---|---|---|
| code | Return code | integer(int32) | |
| message | Return processing message | string | |
| result | Returned data object | List | Specific data object for processing the request |
| jobId | Task ID | string | |
| code | Task submission status code | integer | 200 when the task is submitted successfully; otherwise, the task submission failed |
| message | Task submission description | string | |
| uuid | Container uuid | string | |
| command | Command | string | |
| nodeUuid | Node UUID | string | |
| timestamp | Timestamp | integer(int64) | |
| traceId | Request processing ID | string | Request ID; this traceId can be used to query task results under this request in batches |
Response example:
{
"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. Write file
API address:/v2/command/instance
Request method:POST
Request data type:application/json
Response data type:*/*,application/json
Supported version:v1.1.1
callbackUrl provided by version v1.7.4
API description:
Batch container operation: write file content to the specified path in the container
Request parameters:
| Parameter name | Parameter description | Location | Whether required | Data type | Description |
|---|---|---|---|---|---|
| instanceUuids | one or more container uuid | body | true | List<string> | |
| command | Operation command | body | true | string | Fixed value [ write_file ] |
| content | Operation content object | body | true | object | |
| data | Data content, string | body | true | string | Data content does not exceed 64K |
| dest | Target storage address | body | true | string | Note:Can only be written into/dataor/sdcard/under directory |
| chmod | Target file permissions | body | false | string | Optional |
| chown | Target file user group | body | false | string | Optional |
| callbackUrl | Notification callback address | body | false | string | POST request |
Request example:
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"
]
}
Response parameters:
| Parameter name | Parameter description | Type | Description |
|---|---|---|---|
| code | Return code | integer(int32) | integer(int32) |
| message | Return processing message | string | |
| result | Returned data object | List | Specific data object for processing the request |
| jobId | Task ID | string | |
| code | Task submission status code | integer | 200 when the task is submitted successfully; otherwise, the task submission failed |
| message | Task submission description | string | |
| uuid | Container uuid | string | |
| command | Command | string | |
| nodeUuid | Node UUID | string | |
| timestamp | Timestamp | integer(int64) | integer(int64) |
| traceId | Request processing ID | string | Request ID; this traceId can be used to query task results under this request in batches |
Response example:
{
"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. Execute asynchronous adb command
API address:/v2/command/instance
Request method:POST
Request data type:application/json
Response data type:*/*,application/json
Supported version:v1.1.1
callbackUrl provided by version v1.7.4
API description:
Execute a shell command in the container, return jobId, query the task result through the task execution status query API according to traceId or jobId, and the output result supports up to 8K bytes
Request parameters:
| Parameter name | Parameter description | Location | Whether required | Data type | Description |
|---|---|---|---|---|---|
| instanceUuids | Container uuid | body | true | List<string> | |
| command | Operation command | body | true | string | Fixed value [ shell ] |
| content | Specific execution command | body | true | object | |
| command | shell command | body | true | string | Maximum length is 1024 bytes, for example:find . -name \*.log -exec grep -i user {} + |
| callbackUrl | Notification callback address | body | false | string | POST request |
Request example:
POST "/openapi/v2/command/instance"
body:
{
"command": "shell",
"content": {
"command": "pwd"
},
"instanceUuids": [
"165b41ce26fd406cab7cac868262df44",
"20271b8ef9674bd2ab59cededc9d3e49"
]
}
Response parameters:
| Parameter name | Parameter description | Type | Description |
|---|---|---|---|
| code | Return code | integer(int32) | |
| message | Return processing message | string | |
| result | Returned data object | List | Specific data object for processing the request |
| jobId | Task ID | string | |
| code | Task submission status code | integer | 200 when the task is submitted successfully; otherwise, the task submission failed |
| message | Task submission description | string | |
| uuid | Container uuid | string | |
| command | Command | string | |
| nodeUuid | Node UUID | string | |
| timestamp | Timestamp | integer(int64) | |
| traceId | Request processing ID | string | Request ID; this traceId can be used to query task results under this request in batches |
Response example:
{
"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. Execute synchronous adb command
API address:/v2/command/instance/sync
Request method:POST
Request data type:application/json
Response data type:*/*,application/json
Supported version:v1.1.1
API description:
Synchronously execute shell command in container
Request parameters:
| Parameter name | Parameter description | Location | Whether required | Data type | Description |
|---|---|---|---|---|---|
| instanceUuids | Container uuid | body | true | List<string> | |
| command | Operation command | body | true | string | Fill in [ shell ] here as a fixed value |
| content | Specific execution command | body | true | object | |
| command | specific content of shell command | body | true | string | Maximum length is 1024 bytes, for example:find . -name \*.log -exec grep -i user {} + |
Request example:
POST "/openapi/v2/command/instance/sync"
body:
{
"command": "shell",
"content": {
"command": "pwd"
},
"instanceUuids": [
"1735cbd34ce3459db9cc8e7ada96a8d7",
"173d456c59cf40e684c3f40793883913"
]
}
Response parameters:
| Parameter name | Parameter description | Type | Description |
|---|---|---|---|
| code | Return code | integer(int32) | |
| message | Return processing message | string | |
| result | Returned data object | list<object> | |
| jobId | Task ID | string | |
| message | Task submission description | string | |
| uuid | Container unique uuid | string | |
| status | Task execution status | string | 1:executing 2:execution succeeded -1:execution failed |
| data | Task execution output wrapper object | string | |
| stdOut | Execution content output | list | |
| stdErr | Execution error output | list | |
| command | Command | string | |
| beginTime | Task start time | string | Format is UTC [ YYYY-MM-DD HH:MM:SS] |
| endTime | Task end time | string | Format is the same as [ Task start time ] |
| timestamp | Timestamp | integer(int64) | |
| traceId | Request processing ID | string |
Response example:
{
"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"
}