Table of Contents

Method AddKepwareApiClient

Namespace
Kepware.Api
Assembly
Kepware.Api.dll

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 IServiceCollection

The service collection to add the client to.

name string

The name of the client.

options KepwareApiClientOptions

The 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 IServiceCollection

The service collection to add the client to.

name string

The name of the client.

baseUrl string

The base URL of the Kepware Configuration API in the format of https://{hostname}:{port} or http://{hostname}:{port}

apiUserName string

The username for authentication.

apiPassword string

The password for authentication.

timeoutInSeconds int

The timeout period for the HTTP client in seconds. Default is 60 seconds.

disableCertificateValidation bool

Indicates 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.