你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Device Templates - List

获取应用程序中的设备模板列表。

GET https://{subdomain}.{baseDomain}/api/deviceTemplates?api-version=2022-07-31

URI 参数

名称 必需 类型 说明
baseDomain
path True

string

所有 Azure IoT Central 服务请求的基域。

subdomain
path True

string

应用程序子域。

api-version
query True

string

正在调用的 API 的版本。

响应

名称 类型 说明
200 OK

DeviceTemplateCollection

成功

Other Status Codes

Error

从 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 模拟用户帐户

示例

List device templates

Sample Request

GET https://appsubdomain.azureiotcentral.com/api/deviceTemplates?api-version=2022-07-31

Sample Response

{
  "value": [
    {
      "etag": "\"~FeoA18iSWEoC7QR3Xf33BmlVQoXvM6toNHamHuGdBs8=\"",
      "displayName": "Test Contoso Definition",
      "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": [
              "Telemetry",
              "Humidity"
            ],
            "displayName": "Humidity",
            "name": "humidity",
            "schema": "double"
          },
          {
            "@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",
        "extends": [
          {
            "@id": "dtmi:contoso:testInterface;1",
            "@type": [
              "Interface",
              "NamedInterface"
            ],
            "contents": [
              {
                "@type": "Telemetry",
                "displayName": "Test Telemetry",
                "name": "testTelemetry",
                "schema": "double"
              },
              {
                "@type": [
                  "EventValue",
                  "Telemetry",
                  "Event"
                ],
                "displayName": "Test Event",
                "name": "testEvent",
                "schema": "integer",
                "severity": "warning"
              },
              {
                "@type": [
                  "Initialized",
                  "Property"
                ],
                "displayName": "Test Property",
                "name": "testProperty",
                "schema": "string",
                "writable": true,
                "initialValue": "initialValue1"
              },
              {
                "@type": "Property",
                "displayName": "Test Read-Only Property",
                "name": "testReadOnly",
                "schema": "string"
              },
              {
                "@type": "Property",
                "displayName": "Test Complex Property",
                "name": "testComplex",
                "schema": {
                  "@id": "dtmi:contoso:testComplex;1",
                  "@type": "Object",
                  "displayName": "Object",
                  "fields": [
                    {
                      "displayName": "First",
                      "name": "first",
                      "schema": "string"
                    },
                    {
                      "displayName": "Second",
                      "name": "second",
                      "schema": "string"
                    }
                  ]
                },
                "writable": true
              },
              {
                "@type": "Command",
                "commandType": "synchronous",
                "displayName": "Test Command",
                "name": "testCommand",
                "request": {
                  "@type": "CommandPayload",
                  "displayName": "Test Request",
                  "name": "testRequest",
                  "schema": "double"
                },
                "response": {
                  "@type": "CommandPayload",
                  "displayName": "Test Response",
                  "name": "testResponse",
                  "schema": "geopoint"
                }
              },
              {
                "@type": "Property",
                "displayName": "Test Enum",
                "name": "testEnum",
                "schema": {
                  "@id": "dtmi:contoso:testEnum;1",
                  "@type": "Enum",
                  "displayName": "Enum",
                  "enumValues": [
                    {
                      "displayName": "First",
                      "enumValue": 1,
                      "name": "first"
                    },
                    {
                      "displayName": "Second",
                      "enumValue": 2,
                      "name": "second"
                    }
                  ],
                  "valueSchema": "integer"
                },
                "writable": true
              }
            ],
            "displayName": "Test Interface",
            "name": "contoso_testInterface"
          }
        ]
      },
      "@id": "dtmi:modelDefinition:contoso;1",
      "@type": [
        "ModelDefinition",
        "DeviceModel"
      ]
    }
  ]
}

定义

名称 说明
DeviceTemplate

设备模板定义。

DeviceTemplateCollection

设备模板的分页结果。

Error

响应错误定义。

ErrorDetails

错误的详细信息。

DeviceTemplate

设备模板定义。

名称 类型 说明
@id

string

设备模板的唯一 ID。

@type

string[]

此设备模板的 JSON-LD 类型。

capabilityModel

object

此设备模板使用的功能模型。

description

string

设备模板的详细说明。

displayName

string

设备模板的显示名称。

etag

string

ETag 用于防止设备模板更新中发生冲突。

DeviceTemplateCollection

设备模板的分页结果。

名称 类型 说明
nextLink

string

用于获取设备模板的下一页的 URL。

value

DeviceTemplate[]

设备模板的集合。

Error

响应错误定义。

名称 类型 说明
error

ErrorDetails

当前请求的错误详细信息。

ErrorDetails

错误的详细信息。

名称 类型 说明
code

string

错误代码。

message

string

错误消息详细信息。

requestId

string

当前请求的相关 ID。

time

string

错误请求失败的时间。