Class Service (3.7.4)

Package

@google-cloud/common

Constructors

(constructor)(config, options)

constructor(config: ServiceConfig, options?: ServiceOptions);

Service is a base class, meant to be inherited from by a "service," like BigQuery or Storage.

This handles making authenticated requests by exposing a makeReq_ function.

module:common/service

Parameters
Name Description
config ServiceConfig

Configuration object.

options ServiceOptions

[Configuration object](#/docs).

Properties

apiEndpoint

readonly apiEndpoint: string;
Property Value
Type Description
string

authClient

authClient: GoogleAuth;
Property Value
Type Description
GoogleAuth

baseUrl

baseUrl: string;
Property Value
Type Description
string

interceptors

interceptors: Interceptor[];
Property Value
Type Description
Interceptor[]

makeAuthenticatedRequest

makeAuthenticatedRequest: MakeAuthenticatedRequest;
Property Value
Type Description
MakeAuthenticatedRequest

projectId

projectId: string;
Property Value
Type Description
string

providedUserAgent

providedUserAgent?: string;
Property Value
Type Description
string

timeout

timeout?: number;
Property Value
Type Description
number

Methods

getProjectId()

getProjectId(): Promise<string>;

Get and update the Service's project ID.

Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: (err: Error | null, projectId?: string) => void): void;
Parameter
Name Description
callback (err: Error | null, projectId?: string) => void
Returns
Type Description
void

getProjectIdAsync()

protected getProjectIdAsync(): Promise<string>;
Returns
Type Description
Promise<string>

getRequestInterceptors()

getRequestInterceptors(): Function[];

Return the user's custom request interceptors.

Returns
Type Description
Function[]

request(reqOpts, callback)

request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;

Make an authenticated API request.

Parameters
Name Description
reqOpts DecorateRequestOptions

Request options that are passed to request.

callback BodyResponseCallback

The callback function passed to request.

Returns
Type Description
void

requestStream(reqOpts)

requestStream(reqOpts: DecorateRequestOptions): r.Request;

Make an authenticated API request.

Parameter
Name Description
reqOpts DecorateRequestOptions

Request options that are passed to request.

Returns
Type Description
r.Request