Show / Hide Table of Contents

Class BaseClientService

A base class for a client service which provides common mechanism for all services, like serialization and GZip support. It should be safe to use a single service instance to make server requests concurrently from multiple threads. This class adds a special Google.Apis.Http.IHttpExecuteInterceptor to the Google.Apis.Http.ConfigurableMessageHandler execute interceptor list, which uses the given Authenticator. It calls to its applying authentication method, and injects the "Authorization" header in the request. If the given Authenticator implements Google.Apis.Http.IHttpUnsuccessfulResponseHandler, this class adds the Authenticator to the Google.Apis.Http.ConfigurableMessageHandler's unsuccessful response handler list.

Inheritance
object
BaseClientService
Implements
IClientService
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Google.Apis.Services
Assembly: Google.Apis.dll
Syntax
public abstract class BaseClientService : IClientService, IDisposable

Constructors

BaseClientService(Initializer)

Constructs a new base client with the specified initializer.

Declaration
protected BaseClientService(BaseClientService.Initializer initializer)
Parameters
Type Name Description
BaseClientService.Initializer initializer

Fields

DefaultMaxUrlLength

The default maximum allowed length of a URL string for GET requests.

Declaration
public const uint DefaultMaxUrlLength = 2048
Field Value
Type Description
uint

Properties

ApiKey

Gets the API-Key (DeveloperKey) which this service uses for all requests.

Declaration
public string ApiKey { get; }
Property Value
Type Description
string

ApplicationName

Gets the application name to be used in the User-Agent header.

Declaration
public string ApplicationName { get; }
Property Value
Type Description
string

BasePath

Gets the BasePath of the service.

Declaration
public abstract string BasePath { get; }
Property Value
Type Description
string

BaseUri

Gets the BaseUri of the service. All request paths should be relative to this URI.

Declaration
public abstract string BaseUri { get; }
Property Value
Type Description
string

BaseUriOverride

The BaseUri provided in the initializer, which may be null.

Declaration
protected string BaseUriOverride { get; }
Property Value
Type Description
string

BatchPath

The path used for batch operations.

Declaration
public virtual string BatchPath { get; }
Property Value
Type Description
string

BatchUri

The URI used for batch operations.

Declaration
public virtual string BatchUri { get; }
Property Value
Type Description
string

Features

Gets the supported features by this service.

Declaration
public abstract IList<string> Features { get; }
Property Value
Type Description
IList<string>

GZipEnabled

Gets or sets whether this service supports GZip.

Declaration
public bool GZipEnabled { get; }
Property Value
Type Description
bool

HttpClient

Gets the HTTP client which is used to create requests.

Declaration
public ConfigurableHttpClient HttpClient { get; }
Property Value
Type Description
ConfigurableHttpClient

HttpClientInitializer

Gets a HTTP client initializer which is able to custom properties on Google.Apis.Http.ConfigurableHttpClient and Google.Apis.Http.ConfigurableMessageHandler.

Declaration
public IConfigurableHttpClientInitializer HttpClientInitializer { get; }
Property Value
Type Description
IConfigurableHttpClientInitializer

HttpClientTimeout

The timeout to set on HttpClient instances used by the service. May be null, in which case the default timeout values on HttpClient instances used by this service will be left unchanged.

Declaration
public TimeSpan? HttpClientTimeout { get; }
Property Value
Type Description
TimeSpan?

Name

Gets the service name.

Declaration
public abstract string Name { get; }
Property Value
Type Description
string

Serializer

Gets the Serializer used by this service.

Declaration
public ISerializer Serializer { get; }
Property Value
Type Description
ISerializer

UniverseDomain

The universe domain to connect to, or null to use the default universe domain, which may be configured via the UniverseDomainEnvironmentVariable .

Declaration
public string UniverseDomain { get; set; }
Property Value
Type Description
string
Remarks

UniverseDomain is used to build the endpoint to connect to, unless BaseUriOverride is set, in which case BaseUriOverride will be used without further modification.

Methods

CreateBackOffHandler()

Creates the back-off handler with Google.Apis.Util.ExponentialBackOff. Overrides this method to change the default behavior of back-off handler (e.g. you can change the maximum waited request's time span, or create a back-off handler with you own implementation of Google.Apis.Util.IBackOff).

Declaration
protected virtual BackOffHandler CreateBackOffHandler()
Returns
Type Description
BackOffHandler

DeserializeError(HttpResponseMessage)

Deserializes an error response into a Google.Apis.Requests.RequestError object.

Declaration
public virtual Task<RequestError> DeserializeError(HttpResponseMessage response)
Parameters
Type Name Description
HttpResponseMessage response
Returns
Type Description
Task<RequestError>
Exceptions
Type Condition
GoogleApiException

If no error is found in the response.

DeserializeResponse<T>(HttpResponseMessage)

Deserializes a response into the specified object.

Declaration
public virtual Task<T> DeserializeResponse<T>(HttpResponseMessage response)
Parameters
Type Name Description
HttpResponseMessage response
Returns
Type Description
Task<T>
Type Parameters
Name Description
T

Dispose()

Declaration
public virtual void Dispose()

GetEffectiveUri(string, string)

Gets the effective URI taking into account the UniverseDomain and the value of the UniverseDomainEnvironmentVariable.

Declaration
protected string GetEffectiveUri(string explicitUri, string defaultUri)
Parameters
Type Name Description
string explicitUri

An explicit URI. May be null.

string defaultUri

A default URI. May be null.

Returns
Type Description
string
  • explicitUri if not null.
  • Otherwise, if EffectiveConfiguredUniverseDomain is not null, the result of replacing DefaultUniverseDomain with EffectiveConfiguredUniverseDomain in defaultUri.

SerializeObject(object)

Serializes an object into a string representation.

Declaration
public virtual string SerializeObject(object obj)
Parameters
Type Name Description
object obj
Returns
Type Description
string

SetRequestSerailizedContent(HttpRequestMessage, object)

Sets the content of the request by the given body and the this service's configuration. First the body object is serialized by the Serializer and then, if GZip is enabled, the content will be wrapped in a GZip stream, otherwise a regular string stream will be used.

Declaration
public void SetRequestSerailizedContent(HttpRequestMessage request, object body)
Parameters
Type Name Description
HttpRequestMessage request
object body

Implements

IClientService
IDisposable
In this article
Back to top Generated by DocFX