| | 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.Text; |
| | 7 | | using System.Threading.Tasks; |
| | 8 | | using Azure.Core; |
| | 9 | | using Azure.Storage.Blobs; |
| | 10 | |
|
| | 11 | | namespace Azure.Storage.Blobs.ChangeFeed |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// BlobChangeFeedClient. |
| | 15 | | /// |
| | 16 | | /// For more information, see |
| | 17 | | /// <see href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal"> |
| | 18 | | /// Change Feed</see>. |
| | 19 | | /// </summary> |
| | 20 | | public class BlobChangeFeedClient |
| | 21 | | { |
| | 22 | | private BlobServiceClient _blobServiceClient; |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Constructor. |
| | 26 | | /// </summary> |
| 0 | 27 | | protected BlobChangeFeedClient() { } |
| | 28 | |
|
| 32 | 29 | | internal BlobChangeFeedClient(BlobServiceClient blobServiceClient) |
| | 30 | | { |
| 32 | 31 | | _blobServiceClient = blobServiceClient; |
| 32 | 32 | | } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Initializes a new instance of the <see cref="BlobChangeFeedClient"/> |
| | 36 | | /// class. |
| | 37 | | /// </summary> |
| | 38 | | /// <param name="connectionString"> |
| | 39 | | /// A connection string includes the authentication information |
| | 40 | | /// required for your application to access data in an Azure Storage |
| | 41 | | /// account at runtime. |
| | 42 | | /// |
| | 43 | | /// For more information, see |
| | 44 | | /// <see href="https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string"> |
| | 45 | | /// Configuring Azure Storage conneciton strings</see>. |
| | 46 | | /// </param> |
| 0 | 47 | | public BlobChangeFeedClient(string connectionString) |
| | 48 | | { |
| 0 | 49 | | _blobServiceClient = new BlobServiceClient(connectionString); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | /// <summary> |
| | 53 | | /// Initializes a new instance of the <see cref="BlobChangeFeedClient"/> |
| | 54 | | /// class. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name="connectionString"> |
| | 57 | | /// A connection string includes the authentication information |
| | 58 | | /// required for your application to access data in an Azure Storage |
| | 59 | | /// account at runtime. |
| | 60 | | /// |
| | 61 | | /// For more information, see |
| | 62 | | /// <see href="https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string"> |
| | 63 | | /// Configuring Azure Storage conneciton strings</see>. |
| | 64 | | /// </param> |
| | 65 | | /// <param name="options"> |
| | 66 | | /// Optional client options that define the transport pipeline |
| | 67 | | /// policies for authentication, retries, etc., that are applied to |
| | 68 | | /// every request. |
| | 69 | | /// </param> |
| 0 | 70 | | public BlobChangeFeedClient(string connectionString, BlobClientOptions options) |
| | 71 | | { |
| 0 | 72 | | _blobServiceClient = new BlobServiceClient(connectionString, options); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | /// <summary> |
| | 76 | | /// Initializes a new instance of the <see cref="BlobChangeFeedClient"/> |
| | 77 | | /// class. |
| | 78 | | /// </summary> |
| | 79 | | /// <param name="serviceUri"> |
| | 80 | | /// A <see cref="Uri"/> referencing the blob service. |
| | 81 | | /// This is likely to be similar to "https://{account_name}.blob.core.windows.net". |
| | 82 | | /// </param> |
| | 83 | | /// <param name="options"> |
| | 84 | | /// Optional client options that define the transport pipeline |
| | 85 | | /// policies for authentication, retries, etc., that are applied to |
| | 86 | | /// every request. |
| | 87 | | /// </param> |
| 0 | 88 | | public BlobChangeFeedClient(Uri serviceUri, BlobClientOptions options = default) |
| | 89 | | { |
| 0 | 90 | | _blobServiceClient = new BlobServiceClient(serviceUri, options); |
| 0 | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// Initializes a new instance of the <see cref="BlobChangeFeedClient"/> |
| | 95 | | /// class. |
| | 96 | | /// </summary> |
| | 97 | | /// <param name="serviceUri"> |
| | 98 | | /// A <see cref="Uri"/> referencing the blob service. |
| | 99 | | /// This is likely to be similar to "https://{account_name}.blob.core.windows.net". |
| | 100 | | /// </param> |
| | 101 | | /// <param name="credential"> |
| | 102 | | /// The shared key credential used to sign requests. |
| | 103 | | /// </param> |
| | 104 | | /// <param name="options"> |
| | 105 | | /// Optional client options that define the transport pipeline |
| | 106 | | /// policies for authentication, retries, etc., that are applied to |
| | 107 | | /// every request. |
| | 108 | | /// </param> |
| 0 | 109 | | public BlobChangeFeedClient(Uri serviceUri, StorageSharedKeyCredential credential, BlobClientOptions options = d |
| | 110 | | { |
| 0 | 111 | | _blobServiceClient = new BlobServiceClient(serviceUri, credential, options); |
| 0 | 112 | | } |
| | 113 | |
|
| | 114 | | /// <summary> |
| | 115 | | /// Initializes a new instance of the <see cref="BlobChangeFeedClient"/> |
| | 116 | | /// class. |
| | 117 | | /// </summary> |
| | 118 | | /// <param name="serviceUri"> |
| | 119 | | /// A <see cref="Uri"/> referencing the blob service. |
| | 120 | | /// This is likely to be similar to "https://{account_name}.blob.core.windows.net". |
| | 121 | | /// </param> |
| | 122 | | /// <param name="credential"> |
| | 123 | | /// The token credential used to sign requests. |
| | 124 | | /// </param> |
| | 125 | | /// <param name="options"> |
| | 126 | | /// Optional client options that define the transport pipeline |
| | 127 | | /// policies for authentication, retries, etc., that are applied to |
| | 128 | | /// every request. |
| | 129 | | /// </param> |
| 0 | 130 | | public BlobChangeFeedClient(Uri serviceUri, TokenCredential credential, BlobClientOptions options = default) |
| | 131 | | { |
| 0 | 132 | | _blobServiceClient = new BlobServiceClient(serviceUri, credential, options); |
| 0 | 133 | | } |
| | 134 | |
|
| | 135 | | /// <summary> |
| | 136 | | /// GetChanges. |
| | 137 | | /// </summary> |
| | 138 | | /// <returns><see cref="BlobChangeFeedPageable"/>.</returns> |
| | 139 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 140 | | public virtual Pageable<BlobChangeFeedEvent> GetChanges() |
| | 141 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 142 | | { |
| 0 | 143 | | BlobChangeFeedPageable pageable = new BlobChangeFeedPageable( |
| 0 | 144 | | _blobServiceClient); |
| 0 | 145 | | return pageable; |
| | 146 | | } |
| | 147 | |
|
| | 148 | | /// <summary> |
| | 149 | | /// GetChanges. |
| | 150 | | /// </summary> |
| | 151 | | /// <param name="continuationToken"></param> |
| | 152 | | /// <returns><see cref="BlobChangeFeedPageable"/>.</returns> |
| | 153 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 154 | | public virtual Pageable<BlobChangeFeedEvent> GetChanges(string continuationToken) |
| | 155 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 156 | | { |
| 0 | 157 | | BlobChangeFeedPageable pageable = new BlobChangeFeedPageable( |
| 0 | 158 | | _blobServiceClient, |
| 0 | 159 | | continuationToken); |
| 0 | 160 | | return pageable; |
| | 161 | | } |
| | 162 | |
|
| | 163 | | /// <summary> |
| | 164 | | /// GetChanges. |
| | 165 | | /// </summary> |
| | 166 | | /// <param name="start"></param> |
| | 167 | | /// <param name="end"></param> |
| | 168 | | /// <returns><see cref="BlobChangeFeedPageable"/>.</returns> |
| | 169 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 170 | | public virtual Pageable<BlobChangeFeedEvent> GetChanges(DateTimeOffset? start = default, DateTimeOffset? end = d |
| | 171 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 172 | | { |
| 0 | 173 | | BlobChangeFeedPageable pageable = new BlobChangeFeedPageable( |
| 0 | 174 | | _blobServiceClient, |
| 0 | 175 | | start, |
| 0 | 176 | | end); |
| 0 | 177 | | return pageable; |
| | 178 | | } |
| | 179 | |
|
| | 180 | | /// <summary> |
| | 181 | | /// GetChangesAsync. |
| | 182 | | /// </summary> |
| | 183 | | /// <returns><see cref="BlobChangeFeedAsyncPageable"/>.</returns> |
| | 184 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 185 | | public virtual AsyncPageable<BlobChangeFeedEvent> GetChangesAsync() |
| | 186 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 187 | | { |
| 0 | 188 | | BlobChangeFeedAsyncPageable asyncPagable = new BlobChangeFeedAsyncPageable(_blobServiceClient); |
| 0 | 189 | | return asyncPagable; |
| | 190 | | } |
| | 191 | |
|
| | 192 | | /// <summary> |
| | 193 | | /// GetChangesAsync. |
| | 194 | | /// </summary> |
| | 195 | | /// <param name="continuationToken"></param> |
| | 196 | | /// <returns><see cref="BlobChangeFeedAsyncPageable"/>.</returns> |
| | 197 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 198 | | public virtual AsyncPageable<BlobChangeFeedEvent> GetChangesAsync(string continuationToken) |
| | 199 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 200 | | { |
| 32 | 201 | | BlobChangeFeedAsyncPageable asyncPagable = new BlobChangeFeedAsyncPageable(_blobServiceClient, |
| 32 | 202 | | continuationToken); |
| 32 | 203 | | return asyncPagable; |
| | 204 | | } |
| | 205 | |
|
| | 206 | | /// <summary> |
| | 207 | | /// GetChangesAsync. |
| | 208 | | /// </summary> |
| | 209 | | /// <param name="start"></param> |
| | 210 | | /// <param name="end"></param> |
| | 211 | | /// <returns><see cref="BlobChangeFeedAsyncPageable"/>.</returns> |
| | 212 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 213 | | public virtual AsyncPageable<BlobChangeFeedEvent> GetChangesAsync( |
| | 214 | | DateTimeOffset? start = default, |
| | 215 | | DateTimeOffset? end = default) |
| | 216 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | 217 | | { |
| 44 | 218 | | BlobChangeFeedAsyncPageable asyncPagable = new BlobChangeFeedAsyncPageable( |
| 44 | 219 | | _blobServiceClient, |
| 44 | 220 | | start, |
| 44 | 221 | | end); |
| 44 | 222 | | return asyncPagable; |
| | 223 | | } |
| | 224 | | } |
| | 225 | | } |