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
servicesIServiceCollectionnamestring
Returns
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
builderIOpenShellClientBuilder
Returns
BindConfiguration(IOpenShellClientBuilder, IConfiguration)
Binds settings from configuration, for example the OpenShell section.
public static IOpenShellClientBuilder BindConfiguration(this IOpenShellClientBuilder builder, IConfiguration configuration)
Parameters
builderIOpenShellClientBuilderconfigurationIConfiguration
Returns
WithAddress(IOpenShellClientBuilder, string)
Sets the gateway address from an absolute URL.
public static IOpenShellClientBuilder WithAddress(this IOpenShellClientBuilder builder, string address)
Parameters
builderIOpenShellClientBuilderaddressstring
Returns
WithAddress(IOpenShellClientBuilder, Uri)
Sets the gateway address.
public static IOpenShellClientBuilder WithAddress(this IOpenShellClientBuilder builder, Uri address)
Parameters
builderIOpenShellClientBuilderaddressUri
Returns
WithAuth(IOpenShellClientBuilder, IAuthProvider)
Authenticates with a provider built in code.
public static IOpenShellClientBuilder WithAuth(this IOpenShellClientBuilder builder, IAuthProvider auth)
Parameters
builderIOpenShellClientBuilderauthIAuthProvider
Returns
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
builderIOpenShellClientBuildercreateFunc<IServiceProvider, IAuthProvider>
Returns
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
builderIOpenShellClientBuildertokenstring
Returns
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
builderIOpenShellClientBuilderpemPathstring
Returns
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
builderIOpenShellClientBuildercertificatePathstringkeyPathstring
Returns
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
builderIOpenShellClientBuilderoptionsFunc<IServiceProvider, OidcOptions>
Returns
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
builderIOpenShellClientBuilderissuerstringclientIdstringsecretProviderFunc<CancellationToken, ValueTask<string>>scopesstring[]
Returns
WithInsecureTls(IOpenShellClientBuilder)
Disables server certificate validation. Development only.
public static IOpenShellClientBuilder WithInsecureTls(this IOpenShellClientBuilder builder)
Parameters
builderIOpenShellClientBuilder
Returns
WithRetry(IOpenShellClientBuilder, Action<RetryOptions>)
Adjusts the retry settings; unset values keep their defaults.
public static IOpenShellClientBuilder WithRetry(this IOpenShellClientBuilder builder, Action<RetryOptions> configure)
Parameters
builderIOpenShellClientBuilderconfigureAction<RetryOptions>
Returns
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
builderIOpenShellClientBuildertimeoutTimeSpan
Returns
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
builderIOpenShellClientBuildertlsTlsOptions
Returns
WithWorkspace(IOpenShellClientBuilder, string)
Sets the workspace used when a call does not name one.
public static IOpenShellClientBuilder WithWorkspace(this IOpenShellClientBuilder builder, string workspace)
Parameters
builderIOpenShellClientBuilderworkspacestring
Returns
WithoutRetry(IOpenShellClientBuilder)
Turns retries off.
public static IOpenShellClientBuilder WithoutRetry(this IOpenShellClientBuilder builder)
Parameters
builderIOpenShellClientBuilder