Class HttpClientFactoryService
- Namespace
 - FoundationaLLM.Common.Services.API
 
- Assembly
 - FoundationaLLM.Common.dll
 
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
public class HttpClientFactoryService : IHttpClientFactoryService
  - Inheritance
 - 
      
      HttpClientFactoryService
 
- Implements
 
- Inherited Members
 
- Extension Methods
 
Constructors
HttpClientFactoryService(IServiceProvider, IConfiguration, IHttpClientFactory)
Creates a new instance of the HttpClientFactoryService class.
public HttpClientFactoryService(IServiceProvider serviceProvider, IConfiguration configuration, IHttpClientFactory httpClientFactory)
  Parameters
serviceProviderIServiceProviderThe IServiceProvider for the main DI container.
configurationIConfigurationThe IConfiguration used to retrieve app settings from configuration.
httpClientFactoryIHttpClientFactoryA fully configured IHttpClientFactory.
Exceptions
Methods
CreateClient(APIEndpointConfiguration, UnifiedUserIdentity?)
Creates a HttpClient instance based on the endpoint configuration.
public Task<HttpClient> CreateClient(APIEndpointConfiguration endpointConfiguration, UnifiedUserIdentity? userIdentity)
  Parameters
endpointConfigurationAPIEndpointConfigurationThe APIEndpointConfiguration resource used to create the client.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity of the caller requesting the client.
Returns
- Task<HttpClient>
 An HttpClient instance.
CreateClient(string, string, UnifiedUserIdentity)
Creates a HttpClient instance based on the client name. The client name must be registered in the IHttpClientFactory configuration.
public Task<HttpClient> CreateClient(string instanceId, string clientName, UnifiedUserIdentity userIdentity)
  Parameters
instanceIdstringThe FoundationaLLM instance identifier.
clientNamestringThe name of the HTTP client to create. This name must be registered as an APIEndpointConfiguration resource in the FoundationaLLM.Configuration resource provider.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity of the caller requesting the client.
Returns
- Task<HttpClient>
 An HttpClient instance.
CreateClientForStatus(string, 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.
public Task<HttpClient> CreateClientForStatus(string instanceId, string clientName, UnifiedUserIdentity userIdentity)
  Parameters
instanceIdstringThe FoundationaLLM instance identifier.
clientNamestringThe name of the HTTP client to create. This name must be registered as an APIEndpointConfiguration resource in the FoundationaLLM.Configuration resource provider.
userIdentityUnifiedUserIdentityThe 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, 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
instanceIdstringThe FoundationaLLM instance identifier.
clientNamestringThe name of the HTTP client to create. This name must be registered as an APIEndpointConfiguration resource in the FoundationaLLM.Configuration resource provider.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity of the caller requesting the client.
clientBuilderFunc<Dictionary<string, object>, T>A delegate that creates the
Tclient instance based on a dictionary of values. The keys available in the dictionary are defined in HttpClientFactoryServiceKeyNames.clientBuilderParametersDictionary<string, object>A dictionary of parameters to pass to the client builder delegate.
Returns
- Task<T>
 A
Tclient instance.
Type Parameters
TThe type of the client to create.