Updating an Edge Device Twin

Function

This API is used to update an edge device twin.

URI

PUT /v2/{project_id}/edgemgr/devices/{device_id}/twin

Table 1 describes the parameters.

Table 1 Parameters

Parameter

Mandatory

Description

project_id

Yes

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

device_id

Yes

Device ID.

Request

Request parameters

Table 2 Parameter description

Parameter

Mandatory

Type

Description

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 7. The following is an example:

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

property_visitors

No

Table 25 object

Twin property configuration, which varies depending on access_protocol.

Example request

{
    "twin": {
        "devicestate": {
            "expected": {
                "value": "running"
            }
        }
    },
    "property_visitors": {}
}

Response

Table 6 Parameter description

Parameter

Type

Description

twin

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" } 
                     }

property_visitors

Table 25 object

Twin property configuration, which varies depending on access_protocol.

Example response

{
    "twin": {
        "devicestate": {
            "expected": {
                "value": "running",
                "metadata": {
                    "timestamp": 1523514289
                }
            },
            "actual": {
                "value": "stop",
                "metadata": {
                    "timestamp": 1523514289
                }
            },
            "optional": true,
            "metadata": {
                "type": "string"
            }
        }
    },
    "property_visitors": {}
}

Error Codes

For details, see Error Codes.