| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Threading; |
| | 5 | | using System.Threading.Tasks; |
| | 6 | | using Azure.Core; |
| | 7 | | using Azure.Iot.Hub.Service.Models; |
| | 8 | |
|
| | 9 | | namespace Azure.Iot.Hub.Service |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Statistics client to acquire information about IoT Hub statistics. |
| | 13 | | /// </summary> |
| | 14 | | public class StatisticsClient |
| | 15 | | { |
| | 16 | | private readonly StatisticsRestClient _statisticsRestClient = null; |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Initializes a new instance of StatisticsClient. |
| | 20 | | /// </summary> |
| 8 | 21 | | protected StatisticsClient() |
| | 22 | | { |
| 8 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Initializes a new instance of StatisticsClient. |
| | 27 | | /// <param name="statisticsRestClient"> The REST client to query statistics of the IoT Hub. </param> |
| | 28 | | /// </summary> |
| 76 | 29 | | internal StatisticsClient(StatisticsRestClient statisticsRestClient) |
| | 30 | | { |
| 76 | 31 | | Argument.AssertNotNull(statisticsRestClient, nameof(statisticsRestClient)); |
| | 32 | |
|
| 76 | 33 | | _statisticsRestClient = statisticsRestClient; |
| 76 | 34 | | } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Gets devices statistics of the IoT Hub identity registry. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | 40 | | /// <returns>The devices statistics of the IoT Hub.</returns> |
| | 41 | | public virtual Response<DevicesStatistics> GetDevicesStatistics(CancellationToken cancellationToken = default) |
| | 42 | | { |
| 2 | 43 | | return _statisticsRestClient.GetDeviceStatistics(cancellationToken); |
| | 44 | | } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Gets devices statistics of the IoT Hub identity registry. |
| | 48 | | /// </summary> |
| | 49 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | 50 | | /// <returns>The devices statistics of the IoT Hub.</returns> |
| | 51 | | public virtual Task<Response<DevicesStatistics>> GetDevicesStatisticsAsync(CancellationToken cancellationToken = |
| | 52 | | { |
| 2 | 53 | | return _statisticsRestClient.GetDeviceStatisticsAsync(cancellationToken); |
| | 54 | | } |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Gets service statistics of the IoT Hub. |
| | 58 | | /// </summary> |
| | 59 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | 60 | | /// <returns>The service statistics of the IoT Hub.</returns> |
| | 61 | | public virtual Response<ServiceStatistics> GetServiceStatistics(CancellationToken cancellationToken = default) |
| | 62 | | { |
| 2 | 63 | | return _statisticsRestClient.GetServiceStatistics(cancellationToken); |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Gets service statistics of the IoT Hub. |
| | 68 | | /// </summary> |
| | 69 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | 70 | | /// <returns>The service statistics of the IoT Hub.</returns> |
| | 71 | | public virtual Task<Response<ServiceStatistics>> GetServiceStatisticsAsync(CancellationToken cancellationToken = |
| | 72 | | { |
| 2 | 73 | | return _statisticsRestClient.GetServiceStatisticsAsync(cancellationToken); |
| | 74 | | } |
| | 75 | | } |
| | 76 | | } |