-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
DocumentAnalysisClientOptions.cs
82 lines (71 loc) · 3.25 KB
/
DocumentAnalysisClientOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using Azure.Core;
namespace Azure.AI.FormRecognizer.DocumentAnalysis
{
/// <summary>
/// The set of options that can be specified when creating a <see cref="DocumentAnalysisClient" />
/// or a <see cref="DocumentModelAdministrationClient"/> to configure its behavior.
/// </summary>
public class DocumentAnalysisClientOptions : ClientOptions
{
internal const ServiceVersion LatestVersion = ServiceVersion.V2023_07_31;
/// <summary>
/// Initializes a new instance of the <see cref="DocumentAnalysisClientOptions"/> class which allows
/// to configure the behavior of the <see cref="DocumentAnalysisClient" /> or <see cref="DocumentModelAdministrationClient"/>.
/// </summary>
/// <param name="version">The version of the service to send requests to.</param>
public DocumentAnalysisClientOptions(ServiceVersion version = LatestVersion)
{
Version = version;
VersionString = version switch
{
ServiceVersion.V2022_08_31 => "2022-08-31",
ServiceVersion.V2023_07_31 => "2023-07-31",
_ => throw new NotSupportedException($"The service version {version} is not supported by this library."),
};
AddLoggedHeadersAndQueryParameters();
}
/// <summary>
/// The service version.
/// </summary>
public enum ServiceVersion
{
#pragma warning disable CA1707 // Identifiers should not contain underscores
/// <summary>
/// The version 2022-08-31 of the service.
/// </summary>
V2022_08_31 = 1,
/// <summary>
/// The version 2023-07-31 of the service.
/// </summary>
V2023_07_31
#pragma warning restore CA1707 // Identifiers should not contain underscores
}
/// <summary>
/// Gets or sets the Audience to use for authentication with Azure Active Directory (AAD). The audience is not considered when using a shared key.
/// </summary>
/// <value>If <c>null</c>, <see cref="DocumentAnalysisAudience.AzurePublicCloud" /> will be assumed.</value>
public DocumentAnalysisAudience? Audience { get; set; }
/// <summary>
/// The service version.
/// </summary>
public ServiceVersion Version { get; }
internal string VersionString { get; }
/// <summary>
/// Add headers and query parameters that are considered safe for logging or including in
/// error messages by default.
/// </summary>
private void AddLoggedHeadersAndQueryParameters()
{
Diagnostics.LoggedHeaderNames.Add(Constants.OperationLocationHeader);
Diagnostics.LoggedHeaderNames.Add("apim-request-id");
Diagnostics.LoggedHeaderNames.Add("Strict-Transport-Security");
Diagnostics.LoggedHeaderNames.Add("x-content-type-options");
Diagnostics.LoggedHeaderNames.Add("x-envoy-upstream-service-time");
Diagnostics.LoggedQueryParameters.Add("locale");
Diagnostics.LoggedQueryParameters.Add("pages");
}
}
}