operation.d.ts
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*!
* @module common/operation
*/
import { MetadataCallback, ServiceObject, ServiceObjectConfig } from './service-object';
export declare class Operation<T = any> extends ServiceObject<T> {
completeListeners: number;
hasActiveListeners: boolean;
/**
* An Operation object allows you to interact with APIs that take longer to
* process things.
*
* @constructor
* @alias module:common/operation
*
* @param {object} config - Configuration object.
* @param {module:common/service|module:common/serviceObject|module:common/grpcService|module:common/grpcServiceObject} config.parent - The parent object.
*/
constructor(config: ServiceObjectConfig);
/**
* Wraps the `complete` and `error` events in a Promise.
*
* @return {Promise}
*/
promise(): Promise<unknown>;
/**
* Begin listening for events on the operation. This method keeps track of how
* many "complete" listeners are registered and removed, making sure polling
* is handled automatically.
*
* As long as there is one active "complete" listener, the connection is open.
* When there are no more listeners, the polling stops.
*
* @private
*/
protected listenForEvents_(): void;
/**
* Poll for a status update. Returns null for an incomplete
* status, and metadata for a complete status.
*
* @private
*/
protected poll_(callback: MetadataCallback): void;
/**
* Poll `getMetadata` to check the operation's status. This runs a loop to
* ping the API on an interval.
*
* Note: This method is automatically called once a "complete" event handler
* is registered on the operation.
*
* @private
*/
protected startPolling_(): Promise<void>;
}