Updating an Edge Device Template

Function

This API is used to update an edge device template.

URI

PUT /v2/{project_id}/edgemgr/device_templates/{device_template_id}

Table 1 URI parameters

Parameter

Mandatory

Description

project_id

Yes

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

device_template_id

Yes

Device template ID.

Request

Table 2 Parameters in the request body

Parameter

Mandatory

Type

Description

device_template

Yes

device_template object

Device template information.

Table 3 device_template

Parameter

Mandatory

Type

Description

description

No

String

Device template description. The value contains a maximum of 255 characters.

attributes

No

Object

Static properties of an edge device. A maximum of 64 key-value pairs are supported.

The key indicates the property name. For details about the format of value, see Table 6. The following is an example:

"attributes": {
            "username": {
                "value": "test",
                "optional": true,
                "metadata": {
                    "type": "string"
                }
            }
        }

twin

No

Object

Dynamic properties of an edge device. A maximum of 64 key-value pairs are supported.

The key indicates the property name. For details about the format of value, see Table 21. The following is an example:

"devicestate":{ 
                      "expected":{ 
                           "value":"running", 
                           "metadata":{ 
                                "timestamp":1536822119463 
                                } 
                           }, 
                     "optional":true, 
                     "metadata":{ "type":"string" } 
                     }

tags

No

Object

Device template tag, in key-value pair format.

access_protocol

No

String

Access protocol. The options are as follows:

  • userdefine: custom protocol
  • modbus: Modbus protocol
  • opc-ua: OPC UA protocol

property_visitors

No

Table 25 object

Twin property configuration, which varies depending on access_protocol.

Example request
{    
         "device_template":{
         "description":"This is a camera template",
         "attributes":{
             "cameraURL":{
                 "value":"127.0.0.1",
                 "metadata":{
                     "type":"string"
                 }
             }
         },
         "twin":{
             "runstate":{
                 "expected":{
                     "value":"running"
                 },
                 "metadata":{
                     "type":"string"
                 }
             }
         }
     }
}

Response

Table 4 Parameter description

Parameter

Type

Description

device_template

Table 5

Details about the edge device template.

Example response

{
     "device_template":{
         "name":"CameraTemplate",
         "description":"This is a camera template",
         "created_at":"2018-07-16T04:01:21.212072",
         "updated_at":"2018-07-18T04:01:21.212017",
         "access_protocol": "userdefine",
         "project_id":"d16e6eb6cc0d49a0941df2f31285757a",
         "id":"82952098-ec24-4643-94e6-9989174fce05",
         "attributes":{
             "cameraURL":{
                 "value":"127.0.0.1",
                 "metadata":{
                     "type":"string"
                 }
             },
             "twin":{
                 "runstate":{
                     "expected":{
                         "value":"running"
                     },
                     "metadata":{
                         "type":"string"
                     }
                 }
             }
         }
     }
 }

Error Codes

For details, see Error Codes.