Class Service (5.0.1)

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
NameDescription
config ServiceConfig

Configuration object.

options ServiceOptions

[Configuration object](#/docs).

Properties

apiEndpoint

readonly apiEndpoint: string;

authClient

authClient: GoogleAuth;

baseUrl

baseUrl: string;

interceptors

interceptors: Interceptor[];

makeAuthenticatedRequest

makeAuthenticatedRequest: MakeAuthenticatedRequest;

projectId

projectId: string;

providedUserAgent

providedUserAgent?: string;

timeout

timeout?: number;

Methods

getProjectId()

getProjectId(): Promise<string>;

Get and update the Service's project ID.

Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: (err: Error | null, projectId?: string) => void): void;
Parameter
NameDescription
callback (err: Error | null, projectId?: string) => void
Returns
TypeDescription
void

getProjectIdAsync()

protected getProjectIdAsync(): Promise<string>;
Returns
TypeDescription
Promise<string>

getRequestInterceptors()

getRequestInterceptors(): Function[];

Return the user's custom request interceptors.

Returns
TypeDescription
Function[]

request(reqOpts, callback)

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

Make an authenticated API request.

Parameters
NameDescription
reqOpts DecorateRequestOptions

Request options that are passed to request.

callback BodyResponseCallback

The callback function passed to request.

Returns
TypeDescription
void

requestStream(reqOpts)

requestStream(reqOpts: DecorateRequestOptions): r.Request;

Make an authenticated API request.

Parameter
NameDescription
reqOpts DecorateRequestOptions

Request options that are passed to request.

Returns
TypeDescription
r.Request