| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Core; |
| | 5 | | using System; |
| | 6 | |
|
| | 7 | | namespace Azure.AI.TextAnalytics |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Options that allow to configure the management of the request sent to the service. |
| | 11 | | /// </summary> |
| | 12 | | public class TextAnalyticsClientOptions : ClientOptions |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// The latest service version supported by this client library. |
| | 16 | | /// </summary> |
| | 17 | | internal const ServiceVersion LatestVersion = ServiceVersion.V3_1_Preview_1; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// The versions of the Text Analytics service supported by this client library. |
| | 21 | | /// </summary> |
| | 22 | | public enum ServiceVersion |
| | 23 | | { |
| | 24 | | #pragma warning disable CA1707 // Identifiers should not contain underscores |
| | 25 | | /// <summary> |
| | 26 | | /// Version 3.0 |
| | 27 | | /// </summary> |
| | 28 | | V3_0 = 1, |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Version 3.1-preview.1 |
| | 32 | | /// </summary> |
| | 33 | | V3_1_Preview_1 = 2, |
| | 34 | | #pragma warning restore CA1707 // Identifiers should not contain underscores |
| | 35 | | } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Gets the <see cref="ServiceVersion"/> of the service API used when |
| | 39 | | /// making requests. |
| | 40 | | /// </summary> |
| 184 | 41 | | internal ServiceVersion Version { get; } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Default country hint value to use in all client calls. |
| | 45 | | /// If no value is specified, "us" is set as default. |
| | 46 | | /// To remove this behavior, set to <see cref="DetectLanguageInput.None"/>. |
| | 47 | | /// </summary> |
| 244 | 48 | | public string DefaultCountryHint { get; set; } = "us"; |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Default language value to use in all client calls. |
| | 52 | | /// If no value is specified, "en" is set as default. |
| | 53 | | /// </summary> |
| 0 | 54 | | public string DefaultLanguage { get; set; } = "en"; |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Initializes a new instance of the <see cref="TextAnalyticsClientOptions"/> |
| | 58 | | /// class. |
| | 59 | | /// </summary> |
| | 60 | | /// <param name="version"> |
| | 61 | | /// The <see cref="ServiceVersion"/> of the service API used when |
| | 62 | | /// making requests. |
| | 63 | | /// </param> |
| 200 | 64 | | public TextAnalyticsClientOptions(ServiceVersion version = LatestVersion) |
| | 65 | | { |
| 200 | 66 | | Version = version; |
| 200 | 67 | | this.ConfigureLogging(); |
| 200 | 68 | | } |
| | 69 | |
|
| | 70 | | internal string GetVersionString() |
| | 71 | | { |
| 184 | 72 | | return Version switch |
| 184 | 73 | | { |
| 0 | 74 | | ServiceVersion.V3_0 => "v3.0", |
| 368 | 75 | | ServiceVersion.V3_1_Preview_1 => "v3.1-preview.1", |
| 184 | 76 | |
|
| 0 | 77 | | _ => throw new ArgumentException($"Version {Version.ToString()} not supported."), |
| 184 | 78 | | }; |
| | 79 | | } |
| | 80 | | } |
| | 81 | | } |