|
| 1 | +from datetime import datetime |
| 2 | +from typing import Any, Dict, List, Literal, Optional |
| 3 | + |
| 4 | +from pydantic import BaseModel, Field |
| 5 | + |
| 6 | +EVENT_CRUD_OPERATION = Literal["CREATED", "UPDATED", "DELETED"] |
| 7 | +EVENT_ADD_REMOVE_OPERATION = Literal["ADDED", "REMOVED"] |
| 8 | + |
| 9 | + |
| 10 | +class IoTCoreRegistryEventsBase(BaseModel): |
| 11 | + event_id: str = Field(..., alias="eventId") |
| 12 | + timestamp: datetime |
| 13 | + |
| 14 | + |
| 15 | +class IoTCoreThingEvent(IoTCoreRegistryEventsBase): |
| 16 | + """ |
| 17 | + Thing Created/Updated/Deleted |
| 18 | +
|
| 19 | + The registry publishes event messages when things are created, updated, or deleted. |
| 20 | + """ |
| 21 | + |
| 22 | + event_type: Literal["THING_EVENT"] = Field(..., alias="eventType") |
| 23 | + operation: EVENT_CRUD_OPERATION |
| 24 | + thing_id: str = Field(..., alias="thingId") |
| 25 | + account_id: str = Field(..., alias="accountId") |
| 26 | + thing_name: str = Field(..., alias="thingName") |
| 27 | + version_number: int = Field(..., alias="versionNumber") |
| 28 | + thing_type_name: Optional[str] = Field(None, alias="thingTypeName") |
| 29 | + attributes: Dict[str, Any] |
| 30 | + |
| 31 | + |
| 32 | +class IoTCoreThingTypeEvent(IoTCoreRegistryEventsBase): |
| 33 | + """ |
| 34 | + Thing Type Created/Updated/Deprecated/Undeprecated/Deleted |
| 35 | + The registry publishes event messages when thing types are created, updated, deprecated, undeprecated, or deleted. |
| 36 | +
|
| 37 | + Format: |
| 38 | + $aws/events/thingType/thingTypeName/created |
| 39 | + $aws/events/thingType/thingTypeName/updated |
| 40 | + $aws/events/thingType/thingTypeName/deleted |
| 41 | + """ |
| 42 | + |
| 43 | + event_type: Literal["THING_TYPE_EVENT"] = Field(..., alias="eventType") |
| 44 | + operation: EVENT_CRUD_OPERATION |
| 45 | + account_id: str = Field(..., alias="accountId") |
| 46 | + thing_type_id: str = Field(..., alias="thingTypeId") |
| 47 | + thing_type_name: str = Field(..., alias="thingTypeName") |
| 48 | + is_deprecated: bool = Field(..., alias="isDeprecated") |
| 49 | + deprecation_date: Optional[datetime] = Field(None, alias="deprecationDate") |
| 50 | + searchable_attributes: List[str] = Field(..., alias="searchableAttributes") |
| 51 | + propagating_attributes: List[Dict[str, str]] = Field(..., alias="propagatingAttributes") |
| 52 | + description: str |
| 53 | + |
| 54 | + |
| 55 | +class IoTCoreThingTypeAssociationEvent(IoTCoreRegistryEventsBase): |
| 56 | + """ |
| 57 | + The registry publishes event messages when a thing type is associated or disassociated with a thing. |
| 58 | +
|
| 59 | + Format: |
| 60 | + $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/added |
| 61 | + $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/removed |
| 62 | + """ |
| 63 | + |
| 64 | + event_type: Literal["THING_TYPE_ASSOCIATION_EVENT"] = Field(..., alias="eventType") |
| 65 | + operation: EVENT_ADD_REMOVE_OPERATION |
| 66 | + thing_id: str = Field(..., alias="thingId") |
| 67 | + thing_name: str = Field(..., alias="thingName") |
| 68 | + thing_type_name: str = Field(..., alias="thingTypeName") |
| 69 | + |
| 70 | + |
| 71 | +class IoTCoreThingGroupEvent(IoTCoreRegistryEventsBase): |
| 72 | + """ |
| 73 | + The registry publishes the following event messages when a thing group is created, updated, or deleted. |
| 74 | +
|
| 75 | + Format: |
| 76 | + $aws/events/thingGroup/groupName/created |
| 77 | + $aws/events/thingGroup/groupName/updated |
| 78 | + $aws/events/thingGroup/groupName/deleted |
| 79 | + """ |
| 80 | + |
| 81 | + event_type: Literal["THING_GROUP_EVENT"] = Field(..., alias="eventType") |
| 82 | + operation: EVENT_CRUD_OPERATION |
| 83 | + account_id: str = Field(..., alias="accountId") |
| 84 | + thing_group_id: str = Field(..., alias="thingGroupId") |
| 85 | + thing_group_name: str = Field(..., alias="thingGroupName") |
| 86 | + version_number: int = Field(..., alias="versionNumber") |
| 87 | + parent_group_name: Optional[str] = Field(None, alias="parentGroupName") |
| 88 | + parent_group_id: Optional[str] = Field(None, alias="parentGroupId") |
| 89 | + description: str |
| 90 | + root_to_parent_thing_groups: List[Dict[str, str]] = Field(..., alias="rootToParentThingGroups") |
| 91 | + attributes: Dict[str, Any] |
| 92 | + dynamic_group_mapping_id: Optional[str] = Field(None, alias="dynamicGroupMappingId") |
| 93 | + |
| 94 | + |
| 95 | +class IoTCoreAddOrRemoveFromThingGroupEvent(IoTCoreRegistryEventsBase): |
| 96 | + """ |
| 97 | + The registry publishes event messages when a thing is added to or removed from a thing group. |
| 98 | +
|
| 99 | + Format: |
| 100 | + $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/added |
| 101 | + $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/removed |
| 102 | + """ |
| 103 | + |
| 104 | + event_type: Literal["THING_GROUP_MEMBERSHIP_EVENT"] = Field(..., alias="eventType") |
| 105 | + operation: EVENT_ADD_REMOVE_OPERATION |
| 106 | + account_id: str = Field(..., alias="accountId") |
| 107 | + group_arn: str = Field(..., alias="groupArn") |
| 108 | + group_id: str = Field(..., alias="groupId") |
| 109 | + thing_arn: str = Field(..., alias="thingArn") |
| 110 | + thing_id: str = Field(..., alias="thingId") |
| 111 | + membership_id: str = Field(..., alias="membershipId") |
| 112 | + |
| 113 | + |
| 114 | +class IoTCoreAddOrDeleteFromThingGroupEvent(IoTCoreRegistryEventsBase): |
| 115 | + """ |
| 116 | + The registry publishes event messages when a thing group is added to or removed from another thing group. |
| 117 | +
|
| 118 | + Format: |
| 119 | + $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/added |
| 120 | + $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/removed |
| 121 | + """ |
| 122 | + |
| 123 | + event_type: Literal["THING_GROUP_HIERARCHY_EVENT"] = Field(..., alias="eventType") |
| 124 | + operation: EVENT_ADD_REMOVE_OPERATION |
| 125 | + account_id: str = Field(..., alias="accountId") |
| 126 | + thing_group_id: str = Field(..., alias="thingGroupId") |
| 127 | + thing_group_name: str = Field(..., alias="thingGroupName") |
| 128 | + child_group_id: str = Field(..., alias="childGroupId") |
| 129 | + child_group_name: str = Field(..., alias="childGroupName") |
0 commit comments