| | 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.Security.KeyVault.Keys.Cryptography |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Options that allow you to configure the management of the request sent to Key Vault. |
| | 11 | | /// </summary> |
| | 12 | | public class CryptographyClientOptions : ClientOptions |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// The latest service version supported by this client library. |
| | 16 | | /// For more information, see |
| | 17 | | /// <see href="https://docs.microsoft.com/rest/api/keyvault/key-vault-versions">Key Vault versions</see>. |
| | 18 | | /// </summary> |
| | 19 | | internal const ServiceVersion LatestVersion = ServiceVersion.V7_1_Preview; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// The versions of Azure Key Vault supported by this client |
| | 23 | | /// library. |
| | 24 | | /// </summary> |
| | 25 | | public enum ServiceVersion |
| | 26 | | { |
| | 27 | | #pragma warning disable CA1707 // Identifiers should not contain underscores |
| | 28 | | /// <summary> |
| | 29 | | /// The Key Vault API version 7.0. |
| | 30 | | /// </summary> |
| | 31 | | V7_0 = 0, |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// The Key Vault API version 7.1-preview. |
| | 35 | | /// </summary> |
| | 36 | | V7_1_Preview = 1, |
| | 37 | | #pragma warning restore CA1707 // Identifiers should not contain underscores |
| | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Gets the <see cref="ServiceVersion"/> of the service API used when |
| | 42 | | /// making requests. For more information, see |
| | 43 | | /// <see href="https://docs.microsoft.com/rest/api/keyvault/key-vault-versions">Key Vault versions</see>. |
| | 44 | | /// </summary> |
| 316 | 45 | | public ServiceVersion Version { get; } |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Initializes a new instance of the <see cref="CryptographyClientOptions"/> class. |
| | 49 | | /// class. |
| | 50 | | /// </summary> |
| | 51 | | /// <param name="version"> |
| | 52 | | /// The <see cref="ServiceVersion"/> of the service API used when |
| | 53 | | /// making requests. |
| | 54 | | /// </param> |
| | 55 | | #pragma warning disable AZC0010 // ClientOptions constructors should default ServiceVersion to latest supported service |
| 316 | 56 | | public CryptographyClientOptions(ServiceVersion version = LatestVersion) |
| | 57 | | #pragma warning restore AZC0010 // ClientOptions constructors should default ServiceVersion to latest supported service |
| | 58 | | { |
| 316 | 59 | | Version = version; |
| | 60 | |
|
| 316 | 61 | | this.ConfigureLogging(); |
| 316 | 62 | | } |
| | 63 | |
|
| | 64 | | internal string GetVersionString() |
| | 65 | | { |
| 316 | 66 | | return Version switch |
| 316 | 67 | | { |
| 0 | 68 | | ServiceVersion.V7_0 => "7.0", |
| 632 | 69 | | ServiceVersion.V7_1_Preview => "7.1-preview", |
| 316 | 70 | |
|
| 0 | 71 | | _ => throw new NotSupportedException($"The service version {Version} is not supported."), |
| 316 | 72 | | }; |
| | 73 | | } |
| | 74 | | } |
| | 75 | | } |