diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index bbe48c3f04a9e..7944fcb75194f 100755 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -9,7 +9,7 @@ - + diff --git a/sdk/appconfiguration/Azure.ApplicationModel.Configuration/src/ConfigurationClientOptions.cs b/sdk/appconfiguration/Azure.ApplicationModel.Configuration/src/ConfigurationClientOptions.cs index 2a1f0be0ff38c..e2efd16d822fc 100644 --- a/sdk/appconfiguration/Azure.ApplicationModel.Configuration/src/ConfigurationClientOptions.cs +++ b/sdk/appconfiguration/Azure.ApplicationModel.Configuration/src/ConfigurationClientOptions.cs @@ -7,5 +7,36 @@ namespace Azure.ApplicationModel.Configuration { public class ConfigurationClientOptions: ClientOptions { + /// + /// The latest service version supported by this client library. + /// + internal const ServiceVersion LatestVersion = ServiceVersion.Default; + + /// + /// The versions of App Config Service supported by this client library. + /// + public enum ServiceVersion + { + Default = 0 + } + + /// + /// Gets the of the service API used when + /// making requests. + /// + public ServiceVersion Version { get; } + + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// The of the service API used when + /// making requests. + /// + public ConfigurationClientOptions(ServiceVersion version = ServiceVersion.Default) + { + this.Version = version; + } } } diff --git a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClientOptions.cs b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClientOptions.cs index 023be145e78d2..28a65aef1fdeb 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClientOptions.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClientOptions.cs @@ -8,5 +8,45 @@ namespace Azure.Security.KeyVault.Certificates { public class CertificateClientOptions : ClientOptions { + /// + /// The latest service version supported by this client library. + /// For more information, see + /// + /// + internal const ServiceVersion LatestVersion = ServiceVersion.V7_0; + + /// + /// The versions of Azure Key Vault supported by this client + /// library. + /// + public enum ServiceVersion + { +#pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// The Key Vault API version 7.0. + /// + V7_0 = 0 +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + + /// + /// Gets the of the service API used when + /// making requests. For more information, see + /// + /// + public ServiceVersion Version { get; } + + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// The of the service API used when + /// making requests. + /// + public CertificateClientOptions(ServiceVersion version = ServiceVersion.V7_0) + { + this.Version = version; + } } } diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient.cs index 6051fc79a0c5b..9a28df0959317 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient.cs @@ -51,6 +51,7 @@ public KeyClient(Uri vaultUri, TokenCredential credential, KeyClientOptions opti { _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(credential)); options = options ?? new KeyClientOptions(); + this.ApiVersion = options.GetVersionString(); _pipeline = HttpPipelineBuilder.Build(options, bufferResponse: true, diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClientOptions.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClientOptions.cs index 2fa1af1e083a2..60b1952f3c549 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClientOptions.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClientOptions.cs @@ -3,6 +3,7 @@ // license information. using Azure.Core.Pipeline; +using System; namespace Azure.Security.KeyVault.Keys { @@ -11,5 +12,62 @@ namespace Azure.Security.KeyVault.Keys /// public class KeyClientOptions : ClientOptions { + /// + /// The latest service version supported by this client library. + /// For more information, see + /// + /// + internal const ServiceVersion LatestVersion = ServiceVersion.V7_0; + + /// + /// The versions of Azure Key Vault supported by this client + /// library. + /// + public enum ServiceVersion + { +#pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// The Key Vault API version 7.0. + /// + V7_0 = 0 +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + + /// + /// Gets the of the service API used when + /// making requests. For more information, see + /// + /// + public ServiceVersion Version { get; } + + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// The of the service API used when + /// making requests. + /// + public KeyClientOptions(ServiceVersion version = ServiceVersion.V7_0) + { + this.Version = version; + } + + internal string GetVersionString() + { + var version = string.Empty; + + switch (this.Version) + { + case ServiceVersion.V7_0: + version = "7.0"; + break; + + default: + throw new ArgumentException(this.Version.ToString()); + } + + return version; + } } } diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient_private.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient_private.cs index b9f4caa8ae0c4..3c5241ee6d35e 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient_private.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient_private.cs @@ -9,9 +9,9 @@ namespace Azure.Security.KeyVault.Keys { public partial class KeyClient { - private const string ApiVersion = "7.0"; private const string KeysPath = "/keys/"; private const string DeletedKeysPath = "/deletedkeys/"; + private readonly string ApiVersion; private async Task> SendRequestAsync(RequestMethod method, TContent content, Func resultFactory, CancellationToken cancellationToken, params string[] path) where TContent : Model diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClient.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClient.cs index 32f4c8f321473..a02c6c73b1fda 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClient.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClient.cs @@ -21,7 +21,7 @@ namespace Azure.Security.KeyVault.Secrets public class SecretClient { private readonly Uri _vaultUri; - private const string ApiVersion = "7.0"; + private readonly string ApiVersion; private readonly HttpPipeline _pipeline; private const string SecretsPath = "/secrets/"; @@ -56,6 +56,7 @@ public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOption { _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(credential)); options = options ?? new SecretClientOptions(); + this.ApiVersion = options.GetVersionString(); _pipeline = HttpPipelineBuilder.Build(options, bufferResponse: true, diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClientOptions.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClientOptions.cs index 7248ede837b93..20c3c567a4d05 100644 --- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClientOptions.cs +++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/SecretClientOptions.cs @@ -3,6 +3,7 @@ // license information. using Azure.Core.Pipeline; +using System; namespace Azure.Security.KeyVault.Secrets { @@ -11,5 +12,62 @@ namespace Azure.Security.KeyVault.Secrets /// public class SecretClientOptions : ClientOptions { + /// + /// The latest service version supported by this client library. + /// For more information, see + /// + /// + internal const ServiceVersion LatestVersion = ServiceVersion.V7_0; + + /// + /// The versions of Azure Key Vault supported by this client + /// library. + /// + public enum ServiceVersion + { +#pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// The Key Vault API version 7.0. + /// + V7_0 = 0 +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + + /// + /// Gets the of the service API used when + /// making requests. For more information, see + /// + /// + public ServiceVersion Version { get; } + + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// The of the service API used when + /// making requests. + /// + public SecretClientOptions(ServiceVersion version = ServiceVersion.V7_0) + { + this.Version = version; + } + + internal string GetVersionString() + { + var version = string.Empty; + + switch (this.Version) + { + case ServiceVersion.V7_0: + version = "7.0"; + break; + + default: + throw new ArgumentException(this.Version.ToString()); + } + + return version; + } } }