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 > ServiceObjectPackage
@google-cloud/commonConstructors
(constructor)(config)
constructor
(
config
:
ServiceObjectConfig
);
Constructs a new instance of the ServiceObject
class
Properties
baseUrl
baseUrl
?:
string
;
id
id
?:
string
;
interceptors
interceptors
:
Interceptor
[];
metadata
metadata
:
Metadata
;
methods
protected
methods
:
Methods
;
parent
parent
:
ServiceObjectParent
;
pollIntervalMs
pollIntervalMs
?:
number
;
Methods
create(options)
create
(
options
?:
CreateOptions
)
:
Promise<CreateResponse<T>
> ;
Create the object.
options
CreateOptions
Configuration object.
Promise
< CreateResponse
<T>>
create(options, callback)
create
(
options
:
CreateOptions
,
callback
:
CreateCallback<T>
)
:
void
;
options
CreateOptions
callback
CreateCallback
<T>
void
create(callback)
create
(
callback
:
CreateCallback<T>
)
:
void
;
callback
CreateCallback
<T>
void
delete(options)
delete
(
options
?:
DeleteOptions
)
:
Promise
< [
r
.
Response
]>;
Delete the object.
options
DeleteOptions
Promise
<[r. Response
]>
delete(options, callback)
delete
(
options
:
DeleteOptions
,
callback
:
DeleteCallback
)
:
void
;
void
delete(callback)
delete
(
callback
:
DeleteCallback
)
:
void
;
void
exists(options)
exists
(
options
?:
ExistsOptions
)
:
Promise
< [
boolean
]>;
Check if the object exists.
options
ExistsOptions
Promise
<[boolean]>
exists(options, callback)
exists
(
options
:
ExistsOptions
,
callback
:
ExistsCallback
)
:
void
;
void
exists(callback)
exists
(
callback
:
ExistsCallback
)
:
void
;
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
.
options
GetOrCreateOptions
The configuration object that will be used to create the object if necessary.
Promise
< GetResponse
<T>>
get(callback)
get
(
callback
:
InstanceResponseCallback<T>
)
:
void
;
void
get(options, callback)
get
(
options
:
GetOrCreateOptions
,
callback
:
InstanceResponseCallback<T>
)
:
void
;
void
getMetadata(options)
getMetadata
(
options
?:
GetMetadataOptions
)
:
Promise<MetadataResponse>
;
Get the metadata of this object.
options
GetMetadataOptions
getMetadata(options, callback)
getMetadata
(
options
:
GetMetadataOptions
,
callback
:
MetadataCallback
)
:
void
;
void
getMetadata(callback)
getMetadata
(
callback
:
MetadataCallback
)
:
void
;
void
getRequestInterceptors()
getRequestInterceptors
()
:
Function
[];
Return the user's custom request interceptors.
Function
[]
request(reqOpts)
request
(
reqOpts
:
DecorateRequestOptions
)
:
Promise<RequestResponse>
;
Make an authenticated API request.
reqOpts
Promise
< RequestResponse
>
request(reqOpts, callback)
request
(
reqOpts
:
DecorateRequestOptions
,
callback
:
BodyResponseCallback
)
:
void
;
void
requestStream(reqOpts)
requestStream
(
reqOpts
:
DecorateRequestOptions
)
:
r
.
Request
;
Make an authenticated API request.
reqOpts
r. Request
setMetadata(metadata, options)
setMetadata
(
metadata
:
Metadata
,
options
?:
SetMetadataOptions
)
:
Promise<SetMetadataResponse>
;
Set the metadata for this object.
metadata
options
SetMetadataOptions
Configuration options.
setMetadata(metadata, callback)
setMetadata
(
metadata
:
Metadata
,
callback
:
MetadataCallback
)
:
void
;
void
setMetadata(metadata, options, callback)
setMetadata
(
metadata
:
Metadata
,
options
:
SetMetadataOptions
,
callback
:
MetadataCallback
)
:
void
;
void