Class ClientBuilderBase<TClient>

public abstract class ClientBuilderBase<TClient>

Base class for API-specific builders.

Inheritance

Object > ClientBuilderBase<TClient>

Namespace

Google.Api.Gax.Rest

Assembly

Google.Api.Gax.Rest.dll

Type Parameter

NameDescription
TClient

The type of client created by this builder.

Constructors

ClientBuilderBase()

protected ClientBuilderBase()

Creates a new instance with no settings.

Properties

ApiKey

public string ApiKey { get; set; }

An API key to use instead of a regular credential. If this is non-null and no other credentials are supplied, it will be used as the only credentials. If other credentials are supplied (such as through CredentialsPath) then the two values will both be used together.

Property Value
TypeDescription
String

ApplicationName

public string ApplicationName { get; set; }

A custom application name to use for this client, or null to use the default application name.

Property Value
TypeDescription
String

BaseUri

public string BaseUri { get; set; }

A custom base URI for the service, or null to use the default URI.

Property Value
TypeDescription
String

Credential

public ICredential Credential { get; set; }

The credential to use for authentication. This cannot be specified alongside other authentication properties. Note that scopes are not automatically applied to this credential; if a scoped credential is required, the scoping must be applied by the calling code.

Property Value
TypeDescription
ICredential

CredentialsPath

public string CredentialsPath { get; set; }

The path to the credentials file to use, or null if credentials are being provided in a different way. The resulting credential is automatically scoped with the default scopes for the API.

Property Value
TypeDescription
String

JsonCredentials

public string JsonCredentials { get; set; }

The credentials to use as a JSON string, or null if credentials are being provided in a different way. The resulting credential is automatically scoped with the default scopes for the API.

Property Value
TypeDescription
String

QuotaProject

public string QuotaProject { get; set; }

The GCP project ID that should be used for quota and billing purposes. May be null.

Property Value
TypeDescription
String

Methods

Build()

public abstract TClient Build()

Builds the resulting client.

Returns
TypeDescription
TClient

BuildAsync(CancellationToken)

public abstract Task<TClient> BuildAsync(CancellationToken cancellationToken = default(CancellationToken))

Builds the resulting client asynchronously.

Parameter
TypeNameDescription
CancellationTokencancellationToken
Returns
TypeDescription
Task<TClient>

CreateServiceInitializer()

protected virtual BaseClientService.Initializer CreateServiceInitializer()

Creates an initializer for the service. This method does not perform any validation.

Returns
TypeDescription
BaseClientService.Initializer

An initializer for the service.

CreateServiceInitializerAsync(CancellationToken)

protected virtual Task<BaseClientService.Initializer> CreateServiceInitializerAsync(CancellationToken cancellationToken)

Creates an initializer for the service asynchronously. This method does not perform any validation.

Parameter
TypeNameDescription
CancellationTokencancellationToken
Returns
TypeDescription
Task<BaseClientService.Initializer>

An initializer for the service.

GetDefaultApplicationName()

protected abstract string GetDefaultApplicationName()

Returns the default application name, used if no custom name is otherwise specified.

Returns
TypeDescription
String

GetHttpClientInitializer()

protected virtual IConfigurableHttpClientInitializer GetHttpClientInitializer()

Obtains credentials synchronously. Override this method in a concrete builder type if more credential mechanisms are supported.

Returns
TypeDescription
IConfigurableHttpClientInitializer

GetHttpClientInitializerAsync(CancellationToken)

protected virtual Task<IConfigurableHttpClientInitializer> GetHttpClientInitializerAsync(CancellationToken cancellationToken)

Obtains credentials asynchronously. Override this method in a concrete builder type if more credential mechanisms are supported.

Parameter
TypeNameDescription
CancellationTokencancellationToken
Returns
TypeDescription
Task<IConfigurableHttpClientInitializer>

GetScopedCredentialProvider()

protected abstract ScopedCredentialProvider GetScopedCredentialProvider()

Returns the scoped credential provider for this builder.

Returns
TypeDescription
ScopedCredentialProvider

Validate()

protected virtual void Validate()

Validates that the builder is in a consistent state for building. For example, it's invalid to call Build() on an instance which has both JSON credentials and a credentials path specified.

Exceptions
TypeCondition
InvalidOperationException

The builder is in an invalid state.

ValidateAtMostOneNotNull(String, Object[])

protected void ValidateAtMostOneNotNull(string message, params object[] values)

Validates that at most one of the given values is not null.

Parameters
TypeNameDescription
Stringmessage

The message if the condition is violated.

Object[]values

The values to check for nullity.

Exceptions
TypeCondition
InvalidOperationException

More than one value is null.