| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Globalization; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Blobs.ChangeFeed |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// BlobChangeFeedEvent. |
| | 12 | | /// </summary> |
| | 13 | | public class BlobChangeFeedEvent |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Internal constructor. |
| | 17 | | /// </summary> |
| 29584 | 18 | | internal BlobChangeFeedEvent(Dictionary<string, object> record) |
| | 19 | | { |
| 29584 | 20 | | Topic = (string)record[Constants.ChangeFeed.Event.Topic]; |
| 29584 | 21 | | Subject = (string)record[Constants.ChangeFeed.Event.Subject]; |
| 29584 | 22 | | EventType = new BlobChangeFeedEventType((string)record[Constants.ChangeFeed.Event.EventType]); |
| 29584 | 23 | | EventTime = DateTimeOffset.Parse((string)record[Constants.ChangeFeed.Event.EventTime], CultureInfo.Invariant |
| 29584 | 24 | | Id = Guid.Parse((string)record[Constants.ChangeFeed.Event.EventId]); |
| 29584 | 25 | | EventData = new BlobChangeFeedEventData((Dictionary<string, object>)record[Constants.ChangeFeed.Event.Data]) |
| 29584 | 26 | | record.TryGetValue(Constants.ChangeFeed.Event.SchemaVersion, out object schemaVersion); |
| 29584 | 27 | | SchemaVersion = (long)schemaVersion; |
| 29584 | 28 | | record.TryGetValue(Constants.ChangeFeed.Event.MetadataVersion, out object metadataVersion); |
| 29584 | 29 | | MetadataVersion = (string)metadataVersion; |
| 29584 | 30 | | } |
| | 31 | |
|
| 184 | 32 | | internal BlobChangeFeedEvent() { } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Full resource path to the event source. This field is not writeable. Event Grid provides this value. |
| | 36 | | /// </summary> |
| 29588 | 37 | | public string Topic { get; internal set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Publisher-defined path to the event subject. |
| | 41 | | /// </summary> |
| 30188 | 42 | | public string Subject { get; internal set; } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// One of the registered event types for this event source. |
| | 46 | | /// </summary> |
| 30188 | 47 | | public BlobChangeFeedEventType EventType { get; internal set; } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// The time the event is generated based on the provider's UTC time. |
| | 51 | | /// </summary> |
| 65004 | 52 | | public DateTimeOffset EventTime { get; internal set; } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Unique identifier for the event. |
| | 56 | | /// </summary> |
| 46544 | 57 | | public Guid Id { get; internal set; } |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Blob storage event data. |
| | 61 | | /// </summary> |
| 30236 | 62 | | public BlobChangeFeedEventData EventData { get; internal set; } |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// The schema version of the data object. The publisher defines the schema version. |
| | 66 | | /// </summary> |
| 29588 | 67 | | public long SchemaVersion { get; internal set; } |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// The schema version of the event metadata. Event Grid defines the schema of the top-level properties. |
| | 71 | | /// Event Grid provides this value. |
| | 72 | | /// </summary> |
| 29588 | 73 | | public string MetadataVersion { get; internal set; } |
| | 74 | |
|
| | 75 | | /// <inheritdoc/> |
| 600 | 76 | | public override string ToString() => $"{EventTime}: {EventType} {Subject} ({EventData?.ToString() ?? "Unknown Ev |
| | 77 | | } |
| | 78 | | } |