Query All Tunnels of a Device
Function
You can use this API to query the data of all device tunnels in a project for device management. This API is used by an application to query the status of device tunnels from the IoT platform.
-
This API is not supported by Basic editions.
-
For details, see [Remote Login] (https://support.huaweicloud.com/intl/en-us/usermanual-iothub/iot_01_00301.html).
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
GET /v5/iot/{project_id}/tunnels
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Parameter description: project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
device_id |
No |
String |
Parameter description: device ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. In the returned response header, X-Subject-Token is the desired user token. For details about how to obtain the token, see Token Authentication. |
Instance-Id |
No |
String |
Parameter description: instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
tunnels |
Array of TunnelInfo objects |
Tunnel information list. |
Parameter |
Type |
Description |
---|---|---|
tunnel_id |
String |
Tunnel ID. |
device_id |
String |
Device ID. |
create_time |
String |
Time when a tunnel was created. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
closed_time |
String |
Time when a tunnel was updated. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
status |
String |
Tunnel status. Options: CLOSED and OPEN. |
source_connect_state |
ConnectState object |
Access end (console) status. |
device_connect_state |
ConnectState object |
Device status. |
Example Requests
Queries device tunnels in a list.
GET https://{endpoint}/v5/iot/{project_id}/tunnels
Example Responses
Status code: 200
All tunnel information of the device is successfully queried.
{ "tunnels" : [ { "tunnel_id" : "d144a524-1997-4b99-94bf-f27128da8a34", "device_id" : "1a7ffc5c-d89c-44dd-8265-b1653d951ce0", "create_time" : "20190303T081011Z", "closed_time" : "20190303T081011Z", "status" : "CLOSED", "source_connect_state" : { "last_update_time" : "20190303T081011Z", "status" : "CONNECTED" }, "device_connect_state" : { "last_update_time" : "20190303T081011Z", "status" : "CONNECTED" } } ] }
Status Codes
Status Code |
Description |
---|---|
200 |
All tunnel information of the device is successfully queried. |
400 |
Invalid value. |
401 |
Unauthorized |
403 |
Authentication failed. |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot