@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
package/build/src/pubsub.d.ts
CHANGED
|
@@ -126,18 +126,24 @@ interface GetClientCallback {
|
|
|
126
126
|
*
|
|
127
127
|
* @param {ClientConfig} [options] Configuration options.
|
|
128
128
|
*
|
|
129
|
-
* @example
|
|
129
|
+
* @example Import the client library
|
|
130
|
+
* ```
|
|
130
131
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
131
132
|
*
|
|
132
|
-
*
|
|
133
|
+
* ```
|
|
134
|
+
* @example Create a client that uses <a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application Default Credentials (ADC)</a>:
|
|
135
|
+
* ```
|
|
133
136
|
* const pubsub = new PubSub();
|
|
134
137
|
*
|
|
135
|
-
*
|
|
138
|
+
* ```
|
|
139
|
+
* @example Create a client with <a href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit credentials</a>:
|
|
140
|
+
* ```
|
|
136
141
|
* const pubsub = new PubSub({
|
|
137
142
|
* projectId: 'your-project-id',
|
|
138
143
|
* keyFilename: '/path/to/keyfile.json'
|
|
139
144
|
* });
|
|
140
145
|
*
|
|
146
|
+
* ```
|
|
141
147
|
* @example <caption>include:samples/quickstart.js</caption>
|
|
142
148
|
* region_tag:pubsub_quickstart_create_topic
|
|
143
149
|
* Full quickstart example:
|
|
@@ -164,6 +170,17 @@ export declare class PubSub {
|
|
|
164
170
|
* @returns {boolean} true if the name is resolved.
|
|
165
171
|
*/
|
|
166
172
|
get isIdResolved(): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Closes out this object, releasing any server connections. Note that once
|
|
175
|
+
* you close a PubSub object, it may not be used again. Any pending operations
|
|
176
|
+
* (e.g. queued publish messages) will fail. If you have topic or subscription
|
|
177
|
+
* objects that may have pending operations, you should call close() on those
|
|
178
|
+
* first if you want any pending messages to be delivered correctly. The
|
|
179
|
+
* PubSub class doesn't track those.
|
|
180
|
+
*
|
|
181
|
+
* @callback EmptyCallback
|
|
182
|
+
* @returns {Promise<void>}
|
|
183
|
+
*/
|
|
167
184
|
close(): Promise<void>;
|
|
168
185
|
close(callback: EmptyCallback): void;
|
|
169
186
|
/**
|
|
@@ -183,7 +200,8 @@ export declare class PubSub {
|
|
|
183
200
|
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
184
201
|
* @returns {Promise<Schema>}
|
|
185
202
|
*
|
|
186
|
-
* @example
|
|
203
|
+
* @example Create a schema.
|
|
204
|
+
* ```
|
|
187
205
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
188
206
|
* const pubsub = new PubSub();
|
|
189
207
|
*
|
|
@@ -192,14 +210,171 @@ export declare class PubSub {
|
|
|
192
210
|
* SchemaTypes.Avro,
|
|
193
211
|
* '{...avro definition...}'
|
|
194
212
|
* );
|
|
213
|
+
* ```
|
|
195
214
|
*/
|
|
196
215
|
createSchema(schemaId: string, type: SchemaType, definition: string, gaxOpts?: CallOptions): Promise<Schema>;
|
|
216
|
+
/**
|
|
217
|
+
* @typedef {array} CreateSubscriptionResponse
|
|
218
|
+
* @property {Subscription} 0 The new {@link Subscription}.
|
|
219
|
+
* @property {object} 1 The full API response.
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* @callback CreateSubscriptionCallback
|
|
223
|
+
* @param {?Error} err Request error, if any.
|
|
224
|
+
* @param {Subscription} Subscription
|
|
225
|
+
* @param {object} apiResponse The full API response.
|
|
226
|
+
*/
|
|
227
|
+
/**
|
|
228
|
+
* Options for creating a subscription.
|
|
229
|
+
*
|
|
230
|
+
* See a [Subscription
|
|
231
|
+
* resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions).
|
|
232
|
+
*
|
|
233
|
+
* @typedef {object} CreateSubscriptionRequest
|
|
234
|
+
* @property {DeadLetterPolicy} [deadLetterPolicy] A policy that specifies the
|
|
235
|
+
* conditions for dead lettering messages in this subscription.
|
|
236
|
+
* @property {object} [flowControl] Flow control configurations for
|
|
237
|
+
* receiving messages. Note that these options do not persist across
|
|
238
|
+
* subscription instances.
|
|
239
|
+
* @property {number} [flowControl.maxBytes] The maximum number of bytes
|
|
240
|
+
* in un-acked messages to allow before the subscription pauses incoming
|
|
241
|
+
* messages. Defaults to 20% of free memory.
|
|
242
|
+
* @property {number} [flowControl.maxMessages=Infinity] The maximum number
|
|
243
|
+
* of un-acked messages to allow before the subscription pauses incoming
|
|
244
|
+
* messages.
|
|
245
|
+
* @property {object} [gaxOpts] Request configuration options, outlined
|
|
246
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
247
|
+
* @property {number|google.protobuf.Duration} [messageRetentionDuration] Set
|
|
248
|
+
* this to override the default duration of 7 days. This value is expected
|
|
249
|
+
* in seconds. Acceptable values are in the range of 10 minutes and 7
|
|
250
|
+
* days.
|
|
251
|
+
* @property {string} [pushEndpoint] A URL to a custom endpoint that
|
|
252
|
+
* messages should be pushed to.
|
|
253
|
+
* @property {object} [oidcToken] If specified, Pub/Sub will generate and
|
|
254
|
+
* attach an OIDC JWT token as an `Authorization` header in the HTTP
|
|
255
|
+
* request for every pushed message. This object should have the same
|
|
256
|
+
* structure as [OidcToken]{@link google.pubsub.v1.OidcToken}
|
|
257
|
+
* @property {boolean} [retainAckedMessages=false] If set, acked messages
|
|
258
|
+
* are retained in the subscription's backlog for the length of time
|
|
259
|
+
* specified by `options.messageRetentionDuration`.
|
|
260
|
+
* @property {ExpirationPolicy} [expirationPolicy] A policy that specifies
|
|
261
|
+
* the conditions for this subscription's expiration.
|
|
262
|
+
*/
|
|
263
|
+
/**
|
|
264
|
+
* Create a subscription to a topic.
|
|
265
|
+
*
|
|
266
|
+
* @see [Subscriptions: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create}
|
|
267
|
+
* @see {@link Topic#createSubscription}
|
|
268
|
+
*
|
|
269
|
+
* @throws {Error} If a Topic instance or topic name is not provided.
|
|
270
|
+
* @throws {Error} If a subscription name is not provided.
|
|
271
|
+
*
|
|
272
|
+
* @param {Topic|string} topic The Topic to create a subscription to.
|
|
273
|
+
* @param {string} name The name of the subscription.
|
|
274
|
+
* @param {CreateSubscriptionRequest} [options] See a [Subscription resource](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions).
|
|
275
|
+
* @param {CreateSubscriptionCallback} [callback] Callback function.
|
|
276
|
+
* @returns {Promise<CreateSubscriptionResponse>}
|
|
277
|
+
*
|
|
278
|
+
* @example Subscribe to a topic.
|
|
279
|
+
* ```
|
|
280
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
281
|
+
* const pubsub = new PubSub();
|
|
282
|
+
*
|
|
283
|
+
* const topic = 'messageCenter';
|
|
284
|
+
* const name = 'newMessages';
|
|
285
|
+
*
|
|
286
|
+
* const callback = function(err, subscription, apiResponse) {};
|
|
287
|
+
*
|
|
288
|
+
* pubsub.createSubscription(topic, name, callback);
|
|
289
|
+
*
|
|
290
|
+
* ```
|
|
291
|
+
* @example If the callback is omitted, we'll return a Promise.
|
|
292
|
+
* ```
|
|
293
|
+
* pubsub.createSubscription(topic, name)
|
|
294
|
+
* .then(function(data) {
|
|
295
|
+
* const subscription = data[0];
|
|
296
|
+
* const apiResponse = data[1];
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
197
300
|
createSubscription(topic: Topic | string, name: string, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
|
198
301
|
createSubscription(topic: Topic | string, name: string, callback: CreateSubscriptionCallback): void;
|
|
199
302
|
createSubscription(topic: Topic | string, name: string, options: CreateSubscriptionOptions, callback: CreateSubscriptionCallback): void;
|
|
303
|
+
/**
|
|
304
|
+
* @typedef {array} CreateTopicResponse
|
|
305
|
+
* @property {Topic} 0 The new {@link Topic}.
|
|
306
|
+
* @property {object} 1 The full API response.
|
|
307
|
+
*/
|
|
308
|
+
/**
|
|
309
|
+
* @callback CreateTopicCallback
|
|
310
|
+
* @param {?Error} err Request error, if any.
|
|
311
|
+
* @param {Topic} topic The new {@link Topic}.
|
|
312
|
+
* @param {object} apiResponse The full API response.
|
|
313
|
+
*/
|
|
314
|
+
/**
|
|
315
|
+
* Create a topic with the given name.
|
|
316
|
+
*
|
|
317
|
+
* @see [Topics: create API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/create}
|
|
318
|
+
*
|
|
319
|
+
* @param {string} name Name of the topic.
|
|
320
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
321
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
322
|
+
* @param {CreateTopicCallback} [callback] Callback function.
|
|
323
|
+
* @returns {Promise<CreateTopicResponse>}
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```
|
|
327
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
328
|
+
* const pubsub = new PubSub();
|
|
329
|
+
*
|
|
330
|
+
* pubsub.createTopic('my-new-topic', function(err, topic, apiResponse) {
|
|
331
|
+
* if (!err) {
|
|
332
|
+
* // The topic was created successfully.
|
|
333
|
+
* }
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* //-
|
|
337
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
338
|
+
* //-
|
|
339
|
+
* pubsub.createTopic('my-new-topic').then(function(data) {
|
|
340
|
+
* const topic = data[0];
|
|
341
|
+
* const apiResponse = data[1];
|
|
342
|
+
* });
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
200
345
|
createTopic(name: string | TopicMetadata, gaxOpts?: CallOptions): Promise<CreateTopicResponse>;
|
|
201
346
|
createTopic(name: string | TopicMetadata, callback: CreateTopicCallback): void;
|
|
202
347
|
createTopic(name: string | TopicMetadata, gaxOpts: CallOptions, callback: CreateTopicCallback): void;
|
|
348
|
+
/**
|
|
349
|
+
* Detach a subscription with the given name.
|
|
350
|
+
*
|
|
351
|
+
* @see [Admin: Pub/Sub administration API Documentation]{@link https://cloud.google.com/pubsub/docs/admin}
|
|
352
|
+
*
|
|
353
|
+
* @param {string} name Name of the subscription.
|
|
354
|
+
* @param {object} [gaxOpts] Request configuration options, outlined
|
|
355
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
356
|
+
* @param {DetachSubscriptionCallback} [callback] Callback function.
|
|
357
|
+
* @returns {Promise<DetachSubscriptionResponse>}
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```
|
|
361
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
362
|
+
* const pubsub = new PubSub();
|
|
363
|
+
*
|
|
364
|
+
* pubsub.detachSubscription('my-sub', (err, topic, apiResponse) => {
|
|
365
|
+
* if (!err) {
|
|
366
|
+
* // The topic was created successfully.
|
|
367
|
+
* }
|
|
368
|
+
* });
|
|
369
|
+
*
|
|
370
|
+
* //-
|
|
371
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
372
|
+
* //-
|
|
373
|
+
* pubsub.detachSubscription('my-sub').then(data => {
|
|
374
|
+
* const apiResponse = data[0];
|
|
375
|
+
* });
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
203
378
|
detachSubscription(name: string, gaxOpts?: CallOptions): Promise<DetachSubscriptionResponse>;
|
|
204
379
|
detachSubscription(name: string, callback: DetachSubscriptionCallback): void;
|
|
205
380
|
detachSubscription(name: string, gaxOpts: CallOptions, callback: DetachSubscriptionCallback): void;
|
|
@@ -237,17 +412,184 @@ export declare class PubSub {
|
|
|
237
412
|
* @returns {AsyncIterable<ISchema>}
|
|
238
413
|
*
|
|
239
414
|
* @example
|
|
415
|
+
* ```
|
|
240
416
|
* for await (const s of pubsub.listSchemas()) {
|
|
241
417
|
* const moreInfo = await s.get();
|
|
242
418
|
* }
|
|
419
|
+
* ```
|
|
243
420
|
*/
|
|
244
421
|
listSchemas(view?: SchemaView, options?: CallOptions): AsyncIterable<google.pubsub.v1.ISchema>;
|
|
422
|
+
/**
|
|
423
|
+
* Query object for listing snapshots.
|
|
424
|
+
*
|
|
425
|
+
* @typedef {object} GetSnapshotsRequest
|
|
426
|
+
* @property {boolean} [autoPaginate=true] Have pagination handled
|
|
427
|
+
* automatically.
|
|
428
|
+
* @property {object} [options.gaxOpts] Request configuration options, outlined
|
|
429
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
430
|
+
* @property {number} [options.pageSize] Maximum number of results to return.
|
|
431
|
+
* @property {string} [options.pageToken] Page token.
|
|
432
|
+
*/
|
|
433
|
+
/**
|
|
434
|
+
* @typedef {array} GetSnapshotsResponse
|
|
435
|
+
* @property {Snapshot[]} 0 Array of {@link Snapshot} instances.
|
|
436
|
+
* @property {object} 1 The full API response.
|
|
437
|
+
*/
|
|
438
|
+
/**
|
|
439
|
+
* @callback GetSnapshotsCallback
|
|
440
|
+
* @param {?Error} err Request error, if any.
|
|
441
|
+
* @param {Snapshot[]} snapshots Array of {@link Snapshot} instances.
|
|
442
|
+
* @param {object} apiResponse The full API response.
|
|
443
|
+
*/
|
|
444
|
+
/**
|
|
445
|
+
* Get a list of snapshots.
|
|
446
|
+
*
|
|
447
|
+
* @param {GetSnapshotsRequest} [query] Query object for listing snapshots.
|
|
448
|
+
* @param {GetSnapshotsCallback} [callback] Callback function.
|
|
449
|
+
* @returns {Promise<GetSnapshotsResponse>}
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```
|
|
453
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
454
|
+
* const pubsub = new PubSub();
|
|
455
|
+
*
|
|
456
|
+
* pubsub.getSnapshots(function(err, snapshots) {
|
|
457
|
+
* if (!err) {
|
|
458
|
+
* // snapshots is an array of Snapshot objects.
|
|
459
|
+
* }
|
|
460
|
+
* });
|
|
461
|
+
*
|
|
462
|
+
* //-
|
|
463
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
464
|
+
* //-
|
|
465
|
+
* pubsub.getSnapshots().then(function(data) {
|
|
466
|
+
* const snapshots = data[0];
|
|
467
|
+
* });
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
245
470
|
getSnapshots(options?: PageOptions): Promise<GetSnapshotsResponse>;
|
|
246
471
|
getSnapshots(callback: GetSnapshotsCallback): void;
|
|
247
472
|
getSnapshots(options: PageOptions, callback: GetSnapshotsCallback): void;
|
|
473
|
+
/**
|
|
474
|
+
* Query object for listing subscriptions.
|
|
475
|
+
*
|
|
476
|
+
* @typedef {object} GetSubscriptionsRequest
|
|
477
|
+
* @property {boolean} [autoPaginate=true] Have pagination handled
|
|
478
|
+
* automatically.
|
|
479
|
+
* @property {object} [options.gaxOpts] Request configuration options, outlined
|
|
480
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
481
|
+
* @property {number} [options.pageSize] Maximum number of results to return.
|
|
482
|
+
* @property {string} [options.pageToken] Page token.
|
|
483
|
+
* @param {string|Topic} options.topic - The name of the topic to
|
|
484
|
+
* list subscriptions from.
|
|
485
|
+
*/
|
|
486
|
+
/**
|
|
487
|
+
* @typedef {array} GetSubscriptionsResponse
|
|
488
|
+
* @property {Subscription[]} 0 Array of {@link Subscription} instances.
|
|
489
|
+
* @property {object} 1 The full API response.
|
|
490
|
+
*/
|
|
491
|
+
/**
|
|
492
|
+
* @callback GetSubscriptionsCallback
|
|
493
|
+
* @param {?Error} err Request error, if any.
|
|
494
|
+
* @param {Subscription[]} subscriptions Array of {@link Subscription} instances.
|
|
495
|
+
* @param {object} apiResponse The full API response.
|
|
496
|
+
*/
|
|
497
|
+
/**
|
|
498
|
+
* Get a list of the subscriptions registered to all of your project's topics.
|
|
499
|
+
* You may optionally provide a query object as the first argument to
|
|
500
|
+
* customize the response.
|
|
501
|
+
*
|
|
502
|
+
* Your provided callback will be invoked with an error object if an API error
|
|
503
|
+
* occurred or an array of {@link Subscription} objects.
|
|
504
|
+
*
|
|
505
|
+
* To get subscriptions for a topic, see {@link Topic}.
|
|
506
|
+
*
|
|
507
|
+
* @see [Subscriptions: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/list}
|
|
508
|
+
*
|
|
509
|
+
* @param {GetSubscriptionsRequest} [query] Query object for listing subscriptions.
|
|
510
|
+
* @param {GetSubscriptionsCallback} [callback] Callback function.
|
|
511
|
+
* @returns {Promise<GetSubscriptionsResponse>}
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```
|
|
515
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
516
|
+
* const pubsub = new PubSub();
|
|
517
|
+
*
|
|
518
|
+
* pubsub.getSubscriptions(function(err, subscriptions) {
|
|
519
|
+
* if (!err) {
|
|
520
|
+
* // subscriptions is an array of Subscription objects.
|
|
521
|
+
* }
|
|
522
|
+
* });
|
|
523
|
+
*
|
|
524
|
+
* //-
|
|
525
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
526
|
+
* //-
|
|
527
|
+
* pubsub.getSubscriptions().then(function(data) {
|
|
528
|
+
* const subscriptions = data[0];
|
|
529
|
+
* });
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
248
532
|
getSubscriptions(options?: GetSubscriptionsOptions): Promise<GetSubscriptionsResponse>;
|
|
249
533
|
getSubscriptions(callback: GetSubscriptionsCallback): void;
|
|
250
534
|
getSubscriptions(options: GetSubscriptionsOptions, callback: GetSubscriptionsCallback): void;
|
|
535
|
+
/**
|
|
536
|
+
* Query object for listing topics.
|
|
537
|
+
*
|
|
538
|
+
* @typedef {object} GetTopicsRequest
|
|
539
|
+
* @property {boolean} [autoPaginate=true] Have pagination handled
|
|
540
|
+
* automatically.
|
|
541
|
+
* @property {object} [options.gaxOpts] Request configuration options, outlined
|
|
542
|
+
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
|
|
543
|
+
* @property {number} [options.pageSize] Maximum number of results to return.
|
|
544
|
+
* @property {string} [options.pageToken] Page token.
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* @typedef {array} GetTopicsResponse
|
|
548
|
+
* @property {Topic[]} 0 Array of {@link Topic} instances.
|
|
549
|
+
* @property {object} 1 The full API response.
|
|
550
|
+
*/
|
|
551
|
+
/**
|
|
552
|
+
* @callback GetTopicsCallback
|
|
553
|
+
* @param {?Error} err Request error, if any.
|
|
554
|
+
* @param {Topic[]} topics Array of {@link Topic} instances.
|
|
555
|
+
* @param {object} apiResponse The full API response.
|
|
556
|
+
*/
|
|
557
|
+
/**
|
|
558
|
+
* Get a list of the topics registered to your project. You may optionally
|
|
559
|
+
* provide a query object as the first argument to customize the response.
|
|
560
|
+
*
|
|
561
|
+
* @see [Topics: list API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list}
|
|
562
|
+
*
|
|
563
|
+
* @param {GetTopicsRequest} [query] Query object for listing topics.
|
|
564
|
+
* @param {GetTopicsCallback} [callback] Callback function.
|
|
565
|
+
* @returns {Promise<GetTopicsResponse>}
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```
|
|
569
|
+
* const {PubSub} = require('@google-cloud/pubsub');
|
|
570
|
+
* const pubsub = new PubSub();
|
|
571
|
+
*
|
|
572
|
+
* pubsub.getTopics(function(err, topics) {
|
|
573
|
+
* if (!err) {
|
|
574
|
+
* // topics is an array of Topic objects.
|
|
575
|
+
* }
|
|
576
|
+
* });
|
|
577
|
+
*
|
|
578
|
+
* //-
|
|
579
|
+
* // Customize the query.
|
|
580
|
+
* //-
|
|
581
|
+
* pubsub.getTopics({
|
|
582
|
+
* pageSize: 3
|
|
583
|
+
* }, function(err, topics) {});
|
|
584
|
+
*
|
|
585
|
+
* //-
|
|
586
|
+
* // If the callback is omitted, we'll return a Promise.
|
|
587
|
+
* //-
|
|
588
|
+
* pubsub.getTopics().then(function(data) {
|
|
589
|
+
* const topics = data[0];
|
|
590
|
+
* });
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
251
593
|
getTopics(options?: PageOptions): Promise<GetTopicsResponse>;
|
|
252
594
|
getTopics(callback: GetTopicsCallback): void;
|
|
253
595
|
getTopics(options: PageOptions, callback: GetTopicsCallback): void;
|
|
@@ -327,10 +669,12 @@ export declare class PubSub {
|
|
|
327
669
|
* @returns {Schema} A {@link Schema} instance.
|
|
328
670
|
*
|
|
329
671
|
* @example
|
|
672
|
+
* ```
|
|
330
673
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
331
674
|
* const pubsub = new PubSub();
|
|
332
675
|
*
|
|
333
676
|
* const schema = pubsub.schema('my-schema');
|
|
677
|
+
* ```
|
|
334
678
|
*/
|
|
335
679
|
schema(idOrName: string): Schema;
|
|
336
680
|
/**
|
|
@@ -343,10 +687,12 @@ export declare class PubSub {
|
|
|
343
687
|
* @returns {Snapshot} A {@link Snapshot} instance.
|
|
344
688
|
*
|
|
345
689
|
* @example
|
|
690
|
+
* ```
|
|
346
691
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
347
692
|
* const pubsub = new PubSub();
|
|
348
693
|
*
|
|
349
694
|
* const snapshot = pubsub.snapshot('my-snapshot');
|
|
695
|
+
* ```
|
|
350
696
|
*/
|
|
351
697
|
snapshot(name: string): Snapshot;
|
|
352
698
|
/**
|
|
@@ -361,6 +707,7 @@ export declare class PubSub {
|
|
|
361
707
|
* @returns {Subscription} A {@link Subscription} instance.
|
|
362
708
|
*
|
|
363
709
|
* @example
|
|
710
|
+
* ```
|
|
364
711
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
365
712
|
* const pubsub = new PubSub();
|
|
366
713
|
*
|
|
@@ -375,6 +722,7 @@ export declare class PubSub {
|
|
|
375
722
|
* // message.attributes = Attributes of the message.
|
|
376
723
|
* // message.publishTime = Date when Pub/Sub received the message.
|
|
377
724
|
* });
|
|
725
|
+
* ```
|
|
378
726
|
*/
|
|
379
727
|
subscription(name: string, options?: SubscriptionOptions): Subscription;
|
|
380
728
|
/**
|
|
@@ -387,10 +735,12 @@ export declare class PubSub {
|
|
|
387
735
|
* @returns {Topic} A {@link Topic} instance.
|
|
388
736
|
*
|
|
389
737
|
* @example
|
|
738
|
+
* ```
|
|
390
739
|
* const {PubSub} = require('@google-cloud/pubsub');
|
|
391
740
|
* const pubsub = new PubSub();
|
|
392
741
|
*
|
|
393
742
|
* const topic = pubsub.topic('my-topic');
|
|
743
|
+
* ```
|
|
394
744
|
*/
|
|
395
745
|
topic(name: string, options?: PublishOptions): Topic;
|
|
396
746
|
/**
|