@google-analytics/data 5.0.0 → 5.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.
@@ -97,26 +97,17 @@ class AlphaAnalyticsDataClient {
97
97
  constructor(opts, gaxInstance) {
98
98
  // Ensure that options include all the required fields.
99
99
  const staticMembers = this.constructor;
100
- if (opts?.universe_domain &&
101
- opts?.universeDomain &&
102
- opts?.universe_domain !== opts?.universeDomain) {
100
+ if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) {
103
101
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
104
102
  }
105
- const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
106
- ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
107
- : undefined;
108
- this._universeDomain =
109
- opts?.universeDomain ??
110
- opts?.universe_domain ??
111
- universeDomainEnvVar ??
112
- 'googleapis.com';
103
+ const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
104
+ this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com';
113
105
  this._servicePath = 'analyticsdata.' + this._universeDomain;
114
106
  const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
115
107
  this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
116
108
  const port = opts?.port || staticMembers.port;
117
109
  const clientConfig = opts?.clientConfig ?? {};
118
- const fallback = opts?.fallback ??
119
- (typeof window !== 'undefined' && typeof window?.fetch === 'function');
110
+ const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
120
111
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
121
112
  // Request numeric enum values if REST transport is used.
122
113
  opts.numericEnums = true;
@@ -145,7 +136,10 @@ class AlphaAnalyticsDataClient {
145
136
  this.auth.defaultScopes = staticMembers.scopes;
146
137
  }
147
138
  // Determine the client header string.
148
- const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
139
+ const clientHeader = [
140
+ `gax/${this._gaxModule.version}`,
141
+ `gapic/${version}`,
142
+ ];
149
143
  if (typeof process === 'object' && 'versions' in process) {
150
144
  clientHeader.push(`gl-node/${process.versions.node}`);
151
145
  }
@@ -179,30 +173,28 @@ class AlphaAnalyticsDataClient {
179
173
  this.descriptors.page = {
180
174
  listAudienceLists: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'audienceLists'),
181
175
  listRecurringAudienceLists: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recurringAudienceLists'),
182
- listReportTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reportTasks'),
176
+ listReportTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reportTasks')
183
177
  };
184
- const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
178
+ const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
185
179
  // This API contains "long-running operations", which return a
186
180
  // an Operation object that allows for tracking of the operation,
187
181
  // rather than holding a request open.
188
182
  const lroOptions = {
189
183
  auth: this.auth,
190
- grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
184
+ grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined
191
185
  };
192
186
  if (opts.fallback) {
193
187
  lroOptions.protoJson = protoFilesRoot;
194
188
  lroOptions.httpRules = [];
195
189
  }
196
- this.operationsClient = this._gaxModule
197
- .lro(lroOptions)
198
- .operationsClient(opts);
190
+ this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts);
199
191
  const createAudienceListResponse = protoFilesRoot.lookup('.google.analytics.data.v1alpha.AudienceList');
200
192
  const createAudienceListMetadata = protoFilesRoot.lookup('.google.analytics.data.v1alpha.AudienceListMetadata');
201
193
  const createReportTaskResponse = protoFilesRoot.lookup('.google.analytics.data.v1alpha.ReportTask');
202
194
  const createReportTaskMetadata = protoFilesRoot.lookup('.google.analytics.data.v1alpha.ReportTaskMetadata');
203
195
  this.descriptors.longrunning = {
204
196
  createAudienceList: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createAudienceListResponse.decode.bind(createAudienceListResponse), createAudienceListMetadata.decode.bind(createAudienceListMetadata)),
205
- createReportTask: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createReportTaskResponse.decode.bind(createReportTaskResponse), createReportTaskMetadata.decode.bind(createReportTaskMetadata)),
197
+ createReportTask: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createReportTaskResponse.decode.bind(createReportTaskResponse), createReportTaskMetadata.decode.bind(createReportTaskMetadata))
206
198
  };
207
199
  // Put together the default options sent with requests.
