Method AddKepwareApiClient
AddKepwareApiClient(IServiceCollection, string, KepwareApiClientOptions)
Adds a single Kepware Configuration API client to the service collection.
public static IServiceCollection AddKepwareApiClient(this IServiceCollection services, string name, KepwareApiClientOptions options)
Parameters
services
IServiceCollectionThe service collection to add the client to.
name
stringThe name of the client.
options
KepwareApiClientOptionsThe options for configuring the client.
Returns
- IServiceCollection
The updated service collection.
Exceptions
- ArgumentNullException
Thrown when the services or options parameter is null.
- ArgumentException
Thrown when the name parameter is null or empty.
- InvalidOperationException
Thrown when a client with the same name is already registered or the host URI is not absolute.
AddKepwareApiClient(IServiceCollection, string, string, string, string, int, bool, Action<HttpClient>?, Action<IHttpClientBuilder>?)
Adds a single Kepware API client to the service collection with specified parameters.
public static IServiceCollection AddKepwareApiClient(this IServiceCollection services, string name, string baseUrl, string apiUserName, string apiPassword, int timeoutInSeconds = 60, bool disableCertificateValidation = false, Action<HttpClient>? configureClient = null, Action<IHttpClientBuilder>? configureHttpClientBuilder = null)
Parameters
services
IServiceCollectionThe service collection to add the client to.
name
stringThe name of the client.
baseUrl
stringThe base URL of the Kepware Configuration API in the format of https://{hostname}:{port} or http://{hostname}:{port}
apiUserName
stringThe username for authentication.
apiPassword
stringThe password for authentication.
timeoutInSeconds
intThe timeout period for the HTTP client in seconds. Default is 60 seconds.
disableCertificateValidation
boolIndicates whether to disable certificate validation. Default is false.
configureClient
Action<HttpClient>An optional action to configure the HttpClient.
configureHttpClientBuilder
Action<IHttpClientBuilder>An optional action to configure the IHttpClientBuilder.
Returns
- IServiceCollection
The updated service collection.