Send feedback
Class ServiceObject (3.10.0)
Stay organized with collections
Save and categorize content based on your preferences.
Version 3.10.0 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
id
interceptors
interceptors : Interceptor [];
methods
protected methods : Methods ;
parent
parent : ServiceObjectParent ;
pollIntervalMs
projectId
Methods
create(options)
create(options?: CreateOptions): Promise<CreateResponse<T>>;
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
create(callback)
create ( callback : CreateCallback<T> ): void ;
Parameter
Name Description callback
CreateCallback <T>
Returns
delete(options)
delete(options?: DeleteOptions): Promise<[r.Response]>;
Parameter
Name Description options
DeleteOptions
Returns
Type Description Promise <[r.Response ]>
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
Name Description options
ExistsOptions
Returns
Type Description Promise <[boolean]>
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
Type Description Promise <GetResponse <T>>
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
Name Description options
GetMetadataOptions
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
Type Description Function []
request(reqOpts)
request ( reqOpts : DecorateRequestOptions ): Promise<RequestResponse> ;
Make an authenticated API request.
Parameter
Returns
Type Description Promise <RequestResponse >
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 2024-09-10 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-09-10 UTC."}