/// <summary> /// Initializes a new instance of the <see cref="FormLayoutClient"/>. /// </summary> #pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. public FormLayoutClient(Uri endpoint, FormRecognizerApiKeyCredential credential, FormRecognizerClientOptions options) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { _diagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new ApiKeyAuthenticationPolicy(credential)); _operations = new ServiceClient(_diagnostics, _pipeline, endpoint.ToString()); }
public void ConstructorRequiresTheOptions() { var endpoint = new Uri("http://localhost"); var credential = new FormRecognizerApiKeyCredential("key"); Assert.Throws <ArgumentNullException>(() => new FormLayoutClient(endpoint, credential, null)); }
public void ConstructorRequiresTheEndpoint() { var credential = new FormRecognizerApiKeyCredential("key"); Assert.Throws <ArgumentNullException>(() => new FormLayoutClient(null, credential)); Assert.Throws <ArgumentNullException>(() => new FormLayoutClient(null, credential, new FormRecognizerClientOptions())); }
/// <summary> /// Creates a fake <see cref="FormLayoutClient" /> and instruments it to make use of the Azure Core /// Test Framework functionalities. /// </summary> /// <returns>The instrumented <see cref="FormLayoutClient" />.</returns> private FormLayoutClient CreateInstrumentedClient() { var fakeEndpoint = new Uri("http://localhost"); var fakeCredential = new FormRecognizerApiKeyCredential("fakeKey"); var client = new FormLayoutClient(fakeEndpoint, fakeCredential); return(InstrumentClient(client)); }
/// <summary> /// Creates a <see cref="FormLayoutClient" /> with the endpoint and API key provided via environment /// variables and instruments it to make use of the Azure Core Test Framework functionalities. /// </summary> /// <returns>The instrumented <see cref="FormLayoutClient" />.</returns> private FormLayoutClient CreateInstrumentedClient() { var endpointEnvironmentVariable = Environment.GetEnvironmentVariable(TestEnvironment.EndpointEnvironmentVariableName); var keyEnvironmentVariable = Environment.GetEnvironmentVariable(TestEnvironment.ApiKeyEnvironmentVariableName); Assert.NotNull(endpointEnvironmentVariable); Assert.NotNull(keyEnvironmentVariable); var endpoint = new Uri(endpointEnvironmentVariable); var credential = new FormRecognizerApiKeyCredential(keyEnvironmentVariable); var client = new FormLayoutClient(endpoint, credential); return(InstrumentClient(client)); }
static async Task Main(string[] args) { var endpoint = Environment.GetEnvironmentVariable(EnvEndpoint) ?? throw new ArgumentNullException(EnvEndpoint); var key = Environment.GetEnvironmentVariable(EnvApiKey) ?? throw new ArgumentNullException(EnvApiKey); var frEndpoint = new Uri(endpoint); var frKey = new FormRecognizerApiKeyCredential(key); var frOptions = new FormRecognizerClientOptions(ServiceVersion.V2_0_Preview); var custom = new CustomFormClient(frEndpoint, frKey, frOptions); var receipts = new ReceiptClient(frEndpoint, frKey, frOptions); var layout = new FormLayoutClient(frEndpoint, frKey, frOptions); // await TrainCustomModelWithLabels(custom); // await AnalyzeWithCustomModelWithLabels(custom); // await AnalyzeLayout(layout); // await AnalyzeReceipt(receipts); // await GetModelSummary(custom); // await DeleteModel(custom); await Task.CompletedTask; }
/// <summary> /// Initializes a new instance of the <see cref="CustomFormClient"/>. /// </summary> public CustomFormClient(Uri endpoint, FormRecognizerApiKeyCredential credential, FormRecognizerClientOptions options) { _diagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new ApiKeyAuthenticationPolicy(credential)); _operations = new ServiceClient(_diagnostics, _pipeline, endpoint.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="CustomFormClient"/>. /// </summary> public CustomFormClient(Uri endpoint, FormRecognizerApiKeyCredential credential) : this(endpoint, credential, new FormRecognizerClientOptions()) { }
public ApiKeyAuthenticationPolicy(FormRecognizerApiKeyCredential credential) { _credential = credential; }
/// <summary> /// Initializes a new instance of the <see cref="CustomFormClient"/>. /// </summary> #pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. public CustomFormClient(Uri endpoint, FormRecognizerApiKeyCredential credential) : this(endpoint, credential, new FormRecognizerClientOptions()) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. { }