设备列表管理

创建单个设备

方法 API 说明
POST /v3/iot/management/device 创建单个设备

请求参数

参数名称 参数类型 是否必须 说明
deviceName string 必选 设备名称
description string 必选 描述
schemaId string 必选 物模型

返回参数

一个DeviceAccessDetailResponse对象

请求示例

POST /v3/iot/management/device HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
       "deviceName": "mydevice",
       "description": "device_description",
       "schemaId":"uuid"
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
       "tcpEndpoint": "tcp://test.baidu.iot.com",
       "sslEndpoint": "ssl://test.baidu.iot.com",
       "username": "endpointName/device_1",
       "key":"bWwCxGwaw3boV48NqsuG+XVaHpxfKdMPvmdJzNObvbY="
}

删除设备

方法 API 说明
PUT /v3/iot/management/device?remove 删除设备

请求参数

一个DeviceListRequest对象

返回参数

一个DeviceListResponse对象

请求示例

PUT /v3/iot/management/device?remove HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
    "devices": [
        "device-1",
        "device-2"
    ]
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "devices": [
        "device-1",
        "device-2"
    ]
}

获取设备Profile

方法 API 说明
GET /v3/iot/management/device/{deviceName} 获取设备Profile

返回参数

一个DeviceProfileResponse对象

请求示例

GET /v3/iot/management/device/mydevice HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "name": "mydevice",
    "description": "my device in Shanghai",
    "createTime": 1494904250,
    "state": "online",
    "lastActiveTime": 1494904250,
    "schemaId": "uuid",
    "schemaName": "baidu_shanghai",
    "favourite": false,
    "attributes": {
        "region": "Shanghai"
    },
    "device": {
        "reported": {
            "firewareVersion": "1.0.0",
            "light": "green"
        },
        "desired": {
            "light": "red"
        },
        "lastUpdatedTime": {
            "reported": {
                "firewareVersion": 1494904250,
                "light": 1494904250
            },
            "desired": {
                "light": 1494904250
            }
        },
        "profileVersion": 10
    }
}

获取设备View

方法 API 说明
GET /v3/iot/management/deviceView/{deviceName} 获取设备Profile和模型合并后的View

返回参数

一个DeviceViewResponse对象

请求示例

GET /v3/iot/management/deviceView/mydevice HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "name": "mydevice",
    "description": "my device in Shanghai",
    "createTime": 1326789000,
    "state": "online",
    "lastActiveTime": 1326789000,
    "schemaId":"uuid",
    "schemaName":"baidu_shanghai",
    "favourite":false,
    "profileVersion": 10,
    "properties":[
        {
            "attributeName": "light",
            "showName": "灯光",
            "type":"string",
            "defaultValue": "red",
            "reportedValue": "green",
            "desiredValue": "green"
            "unit": "-",
            "reportedTime": 1326789000,
            "desiredTime": 1435860000
        }
     ]
}

获取及查询影子列表

方法 API 说明
GET /v3/iot/management/device?pageNo=xx&pageSize=xx&orderBy=xx&&order=xx&name=xx&value=xx&favourite=xx 查询设备Profile

请求参数

参数名称 参数类型 是否必须 说明
pageNo int 可选 表示取第几页,默认1
pageSize int 可选 每页返回的数目,默认10
orderBy String 可选 name,createTime,lastActiveTime,默认name
order String 可选 按升序或降序返回结果,desc / asc,默认asc
name String 可选 查询属性名,默认全量
value String 可选 查询属性名对应的值,默认全量
favourite String 可选 收藏,true / false /all,默认all

返回参数

参数名称 参数类型 说明
devices List 由DeviceProfile对象组成的列表
amount int 总数目
pageNo int 返回页数
pageSize int 每页返回数目

请求示例

GET /v3/iot/management/device?pageNo=1&pageSize=10&orderBy=createTime&&order=desc&name=schemaName&value=baidu_shanghai&favourite=false HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "amount": 20,
    "pageNo": 1,
    "pageSize": 10,
    "devices": [
        {
            "name": "mydevice",
            "description": "my description",
            "state": "online",
            "createTime": 1326789000,
            "lastActiveTime": 1326789000,
            "schemaId": "uuid",
            "schemaName": "baidu_shanghai",
            "favourite": false,
            "attributes": {
                "region": "Shanghai"
            },
            "device": {
                "reported": {
                    "light": "green"
                },
                "desired": {
                    "light": "red"
                },
                "profileVersion": 10,
                "lastUpdatedTime": {
                    "reported": {
                        "light": 1326789000
                    },
                    "desired": {
                        "light": 1326789000
                    }
                }
            }
        }
        ...
    ]

}

获取设备接入详情

方法 API 说明
GET /v3/iot/management/device/{deviceName}/accessDetail 获取设备接入详情

返回参数

一个DeviceAccessDetailResponse实例

请求示例

GET /v3/iot/management/device/mydevice/accessDetail HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "tcpEndpoint": "tcp://test.baidu.iot.com",
    "sslEndpoint": "ssl://test.baidu.iot.com",
    "username": "endpointName/device_1",
    "key":"xxxxxxxxx"
}