208
200
  this._defaults = this._gaxGrpc.constructSettings('google.analytics.data.v1alpha.AlphaAnalyticsData', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -231,29 +223,13 @@ class AlphaAnalyticsDataClient {
231
223
  }
232
224
  // Put together the "service stub" for
233
225
  // google.analytics.data.v1alpha.AlphaAnalyticsData.
234
- this.alphaAnalyticsDataStub = this._gaxGrpc.createStub(this._opts.fallback
235
- ? this._protos.lookupService('google.analytics.data.v1alpha.AlphaAnalyticsData')
236
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
237
- this._protos.google.analytics.data.v1alpha
238
- .AlphaAnalyticsData, this._opts, this._providedCustomServicePath);
226
+ this.alphaAnalyticsDataStub = this._gaxGrpc.createStub(this._opts.fallback ?
227
+ this._protos.lookupService('google.analytics.data.v1alpha.AlphaAnalyticsData') :
228
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
229
+ this._protos.google.analytics.data.v1alpha.AlphaAnalyticsData, this._opts, this._providedCustomServicePath);
239
230
  // Iterate over each of the methods that the service provides
240
231
  // and create an API call method for each.
241
- const alphaAnalyticsDataStubMethods = [
242
- 'runFunnelReport',
243
- 'createAudienceList',
244
- 'queryAudienceList',
245
- 'sheetExportAudienceList',
246
- 'getAudienceList',
247
- 'listAudienceLists',
248
- 'createRecurringAudienceList',
249
- 'getRecurringAudienceList',
250
- 'listRecurringAudienceLists',
251
- 'getPropertyQuotasSnapshot',
252
- 'createReportTask',
253
- 'queryReportTask',
254
- 'getReportTask',
255
- 'listReportTasks',
256
- ];
232
+ const alphaAnalyticsDataStubMethods = ['runFunnelReport', 'createAudienceList', 'queryAudienceList', 'sheetExportAudienceList', 'getAudienceList', 'listAudienceLists', 'createRecurringAudienceList', 'getRecurringAudienceList', 'listRecurringAudienceLists', 'getPropertyQuotasSnapshot', 'createReportTask', 'queryReportTask', 'getReportTask', 'listReportTasks'];
257
233
  for (const methodName of alphaAnalyticsDataStubMethods) {
258
234
  const callPromise = this.alphaAnalyticsDataStub.then(stub => (...args) => {
259
235
  if (this._terminated) {
@@ -278,8 +254,7 @@ class AlphaAnalyticsDataClient {
278
254
  * @returns {string} The DNS address for this service.
279
255
  */
280
256
  static get servicePath() {
281
- if (typeof process === 'object' &&
282
- typeof process.emitWarning === 'function') {
257
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
283
258
  process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
284
259
  }
285
260
  return 'analyticsdata.googleapis.com';
@@ -290,8 +265,7 @@ class AlphaAnalyticsDataClient {
290
265
  * @returns {string} The DNS address for this service.
291
266
  */
292
267
  static get apiEndpoint() {
293
- if (typeof process === 'object' &&
294
- typeof process.emitWarning === 'function') {
268
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
295
269
  process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
296
270
  }
297
271
  return 'analyticsdata.googleapis.com';
@@ -324,7 +298,7 @@ class AlphaAnalyticsDataClient {
324
298
  'https://www.googleapis.com/auth/analytics.readonly',
325
299
  'https://www.googleapis.com/auth/drive',
326
300
  'https://www.googleapis.com/auth/drive.file',
327
- 'https://www.googleapis.com/auth/spreadsheets',
301
+ 'https://www.googleapis.com/auth/spreadsheets'
328
302
  ];
329
303
  }
330
304
  /**
@@ -351,11 +325,10 @@ class AlphaAnalyticsDataClient {
351
325
  options = options || {};
352
326
  options.otherArgs = options.otherArgs || {};
353
327
  options.otherArgs.headers = options.otherArgs.headers || {};
354
- options.otherArgs.headers['x-goog-request-params'] =
355
- this._gaxModule.routingHeader.fromParams({
356
- property: request.property ?? '',
357
- });
358
- this.initialize();
328
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
329
+ 'property': request.property ?? '',
330
+ });
331
+ this.initialize().catch(err => { throw err; });
359
332
  this._log.info('runFunnelReport request %j', request);
360
333
  const wrappedCallback = callback
361
334
  ? (error, response, options, rawResponse) => {
@@ -363,11 +336,16 @@ class AlphaAnalyticsDataClient {
363
336
  callback(error, response, options, rawResponse); // We verified callback above.
364
337
  }
365
338
  : undefined;
366
- return this.innerApiCalls
367
- .runFunnelReport(request, options, wrappedCallback)
339
+ return this.innerApiCalls.runFunnelReport(request, options, wrappedCallback)
368
340
  ?.then(([response, options, rawResponse]) => {
369
341
  this._log.info('runFunnelReport response %j', response);
370
342
  return [response, options, rawResponse];
343
+ }).catch((error) => {
344
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
345
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
346
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
347
+ }
348
+ throw error;
371
349
  });
372
350
  }
373
351
  queryAudienceList(request, optionsOrCallback, callback) {
@@ -383,11 +361,10 @@ class AlphaAnalyticsDataClient {
383
361
  options = options || {};
384
362
  options.otherArgs = options.otherArgs || {};
385
363
  options.otherArgs.headers = options.otherArgs.headers || {};
386
- options.otherArgs.headers['x-goog-request-params'] =
387
- this._gaxModule.routingHeader.fromParams({
388
- name: request.name ?? '',
389
- });
390
- this.initialize();
364
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
365
+ 'name': request.name ?? '',
366
+ });
367
+ this.initialize().catch(err => { throw err; });
391
368
  this._log.info('queryAudienceList request %j', request);
392
369
  const wrappedCallback = callback
393
370
  ? (error, response, options, rawResponse) => {
@@ -395,11 +372,16 @@ class AlphaAnalyticsDataClient {
395
372
  callback(error, response, options, rawResponse); // We verified callback above.
396
373
  }
397
374
  : undefined;
398
- return this.innerApiCalls
399
- .queryAudienceList(request, options, wrappedCallback)
375
+ return this.innerApiCalls.queryAudienceList(request, options, wrappedCallback)
400
376
  ?.then(([response, options, rawResponse]) => {
401
377
  this._log.info('queryAudienceList response %j', response);
402
378
  return [response, options, rawResponse];
379
+ }).catch((error) => {
380
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
381
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
382
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
383
+ }
384
+ throw error;
403
385
  });
404
386
  }
405
387
  sheetExportAudienceList(request, optionsOrCallback, callback) {
@@ -415,11 +397,10 @@ class AlphaAnalyticsDataClient {
415
397
  options = options || {};
416
398
  options.otherArgs = options.otherArgs || {};
417
399
  options.otherArgs.headers = options.otherArgs.headers || {};
418
- options.otherArgs.headers['x-goog-request-params'] =
419
- this._gaxModule.routingHeader.fromParams({
420
- name: request.name ?? '',
421
- });
422
- this.initialize();
400
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
401
+ 'name': request.name ?? '',
402
+ });
403
+ this.initialize().catch(err => { throw err; });
423
404
  this._log.info('sheetExportAudienceList request %j', request);
424
405
  const wrappedCallback = callback
425
406
  ? (error, response, options, rawResponse) => {
@@ -427,11 +408,16 @@ class AlphaAnalyticsDataClient {
427
408
  callback(error, response, options, rawResponse); // We verified callback above.
428
409
  }
429
410
  : undefined;
430
- return this.innerApiCalls
431
- .sheetExportAudienceList(request, options, wrappedCallback)
411
+ return this.innerApiCalls.sheetExportAudienceList(request, options, wrappedCallback)
432
412
  ?.then(([response, options, rawResponse]) => {
433
413
  this._log.info('sheetExportAudienceList response %j', response);
434
414
  return [response, options, rawResponse];
415
+ }).catch((error) => {
416
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
417
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
418
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
419
+ }
420
+ throw error;
435
421
  });
436
422
  }
437
423
  getAudienceList(request, optionsOrCallback, callback) {
@@ -447,11 +433,10 @@ class AlphaAnalyticsDataClient {
447
433
  options = options || {};
448
434
  options.otherArgs = options.otherArgs || {};
449
435
  options.otherArgs.headers = options.otherArgs.headers || {};
450
- options.otherArgs.headers['x-goog-request-params'] =
451
- this._gaxModule.routingHeader.fromParams({
452
- name: request.name ?? '',
453
- });
454
- this.initialize();
436
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
437
+ 'name': request.name ?? '',
438
+ });
439
+ this.initialize().catch(err => { throw err; });
455
440
  this._log.info('getAudienceList request %j', request);
456
441
  const wrappedCallback = callback
457
442
  ? (error, response, options, rawResponse) => {
@@ -459,11 +444,16 @@ class AlphaAnalyticsDataClient {
459
444
  callback(error, response, options, rawResponse); // We verified callback above.
460
445
  }
461
446
  : undefined;
462
- return this.innerApiCalls
463
- .getAudienceList(request, options, wrappedCallback)
447
+ return this.innerApiCalls.getAudienceList(request, options, wrappedCallback)
464
448
  ?.then(([response, options, rawResponse]) => {
465
449
  this._log.info('getAudienceList response %j', response);
466
450
  return [response, options, rawResponse];
451
+ }).catch((error) => {
452
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
453
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
454
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
455
+ }
456
+ throw error;
467
457
  });
468
458
  }
469
459
  createRecurringAudienceList(request, optionsOrCallback, callback) {
@@ -479,11 +469,10 @@ class AlphaAnalyticsDataClient {
479
469
  options = options || {};
480
470
  options.otherArgs = options.otherArgs || {};
481
471
  options.otherArgs.headers = options.otherArgs.headers || {};
482
- options.otherArgs.headers['x-goog-request-params'] =
483
- this._gaxModule.routingHeader.fromParams({
484
- parent: request.parent ?? '',
485
- });
486
- this.initialize();
472
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
473
+ 'parent': request.parent ?? '',
474
+ });
475
+ this.initialize().catch(err => { throw err; });
487
476
  this._log.info('createRecurringAudienceList request %j', request);
488
477
  const wrappedCallback = callback
489
478
  ? (error, response, options, rawResponse) => {
@@ -491,11 +480,16 @@ class AlphaAnalyticsDataClient {
491
480
  callback(error, response, options, rawResponse); // We verified callback above.
492
481
  }
493
482
  : undefined;
494
- return this.innerApiCalls
495
- .createRecurringAudienceList(request, options, wrappedCallback)
483
+ return this.innerApiCalls.createRecurringAudienceList(request, options, wrappedCallback)
496
484
  ?.then(([response, options, rawResponse]) => {
497
485
  this._log.info('createRecurringAudienceList response %j', response);
498
486
  return [response, options, rawResponse];
487
+ }).catch((error) => {
488
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
489
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
490
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
491
+ }
492
+ throw error;
499
493
  });
500
494
  }
501
495
  getRecurringAudienceList(request, optionsOrCallback, callback) {
@@ -511,11 +505,10 @@ class AlphaAnalyticsDataClient {
511
505
  options = options || {};
512
506
  options.otherArgs = options.otherArgs || {};
513
507
  options.otherArgs.headers = options.otherArgs.headers || {};
514
- options.otherArgs.headers['x-goog-request-params'] =
515
- this._gaxModule.routingHeader.fromParams({
516
- name: request.name ?? '',
517
- });
518
- this.initialize();
508
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
509
+ 'name': request.name ?? '',
510
+ });
511
+ this.initialize().catch(err => { throw err; });
519
512
  this._log.info('getRecurringAudienceList request %j', request);
520
513
  const wrappedCallback = callback
521
514
  ? (error, response, options, rawResponse) => {
@@ -523,11 +516,16 @@ class AlphaAnalyticsDataClient {
523
516
  callback(error, response, options, rawResponse); // We verified callback above.
524
517
  }
525
518
  : undefined;
526
- return this.innerApiCalls
527
- .getRecurringAudienceList(request, options, wrappedCallback)
519
+ return this.innerApiCalls.getRecurringAudienceList(request, options, wrappedCallback)
528
520
  ?.then(([response, options, rawResponse]) => {
529
521
  this._log.info('getRecurringAudienceList response %j', response);
530
522
  return [response, options, rawResponse];
523
+ }).catch((error) => {
524
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
525
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
526
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
527
+ }
528
+ throw error;
531
529
  });
532
530
  }
533
531
  getPropertyQuotasSnapshot(request, optionsOrCallback, callback) {
@@ -543,11 +541,10 @@ class AlphaAnalyticsDataClient {
543
541
  options = options || {};
544
542
  options.otherArgs = options.otherArgs || {};
545
543
  options.otherArgs.headers = options.otherArgs.headers || {};
546
- options.otherArgs.headers['x-goog-request-params'] =
547
- this._gaxModule.routingHeader.fromParams({
548
- name: request.name ?? '',
549
- });
550
- this.initialize();
544
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
545
+ 'name': request.name ?? '',
546
+ });
547
+ this.initialize().catch(err => { throw err; });
551
548
  this._log.info('getPropertyQuotasSnapshot request %j', request);
552
549
  const wrappedCallback = callback
553
550
  ? (error, response, options, rawResponse) => {
@@ -555,11 +552,16 @@ class AlphaAnalyticsDataClient {
555
552
  callback(error, response, options, rawResponse); // We verified callback above.
556
553
  }
557
554
  : undefined;
558
- return this.innerApiCalls
559
- .getPropertyQuotasSnapshot(request, options, wrappedCallback)
555
+ return this.innerApiCalls.getPropertyQuotasSnapshot(request, options, wrappedCallback)
560
556
  ?.then(([response, options, rawResponse]) => {
561
557
  this._log.info('getPropertyQuotasSnapshot response %j', response);
562
558
  return [response, options, rawResponse];
559
+ }).catch((error) => {
560
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
561
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
562
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
563
+ }
564
+ throw error;
563
565
  });
564
566
  }
565
567
  queryReportTask(request, optionsOrCallback, callback) {
@@ -575,11 +577,10 @@ class AlphaAnalyticsDataClient {
575
577
  options = options || {};
576
578
  options.otherArgs = options.otherArgs || {};
577
579
  options.otherArgs.headers = options.otherArgs.headers || {};
578
- options.otherArgs.headers['x-goog-request-params'] =
579
- this._gaxModule.routingHeader.fromParams({
580
- name: request.name ?? '',
581
- });
582
- this.initialize();
580
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
581
+ 'name': request.name ?? '',
582
+ });
583
+ this.initialize().catch(err => { throw err; });
583
584
  this._log.info('queryReportTask request %j', request);
584
585
  const wrappedCallback = callback
585
586
  ? (error, response, options, rawResponse) => {
@@ -587,11 +588,16 @@ class AlphaAnalyticsDataClient {
587
588
  callback(error, response, options, rawResponse); // We verified callback above.
588
589
  }
589
590
  : undefined;
590
- return this.innerApiCalls
591
- .queryReportTask(request, options, wrappedCallback)
591
+ return this.innerApiCalls.queryReportTask(request, options, wrappedCallback)
592
592
  ?.then(([response, options, rawResponse]) => {
593
593
  this._log.info('queryReportTask response %j', response);
594
594
  return [response, options, rawResponse];
595
+ }).catch((error) => {
596
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
597
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
598
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
599
+ }
600
+ throw error;
595
601
  });
596
602
  }
597
603
  getReportTask(request, optionsOrCallback, callback) {
@@ -607,11 +613,10 @@ class AlphaAnalyticsDataClient {
607
613
  options = options || {};
608
614
  options.otherArgs = options.otherArgs || {};
609
615
  options.otherArgs.headers = options.otherArgs.headers || {};
610
- options.otherArgs.headers['x-goog-request-params'] =
611
- this._gaxModule.routingHeader.fromParams({
612
- name: request.name ?? '',
613
- });
614
- this.initialize();
616
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
617
+ 'name': request.name ?? '',
618
+ });
619
+ this.initialize().catch(err => { throw err; });
615
620
  this._log.info('getReportTask request %j', request);
616
621
  const wrappedCallback = callback
617
622
  ? (error, response, options, rawResponse) => {
@@ -619,11 +624,16 @@ class AlphaAnalyticsDataClient {
619
624
  callback(error, response, options, rawResponse); // We verified callback above.
620
625
  }
621
626
  : undefined;
622
- return this.innerApiCalls
623
- .getReportTask(request, options, wrappedCallback)
627
+ return this.innerApiCalls.getReportTask(request, options, wrappedCallback)
624
628
  ?.then(([response, options, rawResponse]) => {
625
629
  this._log.info('getReportTask response %j', response);
626
630
  return [response, options, rawResponse];
631
+ }).catch((error) => {
632
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
633
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
634
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
635
+ }
636
+ throw error;
627
637
  });
628
638
  }
629
639
  createAudienceList(request, optionsOrCallback, callback) {
@@ -639,11 +649,10 @@ class AlphaAnalyticsDataClient {
639
649
  options = options || {};
640
650
  options.otherArgs = options.otherArgs || {};
641
651
  options.otherArgs.headers = options.otherArgs.headers || {};
642
- options.otherArgs.headers['x-goog-request-params'] =
643
- this._gaxModule.routingHeader.fromParams({
644
- parent: request.parent ?? '',
645
- });
646
- this.initialize();
652
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
653
+ 'parent': request.parent ?? '',
654
+ });
655
+ this.initialize().catch(err => { throw err; });
647
656
  const wrappedCallback = callback
648
657
  ? (error, response, rawResponse, _) => {
649
658
  this._log.info('createAudienceList response %j', rawResponse);
@@ -651,8 +660,7 @@ class AlphaAnalyticsDataClient {
651
660
  }
652
661
  : undefined;
653
662
  this._log.info('createAudienceList request %j', request);
654
- return this.innerApiCalls
655
- .createAudienceList(request, options, wrappedCallback)
663
+ return this.innerApiCalls.createAudienceList(request, options, wrappedCallback)
656
664
  ?.then(([response, rawResponse, _]) => {
657
665
  this._log.info('createAudienceList response %j', rawResponse);
658
666
  return [response, rawResponse, _];
@@ -689,11 +697,10 @@ class AlphaAnalyticsDataClient {
689
697
  options = options || {};
690
698
  options.otherArgs = options.otherArgs || {};
691
699
  options.otherArgs.headers = options.otherArgs.headers || {};
692
- options.otherArgs.headers['x-goog-request-params'] =
693
- this._gaxModule.routingHeader.fromParams({
694
- parent: request.parent ?? '',
695
- });
696
- this.initialize();
700
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
701
+ 'parent': request.parent ?? '',
702
+ });
703
+ this.initialize().catch(err => { throw err; });
697
704
  const wrappedCallback = callback
698
705
  ? (error, response, rawResponse, _) => {
699
706
  this._log.info('createReportTask response %j', rawResponse);
@@ -701,8 +708,7 @@ class AlphaAnalyticsDataClient {
701
708
  }
702
709
  : undefined;
703
710
  this._log.info('createReportTask request %j', request);
704
- return this.innerApiCalls
705
- .createReportTask(request, options, wrappedCallback)
711
+ return this.innerApiCalls.createReportTask(request, options, wrappedCallback)
706
712
  ?.then(([response, rawResponse, _]) => {
707
713
  this._log.info('createReportTask response %j', rawResponse);
708
714
  return [response, rawResponse, _];
@@ -739,11 +745,10 @@ class AlphaAnalyticsDataClient {
739
745
  options = options || {};
740
746
  options.otherArgs = options.otherArgs || {};
741
747
  options.otherArgs.headers = options.otherArgs.headers || {};
742
- options.otherArgs.headers['x-goog-request-params'] =
743
- this._gaxModule.routingHeader.fromParams({
744
- parent: request.parent ?? '',
745
- });
746
- this.initialize();
748
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
749
+ 'parent': request.parent ?? '',
750
+ });
751
+ this.initialize().catch(err => { throw err; });
747
752
  const wrappedCallback = callback
748
753
  ? (error, values, nextPageRequest, rawResponse) => {
749
754
  this._log.info('listAudienceLists values %j', values);
@@ -792,13 +797,12 @@ class AlphaAnalyticsDataClient {
792
797
  options = options || {};
793
798
  options.otherArgs = options.otherArgs || {};
794
799
  options.otherArgs.headers = options.otherArgs.headers || {};
795
- options.otherArgs.headers['x-goog-request-params'] =
796
- this._gaxModule.routingHeader.fromParams({
797
- parent: request.parent ?? '',
798
- });
800
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
801
+ 'parent': request.parent ?? '',
802
+ });
799
803
  const defaultCallSettings = this._defaults['listAudienceLists'];
800
804
  const callSettings = defaultCallSettings.merge(options);
801
- this.initialize();
805
+ this.initialize().catch(err => { throw err; });
802
806
  this._log.info('listAudienceLists stream %j', request);
803
807
  return this.descriptors.page.listAudienceLists.createStream(this.innerApiCalls.listAudienceLists, request, callSettings);
804
808
  }
@@ -839,13 +843,12 @@ class AlphaAnalyticsDataClient {
839
843
  options = options || {};
840
844
  options.otherArgs = options.otherArgs || {};
841
845
  options.otherArgs.headers = options.otherArgs.headers || {};
842
- options.otherArgs.headers['x-goog-request-params'] =
843
- this._gaxModule.routingHeader.fromParams({
844
- parent: request.parent ?? '',
845
- });
846
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
847
+ 'parent': request.parent ?? '',
848
+ });
846
849
  const defaultCallSettings = this._defaults['listAudienceLists'];
847
850
  const callSettings = defaultCallSettings.merge(options);
848
- this.initialize();
851
+ this.initialize().catch(err => { throw err; });
849
852
  this._log.info('listAudienceLists iterate %j', request);
850
853
  return this.descriptors.page.listAudienceLists.asyncIterate(this.innerApiCalls['listAudienceLists'], request, callSettings);
851
854
  }
@@ -862,11 +865,10 @@ class AlphaAnalyticsDataClient {
862
865
  options = options || {};
863
866
  options.otherArgs = options.otherArgs || {};
864
867
  options.otherArgs.headers = options.otherArgs.headers || {};
865
- options.otherArgs.headers['x-goog-request-params'] =
866
- this._gaxModule.routingHeader.fromParams({
867
- parent: request.parent ?? '',
868
- });
869
- this.initialize();
868
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
869
+ 'parent': request.parent ?? '',
870
+ });
871
+ this.initialize().catch(err => { throw err; });
870
872
  const wrappedCallback = callback
871
873
  ? (error, values, nextPageRequest, rawResponse) => {
872
874
  this._log.info('listRecurringAudienceLists values %j', values);
@@ -917,13 +919,12 @@ class AlphaAnalyticsDataClient {
917
919
  options = options || {};
918
920
  options.otherArgs = options.otherArgs || {};
919
921
  options.otherArgs.headers = options.otherArgs.headers || {};
920
- options.otherArgs.headers['x-goog-request-params'] =
921
- this._gaxModule.routingHeader.fromParams({
922
- parent: request.parent ?? '',
923
- });
922
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
923
+ 'parent': request.parent ?? '',
924
+ });
924
925
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
925
926
  const callSettings = defaultCallSettings.merge(options);
926
- this.initialize();
927
+ this.initialize().catch(err => { throw err; });
927
928
  this._log.info('listRecurringAudienceLists stream %j', request);
928
929
  return this.descriptors.page.listRecurringAudienceLists.createStream(this.innerApiCalls.listRecurringAudienceLists, request, callSettings);
929
930
  }
@@ -966,13 +967,12 @@ class AlphaAnalyticsDataClient {
966
967
  options = options || {};
967
968
  options.otherArgs = options.otherArgs || {};
968
969
  options.otherArgs.headers = options.otherArgs.headers || {};
969
- options.otherArgs.headers['x-goog-request-params'] =
970
- this._gaxModule.routingHeader.fromParams({
971
- parent: request.parent ?? '',
972
- });
970
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
971
+ 'parent': request.parent ?? '',
972
+ });
973
973
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
974
974
  const callSettings = defaultCallSettings.merge(options);
975
- this.initialize();
975
+ this.initialize().catch(err => { throw err; });
976
976
  this._log.info('listRecurringAudienceLists iterate %j', request);
977
977
  return this.descriptors.page.listRecurringAudienceLists.asyncIterate(this.innerApiCalls['listRecurringAudienceLists'], request, callSettings);
978
978
  }
@@ -989,11 +989,10 @@ class AlphaAnalyticsDataClient {
989
989
  options = options || {};
990
990
  options.otherArgs = options.otherArgs || {};
991
991
  options.otherArgs.headers = options.otherArgs.headers || {};
992
- options.otherArgs.headers['x-goog-request-params'] =
993
- this._gaxModule.routingHeader.fromParams({
994
- parent: request.parent ?? '',
995
- });
996
- this.initialize();
992
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
993
+ 'parent': request.parent ?? '',
994
+ });
995
+ this.initialize().catch(err => { throw err; });
997
996
  const wrappedCallback = callback
998
997
  ? (error, values, nextPageRequest, rawResponse) => {
999
998
  this._log.info('listReportTasks values %j', values);
@@ -1036,13 +1035,12 @@ class AlphaAnalyticsDataClient {
1036
1035
  options = options || {};
1037
1036
  options.otherArgs = options.otherArgs || {};
1038
1037
  options.otherArgs.headers = options.otherArgs.headers || {};
1039
- options.otherArgs.headers['x-goog-request-params'] =
1040
- this._gaxModule.routingHeader.fromParams({
1041
- parent: request.parent ?? '',
1042
- });
1038
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
1039
+ 'parent': request.parent ?? '',
1040
+ });
1043
1041
  const defaultCallSettings = this._defaults['listReportTasks'];
1044
1042
  const callSettings = defaultCallSettings.merge(options);
1045
- this.initialize();
1043
+ this.initialize().catch(err => { throw err; });
1046
1044
  this._log.info('listReportTasks stream %j', request);
1047
1045
  return this.descriptors.page.listReportTasks.createStream(this.innerApiCalls.listReportTasks, request, callSettings);
1048
1046
  }
@@ -1077,46 +1075,45 @@ class AlphaAnalyticsDataClient {
1077
1075
  options = options || {};
1078
1076
  options.otherArgs = options.otherArgs || {};
1079
1077
  options.otherArgs.headers = options.otherArgs.headers || {};
1080
- options.otherArgs.headers['x-goog-request-params'] =
1081
- this._gaxModule.routingHeader.fromParams({
1082
- parent: request.parent ?? '',
1083
- });
1078
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
1079
+ 'parent': request.parent ?? '',
1080
+ });
1084
1081
  const defaultCallSettings = this._defaults['listReportTasks'];
1085
1082
  const callSettings = defaultCallSettings.merge(options);
1086
- this.initialize();
1083
+ this.initialize().catch(err => { throw err; });
1087
1084
  this._log.info('listReportTasks iterate %j', request);
1088
1085
  return this.descriptors.page.listReportTasks.asyncIterate(this.innerApiCalls['listReportTasks'], request, callSettings);
1089
1086
  }
1090
1087
  /**
1091
- * Gets the latest state of a long-running operation. Clients can use this
1092
- * method to poll the operation result at intervals as recommended by the API
1093
- * service.
1094
- *
1095
- * @param {Object} request - The request object that will be sent.
1096
- * @param {string} request.name - The name of the operation resource.
1097
- * @param {Object=} options
1098
- * Optional parameters. You can override the default settings for this call,
1099
- * e.g, timeout, retries, paginations, etc. See {@link
1100
- * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
1101
- * for the details.
1102
- * @param {function(?Error, ?Object)=} callback
1103
- * The function which will be called with the result of the API call.
1104
- *
1105
- * The second parameter to the callback is an object representing
1106
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
1107
- * @return {Promise} - The promise which resolves to an array.
1108
- * The first element of the array is an object representing
1109
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
1110
- * The promise has a method named "cancel" which cancels the ongoing API call.
1111
- *
1112
- * @example
1113
- * ```
1114
- * const client = longrunning.operationsClient();
1115
- * const name = '';
1116
- * const [response] = await client.getOperation({name});
1117
- * // doThingsWith(response)
1118
- * ```
1119
- */
1088
+ * Gets the latest state of a long-running operation. Clients can use this
1089
+ * method to poll the operation result at intervals as recommended by the API
1090
+ * service.
1091
+ *
1092
+ * @param {Object} request - The request object that will be sent.
1093
+ * @param {string} request.name - The name of the operation resource.
1094
+ * @param {Object=} options
1095
+ * Optional parameters. You can override the default settings for this call,
1096
+ * e.g, timeout, retries, paginations, etc. See {@link
1097
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
1098
+ * for the details.
1099
+ * @param {function(?Error, ?Object)=} callback
1100
+ * The function which will be called with the result of the API call.
1101
+ *
1102
+ * The second parameter to the callback is an object representing
1103
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
1104
+ * @return {Promise} - The promise which resolves to an array.
1105
+ * The first element of the array is an object representing
1106
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
1107
+ * The promise has a method named "cancel" which cancels the ongoing API call.
1108
+ *
1109
+ * @example
1110
+ * ```
1111
+ * const client = longrunning.operationsClient();
1112
+ * const name = '';
1113
+ * const [response] = await client.getOperation({name});
1114
+ * // doThingsWith(response)
1115
+ * ```
1116
+ */
1120
1117
  getOperation(request, optionsOrCallback, callback) {
1121
1118
  let options;
1122
1119
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -1291,8 +1288,7 @@ class AlphaAnalyticsDataClient {
1291
1288
  * @returns {string} A string representing the property.
1292
1289
  */
1293
1290
  matchPropertyFromAudienceListName(audienceListName) {
1294
- return this.pathTemplates.audienceListPathTemplate.match(audienceListName)
1295
- .property;
1291
+ return this.pathTemplates.audienceListPathTemplate.match(audienceListName).property;
1296
1292
  }
1297
1293
  /**
1298
1294
  * Parse the audience_list from AudienceList resource.
@@ -1302,8 +1298,7 @@ class AlphaAnalyticsDataClient {
1302
1298
  * @returns {string} A string representing the audience_list.
1303
1299
  */
1304
1300
  matchAudienceListFromAudienceListName(audienceListName) {
1305
- return this.pathTemplates.audienceListPathTemplate.match(audienceListName)
1306
- .audience_list;
1301
+ return this.pathTemplates.audienceListPathTemplate.match(audienceListName).audience_list;
1307
1302
  }
1308
1303
  /**
1309
1304
  * Return a fully-qualified property resource name string.
@@ -1401,8 +1396,7 @@ class AlphaAnalyticsDataClient {
1401
1396
  * @returns {string} A string representing the property.
1402
1397
  */
1403
1398
  matchPropertyFromReportTaskName(reportTaskName) {
1404
- return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName)
1405
- .property;
1399
+ return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName).property;
1406
1400
  }
1407
1401
  /**
1408
1402
  * Parse the report_task from ReportTask resource.
@@ -1412,8 +1406,7 @@ class AlphaAnalyticsDataClient {
1412
1406
  * @returns {string} A string representing the report_task.
1413
1407
  */
1414
1408
  matchReportTaskFromReportTaskName(reportTaskName) {
1415
- return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName)
1416
- .report_task;
1409
+ return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName).report_task;
1417
1410
  }
1418
1411
  /**
1419
1412
  * Terminate the gRPC channel and close the client.
@@ -1427,7 +1420,7 @@ class AlphaAnalyticsDataClient {
1427
1420
  this._log.info('ending gRPC channel');
1428
1421
  this._terminated = true;
1429
1422
  stub.close();
1430
- this.operationsClient.close();
1423
+ void this.operationsClient.close();
1431
1424
  });
1432
1425
  }
1433
1426
  return Promise.resolve();