| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Iot.Hub.Service |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Options that allow configuration of requests sent to the IoTHub service. |
| | 11 | | /// </summary> |
| | 12 | | public class IotHubServiceClientOptions : ClientOptions |
| | 13 | | { |
| | 14 | | internal const ServiceVersion LatestVersion = ServiceVersion.V2020_03_13; |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// The versions of IoTHub Service supported by this client |
| | 18 | | /// library. |
| | 19 | | /// </summary> |
| | 20 | | [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", |
| | 21 | | public enum ServiceVersion |
| | 22 | | { |
| | 23 | | /// <summary> |
| | 24 | | /// 2020-03-13 |
| | 25 | | /// </summary> |
| | 26 | | V2020_03_13 = 1 |
| | 27 | | } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Gets the <see cref="ServiceVersion"/> of the service API used when |
| | 31 | | /// making requests. |
| | 32 | | /// </summary> |
| 304 | 33 | | public ServiceVersion Version { get; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Initializes a new instance of the <see cref="IotHubServiceClientOptions"/> |
| | 37 | | /// class. |
| | 38 | | /// </summary> |
| 76 | 39 | | public IotHubServiceClientOptions(ServiceVersion version = LatestVersion) |
| | 40 | | { |
| 76 | 41 | | Version = version; |
| 76 | 42 | | } |
| | 43 | |
|
| | 44 | |
|
| | 45 | | internal string GetVersionString() |
| | 46 | | { |
| 304 | 47 | | return Version switch |
| 304 | 48 | | { |
| 608 | 49 | | ServiceVersion.V2020_03_13 => "2020-03-13", |
| 0 | 50 | | _ => throw new ArgumentException(Version.ToString()), |
| 304 | 51 | | }; |
| | 52 | | } |
| | 53 | | } |
| | 54 | | } |