更新密钥

方法 API 说明
PUT /v3/iot/management/device/{deviceName}?updateSecretKey 更改密钥

请求参数

参数名称 参数类型 是否必须 说明
deviceName String 必须 设备名称

返回参数

一个DeviceAccessDetailResponse实例

请求示例

PUT /v3/iot/management/device/deviceName?updateSecretKey HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "tcpEndpoint": "tcp://test.baidu.iot.com",
    "sslEndpoint": "ssl://test.baidu.iot.com",
    "username": "endpointName/deviceName",
    "key":"bWwCxGwaw3boV48NqsuG+XVaHpxfKdMPvmdJzNObvbY="
}

更新设备属性

方法 API 说明
PUT /v3/iot/management/device/{deviceName}?updateProfile 修改设备属性

请求参数

参数名称 参数类型 是否必须 说明
attributes JSONObject 可选 需要更新的attributes
device DeviceAttributes 可选 需要更新的device属性

返回参数

一个DeviceProfileResponse对象

请求示例

PUT /v3/iot/management/device/myDevice?updateProfile HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
    "device": {
        "desired": {
            "light": "red"
        },
        "reported": {
            "light": "green"
        }
    },
    "attributes": {
        “region”:“Shanghai”
    }
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "name": "mydevice",
    "description": "my device in Shanghai",
    "createTime": 1494904250,
    "state": "online",
    "lastActiveTime": 1494904250,
    "schemaId": "uuid",
    "schemaName": "baidu_shanghai",
    "favourite": false,
    "attributes": {
        "region": "Shanghai"
    },
    "device": {
        "reported": {
            "firewareVersion": "1.0.0",
            "light": "green"
        },
        "desired": {
            "light": "red"
        },
        "lastUpdatedTime": {
            "reported": {
                "firewareVersion": 1494904250,
                "light": 1494904250
            },
            "desired": {
                "light": 1494904250
            }
        },
        "profileVersion": 10
    }
}

更新单个设备View信息

方法 API 说明
PUT /v3/iot/management/deviceView/{deviceName}?updateView 修改设备View信息

请求参数

请求名称 参数类型 是否必须 说明
reported JsonNode 可选 需要更新的reported
desired JsonNode 可选 需要更新的desired
profileVersion int 可选 更新版本

返回参数

一个DeviceViewResponse对象

请求示例

PUT /v3/iot/management/deviceView/myDevice?updateView HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
    "desired": {
        "light": "red"
    },
    "reported": {
        "light": "green"
    }
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "name": "myDevice",
    "description": "my device in Shanghai",
    "createTime": 1326789000,
    "state": "online",
    "lastActiveTime": 1326789000,
    "schemaId": "uuid",
    "schemaName": "baidu_shanghai",
    "favourite": false,
    "profileVersion": 1,
    "properties": [
        {
            "attributeName": "light",
            "showName": "灯光",
            "type": "String",
            "defaultValue": "red",
            "reportedValue": "green",
            "desiredValue": "red",
            "unit": "-",
            "reportedTime": 1435860000,
            "desiredTime": 1435860000
        }
    ]
}

更新单个设备注册表信息

方法 API 说明
PUT /v3/iot/management/device/{deviceName}?updateRegistry 更新单个设备注册表信息

请求参数

参数名称 参数类型 是否必须 说明
description String 可选 需要更新的设备描述
schemaId String 可选 需要更换的模板Id
favourite boolean 可选 是否需要收藏

返回参数

一个DeviceProfileResponse对象

请求示例

PUT /v3/iot/management/device/myDevice?updateRegistry HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
    "description": "new device description",
    "schemaId": "uuid",
    "favourite":true,
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "name": "mydevice",
    "description": "new device description",
    "createTime": 1494904250,
    "state": "online",
    "lastActiveTime": 1494904250,
    "schemaId": "uuid",
    "schemaName": "baidu_shanghai",
    "favourite": true,
    "attributes": {
        "region": "Shanghai"
    },
    "device": {
        "reported": {
            "firewareVersion": "1.0.0",
            "light": "green"
        },
        "desired": {
            "light": "red"
        },
        "lastUpdatedTime": {
            "reported": {
                "firewareVersion": 1494904250,
                "light": 1494904250
            },
            "desired": {
                "light": 1494904250
            }
        },
        "profileVersion": 10
    }
}

重置设备影子

方法 API 说明
PUT /v3/iot/management/device?reset 重置(清空)设备影子

请求参数

一个DeviceListRequest对象

返回参数

一个DeviceListResponse对象

请求示例

PUT /v3/iot/management/device?reset HTTP/1.1
Host: iotdm.gz.baidubce.com
Authorization: {authorization}
Content-Type: application/json; charset=utf-8
{
    "devices":[
        "device-1",
        "device-2"
     ]
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
x-bce-request-id: 993ff7e9-018b-4246-a7ba-5dddac970054
{
    "devices": [
        "device-1",
        "device-2"
    ]
}