@googlemaps/fleetengine-delivery 0.4.1 → 0.6.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.
@@ -96,26 +96,17 @@ class DeliveryServiceClient {
96
96
  constructor(opts, gaxInstance) {
97
97
  // Ensure that options include all the required fields.
98
98
  const staticMembers = this.constructor;
99
- if (opts?.universe_domain &&
100
- opts?.universeDomain &&
101
- opts?.universe_domain !== opts?.universeDomain) {
99
+ if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) {
102
100
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
103
101
  }
104
- const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
105
- ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
106
- : undefined;
107
- this._universeDomain =
108
- opts?.universeDomain ??
109
- opts?.universe_domain ??
110
- universeDomainEnvVar ??
111
- 'googleapis.com';
102
+ const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
103
+ this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com';
112
104
  this._servicePath = 'fleetengine.' + this._universeDomain;
113
105
  const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
114
106
  this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
115
107
  const port = opts?.port || staticMembers.port;
116
108
  const clientConfig = opts?.clientConfig ?? {};
117
- const fallback = opts?.fallback ??
118
- (typeof window !== 'undefined' && typeof window?.fetch === 'function');
109
+ const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
119
110
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
120
111
  // Request numeric enum values if REST transport is used.
121
112
  opts.numericEnums = true;
@@ -144,7 +135,10 @@ class DeliveryServiceClient {
144
135
  this.auth.defaultScopes = staticMembers.scopes;
145
136
  }
146
137
  // Determine the client header string.
147
- const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
138
+ const clientHeader = [
139
+ `gax/${this._gaxModule.version}`,
140
+ `gapic/${version}`,
141
+ ];
148
142
  if (typeof process === 'object' && 'versions' in process) {
149
143
  clientHeader.push(`gl-node/${process.versions.node}`);
150
144
  }
@@ -176,7 +170,7 @@ class DeliveryServiceClient {
176
170
  // pages). Denote the keys used for pagination and results.
177
171
  this.descriptors.page = {
178
172
  listTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks'),
179
- listDeliveryVehicles: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deliveryVehicles'),
173
+ listDeliveryVehicles: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deliveryVehicles')
180
174
  };
181
175
  // Put together the default options sent with requests.
182
176
  this._defaults = this._gaxGrpc.constructSettings('maps.fleetengine.delivery.v1.DeliveryService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -205,26 +199,13 @@ class DeliveryServiceClient {
205
199
  }
206
200
  // Put together the "service stub" for
207
201
  // maps.fleetengine.delivery.v1.DeliveryService.
208
- this.deliveryServiceStub = this._gaxGrpc.createStub(this._opts.fallback
209
- ? this._protos.lookupService('maps.fleetengine.delivery.v1.DeliveryService')
210
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
211
- this._protos.maps.fleetengine.delivery.v1.DeliveryService, this._opts, this._providedCustomServicePath);
202
+ this.deliveryServiceStub = this._gaxGrpc.createStub(this._opts.fallback ?
203
+ this._protos.lookupService('maps.fleetengine.delivery.v1.DeliveryService') :
204
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
205
+ this._protos.maps.fleetengine.delivery.v1.DeliveryService, this._opts, this._providedCustomServicePath);
212
206
  // Iterate over each of the methods that the service provides
213
207
  // and create an API call method for each.
214
- const deliveryServiceStubMethods = [
215
- 'createDeliveryVehicle',
216
- 'getDeliveryVehicle',
217
- 'deleteDeliveryVehicle',
218
- 'updateDeliveryVehicle',
219
- 'batchCreateTasks',
220
- 'createTask',
221
- 'getTask',
222
- 'deleteTask',
223
- 'updateTask',
224
- 'listTasks',
225
- 'getTaskTrackingInfo',
226
- 'listDeliveryVehicles',
227
- ];
208
+ const deliveryServiceStubMethods = ['createDeliveryVehicle', 'getDeliveryVehicle', 'deleteDeliveryVehicle', 'updateDeliveryVehicle', 'batchCreateTasks', 'createTask', 'getTask', 'deleteTask', 'updateTask', 'listTasks', 'getTaskTrackingInfo', 'listDeliveryVehicles'];
228
209
  for (const methodName of deliveryServiceStubMethods) {
229
210
  const callPromise = this.deliveryServiceStub.then(stub => (...args) => {
230
211
  if (this._terminated) {
@@ -235,7 +216,8 @@ class DeliveryServiceClient {
235
216
  }, (err) => () => {
236
217
  throw err;
237
218
  });
238
- const descriptor = this.descriptors.page[methodName] || undefined;
219
+ const descriptor = this.descriptors.page[methodName] ||
220
+ undefined;
239
221
  const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
240
222
  this.innerApiCalls[methodName] = apiCall;
241
223
  }
@@ -247,8 +229,7 @@ class DeliveryServiceClient {
247
229
  * @returns {string} The DNS address for this service.
248
230
  */
249
231
  static get servicePath() {
250
- if (typeof process === 'object' &&
251
- typeof process.emitWarning === 'function') {
232
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
252
233
  process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
253
234
  }
254
235
  return 'fleetengine.googleapis.com';
@@ -259,8 +240,7 @@ class DeliveryServiceClient {
259
240
  * @returns {string} The DNS address for this service.
260
241
  */
261
242
  static get apiEndpoint() {
262
- if (typeof process === 'object' &&
263
- typeof process.emitWarning === 'function') {
243
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
264
244
  process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
265
245
  }
266
246
  return 'fleetengine.googleapis.com';
@@ -288,7 +268,9 @@ class DeliveryServiceClient {
288
268
  * @returns {string[]} List of default scopes.
289
269
  */
290
270
  static get scopes() {
291
- return ['https://www.googleapis.com/auth/cloud-platform'];
271
+ return [
272
+ 'https://www.googleapis.com/auth/cloud-platform'
273
+ ];
292
274
  }
293
275
  /**
294
276
  * Return the project ID used by this class.
@@ -314,24 +296,19 @@ class DeliveryServiceClient {
314
296
  options = options || {};
315
297
  options.otherArgs = options.otherArgs || {};
316
298
  options.otherArgs.headers = options.otherArgs.headers || {};
317
- const routingParameter = {};
299
+ let routingParameter = {};
318
300
  {
319
301
  const fieldValue = request.parent;
320
302
  if (fieldValue !== undefined && fieldValue !== null) {
321
- const match = fieldValue
322
- .toString()
323
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
303
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
324
304
  if (match) {
325
305
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
326
306
  Object.assign(routingParameter, { provider_id: parameterValue });
327
307
  }
328
308
  }
329
309
  }
330
- options.otherArgs.headers['x-goog-request-params'] =
331
- this._gaxModule.routingHeader.fromParams(routingParameter);
332
- this.initialize().catch(err => {
333
- throw err;
334
- });
310
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
311
+ this.initialize().catch(err => { throw err; });
335
312
  this._log.info('createDeliveryVehicle request %j', request);
336
313
  const wrappedCallback = callback
337
314
  ? (error, response, options, rawResponse) => {
@@ -339,11 +316,16 @@ class DeliveryServiceClient {
339
316
  callback(error, response, options, rawResponse); // We verified callback above.
340
317
  }
341
318
  : undefined;
342
- return this.innerApiCalls
343
- .createDeliveryVehicle(request, options, wrappedCallback)
319
+ return this.innerApiCalls.createDeliveryVehicle(request, options, wrappedCallback)
344
320
  ?.then(([response, options, rawResponse]) => {
345
321
  this._log.info('createDeliveryVehicle response %j', response);
346
322
  return [response, options, rawResponse];
323
+ }).catch((error) => {
324
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
325
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
326
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
327
+ }
328
+ throw error;
347
329
  });
348
330
  }
349
331
  getDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -359,24 +341,19 @@ class DeliveryServiceClient {
359
341
  options = options || {};
360
342
  options.otherArgs = options.otherArgs || {};
361
343
  options.otherArgs.headers = options.otherArgs.headers || {};
362
- const routingParameter = {};
344
+ let routingParameter = {};
363
345
  {
364
346
  const fieldValue = request.name;
365
347
  if (fieldValue !== undefined && fieldValue !== null) {
366
- const match = fieldValue
367
- .toString()
368
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
348
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
369
349
  if (match) {
370
350
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
371
351
  Object.assign(routingParameter, { provider_id: parameterValue });
372
352
  }
373
353
  }
374
354
  }
375
- options.otherArgs.headers['x-goog-request-params'] =
376
- this._gaxModule.routingHeader.fromParams(routingParameter);
377
- this.initialize().catch(err => {
378
- throw err;
379
- });
355
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
356
+ this.initialize().catch(err => { throw err; });
380
357
  this._log.info('getDeliveryVehicle request %j', request);
381
358
  const wrappedCallback = callback
382
359
  ? (error, response, options, rawResponse) => {
@@ -384,11 +361,16 @@ class DeliveryServiceClient {
384
361
  callback(error, response, options, rawResponse); // We verified callback above.
385
362
  }
386
363
  : undefined;
387
- return this.innerApiCalls
388
- .getDeliveryVehicle(request, options, wrappedCallback)
364
+ return this.innerApiCalls.getDeliveryVehicle(request, options, wrappedCallback)
389
365
  ?.then(([response, options, rawResponse]) => {
390
366
  this._log.info('getDeliveryVehicle response %j', response);
391
367
  return [response, options, rawResponse];
368
+ }).catch((error) => {
369
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
370
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
371
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
372
+ }
373
+ throw error;
392
374
  });
393
375
  }
394
376
  deleteDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -404,24 +386,19 @@ class DeliveryServiceClient {
404
386
  options = options || {};
405
387
  options.otherArgs = options.otherArgs || {};
406
388
  options.otherArgs.headers = options.otherArgs.headers || {};
407
- const routingParameter = {};
389
+ let routingParameter = {};
408
390
  {
409
391
  const fieldValue = request.name;
410
392
  if (fieldValue !== undefined && fieldValue !== null) {
411
- const match = fieldValue
412
- .toString()
413
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
393
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
414
394
  if (match) {
415
395
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
416
396
  Object.assign(routingParameter, { provider_id: parameterValue });
417
397
  }
418
398
  }
419
399
  }
420
- options.otherArgs.headers['x-goog-request-params'] =
421
- this._gaxModule.routingHeader.fromParams(routingParameter);
422
- this.initialize().catch(err => {
423
- throw err;
424
- });
400
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
401
+ this.initialize().catch(err => { throw err; });
425
402
  this._log.info('deleteDeliveryVehicle request %j', request);
426
403
  const wrappedCallback = callback
427
404
  ? (error, response, options, rawResponse) => {
@@ -429,11 +406,16 @@ class DeliveryServiceClient {
429
406
  callback(error, response, options, rawResponse); // We verified callback above.
430
407
  }
431
408
  : undefined;
432
- return this.innerApiCalls
433
- .deleteDeliveryVehicle(request, options, wrappedCallback)
409
+ return this.innerApiCalls.deleteDeliveryVehicle(request, options, wrappedCallback)
434
410
  ?.then(([response, options, rawResponse]) => {
435
411
  this._log.info('deleteDeliveryVehicle response %j', response);
436
412
  return [response, options, rawResponse];
413
+ }).catch((error) => {
414
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
415
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
416
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
417
+ }
418
+ throw error;
437
419
  });
438
420
  }
439
421
  updateDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -449,24 +431,19 @@ class DeliveryServiceClient {
449
431
  options = options || {};
450
432
  options.otherArgs = options.otherArgs || {};
451
433
  options.otherArgs.headers = options.otherArgs.headers || {};
452
- const routingParameter = {};
434
+ let routingParameter = {};
453
435
  {
454
436
  const fieldValue = request.deliveryVehicle?.name;
455
437
  if (fieldValue !== undefined && fieldValue !== null) {
456
- const match = fieldValue
457
- .toString()
458
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
438
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
459
439
  if (match) {
460
440
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
461
441
  Object.assign(routingParameter, { provider_id: parameterValue });
462
442
  }
463
443
  }
464
444
  }
465
- options.otherArgs.headers['x-goog-request-params'] =
466
- this._gaxModule.routingHeader.fromParams(routingParameter);
467
- this.initialize().catch(err => {
468
- throw err;
469
- });
445
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
446
+ this.initialize().catch(err => { throw err; });
470
447
  this._log.info('updateDeliveryVehicle request %j', request);
471
448
  const wrappedCallback = callback
472
449
  ? (error, response, options, rawResponse) => {
@@ -474,11 +451,16 @@ class DeliveryServiceClient {
474
451
  callback(error, response, options, rawResponse); // We verified callback above.
475
452
  }
476
453
  : undefined;
477
- return this.innerApiCalls
478
- .updateDeliveryVehicle(request, options, wrappedCallback)
454
+ return this.innerApiCalls.updateDeliveryVehicle(request, options, wrappedCallback)
479
455
  ?.then(([response, options, rawResponse]) => {
480
456
  this._log.info('updateDeliveryVehicle response %j', response);
481
457
  return [response, options, rawResponse];
458
+ }).catch((error) => {
459
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
460
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
461
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
462
+ }
463
+ throw error;
482
464
  });
483
465
  }
484
466
  batchCreateTasks(request, optionsOrCallback, callback) {
@@ -494,24 +476,19 @@ class DeliveryServiceClient {
494
476
  options = options || {};
495
477
  options.otherArgs = options.otherArgs || {};
496
478
  options.otherArgs.headers = options.otherArgs.headers || {};
497
- const routingParameter = {};
479
+ let routingParameter = {};
498
480
  {
499
481
  const fieldValue = request.parent;
500
482
  if (fieldValue !== undefined && fieldValue !== null) {
501
- const match = fieldValue
502
- .toString()
503
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
483
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
504
484
  if (match) {
505
485
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
506
486
  Object.assign(routingParameter, { provider_id: parameterValue });
507
487
  }
508
488
  }
509
489
  }
510
- options.otherArgs.headers['x-goog-request-params'] =
511
- this._gaxModule.routingHeader.fromParams(routingParameter);
512
- this.initialize().catch(err => {
513
- throw err;
514
- });
490
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
491
+ this.initialize().catch(err => { throw err; });
515
492
  this._log.info('batchCreateTasks request %j', request);
516
493
  const wrappedCallback = callback
517
494
  ? (error, response, options, rawResponse) => {
@@ -519,11 +496,16 @@ class DeliveryServiceClient {
519
496
  callback(error, response, options, rawResponse); // We verified callback above.
520
497
  }
521
498
  : undefined;
522
- return this.innerApiCalls
523
- .batchCreateTasks(request, options, wrappedCallback)
499
+ return this.innerApiCalls.batchCreateTasks(request, options, wrappedCallback)
524
500
  ?.then(([response, options, rawResponse]) => {
525
501
  this._log.info('batchCreateTasks response %j', response);
526
502
  return [response, options, rawResponse];
503
+ }).catch((error) => {
504
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
505
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
506
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
507
+ }
508
+ throw error;
527
509
  });
528
510
  }
529
511
  createTask(request, optionsOrCallback, callback) {
@@ -539,24 +521,19 @@ class DeliveryServiceClient {
539
521
  options = options || {};
540
522
  options.otherArgs = options.otherArgs || {};
541
523
  options.otherArgs.headers = options.otherArgs.headers || {};
542
- const routingParameter = {};
524
+ let routingParameter = {};
543
525
  {
544
526
  const fieldValue = request.parent;
545
527
  if (fieldValue !== undefined && fieldValue !== null) {
546
- const match = fieldValue
547
- .toString()
548
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
528
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
549
529
  if (match) {
550
530
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
551
531
  Object.assign(routingParameter, { provider_id: parameterValue });
552
532
  }
553
533
  }
554
534
  }
555
- options.otherArgs.headers['x-goog-request-params'] =
556
- this._gaxModule.routingHeader.fromParams(routingParameter);
557
- this.initialize().catch(err => {
558
- throw err;
559
- });
535
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
536
+ this.initialize().catch(err => { throw err; });
560
537
  this._log.info('createTask request %j', request);
561
538
  const wrappedCallback = callback
562
539
  ? (error, response, options, rawResponse) => {
@@ -564,11 +541,16 @@ class DeliveryServiceClient {
564
541
  callback(error, response, options, rawResponse); // We verified callback above.
565
542
  }
566
543
  : undefined;
567
- return this.innerApiCalls
568
- .createTask(request, options, wrappedCallback)
544
+ return this.innerApiCalls.createTask(request, options, wrappedCallback)
569
545
  ?.then(([response, options, rawResponse]) => {
570
546
  this._log.info('createTask response %j', response);
571
547
  return [response, options, rawResponse];
548
+ }).catch((error) => {
549
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
550
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
551
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
552
+ }
553
+ throw error;
572
554
  });
573
555
  }
574
556
  getTask(request, optionsOrCallback, callback) {
@@ -584,24 +566,19 @@ class DeliveryServiceClient {
584
566
  options = options || {};
585
567
  options.otherArgs = options.otherArgs || {};
586
568
  options.otherArgs.headers = options.otherArgs.headers || {};
587
- const routingParameter = {};
569
+ let routingParameter = {};
588
570
  {
589
571
  const fieldValue = request.name;
590
572
  if (fieldValue !== undefined && fieldValue !== null) {
591
- const match = fieldValue
592
- .toString()
593
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
573
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
594
574
  if (match) {
595
575
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
596
576
  Object.assign(routingParameter, { provider_id: parameterValue });
597
577
  }
598
578
  }
599
579
  }
600
- options.otherArgs.headers['x-goog-request-params'] =
601
- this._gaxModule.routingHeader.fromParams(routingParameter);
602
- this.initialize().catch(err => {
603
- throw err;
604
- });
580
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
581
+ this.initialize().catch(err => { throw err; });
605
582
  this._log.info('getTask request %j', request);
606
583
  const wrappedCallback = callback
607
584
  ? (error, response, options, rawResponse) => {
@@ -609,11 +586,16 @@ class DeliveryServiceClient {
609
586
  callback(error, response, options, rawResponse); // We verified callback above.
610
587
  }
611
588
  : undefined;
612
- return this.innerApiCalls
613
- .getTask(request, options, wrappedCallback)
589
+ return this.innerApiCalls.getTask(request, options, wrappedCallback)
614
590
  ?.then(([response, options, rawResponse]) => {
615
591
  this._log.info('getTask response %j', response);
616
592
  return [response, options, rawResponse];
593
+ }).catch((error) => {
594
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
595
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
596
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
597
+ }
598
+ throw error;
617
599
  });
618
600
  }
619
601
  deleteTask(request, optionsOrCallback, callback) {
@@ -629,24 +611,19 @@ class DeliveryServiceClient {
629
611
  options = options || {};
630
612
  options.otherArgs = options.otherArgs || {};
631
613
  options.otherArgs.headers = options.otherArgs.headers || {};
632
- const routingParameter = {};
614
+ let routingParameter = {};
633
615
  {
634
616
  const fieldValue = request.name;
635
617
  if (fieldValue !== undefined && fieldValue !== null) {
636
- const match = fieldValue
637
- .toString()
638
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
618
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
639
619
  if (match) {
640
620
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
641
621
  Object.assign(routingParameter, { provider_id: parameterValue });
642
622
  }
643
623
  }
644
624
  }
645
- options.otherArgs.headers['x-goog-request-params'] =
646
- this._gaxModule.routingHeader.fromParams(routingParameter);
647
- this.initialize().catch(err => {
648
- throw err;
649
- });
625
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
626
+ this.initialize().catch(err => { throw err; });
650
627
  this._log.info('deleteTask request %j', request);
651
628
  const wrappedCallback = callback
652
629
  ? (error, response, options, rawResponse) => {
@@ -654,11 +631,16 @@ class DeliveryServiceClient {
654
631
  callback(error, response, options, rawResponse); // We verified callback above.
655
632
  }
656
633
  : undefined;
657
- return this.innerApiCalls
658
- .deleteTask(request, options, wrappedCallback)
634
+ return this.innerApiCalls.deleteTask(request, options, wrappedCallback)
659
635
  ?.then(([response, options, rawResponse]) => {
660
636
  this._log.info('deleteTask response %j', response);
661
637
  return [response, options, rawResponse];
638
+ }).catch((error) => {
639
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
640
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
641
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
642
+ }
643
+ throw error;
662
644
  });
663
645
  }
664
646
  updateTask(request, optionsOrCallback, callback) {
@@ -674,24 +656,19 @@ class DeliveryServiceClient {
674
656
  options = options || {};
675
657
  options.otherArgs = options.otherArgs || {};
676
658
  options.otherArgs.headers = options.otherArgs.headers || {};
677
- const routingParameter = {};
659
+ let routingParameter = {};
678
660
  {
679
661
  const fieldValue = request.task?.name;
680
662
  if (fieldValue !== undefined && fieldValue !== null) {
681
- const match = fieldValue
682
- .toString()
683
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
663
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
684
664
  if (match) {
685
665
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
686
666
  Object.assign(routingParameter, { provider_id: parameterValue });
687
667
  }
688
668
  }
689
669
  }
690
- options.otherArgs.headers['x-goog-request-params'] =
691
- this._gaxModule.routingHeader.fromParams(routingParameter);
692
- this.initialize().catch(err => {
693
- throw err;
694
- });
670
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
671
+ this.initialize().catch(err => { throw err; });
695
672
  this._log.info('updateTask request %j', request);
696
673
  const wrappedCallback = callback
697
674
  ? (error, response, options, rawResponse) => {
@@ -699,11 +676,16 @@ class DeliveryServiceClient {
699
676
  callback(error, response, options, rawResponse); // We verified callback above.
700
677
  }
701
678
  : undefined;
702
- return this.innerApiCalls
703
- .updateTask(request, options, wrappedCallback)
679
+ return this.innerApiCalls.updateTask(request, options, wrappedCallback)
704
680
  ?.then(([response, options, rawResponse]) => {
705
681
  this._log.info('updateTask response %j', response);
706
682
  return [response, options, rawResponse];
683
+ }).catch((error) => {
684
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
685
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
686
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
687
+ }
688
+ throw error;
707
689
  });
708
690
  }
709
691
  getTaskTrackingInfo(request, optionsOrCallback, callback) {
@@ -719,24 +701,19 @@ class DeliveryServiceClient {
719
701
  options = options || {};
720
702
  options.otherArgs = options.otherArgs || {};
721
703
  options.otherArgs.headers = options.otherArgs.headers || {};
722
- const routingParameter = {};
704
+ let routingParameter = {};
723
705
  {
724
706
  const fieldValue = request.name;
725
707
  if (fieldValue !== undefined && fieldValue !== null) {
726
- const match = fieldValue
727
- .toString()
728
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
708
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
729
709
  if (match) {
730
710
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
731
711
  Object.assign(routingParameter, { provider_id: parameterValue });
732
712
  }
733
713
  }
734
714
  }
735
- options.otherArgs.headers['x-goog-request-params'] =
736
- this._gaxModule.routingHeader.fromParams(routingParameter);
737
- this.initialize().catch(err => {
738
- throw err;
739
- });
715
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
716
+ this.initialize().catch(err => { throw err; });
740
717
  this._log.info('getTaskTrackingInfo request %j', request);
741
718
  const wrappedCallback = callback
742
719
  ? (error, response, options, rawResponse) => {
@@ -744,11 +721,16 @@ class DeliveryServiceClient {
744
721
  callback(error, response, options, rawResponse); // We verified callback above.
745
722
  }
746
723
  : undefined;
747
- return this.innerApiCalls
748
- .getTaskTrackingInfo(request, options, wrappedCallback)
724
+ return this.innerApiCalls.getTaskTrackingInfo(request, options, wrappedCallback)
749
725
  ?.then(([response, options, rawResponse]) => {
750
726
  this._log.info('getTaskTrackingInfo response %j', response);
751
727
  return [response, options, rawResponse];
728
+ }).catch((error) => {
729
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
730
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
731
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
732
+ }
733
+ throw error;
752
734
  });
753
735
  }
754
736
  listTasks(request, optionsOrCallback, callback) {
@@ -764,24 +746,19 @@ class DeliveryServiceClient {
764
746
  options = options || {};
765
747
  options.otherArgs = options.otherArgs || {};
766
748
  options.otherArgs.headers = options.otherArgs.headers || {};
767
- const routingParameter = {};
749
+ let routingParameter = {};
768
750
  {
769
751
  const fieldValue = request.parent;
770
752
  if (fieldValue !== undefined && fieldValue !== null) {
771
- const match = fieldValue
772
- .toString()
773
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
753
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
774
754
  if (match) {
775
755
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
776
756
  Object.assign(routingParameter, { provider_id: parameterValue });
777
757
  }
778
758
  }
779
759
  }
780
- options.otherArgs.headers['x-goog-request-params'] =
781
- this._gaxModule.routingHeader.fromParams(routingParameter);
782
- this.initialize().catch(err => {
783
- throw err;
784
- });
760
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
761
+ this.initialize().catch(err => { throw err; });
785
762
  const wrappedCallback = callback
786
763
  ? (error, values, nextPageRequest, rawResponse) => {
787
764
  this._log.info('listTasks values %j', values);
@@ -838,26 +815,21 @@ class DeliveryServiceClient {
838
815
  options = options || {};
839
816
  options.otherArgs = options.otherArgs || {};
840
817
  options.otherArgs.headers = options.otherArgs.headers || {};
841
- const routingParameter = {};
818
+ let routingParameter = {};
842
819
  {
843
820
  const fieldValue = request.parent;
844
821
  if (fieldValue !== undefined && fieldValue !== null) {
845
- const match = fieldValue
846
- .toString()
847
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
822
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
848
823
  if (match) {
849
824
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
850
825
  Object.assign(routingParameter, { provider_id: parameterValue });
851
826
  }
852
827
  }
853
828
  }
854
- options.otherArgs.headers['x-goog-request-params'] =
855
- this._gaxModule.routingHeader.fromParams(routingParameter);
829
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
856
830
  const defaultCallSettings = this._defaults['listTasks'];
857
831
  const callSettings = defaultCallSettings.merge(options);
858
- this.initialize().catch(err => {
859
- throw err;
860
- });
832
+ this.initialize().catch(err => { throw err; });
861
833
  this._log.info('listTasks stream %j', request);
862
834
  return this.descriptors.page.listTasks.createStream(this.innerApiCalls.listTasks, request, callSettings);
863
835
  }
@@ -906,26 +878,21 @@ class DeliveryServiceClient {
906
878
  options = options || {};
907
879
  options.otherArgs = options.otherArgs || {};
908
880
  options.otherArgs.headers = options.otherArgs.headers || {};
909
- const routingParameter = {};
881
+ let routingParameter = {};
910
882
  {
911
883
  const fieldValue = request.parent;
912
884
  if (fieldValue !== undefined && fieldValue !== null) {
913
- const match = fieldValue
914
- .toString()
915
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
885
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
916
886
  if (match) {
917
887
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
918
888
  Object.assign(routingParameter, { provider_id: parameterValue });
919
889
  }
920
890
  }
921
891
  }
922
- options.otherArgs.headers['x-goog-request-params'] =
923
- this._gaxModule.routingHeader.fromParams(routingParameter);
892
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
924
893
  const defaultCallSettings = this._defaults['listTasks'];
925
894
  const callSettings = defaultCallSettings.merge(options);
926
- this.initialize().catch(err => {
927
- throw err;
928
- });
895
+ this.initialize().catch(err => { throw err; });
929
896
  this._log.info('listTasks iterate %j', request);
930
897
  return this.descriptors.page.listTasks.asyncIterate(this.innerApiCalls['listTasks'], request, callSettings);
931
898
  }
@@ -942,24 +909,19 @@ class DeliveryServiceClient {
942
909
  options = options || {};
943
910
  options.otherArgs = options.otherArgs || {};
944
911
  options.otherArgs.headers = options.otherArgs.headers || {};
945
- const routingParameter = {};
912
+ let routingParameter = {};
946
913
  {
947
914
  const fieldValue = request.parent;
948
915
  if (fieldValue !== undefined && fieldValue !== null) {
949
- const match = fieldValue
950
- .toString()
951
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
916
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
952
917
  if (match) {
953
918
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
954
919
  Object.assign(routingParameter, { provider_id: parameterValue });
955
920
  }
956
921
  }
957
922
  }
958
- options.otherArgs.headers['x-goog-request-params'] =
959
- this._gaxModule.routingHeader.fromParams(routingParameter);
960
- this.initialize().catch(err => {
961
- throw err;
962
- });
923
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
924
+ this.initialize().catch(err => { throw err; });
963
925
  const wrappedCallback = callback
964
926
  ? (error, values, nextPageRequest, rawResponse) => {
965
927
  this._log.info('listDeliveryVehicles values %j', values);
@@ -1032,26 +994,21 @@ class DeliveryServiceClient {
1032
994
  options = options || {};
1033
995
  options.otherArgs = options.otherArgs || {};
1034
996
  options.otherArgs.headers = options.otherArgs.headers || {};
1035
- const routingParameter = {};
997
+ let routingParameter = {};
1036
998
  {
1037
999
  const fieldValue = request.parent;
1038
1000
  if (fieldValue !== undefined && fieldValue !== null) {
1039
- const match = fieldValue
1040
- .toString()
1041
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
1001
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
1042
1002
  if (match) {
1043
1003
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
1044
1004
  Object.assign(routingParameter, { provider_id: parameterValue });
1045
1005
  }
1046
1006
  }
1047
1007
  }
1048
- options.otherArgs.headers['x-goog-request-params'] =
1049
- this._gaxModule.routingHeader.fromParams(routingParameter);
1008
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1050
1009
  const defaultCallSettings = this._defaults['listDeliveryVehicles'];
1051
1010
  const callSettings = defaultCallSettings.merge(options);
1052
- this.initialize().catch(err => {
1053
- throw err;
1054
- });
1011
+ this.initialize().catch(err => { throw err; });
1055
1012
  this._log.info('listDeliveryVehicles stream %j', request);
1056
1013
  return this.descriptors.page.listDeliveryVehicles.createStream(this.innerApiCalls.listDeliveryVehicles, request, callSettings);
1057
1014
  }
@@ -1116,26 +1073,21 @@ class DeliveryServiceClient {
1116
1073
  options = options || {};
1117
1074
  options.otherArgs = options.otherArgs || {};
1118
1075
  options.otherArgs.headers = options.otherArgs.headers || {};
1119
- const routingParameter = {};
1076
+ let routingParameter = {};
1120
1077
  {
1121
1078
  const fieldValue = request.parent;
1122
1079
  if (fieldValue !== undefined && fieldValue !== null) {
1123
- const match = fieldValue
1124
- .toString()
1125
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
1080
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
1126
1081
  if (match) {
1127
1082
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
1128
1083
  Object.assign(routingParameter, { provider_id: parameterValue });
1129
1084
  }
1130
1085
  }
1131
1086
  }
1132
- options.otherArgs.headers['x-goog-request-params'] =
1133
- this._gaxModule.routingHeader.fromParams(routingParameter);
1087
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1134
1088
  const defaultCallSettings = this._defaults['listDeliveryVehicles'];
1135
1089
  const callSettings = defaultCallSettings.merge(options);
1136
- this.initialize().catch(err => {
1137
- throw err;
1138
- });
1090
+ this.initialize().catch(err => { throw err; });
1139
1091
  this._log.info('listDeliveryVehicles iterate %j', request);
1140
1092
  return this.descriptors.page.listDeliveryVehicles.asyncIterate(this.innerApiCalls['listDeliveryVehicles'], request, callSettings);
1141
1093
  }