提供设备影子的查询和更新功能。
GET /api/v1/shadow
Query:
Name | Description | Required | Type |
---|---|---|---|
deviceId | 设备ID | Yes | int |
cURL example:
curl --location --request GET '{{address}}/api/v1/shadow?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}&deviceId={deviceId}' \
--header 'projectId: {projectId}'
Response body:
Name | Type | Description |
---|---|---|
deviceId | string | 设备ID |
createTime | string | 设备影子创建时间 |
connectionState | int | 连接状态 |
properties | struct[] | 属性信息 |
properties的子对象结构体:
Name | Type | Description |
---|---|---|
timestamp | long | 影子文档的最新更新时间 |
version | int | 设备影子版本 |
state | struct | 影子各个属性的状态信息 |
metadata | struct | 影子各个属性的元数据 |
state的子对象结构体:
Name | Type | Description |
---|---|---|
desired | string | 设备的预期状态 |
reported | string | 设备的报告状态 |
metadata的子对象结构体:
Name | Type | Description |
---|---|---|
desired | string | 设备的预期状态 |
reported | string | 设备的报告状态 |
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": {
"deviceId": 10000086,
"createTime": 20191227141301,
"connectionState": 0,
"properties": [{
"timestamp": 20191227141301,
"version": 1,
"state": {
"desired": "1",
"reported": "0"
},
"metadata": {
"desired": "1",
"reported": "0"
}
}]
}
}
PUT /api/v1/shadow
Query:
Name | Type | Description | Required |
---|---|---|---|
deviceId | int | 设备ID | Yes |
Body:
Name | Type | Description | Required |
---|---|---|---|
properties | ShadowPropertyRes | 设备影子信息 | Yes |
ShadowPropertyRes:
Name | Type | Description | Required |
---|---|---|---|
timestamp | long | 更新时间 | No |
version | long | 版本号 | No |
state | ShadowPropertyStateRes | 状态信息 | No |
metadata | ShadowPropertyMetadataRes | 元数据信息 | No |
ShadowPropertyStateRes:
Name | Type | Description | Required |
---|---|---|---|
desired | long | 设备的预期状态 | No |
reported | long | 设备的报告状态 | No |
ShadowPropertyMetadataRes:
Name | Type | Description | Required |
---|---|---|---|
desired | long | 设备的预期状态 | No |
reported | long | 设备的报告状态 | No |
Body example:
{
"properties":{
"timestamp":12314566987,
"version":3,
"state":{
"desired":{},
"reported":{
"color": "RED"
}
}
}
}
cURL example:
curl --location --request PUT '{{address}}/api/v1/shadow?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}&deviceId={deviceId}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties":{
"timestamp":12314566987,
"version":3,
"state":{
"desired":{},
"reported":{
"color": "RED"
}
}
}
}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}