@googlemaps/fleetengine-delivery 0.4.0 → 0.5.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,22 +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();
310
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
311
+ this.initialize().catch(err => { throw err; });
333
312
  this._log.info('createDeliveryVehicle request %j', request);
334
313
  const wrappedCallback = callback
335
314
  ? (error, response, options, rawResponse) => {
@@ -337,11 +316,16 @@ class DeliveryServiceClient {
337
316
  callback(error, response, options, rawResponse); // We verified callback above.
338
317
  }
339
318
  : undefined;
340
- return this.innerApiCalls
341
- .createDeliveryVehicle(request, options, wrappedCallback)
319
+ return this.innerApiCalls.createDeliveryVehicle(request, options, wrappedCallback)
342
320
  ?.then(([response, options, rawResponse]) => {
343
321
  this._log.info('createDeliveryVehicle response %j', response);
344
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;
345
329
  });
346
330
  }
347
331
  getDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -357,22 +341,19 @@ class DeliveryServiceClient {
357
341
  options = options || {};
358
342
  options.otherArgs = options.otherArgs || {};
359
343
  options.otherArgs.headers = options.otherArgs.headers || {};
360
- const routingParameter = {};
344
+ let routingParameter = {};
361
345
  {
362
346
  const fieldValue = request.name;
363
347
  if (fieldValue !== undefined && fieldValue !== null) {
364
- const match = fieldValue
365
- .toString()
366
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
348
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
367
349
  if (match) {
368
350
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
369
351
  Object.assign(routingParameter, { provider_id: parameterValue });
370
352
  }
371
353
  }
372
354
  }
373
- options.otherArgs.headers['x-goog-request-params'] =
374
- this._gaxModule.routingHeader.fromParams(routingParameter);
375
- this.initialize();
355
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
356
+ this.initialize().catch(err => { throw err; });
376
357
  this._log.info('getDeliveryVehicle request %j', request);
377
358
  const wrappedCallback = callback
378
359
  ? (error, response, options, rawResponse) => {
@@ -380,11 +361,16 @@ class DeliveryServiceClient {
380
361
  callback(error, response, options, rawResponse); // We verified callback above.
381
362
  }
382
363
  : undefined;
383
- return this.innerApiCalls
384
- .getDeliveryVehicle(request, options, wrappedCallback)
364
+ return this.innerApiCalls.getDeliveryVehicle(request, options, wrappedCallback)
385
365
  ?.then(([response, options, rawResponse]) => {
386
366
  this._log.info('getDeliveryVehicle response %j', response);
387
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;
388
374
  });
389
375
  }
390
376
  deleteDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -400,22 +386,19 @@ class DeliveryServiceClient {
400
386
  options = options || {};
401
387
  options.otherArgs = options.otherArgs || {};
402
388
  options.otherArgs.headers = options.otherArgs.headers || {};
403
- const routingParameter = {};
389
+ let routingParameter = {};
404
390
  {
405
391
  const fieldValue = request.name;
406
392
  if (fieldValue !== undefined && fieldValue !== null) {
407
- const match = fieldValue
408
- .toString()
409
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
393
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
410
394
  if (match) {
411
395
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
412
396
  Object.assign(routingParameter, { provider_id: parameterValue });
413
397
  }
414
398
  }
415
399
  }
416
- options.otherArgs.headers['x-goog-request-params'] =
417
- this._gaxModule.routingHeader.fromParams(routingParameter);
418
- this.initialize();
400
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
401
+ this.initialize().catch(err => { throw err; });
419
402
  this._log.info('deleteDeliveryVehicle request %j', request);
420
403
  const wrappedCallback = callback
421
404
  ? (error, response, options, rawResponse) => {
@@ -423,11 +406,16 @@ class DeliveryServiceClient {
423
406
  callback(error, response, options, rawResponse); // We verified callback above.
424
407
  }
425
408
  : undefined;
426
- return this.innerApiCalls
427
- .deleteDeliveryVehicle(request, options, wrappedCallback)
409
+ return this.innerApiCalls.deleteDeliveryVehicle(request, options, wrappedCallback)
428
410
  ?.then(([response, options, rawResponse]) => {
429
411
  this._log.info('deleteDeliveryVehicle response %j', response);
430
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;
431
419
  });
432
420
  }
433
421
  updateDeliveryVehicle(request, optionsOrCallback, callback) {
@@ -443,22 +431,19 @@ class DeliveryServiceClient {
443
431
  options = options || {};
444
432
  options.otherArgs = options.otherArgs || {};
445
433
  options.otherArgs.headers = options.otherArgs.headers || {};
446
- const routingParameter = {};
434
+ let routingParameter = {};
447
435
  {
448
436
  const fieldValue = request.deliveryVehicle?.name;
449
437
  if (fieldValue !== undefined && fieldValue !== null) {
450
- const match = fieldValue
451
- .toString()
452
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
438
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
453
439
  if (match) {
454
440
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
455
441
  Object.assign(routingParameter, { provider_id: parameterValue });
456
442
  }
457
443
  }
458
444
  }
459
- options.otherArgs.headers['x-goog-request-params'] =
460
- this._gaxModule.routingHeader.fromParams(routingParameter);
461
- this.initialize();
445
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
446
+ this.initialize().catch(err => { throw err; });
462
447
  this._log.info('updateDeliveryVehicle request %j', request);
463
448
  const wrappedCallback = callback
464
449
  ? (error, response, options, rawResponse) => {
@@ -466,11 +451,16 @@ class DeliveryServiceClient {
466
451
  callback(error, response, options, rawResponse); // We verified callback above.
467
452
  }
468
453
  : undefined;
469
- return this.innerApiCalls
470
- .updateDeliveryVehicle(request, options, wrappedCallback)
454
+ return this.innerApiCalls.updateDeliveryVehicle(request, options, wrappedCallback)
471
455
  ?.then(([response, options, rawResponse]) => {
472
456
  this._log.info('updateDeliveryVehicle response %j', response);
473
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;
474
464
  });
475
465
  }
476
466
  batchCreateTasks(request, optionsOrCallback, callback) {
@@ -486,22 +476,19 @@ class DeliveryServiceClient {
486
476
  options = options || {};
487
477
  options.otherArgs = options.otherArgs || {};
488
478
  options.otherArgs.headers = options.otherArgs.headers || {};
489
- const routingParameter = {};
479
+ let routingParameter = {};
490
480
  {
491
481
  const fieldValue = request.parent;
492
482
  if (fieldValue !== undefined && fieldValue !== null) {
493
- const match = fieldValue
494
- .toString()
495
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
483
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
496
484
  if (match) {
497
485
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
498
486
  Object.assign(routingParameter, { provider_id: parameterValue });
499
487
  }
500
488
  }
501
489
  }
502
- options.otherArgs.headers['x-goog-request-params'] =
503
- this._gaxModule.routingHeader.fromParams(routingParameter);
504
- this.initialize();
490
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
491
+ this.initialize().catch(err => { throw err; });
505
492
  this._log.info('batchCreateTasks request %j', request);
506
493
  const wrappedCallback = callback
507
494
  ? (error, response, options, rawResponse) => {
@@ -509,11 +496,16 @@ class DeliveryServiceClient {
509
496
  callback(error, response, options, rawResponse); // We verified callback above.
510
497
  }
511
498
  : undefined;
512
- return this.innerApiCalls
513
- .batchCreateTasks(request, options, wrappedCallback)
499
+ return this.innerApiCalls.batchCreateTasks(request, options, wrappedCallback)
514
500
  ?.then(([response, options, rawResponse]) => {
515
501
  this._log.info('batchCreateTasks response %j', response);
516
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;
517
509
  });
518
510
  }
519
511
  createTask(request, optionsOrCallback, callback) {
@@ -529,22 +521,19 @@ class DeliveryServiceClient {
529
521
  options = options || {};
530
522
  options.otherArgs = options.otherArgs || {};
531
523
  options.otherArgs.headers = options.otherArgs.headers || {};
532
- const routingParameter = {};
524
+ let routingParameter = {};
533
525
  {
534
526
  const fieldValue = request.parent;
535
527
  if (fieldValue !== undefined && fieldValue !== null) {
536
- const match = fieldValue
537
- .toString()
538
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
528
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
539
529
  if (match) {
540
530
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
541
531
  Object.assign(routingParameter, { provider_id: parameterValue });
542
532
  }
543
533
  }
544
534
  }
545
- options.otherArgs.headers['x-goog-request-params'] =
546
- this._gaxModule.routingHeader.fromParams(routingParameter);
547
- this.initialize();
535
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
536
+ this.initialize().catch(err => { throw err; });
548
537
  this._log.info('createTask request %j', request);
549
538
  const wrappedCallback = callback
550
539
  ? (error, response, options, rawResponse) => {
@@ -552,11 +541,16 @@ class DeliveryServiceClient {
552
541
  callback(error, response, options, rawResponse); // We verified callback above.
553
542
  }
554
543
  : undefined;
555
- return this.innerApiCalls
556
- .createTask(request, options, wrappedCallback)
544
+ return this.innerApiCalls.createTask(request, options, wrappedCallback)
557
545
  ?.then(([response, options, rawResponse]) => {
558
546
  this._log.info('createTask response %j', response);
559
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;
560
554
  });
561
555
  }
562
556
  getTask(request, optionsOrCallback, callback) {
@@ -572,22 +566,19 @@ class DeliveryServiceClient {
572
566
  options = options || {};
573
567
  options.otherArgs = options.otherArgs || {};
574
568
  options.otherArgs.headers = options.otherArgs.headers || {};
575
- const routingParameter = {};
569
+ let routingParameter = {};
576
570
  {
577
571
  const fieldValue = request.name;
578
572
  if (fieldValue !== undefined && fieldValue !== null) {
579
- const match = fieldValue
580
- .toString()
581
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
573
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
582
574
  if (match) {
583
575
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
584
576
  Object.assign(routingParameter, { provider_id: parameterValue });
585
577
  }
586
578
  }
587
579
  }
588
- options.otherArgs.headers['x-goog-request-params'] =
589
- this._gaxModule.routingHeader.fromParams(routingParameter);
590
- this.initialize();
580
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
581
+ this.initialize().catch(err => { throw err; });
591
582
  this._log.info('getTask request %j', request);
592
583
  const wrappedCallback = callback
593
584
  ? (error, response, options, rawResponse) => {
@@ -595,11 +586,16 @@ class DeliveryServiceClient {
595
586
  callback(error, response, options, rawResponse); // We verified callback above.
596
587
  }
597
588
  : undefined;
598
- return this.innerApiCalls
599
- .getTask(request, options, wrappedCallback)
589
+ return this.innerApiCalls.getTask(request, options, wrappedCallback)
600
590
  ?.then(([response, options, rawResponse]) => {
601
591
  this._log.info('getTask response %j', response);
602
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;
603
599
  });
604
600
  }
605
601
  deleteTask(request, optionsOrCallback, callback) {
@@ -615,22 +611,19 @@ class DeliveryServiceClient {
615
611
  options = options || {};
616
612
  options.otherArgs = options.otherArgs || {};
617
613
  options.otherArgs.headers = options.otherArgs.headers || {};
618
- const routingParameter = {};
614
+ let routingParameter = {};
619
615
  {
620
616
  const fieldValue = request.name;
621
617
  if (fieldValue !== undefined && fieldValue !== null) {
622
- const match = fieldValue
623
- .toString()
624
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
618
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
625
619
  if (match) {
626
620
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
627
621
  Object.assign(routingParameter, { provider_id: parameterValue });
628
622
  }
629
623
  }
630
624
  }
631
- options.otherArgs.headers['x-goog-request-params'] =
632
- this._gaxModule.routingHeader.fromParams(routingParameter);
633
- this.initialize();
625
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
626
+ this.initialize().catch(err => { throw err; });
634
627
  this._log.info('deleteTask request %j', request);
635
628
  const wrappedCallback = callback
636
629
  ? (error, response, options, rawResponse) => {
@@ -638,11 +631,16 @@ class DeliveryServiceClient {
638
631
  callback(error, response, options, rawResponse); // We verified callback above.
639
632
  }
640
633
  : undefined;
641
- return this.innerApiCalls
642
- .deleteTask(request, options, wrappedCallback)
634
+ return this.innerApiCalls.deleteTask(request, options, wrappedCallback)
643
635
  ?.then(([response, options, rawResponse]) => {
644
636
  this._log.info('deleteTask response %j', response);
645
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;
646
644
  });
647
645
  }
648
646
  updateTask(request, optionsOrCallback, callback) {
@@ -658,22 +656,19 @@ class DeliveryServiceClient {
658
656
  options = options || {};
659
657
  options.otherArgs = options.otherArgs || {};
660
658
  options.otherArgs.headers = options.otherArgs.headers || {};
661
- const routingParameter = {};
659
+ let routingParameter = {};
662
660
  {
663
661
  const fieldValue = request.task?.name;
664
662
  if (fieldValue !== undefined && fieldValue !== null) {
665
- const match = fieldValue
666
- .toString()
667
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
663
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
668
664
  if (match) {
669
665
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
670
666
  Object.assign(routingParameter, { provider_id: parameterValue });
671
667
  }
672
668
  }
673
669
  }
674
- options.otherArgs.headers['x-goog-request-params'] =
675
- this._gaxModule.routingHeader.fromParams(routingParameter);
676
- this.initialize();
670
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
671
+ this.initialize().catch(err => { throw err; });
677
672
  this._log.info('updateTask request %j', request);
678
673
  const wrappedCallback = callback
679
674
  ? (error, response, options, rawResponse) => {
@@ -681,11 +676,16 @@ class DeliveryServiceClient {
681
676
  callback(error, response, options, rawResponse); // We verified callback above.
682
677
  }
683
678
  : undefined;
684
- return this.innerApiCalls
685
- .updateTask(request, options, wrappedCallback)
679
+ return this.innerApiCalls.updateTask(request, options, wrappedCallback)
686
680
  ?.then(([response, options, rawResponse]) => {
687
681
  this._log.info('updateTask response %j', response);
688
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;
689
689
  });
690
690
  }
691
691
  getTaskTrackingInfo(request, optionsOrCallback, callback) {
@@ -701,22 +701,19 @@ class DeliveryServiceClient {
701
701
  options = options || {};
702
702
  options.otherArgs = options.otherArgs || {};
703
703
  options.otherArgs.headers = options.otherArgs.headers || {};
704
- const routingParameter = {};
704
+ let routingParameter = {};
705
705
  {
706
706
  const fieldValue = request.name;
707
707
  if (fieldValue !== undefined && fieldValue !== null) {
708
- const match = fieldValue
709
- .toString()
710
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
708
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
711
709
  if (match) {
712
710
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
713
711
  Object.assign(routingParameter, { provider_id: parameterValue });
714
712
  }
715
713
  }
716
714
  }
717
- options.otherArgs.headers['x-goog-request-params'] =
718
- this._gaxModule.routingHeader.fromParams(routingParameter);
719
- this.initialize();
715
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
716
+ this.initialize().catch(err => { throw err; });
720
717
  this._log.info('getTaskTrackingInfo request %j', request);
721
718
  const wrappedCallback = callback
722
719
  ? (error, response, options, rawResponse) => {
@@ -724,11 +721,16 @@ class DeliveryServiceClient {
724
721
  callback(error, response, options, rawResponse); // We verified callback above.
725
722
  }
726
723
  : undefined;
727
- return this.innerApiCalls
728
- .getTaskTrackingInfo(request, options, wrappedCallback)
724
+ return this.innerApiCalls.getTaskTrackingInfo(request, options, wrappedCallback)
729
725
  ?.then(([response, options, rawResponse]) => {
730
726
  this._log.info('getTaskTrackingInfo response %j', response);
731
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;
732
734
  });
733
735
  }
734
736
  listTasks(request, optionsOrCallback, callback) {
@@ -744,22 +746,19 @@ class DeliveryServiceClient {
744
746
  options = options || {};
745
747
  options.otherArgs = options.otherArgs || {};
746
748
  options.otherArgs.headers = options.otherArgs.headers || {};
747
- const routingParameter = {};
749
+ let routingParameter = {};
748
750
  {
749
751
  const fieldValue = request.parent;
750
752
  if (fieldValue !== undefined && fieldValue !== null) {
751
- const match = fieldValue
752
- .toString()
753
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
753
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
754
754
  if (match) {
755
755
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
756
756
  Object.assign(routingParameter, { provider_id: parameterValue });
757
757
  }
758
758
  }
759
759
  }
760
- options.otherArgs.headers['x-goog-request-params'] =
761
- this._gaxModule.routingHeader.fromParams(routingParameter);
762
- this.initialize();
760
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
761
+ this.initialize().catch(err => { throw err; });
763
762
  const wrappedCallback = callback
764
763
  ? (error, values, nextPageRequest, rawResponse) => {
765
764
  this._log.info('listTasks values %j', values);
@@ -816,24 +815,21 @@ class DeliveryServiceClient {
816
815
  options = options || {};
817
816
  options.otherArgs = options.otherArgs || {};
818
817
  options.otherArgs.headers = options.otherArgs.headers || {};
819
- const routingParameter = {};
818
+ let routingParameter = {};
820
819
  {
821
820
  const fieldValue = request.parent;
822
821
  if (fieldValue !== undefined && fieldValue !== null) {
823
- const match = fieldValue
824
- .toString()
825
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
822
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
826
823
  if (match) {
827
824
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
828
825
  Object.assign(routingParameter, { provider_id: parameterValue });
829
826
  }
830
827
  }
831
828
  }
832
- options.otherArgs.headers['x-goog-request-params'] =
833
- this._gaxModule.routingHeader.fromParams(routingParameter);
829
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
834
830
  const defaultCallSettings = this._defaults['listTasks'];
835
831
  const callSettings = defaultCallSettings.merge(options);
836
- this.initialize();
832
+ this.initialize().catch(err => { throw err; });
837
833
  this._log.info('listTasks stream %j', request);
838
834
  return this.descriptors.page.listTasks.createStream(this.innerApiCalls.listTasks, request, callSettings);
839
835
  }
@@ -882,24 +878,21 @@ class DeliveryServiceClient {
882
878
  options = options || {};
883
879
  options.otherArgs = options.otherArgs || {};
884
880
  options.otherArgs.headers = options.otherArgs.headers || {};
885
- const routingParameter = {};
881
+ let routingParameter = {};
886
882
  {
887
883
  const fieldValue = request.parent;
888
884
  if (fieldValue !== undefined && fieldValue !== null) {
889
- const match = fieldValue
890
- .toString()
891
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
885
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
892
886
  if (match) {
893
887
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
894
888
  Object.assign(routingParameter, { provider_id: parameterValue });
895
889
  }
896
890
  }
897
891
  }
898
- options.otherArgs.headers['x-goog-request-params'] =
899
- this._gaxModule.routingHeader.fromParams(routingParameter);
892
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
900
893
  const defaultCallSettings = this._defaults['listTasks'];
901
894
  const callSettings = defaultCallSettings.merge(options);
902
- this.initialize();
895
+ this.initialize().catch(err => { throw err; });
903
896
  this._log.info('listTasks iterate %j', request);
904
897
  return this.descriptors.page.listTasks.asyncIterate(this.innerApiCalls['listTasks'], request, callSettings);
905
898
  }
@@ -916,22 +909,19 @@ class DeliveryServiceClient {
916
909
  options = options || {};
917
910
  options.otherArgs = options.otherArgs || {};
918
911
  options.otherArgs.headers = options.otherArgs.headers || {};
919
- const routingParameter = {};
912
+ let routingParameter = {};
920
913
  {
921
914
  const fieldValue = request.parent;
922
915
  if (fieldValue !== undefined && fieldValue !== null) {
923
- const match = fieldValue
924
- .toString()
925
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
916
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
926
917
  if (match) {
927
918
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
928
919
  Object.assign(routingParameter, { provider_id: parameterValue });
929
920
  }
930
921
  }
931
922
  }
932
- options.otherArgs.headers['x-goog-request-params'] =
933
- this._gaxModule.routingHeader.fromParams(routingParameter);
934
- this.initialize();
923
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
924
+ this.initialize().catch(err => { throw err; });
935
925
  const wrappedCallback = callback
936
926
  ? (error, values, nextPageRequest, rawResponse) => {
937
927
  this._log.info('listDeliveryVehicles values %j', values);
@@ -1004,24 +994,21 @@ class DeliveryServiceClient {
1004
994
  options = options || {};
1005
995
  options.otherArgs = options.otherArgs || {};
1006
996
  options.otherArgs.headers = options.otherArgs.headers || {};
1007
- const routingParameter = {};
997
+ let routingParameter = {};
1008
998
  {
1009
999
  const fieldValue = request.parent;
1010
1000
  if (fieldValue !== undefined && fieldValue !== null) {
1011
- const match = fieldValue
1012
- .toString()
1013
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
1001
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
1014
1002
  if (match) {
1015
1003
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
1016
1004
  Object.assign(routingParameter, { provider_id: parameterValue });
1017
1005
  }
1018
1006
  }
1019
1007
  }
1020
- options.otherArgs.headers['x-goog-request-params'] =
1021
- this._gaxModule.routingHeader.fromParams(routingParameter);
1008
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1022
1009
  const defaultCallSettings = this._defaults['listDeliveryVehicles'];
1023
1010
  const callSettings = defaultCallSettings.merge(options);
1024
- this.initialize();
1011
+ this.initialize().catch(err => { throw err; });
1025
1012
  this._log.info('listDeliveryVehicles stream %j', request);
1026
1013
  return this.descriptors.page.listDeliveryVehicles.createStream(this.innerApiCalls.listDeliveryVehicles, request, callSettings);
1027
1014
  }
@@ -1086,24 +1073,21 @@ class DeliveryServiceClient {
1086
1073
  options = options || {};
1087
1074
  options.otherArgs = options.otherArgs || {};
1088
1075
  options.otherArgs.headers = options.otherArgs.headers || {};
1089
- const routingParameter = {};
1076
+ let routingParameter = {};
1090
1077
  {
1091
1078
  const fieldValue = request.parent;
1092
1079
  if (fieldValue !== undefined && fieldValue !== null) {
1093
- const match = fieldValue
1094
- .toString()
1095
- .match(RegExp('(?<provider_id>providers/[^/]+)'));
1080
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
1096
1081
  if (match) {
1097
1082
  const parameterValue = match.groups?.['provider_id'] ?? fieldValue;
1098
1083
  Object.assign(routingParameter, { provider_id: parameterValue });
1099
1084
  }
1100
1085
  }
1101
1086
  }
1102
- options.otherArgs.headers['x-goog-request-params'] =
1103
- this._gaxModule.routingHeader.fromParams(routingParameter);
1087
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1104
1088
  const defaultCallSettings = this._defaults['listDeliveryVehicles'];
1105
1089
  const callSettings = defaultCallSettings.merge(options);
1106
- this.initialize();
1090
+ this.initialize().catch(err => { throw err; });
1107
1091
  this._log.info('listDeliveryVehicles iterate %j', request);
1108
1092
  return this.descriptors.page.listDeliveryVehicles.asyncIterate(this.innerApiCalls['listDeliveryVehicles'], request, callSettings);
1109
1093
  }