Class GrpcChannelFactory

Namespace: ArmoniK.Api.Client.Submitter
Assembly: ArmoniK.Api.Client.dll

Factory for creating a secure GrpcChannel

[PublicAPI]
public static class GrpcChannelFactory

Inheritance

objectGrpcChannelFactory

Inherited Members

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object, object), object.ToString()

Methods

CreateChannel(GrpcClient, ILogger?, ILoggerFactory?)

Creates the GrpcChannel

public static GrpcChannel CreateChannel(GrpcClient optionsGrpcClient, ILogger? logger = null, ILoggerFactory? loggerFactory = null)

Parameters

optionsGrpcClient GrpcClient

Options for the creation of the channel

logger ILogger?

Optional logger

loggerFactory ILoggerFactory?

Optional loggerFactory

Returns

GrpcChannel

The initialized GrpcChannel

Exceptions

InvalidOperationException

Endpoint passed through options is missing

CreateChannelAsync(GrpcClient, ILogger?, ILoggerFactory?, CancellationToken)

Creates the GrpcChannel

public static Task<GrpcChannel> CreateChannelAsync(GrpcClient optionsGrpcClient, ILogger? logger = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)

Parameters

optionsGrpcClient GrpcClient

Options for the creation of the channel

logger ILogger?

Optional logger

loggerFactory ILoggerFactory?

Optional loggerFactory

cancellationToken CancellationToken

Cancellation token

Returns

Task<GrpcChannel>

The initialized GrpcChannel

Exceptions

InvalidOperationException

Endpoint passed through options is missing

GetCertificate(GrpcClient)

Get the certificate in PFX format from the given options. Loads the certificate file directly if optionsGrpcClient.CertP12.CertP12 is specified, otherwise creates it from the pem formatted files optionsGrpcClient.CertPem.CertPem and optionsGrpcClient.KeyPem.KeyPem

public static X509Certificate2 GetCertificate(GrpcClient optionsGrpcClient)

Parameters

optionsGrpcClient GrpcClient

Client option

Returns

X509Certificate2

The PFX formatted client certificate

Exceptions

FileNotFoundException

The P12 certificate is specified but not found, or either the Pem cert or key are not found

InvalidOperationException

No certificate was specified in options

CryptographicException

The key could not be retrieved from the key file