更新时间:2025-03-26 GMT+08:00

查询设备主题

功能介绍

查询设备主题

URI

GET /v2/{project_id}/link/instances/{instance_id}/devices/{device_id}/topics

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。兼容20.0场景默认为default。项目ID,获取方式请参见API参考的“附录 > 获取项目ID”章节。

instance_id

String

实例的ID。兼容20.0场景默认为default。

device_id

Integer

设备ID。

表2 Query参数

参数

是否必选

参数类型

描述

limit

Integer

每页显示条目数量。

offset

Integer

偏移量,表示从此偏移量开始查询, offset大于等于0。

name

String

Topic名称。

topic_permission

Integer

Topic权限,0为发布,1为订阅。

topic_type

Integer

Topic类型,0为设备类Topic,1为产品类Topic。

is_private

Integer

Topic是否为自定义,0为基础Topic,1为自定义Topic。

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

total

Integer

总数。

size

Integer

本次返回数量。

items

Array of Topic objects

主题列表。

表5 Topic

参数

参数类型

描述

id

Integer

Topic的ID。

name

String

Topic的名称。

description

String

Topic描述。

permission

Integer

Topic权限,主题权限,0-发布,1-订阅。

is_private

Integer

Topic类型,0-基础Topic,1-用户自定义Topic。

状态码: 400

表6 响应Body参数

参数

参数类型

描述

error_code

String

系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。

error_msg

String

错误描述。

request_id

String

消息ID。

状态码: 404

表7 响应Body参数

参数

参数类型

描述

error_code

String

系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。

error_msg

String

错误描述。

request_id

String

消息ID。

状态码: 500

表8 响应Body参数

参数

参数类型

描述

error_code

String

系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。

error_msg

String

错误描述。

request_id

String

消息ID。

请求示例

GET /{project_id}/link/instances/{instance_id}/devices/{device_id}/topics

响应示例

状态码: 200

OK

{
  "total" : 1,
  "size" : 1,
  "items" : [ {
    "id" : 1528605,
    "name" : "/v1/devices/device/datas",
    "description" : "Device data report",
    "permission" : 0,
    "is_private" : 0
  } ]
}

状态码: 400

Bad Request

{
  "error_code" : "SCB.00000000",
  "error_msg" : "Parameter is not valid for operation [romalink.link-device-topics.queryTopics]. Parameter is [deviceOid]. Processor is [path].",
  "request_id" : "cb39e78a-afd3-4e04-901d-70468b1c23dc-1619602712496-cnnorth7a-P-romalink-service01"
}

状态码: 404

Not Found

{
  "error_code" : "ROMA.00110006",
  "error_msg" : "The resource does not exist. Check whether the resource ID 1 is correct.",
  "request_id" : "624c8be1-39b6-47b7-941d-c159aced368a-1619602544650-cnnorth7a-P-romalink-service01"
}

状态码: 500

Internal Server Error

{
  "error_code" : "ROMA.00110002",
  "error_msg" : "The instance does not exist. project_id: 397cd10b30544c588b2f4a56d83856c4, instance_id: f3bb386a-23ec-47aa-9943-4c60ac658611",
  "request_id" : "c8c06d0a-be92-4fdf-9d10-bc20131ab158-1619593104919-cnnorth7a-P-romalink-service01"
}

状态码

状态码

描述

200

OK

400

Bad Request

404

Not Found

500

Internal Server Error

错误码

请参见错误码