Class ServiceObject (3.7.4)

ServiceObject is a base class, meant to be inherited from by a "service object," like a BigQuery dataset or Storage bucket.

Most of the time, these objects share common functionality; they can be created or deleted, and you can get or set their metadata.

By inheriting from this class, a service object will be extended with these shared behaviors. Note that any method can be overridden when the service object requires specific behavior.

Inheritance

EventEmitter > ServiceObject

Package

@google-cloud/common

Constructors

(constructor)(config)

  constructor 
 ( 
 config 
 : 
  
 ServiceObjectConfig 
 ); 
 

Constructs a new instance of the ServiceObject class

Parameter
Name Description
config ServiceObjectConfig

Properties

baseUrl

  baseUrl 
 ?: 
  
 string 
 ; 
 
Property Value
Type Description
string

id

  id 
 ?: 
  
 string 
 ; 
 
Property Value
Type Description
string

interceptors

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

methods

  protected 
  
 methods 
 : 
  
 Methods 
 ; 
 
Property Value
Type Description
Methods

parent

  parent 
 : 
  
 ServiceObjectParent 
 ; 
 
Property Value
Type Description
ServiceObjectParent

pollIntervalMs

  pollIntervalMs 
 ?: 
  
 number 
 ; 
 
Property Value
Type Description
number

Methods

create(options)

  create 
 ( 
 options 
 ?: 
  
 CreateOptions 
 ) 
 : 
  
 Promise<CreateResponse<T> 
> ; 
 

Create the object.

Parameter
Name Description
options CreateOptions

Configuration object.

Returns
Type Description
Promise < CreateResponse <T>>

create(options, callback)

  create 
 ( 
 options 
 : 
  
 CreateOptions 
 , 
  
 callback 
 : 
  
 CreateCallback<T> 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options CreateOptions
callback CreateCallback <T>
Returns
Type Description
void

create(callback)

  create 
 ( 
 callback 
 : 
  
 CreateCallback<T> 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback CreateCallback <T>
Returns
Type Description
void

delete(options)

  delete 
 ( 
 options 
 ?: 
  
 DeleteOptions 
 ) 
 : 
  
 Promise 
< [ 
 r 
 . 
 Response 
 ]>; 
 

Delete the object.

Parameter
Name Description
options DeleteOptions
Returns
Type Description
Promise <[r. Response ]>

delete(options, callback)

  delete 
 ( 
 options 
 : 
  
 DeleteOptions 
 , 
  
 callback 
 : 
  
 DeleteCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options DeleteOptions
callback DeleteCallback
Returns
Type Description
void

delete(callback)

  delete 
 ( 
 callback 
 : 
  
 DeleteCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback DeleteCallback
Returns
Type Description
void

exists(options)

  exists 
 ( 
 options 
 ?: 
  
 ExistsOptions 
 ) 
 : 
  
 Promise 
< [ 
 boolean 
 ]>; 
 

Check if the object exists.

Parameter
Name Description
options ExistsOptions
Returns
Type Description
Promise <[boolean]>

exists(options, callback)

  exists 
 ( 
 options 
 : 
  
 ExistsOptions 
 , 
  
 callback 
 : 
  
 ExistsCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options ExistsOptions
callback ExistsCallback
Returns
Type Description
void

exists(callback)

  exists 
 ( 
 callback 
 : 
  
 ExistsCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback ExistsCallback
Returns
Type Description
void

get(options)

  get 
 ( 
 options 
 ?: 
  
 GetOrCreateOptions 
 ) 
 : 
  
 Promise<GetResponse<T> 
> ; 
 

Get the object if it exists. Optionally have the object created if an options object is provided with autoCreate: true .

Parameter
Name Description
options GetOrCreateOptions

The configuration object that will be used to create the object if necessary.

Returns
Type Description
Promise < GetResponse <T>>

get(callback)

  get 
 ( 
 callback 
 : 
  
 InstanceResponseCallback<T> 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback InstanceResponseCallback <T>
Returns
Type Description
void

get(options, callback)

  get 
 ( 
 options 
 : 
  
 GetOrCreateOptions 
 , 
  
 callback 
 : 
  
 InstanceResponseCallback<T> 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options GetOrCreateOptions
callback InstanceResponseCallback <T>
Returns
Type Description
void
  getMetadata 
 ( 
 options 
 ?: 
  
 GetMetadataOptions 
 ) 
 : 
  
 Promise<MetadataResponse> 
 ; 
 

Get the metadata of this object.

Parameter
Name Description
options GetMetadataOptions
Returns
Type Description
Promise < MetadataResponse >
  getMetadata 
 ( 
 options 
 : 
  
 GetMetadataOptions 
 , 
  
 callback 
 : 
  
 MetadataCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options GetMetadataOptions
callback MetadataCallback
Returns
Type Description
void
  getMetadata 
 ( 
 callback 
 : 
  
 MetadataCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback MetadataCallback
Returns
Type Description
void

getRequestInterceptors()

  getRequestInterceptors 
 () 
 : 
  
 Function 
 []; 
 

Return the user's custom request interceptors.

Returns
Type Description
Function []

request(reqOpts)

  request 
 ( 
 reqOpts 
 : 
  
 DecorateRequestOptions 
 ) 
 : 
  
 Promise<RequestResponse> 
 ; 
 

Make an authenticated API request.

Parameter
Name Description
reqOpts DecorateRequestOptions

Request options that are passed to request .

Returns
Type Description
Promise < RequestResponse >

request(reqOpts, callback)

  request 
 ( 
 reqOpts 
 : 
  
 DecorateRequestOptions 
 , 
  
 callback 
 : 
  
 BodyResponseCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
reqOpts DecorateRequestOptions
callback BodyResponseCallback
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
  setMetadata 
 ( 
 metadata 
 : 
  
 Metadata 
 , 
  
 options 
 ?: 
  
 SetMetadataOptions 
 ) 
 : 
  
 Promise<SetMetadataResponse> 
 ; 
 

Set the metadata for this object.

Parameters
Name Description
metadata Metadata

The metadata to set on this object.

options SetMetadataOptions

Configuration options.

Returns
Type Description
Promise < SetMetadataResponse >
  setMetadata 
 ( 
 metadata 
 : 
  
 Metadata 
 , 
  
 callback 
 : 
  
 MetadataCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
metadata Metadata
callback MetadataCallback
Returns
Type Description
void
  setMetadata 
 ( 
 metadata 
 : 
  
 Metadata 
 , 
  
 options 
 : 
  
 SetMetadataOptions 
 , 
  
 callback 
 : 
  
 MetadataCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
metadata Metadata
options SetMetadataOptions
callback MetadataCallback
Returns
Type Description
void
Create a Mobile Website
View Site in Mobile | Classic
Share by: