设备
<p>[TOC]</p>
<ul>
<li>
<h2>创建设备</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/device</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>POST </li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
{
&quot;name&quot;: &quot;测试api创建设备1&quot;,
&quot;type&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;customerId&quot;: {//客户
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;e9c02870-7d00-11ed-8390-0f469c2dc9ee&quot;
}
}</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;id&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;7ae33f10-512f-11ee-96a8-370bbcf38443&quot;
},
&quot;createdTime&quot;: 1694497486209,
&quot;additionalInfo&quot;: null,
&quot;tenantId&quot;: {
&quot;entityType&quot;: &quot;TENANT&quot;,
&quot;id&quot;: &quot;b3898830-7c7b-11ed-8390-0f469c2dc9ee&quot;
},
&quot;customerId&quot;: {
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;e9c02870-7d00-11ed-8390-0f469c2dc9ee&quot;
},
&quot;name&quot;: &quot;测试api创建设备1&quot;,
&quot;type&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;label&quot;: null,
&quot;deviceProfileId&quot;: {
&quot;entityType&quot;: &quot;DEVICE_PROFILE&quot;,
&quot;id&quot;: &quot;71fda560-93b7-11ed-99fc-21fcefd60962&quot;
},
&quot;deviceData&quot;: {
&quot;configuration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
},
&quot;transportConfiguration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
}
},
&quot;firmwareId&quot;: null,
&quot;softwareId&quot;: null,
&quot;externalId&quot;: null
}</code></pre>
<ul>
<li>
<h2>删除设备</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/device/设备id</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>DELETE </li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
</code></pre>
<ul>
<li>
<h2>将设备分配给客户</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net//api/customer/{customerID}/device/{deviceID}</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>post</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;id&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;089d7e30-47a1-11ee-a6f2-9b0e91a77621&quot;
},
&quot;createdTime&quot;: 1693446745491,
&quot;additionalInfo&quot;: {
&quot;gateway&quot;: false,
&quot;overwriteActivityTime&quot;: false,
&quot;description&quot;: &quot;&quot;
},
&quot;tenantId&quot;: {
&quot;entityType&quot;: &quot;TENANT&quot;,
&quot;id&quot;: &quot;b3898830-7c7b-11ed-8390-0f469c2dc9ee&quot;
},
&quot;customerId&quot;: {
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;e9c02870-7d00-11ed-8390-0f469c2dc9ee&quot;
},
&quot;name&quot;: &quot;测试智能门磁设备1&quot;,
&quot;type&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;label&quot;: &quot;&quot;,
&quot;deviceProfileId&quot;: {
&quot;entityType&quot;: &quot;DEVICE_PROFILE&quot;,
&quot;id&quot;: &quot;71fda560-93b7-11ed-99fc-21fcefd60962&quot;
},
&quot;deviceData&quot;: {
&quot;configuration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
},
&quot;transportConfiguration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
}
},
&quot;firmwareId&quot;: null,
&quot;softwareId&quot;: null,
&quot;externalId&quot;: null
}</code></pre>
<ul>
<li>
<h2>取消设备分配的客户</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net//api/customer/device/{deviceID}</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>DELETE</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;id&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;089d7e30-47a1-11ee-a6f2-9b0e91a77621&quot;
},
&quot;createdTime&quot;: 1693446745491,
&quot;additionalInfo&quot;: {
&quot;gateway&quot;: false,
&quot;overwriteActivityTime&quot;: false,
&quot;description&quot;: &quot;&quot;
},
&quot;tenantId&quot;: {
&quot;entityType&quot;: &quot;TENANT&quot;,
&quot;id&quot;: &quot;b3898830-7c7b-11ed-8390-0f469c2dc9ee&quot;
},
&quot;customerId&quot;: {
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;13814000-1dd2-11b2-8080-808080808080&quot;
},
&quot;name&quot;: &quot;测试智能门磁设备1&quot;,
&quot;type&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;label&quot;: &quot;&quot;,
&quot;deviceProfileId&quot;: {
&quot;entityType&quot;: &quot;DEVICE_PROFILE&quot;,
&quot;id&quot;: &quot;71fda560-93b7-11ed-99fc-21fcefd60962&quot;
},
&quot;deviceData&quot;: {
&quot;configuration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
},
&quot;transportConfiguration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
}
},
&quot;firmwareId&quot;: null,
&quot;softwareId&quot;: null,
&quot;externalId&quot;: null
}</code></pre>
<ul>
<li>
<h2>获取设备访问凭证</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/device/设备id/credentials</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>get</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;id&quot;: {
&quot;id&quot;: &quot;089e8fa0-47a1-11ee-a6f2-9b0e91a77621&quot;
},
&quot;createdTime&quot;: 1693446745498,
&quot;deviceId&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;089d7e30-47a1-11ee-a6f2-9b0e91a77621&quot;
},
&quot;credentialsType&quot;: &quot;ACCESS_TOKEN&quot;,
&quot;credentialsId&quot;: &quot;PB1oedds0ROpr2FlntxM&quot;,//设备访问凭证
&quot;credentialsValue&quot;: null
}
</code></pre>
<ul>
<li>
<h2>批量导入设备</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/device/bulk_import</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>post</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>file: 这是CSV文件的内容,以字符串形式表示。
批量导入以下两个设备:
名称为 DeviceA,类型为 Type1,访问令牌为 TokenA
名称为 DeviceB,类型为 Type2,访问令牌为 TokenB
name,type,access_token
DeviceA,Type1,TokenA
DeviceB,Type2,TokenB
mapping:定义如何从CSV文件中解析数据。//不能设置客户
columns: 列的列表,表示CSV文件中的每一列。
key: CSV列的名称。
type: 定义列的类型,如ACCESS_TOKEN、NAME、TYPE等。
delimiter: 用于分隔CSV文件中的列的字符,常见的是逗号,。
header: 布尔值,表示CSV文件的第一行是否是标题行。
update: 布尔值,表示是否应更新现有的设备记录。
-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
{
&quot;file&quot;: &quot;name,type,access_token\nDeviceA,Type1,TokenA\nDeviceB,Type2,TokenB&quot;,
&quot;mapping&quot;: {
&quot;columns&quot;: [
{
&quot;key&quot;: &quot;name&quot;,
&quot;type&quot;: &quot;NAME&quot;
},
{
&quot;key&quot;: &quot;type&quot;,
&quot;type&quot;: &quot;TYPE&quot;
},
{
&quot;key&quot;: &quot;access_token&quot;,
&quot;type&quot;: &quot;ACCESS_TOKEN&quot;
}
],
&quot;delimiter&quot;: &quot;,&quot;,
&quot;header&quot;: true,
&quot;update&quot;: true
}
}
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;created&quot;: 2,
&quot;updated&quot;: 0,
&quot;errors&quot;: 0,
&quot;errorsList&quot;: []
}</code></pre>
<ul>
<li>
<h2>通过设备名称来获取设备信息</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/tenant/devices?deviceName={设备名称}</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>get</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;id&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;92adc330-510d-11ee-96a8-370bbcf38443&quot;
},
&quot;createdTime&quot;: 1694482923235,
&quot;additionalInfo&quot;: {},
&quot;tenantId&quot;: {
&quot;entityType&quot;: &quot;TENANT&quot;,
&quot;id&quot;: &quot;b3898830-7c7b-11ed-8390-0f469c2dc9ee&quot;
},
&quot;customerId&quot;: {
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;13814000-1dd2-11b2-8080-808080808080&quot;
},
&quot;name&quot;: &quot;DeviceA&quot;,
&quot;type&quot;: &quot;Type1&quot;,
&quot;label&quot;: null,
&quot;deviceProfileId&quot;: {
&quot;entityType&quot;: &quot;DEVICE_PROFILE&quot;,
&quot;id&quot;: &quot;92aadd00-510d-11ee-96a8-370bbcf38443&quot;
},
&quot;deviceData&quot;: {
&quot;configuration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
},
&quot;transportConfiguration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
}
},
&quot;firmwareId&quot;: null,
&quot;softwareId&quot;: null,
&quot;externalId&quot;: null
}
</code></pre>
<ul>
<li>
<h2>获取租户的设备信息(查询租户的设备)</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/tenant/deviceInfos?pageSize=10&amp;page=0&amp;type=数据分析传感器设备配置 &amp;textSearch=测试人体红外传感器设备1 &amp;sortProperty=name&amp;sortOrder=ASC</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>get</li>
</ul>
<h5>JSON 格式</h5>
<pre><code>-H 'Content-Type: application/json' \
-H 'X-Authorization : Bearer' \ 租户管理员的JWT 令牌
//查询字符串
pageSize: 这指定了每页要返回的项目数量。
值: 10
page: 这指定了页码,通常从0开始。
值: 0
type: 这是用来过滤某种类型的设备的。根据URL解码,您是在查找类型为“数据分析传感器设备配置”的设备。
值: 数据分析传感器设备配置
textSearch: 这是一个过滤条件,API会返回那些名字或其他相关属性包含这个字符串的设备。根据URL解码,您是在搜索包含“测试”的设备。
值: 测试
sortProperty: 这指定了返回的设备应该基于哪个属性进行排序。
值: (例如: &quot;name&quot;, &quot;label&quot;, &quot;deviceProfileName&quot;, &quot;label&quot;, &quot;label&quot;)
sortOrder: 这指定了排序的顺序,可以是ASC (升序) 或 DESC (降序)。
值: ASC
</code></pre>
<h5>返回参数</h5>
<pre><code>{
&quot;data&quot;: [
{
&quot;id&quot;: {
&quot;entityType&quot;: &quot;DEVICE&quot;,
&quot;id&quot;: &quot;880786a0-47a3-11ee-a6f2-9b0e91a77621&quot;
},
&quot;createdTime&quot;: 1693447818250,
&quot;additionalInfo&quot;: {
&quot;gateway&quot;: false,
&quot;overwriteActivityTime&quot;: false,
&quot;description&quot;: &quot;&quot;
},
&quot;tenantId&quot;: {
&quot;entityType&quot;: &quot;TENANT&quot;,
&quot;id&quot;: &quot;b3898830-7c7b-11ed-8390-0f469c2dc9ee&quot;
},
&quot;customerId&quot;: {
&quot;entityType&quot;: &quot;CUSTOMER&quot;,
&quot;id&quot;: &quot;13814000-1dd2-11b2-8080-808080808080&quot;
},
&quot;name&quot;: &quot;测试人体红外传感器设备1&quot;,
&quot;type&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;label&quot;: &quot;&quot;,
&quot;deviceProfileId&quot;: {
&quot;entityType&quot;: &quot;DEVICE_PROFILE&quot;,
&quot;id&quot;: &quot;71fda560-93b7-11ed-99fc-21fcefd60962&quot;
},
&quot;deviceData&quot;: {
&quot;configuration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
},
&quot;transportConfiguration&quot;: {
&quot;type&quot;: &quot;DEFAULT&quot;
}
},
&quot;firmwareId&quot;: null,
&quot;softwareId&quot;: null,
&quot;externalId&quot;: null,
&quot;customerTitle&quot;: null,
&quot;customerIsPublic&quot;: false,
&quot;deviceProfileName&quot;: &quot;数据分析传感器设备配置&quot;,
&quot;active&quot;: false
}
],
&quot;totalPages&quot;: 1,
&quot;totalElements&quot;: 1,
&quot;hasNext&quot;: false
}
</code></pre>
<ul>
<li>
<h2>通过设备凭证来发送遥测数据</h2>
</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://iot.cocall.net/api/v1/$ACCESS_TOKEN/telemetry</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>post
<h5>JSON 格式</h5></li>
</ul>
<pre><code>{&quot;key1&quot;:&quot;value1&quot;, &quot;key2&quot;:&quot;value2&quot;}
或者
[{&quot;key1&quot;:&quot;value1&quot;}, {&quot;key2&quot;:&quot;value2&quot;}]
</code></pre>