| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.EventGrid |
| | 8 | | { |
| | 9 | | /// <summary> Properties of an event published to an Event Grid topic using the EventGrid Schema. </summary> |
| | 10 | | public class EventGridEvent |
| | 11 | | { |
| | 12 | | /// <summary> Initializes a new instance of EventGridEvent. </summary> |
| | 13 | | /// <param name="subject"> A resource path relative to the topic path. </param> |
| | 14 | | /// <param name="data"> Event data specific to the event type. </param> |
| | 15 | | /// <param name="eventType"> The type of the event that occurred. </param> |
| | 16 | | /// <param name="dataVersion"> The schema version of the data object. </param> |
| 332 | 17 | | public EventGridEvent(string subject, object data, string eventType, string dataVersion) |
| | 18 | | { |
| 332 | 19 | | Argument.AssertNotNull(subject, nameof(subject)); |
| 332 | 20 | | Argument.AssertNotNull(data, nameof(data)); |
| 332 | 21 | | Argument.AssertNotNull(eventType, nameof(eventType)); |
| 332 | 22 | | Argument.AssertNotNull(dataVersion, nameof(dataVersion)); |
| | 23 | |
|
| 332 | 24 | | Subject = subject; |
| 332 | 25 | | Data = data; |
| 332 | 26 | | EventType = eventType; |
| 332 | 27 | | DataVersion = dataVersion; |
| 332 | 28 | | } |
| | 29 | |
|
| | 30 | | /// <summary> An unique identifier for the event. </summary> |
| 824 | 31 | | public string Id { get; set; } = Guid.NewGuid().ToString(); |
| | 32 | |
|
| | 33 | | /// <summary> The resource path of the event source. </summary> |
| 200 | 34 | | public string Topic { get; set; } |
| | 35 | |
|
| | 36 | | /// <summary> A resource path relative to the topic path. </summary> |
| 492 | 37 | | public string Subject { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> Event data specific to the event type. </summary> |
| 992 | 40 | | public object Data { get; set; } |
| | 41 | |
|
| | 42 | | /// <summary> The type of the event that occurred. </summary> |
| 492 | 43 | | public string EventType { get; set; } |
| | 44 | |
|
| | 45 | | /// <summary> The time (in UTC) the event was generated. </summary> |
| 824 | 46 | | public DateTimeOffset EventTime { get; set; } = DateTimeOffset.UtcNow; |
| | 47 | |
|
| | 48 | | /// <summary> The schema version of the data object. </summary> |
| 492 | 49 | | public string DataVersion { get; set; } |
| | 50 | | } |
| | 51 | | } |