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.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
iotda:tunnel:queryList
List
-
g:EnterpriseProjectId
-
-
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 |
|---|---|---|---|
|
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 |
Parameter description: tunnel status. Range: CLOSED: The tunnel is closed. OPEN: The tunnel is open. Default value: N/A |
|
source_connect_state |
ConnectState object |
Access end (console) status. |
|
device_connect_state |
ConnectState object |
Device status. |
|
Parameter |
Type |
Description |
|---|---|---|
|
last_update_time |
String |
Time when the latest tunnel status was updated. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
|
status |
String |
Parameter description: client connection status. Range:
Default value: N/A |
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