Send feedback
Class ServiceObject (3.7.4) Stay organized with collections
Save and categorize content based on your preferences.
Version 3.7.4 keyboard_arrow_down
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
Properties
baseUrl
Property Value
id
Property Value
interceptors
interceptors
:
Interceptor
[];
Property Value
Property Value
methods
protected
methods
:
Methods
;
Property Value
parent
parent
:
ServiceObjectParent
;
Property Value
pollIntervalMs
pollIntervalMs
?:
number
;
Property Value
Methods
create(options)
create
(
options
?:
CreateOptions
)
:
Promise<CreateResponse<T>
> ;
Parameter Name
Description
options
CreateOptions
Configuration object.
Returns
create(options, callback)
create
(
options
:
CreateOptions
,
callback
:
CreateCallback<T>
)
:
void
;
Parameters Name
Description
options
CreateOptions
callback
CreateCallback
<T>
Returns
create(callback)
create
(
callback
:
CreateCallback<T>
)
:
void
;
Parameter Name
Description
callback
CreateCallback
<T>
Returns
delete(options)
delete
(
options
?:
DeleteOptions
)
:
Promise
< [
r
.
Response
]>;
Parameter
Returns
delete(options, callback)
delete
(
options
:
DeleteOptions
,
callback
:
DeleteCallback
)
:
void
;
Parameters
Returns
delete(callback)
delete
(
callback
:
DeleteCallback
)
:
void
;
Parameter
Returns
exists(options)
exists
(
options
?:
ExistsOptions
)
:
Promise
< [
boolean
]>;
Check if the object exists.
Parameter
Returns
exists(options, callback)
exists
(
options
:
ExistsOptions
,
callback
:
ExistsCallback
)
:
void
;
Parameters
Returns
exists(callback)
exists
(
callback
:
ExistsCallback
)
:
void
;
Parameter
Returns
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
get(callback)
get
(
callback
:
InstanceResponseCallback<T>
)
:
void
;
Parameter
Returns
get(options, callback)
get
(
options
:
GetOrCreateOptions
,
callback
:
InstanceResponseCallback<T>
)
:
void
;
Parameters
Returns
getMetadata
(
options
?:
GetMetadataOptions
)
:
Promise<MetadataResponse>
;
Get the metadata of this object.
Parameter
Returns
getMetadata
(
options
:
GetMetadataOptions
,
callback
:
MetadataCallback
)
:
void
;
Parameters
Returns
getMetadata
(
callback
:
MetadataCallback
)
:
void
;
Parameter
Returns
getRequestInterceptors()
getRequestInterceptors
()
:
Function
[];
Return the user's custom request interceptors.
Returns
request(reqOpts)
request
(
reqOpts
:
DecorateRequestOptions
)
:
Promise<RequestResponse>
;
Make an authenticated API request.
Parameter
Returns
request(reqOpts, callback)
request
(
reqOpts
:
DecorateRequestOptions
,
callback
:
BodyResponseCallback
)
:
void
;
Parameters
Returns
requestStream(reqOpts)
requestStream
(
reqOpts
:
DecorateRequestOptions
)
:
r
.
Request
;
Make an authenticated API request.
Parameter
Returns
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
setMetadata
(
metadata
:
Metadata
,
callback
:
MetadataCallback
)
:
void
;
Parameters
Returns
setMetadata
(
metadata
:
Metadata
,
options
:
SetMetadataOptions
,
callback
:
MetadataCallback
)
:
void
;
Parameters
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,[]]