| | 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.Threading; |
| | 7 | | using System.Threading.Tasks; |
| | 8 | | using Azure.Core; |
| | 9 | | using Azure.Core.Pipeline; |
| | 10 | | using Azure.Data.Tables.Models; |
| | 11 | | using Azure.Data.Tables.Sas; |
| | 12 | |
|
| | 13 | | namespace Azure.Data.Tables |
| | 14 | | { |
| | 15 | | public class TableServiceClient |
| | 16 | | { |
| | 17 | | private readonly ClientDiagnostics _diagnostics; |
| | 18 | | private readonly TableRestClient _tableOperations; |
| | 19 | | private readonly ServiceRestClient _serviceOperations; |
| | 20 | | private readonly ServiceRestClient _secondaryServiceOperations; |
| 0 | 21 | | private readonly OdataMetadataFormat _format = OdataMetadataFormat.ApplicationJsonOdataFullmetadata; |
| | 22 | | private readonly string _version; |
| | 23 | | internal readonly bool _isPremiumEndpoint; |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Initializes a new instance of the <see cref="TableServiceClient"/>. |
| | 27 | | /// </summary> |
| | 28 | | /// <param name="endpoint"> |
| | 29 | | /// A <see cref="Uri"/> referencing the table service account. |
| | 30 | | /// This is likely to be similar to "https://{account_name}.table.core.windows.net/" or "https://{account_name}. |
| | 31 | | /// </param> |
| | 32 | | public TableServiceClient(Uri endpoint) |
| 44 | 33 | | : this(endpoint, options: null) |
| 40 | 34 | | { } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Initializes a new instance of the <see cref="TableServiceClient"/>. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="endpoint"> |
| | 40 | | /// A <see cref="Uri"/> referencing the table service account. |
| | 41 | | /// This is likely to be similar to "https://{account_name}.table.core.windows.net/" or "https://{account_name}. |
| | 42 | | /// </param> |
| | 43 | | /// <param name="options"> |
| | 44 | | /// Optional client options that define the transport pipeline policies for authentication, retries, etc., that |
| | 45 | | /// </param> |
| | 46 | | public TableServiceClient(Uri endpoint, TableClientOptions options = null) |
| 84 | 47 | | : this(endpoint, default(TableSharedKeyPipelinePolicy), options) |
| | 48 | | { |
| 84 | 49 | | if (endpoint.Scheme != "https") |
| | 50 | | { |
| 4 | 51 | | throw new ArgumentException("Cannot use TokenCredential without HTTPS.", nameof(endpoint)); |
| | 52 | | } |
| 80 | 53 | | } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Initializes a new instance of the <see cref="TableServiceClient"/>. |
| | 57 | | /// </summary> |
| | 58 | | /// <param name="endpoint"> |
| | 59 | | /// A <see cref="Uri"/> referencing the table service account. |
| | 60 | | /// This is likely to be similar to "https://{account_name}.table.core.windows.net/" or "https://{account_name}. |
| | 61 | | /// </param> |
| | 62 | | /// <param name="credential">The shared key credential used to sign requests.</param> |
| | 63 | | public TableServiceClient(Uri endpoint, TableSharedKeyCredential credential) |
| 16 | 64 | | : this(endpoint, new TableSharedKeyPipelinePolicy(credential), null) |
| | 65 | | { |
| 12 | 66 | | Argument.AssertNotNull(credential, nameof(credential)); |
| 8 | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// Initializes a new instance of the <see cref="TableServiceClient"/>. |
| | 71 | | /// </summary> |
| | 72 | | /// <param name="endpoint"> |
| | 73 | | /// A <see cref="Uri"/> referencing the table service account. |
| | 74 | | /// This is likely to be similar to "https://{account_name}.table.core.windows.net/" or "https://{account_name}. |
| | 75 | | /// </param> |
| | 76 | | /// <param name="credential">The shared key credential used to sign requests.</param> |
| | 77 | | /// <param name="options"> |
| | 78 | | /// Optional client options that define the transport pipeline policies for authentication, retries, etc., that |
| | 79 | | /// </param> |
| | 80 | | public TableServiceClient(Uri endpoint, TableSharedKeyCredential credential, TableClientOptions options = null) |
| 376 | 81 | | : this(endpoint, new TableSharedKeyPipelinePolicy(credential), options) |
| | 82 | | { |
| 376 | 83 | | Argument.AssertNotNull(credential, nameof(credential)); |
| 376 | 84 | | } |
| | 85 | |
|
| 476 | 86 | | internal TableServiceClient(Uri endpoint, TableSharedKeyPipelinePolicy policy, TableClientOptions options) |
| | 87 | | { |
| 476 | 88 | | Argument.AssertNotNull(endpoint, nameof(endpoint)); |
| | 89 | |
|
| 472 | 90 | | options ??= new TableClientOptions(); |
| 472 | 91 | | var endpointString = endpoint.ToString(); |
| 472 | 92 | | var secondaryEndpoint = endpointString.Insert(endpointString.IndexOf('.'), "-secondary"); |
| 472 | 93 | | HttpPipeline pipeline = HttpPipelineBuilder.Build(options, policy); |
| | 94 | |
|
| 472 | 95 | | _diagnostics = new ClientDiagnostics(options); |
| 472 | 96 | | _tableOperations = new TableRestClient(_diagnostics, pipeline, endpointString); |
| 472 | 97 | | _serviceOperations = new ServiceRestClient(_diagnostics, pipeline, endpointString); |
| 472 | 98 | | _secondaryServiceOperations = new ServiceRestClient(_diagnostics, pipeline, secondaryEndpoint); |
| 472 | 99 | | _version = options.VersionString; |
| 472 | 100 | | _isPremiumEndpoint = IsPremiumEndpoint(endpoint); |
| 472 | 101 | | } |
| | 102 | |
|
| | 103 | | /// <summary> |
| | 104 | | /// Initializes a new instance of the <see cref="TableServiceClient"/> |
| | 105 | | /// class for mocking. |
| | 106 | | /// </summary> |
| 0 | 107 | | internal TableServiceClient(TableRestClient internalClient) |
| | 108 | | { |
| 0 | 109 | | _tableOperations = internalClient; |
| 0 | 110 | | } |
| | 111 | |
|
| | 112 | | /// <summary> |
| | 113 | | /// Initializes a new instance of the <see cref="TableServiceClient"/> |
| | 114 | | /// class for mocking. |
| | 115 | | /// </summary> |
| 452 | 116 | | protected TableServiceClient() |
| 452 | 117 | | { } |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// Gets a <see cref="TableSasBuilder"/> instance scoped to the current account. |
| | 121 | | /// </summary> |
| | 122 | | /// <param name="permissions"><see cref="TableAccountSasPermissions"/> containing the allowed permissions.</para |
| | 123 | | /// <param name="resourceTypes"><see cref="TableAccountSasResourceTypes"/> containing the accessible resource ty |
| | 124 | | /// <param name="expiresOn">The time at which the shared access signature becomes invalid.</param> |
| | 125 | | /// <returns>An instance of <see cref="TableAccountSasBuilder"/>.</returns> |
| | 126 | | public virtual TableAccountSasBuilder GetSasBuilder(TableAccountSasPermissions permissions, TableAccountSasResou |
| | 127 | | { |
| 36 | 128 | | return new TableAccountSasBuilder(permissions, resourceTypes, expiresOn) { Version = _version }; |
| | 129 | | } |
| | 130 | |
|
| | 131 | | /// <summary> |
| | 132 | | /// Gets a <see cref="TableAccountSasBuilder"/> instance scoped to the current table. |
| | 133 | | /// </summary> |
| | 134 | | /// <param name="rawPermissions">The permissions associated with the shared access signature. This string should |
| | 135 | | /// <param name="resourceTypes"><see cref="TableAccountSasResourceTypes"/> containing the accessible resource ty |
| | 136 | | /// <param name="expiresOn">The time at which the shared access signature becomes invalid.</param> |
| | 137 | | /// <returns>An instance of <see cref="TableAccountSasBuilder"/>.</returns> |
| | 138 | | public virtual TableAccountSasBuilder GetSasBuilder(string rawPermissions, TableAccountSasResourceTypes resource |
| | 139 | | { |
| 4 | 140 | | return new TableAccountSasBuilder(rawPermissions, resourceTypes, expiresOn) { Version = _version }; |
| | 141 | | } |
| | 142 | |
|
| | 143 | | public virtual TableClient GetTableClient(string tableName) |
| | 144 | | { |
| 412 | 145 | | Argument.AssertNotNull(tableName, nameof(tableName)); |
| | 146 | |
|
| 408 | 147 | | return new TableClient(tableName, _tableOperations, _version, _diagnostics, _isPremiumEndpoint); |
| | 148 | | } |
| | 149 | |
|
| | 150 | | /// <summary> |
| | 151 | | /// Gets a list of tables from the storage account. |
| | 152 | | /// </summary> |
| | 153 | | /// <param name="filter">Returns only tables that satisfy the specified filter.</param> |
| | 154 | | /// <param name="maxPerPage">The maximum number of tables that will be returned per page.</param> |
| | 155 | | /// <param name="select">Returns the desired properties of an entity from the set. </param> |
| | 156 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 157 | | /// <returns></returns> |
| | 158 | | public virtual AsyncPageable<TableItem> GetTablesAsync(string filter = null, int? maxPerPage = null, string sele |
| | 159 | | { |
| 20 | 160 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); |
| 20 | 161 | | scope.Start(); |
| | 162 | | try |
| | 163 | | { |
| 20 | 164 | | return PageableHelpers.CreateAsyncEnumerable(async _ => |
| 20 | 165 | | { |
| 40 | 166 | | var response = await _tableOperations.QueryAsync( |
| 40 | 167 | | null, |
| 40 | 168 | | null, |
| 40 | 169 | | new QueryOptions() { Filter = filter, Select = select, Top = maxPerPage, Format = _format }, |
| 40 | 170 | | cancellationToken).ConfigureAwait(false); |
| 40 | 171 | | return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.Get |
| 40 | 172 | | }, async (nextLink, _) => |
| 20 | 173 | | { |
| 28 | 174 | | var response = await _tableOperations.QueryAsync( |
| 28 | 175 | | null, |
| 28 | 176 | | nextTableName: nextLink, |
| 28 | 177 | | new QueryOptions() { Filter = filter, Select = select, Top = maxPerPage, Format = _format }, |
| 28 | 178 | | cancellationToken).ConfigureAwait(false); |
| 28 | 179 | | return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.Get |
| 28 | 180 | | }); |
| | 181 | | } |
| 0 | 182 | | catch (Exception ex) |
| | 183 | | { |
| 0 | 184 | | scope.Failed(ex); |
| 0 | 185 | | throw; |
| | 186 | | } |
| 20 | 187 | | } |
| | 188 | |
|
| | 189 | | /// <summary> |
| | 190 | | /// Gets a list of tables from the storage account. |
| | 191 | | /// </summary> |
| | 192 | | /// <param name="filter">Returns only tables or entities that satisfy the specified filter.</param> |
| | 193 | | /// <param name="maxPerPage">The maximum number of tables that will be returned per page.</param> |
| | 194 | | /// <param name="select">Returns the desired properties of an entity from the set. </param> |
| | 195 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 196 | | /// <returns></returns> |
| | 197 | | public virtual Pageable<TableItem> GetTables(string filter = null, int? maxPerPage = null, string select = null, |
| | 198 | | { |
| | 199 | |
|
| 20 | 200 | | return PageableHelpers.CreateEnumerable(_ => |
| 20 | 201 | | { |
| 40 | 202 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables) |
| 40 | 203 | | scope.Start(); |
| 20 | 204 | | try |
| 20 | 205 | | { |
| 40 | 206 | | var response = _tableOperations.Query( |
| 40 | 207 | | null, |
| 40 | 208 | | null, |
| 40 | 209 | | new QueryOptions() { Filter = filter, Select = select, Top = maxPerPage, Format = _format }, |
| 40 | 210 | | cancellationToken); |
| 40 | 211 | | return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response |
| 20 | 212 | | } |
| 0 | 213 | | catch (Exception ex) |
| 20 | 214 | | { |
| 0 | 215 | | scope.Failed(ex); |
| 0 | 216 | | throw; |
| 20 | 217 | | } |
| 40 | 218 | | }, (nextLink, _) => |
| 20 | 219 | | { |
| 28 | 220 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables) |
| 28 | 221 | | scope.Start(); |
| 20 | 222 | | try |
| 20 | 223 | | { |
| 28 | 224 | | var response = _tableOperations.Query( |
| 28 | 225 | | null, |
| 28 | 226 | | nextTableName: nextLink, |
| 28 | 227 | | new QueryOptions() { Filter = filter, Select = select, Top = maxPerPage, Format = _format }, |
| 28 | 228 | | cancellationToken); |
| 28 | 229 | | return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response |
| 20 | 230 | | } |
| 0 | 231 | | catch (Exception ex) |
| 20 | 232 | | { |
| 0 | 233 | | scope.Failed(ex); |
| 0 | 234 | | throw; |
| 20 | 235 | | } |
| 28 | 236 | | }); |
| | 237 | | } |
| | 238 | |
|
| | 239 | | /// <summary> |
| | 240 | | /// Creates a table in the storage account. |
| | 241 | | /// </summary> |
| | 242 | | /// <param name="tableName">The table name to create.</param> |
| | 243 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 244 | | /// <returns></returns> |
| | 245 | | public virtual Response<TableItem> CreateTable(string tableName, CancellationToken cancellationToken = default) |
| | 246 | | { |
| 326 | 247 | | Argument.AssertNotNull(tableName, nameof(tableName)); |
| 324 | 248 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(CreateTable)}" |
| 324 | 249 | | scope.Start(); |
| | 250 | | try |
| | 251 | | { |
| 324 | 252 | | var response = _tableOperations.Create(new TableProperties() { TableName = tableName }, null, queryOptio |
| 316 | 253 | | return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); |
| | 254 | | } |
| 8 | 255 | | catch (Exception ex) |
| | 256 | | { |
| 8 | 257 | | scope.Failed(ex); |
| 8 | 258 | | throw; |
| | 259 | | } |
| 316 | 260 | | } |
| | 261 | |
|
| | 262 | | /// <summary> |
| | 263 | | /// Creates a table in the storage account. |
| | 264 | | /// </summary> |
| | 265 | | /// <param name="tableName">The table name to create.</param> |
| | 266 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 267 | | /// <returns></returns> |
| | 268 | | public virtual async Task<Response<TableItem>> CreateTableAsync(string tableName, CancellationToken cancellation |
| | 269 | | { |
| 326 | 270 | | Argument.AssertNotNull(tableName, nameof(tableName)); |
| 324 | 271 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(CreateTable)}" |
| 324 | 272 | | scope.Start(); |
| | 273 | | try |
| | 274 | | { |
| 324 | 275 | | var response = await _tableOperations.CreateAsync(new TableProperties() { TableName = tableName }, null, |
| 316 | 276 | | return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); |
| | 277 | | } |
| 8 | 278 | | catch (Exception ex) |
| | 279 | | { |
| 8 | 280 | | scope.Failed(ex); |
| 8 | 281 | | throw; |
| | 282 | | } |
| 316 | 283 | | } |
| | 284 | |
|
| | 285 | | /// <summary> |
| | 286 | | /// Deletes a table in the storage account. |
| | 287 | | /// </summary> |
| | 288 | | /// <param name="tableName">The table name to create.</param> |
| | 289 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 290 | | /// <returns></returns> |
| | 291 | | public virtual Response DeleteTable(string tableName, CancellationToken cancellationToken = default) |
| | 292 | | { |
| 318 | 293 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(DeleteTable)}" |
| 318 | 294 | | scope.Start(); |
| | 295 | | try |
| | 296 | | { |
| 318 | 297 | | return _tableOperations.Delete(tableName, null, cancellationToken: cancellationToken); |
| | 298 | | } |
| 2 | 299 | | catch (Exception ex) |
| | 300 | | { |
| 2 | 301 | | scope.Failed(ex); |
| 2 | 302 | | throw; |
| | 303 | | } |
| 316 | 304 | | } |
| | 305 | |
|
| | 306 | | /// <summary> |
| | 307 | | /// Deletes a table in the storage account. |
| | 308 | | /// </summary> |
| | 309 | | /// <param name="tableName">The table name to create.</param> |
| | 310 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | 311 | | /// <returns></returns> |
| | 312 | | public virtual async Task<Response> DeleteTableAsync(string tableName, CancellationToken cancellationToken = def |
| | 313 | | { |
| 318 | 314 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(DeleteTable)}" |
| 318 | 315 | | scope.Start(); |
| | 316 | | try |
| | 317 | | { |
| 318 | 318 | | return await _tableOperations.DeleteAsync(tableName, null, cancellationToken: cancellationToken).Configu |
| | 319 | | } |
| 2 | 320 | | catch (Exception ex) |
| | 321 | | { |
| 2 | 322 | | scope.Failed(ex); |
| 2 | 323 | | throw; |
| | 324 | | } |
| 316 | 325 | | } |
| | 326 | |
|
| | 327 | | /// <summary> Sets properties for an account's Table service endpoint, including properties for Analytics a |
| | 328 | | /// <param name="tableServiceProperties"> The Table Service properties. </param> |
| | 329 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 330 | | public virtual Response SetProperties(TableServiceProperties tableServiceProperties, CancellationToken cancellat |
| | 331 | | { |
| 2 | 332 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(SetProperties) |
| 2 | 333 | | scope.Start(); |
| | 334 | | try |
| | 335 | | { |
| 2 | 336 | | return _serviceOperations.SetProperties(tableServiceProperties, cancellationToken: cancellationToken); |
| | 337 | | } |
| 0 | 338 | | catch (Exception ex) |
| | 339 | | { |
| 0 | 340 | | scope.Failed(ex); |
| 0 | 341 | | throw; |
| | 342 | | } |
| 2 | 343 | | } |
| | 344 | |
|
| | 345 | | /// <summary> Sets properties for an account's Table service endpoint, including properties for Analytics a |
| | 346 | | /// <param name="tableServiceProperties"> The Table Service properties. </param> |
| | 347 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 348 | | public virtual async Task<Response> SetPropertiesAsync(TableServiceProperties tableServiceProperties, Cancellati |
| | 349 | | { |
| 2 | 350 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(SetProperties) |
| 2 | 351 | | scope.Start(); |
| | 352 | | try |
| | 353 | | { |
| 2 | 354 | | return await _serviceOperations.SetPropertiesAsync(tableServiceProperties, cancellationToken: cancellati |
| | 355 | | } |
| 0 | 356 | | catch (Exception ex) |
| | 357 | | { |
| 0 | 358 | | scope.Failed(ex); |
| 0 | 359 | | throw; |
| | 360 | | } |
| 2 | 361 | | } |
| | 362 | |
|
| | 363 | | /// <summary> Gets the properties of an account's Table service, including properties for Analytics and COR |
| | 364 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 365 | | public virtual Response<TableServiceProperties> GetProperties(CancellationToken cancellationToken = default) |
| | 366 | | { |
| 12 | 367 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetProperties) |
| 12 | 368 | | scope.Start(); |
| | 369 | | try |
| | 370 | | { |
| 12 | 371 | | var response = _serviceOperations.GetProperties(cancellationToken: cancellationToken); |
| 12 | 372 | | return Response.FromValue(response.Value, response.GetRawResponse()); |
| | 373 | | } |
| 0 | 374 | | catch (Exception ex) |
| | 375 | | { |
| 0 | 376 | | scope.Failed(ex); |
| 0 | 377 | | throw; |
| | 378 | | } |
| 12 | 379 | | } |
| | 380 | |
|
| | 381 | | /// <summary> Gets the properties of an account's Table service, including properties for Analytics and COR |
| | 382 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 383 | | public virtual async Task<Response<TableServiceProperties>> GetPropertiesAsync(CancellationToken cancellationTok |
| | 384 | | { |
| 12 | 385 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetProperties) |
| 12 | 386 | | scope.Start(); |
| | 387 | | try |
| | 388 | | { |
| 12 | 389 | | var response = await _serviceOperations.GetPropertiesAsync(cancellationToken: cancellationToken).Configu |
| 12 | 390 | | return Response.FromValue(response.Value, response.GetRawResponse()); |
| | 391 | | } |
| 0 | 392 | | catch (Exception ex) |
| | 393 | | { |
| 0 | 394 | | scope.Failed(ex); |
| 0 | 395 | | throw; |
| | 396 | | } |
| 12 | 397 | | } |
| | 398 | |
|
| | 399 | | /// <summary> Retrieves statistics related to replication for the Table service. It is only available on the sec |
| | 400 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 401 | | public virtual async Task<Response<TableServiceStatistics>> GetStatisticsAsync(CancellationToken cancellationTok |
| | 402 | | { |
| 2 | 403 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetStatistics) |
| 2 | 404 | | scope.Start(); |
| | 405 | | try |
| | 406 | | { |
| 2 | 407 | | var response = await _secondaryServiceOperations.GetStatisticsAsync(cancellationToken: cancellationToken |
| 2 | 408 | | return Response.FromValue(response.Value, response.GetRawResponse()); |
| | 409 | | } |
| 0 | 410 | | catch (Exception ex) |
| | 411 | | { |
| 0 | 412 | | scope.Failed(ex); |
| 0 | 413 | | throw; |
| | 414 | | } |
| 2 | 415 | | } |
| | 416 | |
|
| | 417 | | /// <summary> Retrieves statistics related to replication for the Table service. It is only available on the sec |
| | 418 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 419 | | public virtual Response<TableServiceStatistics> GetStatistics(CancellationToken cancellationToken = default) |
| | 420 | | { |
| 2 | 421 | | using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetStatistics) |
| 2 | 422 | | scope.Start(); |
| | 423 | | try |
| | 424 | | { |
| 2 | 425 | | var response = _secondaryServiceOperations.GetStatistics(cancellationToken: cancellationToken); |
| 2 | 426 | | return Response.FromValue(response.Value, response.GetRawResponse()); |
| | 427 | | } |
| 0 | 428 | | catch (Exception ex) |
| | 429 | | { |
| 0 | 430 | | scope.Failed(ex); |
| 0 | 431 | | throw; |
| | 432 | | } |
| 2 | 433 | | } |
| | 434 | |
|
| | 435 | | internal static bool IsPremiumEndpoint(Uri endpoint) |
| | 436 | | { |
| 496 | 437 | | string absoluteUri = endpoint.OriginalString.ToLowerInvariant(); |
| 496 | 438 | | return (endpoint.Host.Equals("localhost", StringComparison.OrdinalIgnoreCase) && endpoint.Port != 10002) || |
| 496 | 439 | | absoluteUri.Contains(TableConstants.CosmosTableDomain) || absoluteUri.Contains(TableConstants.LegacyCosm |
| | 440 | | } |
| | 441 | | } |
| | 442 | | } |