@google-analytics/data 5.1.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,13 +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().catch(err => {
359
- throw err;
328
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
329
+ 'property': request.property ?? '',
360
330
  });
331
+ this.initialize().catch(err => { throw err; });
361
332
  this._log.info('runFunnelReport request %j', request);
362
333
  const wrappedCallback = callback
363
334
  ? (error, response, options, rawResponse) => {
@@ -365,11 +336,16 @@ class AlphaAnalyticsDataClient {
365
336
  callback(error, response, options, rawResponse); // We verified callback above.
366
337
  }
367
338
  : undefined;
368
- return this.innerApiCalls
369
- .runFunnelReport(request, options, wrappedCallback)
339
+ return this.innerApiCalls.runFunnelReport(request, options, wrappedCallback)
370
340
  ?.then(([response, options, rawResponse]) => {
371
341
  this._log.info('runFunnelReport response %j', response);
372
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;
373
349
  });
374
350
  }
375
351
  queryAudienceList(request, optionsOrCallback, callback) {
@@ -385,13 +361,10 @@ class AlphaAnalyticsDataClient {
385
361
  options = options || {};
386
362
  options.otherArgs = options.otherArgs || {};
387
363
  options.otherArgs.headers = options.otherArgs.headers || {};
388
- options.otherArgs.headers['x-goog-request-params'] =
389
- this._gaxModule.routingHeader.fromParams({
390
- name: request.name ?? '',
391
- });
392
- this.initialize().catch(err => {
393
- throw err;
364
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
365
+ 'name': request.name ?? '',
394
366
  });
367
+ this.initialize().catch(err => { throw err; });
395
368
  this._log.info('queryAudienceList request %j', request);
396
369
  const wrappedCallback = callback
397
370
  ? (error, response, options, rawResponse) => {
@@ -399,11 +372,16 @@ class AlphaAnalyticsDataClient {
399
372
  callback(error, response, options, rawResponse); // We verified callback above.
400
373
  }
401
374
  : undefined;
402
- return this.innerApiCalls
403
- .queryAudienceList(request, options, wrappedCallback)
375
+ return this.innerApiCalls.queryAudienceList(request, options, wrappedCallback)
404
376
  ?.then(([response, options, rawResponse]) => {
405
377
  this._log.info('queryAudienceList response %j', response);
406
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;
407
385
  });
408
386
  }
409
387
  sheetExportAudienceList(request, optionsOrCallback, callback) {
@@ -419,13 +397,10 @@ class AlphaAnalyticsDataClient {
419
397
  options = options || {};
420
398
  options.otherArgs = options.otherArgs || {};
421
399
  options.otherArgs.headers = options.otherArgs.headers || {};
422
- options.otherArgs.headers['x-goog-request-params'] =
423
- this._gaxModule.routingHeader.fromParams({
424
- name: request.name ?? '',
425
- });
426
- this.initialize().catch(err => {
427
- throw err;
400
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
401
+ 'name': request.name ?? '',
428
402
  });
403
+ this.initialize().catch(err => { throw err; });
429
404
  this._log.info('sheetExportAudienceList request %j', request);
430
405
  const wrappedCallback = callback
431
406
  ? (error, response, options, rawResponse) => {
@@ -433,11 +408,16 @@ class AlphaAnalyticsDataClient {
433
408
  callback(error, response, options, rawResponse); // We verified callback above.
434
409
  }
435
410
  : undefined;
436
- return this.innerApiCalls
437
- .sheetExportAudienceList(request, options, wrappedCallback)
411
+ return this.innerApiCalls.sheetExportAudienceList(request, options, wrappedCallback)
438
412
  ?.then(([response, options, rawResponse]) => {
439
413
  this._log.info('sheetExportAudienceList response %j', response);
440
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;
441
421
  });
442
422
  }
443
423
  getAudienceList(request, optionsOrCallback, callback) {
@@ -453,13 +433,10 @@ class AlphaAnalyticsDataClient {
453
433
  options = options || {};
454
434
  options.otherArgs = options.otherArgs || {};
455
435
  options.otherArgs.headers = options.otherArgs.headers || {};
456
- options.otherArgs.headers['x-goog-request-params'] =
457
- this._gaxModule.routingHeader.fromParams({
458
- name: request.name ?? '',
459
- });
460
- this.initialize().catch(err => {
461
- throw err;
436
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
437
+ 'name': request.name ?? '',
462
438
  });
439
+ this.initialize().catch(err => { throw err; });
463
440
  this._log.info('getAudienceList request %j', request);
464
441
  const wrappedCallback = callback
465
442
  ? (error, response, options, rawResponse) => {
@@ -467,11 +444,16 @@ class AlphaAnalyticsDataClient {
467
444
  callback(error, response, options, rawResponse); // We verified callback above.
468
445
  }
469
446
  : undefined;
470
- return this.innerApiCalls
471
- .getAudienceList(request, options, wrappedCallback)
447
+ return this.innerApiCalls.getAudienceList(request, options, wrappedCallback)
472
448
  ?.then(([response, options, rawResponse]) => {
473
449
  this._log.info('getAudienceList response %j', response);
474
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;
475
457
  });
476
458
  }
477
459
  createRecurringAudienceList(request, optionsOrCallback, callback) {
@@ -487,13 +469,10 @@ class AlphaAnalyticsDataClient {
487
469
  options = options || {};
488
470
  options.otherArgs = options.otherArgs || {};
489
471
  options.otherArgs.headers = options.otherArgs.headers || {};
490
- options.otherArgs.headers['x-goog-request-params'] =
491
- this._gaxModule.routingHeader.fromParams({
492
- parent: request.parent ?? '',
493
- });
494
- this.initialize().catch(err => {
495
- throw err;
472
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
473
+ 'parent': request.parent ?? '',
496
474
  });
475
+ this.initialize().catch(err => { throw err; });
497
476
  this._log.info('createRecurringAudienceList request %j', request);
498
477
  const wrappedCallback = callback
499
478
  ? (error, response, options, rawResponse) => {
@@ -501,11 +480,16 @@ class AlphaAnalyticsDataClient {
501
480
  callback(error, response, options, rawResponse); // We verified callback above.
502
481
  }
503
482
  : undefined;
504
- return this.innerApiCalls
505
- .createRecurringAudienceList(request, options, wrappedCallback)
483
+ return this.innerApiCalls.createRecurringAudienceList(request, options, wrappedCallback)
506
484
  ?.then(([response, options, rawResponse]) => {
507
485
  this._log.info('createRecurringAudienceList response %j', response);
508
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;
509
493
  });
510
494
  }
511
495
  getRecurringAudienceList(request, optionsOrCallback, callback) {
@@ -521,13 +505,10 @@ class AlphaAnalyticsDataClient {
521
505
  options = options || {};
522
506
  options.otherArgs = options.otherArgs || {};
523
507
  options.otherArgs.headers = options.otherArgs.headers || {};
524
- options.otherArgs.headers['x-goog-request-params'] =
525
- this._gaxModule.routingHeader.fromParams({
526
- name: request.name ?? '',
527
- });
528
- this.initialize().catch(err => {
529
- throw err;
508
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
509
+ 'name': request.name ?? '',
530
510
  });
511
+ this.initialize().catch(err => { throw err; });
531
512
  this._log.info('getRecurringAudienceList request %j', request);
532
513
  const wrappedCallback = callback
533
514
  ? (error, response, options, rawResponse) => {
@@ -535,11 +516,16 @@ class AlphaAnalyticsDataClient {
535
516
  callback(error, response, options, rawResponse); // We verified callback above.
536
517
  }
537
518
  : undefined;
538
- return this.innerApiCalls
539
- .getRecurringAudienceList(request, options, wrappedCallback)
519
+ return this.innerApiCalls.getRecurringAudienceList(request, options, wrappedCallback)
540
520
  ?.then(([response, options, rawResponse]) => {
541
521
  this._log.info('getRecurringAudienceList response %j', response);
542
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;
543
529
  });
544
530
  }
545
531
  getPropertyQuotasSnapshot(request, optionsOrCallback, callback) {
@@ -555,13 +541,10 @@ class AlphaAnalyticsDataClient {
555
541
  options = options || {};
556
542
  options.otherArgs = options.otherArgs || {};
557
543
  options.otherArgs.headers = options.otherArgs.headers || {};
558
- options.otherArgs.headers['x-goog-request-params'] =
559
- this._gaxModule.routingHeader.fromParams({
560
- name: request.name ?? '',
561
- });
562
- this.initialize().catch(err => {
563
- throw err;
544
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
545
+ 'name': request.name ?? '',
564
546
  });
547
+ this.initialize().catch(err => { throw err; });
565
548
  this._log.info('getPropertyQuotasSnapshot request %j', request);
566
549
  const wrappedCallback = callback
567
550
  ? (error, response, options, rawResponse) => {
@@ -569,11 +552,16 @@ class AlphaAnalyticsDataClient {
569
552
  callback(error, response, options, rawResponse); // We verified callback above.
570
553
  }
571
554
  : undefined;
572
- return this.innerApiCalls
573
- .getPropertyQuotasSnapshot(request, options, wrappedCallback)
555
+ return this.innerApiCalls.getPropertyQuotasSnapshot(request, options, wrappedCallback)
574
556
  ?.then(([response, options, rawResponse]) => {
575
557
  this._log.info('getPropertyQuotasSnapshot response %j', response);
576
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;
577
565
  });
578
566
  }
579
567
  queryReportTask(request, optionsOrCallback, callback) {
@@ -589,13 +577,10 @@ class AlphaAnalyticsDataClient {
589
577
  options = options || {};
590
578
  options.otherArgs = options.otherArgs || {};
591
579
  options.otherArgs.headers = options.otherArgs.headers || {};
592
- options.otherArgs.headers['x-goog-request-params'] =
593
- this._gaxModule.routingHeader.fromParams({
594
- name: request.name ?? '',
595
- });
596
- this.initialize().catch(err => {
597
- throw err;
580
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
581
+ 'name': request.name ?? '',
598
582
  });
583
+ this.initialize().catch(err => { throw err; });
599
584
  this._log.info('queryReportTask request %j', request);
600
585
  const wrappedCallback = callback
601
586
  ? (error, response, options, rawResponse) => {
@@ -603,11 +588,16 @@ class AlphaAnalyticsDataClient {
603
588
  callback(error, response, options, rawResponse); // We verified callback above.
604
589
  }
605
590
  : undefined;
606
- return this.innerApiCalls
607
- .queryReportTask(request, options, wrappedCallback)
591
+ return this.innerApiCalls.queryReportTask(request, options, wrappedCallback)
608
592
  ?.then(([response, options, rawResponse]) => {
609
593
  this._log.info('queryReportTask response %j', response);
610
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;
611
601
  });
612
602
  }
613
603
  getReportTask(request, optionsOrCallback, callback) {
@@ -623,13 +613,10 @@ class AlphaAnalyticsDataClient {
623
613
  options = options || {};
624
614
  options.otherArgs = options.otherArgs || {};
625
615
  options.otherArgs.headers = options.otherArgs.headers || {};
626
- options.otherArgs.headers['x-goog-request-params'] =
627
- this._gaxModule.routingHeader.fromParams({
628
- name: request.name ?? '',
629
- });
630
- this.initialize().catch(err => {
631
- throw err;
616
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
617
+ 'name': request.name ?? '',
632
618
  });
619
+ this.initialize().catch(err => { throw err; });
633
620
  this._log.info('getReportTask request %j', request);
634
621
  const wrappedCallback = callback
635
622
  ? (error, response, options, rawResponse) => {
@@ -637,11 +624,16 @@ class AlphaAnalyticsDataClient {
637
624
  callback(error, response, options, rawResponse); // We verified callback above.
638
625
  }
639
626
  : undefined;
640
- return this.innerApiCalls
641
- .getReportTask(request, options, wrappedCallback)
627
+ return this.innerApiCalls.getReportTask(request, options, wrappedCallback)
642
628
  ?.then(([response, options, rawResponse]) => {
643
629
  this._log.info('getReportTask response %j', response);
644
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;
645
637
  });
646
638
  }
647
639
  createAudienceList(request, optionsOrCallback, callback) {
@@ -657,13 +649,10 @@ class AlphaAnalyticsDataClient {
657
649
  options = options || {};
658
650
  options.otherArgs = options.otherArgs || {};
659
651
  options.otherArgs.headers = options.otherArgs.headers || {};
660
- options.otherArgs.headers['x-goog-request-params'] =
661
- this._gaxModule.routingHeader.fromParams({
662
- parent: request.parent ?? '',
663
- });
664
- this.initialize().catch(err => {
665
- throw err;
652
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
653
+ 'parent': request.parent ?? '',
666
654
  });
655
+ this.initialize().catch(err => { throw err; });
667
656
  const wrappedCallback = callback
668
657
  ? (error, response, rawResponse, _) => {
669
658
  this._log.info('createAudienceList response %j', rawResponse);
@@ -671,8 +660,7 @@ class AlphaAnalyticsDataClient {
671
660
  }
672
661
  : undefined;
673
662
  this._log.info('createAudienceList request %j', request);
674
- return this.innerApiCalls
675
- .createAudienceList(request, options, wrappedCallback)
663
+ return this.innerApiCalls.createAudienceList(request, options, wrappedCallback)
676
664
  ?.then(([response, rawResponse, _]) => {
677
665
  this._log.info('createAudienceList response %j', rawResponse);
678
666
  return [response, rawResponse, _];
@@ -709,13 +697,10 @@ class AlphaAnalyticsDataClient {
709
697
  options = options || {};
710
698
  options.otherArgs = options.otherArgs || {};
711
699
  options.otherArgs.headers = options.otherArgs.headers || {};
712
- options.otherArgs.headers['x-goog-request-params'] =
713
- this._gaxModule.routingHeader.fromParams({
714
- parent: request.parent ?? '',
715
- });
716
- this.initialize().catch(err => {
717
- throw err;
700
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
701
+ 'parent': request.parent ?? '',
718
702
  });
703
+ this.initialize().catch(err => { throw err; });
719
704
  const wrappedCallback = callback
720
705
  ? (error, response, rawResponse, _) => {
721
706
  this._log.info('createReportTask response %j', rawResponse);
@@ -723,8 +708,7 @@ class AlphaAnalyticsDataClient {
723
708
  }
724
709
  : undefined;
725
710
  this._log.info('createReportTask request %j', request);
726
- return this.innerApiCalls
727
- .createReportTask(request, options, wrappedCallback)
711
+ return this.innerApiCalls.createReportTask(request, options, wrappedCallback)
728
712
  ?.then(([response, rawResponse, _]) => {
729
713
  this._log.info('createReportTask response %j', rawResponse);
730
714
  return [response, rawResponse, _];
@@ -761,13 +745,10 @@ class AlphaAnalyticsDataClient {
761
745
  options = options || {};
762
746
  options.otherArgs = options.otherArgs || {};
763
747
  options.otherArgs.headers = options.otherArgs.headers || {};
764
- options.otherArgs.headers['x-goog-request-params'] =
765
- this._gaxModule.routingHeader.fromParams({
766
- parent: request.parent ?? '',
767
- });
768
- this.initialize().catch(err => {
769
- throw err;
748
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
749
+ 'parent': request.parent ?? '',
770
750
  });
751
+ this.initialize().catch(err => { throw err; });
771
752
  const wrappedCallback = callback
772
753
  ? (error, values, nextPageRequest, rawResponse) => {
773
754
  this._log.info('listAudienceLists values %j', values);
@@ -816,15 +797,12 @@ class AlphaAnalyticsDataClient {
816
797
  options = options || {};
817
798
  options.otherArgs = options.otherArgs || {};
818
799
  options.otherArgs.headers = options.otherArgs.headers || {};
819
- options.otherArgs.headers['x-goog-request-params'] =
820
- this._gaxModule.routingHeader.fromParams({
821
- parent: request.parent ?? '',
822
- });
800
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
801
+ 'parent': request.parent ?? '',
802
+ });
823
803
  const defaultCallSettings = this._defaults['listAudienceLists'];
824
804
  const callSettings = defaultCallSettings.merge(options);
825
- this.initialize().catch(err => {
826
- throw err;
827
- });
805
+ this.initialize().catch(err => { throw err; });
828
806
  this._log.info('listAudienceLists stream %j', request);
829
807
  return this.descriptors.page.listAudienceLists.createStream(this.innerApiCalls.listAudienceLists, request, callSettings);
830
808
  }
@@ -865,15 +843,12 @@ class AlphaAnalyticsDataClient {
865
843
  options = options || {};
866
844
  options.otherArgs = options.otherArgs || {};
867
845
  options.otherArgs.headers = options.otherArgs.headers || {};
868
- options.otherArgs.headers['x-goog-request-params'] =
869
- this._gaxModule.routingHeader.fromParams({
870
- parent: request.parent ?? '',
871
- });
846
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
847
+ 'parent': request.parent ?? '',
848
+ });
872
849
  const defaultCallSettings = this._defaults['listAudienceLists'];
873
850
  const callSettings = defaultCallSettings.merge(options);
874
- this.initialize().catch(err => {
875
- throw err;
876
- });
851
+ this.initialize().catch(err => { throw err; });
877
852
  this._log.info('listAudienceLists iterate %j', request);
878
853
  return this.descriptors.page.listAudienceLists.asyncIterate(this.innerApiCalls['listAudienceLists'], request, callSettings);
879
854
  }
@@ -890,13 +865,10 @@ class AlphaAnalyticsDataClient {
890
865
  options = options || {};
891
866
  options.otherArgs = options.otherArgs || {};
892
867
  options.otherArgs.headers = options.otherArgs.headers || {};
893
- options.otherArgs.headers['x-goog-request-params'] =
894
- this._gaxModule.routingHeader.fromParams({
895
- parent: request.parent ?? '',
896
- });
897
- this.initialize().catch(err => {
898
- throw err;
868
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
869
+ 'parent': request.parent ?? '',
899
870
  });
871
+ this.initialize().catch(err => { throw err; });
900
872
  const wrappedCallback = callback
901
873
  ? (error, values, nextPageRequest, rawResponse) => {
902
874
  this._log.info('listRecurringAudienceLists values %j', values);
@@ -947,15 +919,12 @@ class AlphaAnalyticsDataClient {
947
919
  options = options || {};
948
920
  options.otherArgs = options.otherArgs || {};
949
921
  options.otherArgs.headers = options.otherArgs.headers || {};
950
- options.otherArgs.headers['x-goog-request-params'] =
951
- this._gaxModule.routingHeader.fromParams({
952
- parent: request.parent ?? '',
953
- });
922
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
923
+ 'parent': request.parent ?? '',
924
+ });
954
925
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
955
926
  const callSettings = defaultCallSettings.merge(options);
956
- this.initialize().catch(err => {
957
- throw err;
958
- });
927
+ this.initialize().catch(err => { throw err; });
959
928
  this._log.info('listRecurringAudienceLists stream %j', request);
960
929
  return this.descriptors.page.listRecurringAudienceLists.createStream(this.innerApiCalls.listRecurringAudienceLists, request, callSettings);
961
930
  }
@@ -998,15 +967,12 @@ class AlphaAnalyticsDataClient {
998
967
  options = options || {};
999
968
  options.otherArgs = options.otherArgs || {};
1000
969
  options.otherArgs.headers = options.otherArgs.headers || {};
1001
- options.otherArgs.headers['x-goog-request-params'] =
1002
- this._gaxModule.routingHeader.fromParams({
1003
- parent: request.parent ?? '',
1004
- });
970
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
971
+ 'parent': request.parent ?? '',
972
+ });
1005
973
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
1006
974
  const callSettings = defaultCallSettings.merge(options);
1007
- this.initialize().catch(err => {
1008
- throw err;
1009
- });
975
+ this.initialize().catch(err => { throw err; });
1010
976
  this._log.info('listRecurringAudienceLists iterate %j', request);
1011
977
  return this.descriptors.page.listRecurringAudienceLists.asyncIterate(this.innerApiCalls['listRecurringAudienceLists'], request, callSettings);
1012
978
  }
@@ -1023,13 +989,10 @@ class AlphaAnalyticsDataClient {
1023
989
  options = options || {};
1024
990
  options.otherArgs = options.otherArgs || {};
1025
991
  options.otherArgs.headers = options.otherArgs.headers || {};
1026
- options.otherArgs.headers['x-goog-request-params'] =
1027
- this._gaxModule.routingHeader.fromParams({
1028
- parent: request.parent ?? '',
1029
- });
1030
- this.initialize().catch(err => {
1031
- throw err;
992
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
993
+ 'parent': request.parent ?? '',
1032
994
  });
995
+ this.initialize().catch(err => { throw err; });
1033
996
  const wrappedCallback = callback
1034
997
  ? (error, values, nextPageRequest, rawResponse) => {
1035
998
  this._log.info('listReportTasks values %j', values);
@@ -1072,15 +1035,12 @@ class AlphaAnalyticsDataClient {
1072
1035
  options = options || {};
1073
1036
  options.otherArgs = options.otherArgs || {};
1074
1037
  options.otherArgs.headers = options.otherArgs.headers || {};
1075
- options.otherArgs.headers['x-goog-request-params'] =
1076
- this._gaxModule.routingHeader.fromParams({
1077
- parent: request.parent ?? '',
1078
- });
1038
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
1039
+ 'parent': request.parent ?? '',
1040
+ });
1079
1041
  const defaultCallSettings = this._defaults['listReportTasks'];
1080
1042
  const callSettings = defaultCallSettings.merge(options);
1081
- this.initialize().catch(err => {
1082
- throw err;
1083
- });
1043
+ this.initialize().catch(err => { throw err; });
1084
1044
  this._log.info('listReportTasks stream %j', request);
1085
1045
  return this.descriptors.page.listReportTasks.createStream(this.innerApiCalls.listReportTasks, request, callSettings);
1086
1046
  }
@@ -1115,48 +1075,45 @@ class AlphaAnalyticsDataClient {
1115
1075
  options = options || {};
1116
1076
  options.otherArgs = options.otherArgs || {};
1117
1077
  options.otherArgs.headers = options.otherArgs.headers || {};
1118
- options.otherArgs.headers['x-goog-request-params'] =
1119
- this._gaxModule.routingHeader.fromParams({
1120
- parent: request.parent ?? '',
1121
- });
1078
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
1079
+ 'parent': request.parent ?? '',
1080
+ });
1122
1081
  const defaultCallSettings = this._defaults['listReportTasks'];
1123
1082
  const callSettings = defaultCallSettings.merge(options);
1124
- this.initialize().catch(err => {
1125
- throw err;
1126
- });
1083
+ this.initialize().catch(err => { throw err; });
1127
1084
  this._log.info('listReportTasks iterate %j', request);
1128
1085
  return this.descriptors.page.listReportTasks.asyncIterate(this.innerApiCalls['listReportTasks'], request, callSettings);
1129
1086
  }
1130
1087
  /**
1131
- * Gets the latest state of a long-running operation. Clients can use this
1132
- * method to poll the operation result at intervals as recommended by the API
1133
- * service.
1134
- *
1135
- * @param {Object} request - The request object that will be sent.
1136
- * @param {string} request.name - The name of the operation resource.
1137
- * @param {Object=} options
1138
- * Optional parameters. You can override the default settings for this call,
1139
- * e.g, timeout, retries, paginations, etc. See {@link
1140
- * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
1141
- * for the details.
1142
- * @param {function(?Error, ?Object)=} callback
1143
- * The function which will be called with the result of the API call.
1144
- *
1145
- * The second parameter to the callback is an object representing
1146
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
1147
- * @return {Promise} - The promise which resolves to an array.
1148
- * The first element of the array is an object representing
1149
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
1150
- * The promise has a method named "cancel" which cancels the ongoing API call.
1151
- *
1152
- * @example
1153
- * ```
1154
- * const client = longrunning.operationsClient();
1155
- * const name = '';
1156
- * const [response] = await client.getOperation({name});
1157
- * // doThingsWith(response)
1158
- * ```
1159
- */
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
+ */
1160
1117
  getOperation(request, optionsOrCallback, callback) {
1161
1118
  let options;
1162
1119
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -1331,8 +1288,7 @@ class AlphaAnalyticsDataClient {
1331
1288
  * @returns {string} A string representing the property.
1332
1289
  */
1333
1290
  matchPropertyFromAudienceListName(audienceListName) {
1334
- return this.pathTemplates.audienceListPathTemplate.match(audienceListName)
1335
- .property;
1291
+ return this.pathTemplates.audienceListPathTemplate.match(audienceListName).property;
1336
1292
  }
1337
1293
  /**
1338
1294
  * Parse the audience_list from AudienceList resource.
@@ -1342,8 +1298,7 @@ class AlphaAnalyticsDataClient {
1342
1298
  * @returns {string} A string representing the audience_list.
1343
1299
  */
1344
1300
  matchAudienceListFromAudienceListName(audienceListName) {
1345
- return this.pathTemplates.audienceListPathTemplate.match(audienceListName)
1346
- .audience_list;
1301
+ return this.pathTemplates.audienceListPathTemplate.match(audienceListName).audience_list;
1347
1302
  }
1348
1303
  /**
1349
1304
  * Return a fully-qualified property resource name string.
@@ -1441,8 +1396,7 @@ class AlphaAnalyticsDataClient {
1441
1396
  * @returns {string} A string representing the property.
1442
1397
  */
1443
1398
  matchPropertyFromReportTaskName(reportTaskName) {
1444
- return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName)
1445
- .property;
1399
+ return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName).property;
1446
1400
  }
1447
1401
  /**
1448
1402
  * Parse the report_task from ReportTask resource.
@@ -1452,8 +1406,7 @@ class AlphaAnalyticsDataClient {
1452
1406
  * @returns {string} A string representing the report_task.
1453
1407
  */
1454
1408
  matchReportTaskFromReportTaskName(reportTaskName) {
1455
- return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName)
1456
- .report_task;
1409
+ return this.pathTemplates.reportTaskPathTemplate.match(reportTaskName).report_task;
1457
1410
  }
1458
1411
  /**
1459
1412
  * Terminate the gRPC channel and close the client.
@@ -1467,7 +1420,7 @@ class AlphaAnalyticsDataClient {
1467
1420
  this._log.info('ending gRPC channel');
1468
1421
  this._terminated = true;
1469
1422
  stub.close();
1470
- this.operationsClient.close();
1423
+ void this.operationsClient.close();
1471
1424
  });
1472
1425
  }
1473
1426
  return Promise.resolve();