注册表事件 - Amazon IoT Core
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

注册表事件

在创建、更新或删除了事物、事物类型和事物组时,注册表将发布事件消息。但是,默认情况下,这些事件不可用。有关如何启用这些事件的更多信息,请参阅 启用以下项的事件 Amazon IoT

注册表可以提供以下事件类型:

事物事件

事物已创建/已更新/已删除

在创建、更新或删除了事物时,注册表将发布以下事件消息:

  • $aws/events/thing/thingName/created

  • $aws/events/thing/thingName/updated

  • $aws/events/thing/thingName/deleted

消息包含以下示例负载:

{ "eventType" : "THING_EVENT", "eventId" : "f5ae9b94-8b8e-4d8e-8c8f-b3266dd89853", "timestamp" : 1234567890123, "operation" : "CREATED|UPDATED|DELETED", "accountId" : "123456789012", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "thingName" : "MyThing", "versionNumber" : 1, "thingTypeName" : null, "attributes": { "attribute3": "value3", "attribute1": "value1", "attribute2": "value2" } }

负载包含以下属性:

eventType

设置为“THING_EVENT”。

eventId

唯一事件 ID (字符串)。

时间戳

事件发生的 UNIX 时间戳。

operation

触发事件的操作。有效值为:

  • CREATED

  • 已更新

  • DELETED

accountId

你的 Amazon Web Services 账户 身份证。

thingId

要创建、更新或删除的事物的 ID。

thingName

要创建、更新或删除的事物的名称。

versionNumber

要创建、更新或删除的事物的版本。在创建事物时,此值设置为 1。每次更新事物时,此值增加 1。

thingTypeName

与事物关联的事物类型 (如果存在)。否则为 null

attributes

与事物关联的名称/值对的集合。

事物类型事件

事物类型已创建/已弃用/已取消弃用/已删除

在创建、弃用、取消弃用或删除了事物类型时,注册表将发布以下事件消息:

  • $aws/events/thingType/thingTypeName/created

  • $aws/events/thingType/thingTypeName/updated

  • $aws/events/thingType/thingTypeName/deleted

消息包含以下示例负载:

{ "eventType" : "THING_TYPE_EVENT", "eventId" : "8827376c-4b05-49a3-9b3b-733729df7ed5", "timestamp" : 1234567890123, "operation" : "CREATED|UPDATED|DELETED", "accountId" : "123456789012", "thingTypeId" : "c530ae83-32aa-4592-94d3-da29879d1aac", "thingTypeName" : "MyThingType", "isDeprecated" : false|true, "deprecationDate" : null, "searchableAttributes" : [ "attribute1", "attribute2", "attribute3" ], "description" : "My thing type" }

负载包含以下属性:

eventType

设置为“THING_TYPE_EVENT”。

eventId

唯一事件 ID (字符串)。

时间戳

事件发生的 UNIX 时间戳。

operation

触发事件的操作。有效值为:

  • CREATED

  • 已更新

  • DELETED

accountId

你的 Amazon Web Services 账户 身份证。

thingTypeId

要创建、弃用或删除的事物类型的 ID。

thingTypeName

要创建、弃用或删除的事物类型的名称。

isDeprecated

如果事物类型已弃用,则为 true。否则为 false

deprecationDate

弃用事物类型的 UNIX 时间戳。

searchableAttributes

与可用于搜索的事物类型关联的名称/值对集合。

description

事物类型的描述。

事物类型已与某个事物关联或取消关联

当事物类型与某个事物关联或取消关联时,注册表将发布以下事件消息。

  • $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/added

  • $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/removed

以下是 added 负载的示例。removed 消息的有效负载类似。

{ "eventId" : "87f8e095-531c-47b3-aab5-5171364d138d", "eventType" : "THING_TYPE_ASSOCIATION_EVENT", "operation" : "ADDED", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "thingName": "myThing", "thingTypeName" : "MyThingType", "timestamp" : 1234567890123, }

负载包含以下属性:

eventId

唯一事件 ID (字符串)。

eventType

设置为“THING_TYPE_ASSOCIATION_EVENT”。

operation

触发事件的操作。有效值为:

  • 已添加

  • REMOVED

thingId

已更改其类型关联的事物的 ID。

thingName

已更改其类型关联的事物的名称。

thingTypeName

已与事物关联或不再与事物关联的事物类型。

时间戳

事件发生的 UNIX 时间戳。

事物组事件

事物组已创建/已更新/已删除

在创建、更新或删除了事物组时,注册表将发布以下事件消息。

  • $aws/events/thingGroup/groupName/created

  • $aws/events/thingGroup/groupName/updated

  • $aws/events/thingGroup/groupName/deleted

以下是 updated 负载的示例。createddeleted 消息的负载类似。

