更新产品主题 - UpdateProductTopic
功能介绍
更新产品主题。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
PUT /v2/{project_id}/link/instances/{instance_id}/products/{product_id}/topics/{topic_id}
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| project_id | 是 | String | 项目ID。兼容20.0场景默认为default。项目ID,获取方式请参见API参考的“附录 > 获取项目ID”章节。 | 
| instance_id | 是 | String | 实例ID。兼容20.0场景默认为default。 | 
| product_id | 是 | Integer | 产品ID,该字段为数据库中的自增唯一标识符;通过调用查询产品接口:GET /v2/{project_id}/link/instances/{instance_id}/products获取响应体中对应的id字段值。 | 
| topic_id | 是 | Integer | 产品主题ID。 | 
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| X-Auth-Token | 是 | String | 用户Token。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 | 
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| permission | 是 | Integer | 主题权限,0-发布,1-订阅。 | 
| name | 是 | String | 产品级主题名称。 Topic类格式必须以“/”进行分层,区分每个类目。其中第一个为用户自定义的版本号;第二个已经规定好,为${deviceId}通配设备ID;第三个为用户自定义的Topic类名(即本字段)。Topic类组成即为:${version}/${deviceId}/${customizePart}。简单来说,Topic类:a/b/c/${deviceId}/customizePart是具体Topic:a/b/c/deviceid1/customizePart1和a/b/c/deviceid2/customizePart2等的集合。 | 
| version | 是 | String | 版本号,输入1-64个字符。值以字母或数字开头和结尾。仅允许使用字母、数字、下划线、中划线、点号、斜杠、反斜杠,即[a-zA-Z0-9.-_/\]{1,64} | 
| with_prefix_slash | 否 | Boolean | 是否在topic前拼接"/",默认true。 | 
| description | 否 | String | 描述。 | 
响应参数
状态码:200
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| product_id | Integer | 归属产品ID。 | 
| topic_id | Integer | 产品主题ID。 | 
| permission | Integer | 主题权限,0-发布,1-订阅。 | 
| topic_name | String | 主题名称。 | 
| version | String | 版本号。 | 
| description | String | 描述。 | 
状态码:400
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 | 
| error_msg | String | 错误描述。 | 
| request_id | String | 消息ID。 | 
状态码:404
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 | 
| error_msg | String | 错误描述。 | 
| request_id | String | 消息ID。 | 
状态码:500
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| error_code | String | 系统错误码,针对4xx和5xx类HTTP错误码的详细错误码。 | 
| error_msg | String | 错误描述。 | 
| request_id | String | 消息ID。 | 
请求示例
更新指定的产品Topic,权限修改为订阅,并修改版本号。
{
  "permission" : 1,
  "name" : "datas",
  "version" : "v2",
  "description" : "/v2/${deviceId}/datas"
}
 响应示例
状态码:200
OK
{
  "product_id" : 122888,
  "topic_id" : 17,
  "permission" : 1,
  "topic_name" : "/3.0/${deviceId}/t1",
  "version" : "3.0",
  "description" : "description"
}
  状态码:400
Bad Request
{
  "error_code" : "SCB.00000000",
  "error_msg" : "Parameter is not valid for operation [romalink.link-product-topic.updateProductTopic]. Parameter is [productId]. 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 ff38023c-0854-4779-847d-72528e1f5da5 is correct.",
  "request_id" : "72b07918-f6a2-4721-81bf-f3fd5486025e-1619663576836-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 | 
错误码
请参见错误码。
 
  