| | 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 Azure.Storage.Blobs.Models; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Blobs.ChangeFeed |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// BlobChangeFeedEventData. |
| | 12 | | /// </summary> |
| | 13 | | public class BlobChangeFeedEventData |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Internal constructor. |
| | 17 | | /// </summary> |
| 0 | 18 | | internal BlobChangeFeedEventData() { } |
| | 19 | |
|
| 29584 | 20 | | internal BlobChangeFeedEventData(Dictionary<string, object> record) |
| | 21 | | { |
| 29584 | 22 | | BlobOperationName = new BlobOperationName((string)record[Constants.ChangeFeed.EventData.Api]); |
| 29584 | 23 | | ClientRequestId = Guid.Parse((string)record[Constants.ChangeFeed.EventData.ClientRequestId]); |
| 29584 | 24 | | RequestId = Guid.Parse((string)record[Constants.ChangeFeed.EventData.RequestId]); |
| 29584 | 25 | | ETag = new ETag((string)record[Constants.ChangeFeed.EventData.Etag]); |
| 29584 | 26 | | ContentType = (string)record[Constants.ChangeFeed.EventData.ContentType]; |
| 29584 | 27 | | ContentLength = (long)record[Constants.ChangeFeed.EventData.ContentLength]; |
| 29584 | 28 | | BlobType = ((string)record[Constants.ChangeFeed.EventData.BlobType]) switch |
| 29584 | 29 | | { |
| 59168 | 30 | | Constants.ChangeFeed.EventData.BlockBlob => BlobType.Block, |
| 0 | 31 | | Constants.ChangeFeed.EventData.PageBlob => BlobType.Page, |
| 0 | 32 | | Constants.ChangeFeed.EventData.AppendBlob => BlobType.Append, |
| 0 | 33 | | _ => default |
| 29584 | 34 | | }; |
| 29584 | 35 | | record.TryGetValue(Constants.ChangeFeed.EventData.ContentOffset, out object contentOffset); |
| 29584 | 36 | | ContentOffset = (long?)contentOffset; |
| 29584 | 37 | | record.TryGetValue(Constants.ChangeFeed.EventData.DestinationUrl, out object destinationUrl); |
| 29584 | 38 | | DestinationUri = !string.IsNullOrEmpty((string)destinationUrl) ? new Uri((string)destinationUrl) : null; |
| 29584 | 39 | | record.TryGetValue(Constants.ChangeFeed.EventData.SourceUrl, out object sourceUrl); |
| 29584 | 40 | | SourceUri = !string.IsNullOrEmpty((string)sourceUrl) ? new Uri((string)sourceUrl) : null; |
| 29584 | 41 | | record.TryGetValue(Constants.ChangeFeed.EventData.Url, out object url); |
| 29584 | 42 | | Uri = !string.IsNullOrEmpty((string)url) ? new Uri((string)url) : null; |
| 29584 | 43 | | record.TryGetValue(Constants.ChangeFeed.EventData.Recursive, out object recursive); |
| 29584 | 44 | | Recursive = (bool?)recursive; |
| 29584 | 45 | | Sequencer = (string)record[Constants.ChangeFeed.EventData.Sequencer]; |
| 29584 | 46 | | } |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// The operation that triggered the event. |
| | 50 | | /// </summary> |
| 29588 | 51 | | public BlobOperationName BlobOperationName { get; internal set; } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// A client-provided request id for the storage API operation. This id can be used to correlate to Azure Storag |
| | 55 | | /// diagnostic logs using the "client-request-id" field in the logs, and can be provided in client requests usin |
| | 56 | | /// the "x-ms-client-request-id" header. |
| | 57 | | /// </summary> |
| 29588 | 58 | | public Guid ClientRequestId { get; internal set; } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Service-generated request id for the storage API operation. Can be used to correlate to Azure Storage diagno |
| | 62 | | /// logs using the "request-id-header" field in the logs and is returned from initiating API call in the |
| | 63 | | /// 'x-ms-request-id' header. |
| | 64 | | /// </summary> |
| 29588 | 65 | | public Guid RequestId { get; internal set; } |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// The value that you can use to perform operations conditionally. |
| | 69 | | /// </summary> |
| 29588 | 70 | | public ETag ETag { get; internal set; } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// The content type specified for the blob. |
| | 74 | | /// </summary> |
| 29588 | 75 | | public string ContentType { get; internal set; } |
| | 76 | |
|
| | 77 | | /// <summary> |
| | 78 | | /// The size of the blob in bytes. |
| | 79 | | /// </summary> |
| 29588 | 80 | | public long ContentLength { get; internal set; } |
| | 81 | |
|
| | 82 | | /// <summary> |
| | 83 | | /// The type of blob. Valid values are either BlockBlob or PageBlob. |
| | 84 | | /// </summary> |
| 29588 | 85 | | public BlobType BlobType { get; internal set; } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// The offset in bytes of a write operation taken at the point where the event-triggering application completed |
| | 89 | | /// writing to the file. |
| | 90 | | /// Appears only for events triggered on blob storage accounts that have a hierarchical namespace. |
| | 91 | | /// </summary> |
| 29588 | 92 | | public long? ContentOffset { get; internal set; } |
| | 93 | |
|
| | 94 | | /// <summary> |
| | 95 | | /// The url of the file that will exist after the operation completes. For example, if a file is renamed, |
| | 96 | | /// the destinationUrl property contains the url of the new file name. |
| | 97 | | /// Appears only for events triggered on blob storage accounts that have a hierarchical namespace. |
| | 98 | | /// </summary> |
| 29588 | 99 | | public Uri DestinationUri { get; internal set; } |
| | 100 | |
|
| | 101 | | /// <summary> |
| | 102 | | /// The url of the file that exists prior to the operation. For example, if a file is renamed, the sourceUrl |
| | 103 | | /// contains the url of the original file name prior to the rename operation. |
| | 104 | | /// Appears only for events triggered on blob storage accounts that have a hierarchical namespace. |
| | 105 | | /// </summary> |
| 29588 | 106 | | public Uri SourceUri { get; internal set; } |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// The path to the blob. |
| | 110 | | /// If the client uses a Blob REST API, then the url has this structure: |
| | 111 | | /// (storage-account-name).blob.core.windows.net/(container-name)/(file-name) |
| | 112 | | /// If the client uses a Data Lake Storage REST API, then the url has this structure: |
| | 113 | | /// (storage-account-name).dfs.core.windows.net/(file-system-name)/(file-name). |
| | 114 | | /// </summary> |
| 29588 | 115 | | public Uri Uri { get; internal set; } |
| | 116 | |
|
| | 117 | | /// <summary> |
| | 118 | | /// True to perform the operation on all child directories; otherwise False. |
| | 119 | | /// Appears only for events triggered on blob storage accounts that have a hierarchical namespace. |
| | 120 | | /// </summary> |
| 29588 | 121 | | public bool? Recursive { get; internal set; } |
| | 122 | |
|
| | 123 | | /// <summary> |
| | 124 | | /// An opaque string value representing the logical sequence of events for any particular blob name. |
| | 125 | | /// Users can use standard string comparison to understand the relative sequence of two events on the same blob |
| | 126 | | /// </summary> |
| 29588 | 127 | | public string Sequencer { get; internal set; } |
| | 128 | | } |
| | 129 | | } |