Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
{
"swagger": "2.0",
"info": {
"version": "2018-01-01",
"title": "Schema of Azure IoT Hub events published to Azure Event Grid",
"description":
"Describes the schema of the Azure IoT Hub events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
},
"paths": {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand correctly, you are simply defining models but not any paths from the service. What is the intention here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to document the schemas of the various events published to EventGrid. A consumer who is consuming events from EventGrid (e.g. in an Azure function or in any webhook) can use the generated classes to deserialize the event appropriately. This is the same pattern used for other existing event schemas as well (e.g. the storage events in the eventgrid data plane directory).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

"definitions": {
"IotHubDeviceCreatedEventData": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are sharing a bunch of properties with IotHubDeviceDeletedEventData, can you consolidate the common properties into a common definition here

"type": "object",
"description": "Schema of the Data property of an EventGridEvent for an Microsoft.Devices.DeviceCreated event.",
"properties": {
"deviceId": {
"type": "string",
"description":
"The unique identifier of the device. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - : . + % _ # * ? ! ( ) , = @ ; $ '."
},
"hubName": {
"type": "string",
"description": "Name of the IoT Hub where the device was created or deleted."
},
"opType": {
"type": "string",
"description": "The event type specified for this operation by the IoT Hub."
},
"operationTimestamp": {
"type": "string",
"description": "The ISO8601 timestamp of the operation."
},
"twin": {
"type": "object",
"description":
"Information about the device twin, which is the cloud represenation of application device metadata.",
"properties": {
"authenticationType": {
"type": "string",
"description":
"Authentication type used for this device: either SAS, SelfSigned, or CertificateAuthority."
},
"cloudToDeviceMessageCount": {
"type": "number",
"description": "Count of cloud to device messages sent to this device."
},
"connectionState": {
"type": "string",
"description": "Whether the device is connected or disconnected."
},
"deviceId": {
"type": "string",
"description": "The unique identifier of the device twin."
},
"etag": {
"type": "string",
"description":
"A piece of information that describes the content of the device twin. Each etag is guaranteed to be unique per device twin."
},
"lastActivityTime": {
"type": "string",
"description": "The ISO8601 timestamp of the last activity."
},
"properties": {
"type": "object",
"description": "Properties JSON element.",
"properties": {
"desired": {
"type": "object",
"description":
"A portion of the properties that can be written only by the application back-end, and read by the device.",
"properties": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A. We discourage use of inline definitions for complex object properties.
B. Is this odata by any chance or does your model actually have properties with special characters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you are repeating this definition again in report, better pull it out into a different definition altogether and reference it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the model has properties with "$" to signify that they are system properties.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are not odata properties, we strongly recommend using x-ms-client-name (here)
You can name the property without special characters and specify its exact name with the special character as the x-ms-client-name value

"$metadata": {
"type": "object",
"description": "Metadata information for the properties JSON document.",
"properties": {
"$lastUpdated": {
"type": "string",
"description": "The ISO8601 timestamp of the last time the properties were updated."
}
}
},
"$version": {
"type": "number",
"description": "Version of device twin properties."
}
}
},
"reported": {
"type": "object",
"description":
"A portion of the properties that can be written only by the device, and read by the application back-end.",
"properties": {
"$metadata": {
"type": "object",
"description": "Metadata information for the properties JSON document.",
"properties": {
"$lastUpdated": {
"type": "string",
"description": "The ISO8601 timestamp of the last time the properties were updated."
}
}
},
"$version": {
"type": "number",
"description": "Version of device twin properties."
}
}
}
}
},
"status": {
"type": "string",
"description": "Whether the device twin is enabled or disabled."
},
"statusUpdateTime": {
"type": "string",
"description": "The ISO8601 timestamp of the last device twin status update."
},
"version": {
"type": "number",
"description": "An integer that is incremented by one each time the device twin is updated."
},
"x509Thumbprint": {
"type": "object",
"description":
"The thumbprint is a unique value for the x509 certificate, commonly used to find a particular certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 algorithm, and does not physically exist in the certificate.",
"properties": {
"primaryThumbprint": {
"type": "string",
"description": "Primary thumbprint for the x509 certificate."
},
"secondaryThumbprint": {
"type": "string",
"description": "Secondary thumbprint for the x509 certificate."
}
}
}
}
}
}
},
"IotHubDeviceDeletedEventData": {
"type": "object",
"description": "Schema of the Data property of an EventGridEvent for an Microsoft.Devices.DeviceDeleted event.",
"properties": {
"deviceId": {
"type": "string",
"description":
"The unique identifier of the device. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: - : . + % _ # * ? ! ( ) , = @ ; $ '."
},
"hubName": {
"type": "string",
"description": "Name of the IoT Hub where the device was created or deleted."
},
"opType": {
"type": "string",
"description": "The event type specified for this operation by the IoT Hub."
},
"operationTimestamp": {
"type": "string",
"description": "The ISO8601 timestamp of the operation."
},
"twin": {
"type": "object",
"description":
"Information about the device twin, which is the cloud represenation of application device metadata.",
"properties": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, please do not define inline properties like so, create a new definition

"authenticationType": {
"type": "string",
"description":
"Authentication type used for this device: either SAS, SelfSigned, or CertificateAuthority."
},
"cloudToDeviceMessageCount": {
"type": "number",
"description": "Count of cloud to device messages sent to this device."
},
"connectionState": {
"type": "string",
"description": "Whether the device is connected or disconnected."
},
"deviceId": {
"type": "string",
"description": "The unique identifier of the device twin."
},
"etag": {
"type": "string",
"description":
"A piece of information that describes the content of the device twin. Each etag is guaranteed to be unique per device twin."
},
"lastActivityTime": {
"type": "string",
"description": "The ISO8601 timestamp of the last activity."
},
"properties": {
"type": "object",
"description": "Properties JSON element.",
"properties": {
"desired": {
"type": "object",
"description":
"A portion of the properties that can be written only by the application back-end, and read by the device.",
"properties": {
"$metadata": {
"type": "object",
"description": "Metadata information for the properties JSON document.",
"properties": {
"$lastUpdated": {
"type": "string",
"description": "The ISO8601 timestamp of the last time the properties were updated."
}
}
},
"$version": {
"type": "number",
"description": "Version of device twin properties."
}
}
},
"reported": {
"type": "object",
"description":
"A portion of the properties that can be written only by the device, and read by the application back-end.",
"properties": {
"$metadata": {
"type": "object",
"description": "Metadata information for the properties JSON document.",
"properties": {
"$lastUpdated": {
"type": "string",
"description": "The ISO8601 timestamp of the last time the properties were updated."
}
}
},
"$version": {
"type": "number",
"description": "Version of device twin properties."
}
}
}
}
},
"status": {
"type": "string",
"description": "Whether the device twin is enabled or disabled."
},
"statusUpdateTime": {
"type": "string",
"description": "The ISO8601 timestamp of the last device twin status update."
},
"version": {
"type": "number",
"description": "An integer that is incremented by one each time the device twin is updated."
},
"x509Thumbprint": {
"type": "object",
"description":
"The thumbprint is a unique value for the x509 certificate, commonly used to find a particular certificate in a certificate store. The thumbprint is dynamically generated using the SHA1 algorithm, and does not physically exist in the certificate.",
"properties": {
"primaryThumbprint": {
"type": "string",
"description": "Primary thumbprint for the x509 certificate."
},
"secondaryThumbprint": {
"type": "string",
"description": "Secondary thumbprint for the x509 certificate."
}
}
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions specification/eventgrid/data-plane/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ input-file:
- Microsoft.EventHub/stable/2018-01-01/EventHub.json
- Microsoft.Resources/stable/2018-01-01/Resources.json
- Microsoft.EventGrid/stable/2018-01-01/EventGrid.json
- Microsoft.Devices/stable/2018-01-01/IotHub.json
```

---
Expand Down