< Summary

Class:Azure.AI.FormRecognizer.FormRecognizerClientOptions
Assembly:Azure.AI.FormRecognizer
File(s):C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\FormRecognizerClientOptions.cs
Covered lines:14
Uncovered lines:6
Coverable lines:20
Total lines:73
Line coverage:70% (14 of 20)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Version()-0%100%
GetVersionString(...)-0%0%
AddLoggedHeadersAndQueryParameters()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\FormRecognizerClientOptions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.AI.FormRecognizer.Training;
 6using Azure.Core;
 7
 8namespace Azure.AI.FormRecognizer
 9{
 10    /// <summary>
 11    /// The set of options that can be specified when creating a <see cref="FormRecognizerClient" />
 12    /// or a <see cref="FormTrainingClient"/> to configure its behavior.
 13    /// </summary>
 14    public class FormRecognizerClientOptions : ClientOptions
 15    {
 16        internal const ServiceVersion LatestVersion = ServiceVersion.V2_0;
 17
 18        /// <summary>
 19        /// Initializes a new instance of the <see cref="FormRecognizerClientOptions"/> class.
 20        /// </summary>
 21        /// <param name="version">The version of the service to send requests to.</param>
 58822        public FormRecognizerClientOptions(ServiceVersion version = LatestVersion)
 23        {
 58824            Version = version;
 58825            AddLoggedHeadersAndQueryParameters();
 58826        }
 27
 28        /// <summary>
 29        /// The service version.
 30        /// </summary>
 31        public enum ServiceVersion
 32        {
 33            /// <summary>
 34            /// The V2.0 of the service.
 35            /// </summary>
 36#pragma warning disable CA1707 // Identifiers should not contain underscores
 37            V2_0 = 1
 38#pragma warning restore CA1707 // Identifiers should not contain underscores
 39        }
 40
 41        /// <summary>
 42        /// The service version.
 43        /// </summary>
 044        public ServiceVersion Version { get; }
 45
 46        internal static string GetVersionString(ServiceVersion version)
 47        {
 048            return version switch
 049            {
 050                ServiceVersion.V2_0 => "v2.0",
 051                _ => throw new NotSupportedException($"The service version {version} is not supported."),
 052            };
 53        }
 54
 55        /// <summary>
 56        /// Add headers and query parameters that are considered safe for logging or including in
 57        /// error messages by default.
 58        /// </summary>
 59        private void AddLoggedHeadersAndQueryParameters()
 60        {
 58861            Diagnostics.LoggedHeaderNames.Add(Constants.OperationLocationHeader);
 58862            Diagnostics.LoggedHeaderNames.Add("apim-request-id");
 58863            Diagnostics.LoggedHeaderNames.Add("Location");
 58864            Diagnostics.LoggedHeaderNames.Add("Strict-Transport-Security");
 58865            Diagnostics.LoggedHeaderNames.Add("X-Content-Type-Options");
 58866            Diagnostics.LoggedHeaderNames.Add("x-envoy-upstream-service-time");
 67
 58868            Diagnostics.LoggedQueryParameters.Add("includeKeys");
 58869            Diagnostics.LoggedQueryParameters.Add("includeTextDetails");
 58870            Diagnostics.LoggedQueryParameters.Add("op");
 58871        }
 72    }
 73}