你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Device Templates - Update
通过修补程序更新现有设备模板的云属性和替代。
PATCH https://{subdomain}.{baseDomain}/api/deviceTemplates/{deviceTemplateId}?api-version=2022-07-31
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
base
|
path | True |
string |
所有 Azure IoT Central 服务请求的基域。 |
device
|
path | True |
string |
设备模板的唯一 数字孪生模型标识符 。 |
subdomain
|
path | True |
string |
应用程序子域。 |
api-version
|
query | True |
string |
正在调用的 API 的版本。 |
请求正文
Media Types: "application/json", "application/merge-patch+json"
名称 | 类型 | 说明 |
---|---|---|
body |
object |
设备模板修补程序正文。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功 |
|
Other Status Codes |
从 IoT Central 服务收到的错误响应。 Headers x-ms-error-code: string |
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 | 说明 |
---|---|
user_impersonation | 模拟用户帐户 |
示例
Update a device template
Sample Request
PATCH https://appsubdomain.azureiotcentral.com/api/deviceTemplates/dtmi:contoso:testDeviceTemplate;1?api-version=2022-07-31
{
"displayName": "Test Definition Update",
"@type": [
"ModelDefinition",
"DeviceModel"
],
"capabilityModel": {
"@id": "dtmi:contoso:testCapabilityModel;1",
"@type": "Interface",
"contents": [
{
"@id": "dtmi:contoso:testCapabilityModel:settings;1",
"@type": "Component",
"displayName": "Settings",
"name": "settings",
"schema": {
"@id": "dtmi:contoso:settings;1",
"@type": "Interface",
"contents": [
{
"@type": "Telemetry",
"displayName": "Test Component Telemetry",
"name": "testComponentTelemetry",
"schema": "double"
},
{
"@type": [
"Property",
"Initialized"
],
"displayName": "Temperature Threshold",
"name": "threshold",
"schema": "double",
"writable": true,
"initialValue": "100"
}
],
"displayName": "Settings"
}
},
{
"@type": [
"Property",
"Cloud"
],
"displayName": "Online Status",
"name": "status",
"schema": {
"@type": "Enum",
"enumValues": [
{
"displayName": "Offline",
"enumValue": 1,
"name": "offline"
},
{
"displayName": "Online",
"enumValue": 2,
"name": "online"
}
],
"valueSchema": "integer"
}
}
],
"displayName": "Test Capability Model"
}
}
Sample Response
{
"etag": "\"~FeoA18iSWEoC7QR3Xf33BmlVQoXvM6toNHamHuGdBs8=\"",
"displayName": "Test Definition Update",
"capabilityModel": {
"@id": "dtmi:contoso:testCapabilityModel;1",
"@type": "Interface",
"contents": [
{
"@id": "dtmi:contoso:testCapabilityModel:settings;1",
"@type": "Component",
"displayName": "Settings",
"name": "settings",
"schema": {
"@id": "dtmi:contoso:settings;1",
"@type": "Interface",
"contents": [
{
"@type": "Telemetry",
"displayName": "Test Component Telemetry",
"name": "testComponentTelemetry",
"schema": "double"
},
{
"@type": [
"Property",
"Initialized"
],
"displayName": "Temperature Threshold",
"name": "threshold",
"schema": "double",
"writable": true,
"initialValue": "100"
}
],
"displayName": "Settings"
}
},
{
"@type": [
"Property",
"Cloud"
],
"displayName": "Online Status",
"name": "status",
"schema": {
"@type": "Enum",
"enumValues": [
{
"displayName": "Offline",
"enumValue": 1,
"name": "offline"
},
{
"displayName": "Online",
"enumValue": 2,
"name": "online"
}
],
"valueSchema": "integer"
}
}
],
"displayName": "Test Capability Model"
},
"@id": "dtmi:modelDefinition:contoso;1",
"@type": [
"ModelDefinition",
"DeviceModel"
]
}
定义
名称 | 说明 |
---|---|
Device |
设备模板定义。 |
Error |
响应错误定义。 |
Error |
错误的详细信息。 |
DeviceTemplate
设备模板定义。
名称 | 类型 | 说明 |
---|---|---|
@id |
string |
设备模板的唯一 ID。 |
@type |
string[] |
此设备模板的 JSON-LD 类型。 |
capabilityModel |
object |
此设备模板使用的功能模型。 |
description |
string |
设备模板的详细说明。 |
displayName |
string |
设备模板的显示名称。 |
etag |
string |
ETag 用于防止设备模板更新中发生冲突。 |
Error
响应错误定义。
名称 | 类型 | 说明 |
---|---|---|
error |
当前请求的错误详细信息。 |
ErrorDetails
错误的详细信息。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
错误代码。 |
message |
string |
错误消息详细信息。 |
requestId |
string |
当前请求的相关 ID。 |
time |
string |
错误请求失败的时间。 |