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