Table of Contents

Class ClientFactoryService

Namespace
FoundationaLLM.Common.Services.API
Assembly
FoundationaLLM.Common.dll

Provides methods for creating client pipelines for communication with API endpoints.

public class ClientFactoryService : IClientFactoryService
Inheritance
ClientFactoryService
Implements
Inherited Members
Extension Methods

Remarks

This service abstracts the creation of client pipelines, allowing clients to establish connections using either an instance identifier and client name or a specific API endpoint configuration. Implementations may enforce authentication or configuration requirements depending on the provided parameters.

Constructors

ClientFactoryService(IServiceProvider, IConfiguration)

Provides methods for creating client pipelines for communication with API endpoints.

public ClientFactoryService(IServiceProvider serviceProvider, IConfiguration configuration)

Parameters

serviceProvider IServiceProvider

The IServiceProvider for the main DI container.

configuration IConfiguration

The IConfiguration used to retrieve app settings from configuration.

Remarks

This service abstracts the creation of client pipelines, allowing clients to establish connections using either an instance identifier and client name or a specific API endpoint configuration. Implementations may enforce authentication or configuration requirements depending on the provided parameters.

Methods

CreateClient<T>(string, string, UnifiedUserIdentity, Func<Dictionary<string, object>, T>, Dictionary<string, object>?)

Creates a T client instance based on the client name and a client builder delegate.

public Task<T> CreateClient<T>(string instanceId, string clientName, UnifiedUserIdentity userIdentity, Func<Dictionary<string, object>, T> clientBuilder, Dictionary<string, object>? clientBuilderParameters = null)

Parameters

instanceId string

The FoundationaLLM instance identifier.

clientName string

The name of the HTTP client to create. This name must be registered as an APIEndpointConfiguration resource in the FoundationaLLM.Configuration resource provider.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity of the caller requesting the client.

clientBuilder Func<Dictionary<string, object>, T>

A delegate that creates the T client instance based on a dictionary of values. The keys available in the dictionary are defined in HttpClientFactoryServiceKeyNames.

clientBuilderParameters Dictionary<string, object>

A dictionary of parameters to pass to the client builder delegate.

Returns

Task<T>

A T client instance.

Type Parameters

T

The type of the client to create.