Table of Contents

Class OpenShellClientBuilderExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
OpenShell.Sdk.DependencyInjection.dll

Entry point and fluent settings for the builder-style registration.

public static class OpenShellClientBuilderExtensions
Inheritance
OpenShellClientBuilderExtensions
Inherited Members

Methods

AddOpenShellClient(IServiceCollection, string?)

Registers a gateway and returns a builder for it. Omit name for the default gateway; a name registers a keyed IOpenShellClient and makes it available from IOpenShellClientFactory.

public static IOpenShellClientBuilder AddOpenShellClient(this IServiceCollection services, string? name = null)

Parameters

services IServiceCollection
name string

Returns

IOpenShellClientBuilder

AllowInsecureAuth(IOpenShellClientBuilder)

Permits credentials over plaintext http:// to a non-loopback host. They cross the network in the clear.

public static IOpenShellClientBuilder AllowInsecureAuth(this IOpenShellClientBuilder builder)

Parameters

builder IOpenShellClientBuilder

Returns

IOpenShellClientBuilder

BindConfiguration(IOpenShellClientBuilder, IConfiguration)

Binds settings from configuration, for example the OpenShell section.

public static IOpenShellClientBuilder BindConfiguration(this IOpenShellClientBuilder builder, IConfiguration configuration)

Parameters

builder IOpenShellClientBuilder
configuration IConfiguration

Returns

IOpenShellClientBuilder

WithAddress(IOpenShellClientBuilder, string)

Sets the gateway address from an absolute URL.

public static IOpenShellClientBuilder WithAddress(this IOpenShellClientBuilder builder, string address)

Parameters

builder IOpenShellClientBuilder
address string

Returns

IOpenShellClientBuilder

WithAddress(IOpenShellClientBuilder, Uri)

Sets the gateway address.

public static IOpenShellClientBuilder WithAddress(this IOpenShellClientBuilder builder, Uri address)

Parameters

builder IOpenShellClientBuilder
address Uri

Returns

IOpenShellClientBuilder

WithAuth(IOpenShellClientBuilder, IAuthProvider)

Authenticates with a provider built in code.

public static IOpenShellClientBuilder WithAuth(this IOpenShellClientBuilder builder, IAuthProvider auth)

Parameters

builder IOpenShellClientBuilder
auth IAuthProvider

Returns

IOpenShellClientBuilder

WithAuth(IOpenShellClientBuilder, Func<IServiceProvider, IAuthProvider>)

Authenticates with a provider that needs other registered services.

public static IOpenShellClientBuilder WithAuth(this IOpenShellClientBuilder builder, Func<IServiceProvider, IAuthProvider> create)

Parameters

builder IOpenShellClientBuilder
create Func<IServiceProvider, IAuthProvider>

Returns

IOpenShellClientBuilder

WithBearerToken(IOpenShellClientBuilder, string)

Authenticates with a fixed bearer token. Prefer WithClientCredentials(IOpenShellClientBuilder, Func<IServiceProvider, OidcOptions>) for tokens that expire.

public static IOpenShellClientBuilder WithBearerToken(this IOpenShellClientBuilder builder, string token)

Parameters

builder IOpenShellClientBuilder
token string

Returns

IOpenShellClientBuilder

WithCaCertificate(IOpenShellClientBuilder, string)

Trusts the CA certificates in a PEM file instead of the system roots.

public static IOpenShellClientBuilder WithCaCertificate(this IOpenShellClientBuilder builder, string pemPath)

Parameters

builder IOpenShellClientBuilder
pemPath string

Returns

IOpenShellClientBuilder

WithClientCertificate(IOpenShellClientBuilder, string, string?)

Authenticates with a client certificate (mTLS). Omit keyPath when the key is in the certificate file.

public static IOpenShellClientBuilder WithClientCertificate(this IOpenShellClientBuilder builder, string certificatePath, string? keyPath = null)

Parameters

builder IOpenShellClientBuilder
certificatePath string
keyPath string

Returns

IOpenShellClientBuilder

WithClientCredentials(IOpenShellClientBuilder, Func<IServiceProvider, OidcOptions>)

Authenticates with the OAuth2 client-credentials grant, renewing the token before it expires. The provider is a container singleton, so it is disposed with the container.

public static IOpenShellClientBuilder WithClientCredentials(this IOpenShellClientBuilder builder, Func<IServiceProvider, OidcOptions> options)

Parameters

builder IOpenShellClientBuilder
options Func<IServiceProvider, OidcOptions>

Returns

IOpenShellClientBuilder

WithClientCredentials(IOpenShellClientBuilder, string, string, Func<CancellationToken, ValueTask<string>>, params string[])

Authenticates with client credentials, reading the secret from secretProvider on every renewal.

public static IOpenShellClientBuilder WithClientCredentials(this IOpenShellClientBuilder builder, string issuer, string clientId, Func<CancellationToken, ValueTask<string>> secretProvider, params string[] scopes)

Parameters

builder IOpenShellClientBuilder
issuer string
clientId string
secretProvider Func<CancellationToken, ValueTask<string>>
scopes string[]

Returns

IOpenShellClientBuilder

WithInsecureTls(IOpenShellClientBuilder)

Disables server certificate validation. Development only.

public static IOpenShellClientBuilder WithInsecureTls(this IOpenShellClientBuilder builder)

Parameters

builder IOpenShellClientBuilder

Returns

IOpenShellClientBuilder

WithRetry(IOpenShellClientBuilder, Action<RetryOptions>)

Adjusts the retry settings; unset values keep their defaults.

public static IOpenShellClientBuilder WithRetry(this IOpenShellClientBuilder builder, Action<RetryOptions> configure)

Parameters

builder IOpenShellClientBuilder
configure Action<RetryOptions>

Returns

IOpenShellClientBuilder

WithTimeout(IOpenShellClientBuilder, TimeSpan)

Applies a deadline to unary calls that do not set their own.

public static IOpenShellClientBuilder WithTimeout(this IOpenShellClientBuilder builder, TimeSpan timeout)

Parameters

builder IOpenShellClientBuilder
timeout TimeSpan

Returns

IOpenShellClientBuilder

WithTls(IOpenShellClientBuilder, TlsOptions)

Uses TLS settings built in code. They take precedence over the certificate paths.

public static IOpenShellClientBuilder WithTls(this IOpenShellClientBuilder builder, TlsOptions tls)

Parameters

builder IOpenShellClientBuilder
tls TlsOptions

Returns

IOpenShellClientBuilder

WithWorkspace(IOpenShellClientBuilder, string)

Sets the workspace used when a call does not name one.

public static IOpenShellClientBuilder WithWorkspace(this IOpenShellClientBuilder builder, string workspace)

Parameters

builder IOpenShellClientBuilder
workspace string

Returns

IOpenShellClientBuilder

WithoutRetry(IOpenShellClientBuilder)

Turns retries off.

public static IOpenShellClientBuilder WithoutRetry(this IOpenShellClientBuilder builder)

Parameters

builder IOpenShellClientBuilder

Returns

IOpenShellClientBuilder