/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="RecognizeBusinessCardsOperation"/> class. /// </summary> /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param> /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param> /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param> internal RecognizeBusinessCardsOperation(FormRecognizerRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation) { _serviceClient = serviceClient; _diagnostics = diagnostics; _operationInternal = new(_diagnostics, this, rawResponse : null); // TODO: Add validation here // https://github.com/Azure/azure-sdk-for-net/issues/10385 Id = operationLocation.Split('/').Last(); }
/// <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)); }
/// <summary> /// Initializes a new instance of the <see cref="RecognizeBusinessCardsOperation"/> class which /// tracks the status of a long-running operation for recognizing values from business cards. /// </summary> /// <param name="operationId">The ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public RecognizeBusinessCardsOperation(string operationId, FormRecognizerClient client) { Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); Argument.AssertNotNull(client, nameof(client)); Id = operationId; _serviceClient = client.ServiceClient; _diagnostics = client.Diagnostics; _operationInternal = new(_diagnostics, this, rawResponse : null); }
/// <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. /// </remarks> /// <seealso href="https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"/> 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); var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope)); ServiceClient = new FormRecognizerRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri); }
/// <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. /// </remarks> /// <seealso href="https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"/> 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); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader)); ServiceClient = new FormRecognizerRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri); }
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(); }
/// <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)); }
/// <summary> /// </summary> /// <param name="operations"></param> /// <param name="diagnostics"></param> /// <param name="operationLocation"></param> internal RecognizeCustomFormsOperation(FormRecognizerRestClient operations, ClientDiagnostics diagnostics, string operationLocation) { _serviceClient = operations; _diagnostics = diagnostics; // TODO: Use regex to parse ids. // https://github.com/Azure/azure-sdk-for-net/issues/11505 // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?) // https://github.com/Azure/azure-sdk-for-net/issues/10385 string[] substrs = operationLocation.Split('/'); _resultId = substrs[substrs.Length - 1]; _modelId = substrs[substrs.Length - 3]; Id = string.Join("/", substrs, substrs.Length - 3, 3); }
/// <summary> /// Initializes a new instance of the <see cref="CopyModelOperation"/> class. /// </summary> /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param> /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param> /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param> /// <param name="targetModelId">Model ID in the target Form Recognizer resource.</param> internal CopyModelOperation(FormRecognizerRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation, string targetModelId) { _serviceClient = serviceClient; _diagnostics = diagnostics; _targetModelId = targetModelId; _operationInternal = new(_diagnostics, this, rawResponse : null); string[] substrs = operationLocation.Split('/'); if (substrs.Length < 3) { throw new ArgumentException($"Invalid '{nameof(operationLocation)}'. It should be formatted as: '{{prefix}}/{{modelId}}/copyresults/{{resultId}}'.", nameof(operationLocation)); } _resultId = substrs[substrs.Length - 1]; _modelId = substrs[substrs.Length - 3]; Id = string.Join("/", substrs, substrs.Length - 3, 3); }
/// <summary> /// Initializes a new instance of the <see cref="CopyModelOperation"/> class which /// tracks the status of the long-running operation for copying a custom model into a target Form Recognizer resource. /// </summary> /// <param name="operationId">The ID of this operation.</param> /// <param name="targetModelId">Model ID in the target Form Recognizer resource.</param> /// <param name="client">The client used to check for completion.</param> public CopyModelOperation(string operationId, string targetModelId, FormTrainingClient client) { Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); Argument.AssertNotNull(client, nameof(client)); _serviceClient = client.ServiceClient; _diagnostics = client.Diagnostics; _targetModelId = targetModelId; _operationInternal = new(_diagnostics, this, rawResponse : null); string[] substrs = operationId.Split('/'); if (substrs.Length < 3) { throw new ArgumentException($"Invalid '{nameof(operationId)}'. It should be formatted as: '{{modelId}}/copyresults/{{resultId}}'.", nameof(operationId)); } _resultId = substrs.Last(); _modelId = substrs.First(); Id = operationId; }
/// <summary> /// Initializes a new instance of the <see cref="RecognizeCustomFormsOperation"/> class. /// </summary> /// <param name="operationId">The ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public RecognizeCustomFormsOperation(string operationId, FormRecognizerClient client) { _serviceClient = client.ServiceClient; _diagnostics = client.Diagnostics; // TODO: Use regex to parse ids. // https://github.com/Azure/azure-sdk-for-net/issues/11505 // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?) // https://github.com/Azure/azure-sdk-for-net/issues/10385 string[] substrs = operationId.Split('/'); if (substrs.Length < 3) { throw new ArgumentException($"Invalid '{nameof(operationId)}'. It should be formatted as: '{{modelId}}/analyzeresults/{{resultId}}'.", nameof(operationId)); } _resultId = substrs.Last(); _modelId = substrs.First(); Id = operationId; }
/// <summary> /// Initializes a new instance of the <see cref="CopyModelOperation"/> class. /// </summary> /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param> /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param> /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param> /// <param name="targetModelId">Model ID in the target Form Recognizer resource.</param> internal CopyModelOperation(FormRecognizerRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation, string targetModelId) { _serviceClient = serviceClient; _diagnostics = diagnostics; _targetModelId = targetModelId; // TODO: Use regex to parse ids. // https://github.com/Azure/azure-sdk-for-net/issues/11505 // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?) // https://github.com/Azure/azure-sdk-for-net/issues/10385 string[] substrs = operationLocation.Split('/'); if (substrs.Length < 3) { throw new ArgumentException($"Invalid '{nameof(operationLocation)}'. It should be formatted as: '{{prefix}}/{{modelId}}/copyresults/{{resultId}}'.", nameof(operationLocation)); } _resultId = substrs[substrs.Length - 1]; _modelId = substrs[substrs.Length - 3]; Id = string.Join("/", substrs, substrs.Length - 3, 3); }
internal CreateComposedModelOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics) : base(location, allOperations, diagnostics) { }
internal CreateComposedModelOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics, FormRecognizerClientOptions.ServiceVersion serviceVersion) : base(location, allOperations, diagnostics, serviceVersion) { }
internal TrainingOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics, FormRecognizerClientOptions.ServiceVersion serviceVersion) : base(location, allOperations, diagnostics, serviceVersion) { }
/// <summary> /// Initializes a new instance of the <see cref="TrainingOperation"/> class. /// </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) { Id = operationId; _diagnostics = client.Diagnostics; _serviceClient = client.ServiceClient; }
/// <summary> /// Initializes a new instance of the <see cref="FormRecognizerClient"/> class. /// </summary> /// <param name="diagnostics">Provides tools for exception creation in case of failure.</param> /// <param name="serviceClient">Provides communication with the Form Recognizer Azure Cognitive Service through its REST API.</param> internal FormRecognizerClient(ClientDiagnostics diagnostics, FormRecognizerRestClient serviceClient) { Diagnostics = diagnostics; ServiceClient = serviceClient; }
/// <summary> /// Initializes a new instance of the <see cref="TrainingOperation"/> class. /// </summary> /// <param name="operationId">The ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public TrainingOperation(string operationId, FormTrainingClient client) { Id = operationId; _diagnostics = client.Diagnostics; _serviceClient = client.ServiceClient; }
internal TrainingOperation(string location, FormRecognizerRestClient allOperations, ClientDiagnostics diagnostics) : base(location, allOperations, diagnostics) { }