コード例 #1
0
 public FormRecognizerLiveTestBase(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync)
 {
     _serviceVersion = serviceVersion;
     JsonPathSanitizers.Add("$..accessToken");
     JsonPathSanitizers.Add("$..source");
     SanitizedHeaders.Add(Constants.AuthorizationHeader);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateCustomFormModelOperation"/> class which
        /// tracks the status of a long-running operation for creating a custom model.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="client">The client used to check for completion.</param>
        public CreateCustomFormModelOperation(string operationId, FormTrainingClient client)
        {
            Argument.AssertNotNull(client, nameof(client));

            Id              = operationId;
            _diagnostics    = client.Diagnostics;
            _serviceClient  = client.ServiceClient;
            _serviceVersion = client.ServiceVersion;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateCustomFormModelOperation"/> class which
        /// tracks the status of a long-running operation for creating a custom model.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="client">The client used to check for completion.</param>
        public CreateCustomFormModelOperation(string operationId, FormTrainingClient client)
        {
            Argument.AssertNotNull(client, nameof(client));

            Id                 = operationId;
            _diagnostics       = client.Diagnostics;
            _serviceClient     = client.ServiceClient;
            _serviceVersion    = client.ServiceVersion;
            _operationInternal = new(_diagnostics, this, rawResponse : null, nameof(CreateCustomFormModelOperation));
        }
コード例 #4
0
 public FormRecognizerLiveTestBase(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync)
 {
     _serviceVersion = serviceVersion;
     JsonPathSanitizers.Add("$..accessToken");
     JsonPathSanitizers.Add("$..containerUrl");
     SanitizedHeaders.Add(Constants.AuthorizationHeader);
     // temporary until https://github.com/Azure/azure-sdk-for-net/issues/27688 is addressed
     CompareBodies = false;
 }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
        /// <param name="credential">A credential used to authenticate to an Azure Service.</param>
        /// <param name="options">A set of options to apply when configuring the client.</param>
        /// <remarks>
        /// The <paramref name="endpoint"/> URI string can be found in the Azure Portal.
        /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"> here</see>.
        /// </remarks>
        public FormTrainingClient(Uri endpoint, TokenCredential credential, FormRecognizerClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(options, nameof(options));

            Diagnostics    = new ClientDiagnostics(options);
            ServiceVersion = options.Version;
            var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope));

            ServiceClient = new FormRecognizerRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri, FormRecognizerClientOptions.GetVersionString(ServiceVersion));
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
        /// <param name="credential">A credential used to authenticate to an Azure Service.</param>
        /// <param name="options">A set of options to apply when configuring the client.</param>
        /// <remarks>
        /// Both the <paramref name="endpoint"/> URI string and the <paramref name="credential"/> <c>string</c> key
        /// can be found in the Azure Portal.
        /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"> here</see>.
        /// </remarks>
        public FormTrainingClient(Uri endpoint, AzureKeyCredential credential, FormRecognizerClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(options, nameof(options));

            Diagnostics    = new ClientDiagnostics(options);
            ServiceVersion = options.Version;
            HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader));

            ServiceClient = new FormRecognizerRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri, FormRecognizerClientOptions.GetVersionString(ServiceVersion));
        }
コード例 #7
0
 internal CustomFormModel(Model model, FormRecognizerClientOptions.ServiceVersion serviceVersion)
 {
     ModelId             = model.ModelInfo.ModelId;
     ModelName           = model.ModelInfo.ModelName;
     Status              = model.ModelInfo.Status;
     TrainingStartedOn   = model.ModelInfo.TrainingStartedOn;
     TrainingCompletedOn = model.ModelInfo.TrainingCompletedOn;
     Submodels           = ConvertToSubmodels(model, serviceVersion);
     TrainingDocuments   = ConvertToTrainingDocuments(model);
     Errors              = model.TrainResult?.Errors ?? new List <FormRecognizerError>();
     Properties          = model.ModelInfo.Properties ?? new CustomFormModelProperties();
 }
コード例 #8
0
        internal CreateCustomFormModelOperation(
            string location,
            FormRecognizerRestClient allOperations,
            ClientDiagnostics diagnostics,
            FormRecognizerClientOptions.ServiceVersion serviceVersion)
        {
            _serviceClient     = allOperations;
            _diagnostics       = diagnostics;
            _serviceVersion    = serviceVersion;
            _operationInternal = new(_diagnostics, this, rawResponse : null, nameof(CreateCustomFormModelOperation));

            Id = location.Split('/').Last();
        }
        internal CreateCustomFormModelOperation(
            string location,
            FormRecognizerRestClient allOperations,
            ClientDiagnostics diagnostics,
            FormRecognizerClientOptions.ServiceVersion serviceVersion)
        {
            _serviceClient  = allOperations;
            _diagnostics    = diagnostics;
            _serviceVersion = serviceVersion;

            // TODO: validate this
            // https://github.com/Azure/azure-sdk-for-net/issues/10385
            Id = location.Split('/').Last();
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
        /// <param name="credential">A credential used to authenticate to an Azure Service.</param>
        /// <param name="options">A set of options to apply when configuring the client.</param>
        /// <remarks>
        /// The <paramref name="endpoint"/> URI string can be found in the Azure Portal.
        /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"> here</see>.
        /// </remarks>
        public FormTrainingClient(Uri endpoint, TokenCredential credential, FormRecognizerClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(options, nameof(options));

            string defaultScope = $"{(string.IsNullOrEmpty(options.Audience?.ToString()) ? FormRecognizerAudience.AzurePublicCloud : options.Audience)}/.default";

            Diagnostics    = new ClientDiagnostics(options);
            ServiceVersion = options.Version;
            var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, defaultScope));

            ServiceClient = new FormRecognizerRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri, FormRecognizerClientOptions.GetVersionString(ServiceVersion));
        }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormTrainingClientLiveTests"/> class.
 /// </summary>
 /// <param name="isAsync">A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods.</param>
 public FormTrainingClientLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
 }
コード例 #12
0
        private static IReadOnlyList <CustomFormSubmodel> ConvertToSubmodels(Model model, FormRecognizerClientOptions.ServiceVersion serviceVersion = default)
        {
            if (model.Keys != null)
            {
                return(ConvertFromUnlabeled(model));
            }

            if (model.TrainResult != null)
            {
                return(ConvertFromLabeled(model, serviceVersion));
            }

            if (model.ComposedTrainResults != null)
            {
                return(ConvertFromLabeledComposedModel(model));
            }

            return(null);
        }
コード例 #13
0
 public RecognizeCustomFormsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormRecognizerOperationsLiveTests"/> class.
 /// </summary>
 /// <param name="isAsync">A flag used by the Azure Core Test Framework to differentiate between tests for asynchronous and synchronous methods.</param>
 public FormRecognizerOperationsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
 }
コード例 #15
0
 public RecognizeBusinessCardsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
 }
コード例 #16
0
 public RecognizeIdentityDocumentsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
 }
コード例 #17
0
 internal TrainingOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(location, allOperations, diagnostics, serviceVersion)
 {
 }
コード例 #18
0
 public FormRecognizerLiveTestBase(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(isAsync)
 {
     _serviceVersion = serviceVersion;
     Sanitizer       = new FormRecognizerRecordedTestSanitizer();
 }
コード例 #19
0
 internal CreateComposedModelOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics, FormRecognizerClientOptions.ServiceVersion serviceVersion)
     : base(location, allOperations, diagnostics, serviceVersion)
 {
 }