Table of Contents

Interface IHttpClientFactoryService

Namespace
FoundationaLLM.Common.Interfaces
Assembly
FoundationaLLM.Common.dll

Service that provides a common interface for creating HttpClient instances from IHttpClientFactory. and ensures that all necessary headers are added to the request.

public interface IHttpClientFactoryService
Extension Methods

Methods

CreateClient(APIEndpointConfiguration, UnifiedUserIdentity?)

Creates a HttpClient instance based on the endpoint configuration.

Task<HttpClient> CreateClient(APIEndpointConfiguration endpointConfiguration, UnifiedUserIdentity? userIdentity)

Parameters

endpointConfiguration APIEndpointConfiguration

The APIEndpointConfiguration resource used to create the client.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity of the caller requesting the client.

Returns

Task<HttpClient>

An HttpClient instance.

CreateClient(string, UnifiedUserIdentity)

Creates a HttpClient instance based on the client name. The client name must be registered in the IHttpClientFactory configuration.

Task<HttpClient> CreateClient(string clientName, UnifiedUserIdentity userIdentity)

Parameters

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.

Returns

Task<HttpClient>

An HttpClient instance.

CreateClientForStatus(string, UnifiedUserIdentity)

Creates a HttpClient instance based on the client name and sets the base address to the status endpoint. The client name must be registered in the IHttpClientFactory configuration.

Task<HttpClient> CreateClientForStatus(string clientName, UnifiedUserIdentity userIdentity)

Parameters

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.

Returns

Task<HttpClient>

An HttpClient instance.

Exceptions

Exception

When if the service base address is null or the status endpoint is null or empty.

CreateClient<T>(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.

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

Parameters

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.

CreateUnregisteredClient(TimeSpan?)

Creates a new unregistered HttpClient instance with a timeout.

HttpClient CreateUnregisteredClient(TimeSpan? timeout = null)

Parameters

timeout TimeSpan?

The timeout for the HttpClient. If not specified, the default timeout in seconds is applied. For an infinite waiting period, use InfiniteTimeSpan

Returns

HttpClient

An HttpClient instance.