@google-cloud/pubsub 2.18.1 → 2.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +5 -5
- package/build/protos/protos.d.ts +1 -1
- package/build/protos/protos.js +1 -1
- package/build/src/iam.d.ts +180 -0
- package/build/src/iam.js +2 -172
- package/build/src/iam.js.map +1 -1
- package/build/src/index.d.ts +12 -4
- package/build/src/index.js +12 -4
- package/build/src/index.js.map +1 -1
- package/build/src/message-stream.d.ts +0 -7
- package/build/src/message-stream.js +6 -17
- package/build/src/message-stream.js.map +1 -1
- package/build/src/publisher/flow-publisher.d.ts +6 -0
- package/build/src/publisher/flow-publisher.js +6 -0
- package/build/src/publisher/flow-publisher.js.map +1 -1
- package/build/src/publisher/index.d.ts +35 -0
- package/build/src/publisher/index.js +0 -35
- package/build/src/publisher/index.js.map +1 -1
- package/build/src/pubsub.d.ts +354 -4
- package/build/src/pubsub.js +28 -322
- package/build/src/pubsub.js.map +1 -1
- package/build/src/schema.d.ts +9 -4
- package/build/src/schema.js +9 -4
- package/build/src/schema.js.map +1 -1
- package/build/src/snapshot.d.ts +87 -0
- package/build/src/snapshot.js +2 -79
- package/build/src/snapshot.js.map +1 -1
- package/build/src/subscriber.d.ts +6 -0
- package/build/src/subscriber.js +6 -0
- package/build/src/subscriber.js.map +1 -1
- package/build/src/subscription.d.ts +439 -9
- package/build/src/subscription.js +24 -400
- package/build/src/subscription.js.map +1 -1
- package/build/src/topic.d.ts +467 -2
- package/build/src/topic.js +17 -417
- package/build/src/topic.js.map +1 -1
- package/build/src/v1/index.js +1 -1
- package/build/src/v1/publisher_client.d.ts +246 -15
- package/build/src/v1/publisher_client.js +19 -265
- package/build/src/v1/publisher_client.js.map +1 -1
- package/build/src/v1/publisher_client_config.json +2 -2
- package/build/src/v1/schema_service_client.d.ts +151 -5
- package/build/src/v1/schema_service_client.js +7 -158
- package/build/src/v1/schema_service_client.js.map +1 -1
- package/build/src/v1/subscriber_client.d.ts +536 -16
- package/build/src/v1/subscriber_client.js +15 -553
- package/build/src/v1/subscriber_client.js.map +1 -1
- package/package.json +6 -6
|
@@ -123,7 +123,8 @@ export declare type DetachSubscriptionResponse = EmptyResponse;
|
|
|
123
123
|
* @param {string} name The name of the subscription.
|
|
124
124
|
* @param {SubscriberOptions} [options] Options for handling messages.
|
|
125
125
|
*
|
|
126
|
-
* @example
|
|
126
|
+
* @example From {@link PubSub#getSubscriptions}
|
|
127
|
+
* ```
|
|
127
128
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
128
129
|
* const pubsub = new PubSub();
|
|
129
130
|
*
|
|
@@ -131,26 +132,32 @@ export declare type DetachSubscriptionResponse = EmptyResponse;
|
|
|
131
132
|
* // `subscriptions` is an array of Subscription objects.
|
|
132
133
|
* });
|
|
133
134
|
*
|
|
134
|
-
*
|
|
135
|
+
* ```
|
|
136
|
+
* @example From {@link Topic#getSubscriptions}
|
|
137
|
+
* ```
|
|
135
138
|
* const topic = pubsub.topic('my-topic');
|
|
136
139
|
* topic.getSubscriptions((err, subscriptions) => {
|
|
137
140
|
* // `subscriptions` is an array of Subscription objects.
|
|
138
141
|
* });
|
|
139
142
|
*
|
|
140
|
-
*
|
|
143
|
+
* ```
|
|
144
|
+
* @example {@link Topic#createSubscription}
|
|
145
|
+
* ```
|
|
141
146
|
* const topic = pubsub.topic('my-topic');
|
|
142
147
|
* topic.createSubscription('new-subscription', (err, subscription) => {
|
|
143
148
|
* // `subscription` is a Subscription object.
|
|
144
149
|
* });
|
|
145
150
|
*
|
|
146
|
-
*
|
|
151
|
+
* ```
|
|
152
|
+
* @example {@link Topic#subscription}
|
|
153
|
+
* ```
|
|
147
154
|
* const topic = pubsub.topic('my-topic');
|
|
148
155
|
* const subscription = topic.subscription('my-subscription');
|
|
149
156
|
* // `subscription` is a Subscription object.
|
|
150
157
|
*
|
|
151
|
-
*
|
|
152
|
-
* to register listeners. This will automatically trigger pulling for messages.
|
|
153
|
-
*
|
|
158
|
+
* ```
|
|
159
|
+
* @example Once you have obtained a subscription object, you may begin to register listeners. This will automatically trigger pulling for messages.
|
|
160
|
+
* ```
|
|
154
161
|
* // Register an error handler.
|
|
155
162
|
* subscription.on('error', (err) => {});
|
|
156
163
|
*
|
|
@@ -179,8 +186,9 @@ export declare type DetachSubscriptionResponse = EmptyResponse;
|
|
|
179
186
|
* // Remove the listener from receiving `message` events.
|
|
180
187
|
* subscription.removeListener('message', onMessage);
|
|
181
188
|
*
|
|
182
|
-
*
|
|
183
|
-
* following configuration
|
|
189
|
+
* ```
|
|
190
|
+
* @example To apply a fine level of flow control, consider the following configuration
|
|
191
|
+
* ```
|
|
184
192
|
* const subscription = topic.subscription('my-sub', {
|
|
185
193
|
* flowControl: {
|
|
186
194
|
* maxMessages: 1,
|
|
@@ -188,6 +196,7 @@ export declare type DetachSubscriptionResponse = EmptyResponse;
|
|
|
188
196
|
* allowExcessMessages: false
|
|
189
197
|
* }
|
|
190
198
|
* });
|
|
199
|
+
* ```
|
|
191
200
|
*/
|
|
192
201
|
export declare class Subscription extends EventEmitter {
|
|
193
202
|
pubsub: PubSub;
|
|
@@ -208,27 +217,367 @@ export declare class Subscription extends EventEmitter {
|
|
|
208
217
|
* @type {string}
|
|
209
218
|
*/
|
|
210
219
|
get projectId(): string;
|
|
220
|
+
/**
|
|
221
|
+
* Closes the Subscription, once this is called you will no longer receive
|
|
222
|
+
* message events unless you call {Subscription#open} or add new message
|
|
223
|
+
* listeners.
|
|
224
|
+
*
|
|
225
|
+
* @param {function} [callback] The callback function.
|
|
226
|
+
* @param {?error} callback.err An error returned while closing the
|
|
227
|
+
* Subscription.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```
|
|
231
|
+
* subscription.close(err => {
|
|
232
|
+
* if (err) {
|
|
233
|
+
* // Error handling omitted.
|
|
234
|
+
* }
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // If the callback is omitted a Promise will be returned.
|
|
238
|
+
* subscription.close().then(() => {});
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
211
241
|
close(): Promise<void>;
|
|
212
242
|
close(callback: SubscriptionCloseCallback): void;
|
|
243
|
+
/**
|
|
244
|
+
* Create a subscription.
|
|
245
|
+
*
|
|
246
|
+
* @see [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create}
|
|
247
|
+
*
|
|
248
|
+
* @throws {Error} If subscription name is omitted.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} name The name of the subscription.
|
|
251
|
+
* @param {CreateSubscriptionRequest} [options] See a
|
|
252
|
+
* [Subscription
|
|
253
|
+
* resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions).
|
|
254
|
+
* @param {CreateSubscriptionCallback} [callback] Callback function.
|
|
255
|
+
* @returns {Promise<CreateSubscriptionResponse>}
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```
|
|
259
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
260
|
+
* const pubsub = new PubSub();
|
|
261
|
+
*
|
|
262
|
+
* const topic = pubsub.topic('my-topic');
|
|
263
|
+
* const subscription = topic.subscription('newMessages');
|
|
264
|
+
* const callback = function(err, subscription, apiResponse) {};
|
|
265
|
+
*
|
|
266
|
+
* subscription.create(callback);
|
|
267
|
+
*
|
|
268
|
+
* ```
|
|
269
|
+
* @example With options
|
|
270
|
+
* ```
|
|
271
|
+
* subscription.create({
|
|
272
|
+
* ackDeadlineSeconds: 90
|
|
273
|
+
* }, callback);
|
|
274
|
+
*
|
|
275
|
+
* ```
|
|
276
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
277
|
+
* ```
|
|
278
|
+
* const [sub, apiResponse] = await subscription.create();
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
213
281
|
create(options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
|
214
282
|
create(callback: CreateSubscriptionCallback): void;
|
|
215
283
|
create(options: CreateSubscriptionOptions, callback: CreateSubscriptionCallback): void;
|
|
284
|
+
/**
|
|
285
|
+
* @typedef {array} CreateSnapshotResponse
|
|
286
|
+
* @property {Snapshot} 0 The new {@link Snapshot}.
|
|
287
|
+
* @property {object} 1 The full API response.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* @callback CreateSnapshotCallback
|
|
291
|
+
* @param {?Error} err Request error, if any.
|
|
292
|
+
* @param {Snapshot} snapshot The new {@link Snapshot}.
|
|
293
|
+
* @param {object} apiResponse The full API response.
|
|
294
|
+
*/
|
|
295
|
+
/**
|
|
296
|
+
* Create a snapshot with the given name.
|
|
297
|
+
*
|
|
298
|
+
* @param {string} name Name of the snapshot.
|
|
299
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
300
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
301
|
+
* @param {CreateSnapshotCallback} [callback] Callback function.
|
|
302
|
+
* @returns {Promise<CreateSnapshotResponse>}
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```
|
|
306
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
307
|
+
* const pubsub = new PubSub();
|
|
308
|
+
*
|
|
309
|
+
* const topic = pubsub.topic('my-topic');
|
|
310
|
+
* const subscription = topic.subscription('my-subscription');
|
|
311
|
+
*
|
|
312
|
+
* const callback = (err, snapshot, apiResponse) => {
|
|
313
|
+
* if (!err) {
|
|
314
|
+
* // The snapshot was created successfully.
|
|
315
|
+
* }
|
|
316
|
+
* };
|
|
317
|
+
*
|
|
318
|
+
* subscription.createSnapshot('my-snapshot', callback);
|
|
319
|
+
*
|
|
320
|
+
* //-
|
|
321
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
322
|
+
* //-
|
|
323
|
+
* subscription.createSnapshot('my-snapshot').then((data) => {
|
|
324
|
+
* const snapshot = data[0];
|
|
325
|
+
* const apiResponse = data[1];
|
|
326
|
+
* });
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
216
329
|
createSnapshot(name: string, gaxOpts?: CallOptions): Promise<CreateSnapshotResponse>;
|
|
217
330
|
createSnapshot(name: string, callback: CreateSnapshotCallback): void;
|
|
218
331
|
createSnapshot(name: string, gaxOpts: CallOptions, callback: CreateSnapshotCallback): void;
|
|
332
|
+
/**
|
|
333
|
+
* Delete the subscription. Pull requests from the current subscription will
|
|
334
|
+
* be errored once unsubscription is complete.
|
|
335
|
+
*
|
|
336
|
+
* @see [Subscriptions: delete API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/delete}
|
|
337
|
+
*
|
|
338
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
339
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
340
|
+
* @param {function} [callback] The callback function.
|
|
341
|
+
* @param {?error} callback.err An error returned while making this
|
|
342
|
+
* request.
|
|
343
|
+
* @param {object} callback.apiResponse Raw API response.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```
|
|
347
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
348
|
+
* const pubsub = new PubSub();
|
|
349
|
+
*
|
|
350
|
+
* const topic = pubsub.topic('my-topic');
|
|
351
|
+
* const subscription = topic.subscription('my-subscription');
|
|
352
|
+
*
|
|
353
|
+
* subscription.delete((err, apiResponse) => {});
|
|
354
|
+
*
|
|
355
|
+
* //-
|
|
356
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
357
|
+
* //-
|
|
358
|
+
* subscription.delete().then((data) => {
|
|
359
|
+
* const apiResponse = data[0];
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
219
363
|
delete(gaxOpts?: CallOptions): Promise<EmptyResponse>;
|
|
220
364
|
delete(callback: EmptyCallback): void;
|
|
221
365
|
delete(gaxOpts: CallOptions, callback: EmptyCallback): void;
|
|
366
|
+
/**
|
|
367
|
+
* @typedef {array} SubscriptionDetachedResponse
|
|
368
|
+
* @property {boolean} 0 Whether the subscription is detached.
|
|
369
|
+
*/
|
|
370
|
+
/**
|
|
371
|
+
* @callback SubscriptionDetachedCallback
|
|
372
|
+
* @param {?Error} err Request error, if any.
|
|
373
|
+
* @param {boolean} exists Whether the subscription is detached.
|
|
374
|
+
*/
|
|
375
|
+
/**
|
|
376
|
+
* Check if a subscription is detached.
|
|
377
|
+
*
|
|
378
|
+
* @param {SubscriptionDetachedCallback} [callback] Callback function.
|
|
379
|
+
* @returns {Promise<SubscriptionDetachedResponse>}
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```
|
|
383
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
384
|
+
* const pubsub = new PubSub();
|
|
385
|
+
*
|
|
386
|
+
* const topic = pubsub.topic('my-topic');
|
|
387
|
+
* const subscription = topic.subscription('my-subscription');
|
|
388
|
+
*
|
|
389
|
+
* subscription.detached((err, exists) => {});
|
|
390
|
+
*
|
|
391
|
+
* //-
|
|
392
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
393
|
+
* //-
|
|
394
|
+
* subscription.detached().then((data) => {
|
|
395
|
+
* const detached = data[0];
|
|
396
|
+
* });
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
222
399
|
detached(): Promise<DetachedResponse>;
|
|
223
400
|
detached(callback: DetachedCallback): void;
|
|
401
|
+
/**
|
|
402
|
+
* @typedef {array} SubscriptionExistsResponse
|
|
403
|
+
* @property {boolean} 0 Whether the subscription exists
|
|
404
|
+
*/
|
|
405
|
+
/**
|
|
406
|
+
* @callback SubscriptionExistsCallback
|
|
407
|
+
* @param {?Error} err Request error, if any.
|
|
408
|
+
* @param {boolean} exists Whether the subscription exists.
|
|
409
|
+
*/
|
|
410
|
+
/**
|
|
411
|
+
* Check if a subscription exists.
|
|
412
|
+
*
|
|
413
|
+
* @param {SubscriptionExistsCallback} [callback] Callback function.
|
|
414
|
+
* @returns {Promise<SubscriptionExistsResponse>}
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```
|
|
418
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
419
|
+
* const pubsub = new PubSub();
|
|
420
|
+
*
|
|
421
|
+
* const topic = pubsub.topic('my-topic');
|
|
422
|
+
* const subscription = topic.subscription('my-subscription');
|
|
423
|
+
*
|
|
424
|
+
* subscription.exists((err, exists) => {});
|
|
425
|
+
*
|
|
426
|
+
* //-
|
|
427
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
428
|
+
* //-
|
|
429
|
+
* subscription.exists().then((data) => {
|
|
430
|
+
* const exists = data[0];
|
|
431
|
+
* });
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
224
434
|
exists(): Promise<ExistsResponse>;
|
|
225
435
|
exists(callback: ExistsCallback): void;
|
|
436
|
+
/**
|
|
437
|
+
* @typedef {array} GetSubscriptionResponse
|
|
438
|
+
* @property {Subscription} 0 The {@link Subscription}.
|
|
439
|
+
* @property {object} 1 The full API response.
|
|
440
|
+
*/
|
|
441
|
+
/**
|
|
442
|
+
* @callback GetSubscriptionCallback
|
|
443
|
+
* @param {?Error} err Request error, if any.
|
|
444
|
+
* @param {Subscription} subscription The {@link Subscription}.
|
|
445
|
+
* @param {object} apiResponse The full API response.
|
|
446
|
+
*/
|
|
447
|
+
/**
|
|
448
|
+
* Get a subscription if it exists.
|
|
449
|
+
*
|
|
450
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
451
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
452
|
+
* @param {boolean} [gaxOpts.autoCreate=false] Automatically create the
|
|
453
|
+
* subscription if it does not already exist.
|
|
454
|
+
* @param {GetSubscriptionCallback} [callback] Callback function.
|
|
455
|
+
* @returns {Promise<GetSubscriptionResponse>}
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```
|
|
459
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
460
|
+
* const pubsub = new PubSub();
|
|
461
|
+
*
|
|
462
|
+
* const topic = pubsub.topic('my-topic');
|
|
463
|
+
* const subscription = topic.subscription('my-subscription');
|
|
464
|
+
*
|
|
465
|
+
* subscription.get((err, subscription, apiResponse) => {
|
|
466
|
+
* // The `subscription` data has been populated.
|
|
467
|
+
* });
|
|
468
|
+
*
|
|
469
|
+
* //-
|
|
470
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
471
|
+
* //-
|
|
472
|
+
* subscription.get().then((data) => {
|
|
473
|
+
* const subscription = data[0];
|
|
474
|
+
* const apiResponse = data[1];
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
226
478
|
get(gaxOpts?: GetSubscriptionOptions): Promise<GetSubscriptionResponse>;
|
|
227
479
|
get(callback: GetSubscriptionCallback): void;
|
|
228
480
|
get(gaxOpts: GetSubscriptionOptions, callback: GetSubscriptionCallback): void;
|
|
481
|
+
/**
|
|
482
|
+
* @typedef {array} GetSubscriptionMetadataResponse
|
|
483
|
+
* @property {object} 0 The full API response.
|
|
484
|
+
*/
|
|
485
|
+
/**
|
|
486
|
+
* @callback GetSubscriptionMetadataCallback
|
|
487
|
+
* @param {?Error} err Request error, if any.
|
|
488
|
+
* @param {object} apiResponse The full API response.
|
|
489
|
+
*/
|
|
490
|
+
/**
|
|
491
|
+
* Fetches the subscriptions metadata.
|
|
492
|
+
*
|
|
493
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
494
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
495
|
+
* @param {GetSubscriptionMetadataCallback} [callback] Callback function.
|
|
496
|
+
* @returns {Promise<GetSubscriptionMetadataResponse>}
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```
|
|
500
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
501
|
+
* const pubsub = new PubSub();
|
|
502
|
+
*
|
|
503
|
+
* const topic = pubsub.topic('my-topic');
|
|
504
|
+
* const subscription = topic.subscription('my-subscription');
|
|
505
|
+
*
|
|
506
|
+
* subscription.getMetadata((err, apiResponse) => {
|
|
507
|
+
* if (err) {
|
|
508
|
+
* // Error handling omitted.
|
|
509
|
+
* }
|
|
510
|
+
* });
|
|
511
|
+
*
|
|
512
|
+
* //-
|
|
513
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
514
|
+
* //-
|
|
515
|
+
* subscription.getMetadata().then((data) => {
|
|
516
|
+
* const apiResponse = data[0];
|
|
517
|
+
* });
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
229
520
|
getMetadata(gaxOpts?: CallOptions): Promise<GetSubscriptionMetadataResponse>;
|
|
230
521
|
getMetadata(callback: GetSubscriptionMetadataCallback): void;
|
|
231
522
|
getMetadata(gaxOpts: CallOptions, callback: GetSubscriptionMetadataCallback): void;
|
|
523
|
+
/**
|
|
524
|
+
* @typedef {array} ModifyPushConfigResponse
|
|
525
|
+
* @property {object} 0 The full API response.
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* @callback ModifyPushConfigCallback
|
|
529
|
+
* @param {?Error} err Request error, if any.
|
|
530
|
+
* @param {object} apiResponse The full API response.
|
|
531
|
+
*/
|
|
532
|
+
/**
|
|
533
|
+
* Modify the push config for the subscription.
|
|
534
|
+
*
|
|
535
|
+
* @param {object} config The push config.
|
|
536
|
+
* @param {string} config.pushEndpoint A URL locating the endpoint to which
|
|
537
|
+
* messages should be published.
|
|
538
|
+
* @param {object} config.attributes [PushConfig attributes](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.PushConfig).
|
|
539
|
+
* @param {object} config.oidcToken If specified, Pub/Sub will generate and
|
|
540
|
+
* attach an OIDC JWT token as an `Authorization` header in the HTTP
|
|
541
|
+
* request for every pushed message. This object should have the same
|
|
542
|
+
* structure as [OidcToken]{@link google.pubsub.v1.OidcToken}
|
|
543
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
544
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
545
|
+
* @param {ModifyPushConfigCallback} [callback] Callback function.
|
|
546
|
+
* @returns {Promise<ModifyPushConfigResponse>}
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* ```
|
|
550
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
551
|
+
* const pubsub = new PubSub();
|
|
552
|
+
*
|
|
553
|
+
* const topic = pubsub.topic('my-topic');
|
|
554
|
+
* const subscription = topic.subscription('my-subscription');
|
|
555
|
+
*
|
|
556
|
+
* const pushConfig = {
|
|
557
|
+
* pushEndpoint: 'https://mydomain.com/push',
|
|
558
|
+
* attributes: {
|
|
559
|
+
* key: 'value'
|
|
560
|
+
* },
|
|
561
|
+
* oidcToken: {
|
|
562
|
+
* serviceAccountEmail: 'myproject@appspot.gserviceaccount.com',
|
|
563
|
+
* audience: 'myaudience'
|
|
564
|
+
* }
|
|
565
|
+
* };
|
|
566
|
+
*
|
|
567
|
+
* subscription.modifyPushConfig(pushConfig, (err, apiResponse) => {
|
|
568
|
+
* if (err) {
|
|
569
|
+
* // Error handling omitted.
|
|
570
|
+
* }
|
|
571
|
+
* });
|
|
572
|
+
*
|
|
573
|
+
* //-
|
|
574
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
575
|
+
* //-
|
|
576
|
+
* subscription.modifyPushConfig(pushConfig).then((data) => {
|
|
577
|
+
* const apiResponse = data[0];
|
|
578
|
+
* });
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
232
581
|
modifyPushConfig(config: PushConfig, gaxOpts?: CallOptions): Promise<EmptyResponse>;
|
|
233
582
|
modifyPushConfig(config: PushConfig, callback: EmptyCallback): void;
|
|
234
583
|
modifyPushConfig(config: PushConfig, gaxOpts: CallOptions, callback: EmptyCallback): void;
|
|
@@ -239,6 +588,7 @@ export declare class Subscription extends EventEmitter {
|
|
|
239
588
|
* new `message` event listener which will also re-open the Subscription.
|
|
240
589
|
*
|
|
241
590
|
* @example
|
|
591
|
+
* ```
|
|
242
592
|
* subscription.on('message', message => message.ack());
|
|
243
593
|
*
|
|
244
594
|
* // Close the subscription.
|
|
@@ -252,11 +602,89 @@ export declare class Subscription extends EventEmitter {
|
|
|
252
602
|
*
|
|
253
603
|
* // Resume receiving messages.
|
|
254
604
|
* subscription.open();
|
|
605
|
+
* ```
|
|
255
606
|
*/
|
|
256
607
|
open(): void;
|
|
608
|
+
/**
|
|
609
|
+
* @typedef {array} SeekResponse
|
|
610
|
+
* @property {object} 0 The full API response.
|
|
611
|
+
*/
|
|
612
|
+
/**
|
|
613
|
+
* @callback SeekCallback
|
|
614
|
+
* @param {?Error} err Request error, if any.
|
|
615
|
+
* @param {object} apiResponse The full API response.
|
|
616
|
+
*/
|
|
617
|
+
/**
|
|
618
|
+
* Seeks an existing subscription to a point in time or a given snapshot.
|
|
619
|
+
*
|
|
620
|
+
* @param {string|date} snapshot The point to seek to. This will accept the
|
|
621
|
+
* name of the snapshot or a Date object.
|
|
622
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
623
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
624
|
+
* @param {SeekCallback} [callback] Callback function.
|
|
625
|
+
* @returns {Promise<SeekResponse>}
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```
|
|
629
|
+
* const callback = (err, resp) => {
|
|
630
|
+
* if (!err) {
|
|
631
|
+
* // Seek was successful.
|
|
632
|
+
* }
|
|
633
|
+
* };
|
|
634
|
+
*
|
|
635
|
+
* subscription.seek('my-snapshot', callback);
|
|
636
|
+
*
|
|
637
|
+
* //-
|
|
638
|
+
* // Alternatively, to specify a certain point in time, you can provide a
|
|
639
|
+
* Date
|
|
640
|
+
* // object.
|
|
641
|
+
* //-
|
|
642
|
+
* const date = new Date('October 21 2015');
|
|
643
|
+
*
|
|
644
|
+
* subscription.seek(date, callback);
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
257
647
|
seek(snapshot: string | Date, gaxOpts?: CallOptions): Promise<SeekResponse>;
|
|
258
648
|
seek(snapshot: string | Date, callback: SeekCallback): void;
|
|
259
649
|
seek(snapshot: string | Date, gaxOpts: CallOptions, callback: SeekCallback): void;
|
|
650
|
+
/**
|
|
651
|
+
* @typedef {array} SetSubscriptionMetadataResponse
|
|
652
|
+
* @property {object} 0 The full API response.
|
|
653
|
+
*/
|
|
654
|
+
/**
|
|
655
|
+
* @callback SetSubscriptionMetadataCallback
|
|
656
|
+
* @param {?Error} err Request error, if any.
|
|
657
|
+
* @param {object} apiResponse The full API response.
|
|
658
|
+
*/
|
|
659
|
+
/**
|
|
660
|
+
* Update the subscription object.
|
|
661
|
+
*
|
|
662
|
+
* @param {object} metadata The subscription metadata.
|
|
663
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
664
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
665
|
+
* @param {SetSubscriptionMetadataCallback} [callback] Callback function.
|
|
666
|
+
* @returns {Promise<SetSubscriptionMetadataResponse>}
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```
|
|
670
|
+
* const metadata = {
|
|
671
|
+
* key: 'value'
|
|
672
|
+
* };
|
|
673
|
+
*
|
|
674
|
+
* subscription.setMetadata(metadata, (err, apiResponse) => {
|
|
675
|
+
* if (err) {
|
|
676
|
+
* // Error handling omitted.
|
|
677
|
+
* }
|
|
678
|
+
* });
|
|
679
|
+
*
|
|
680
|
+
* //-
|
|
681
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
682
|
+
* //-
|
|
683
|
+
* subscription.setMetadata(metadata).then((data) => {
|
|
684
|
+
* const apiResponse = data[0];
|
|
685
|
+
* });
|
|
686
|
+
* ```
|
|
687
|
+
*/
|
|
260
688
|
setMetadata(metadata: SubscriptionMetadata, gaxOpts?: CallOptions): Promise<SetSubscriptionMetadataResponse>;
|
|
261
689
|
setMetadata(metadata: SubscriptionMetadata, callback: SetSubscriptionMetadataCallback): void;
|
|
262
690
|
setMetadata(metadata: SubscriptionMetadata, gaxOpts: CallOptions, callback: SetSubscriptionMetadataCallback): void;
|
|
@@ -276,7 +704,9 @@ export declare class Subscription extends EventEmitter {
|
|
|
276
704
|
* @returns {Snapshot}
|
|
277
705
|
*
|
|
278
706
|
* @example
|
|
707
|
+
* ```
|
|
279
708
|
* const snapshot = subscription.snapshot('my-snapshot');
|
|
709
|
+
* ```
|
|
280
710
|
*/
|
|
281
711
|
snapshot(name: string): Snapshot;
|
|
282
712
|
/**
|