
# 修改产品
#### 功能介绍
应用服务器可调用此接口修改产品。
#### URI
PUT /v1/iotfm/products/{product_id}
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                       |
|:---|:---|:---|:---|
| product_id | 是    | String | **参数说明**：产品ID。 **取值范围**：长度不超过36，只允许字母、数字、以及_-字符的组合。 |
   
#### 请求参数
表2请求Header参数 
| 参数            | 是否必选 | 参数类型   | 描述                                                                                                                                                              |
|:---|:---|:---|:---|
| X-Auth-Token  | 是    | String | **参数说明** ：用户Token。通过调用 [生成Token](https://support.huaweicloud.com/api-ocsmartcampus/ocsmartcampus_06_0008.html) 接口获取，接口返回的响应消息头中"X-Subject-Token"就是需要获取的用户Token。 |
| X-Instance-Id | 是    | String | **参数说明**：实例ID。通过访问智能设施云平台界面后获取，智能设施云平台资源均为实例级隔离，所有业务接口必须填写正确的实例ID才能被成功调用。 **取值范围**：长度8-36，只允许大小写字母、数字和-字符的组合。          |
   
表3请求Body参数 
| 参数                   | 是否必选 | 参数类型   | 描述                                                                                             |
|:---|:---|:---|:---|
| product_short_code   | 否    | String | **参数说明**：产品简码。 **取值范围**：长度不超过24，只允许大写字母、数字的组合。           |
| product_name         | 否    | String | **参数说明**：产品名称。 **取值范围**：长度不超过64，只允许中文、字母、数字、以及_-字符的组合。  |
| product_description  | 否    | String | **参数说明**：产品详情描述。 **取值范围**：长度不超过128，只允许字母、数字、以及_.-字符的组合。 |
| category_id          | 否    | String | **参数说明**：产品分类ID。 **取值范围**：长度不超过36，只允许字母、数字、以及_$-字符的组合。  |
| service_capabilities | 否    | Object | **参数说明**：服务列表。 **取值范围**：数组长度不超过500，且文本内容长度不超过128KB。     |
| def_properties       | 否    | Object | **参数说明**：设备规格属性列表。 **取值范围**：数组长度不超过500，且文本内容长度不超过128KB。 |
| access_type          | 否    | String | **参数说明**：接入类型。 **取值范围**：长度不超过36，只允许字母、数字、以及_-字符的组合。     |
   
表4ServiceCapabilityDef 
| 参数         | 是否必选 | 参数类型                                                                                                                   | 描述                                                                                                             |
|:---|:---|:---|:---|
| service_id | 是    | String                                                                                                                 | **参数说明**：服务ID。产品内唯一。 **取值范围**：长度不超过64，只允许字母、数字、以及_?'#().,\&%@!\\-字符的组合。 |
| properties | 否    | Array of [ServicePropertyDef] objects | **参数说明**：设备属性列表。 **取值范围**：数组长度不超过500。                                  |
| commands   | 否    | Array of [ServiceCommandDef] objects   | **参数说明**：设备命令列表。 **取值范围**：数组长度不超过500。                                   |
| events     | 否    | Array of [ServiceEventDef] objects       | **参数说明**：设备事件列表。 **取值范围**：数组长度不超过500。                                   |
   
 表5ServicePropertyDef 
| 参数                      | 是否必选 | 参数类型             | 描述                                                                                                                                                 |
|:---|:---|:---|:---|
| property_code           | 是    | String           | **参数说明**：属性编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。                                                         |
| property_name           | 否    | String           | **参数说明**：属性名称。 **取值范围**：长度不超过40，只允许英文字母大小写、数字以及_?'#()\\\[\\\]=℃.,;\&%@!\\- ，、：；。￥$！【】''""（）？...\~/字符的组合。    |
| data_type               | 是    | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json |
| unit                    | 否    | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%等字符的组合。           |
| property_priority       | 否    | Integer          | **参数说明**：设施点位控制优先级。 **取值范围**：只允许数字，设施云priority范围：8-16。                                                       |
| default_value           | 否    | Object           | **参数说明**：设备属性默认值，根据data_type的类型设置。                                                                                                                 |
| collect_period          | 否    | Integer          | **参数说明**：设备属性采集周期。 **取值范围**：只允许数字，单位：秒，范围：5-86400(24小时)。                                                    |
| enum_list               | 否    | Array of objects | **参数说明**：枚举值列表，字符串数组或者{value，display}的对象数组。 **取值范围**：数组长度不超过100，单字符串长度不超过128。                                |
| method                  | 否    | String           | **参数说明**：访问权限。R-属性值可读 W-属性值可写 RW-属性值可读可写。 **取值范围**：只允许R，W，RW。                                               |
| property_component_name | 否    | String           | **参数说明**：属性组件名，默认为空，即不使用系统组件定义；使用组件定义时，填入该组件名称。                                                                                                    |
   
 表6ServiceCommandDef 
| 参数                | 是否必选 | 参数类型                                                                                                                                 | 描述                                                                                                |
|:---|:---|:---|:---|
| command_code      | 是    | String                                                                                                                               | **参数说明**：命令编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。      |
| command_name      | 否    | String                                                                                                                               | **参数说明**：命令中文名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。 |
| invoke_type       | 否    | String                                                                                                                               | **参数说明**：调用方式，同步-SYNC 异步-ASYNC。 **取值范围**：只允许SYNC，ASYNC。    |
| command_paras     | 否    | Array of [ServiceCommandParaDef] objects         | **参数说明**：命令参数。                                                                                    |
| command_responses | 否    | Array of [ServiceCommandResponseDef] objects | **参数说明**：命令响应列表。                                                                                  |
   
 表7ServiceCommandResponseDef 
| 参数             | 是否必选 | 参数类型                                                                                                                         | 描述                                                                                            |
|:---|:---|:---|:---|
| response_code  | 是    | String                                                                                                                       | **参数说明**：命令响应编码。 **取值范围**：长度不超过128，只允许英文字母大小写、数字、下划线的组合。 |
| response_paras | 否    | Array of [ServiceCommandParaDef] objects | **参数说明**：命令响应的参数列表。                                                                           |
   
 表8ServiceEventDef 
| 参数         | 是否必选 | 参数类型                                                                                                                         | 描述                                                                                                       |
|:---|:---|:---|:---|
| event_type | 是    | String                                                                                                                       | **参数说明**：设备事件类型。设备服务内不允许重复。 **取值范围**：长度不超过32，只允许英文字母大小写、数字、下划线的组合。 |
| paras      | 否    | Array of [ServiceCommandParaDef] objects | **参数说明**：设备事件的参数列表。                                                                                      |
   
 表9ServiceCommandParaDef 
| 参数        | 是否必选 | 参数类型             | 描述                                                                                                                                                  |
|:---|:---|:---|:---|
| para_code | 是    | String           | **参数说明**：参数标识符。 **取值范围**：长度不超过32，只允许字母、数字、以及_?''#().,\&%@!-字符的组合。                                              |
| para_name | 否    | String           | **参数说明**：参数名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。                                                      |
| data_type | 是    | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json。 |
| unit      | 否    | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%字符的组合。             |
| min       | 否    | String           | **参数说明**：参数的最小值。                                                                                                                                    |
| max       | 否    | String           | **参数说明**：参数的最大值。                                                                                                                                    |
| enum_list | 否    | Array of strings | **参数说明**：枚举值列表。                                                                                                                                     |
   
表10SpecPropertyDef 
| 参数            | 是否必选 | 参数类型             | 描述                                                                                                                                                   |
|:---|:---|:---|:---|
| property_code | 是    | String           | **参数说明**：属性编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。                                                        |
| property_name | 否    | String           | **参数说明**：属性名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。                                                      |
| data_type     | 是    | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json。 |
| unit          | 否    | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%字符的组合。               |
| enum_list     | 否    | Array of objects | **参数说明**：枚举值列表，字符串数组或者{value，display}的对象数组。 **取值范围**：数组长度不超过100，单字符串长度不超过128。                                   |
   
#### 响应参数
**状态码：200**
表11响应Body参数 
| 参数                   | 参数类型                                                                                                                        | 描述                                                                                                                         |
|:---|:---|:---|
| product_code         | String                                                                                                                      | **参数说明**：产品编码。 **取值范围**：长度不超过48，只允许字母、数字、以及_.-字符的组合。                               |
| product_short_code   | String                                                                                                                      | **参数说明**：产品简码。 **取值范围**：长度不超过24，只允许大写字母、数字的组合。                                      |
| product_name         | String                                                                                                                      | **参数说明**：产品名称。 **取值范围**：长度不超过64，只允许中文、字母、数字、以及_-字符的组合。                               |
| protocol_type        | String                                                                                                                      | **参数说明**：设备使用的协议类型。 **取值范围**：MQTT，CoAP，HTTP，HTTPS，Modbus，ONVIF，OPC-UA，OPC-DA，Other。" |
| product_description  | String                                                                                                                      | **参数说明**：产品详情描述。 **取值范围**：长度不超过128，只允许中文、字母、数字、以及_-字符的组合。                         |
| category_id          | String                                                                                                                      | **参数说明**：产品分类ID。 **取值范围**：长度不超过36，只允许字母、数字、以及_$-字符的组合。                              |
| category_code        | String                                                                                                                      | **参数说明**：产品分类编码。 **取值范围**：长度不超过36，只允许字母、数字、以及_-字符的组合。                              |
| product_id           | String                                                                                                                      | **参数说明**：产品ID。 **取值范围**：长度不超过36，只允许字母、数字、以及_-字符的组合。                                   |
| is_system            | Boolean                                                                                                                     | **参数说明**：是否为系统内部产品。 **取值范围**：true\|false。                                            |
| service_capabilities | Array of [ServiceCapabilityDef] objects | **参数说明**：服务列表。 **取值范围**：数组长度不超过500，且文本内容长度不超过128KB。                                   |
| def_properties       | Array of [SpecPropertyDef] objects           | **参数说明**：设备规格属性列表。 **取值范围**：数组长度不超过500，且文本内容长度不超过128KB。                             |
| access_type          | String                                                                                                                      | **参数说明**：接入类型。 **取值范围**：长度不超过36，只允许字母、数字、以及_-字符的组合。                                 |
   
 表12ServiceCapabilityDef 
| 参数         | 参数类型                                                                                                                    | 描述                                                                                                           |
|:---|:---|:---|
| service_id | String                                                                                                                  | **参数说明**：服务ID。产品内唯一。 **取值范围**：长度不超过64，只允许字母、数字、以及_?'#().,\&%@!\\-字符的组合。 |
| properties | Array of [ServicePropertyDef] objects | **参数说明**：设备属性列表。 **取值范围**：数组长度不超过500。                                   |
| commands   | Array of [ServiceCommandDef] objects   | **参数说明**：设备命令列表。 **取值范围**：数组长度不超过500。                                |
| events     | Array of [ServiceEventDef] objects       | **参数说明**：设备事件列表。 **取值范围**：数组长度不超过500。                                 |
   
 表13ServicePropertyDef 
| 参数                      | 参数类型             | 描述                                                                                                                                                   |
|:---|:---|:---|
| property_code           | String           | **参数说明**：属性编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。                                                        |
| property_name           | String           | **参数说明**：属性名称。 **取值范围**：长度不超过40，只允许英文字母大小写、数字以及_?'#()\\\[\\\]=℃.,;\&%@!\\- ，、：；。￥$！【】''""（）？...\~/字符的组合。     |
| data_type               | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json |
| unit                    | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%等字符的组合。             |
| property_priority       | Integer          | **参数说明**：设施点位控制优先级。 **取值范围**：只允许数字，设施云priority范围：8-16。                                                         |
| default_value           | Object           | **参数说明**：设备属性默认值，根据data_type的类型设置。                                                                                                                   |
| collect_period          | Integer          | **参数说明**：设备属性采集周期。 **取值范围**：只允许数字，单位：秒，范围：5-86400(24小时)。                                                     |
| enum_list               | Array of objects | **参数说明**：枚举值列表，字符串数组或者{value，display}的对象数组。 **取值范围**：数组长度不超过100，单字符串长度不超过128。                                |
| method                  | String           | **参数说明**：访问权限。R-属性值可读 W-属性值可写 RW-属性值可读可写。 **取值范围**：只允许R，W，RW。                                                 |
| property_component_name | String           | **参数说明**：属性组件名，默认为空，即不使用系统组件定义；使用组件定义时，填入该组件名称。                                                                                                      |
   
 表14ServiceCommandDef 
| 参数                | 参数类型                                                                                                                                  | 描述                                                                                                |
|:---|:---|:---|
| command_code      | String                                                                                                                                | **参数说明**：命令编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。       |
| command_name      | String                                                                                                                                | **参数说明**：命令中文名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。 |
| invoke_type       | String                                                                                                                                | **参数说明**：调用方式，同步-SYNC 异步-ASYNC。 **取值范围**：只允许SYNC，ASYNC。     |
| command_paras     | Array of [ServiceCommandParaDef] objects         | **参数说明**：命令参数。                                                                                    |
| command_responses | Array of [ServiceCommandResponseDef] objects | **参数说明**：命令响应列表。                                                                                  |
   
 表15ServiceCommandResponseDef 
| 参数             | 参数类型                                                                                                                          | 描述                                                                                               |
|:---|:---|:---|
| response_code  | String                                                                                                                        | **参数说明**：命令响应编码。 **取值范围**：长度不超过128，只允许英文字母大小写、数字、下划线的组合。 |
| response_paras | Array of [ServiceCommandParaDef] objects | **参数说明**：命令响应的参数列表。                                                                              |
   
 表16ServiceEventDef 
| 参数         | 参数类型                                                                                                                          | 描述                                                                                                        |
|:---|:---|:---|
| event_type | String                                                                                                                        | **参数说明**：设备事件类型。设备服务内不允许重复。 **取值范围**：长度不超过32，只允许英文字母大小写、数字、下划线的组合。 |
| paras      | Array of [ServiceCommandParaDef] objects | **参数说明**：设备事件的参数列表。                                                                                       |
   
 表17ServiceCommandParaDef 
| 参数        | 参数类型             | 描述                                                                                                                                                    |
|:---|:---|:---|
| para_code | String           | **参数说明**：参数标识符。 **取值范围**：长度不超过32，只允许字母、数字、以及_?''#().,\&%@!-字符的组合。                                               |
| para_name | String           | **参数说明**：参数名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。                                                       |
| data_type | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json。 |
| unit      | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%字符的组合。              |
| min       | String           | **参数说明**：参数的最小值。                                                                                                                                      |
| max       | String           | **参数说明**：参数的最大值。                                                                                                                                      |
| enum_list | Array of strings | **参数说明**：枚举值列表。                                                                                                                                       |
   
 表18SpecPropertyDef 
| 参数            | 参数类型             | 描述                                                                                                                                                  |
|:---|:---|:---|
| property_code | String           | **参数说明**：属性编码。 **取值范围**：长度不超过40，只允许英文字母大小写、数字、下划线的组合。                                                       |
| property_name | String           | **参数说明**：属性名称。 **取值范围**：长度不超过40，只允许中文、英文字母大小写、数字、下划线的组合。                                                      |
| data_type     | String           | **参数说明**：数据类型。 **取值范围**：字符串-String 整数-Integer 小数-Decimal 布尔-Boolean 枚举-Enumeration 日期时间-Datetime Json对象-Json。 |
| unit          | String           | **参数说明**：单位。 **取值范围**：只允许中文、英文字母大小写、数字、下划线、数字上标、Greek and Coptic、CJK Compatibility、斜杆、·℃°%字符的组合。             |
| enum_list     | Array of objects | **参数说明**：枚举值列表，字符串数组或者{value，display}的对象数组。 **取值范围**：数组长度不超过100，单字符串长度不超过128。                                  |
   
**状态码：400**
表19响应Body参数 
| 参数         | 参数类型   | 描述                                                                       |
|:---|:---|:---|
| error_code | String | **参数说明**：错误码。 **取值范围**：长度8-36。     |
| error_msg  | String | **参数说明**：错误描述。 **取值范围**：长度2-512。 |
   
#### 请求示例
修改产品
```
UPDATE https://{endpoint}/v1/iotfm/products/18bf11192517e8775048393d
{
  "product_name" : "冷却水机",
  "product_code" : "CoolDownWaterMainPipeV1",
  "product_short_code" : "CDWMP",
  "category_id" : "189ba65d77058655629ea44a"
}
```
#### 响应示例
**状态码：200**
OK
```
{
  "category_code" : "dashboard",
  "category_id" : "18b0ea7d7fb54e7440f01597",
  "def_properties" : [ ],
  "is_system" : false,
  "product_code" : "CoolDownWaterMainPipe",
  "product_description" : "冷却水机的产品",
  "product_id" : "18bf11192517e8775048393d",
  "product_name" : "冷却水总管",
  "product_short_code" : "CDWMP",
  "protocol_type" : "MQTT",
  "service_capabilities" : [ {
    "service_id" : "InfoService",
    "properties" : [ {
      "property_code" : "WaterSupplyTemp",
      "property_name" : "供水温度",
      "data_type" : "Decimal",
      "enum_list" : [ ]
    } ],
    "commands" : [ ],
    "events" : [ ]
  } ]
}
```
#### 状态码
| 状态码 | 描述          |
|:---|:---|
| 200 | OK          |
| 400 | Bad Request |
   
