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
servicesIServiceCollectionThe service collection to add the client to.
namestringThe name of the client.
optionsKepwareApiClientOptionsThe 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
servicesIServiceCollectionThe service collection to add the client to.
namestringThe name of the client.
baseUrlstringThe base URL of the Kepware Configuration API in the format of https://{hostname}:{port} or http://{hostname}:{port}
apiUserNamestringThe username for authentication.
apiPasswordstringThe password for authentication.
timeoutInSecondsintThe timeout period for the HTTP client in seconds. Default is 60 seconds.
disableCertificateValidationboolIndicates whether to disable certificate validation. Default is false.
configureClientAction<HttpClient>An optional action to configure the HttpClient.
configureHttpClientBuilderAction<IHttpClientBuilder>An optional action to configure the IHttpClientBuilder.
Returns
- IServiceCollection
The updated service collection.