@google-cloud/pubsub-api 0.2.0

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.
@@ -0,0 +1,1260 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.PublisherClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ const google_gax_1 = require("google-gax");
23
+ /**
24
+ * Client JSON configuration object, loaded from
25
+ * `src/v1/publisher_client_config.json`.
26
+ * This file defines retry strategy and timeouts for all API methods in this library.
27
+ */
28
+ const gapicConfig = require("./publisher_client_config.json");
29
+ const version = require('../../../package.json').version;
30
+ /**
31
+ * The service that an application uses to manipulate topics, and to send
32
+ * messages to a topic.
33
+ * @class
34
+ * @memberof v1
35
+ */
36
+ class PublisherClient {
37
+ _terminated = false;
38
+ _opts;
39
+ _providedCustomServicePath;
40
+ _gaxModule;
41
+ _gaxGrpc;
42
+ _protos;
43
+ _defaults;
44
+ _universeDomain;
45
+ _servicePath;
46
+ _log = google_gax_1.loggingUtils.log('pubsub-api');
47
+ auth;
48
+ descriptors = {
49
+ page: {},
50
+ stream: {},
51
+ longrunning: {},
52
+ batching: {},
53
+ };
54
+ warn;
55
+ innerApiCalls;
56
+ iamClient;
57
+ pathTemplates;
58
+ publisherStub;
59
+ /**
60
+ * Construct an instance of PublisherClient.
61
+ *
62
+ * @param {object} [options] - The configuration object.
63
+ * The options accepted by the constructor are described in detail
64
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
65
+ * The common options are:
66
+ * @param {object} [options.credentials] - Credentials object.
67
+ * @param {string} [options.credentials.client_email]
68
+ * @param {string} [options.credentials.private_key]
69
+ * @param {string} [options.email] - Account email address. Required when
70
+ * using a .pem or .p12 keyFilename.
71
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
72
+ * .p12 key downloaded from the Google Developers Console. If you provide
73
+ * a path to a JSON file, the projectId option below is not necessary.
74
+ * NOTE: .pem and .p12 require you to specify options.email as well.
75
+ * @param {number} [options.port] - The port on which to connect to
76
+ * the remote host.
77
+ * @param {string} [options.projectId] - The project ID from the Google
78
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
79
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
80
+ * app is running in an environment which supports
81
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
82
+ * your project ID will be detected automatically.
83
+ * @param {string} [options.apiEndpoint] - The domain name of the
84
+ * API remote host.
85
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
86
+ * Follows the structure of {@link gapicConfig}.
87
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
88
+ * For more information, please check the
89
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
90
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
91
+ * need to avoid loading the default gRPC version and want to use the fallback
92
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
93
+ * ```
94
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
95
+ * const client = new PublisherClient({fallback: true}, gax);
96
+ * ```
97
+ */
98
+ constructor(opts, gaxInstance) {
99
+ // Ensure that options include all the required fields.
100
+ const staticMembers = this.constructor;
101
+ if (opts?.universe_domain &&
102
+ opts?.universeDomain &&
103
+ opts?.universe_domain !== opts?.universeDomain) {
104
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
105
+ }
106
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
107
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
108
+ : undefined;
109
+ this._universeDomain =
110
+ opts?.universeDomain ??
111
+ opts?.universe_domain ??
112
+ universeDomainEnvVar ??
113
+ 'googleapis.com';
114
+ this._servicePath = 'pubsub.' + this._universeDomain;
115
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
116
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
117
+ const port = opts?.port || staticMembers.port;
118
+ const clientConfig = opts?.clientConfig ?? {};
119
+ const fallback = opts?.fallback ??
120
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
121
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
122
+ // Request numeric enum values if REST transport is used.
123
+ opts.numericEnums = true;
124
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
125
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
126
+ opts['scopes'] = staticMembers.scopes;
127
+ }
128
+ // Load google-gax module synchronously if needed
129
+ if (!gaxInstance) {
130
+ gaxInstance = require('google-gax');
131
+ }
132
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
133
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
134
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
135
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
136
+ // Save options to use in initialize() method.
137
+ this._opts = opts;
138
+ // Save the auth object to the client, for use by other methods.
139
+ this.auth = this._gaxGrpc.auth;
140
+ // Set useJWTAccessWithScope on the auth object.
141
+ this.auth.useJWTAccessWithScope = true;
142
+ // Set defaultServicePath on the auth object.
143
+ this.auth.defaultServicePath = this._servicePath;
144
+ // Set the default scopes in auth client if needed.
145
+ if (servicePath === this._servicePath) {
146
+ this.auth.defaultScopes = staticMembers.scopes;
147
+ }
148
+ this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts);
149
+ // Determine the client header string.
150
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
151
+ if (typeof process === 'object' && 'versions' in process) {
152
+ clientHeader.push(`gl-node/${process.versions.node}`);
153
+ }
154
+ else {
155
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
156
+ }
157
+ if (!opts.fallback) {
158
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
159
+ }
160
+ else {
161
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
162
+ }
163
+ if (opts.libName && opts.libVersion) {
164
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
165
+ }
166
+ // Load the applicable protos.
167
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
168
+ // This API contains "path templates"; forward-slash-separated
169
+ // identifiers to uniquely identify resources within the API.
170
+ // Create useful helper objects for these.
171
+ this.pathTemplates = {
172
+ cryptoKeyPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}'),
173
+ projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
174
+ projectTopicsPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/topics/{topic}'),
175
+ schemaPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/schemas/{schema}'),
176
+ snapshotPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/snapshots/{snapshot}'),
177
+ subscriptionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/subscriptions/{subscription}'),
178
+ };
179
+ // Some of the methods on this service return "paged" results,
180
+ // (e.g. 50 results at a time, with tokens to get subsequent
181
+ // pages). Denote the keys used for pagination and results.
182
+ this.descriptors.page = {
183
+ listTopics: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'topics'),
184
+ listTopicSubscriptions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'subscriptions'),
185
+ listTopicSnapshots: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'snapshots'),
186
+ };
187
+ // Put together the default options sent with requests.
188
+ this._defaults = this._gaxGrpc.constructSettings('google.pubsub.v1.Publisher', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
189
+ // Set up a dictionary of "inner API calls"; the core implementation
190
+ // of calling the API is handled in `google-gax`, with this code
191
+ // merely providing the destination and request information.
192
+ this.innerApiCalls = {};
193
+ // Add a warn function to the client constructor so it can be easily tested.
194
+ this.warn = this._gaxModule.warn;
195
+ }
196
+ /**
197
+ * Initialize the client.
198
+ * Performs asynchronous operations (such as authentication) and prepares the client.
199
+ * This function will be called automatically when any class method is called for the
200
+ * first time, but if you need to initialize it before calling an actual method,
201
+ * feel free to call initialize() directly.
202
+ *
203
+ * You can await on this method if you want to make sure the client is initialized.
204
+ *
205
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
206
+ */
207
+ initialize() {
208
+ // If the client stub promise is already initialized, return immediately.
209
+ if (this.publisherStub) {
210
+ return this.publisherStub;
211
+ }
212
+ // Put together the "service stub" for
213
+ // google.pubsub.v1.Publisher.
214
+ this.publisherStub = this._gaxGrpc.createStub(this._opts.fallback
215
+ ? this._protos.lookupService('google.pubsub.v1.Publisher')
216
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
217
+ this._protos.google.pubsub.v1.Publisher, this._opts, this._providedCustomServicePath);
218
+ // Iterate over each of the methods that the service provides
219
+ // and create an API call method for each.
220
+ const publisherStubMethods = [
221
+ 'createTopic',
222
+ 'updateTopic',
223
+ 'publish',
224
+ 'getTopic',
225
+ 'listTopics',
226
+ 'listTopicSubscriptions',
227
+ 'listTopicSnapshots',
228
+ 'deleteTopic',
229
+ 'detachSubscription',
230
+ ];
231
+ for (const methodName of publisherStubMethods) {
232
+ const callPromise = this.publisherStub.then((stub) => (...args) => {
233
+ if (this._terminated) {
234
+ return Promise.reject('The client has already been closed.');
235
+ }
236
+ const func = stub[methodName];
237
+ return func.apply(stub, args);
238
+ }, (err) => () => {
239
+ throw err;
240
+ });
241
+ const descriptor = this.descriptors.page[methodName] || undefined;
242
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
243
+ this.innerApiCalls[methodName] = apiCall;
244
+ }
245
+ return this.publisherStub;
246
+ }
247
+ /**
248
+ * The DNS address for this API service.
249
+ * @deprecated Use the apiEndpoint method of the client instance.
250
+ * @returns {string} The DNS address for this service.
251
+ */
252
+ static get servicePath() {
253
+ if (typeof process === 'object' &&
254
+ typeof process.emitWarning === 'function') {
255
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
256
+ }
257
+ return 'pubsub.googleapis.com';
258
+ }
259
+ /**
260
+ * The DNS address for this API service - same as servicePath.
261
+ * @deprecated Use the apiEndpoint method of the client instance.
262
+ * @returns {string} The DNS address for this service.
263
+ */
264
+ static get apiEndpoint() {
265
+ if (typeof process === 'object' &&
266
+ typeof process.emitWarning === 'function') {
267
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
268
+ }
269
+ return 'pubsub.googleapis.com';
270
+ }
271
+ /**
272
+ * The DNS address for this API service.
273
+ * @returns {string} The DNS address for this service.
274
+ */
275
+ get apiEndpoint() {
276
+ return this._servicePath;
277
+ }
278
+ get universeDomain() {
279
+ return this._universeDomain;
280
+ }
281
+ /**
282
+ * The port for this API service.
283
+ * @returns {number} The default port for this service.
284
+ */
285
+ static get port() {
286
+ return 443;
287
+ }
288
+ /**
289
+ * The scopes needed to make gRPC calls for every method defined
290
+ * in this service.
291
+ * @returns {string[]} List of default scopes.
292
+ */
293
+ static get scopes() {
294
+ return [
295
+ 'https://www.googleapis.com/auth/cloud-platform',
296
+ 'https://www.googleapis.com/auth/pubsub',
297
+ ];
298
+ }
299
+ /**
300
+ * Return the project ID used by this class.
301
+ * @returns {Promise} A promise that resolves to string containing the project ID.
302
+ */
303
+ getProjectId(callback) {
304
+ if (callback) {
305
+ this.auth.getProjectId(callback);
306
+ return;
307
+ }
308
+ return this.auth.getProjectId();
309
+ }
310
+ createTopic(request, optionsOrCallback, callback) {
311
+ request = request || {};
312
+ let options;
313
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
314
+ callback = optionsOrCallback;
315
+ options = {};
316
+ }
317
+ else {
318
+ options = optionsOrCallback;
319
+ }
320
+ options = options || {};
321
+ options.otherArgs = options.otherArgs || {};
322
+ options.otherArgs.headers = options.otherArgs.headers || {};
323
+ options.otherArgs.headers['x-goog-request-params'] =
324
+ this._gaxModule.routingHeader.fromParams({
325
+ name: request.name ?? '',
326
+ });
327
+ this.initialize().catch((err) => {
328
+ throw err;
329
+ });
330
+ this._log.info('createTopic request %j', request);
331
+ const wrappedCallback = callback
332
+ ? (error, response, options, rawResponse) => {
333
+ this._log.info('createTopic response %j', response);
334
+ callback(error, response, options, rawResponse); // We verified callback above.
335
+ }
336
+ : undefined;
337
+ return this.innerApiCalls
338
+ .createTopic(request, options, wrappedCallback)
339
+ ?.then(([response, options, rawResponse]) => {
340
+ this._log.info('createTopic response %j', response);
341
+ return [response, options, rawResponse];
342
+ })
343
+ .catch((error) => {
344
+ if (error &&
345
+ 'statusDetails' in error &&
346
+ error.statusDetails instanceof Array) {
347
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
348
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
349
+ }
350
+ throw error;
351
+ });
352
+ }
353
+ updateTopic(request, optionsOrCallback, callback) {
354
+ request = request || {};
355
+ let options;
356
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
357
+ callback = optionsOrCallback;
358
+ options = {};
359
+ }
360
+ else {
361
+ options = optionsOrCallback;
362
+ }
363
+ options = options || {};
364
+ options.otherArgs = options.otherArgs || {};
365
+ options.otherArgs.headers = options.otherArgs.headers || {};
366
+ options.otherArgs.headers['x-goog-request-params'] =
367
+ this._gaxModule.routingHeader.fromParams({
368
+ 'topic.name': request.topic.name ?? '',
369
+ });
370
+ this.initialize().catch((err) => {
371
+ throw err;
372
+ });
373
+ this._log.info('updateTopic request %j', request);
374
+ const wrappedCallback = callback
375
+ ? (error, response, options, rawResponse) => {
376
+ this._log.info('updateTopic response %j', response);
377
+ callback(error, response, options, rawResponse); // We verified callback above.
378
+ }
379
+ : undefined;
380
+ return this.innerApiCalls
381
+ .updateTopic(request, options, wrappedCallback)
382
+ ?.then(([response, options, rawResponse]) => {
383
+ this._log.info('updateTopic response %j', response);
384
+ return [response, options, rawResponse];
385
+ })
386
+ .catch((error) => {
387
+ if (error &&
388
+ 'statusDetails' in error &&
389
+ error.statusDetails instanceof Array) {
390
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
391
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
392
+ }
393
+ throw error;
394
+ });
395
+ }
396
+ publish(request, optionsOrCallback, callback) {
397
+ request = request || {};
398
+ let options;
399
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
400
+ callback = optionsOrCallback;
401
+ options = {};
402
+ }
403
+ else {
404
+ options = optionsOrCallback;
405
+ }
406
+ options = options || {};
407
+ options.otherArgs = options.otherArgs || {};
408
+ options.otherArgs.headers = options.otherArgs.headers || {};
409
+ options.otherArgs.headers['x-goog-request-params'] =
410
+ this._gaxModule.routingHeader.fromParams({
411
+ topic: request.topic ?? '',
412
+ });
413
+ this.initialize().catch((err) => {
414
+ throw err;
415
+ });
416
+ this._log.info('publish request %j', request);
417
+ const wrappedCallback = callback
418
+ ? (error, response, options, rawResponse) => {
419
+ this._log.info('publish response %j', response);
420
+ callback(error, response, options, rawResponse); // We verified callback above.
421
+ }
422
+ : undefined;
423
+ return this.innerApiCalls
424
+ .publish(request, options, wrappedCallback)
425
+ ?.then(([response, options, rawResponse]) => {
426
+ this._log.info('publish response %j', response);
427
+ return [response, options, rawResponse];
428
+ })
429
+ .catch((error) => {
430
+ if (error &&
431
+ 'statusDetails' in error &&
432
+ error.statusDetails instanceof Array) {
433
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
434
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
435
+ }
436
+ throw error;
437
+ });
438
+ }
439
+ getTopic(request, optionsOrCallback, callback) {
440
+ request = request || {};
441
+ let options;
442
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
443
+ callback = optionsOrCallback;
444
+ options = {};
445
+ }
446
+ else {
447
+ options = optionsOrCallback;
448
+ }
449
+ options = options || {};
450
+ options.otherArgs = options.otherArgs || {};
451
+ options.otherArgs.headers = options.otherArgs.headers || {};
452
+ options.otherArgs.headers['x-goog-request-params'] =
453
+ this._gaxModule.routingHeader.fromParams({
454
+ topic: request.topic ?? '',
455
+ });
456
+ this.initialize().catch((err) => {
457
+ throw err;
458
+ });
459
+ this._log.info('getTopic request %j', request);
460
+ const wrappedCallback = callback
461
+ ? (error, response, options, rawResponse) => {
462
+ this._log.info('getTopic response %j', response);
463
+ callback(error, response, options, rawResponse); // We verified callback above.
464
+ }
465
+ : undefined;
466
+ return this.innerApiCalls
467
+ .getTopic(request, options, wrappedCallback)
468
+ ?.then(([response, options, rawResponse]) => {
469
+ this._log.info('getTopic response %j', response);
470
+ return [response, options, rawResponse];
471
+ })
472
+ .catch((error) => {
473
+ if (error &&
474
+ 'statusDetails' in error &&
475
+ error.statusDetails instanceof Array) {
476
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
477
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
478
+ }
479
+ throw error;
480
+ });
481
+ }
482
+ deleteTopic(request, optionsOrCallback, callback) {
483
+ request = request || {};
484
+ let options;
485
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
486
+ callback = optionsOrCallback;
487
+ options = {};
488
+ }
489
+ else {
490
+ options = optionsOrCallback;
491
+ }
492
+ options = options || {};
493
+ options.otherArgs = options.otherArgs || {};
494
+ options.otherArgs.headers = options.otherArgs.headers || {};
495
+ options.otherArgs.headers['x-goog-request-params'] =
496
+ this._gaxModule.routingHeader.fromParams({
497
+ topic: request.topic ?? '',
498
+ });
499
+ this.initialize().catch((err) => {
500
+ throw err;
501
+ });
502
+ this._log.info('deleteTopic request %j', request);
503
+ const wrappedCallback = callback
504
+ ? (error, response, options, rawResponse) => {
505
+ this._log.info('deleteTopic response %j', response);
506
+ callback(error, response, options, rawResponse); // We verified callback above.
507
+ }
508
+ : undefined;
509
+ return this.innerApiCalls
510
+ .deleteTopic(request, options, wrappedCallback)
511
+ ?.then(([response, options, rawResponse]) => {
512
+ this._log.info('deleteTopic response %j', response);
513
+ return [response, options, rawResponse];
514
+ })
515
+ .catch((error) => {
516
+ if (error &&
517
+ 'statusDetails' in error &&
518
+ error.statusDetails instanceof Array) {
519
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
520
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
521
+ }
522
+ throw error;
523
+ });
524
+ }
525
+ detachSubscription(request, optionsOrCallback, callback) {
526
+ request = request || {};
527
+ let options;
528
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
529
+ callback = optionsOrCallback;
530
+ options = {};
531
+ }
532
+ else {
533
+ options = optionsOrCallback;
534
+ }
535
+ options = options || {};
536
+ options.otherArgs = options.otherArgs || {};
537
+ options.otherArgs.headers = options.otherArgs.headers || {};
538
+ options.otherArgs.headers['x-goog-request-params'] =
539
+ this._gaxModule.routingHeader.fromParams({
540
+ subscription: request.subscription ?? '',
541
+ });
542
+ this.initialize().catch((err) => {
543
+ throw err;
544
+ });
545
+ this._log.info('detachSubscription request %j', request);
546
+ const wrappedCallback = callback
547
+ ? (error, response, options, rawResponse) => {
548
+ this._log.info('detachSubscription response %j', response);
549
+ callback(error, response, options, rawResponse); // We verified callback above.
550
+ }
551
+ : undefined;
552
+ return this.innerApiCalls
553
+ .detachSubscription(request, options, wrappedCallback)
554
+ ?.then(([response, options, rawResponse]) => {
555
+ this._log.info('detachSubscription response %j', response);
556
+ return [response, options, rawResponse];
557
+ })
558
+ .catch((error) => {
559
+ if (error &&
560
+ 'statusDetails' in error &&
561
+ error.statusDetails instanceof Array) {
562
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
563
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
564
+ }
565
+ throw error;
566
+ });
567
+ }
568
+ listTopics(request, optionsOrCallback, callback) {
569
+ request = request || {};
570
+ let options;
571
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
572
+ callback = optionsOrCallback;
573
+ options = {};
574
+ }
575
+ else {
576
+ options = optionsOrCallback;
577
+ }
578
+ options = options || {};
579
+ options.otherArgs = options.otherArgs || {};
580
+ options.otherArgs.headers = options.otherArgs.headers || {};
581
+ options.otherArgs.headers['x-goog-request-params'] =
582
+ this._gaxModule.routingHeader.fromParams({
583
+ project: request.project ?? '',
584
+ });
585
+ this.initialize().catch((err) => {
586
+ throw err;
587
+ });
588
+ const wrappedCallback = callback
589
+ ? (error, values, nextPageRequest, rawResponse) => {
590
+ this._log.info('listTopics values %j', values);
591
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
592
+ }
593
+ : undefined;
594
+ this._log.info('listTopics request %j', request);
595
+ return this.innerApiCalls
596
+ .listTopics(request, options, wrappedCallback)
597
+ ?.then(([response, input, output]) => {
598
+ this._log.info('listTopics values %j', response);
599
+ return [response, input, output];
600
+ });
601
+ }
602
+ /**
603
+ * Equivalent to `listTopics`, but returns a NodeJS Stream object.
604
+ * @param {Object} request
605
+ * The request object that will be sent.
606
+ * @param {string} request.project
607
+ * Required. The name of the project in which to list topics.
608
+ * Format is `projects/{project-id}`.
609
+ * @param {number} [request.pageSize]
610
+ * Optional. Maximum number of topics to return.
611
+ * @param {string} [request.pageToken]
612
+ * Optional. The value returned by the last `ListTopicsResponse`; indicates
613
+ * that this is a continuation of a prior `ListTopics` call, and that the
614
+ * system should return the next page of data.
615
+ * @param {object} [options]
616
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
617
+ * @returns {Stream}
618
+ * An object stream which emits an object representing {@link protos.google.pubsub.v1.Topic|Topic} on 'data' event.
619
+ * The client library will perform auto-pagination by default: it will call the API as many
620
+ * times as needed. Note that it can affect your quota.
621
+ * We recommend using `listTopicsAsync()`
622
+ * method described below for async iteration which you can stop as needed.
623
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
624
+ * for more details and examples.
625
+ */
626
+ listTopicsStream(request, options) {
627
+ request = request || {};
628
+ options = options || {};
629
+ options.otherArgs = options.otherArgs || {};
630
+ options.otherArgs.headers = options.otherArgs.headers || {};
631
+ options.otherArgs.headers['x-goog-request-params'] =
632
+ this._gaxModule.routingHeader.fromParams({
633
+ project: request.project ?? '',
634
+ });
635
+ const defaultCallSettings = this._defaults['listTopics'];
636
+ const callSettings = defaultCallSettings.merge(options);
637
+ this.initialize().catch((err) => {
638
+ throw err;
639
+ });
640
+ this._log.info('listTopics stream %j', request);
641
+ return this.descriptors.page.listTopics.createStream(this.innerApiCalls.listTopics, request, callSettings);
642
+ }
643
+ /**
644
+ * Equivalent to `listTopics`, but returns an iterable object.
645
+ *
646
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
647
+ * @param {Object} request
648
+ * The request object that will be sent.
649
+ * @param {string} request.project
650
+ * Required. The name of the project in which to list topics.
651
+ * Format is `projects/{project-id}`.
652
+ * @param {number} [request.pageSize]
653
+ * Optional. Maximum number of topics to return.
654
+ * @param {string} [request.pageToken]
655
+ * Optional. The value returned by the last `ListTopicsResponse`; indicates
656
+ * that this is a continuation of a prior `ListTopics` call, and that the
657
+ * system should return the next page of data.
658
+ * @param {object} [options]
659
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
660
+ * @returns {Object}
661
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
662
+ * When you iterate the returned iterable, each element will be an object representing
663
+ * {@link protos.google.pubsub.v1.Topic|Topic}. The API will be called under the hood as needed, once per the page,
664
+ * so you can stop the iteration when you don't need more results.
665
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
666
+ * for more details and examples.
667
+ * @example <caption>include:samples/generated/v1/publisher.list_topics.js</caption>
668
+ * region_tag:pubsub_v1_generated_Publisher_ListTopics_async
669
+ */
670
+ listTopicsAsync(request, options) {
671
+ request = request || {};
672
+ options = options || {};
673
+ options.otherArgs = options.otherArgs || {};
674
+ options.otherArgs.headers = options.otherArgs.headers || {};
675
+ options.otherArgs.headers['x-goog-request-params'] =
676
+ this._gaxModule.routingHeader.fromParams({
677
+ project: request.project ?? '',
678
+ });
679
+ const defaultCallSettings = this._defaults['listTopics'];
680
+ const callSettings = defaultCallSettings.merge(options);
681
+ this.initialize().catch((err) => {
682
+ throw err;
683
+ });
684
+ this._log.info('listTopics iterate %j', request);
685
+ return this.descriptors.page.listTopics.asyncIterate(this.innerApiCalls['listTopics'], request, callSettings);
686
+ }
687
+ listTopicSubscriptions(request, optionsOrCallback, callback) {
688
+ request = request || {};
689
+ let options;
690
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
691
+ callback = optionsOrCallback;
692
+ options = {};
693
+ }
694
+ else {
695
+ options = optionsOrCallback;
696
+ }
697
+ options = options || {};
698
+ options.otherArgs = options.otherArgs || {};
699
+ options.otherArgs.headers = options.otherArgs.headers || {};
700
+ options.otherArgs.headers['x-goog-request-params'] =
701
+ this._gaxModule.routingHeader.fromParams({
702
+ topic: request.topic ?? '',
703
+ });
704
+ this.initialize().catch((err) => {
705
+ throw err;
706
+ });
707
+ const wrappedCallback = callback
708
+ ? (error, values, nextPageRequest, rawResponse) => {
709
+ this._log.info('listTopicSubscriptions values %j', values);
710
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
711
+ }
712
+ : undefined;
713
+ this._log.info('listTopicSubscriptions request %j', request);
714
+ return this.innerApiCalls
715
+ .listTopicSubscriptions(request, options, wrappedCallback)
716
+ ?.then(([response, input, output]) => {
717
+ this._log.info('listTopicSubscriptions values %j', response);
718
+ return [response, input, output];
719
+ });
720
+ }
721
+ /**
722
+ * Equivalent to `listTopicSubscriptions`, but returns a NodeJS Stream object.
723
+ * @param {Object} request
724
+ * The request object that will be sent.
725
+ * @param {string} request.topic
726
+ * Required. The name of the topic that subscriptions are attached to.
727
+ * Format is `projects/{project}/topics/{topic}`.
728
+ * @param {number} [request.pageSize]
729
+ * Optional. Maximum number of subscription names to return.
730
+ * @param {string} [request.pageToken]
731
+ * Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
732
+ * indicates that this is a continuation of a prior `ListTopicSubscriptions`
733
+ * call, and that the system should return the next page of data.
734
+ * @param {object} [options]
735
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
736
+ * @returns {Stream}
737
+ * An object stream which emits an object representing string on 'data' event.
738
+ * The client library will perform auto-pagination by default: it will call the API as many
739
+ * times as needed. Note that it can affect your quota.
740
+ * We recommend using `listTopicSubscriptionsAsync()`
741
+ * method described below for async iteration which you can stop as needed.
742
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
743
+ * for more details and examples.
744
+ */
745
+ listTopicSubscriptionsStream(request, options) {
746
+ request = request || {};
747
+ options = options || {};
748
+ options.otherArgs = options.otherArgs || {};
749
+ options.otherArgs.headers = options.otherArgs.headers || {};
750
+ options.otherArgs.headers['x-goog-request-params'] =
751
+ this._gaxModule.routingHeader.fromParams({
752
+ topic: request.topic ?? '',
753
+ });
754
+ const defaultCallSettings = this._defaults['listTopicSubscriptions'];
755
+ const callSettings = defaultCallSettings.merge(options);
756
+ this.initialize().catch((err) => {
757
+ throw err;
758
+ });
759
+ this._log.info('listTopicSubscriptions stream %j', request);
760
+ return this.descriptors.page.listTopicSubscriptions.createStream(this.innerApiCalls.listTopicSubscriptions, request, callSettings);
761
+ }
762
+ /**
763
+ * Equivalent to `listTopicSubscriptions`, but returns an iterable object.
764
+ *
765
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
766
+ * @param {Object} request
767
+ * The request object that will be sent.
768
+ * @param {string} request.topic
769
+ * Required. The name of the topic that subscriptions are attached to.
770
+ * Format is `projects/{project}/topics/{topic}`.
771
+ * @param {number} [request.pageSize]
772
+ * Optional. Maximum number of subscription names to return.
773
+ * @param {string} [request.pageToken]
774
+ * Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
775
+ * indicates that this is a continuation of a prior `ListTopicSubscriptions`
776
+ * call, and that the system should return the next page of data.
777
+ * @param {object} [options]
778
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
779
+ * @returns {Object}
780
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
781
+ * When you iterate the returned iterable, each element will be an object representing
782
+ * string. The API will be called under the hood as needed, once per the page,
783
+ * so you can stop the iteration when you don't need more results.
784
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
785
+ * for more details and examples.
786
+ * @example <caption>include:samples/generated/v1/publisher.list_topic_subscriptions.js</caption>
787
+ * region_tag:pubsub_v1_generated_Publisher_ListTopicSubscriptions_async
788
+ */
789
+ listTopicSubscriptionsAsync(request, options) {
790
+ request = request || {};
791
+ options = options || {};
792
+ options.otherArgs = options.otherArgs || {};
793
+ options.otherArgs.headers = options.otherArgs.headers || {};
794
+ options.otherArgs.headers['x-goog-request-params'] =
795
+ this._gaxModule.routingHeader.fromParams({
796
+ topic: request.topic ?? '',
797
+ });
798
+ const defaultCallSettings = this._defaults['listTopicSubscriptions'];
799
+ const callSettings = defaultCallSettings.merge(options);
800
+ this.initialize().catch((err) => {
801
+ throw err;
802
+ });
803
+ this._log.info('listTopicSubscriptions iterate %j', request);
804
+ return this.descriptors.page.listTopicSubscriptions.asyncIterate(this.innerApiCalls['listTopicSubscriptions'], request, callSettings);
805
+ }
806
+ listTopicSnapshots(request, optionsOrCallback, callback) {
807
+ request = request || {};
808
+ let options;
809
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
810
+ callback = optionsOrCallback;
811
+ options = {};
812
+ }
813
+ else {
814
+ options = optionsOrCallback;
815
+ }
816
+ options = options || {};
817
+ options.otherArgs = options.otherArgs || {};
818
+ options.otherArgs.headers = options.otherArgs.headers || {};
819
+ options.otherArgs.headers['x-goog-request-params'] =
820
+ this._gaxModule.routingHeader.fromParams({
821
+ topic: request.topic ?? '',
822
+ });
823
+ this.initialize().catch((err) => {
824
+ throw err;
825
+ });
826
+ const wrappedCallback = callback
827
+ ? (error, values, nextPageRequest, rawResponse) => {
828
+ this._log.info('listTopicSnapshots values %j', values);
829
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
830
+ }
831
+ : undefined;
832
+ this._log.info('listTopicSnapshots request %j', request);
833
+ return this.innerApiCalls
834
+ .listTopicSnapshots(request, options, wrappedCallback)
835
+ ?.then(([response, input, output]) => {
836
+ this._log.info('listTopicSnapshots values %j', response);
837
+ return [response, input, output];
838
+ });
839
+ }
840
+ /**
841
+ * Equivalent to `listTopicSnapshots`, but returns a NodeJS Stream object.
842
+ * @param {Object} request
843
+ * The request object that will be sent.
844
+ * @param {string} request.topic
845
+ * Required. The name of the topic that snapshots are attached to.
846
+ * Format is `projects/{project}/topics/{topic}`.
847
+ * @param {number} [request.pageSize]
848
+ * Optional. Maximum number of snapshot names to return.
849
+ * @param {string} [request.pageToken]
850
+ * Optional. The value returned by the last `ListTopicSnapshotsResponse`;
851
+ * indicates that this is a continuation of a prior `ListTopicSnapshots` call,
852
+ * and that the system should return the next page of data.
853
+ * @param {object} [options]
854
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
855
+ * @returns {Stream}
856
+ * An object stream which emits an object representing string on 'data' event.
857
+ * The client library will perform auto-pagination by default: it will call the API as many
858
+ * times as needed. Note that it can affect your quota.
859
+ * We recommend using `listTopicSnapshotsAsync()`
860
+ * method described below for async iteration which you can stop as needed.
861
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
862
+ * for more details and examples.
863
+ */
864
+ listTopicSnapshotsStream(request, options) {
865
+ request = request || {};
866
+ options = options || {};
867
+ options.otherArgs = options.otherArgs || {};
868
+ options.otherArgs.headers = options.otherArgs.headers || {};
869
+ options.otherArgs.headers['x-goog-request-params'] =
870
+ this._gaxModule.routingHeader.fromParams({
871
+ topic: request.topic ?? '',
872
+ });
873
+ const defaultCallSettings = this._defaults['listTopicSnapshots'];
874
+ const callSettings = defaultCallSettings.merge(options);
875
+ this.initialize().catch((err) => {
876
+ throw err;
877
+ });
878
+ this._log.info('listTopicSnapshots stream %j', request);
879
+ return this.descriptors.page.listTopicSnapshots.createStream(this.innerApiCalls.listTopicSnapshots, request, callSettings);
880
+ }
881
+ /**
882
+ * Equivalent to `listTopicSnapshots`, but returns an iterable object.
883
+ *
884
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
885
+ * @param {Object} request
886
+ * The request object that will be sent.
887
+ * @param {string} request.topic
888
+ * Required. The name of the topic that snapshots are attached to.
889
+ * Format is `projects/{project}/topics/{topic}`.
890
+ * @param {number} [request.pageSize]
891
+ * Optional. Maximum number of snapshot names to return.
892
+ * @param {string} [request.pageToken]
893
+ * Optional. The value returned by the last `ListTopicSnapshotsResponse`;
894
+ * indicates that this is a continuation of a prior `ListTopicSnapshots` call,
895
+ * and that the system should return the next page of data.
896
+ * @param {object} [options]
897
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
898
+ * @returns {Object}
899
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
900
+ * When you iterate the returned iterable, each element will be an object representing
901
+ * string. The API will be called under the hood as needed, once per the page,
902
+ * so you can stop the iteration when you don't need more results.
903
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
904
+ * for more details and examples.
905
+ * @example <caption>include:samples/generated/v1/publisher.list_topic_snapshots.js</caption>
906
+ * region_tag:pubsub_v1_generated_Publisher_ListTopicSnapshots_async
907
+ */
908
+ listTopicSnapshotsAsync(request, options) {
909
+ request = request || {};
910
+ options = options || {};
911
+ options.otherArgs = options.otherArgs || {};
912
+ options.otherArgs.headers = options.otherArgs.headers || {};
913
+ options.otherArgs.headers['x-goog-request-params'] =
914
+ this._gaxModule.routingHeader.fromParams({
915
+ topic: request.topic ?? '',
916
+ });
917
+ const defaultCallSettings = this._defaults['listTopicSnapshots'];
918
+ const callSettings = defaultCallSettings.merge(options);
919
+ this.initialize().catch((err) => {
920
+ throw err;
921
+ });
922
+ this._log.info('listTopicSnapshots iterate %j', request);
923
+ return this.descriptors.page.listTopicSnapshots.asyncIterate(this.innerApiCalls['listTopicSnapshots'], request, callSettings);
924
+ }
925
+ /**
926
+ * Gets the access control policy for a resource. Returns an empty policy
927
+ * if the resource exists and does not have a policy set.
928
+ *
929
+ * @param {Object} request
930
+ * The request object that will be sent.
931
+ * @param {string} request.resource
932
+ * REQUIRED: The resource for which the policy is being requested.
933
+ * See the operation documentation for the appropriate value for this field.
934
+ * @param {Object} [request.options]
935
+ * OPTIONAL: A `GetPolicyOptions` object for specifying options to
936
+ * `GetIamPolicy`. This field is only used by Cloud IAM.
937
+ *
938
+ * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}.
939
+ * @param {Object} [options]
940
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
941
+ * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details.
942
+ * @param {function(?Error, ?Object)} [callback]
943
+ * The function which will be called with the result of the API call.
944
+ *
945
+ * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}.
946
+ * @returns {Promise} - The promise which resolves to an array.
947
+ * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}.
948
+ * The promise has a method named "cancel" which cancels the ongoing API call.
949
+ */
950
+ getIamPolicy(request, options, callback) {
951
+ return this.iamClient.getIamPolicy(request, options, callback);
952
+ }
953
+ /**
954
+ * Returns permissions that a caller has on the specified resource. If the
955
+ * resource does not exist, this will return an empty set of
956
+ * permissions, not a NOT_FOUND error.
957
+ *
958
+ * Note: This operation is designed to be used for building
959
+ * permission-aware UIs and command-line tools, not for authorization
960
+ * checking. This operation may "fail open" without warning.
961
+ *
962
+ * @param {Object} request
963
+ * The request object that will be sent.
964
+ * @param {string} request.resource
965
+ * REQUIRED: The resource for which the policy detail is being requested.
966
+ * See the operation documentation for the appropriate value for this field.
967
+ * @param {string[]} request.permissions
968
+ * The set of permissions to check for the `resource`. Permissions with
969
+ * wildcards (such as '*' or 'storage.*') are not allowed. For more
970
+ * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }.
971
+ * @param {Object} [options]
972
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
973
+ * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details.
974
+ * @param {function(?Error, ?Object)} [callback]
975
+ * The function which will be called with the result of the API call.
976
+ *
977
+ * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}.
978
+ * @returns {Promise} - The promise which resolves to an array.
979
+ * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}.
980
+ * The promise has a method named "cancel" which cancels the ongoing API call.
981
+ */
982
+ setIamPolicy(request, options, callback) {
983
+ return this.iamClient.setIamPolicy(request, options, callback);
984
+ }
985
+ /**
986
+ * Returns permissions that a caller has on the specified resource. If the
987
+ * resource does not exist, this will return an empty set of
988
+ * permissions, not a NOT_FOUND error.
989
+ *
990
+ * Note: This operation is designed to be used for building
991
+ * permission-aware UIs and command-line tools, not for authorization
992
+ * checking. This operation may "fail open" without warning.
993
+ *
994
+ * @param {Object} request
995
+ * The request object that will be sent.
996
+ * @param {string} request.resource
997
+ * REQUIRED: The resource for which the policy detail is being requested.
998
+ * See the operation documentation for the appropriate value for this field.
999
+ * @param {string[]} request.permissions
1000
+ * The set of permissions to check for the `resource`. Permissions with
1001
+ * wildcards (such as '*' or 'storage.*') are not allowed. For more
1002
+ * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }.
1003
+ * @param {Object} [options]
1004
+ * Optional parameters. You can override the default settings for this call, e.g, timeout,
1005
+ * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details.
1006
+ * @param {function(?Error, ?Object)} [callback]
1007
+ * The function which will be called with the result of the API call.
1008
+ *
1009
+ * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}.
1010
+ * @returns {Promise} - The promise which resolves to an array.
1011
+ * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}.
1012
+ * The promise has a method named "cancel" which cancels the ongoing API call.
1013
+ *
1014
+ */
1015
+ testIamPermissions(request, options, callback) {
1016
+ return this.iamClient.testIamPermissions(request, options, callback);
1017
+ }
1018
+ // --------------------
1019
+ // -- Path templates --
1020
+ // --------------------
1021
+ /**
1022
+ * Return a fully-qualified cryptoKey resource name string.
1023
+ *
1024
+ * @param {string} project
1025
+ * @param {string} location
1026
+ * @param {string} key_ring
1027
+ * @param {string} crypto_key
1028
+ * @returns {string} Resource name string.
1029
+ */
1030
+ cryptoKeyPath(project, location, keyRing, cryptoKey) {
1031
+ return this.pathTemplates.cryptoKeyPathTemplate.render({
1032
+ project: project,
1033
+ location: location,
1034
+ key_ring: keyRing,
1035
+ crypto_key: cryptoKey,
1036
+ });
1037
+ }
1038
+ /**
1039
+ * Parse the project from CryptoKey resource.
1040
+ *
1041
+ * @param {string} cryptoKeyName
1042
+ * A fully-qualified path representing CryptoKey resource.
1043
+ * @returns {string} A string representing the project.
1044
+ */
1045
+ matchProjectFromCryptoKeyName(cryptoKeyName) {
1046
+ return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName)
1047
+ .project;
1048
+ }
1049
+ /**
1050
+ * Parse the location from CryptoKey resource.
1051
+ *
1052
+ * @param {string} cryptoKeyName
1053
+ * A fully-qualified path representing CryptoKey resource.
1054
+ * @returns {string} A string representing the location.
1055
+ */
1056
+ matchLocationFromCryptoKeyName(cryptoKeyName) {
1057
+ return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName)
1058
+ .location;
1059
+ }
1060
+ /**
1061
+ * Parse the key_ring from CryptoKey resource.
1062
+ *
1063
+ * @param {string} cryptoKeyName
1064
+ * A fully-qualified path representing CryptoKey resource.
1065
+ * @returns {string} A string representing the key_ring.
1066
+ */
1067
+ matchKeyRingFromCryptoKeyName(cryptoKeyName) {
1068
+ return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName)
1069
+ .key_ring;
1070
+ }
1071
+ /**
1072
+ * Parse the crypto_key from CryptoKey resource.
1073
+ *
1074
+ * @param {string} cryptoKeyName
1075
+ * A fully-qualified path representing CryptoKey resource.
1076
+ * @returns {string} A string representing the crypto_key.
1077
+ */
1078
+ matchCryptoKeyFromCryptoKeyName(cryptoKeyName) {
1079
+ return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName)
1080
+ .crypto_key;
1081
+ }
1082
+ /**
1083
+ * Return a fully-qualified project resource name string.
1084
+ *
1085
+ * @param {string} project
1086
+ * @returns {string} Resource name string.
1087
+ */
1088
+ projectPath(project) {
1089
+ return this.pathTemplates.projectPathTemplate.render({
1090
+ project: project,
1091
+ });
1092
+ }
1093
+ /**
1094
+ * Parse the project from Project resource.
1095
+ *
1096
+ * @param {string} projectName
1097
+ * A fully-qualified path representing Project resource.
1098
+ * @returns {string} A string representing the project.
1099
+ */
1100
+ matchProjectFromProjectName(projectName) {
1101
+ return this.pathTemplates.projectPathTemplate.match(projectName).project;
1102
+ }
1103
+ /**
1104
+ * Return a fully-qualified projectTopics resource name string.
1105
+ *
1106
+ * @param {string} project
1107
+ * @param {string} topic
1108
+ * @returns {string} Resource name string.
1109
+ */
1110
+ projectTopicsPath(project, topic) {
1111
+ return this.pathTemplates.projectTopicsPathTemplate.render({
1112
+ project: project,
1113
+ topic: topic,
1114
+ });
1115
+ }
1116
+ /**
1117
+ * Parse the project from ProjectTopics resource.
1118
+ *
1119
+ * @param {string} projectTopicsName
1120
+ * A fully-qualified path representing project_topics resource.
1121
+ * @returns {string} A string representing the project.
1122
+ */
1123
+ matchProjectFromProjectTopicsName(projectTopicsName) {
1124
+ return this.pathTemplates.projectTopicsPathTemplate.match(projectTopicsName)
1125
+ .project;
1126
+ }
1127
+ /**
1128
+ * Parse the topic from ProjectTopics resource.
1129
+ *
1130
+ * @param {string} projectTopicsName
1131
+ * A fully-qualified path representing project_topics resource.
1132
+ * @returns {string} A string representing the topic.
1133
+ */
1134
+ matchTopicFromProjectTopicsName(projectTopicsName) {
1135
+ return this.pathTemplates.projectTopicsPathTemplate.match(projectTopicsName)
1136
+ .topic;
1137
+ }
1138
+ /**
1139
+ * Return a fully-qualified schema resource name string.
1140
+ *
1141
+ * @param {string} project
1142
+ * @param {string} schema
1143
+ * @returns {string} Resource name string.
1144
+ */
1145
+ schemaPath(project, schema) {
1146
+ return this.pathTemplates.schemaPathTemplate.render({
1147
+ project: project,
1148
+ schema: schema,
1149
+ });
1150
+ }
1151
+ /**
1152
+ * Parse the project from Schema resource.
1153
+ *
1154
+ * @param {string} schemaName
1155
+ * A fully-qualified path representing Schema resource.
1156
+ * @returns {string} A string representing the project.
1157
+ */
1158
+ matchProjectFromSchemaName(schemaName) {
1159
+ return this.pathTemplates.schemaPathTemplate.match(schemaName).project;
1160
+ }
1161
+ /**
1162
+ * Parse the schema from Schema resource.
1163
+ *
1164
+ * @param {string} schemaName
1165
+ * A fully-qualified path representing Schema resource.
1166
+ * @returns {string} A string representing the schema.
1167
+ */
1168
+ matchSchemaFromSchemaName(schemaName) {
1169
+ return this.pathTemplates.schemaPathTemplate.match(schemaName).schema;
1170
+ }
1171
+ /**
1172
+ * Return a fully-qualified snapshot resource name string.
1173
+ *
1174
+ * @param {string} project
1175
+ * @param {string} snapshot
1176
+ * @returns {string} Resource name string.
1177
+ */
1178
+ snapshotPath(project, snapshot) {
1179
+ return this.pathTemplates.snapshotPathTemplate.render({
1180
+ project: project,
1181
+ snapshot: snapshot,
1182
+ });
1183
+ }
1184
+ /**
1185
+ * Parse the project from Snapshot resource.
1186
+ *
1187
+ * @param {string} snapshotName
1188
+ * A fully-qualified path representing Snapshot resource.
1189
+ * @returns {string} A string representing the project.
1190
+ */
1191
+ matchProjectFromSnapshotName(snapshotName) {
1192
+ return this.pathTemplates.snapshotPathTemplate.match(snapshotName).project;
1193
+ }
1194
+ /**
1195
+ * Parse the snapshot from Snapshot resource.
1196
+ *
1197
+ * @param {string} snapshotName
1198
+ * A fully-qualified path representing Snapshot resource.
1199
+ * @returns {string} A string representing the snapshot.
1200
+ */
1201
+ matchSnapshotFromSnapshotName(snapshotName) {
1202
+ return this.pathTemplates.snapshotPathTemplate.match(snapshotName).snapshot;
1203
+ }
1204
+ /**
1205
+ * Return a fully-qualified subscription resource name string.
1206
+ *
1207
+ * @param {string} project
1208
+ * @param {string} subscription
1209
+ * @returns {string} Resource name string.
1210
+ */
1211
+ subscriptionPath(project, subscription) {
1212
+ return this.pathTemplates.subscriptionPathTemplate.render({
1213
+ project: project,
1214
+ subscription: subscription,
1215
+ });
1216
+ }
1217
+ /**
1218
+ * Parse the project from Subscription resource.
1219
+ *
1220
+ * @param {string} subscriptionName
1221
+ * A fully-qualified path representing Subscription resource.
1222
+ * @returns {string} A string representing the project.
1223
+ */
1224
+ matchProjectFromSubscriptionName(subscriptionName) {
1225
+ return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName)
1226
+ .project;
1227
+ }
1228
+ /**
1229
+ * Parse the subscription from Subscription resource.
1230
+ *
1231
+ * @param {string} subscriptionName
1232
+ * A fully-qualified path representing Subscription resource.
1233
+ * @returns {string} A string representing the subscription.
1234
+ */
1235
+ matchSubscriptionFromSubscriptionName(subscriptionName) {
1236
+ return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName)
1237
+ .subscription;
1238
+ }
1239
+ /**
1240
+ * Terminate the gRPC channel and close the client.
1241
+ *
1242
+ * The client will no longer be usable and all future behavior is undefined.
1243
+ * @returns {Promise} A promise that resolves when the client is closed.
1244
+ */
1245
+ close() {
1246
+ if (this.publisherStub && !this._terminated) {
1247
+ return this.publisherStub.then((stub) => {
1248
+ this._log.info('ending gRPC channel');
1249
+ this._terminated = true;
1250
+ stub.close();
1251
+ this.iamClient.close().catch((err) => {
1252
+ throw err;
1253
+ });
1254
+ });
1255
+ }
1256
+ return Promise.resolve();
1257
+ }
1258
+ }
1259
+ exports.PublisherClient = PublisherClient;
1260
+ //# sourceMappingURL=publisher_client.js.map