{ "eventType": "THING_GROUP_EVENT", "eventId": "8b9ea8626aeaa1e42100f3f32b975899", "timestamp": 1603995417409, "operation": "UPDATED", "accountId": "571EXAMPLE833", "thingGroupId": "8757eec8-bb37-4cca-a6fa-403b003d139f", "thingGroupName": "Tg_level5", "versionNumber": 3, "parentGroupName": "Tg_level4", "parentGroupId": "5fce366a-7875-4c0e-870b-79d8d1dce119", "description": "New description for Tg_level5", "rootToParentThingGroups": [ { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/TgTopLevel", "groupId": "36aa0482-f80d-4e13-9bff-1c0a75c055f6" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level1", "groupId": "bc1643e1-5a85-4eac-b45a-92509cbe2a77" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level2", "groupId": "0476f3d2-9beb-48bb-ae2c-ea8bd6458158" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level3", "groupId": "1d9d4ffe-a6b0-48d6-9de6-2e54d1eae78f" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level4", "groupId": "5fce366a-7875-4c0e-870b-79d8d1dce119" } ], "attributes": { "attribute1": "value1", "attribute3": "value3", "attribute2": "value2" }, "dynamicGroupMappingId": null }

负载包含以下属性:

eventType

设置为“THING_GROUP_EVENT”。

eventId

唯一事件 ID (字符串)。

时间戳

事件发生的 UNIX 时间戳。

operation

触发事件的操作。有效值为:

  • CREATED

  • 已更新

  • DELETED

accountId

你的 Amazon Web Services 账户 身份证。

thingGroupId

要创建、更新或删除的事物组的 ID。

thingGroupName

要创建、更新或删除的事物组的名称。

versionNumber

事物组的版本。在创建事物组时,此值设置为 1。每次更新事物组时,此值增加 1。

parentGroupName

父事物组的名称(如果存在)。

parentGroupId

父事物组的 ID(如果存在)。

description

事物组的描述。

rootToParentThingGroups

有关父事物组的信息数组。每个父事物组都有一个条目,从根事物组开始,继续直至达到父事物组。每个条目均包含事物组的 groupArngroupId

attributes

与事物组关联的名称/值对的集合。

事物已添加到事物组或从事物组中删除

当事物已添加到事物组或从事物组中删除时,注册表将发布以下事件消息。

  • $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/added

  • $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/removed

消息包含以下示例负载:

{ "eventType" : "THING_GROUP_MEMBERSHIP_EVENT", "eventId" : "d684bd5f-6f6e-48e1-950c-766ac7f02fd1", "timestamp" : 1234567890123, "operation" : "ADDED|REMOVED", "accountId" : "123456789012", "groupArn" : "arn:aws:iot:ap-northeast-2:123456789012:thinggroup/MyChildThingGroup", "groupId" : "06838589-373f-4312-b1f2-53f2192291c4", "thingArn" : "arn:aws:iot:ap-northeast-2:123456789012:thing/MyThing", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "membershipId" : "8505ebf8-4d32-4286-80e9-c23a4a16bbd8" }

负载包含以下属性:

eventType

设置为“THING_GROUP_MEMBERSHIP_EVENT”。

eventId

事件 ID。

时间戳

事件发生的 UNIX 时间戳。

operation

当事物添加到事物组时为 ADDED。当事物从事物组中删除时为 REMOVED

accountId

你的 Amazon Web Services 账户 身份证。

groupArn

事物组的 ARN。

groupId

组的 ID。

thingArn

在事物组中添加或删除的事物的 ARN。

thingId

在事物组中添加或删除的事物的 ID。

membershipId

表示事物与事物组之间关系的 ID。将事物添加到事物组时生成此值。

事物组已添加到事物组或从事物组中删除

当某个事物组已添加到另一个事物组或从另一个事物组中删除时,注册表将发布以下事件消息。

  • $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/added

  • $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/removed

消息包含以下示例负载:

{ "eventType" : "THING_GROUP_HIERARCHY_EVENT", "eventId" : "264192c7-b573-46ef-ab7b-489fcd47da41", "timestamp" : 1234567890123, "operation" : "ADDED|REMOVED", "accountId" : "123456789012", "thingGroupId" : "8f82a106-6b1d-4331-8984-a84db5f6f8cb", "thingGroupName" : "MyRootThingGroup", "childGroupId" : "06838589-373f-4312-b1f2-53f2192291c4", "childGroupName" : "MyChildThingGroup" }

负载包含以下属性:

eventType

设置为“THING_GROUP_HIERARCHY_EVENT”。

eventId

事件 ID。

时间戳

事件发生的 UNIX 时间戳。

operation

当事物添加到事物组时为 ADDED。当事物从事物组中删除时为 REMOVED

accountId

你的 Amazon Web Services 账户 身份证。

thingGroupId

父事物组的 ID。

thingGroupName

父事物组的名称。

childGroupId

子事物组的 ID。

childGroupName

子事物组的名称。