Getting Started
This topic describes how to manage cloud phones by calling Cloud Phone APIs.
The token obtained from Identity and Access Management (IAM) is valid for only 24 hours. If you want to use a token for authentication, you can cache it to avoid frequently calling the IAM API.
Involved APIs
To use token authentication, you need to obtain a token and add X-Auth-Token to the request header of API calls.
- API for obtaining tokens from IAM
- API for querying the cloud phone list
- API for restarting a cloud phone
- API for querying the task list
Procedure
- Perform token authentication by following the steps provided in Authentication.
- Query the cloud phone list. Send GET https://{CPH Endpoint}/v1/{project_id}/cloud-phone/phones?offset=0&limit=100.
- Add X-Auth-Token to the request header.
If the request succeeds, request_id and phones are returned.
If the request fails, an error code and description are returned. For details, see Error Codes.
- Add X-Auth-Token to the request header.
- Restart a cloud phone. Send POST https://{CPH Endpoint}/v1/{project_id}/cloud-phone/phones/batch-restart.
- Add X-Auth-Token to the request header.
- Specify the following parameters in the request body:
{ "phones": [ { "phone_id": "a7f3a1c5258347d6b6f1def79e11f2bc" } ] }If the request succeeds, request_id and jobs are returned.
If the request fails, an error code and description are returned. For details, see Error Codes.
- Querying the task list. Send GET https://{CPH Endpoint}/v1/{project_id}/cloud-phone/ jobs?request_id={request_id}.
- Add X-Auth-Token to the request header.
If the request succeeds, request_id and jobs are returned.
{ "request_id": "6a63a18b8bab40ffb71ebd9cb80d0085", "jobs": [ { "phone_id": "1234567b8bab40ffb711234cb80d0234", "server_id": "1e223c8e-3ad0-4bf0-a837-bc90d4f91d01", "node_id": "1e223c8e-3ad0-4bf0-a837-bc90d4f91d01", "job_id": "1564567b8bab40f34711234cb80d0123", "begin_time": "2017-10-25T00:00:00Z", "end_time": "2017-12-26T00:00:00Z", "status": 2, "error_code": "", "error_msg": "" }, ...... ] }If the request fails, an error code and description are returned. For details, see Error Codes.
- Add X-Auth-Token to the request header.
Last Article: Response
Next Article: Cloud Phone APIs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.