| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using Azure.Core; |
| | 8 | |
|
| | 9 | | namespace Azure.Messaging.EventGrid |
| | 10 | | { |
| | 11 | | /// <summary> Properties of an event published to an Event Grid topic using the CloudEvent 1.0 Schema. </summary> |
| | 12 | | public class CloudEvent |
| | 13 | | { |
| | 14 | | /// <summary> Initializes a new instance of CloudEvent. </summary> |
| | 15 | | /// <param name="source"> Identifies the context in which an event happened. The combination of id and source mu |
| | 16 | | /// <param name="type"> Type of event related to the originating occurrence. </param> |
| 234 | 17 | | public CloudEvent(string source, string type) |
| | 18 | | { |
| 234 | 19 | | Argument.AssertNotNull(source, nameof(source)); |
| 234 | 20 | | Argument.AssertNotNull(type, nameof(type)); |
| | 21 | |
|
| 234 | 22 | | Source = source; |
| 234 | 23 | | Type = type; |
| 234 | 24 | | ExtensionAttributes = new Dictionary<string, object>(); |
| 234 | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> An identifier for the event. The combination of id and source must be unique for each distinct eve |
| 688 | 28 | | public string Id { get; set; } = Guid.NewGuid().ToString(); |
| | 29 | |
|
| | 30 | | /// <summary> Identifies the context in which an event happened. The combination of id and source must be unique |
| 454 | 31 | | public string Source { get; set; } |
| | 32 | |
|
| | 33 | | /// <summary> Event data specific to the event type. </summary> |
| 994 | 34 | | public object Data { get; set; } |
| | 35 | |
|
| | 36 | | /// <summary> Type of event related to the originating occurrence. </summary> |
| 458 | 37 | | public string Type { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> The time (in UTC) the event was generated, in RFC3339 format. </summary> |
| 688 | 40 | | public DateTimeOffset? Time { get; set; } = DateTimeOffset.UtcNow; |
| | 41 | |
|
| | 42 | | /// <summary> Identifies the schema that data adheres to. </summary> |
| 234 | 43 | | public string DataSchema { get; set; } |
| | 44 | |
|
| | 45 | | /// <summary> Content type of data value. </summary> |
| 234 | 46 | | public string DataContentType { get; set; } |
| | 47 | |
|
| | 48 | | /// <summary> This describes the subject of the event in the context of the event producer (identified by source |
| 454 | 49 | | public string Subject { get; set; } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Extension attributes that can be additionally added to the CloudEvent envelope. |
| | 53 | | /// </summary> |
| 300 | 54 | | public Dictionary<string, object> ExtensionAttributes { get; } |
| | 55 | | } |
| | 56 | | } |