Update virtual device mirrors
- Print
- PDF
Update virtual device mirrors
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Summary
Update virtual device mirror.
A new virtual device mirror is created when none exists. When one already exists, it is modified.
Request
Request URL
POST {CLOUD_IOT_CORE_API_URL}/devices/{deviceName}/mirror
Content-Type: application/json; charset=utf-8
x-ncp-apigw-timestamp: {Timestamp}
x-ncp-iam-access-key: {Sub Account Access Key}
x-ncp-apigw-signature-v2: {API Gateway Signature}
Path Variables
Item | Requirement status | Type | Description |
---|---|---|---|
deviceName | Yes | string | Virtual device name |
Request parameters
Parameter name | Requirement status | Type | Restrictions | Description |
---|---|---|---|---|
name | No | string | Virtual device mirror name (operate as default mirror when null) |
Request body
Updates are only made for the keys specified in the state within the request body.
Keys are deleted when you enter "null" for the key value.
Use only one of the desired and reported properties for general requests.
{
"state" : {
"desired" : "JSONObject",
"reported" : "JSONObject"
},
"clientToken" : "string",
"version" : "long"
}
Item | Requirement status | Type | Description | Limitations |
---|---|---|---|---|
state | Yes | JSON Object | State of the virtual device mirror | |
state.desired | No | JSON Object | State property and value requested to be updated for the virtual device | Although the content of the JSON object is in free format, the sub-level JSON consists of up to six levels. |
state.reported | No | JSON Object | State property and value reported by the virtual device | Although the content of the JSON object is in free format, the sub-level JSON consists of up to six levels. |
clientToken | No | string | When clientToken is included in the request, the clientToken gets displayed in the response as is. | Up to 64 bytes |
version | No | long | The virtual device mirror is only updated when the version value of the request body and the current version value of the virtual device mirror match. |
Response
Response body
{
"metadata": {
"desired" : {
"key" : {
"timstamp" : "long"
}
},
"reported" : {
"key" : {
"timstamp" : "long"
}
}
},
"state": {
"desired": {
"key": "value"
},
"reported": {
"key": "value"
}
},
"clientToken" : "string",
"version": "long",
"timestamp": "long"
}
Item | Type | Description |
---|---|---|
metadata | JSON Object | Object that expresses the time when the key was updated in desired and reported state |
metadata.desired.{keyName}.timestamp | timestamp | Time when the key was updated in desired state |
metadata.reported.{keyName}.timestamp | long | Time when the key was updated in reported state |
state | JSON Object | State of the request body |
state.desired | JSONObject | state.desired of the request body |
state.reported | JSONObject | state.reported of the request body |
clientToken | string | clientToken of the request body |
version | long | Version of the virtual device mirror |
timestamp | long | Time when the virtual device mirror update response was created |
Example
Request body
{
"state": {
"desired": {
"id": "abc1",
"temperature": 33 ,
"isOn": true
}
},
"clientToken": "ABVS111",
"version": 4
}
Response body
{
"metadata": {
"desired": {
"temperature": {
"timestamp": 1631097617
},
"isOn": {
"timestamp": 1631097617
},
"id": {
"timestamp": 1631097617
}
}
},
"clientToken": "ABVS111",
"state": {
"desired": {
"temperature": 33,
"isOn": true,
"id": "abc1"
},
"reported": {
"temperature": 35,
"isOn": false,
"id": "abc1"
}
},
"version": 5,
"timestamp": 1631097617
}
Was this article helpful?