@googlemaps/fleetengine-delivery 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1210 @@
1
+ "use strict";
2
+ // Copyright 2024 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.DeliveryServiceClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ /**
23
+ * Client JSON configuration object, loaded from
24
+ * `src/v1/delivery_service_client_config.json`.
25
+ * This file defines retry strategy and timeouts for all API methods in this library.
26
+ */
27
+ const gapicConfig = require("./delivery_service_client_config.json");
28
+ const version = require('../../../package.json').version;
29
+ /**
30
+ * The Last Mile Delivery service.
31
+ * @class
32
+ * @memberof v1
33
+ */
34
+ class DeliveryServiceClient {
35
+ /**
36
+ * Construct an instance of DeliveryServiceClient.
37
+ *
38
+ * @param {object} [options] - The configuration object.
39
+ * The options accepted by the constructor are described in detail
40
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
41
+ * The common options are:
42
+ * @param {object} [options.credentials] - Credentials object.
43
+ * @param {string} [options.credentials.client_email]
44
+ * @param {string} [options.credentials.private_key]
45
+ * @param {string} [options.email] - Account email address. Required when
46
+ * using a .pem or .p12 keyFilename.
47
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
48
+ * .p12 key downloaded from the Google Developers Console. If you provide
49
+ * a path to a JSON file, the projectId option below is not necessary.
50
+ * NOTE: .pem and .p12 require you to specify options.email as well.
51
+ * @param {number} [options.port] - The port on which to connect to
52
+ * the remote host.
53
+ * @param {string} [options.projectId] - The project ID from the Google
54
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
55
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
56
+ * app is running in an environment which supports
57
+ * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
58
+ * your project ID will be detected automatically.
59
+ * @param {string} [options.apiEndpoint] - The domain name of the
60
+ * API remote host.
61
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
62
+ * Follows the structure of {@link gapicConfig}.
63
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
64
+ * For more information, please check the
65
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
66
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
67
+ * need to avoid loading the default gRPC version and want to use the fallback
68
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
69
+ * ```
70
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
71
+ * const client = new DeliveryServiceClient({fallback: true}, gax);
72
+ * ```
73
+ */
74
+ constructor(opts, gaxInstance) {
75
+ var _a, _b, _c, _d, _e;
76
+ this._terminated = false;
77
+ this.descriptors = {
78
+ page: {},
79
+ stream: {},
80
+ longrunning: {},
81
+ batching: {},
82
+ };
83
+ // Ensure that options include all the required fields.
84
+ const staticMembers = this.constructor;
85
+ if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
86
+ (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
87
+ (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
88
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
89
+ }
90
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
91
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
92
+ : undefined;
93
+ this._universeDomain =
94
+ (_c = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : universeDomainEnvVar) !== null && _c !== void 0 ? _c : 'googleapis.com';
95
+ this._servicePath = 'fleetengine.' + this._universeDomain;
96
+ const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
97
+ this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
98
+ const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
99
+ const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
100
+ const fallback = (_e = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _e !== void 0 ? _e : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
101
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
102
+ // Request numeric enum values if REST transport is used.
103
+ opts.numericEnums = true;
104
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
105
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
106
+ opts['scopes'] = staticMembers.scopes;
107
+ }
108
+ // Load google-gax module synchronously if needed
109
+ if (!gaxInstance) {
110
+ gaxInstance = require('google-gax');
111
+ }
112
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
113
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
114
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
115
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
116
+ // Save options to use in initialize() method.
117
+ this._opts = opts;
118
+ // Save the auth object to the client, for use by other methods.
119
+ this.auth = this._gaxGrpc.auth;
120
+ // Set useJWTAccessWithScope on the auth object.
121
+ this.auth.useJWTAccessWithScope = true;
122
+ // Set defaultServicePath on the auth object.
123
+ this.auth.defaultServicePath = this._servicePath;
124
+ // Set the default scopes in auth client if needed.
125
+ if (servicePath === this._servicePath) {
126
+ this.auth.defaultScopes = staticMembers.scopes;
127
+ }
128
+ // Determine the client header string.
129
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
130
+ if (typeof process === 'object' && 'versions' in process) {
131
+ clientHeader.push(`gl-node/${process.versions.node}`);
132
+ }
133
+ else {
134
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
135
+ }
136
+ if (!opts.fallback) {
137
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
138
+ }
139
+ else {
140
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
141
+ }
142
+ if (opts.libName && opts.libVersion) {
143
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
144
+ }
145
+ // Load the applicable protos.
146
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
147
+ // This API contains "path templates"; forward-slash-separated
148
+ // identifiers to uniquely identify resources within the API.
149
+ // Create useful helper objects for these.
150
+ this.pathTemplates = {
151
+ deliveryVehiclePathTemplate: new this._gaxModule.PathTemplate('providers/{provider}/deliveryVehicles/{vehicle}'),
152
+ providerPathTemplate: new this._gaxModule.PathTemplate('providers/{provider}'),
153
+ taskPathTemplate: new this._gaxModule.PathTemplate('providers/{provider}/tasks/{task}'),
154
+ taskTrackingInfoPathTemplate: new this._gaxModule.PathTemplate('providers/{provider}/taskTrackingInfo/{tracking}'),
155
+ };
156
+ // Some of the methods on this service return "paged" results,
157
+ // (e.g. 50 results at a time, with tokens to get subsequent
158
+ // pages). Denote the keys used for pagination and results.
159
+ this.descriptors.page = {
160
+ searchTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks'),
161
+ listTasks: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks'),
162
+ listDeliveryVehicles: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deliveryVehicles'),
163
+ };
164
+ // Put together the default options sent with requests.
165
+ this._defaults = this._gaxGrpc.constructSettings('maps.fleetengine.delivery.v1.DeliveryService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
166
+ // Set up a dictionary of "inner API calls"; the core implementation
167
+ // of calling the API is handled in `google-gax`, with this code
168
+ // merely providing the destination and request information.
169
+ this.innerApiCalls = {};
170
+ // Add a warn function to the client constructor so it can be easily tested.
171
+ this.warn = this._gaxModule.warn;
172
+ }
173
+ /**
174
+ * Initialize the client.
175
+ * Performs asynchronous operations (such as authentication) and prepares the client.
176
+ * This function will be called automatically when any class method is called for the
177
+ * first time, but if you need to initialize it before calling an actual method,
178
+ * feel free to call initialize() directly.
179
+ *
180
+ * You can await on this method if you want to make sure the client is initialized.
181
+ *
182
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
183
+ */
184
+ initialize() {
185
+ // If the client stub promise is already initialized, return immediately.
186
+ if (this.deliveryServiceStub) {
187
+ return this.deliveryServiceStub;
188
+ }
189
+ // Put together the "service stub" for
190
+ // maps.fleetengine.delivery.v1.DeliveryService.
191
+ this.deliveryServiceStub = this._gaxGrpc.createStub(this._opts.fallback
192
+ ? this._protos.lookupService('maps.fleetengine.delivery.v1.DeliveryService')
193
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
+ this._protos.maps.fleetengine.delivery.v1.DeliveryService, this._opts, this._providedCustomServicePath);
195
+ // Iterate over each of the methods that the service provides
196
+ // and create an API call method for each.
197
+ const deliveryServiceStubMethods = [
198
+ 'createDeliveryVehicle',
199
+ 'getDeliveryVehicle',
200
+ 'updateDeliveryVehicle',
201
+ 'batchCreateTasks',
202
+ 'createTask',
203
+ 'getTask',
204
+ 'searchTasks',
205
+ 'updateTask',
206
+ 'listTasks',
207
+ 'getTaskTrackingInfo',
208
+ 'listDeliveryVehicles',
209
+ ];
210
+ for (const methodName of deliveryServiceStubMethods) {
211
+ const callPromise = this.deliveryServiceStub.then(stub => (...args) => {
212
+ if (this._terminated) {
213
+ return Promise.reject('The client has already been closed.');
214
+ }
215
+ const func = stub[methodName];
216
+ return func.apply(stub, args);
217
+ }, (err) => () => {
218
+ throw err;
219
+ });
220
+ const descriptor = this.descriptors.page[methodName] || undefined;
221
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
222
+ this.innerApiCalls[methodName] = apiCall;
223
+ }
224
+ return this.deliveryServiceStub;
225
+ }
226
+ /**
227
+ * The DNS address for this API service.
228
+ * @deprecated Use the apiEndpoint method of the client instance.
229
+ * @returns {string} The DNS address for this service.
230
+ */
231
+ static get servicePath() {
232
+ if (typeof process === 'object' &&
233
+ typeof process.emitWarning === 'function') {
234
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
235
+ }
236
+ return 'fleetengine.googleapis.com';
237
+ }
238
+ /**
239
+ * The DNS address for this API service - same as servicePath.
240
+ * @deprecated Use the apiEndpoint method of the client instance.
241
+ * @returns {string} The DNS address for this service.
242
+ */
243
+ static get apiEndpoint() {
244
+ if (typeof process === 'object' &&
245
+ typeof process.emitWarning === 'function') {
246
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
247
+ }
248
+ return 'fleetengine.googleapis.com';
249
+ }
250
+ /**
251
+ * The DNS address for this API service.
252
+ * @returns {string} The DNS address for this service.
253
+ */
254
+ get apiEndpoint() {
255
+ return this._servicePath;
256
+ }
257
+ get universeDomain() {
258
+ return this._universeDomain;
259
+ }
260
+ /**
261
+ * The port for this API service.
262
+ * @returns {number} The default port for this service.
263
+ */
264
+ static get port() {
265
+ return 443;
266
+ }
267
+ /**
268
+ * The scopes needed to make gRPC calls for every method defined
269
+ * in this service.
270
+ * @returns {string[]} List of default scopes.
271
+ */
272
+ static get scopes() {
273
+ return ['https://www.googleapis.com/auth/cloud-platform'];
274
+ }
275
+ /**
276
+ * Return the project ID used by this class.
277
+ * @returns {Promise} A promise that resolves to string containing the project ID.
278
+ */
279
+ getProjectId(callback) {
280
+ if (callback) {
281
+ this.auth.getProjectId(callback);
282
+ return;
283
+ }
284
+ return this.auth.getProjectId();
285
+ }
286
+ createDeliveryVehicle(request, optionsOrCallback, callback) {
287
+ var _a, _b;
288
+ request = request || {};
289
+ let options;
290
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
291
+ callback = optionsOrCallback;
292
+ options = {};
293
+ }
294
+ else {
295
+ options = optionsOrCallback;
296
+ }
297
+ options = options || {};
298
+ options.otherArgs = options.otherArgs || {};
299
+ options.otherArgs.headers = options.otherArgs.headers || {};
300
+ const routingParameter = {};
301
+ {
302
+ const fieldValue = request.parent;
303
+ if (fieldValue !== undefined && fieldValue !== null) {
304
+ const match = fieldValue
305
+ .toString()
306
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
307
+ if (match) {
308
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
309
+ Object.assign(routingParameter, { provider_id: parameterValue });
310
+ }
311
+ }
312
+ }
313
+ options.otherArgs.headers['x-goog-request-params'] =
314
+ this._gaxModule.routingHeader.fromParams(routingParameter);
315
+ this.initialize();
316
+ return this.innerApiCalls.createDeliveryVehicle(request, options, callback);
317
+ }
318
+ getDeliveryVehicle(request, optionsOrCallback, callback) {
319
+ var _a, _b;
320
+ request = request || {};
321
+ let options;
322
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
323
+ callback = optionsOrCallback;
324
+ options = {};
325
+ }
326
+ else {
327
+ options = optionsOrCallback;
328
+ }
329
+ options = options || {};
330
+ options.otherArgs = options.otherArgs || {};
331
+ options.otherArgs.headers = options.otherArgs.headers || {};
332
+ const routingParameter = {};
333
+ {
334
+ const fieldValue = request.name;
335
+ if (fieldValue !== undefined && fieldValue !== null) {
336
+ const match = fieldValue
337
+ .toString()
338
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
339
+ if (match) {
340
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
341
+ Object.assign(routingParameter, { provider_id: parameterValue });
342
+ }
343
+ }
344
+ }
345
+ options.otherArgs.headers['x-goog-request-params'] =
346
+ this._gaxModule.routingHeader.fromParams(routingParameter);
347
+ this.initialize();
348
+ return this.innerApiCalls.getDeliveryVehicle(request, options, callback);
349
+ }
350
+ updateDeliveryVehicle(request, optionsOrCallback, callback) {
351
+ var _a, _b, _c;
352
+ request = request || {};
353
+ let options;
354
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
355
+ callback = optionsOrCallback;
356
+ options = {};
357
+ }
358
+ else {
359
+ options = optionsOrCallback;
360
+ }
361
+ options = options || {};
362
+ options.otherArgs = options.otherArgs || {};
363
+ options.otherArgs.headers = options.otherArgs.headers || {};
364
+ const routingParameter = {};
365
+ {
366
+ const fieldValue = (_a = request.deliveryVehicle) === null || _a === void 0 ? void 0 : _a.name;
367
+ if (fieldValue !== undefined && fieldValue !== null) {
368
+ const match = fieldValue
369
+ .toString()
370
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
371
+ if (match) {
372
+ const parameterValue = (_c = (_b = match.groups) === null || _b === void 0 ? void 0 : _b['provider_id']) !== null && _c !== void 0 ? _c : fieldValue;
373
+ Object.assign(routingParameter, { provider_id: parameterValue });
374
+ }
375
+ }
376
+ }
377
+ options.otherArgs.headers['x-goog-request-params'] =
378
+ this._gaxModule.routingHeader.fromParams(routingParameter);
379
+ this.initialize();
380
+ return this.innerApiCalls.updateDeliveryVehicle(request, options, callback);
381
+ }
382
+ batchCreateTasks(request, optionsOrCallback, callback) {
383
+ var _a, _b;
384
+ request = request || {};
385
+ let options;
386
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
387
+ callback = optionsOrCallback;
388
+ options = {};
389
+ }
390
+ else {
391
+ options = optionsOrCallback;
392
+ }
393
+ options = options || {};
394
+ options.otherArgs = options.otherArgs || {};
395
+ options.otherArgs.headers = options.otherArgs.headers || {};
396
+ const routingParameter = {};
397
+ {
398
+ const fieldValue = request.parent;
399
+ if (fieldValue !== undefined && fieldValue !== null) {
400
+ const match = fieldValue
401
+ .toString()
402
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
403
+ if (match) {
404
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
405
+ Object.assign(routingParameter, { provider_id: parameterValue });
406
+ }
407
+ }
408
+ }
409
+ options.otherArgs.headers['x-goog-request-params'] =
410
+ this._gaxModule.routingHeader.fromParams(routingParameter);
411
+ this.initialize();
412
+ return this.innerApiCalls.batchCreateTasks(request, options, callback);
413
+ }
414
+ createTask(request, optionsOrCallback, callback) {
415
+ var _a, _b;
416
+ request = request || {};
417
+ let options;
418
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
419
+ callback = optionsOrCallback;
420
+ options = {};
421
+ }
422
+ else {
423
+ options = optionsOrCallback;
424
+ }
425
+ options = options || {};
426
+ options.otherArgs = options.otherArgs || {};
427
+ options.otherArgs.headers = options.otherArgs.headers || {};
428
+ const routingParameter = {};
429
+ {
430
+ const fieldValue = request.parent;
431
+ if (fieldValue !== undefined && fieldValue !== null) {
432
+ const match = fieldValue
433
+ .toString()
434
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
435
+ if (match) {
436
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
437
+ Object.assign(routingParameter, { provider_id: parameterValue });
438
+ }
439
+ }
440
+ }
441
+ options.otherArgs.headers['x-goog-request-params'] =
442
+ this._gaxModule.routingHeader.fromParams(routingParameter);
443
+ this.initialize();
444
+ return this.innerApiCalls.createTask(request, options, callback);
445
+ }
446
+ getTask(request, optionsOrCallback, callback) {
447
+ var _a, _b;
448
+ request = request || {};
449
+ let options;
450
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
451
+ callback = optionsOrCallback;
452
+ options = {};
453
+ }
454
+ else {
455
+ options = optionsOrCallback;
456
+ }
457
+ options = options || {};
458
+ options.otherArgs = options.otherArgs || {};
459
+ options.otherArgs.headers = options.otherArgs.headers || {};
460
+ const routingParameter = {};
461
+ {
462
+ const fieldValue = request.name;
463
+ if (fieldValue !== undefined && fieldValue !== null) {
464
+ const match = fieldValue
465
+ .toString()
466
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
467
+ if (match) {
468
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
469
+ Object.assign(routingParameter, { provider_id: parameterValue });
470
+ }
471
+ }
472
+ }
473
+ options.otherArgs.headers['x-goog-request-params'] =
474
+ this._gaxModule.routingHeader.fromParams(routingParameter);
475
+ this.initialize();
476
+ return this.innerApiCalls.getTask(request, options, callback);
477
+ }
478
+ updateTask(request, optionsOrCallback, callback) {
479
+ var _a, _b, _c;
480
+ request = request || {};
481
+ let options;
482
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
483
+ callback = optionsOrCallback;
484
+ options = {};
485
+ }
486
+ else {
487
+ options = optionsOrCallback;
488
+ }
489
+ options = options || {};
490
+ options.otherArgs = options.otherArgs || {};
491
+ options.otherArgs.headers = options.otherArgs.headers || {};
492
+ const routingParameter = {};
493
+ {
494
+ const fieldValue = (_a = request.task) === null || _a === void 0 ? void 0 : _a.name;
495
+ if (fieldValue !== undefined && fieldValue !== null) {
496
+ const match = fieldValue
497
+ .toString()
498
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
499
+ if (match) {
500
+ const parameterValue = (_c = (_b = match.groups) === null || _b === void 0 ? void 0 : _b['provider_id']) !== null && _c !== void 0 ? _c : fieldValue;
501
+ Object.assign(routingParameter, { provider_id: parameterValue });
502
+ }
503
+ }
504
+ }
505
+ options.otherArgs.headers['x-goog-request-params'] =
506
+ this._gaxModule.routingHeader.fromParams(routingParameter);
507
+ this.initialize();
508
+ return this.innerApiCalls.updateTask(request, options, callback);
509
+ }
510
+ getTaskTrackingInfo(request, optionsOrCallback, callback) {
511
+ var _a, _b;
512
+ request = request || {};
513
+ let options;
514
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
515
+ callback = optionsOrCallback;
516
+ options = {};
517
+ }
518
+ else {
519
+ options = optionsOrCallback;
520
+ }
521
+ options = options || {};
522
+ options.otherArgs = options.otherArgs || {};
523
+ options.otherArgs.headers = options.otherArgs.headers || {};
524
+ const routingParameter = {};
525
+ {
526
+ const fieldValue = request.name;
527
+ if (fieldValue !== undefined && fieldValue !== null) {
528
+ const match = fieldValue
529
+ .toString()
530
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
531
+ if (match) {
532
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
533
+ Object.assign(routingParameter, { provider_id: parameterValue });
534
+ }
535
+ }
536
+ }
537
+ options.otherArgs.headers['x-goog-request-params'] =
538
+ this._gaxModule.routingHeader.fromParams(routingParameter);
539
+ this.initialize();
540
+ return this.innerApiCalls.getTaskTrackingInfo(request, options, callback);
541
+ }
542
+ searchTasks(request, optionsOrCallback, callback) {
543
+ var _a, _b;
544
+ request = request || {};
545
+ let options;
546
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
547
+ callback = optionsOrCallback;
548
+ options = {};
549
+ }
550
+ else {
551
+ options = optionsOrCallback;
552
+ }
553
+ options = options || {};
554
+ options.otherArgs = options.otherArgs || {};
555
+ options.otherArgs.headers = options.otherArgs.headers || {};
556
+ const routingParameter = {};
557
+ {
558
+ const fieldValue = request.parent;
559
+ if (fieldValue !== undefined && fieldValue !== null) {
560
+ const match = fieldValue
561
+ .toString()
562
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
563
+ if (match) {
564
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
565
+ Object.assign(routingParameter, { provider_id: parameterValue });
566
+ }
567
+ }
568
+ }
569
+ options.otherArgs.headers['x-goog-request-params'] =
570
+ this._gaxModule.routingHeader.fromParams(routingParameter);
571
+ this.initialize();
572
+ this.warn('DEP$DeliveryService-$SearchTasks', 'SearchTasks is deprecated and may be removed in a future version.', 'DeprecationWarning');
573
+ return this.innerApiCalls.searchTasks(request, options, callback);
574
+ }
575
+ /**
576
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
577
+ * @param {Object} request
578
+ * The request object that will be sent.
579
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
580
+ * Optional. The standard Delivery API request header.
581
+ * @param {string} request.parent
582
+ * Required. Must be in the format `providers/{provider}`.
583
+ * The provider must be the Google Cloud Project ID. For example,
584
+ * `sample-cloud-project`.
585
+ * @param {string} request.trackingId
586
+ * Required. The identifier of the set of related Tasks being requested.
587
+ * Tracking IDs are subject to the following restrictions:
588
+ *
589
+ * * Must be a valid Unicode string.
590
+ * * Limited to a maximum length of 64 characters.
591
+ * * Normalized according to [Unicode Normalization Form C]
592
+ * (http://www.unicode.org/reports/tr15/).
593
+ * * May not contain any of the following ASCII characters: '/', ':', '?',
594
+ * ',', or '#'.
595
+ * @param {number} [request.pageSize]
596
+ * Optional. The maximum number of Tasks to return. The service may return
597
+ * fewer than this value. If you don't specify this value, then the server
598
+ * determines the number of results to return.
599
+ * @param {string} [request.pageToken]
600
+ * Optional. A page token, received from a previous `SearchTasks` call. You
601
+ * must provide this value to retrieve the subsequent page.
602
+ *
603
+ * When paginating, all other parameters provided to `SearchTasks` must match
604
+ * the call that provided the page token.
605
+ * @param {object} [options]
606
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
607
+ * @returns {Stream}
608
+ * An object stream which emits an object representing {@link protos.maps.fleetengine.delivery.v1.Task|Task} on 'data' event.
609
+ * The client library will perform auto-pagination by default: it will call the API as many
610
+ * times as needed. Note that it can affect your quota.
611
+ * We recommend using `searchTasksAsync()`
612
+ * method described below for async iteration which you can stop as needed.
613
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
614
+ * for more details and examples.
615
+ * @deprecated SearchTasks is deprecated and may be removed in a future version.
616
+ */
617
+ searchTasksStream(request, options) {
618
+ var _a, _b;
619
+ request = request || {};
620
+ options = options || {};
621
+ options.otherArgs = options.otherArgs || {};
622
+ options.otherArgs.headers = options.otherArgs.headers || {};
623
+ const routingParameter = {};
624
+ {
625
+ const fieldValue = request.parent;
626
+ if (fieldValue !== undefined && fieldValue !== null) {
627
+ const match = fieldValue
628
+ .toString()
629
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
630
+ if (match) {
631
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
632
+ Object.assign(routingParameter, { provider_id: parameterValue });
633
+ }
634
+ }
635
+ }
636
+ options.otherArgs.headers['x-goog-request-params'] =
637
+ this._gaxModule.routingHeader.fromParams(routingParameter);
638
+ const defaultCallSettings = this._defaults['searchTasks'];
639
+ const callSettings = defaultCallSettings.merge(options);
640
+ this.initialize();
641
+ this.warn('DEP$DeliveryService-$SearchTasks', 'SearchTasks is deprecated and may be removed in a future version.', 'DeprecationWarning');
642
+ return this.descriptors.page.searchTasks.createStream(this.innerApiCalls.searchTasks, request, callSettings);
643
+ }
644
+ /**
645
+ * Equivalent to `searchTasks`, but returns an iterable object.
646
+ *
647
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
648
+ * @param {Object} request
649
+ * The request object that will be sent.
650
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
651
+ * Optional. The standard Delivery API request header.
652
+ * @param {string} request.parent
653
+ * Required. Must be in the format `providers/{provider}`.
654
+ * The provider must be the Google Cloud Project ID. For example,
655
+ * `sample-cloud-project`.
656
+ * @param {string} request.trackingId
657
+ * Required. The identifier of the set of related Tasks being requested.
658
+ * Tracking IDs are subject to the following restrictions:
659
+ *
660
+ * * Must be a valid Unicode string.
661
+ * * Limited to a maximum length of 64 characters.
662
+ * * Normalized according to [Unicode Normalization Form C]
663
+ * (http://www.unicode.org/reports/tr15/).
664
+ * * May not contain any of the following ASCII characters: '/', ':', '?',
665
+ * ',', or '#'.
666
+ * @param {number} [request.pageSize]
667
+ * Optional. The maximum number of Tasks to return. The service may return
668
+ * fewer than this value. If you don't specify this value, then the server
669
+ * determines the number of results to return.
670
+ * @param {string} [request.pageToken]
671
+ * Optional. A page token, received from a previous `SearchTasks` call. You
672
+ * must provide this value to retrieve the subsequent page.
673
+ *
674
+ * When paginating, all other parameters provided to `SearchTasks` must match
675
+ * the call that provided the page token.
676
+ * @param {object} [options]
677
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
678
+ * @returns {Object}
679
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
680
+ * When you iterate the returned iterable, each element will be an object representing
681
+ * {@link protos.maps.fleetengine.delivery.v1.Task|Task}. The API will be called under the hood as needed, once per the page,
682
+ * so you can stop the iteration when you don't need more results.
683
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
684
+ * for more details and examples.
685
+ * @example <caption>include:samples/generated/v1/delivery_service.search_tasks.js</caption>
686
+ * region_tag:fleetengine_v1_generated_DeliveryService_SearchTasks_async
687
+ * @deprecated SearchTasks is deprecated and may be removed in a future version.
688
+ */
689
+ searchTasksAsync(request, options) {
690
+ var _a, _b;
691
+ request = request || {};
692
+ options = options || {};
693
+ options.otherArgs = options.otherArgs || {};
694
+ options.otherArgs.headers = options.otherArgs.headers || {};
695
+ const routingParameter = {};
696
+ {
697
+ const fieldValue = request.parent;
698
+ if (fieldValue !== undefined && fieldValue !== null) {
699
+ const match = fieldValue
700
+ .toString()
701
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
702
+ if (match) {
703
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
704
+ Object.assign(routingParameter, { provider_id: parameterValue });
705
+ }
706
+ }
707
+ }
708
+ options.otherArgs.headers['x-goog-request-params'] =
709
+ this._gaxModule.routingHeader.fromParams(routingParameter);
710
+ const defaultCallSettings = this._defaults['searchTasks'];
711
+ const callSettings = defaultCallSettings.merge(options);
712
+ this.initialize();
713
+ this.warn('DEP$DeliveryService-$SearchTasks', 'SearchTasks is deprecated and may be removed in a future version.', 'DeprecationWarning');
714
+ return this.descriptors.page.searchTasks.asyncIterate(this.innerApiCalls['searchTasks'], request, callSettings);
715
+ }
716
+ listTasks(request, optionsOrCallback, callback) {
717
+ var _a, _b;
718
+ request = request || {};
719
+ let options;
720
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
721
+ callback = optionsOrCallback;
722
+ options = {};
723
+ }
724
+ else {
725
+ options = optionsOrCallback;
726
+ }
727
+ options = options || {};
728
+ options.otherArgs = options.otherArgs || {};
729
+ options.otherArgs.headers = options.otherArgs.headers || {};
730
+ const routingParameter = {};
731
+ {
732
+ const fieldValue = request.parent;
733
+ if (fieldValue !== undefined && fieldValue !== null) {
734
+ const match = fieldValue
735
+ .toString()
736
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
737
+ if (match) {
738
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
739
+ Object.assign(routingParameter, { provider_id: parameterValue });
740
+ }
741
+ }
742
+ }
743
+ options.otherArgs.headers['x-goog-request-params'] =
744
+ this._gaxModule.routingHeader.fromParams(routingParameter);
745
+ this.initialize();
746
+ return this.innerApiCalls.listTasks(request, options, callback);
747
+ }
748
+ /**
749
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
750
+ * @param {Object} request
751
+ * The request object that will be sent.
752
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
753
+ * Optional. The standard Delivery API request header.
754
+ * @param {string} request.parent
755
+ * Required. Must be in the format `providers/{provider}`.
756
+ * The `provider` must be the Google Cloud Project ID. For example,
757
+ * `sample-cloud-project`.
758
+ * @param {number} [request.pageSize]
759
+ * Optional. The maximum number of Tasks to return. The service may return
760
+ * fewer than this value. If you don't specify this value, then the server
761
+ * determines the number of results to return.
762
+ * @param {string} [request.pageToken]
763
+ * Optional. A page token received from a previous `ListTasks` call.
764
+ * You can provide this to retrieve the subsequent page.
765
+ *
766
+ * When paginating, all other parameters provided to `ListTasks` must match
767
+ * the call that provided the page token.
768
+ * @param {string} [request.filter]
769
+ * Optional. A filter query to apply when listing Tasks. See
770
+ * http://aip.dev/160 for examples of filter syntax. If you don't specify a
771
+ * value, or if you filter on an empty string, then all Tasks are returned.
772
+ * For information about the Task properties that you can filter on, see [Task
773
+ * list](/maps/documentation/transportation-logistics/last-mile-fleet-solution/fleet-performance/fleet-engine/deliveries_api#list_tasks).
774
+ * @param {object} [options]
775
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
776
+ * @returns {Stream}
777
+ * An object stream which emits an object representing {@link protos.maps.fleetengine.delivery.v1.Task|Task} on 'data' event.
778
+ * The client library will perform auto-pagination by default: it will call the API as many
779
+ * times as needed. Note that it can affect your quota.
780
+ * We recommend using `listTasksAsync()`
781
+ * method described below for async iteration which you can stop as needed.
782
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
783
+ * for more details and examples.
784
+ */
785
+ listTasksStream(request, options) {
786
+ var _a, _b;
787
+ request = request || {};
788
+ options = options || {};
789
+ options.otherArgs = options.otherArgs || {};
790
+ options.otherArgs.headers = options.otherArgs.headers || {};
791
+ const routingParameter = {};
792
+ {
793
+ const fieldValue = request.parent;
794
+ if (fieldValue !== undefined && fieldValue !== null) {
795
+ const match = fieldValue
796
+ .toString()
797
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
798
+ if (match) {
799
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
800
+ Object.assign(routingParameter, { provider_id: parameterValue });
801
+ }
802
+ }
803
+ }
804
+ options.otherArgs.headers['x-goog-request-params'] =
805
+ this._gaxModule.routingHeader.fromParams(routingParameter);
806
+ const defaultCallSettings = this._defaults['listTasks'];
807
+ const callSettings = defaultCallSettings.merge(options);
808
+ this.initialize();
809
+ return this.descriptors.page.listTasks.createStream(this.innerApiCalls.listTasks, request, callSettings);
810
+ }
811
+ /**
812
+ * Equivalent to `listTasks`, but returns an iterable object.
813
+ *
814
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
815
+ * @param {Object} request
816
+ * The request object that will be sent.
817
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
818
+ * Optional. The standard Delivery API request header.
819
+ * @param {string} request.parent
820
+ * Required. Must be in the format `providers/{provider}`.
821
+ * The `provider` must be the Google Cloud Project ID. For example,
822
+ * `sample-cloud-project`.
823
+ * @param {number} [request.pageSize]
824
+ * Optional. The maximum number of Tasks to return. The service may return
825
+ * fewer than this value. If you don't specify this value, then the server
826
+ * determines the number of results to return.
827
+ * @param {string} [request.pageToken]
828
+ * Optional. A page token received from a previous `ListTasks` call.
829
+ * You can provide this to retrieve the subsequent page.
830
+ *
831
+ * When paginating, all other parameters provided to `ListTasks` must match
832
+ * the call that provided the page token.
833
+ * @param {string} [request.filter]
834
+ * Optional. A filter query to apply when listing Tasks. See
835
+ * http://aip.dev/160 for examples of filter syntax. If you don't specify a
836
+ * value, or if you filter on an empty string, then all Tasks are returned.
837
+ * For information about the Task properties that you can filter on, see [Task
838
+ * list](/maps/documentation/transportation-logistics/last-mile-fleet-solution/fleet-performance/fleet-engine/deliveries_api#list_tasks).
839
+ * @param {object} [options]
840
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
841
+ * @returns {Object}
842
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
843
+ * When you iterate the returned iterable, each element will be an object representing
844
+ * {@link protos.maps.fleetengine.delivery.v1.Task|Task}. The API will be called under the hood as needed, once per the page,
845
+ * so you can stop the iteration when you don't need more results.
846
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
847
+ * for more details and examples.
848
+ * @example <caption>include:samples/generated/v1/delivery_service.list_tasks.js</caption>
849
+ * region_tag:fleetengine_v1_generated_DeliveryService_ListTasks_async
850
+ */
851
+ listTasksAsync(request, options) {
852
+ var _a, _b;
853
+ request = request || {};
854
+ options = options || {};
855
+ options.otherArgs = options.otherArgs || {};
856
+ options.otherArgs.headers = options.otherArgs.headers || {};
857
+ const routingParameter = {};
858
+ {
859
+ const fieldValue = request.parent;
860
+ if (fieldValue !== undefined && fieldValue !== null) {
861
+ const match = fieldValue
862
+ .toString()
863
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
864
+ if (match) {
865
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
866
+ Object.assign(routingParameter, { provider_id: parameterValue });
867
+ }
868
+ }
869
+ }
870
+ options.otherArgs.headers['x-goog-request-params'] =
871
+ this._gaxModule.routingHeader.fromParams(routingParameter);
872
+ const defaultCallSettings = this._defaults['listTasks'];
873
+ const callSettings = defaultCallSettings.merge(options);
874
+ this.initialize();
875
+ return this.descriptors.page.listTasks.asyncIterate(this.innerApiCalls['listTasks'], request, callSettings);
876
+ }
877
+ listDeliveryVehicles(request, optionsOrCallback, callback) {
878
+ var _a, _b;
879
+ request = request || {};
880
+ let options;
881
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
882
+ callback = optionsOrCallback;
883
+ options = {};
884
+ }
885
+ else {
886
+ options = optionsOrCallback;
887
+ }
888
+ options = options || {};
889
+ options.otherArgs = options.otherArgs || {};
890
+ options.otherArgs.headers = options.otherArgs.headers || {};
891
+ const routingParameter = {};
892
+ {
893
+ const fieldValue = request.parent;
894
+ if (fieldValue !== undefined && fieldValue !== null) {
895
+ const match = fieldValue
896
+ .toString()
897
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
898
+ if (match) {
899
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
900
+ Object.assign(routingParameter, { provider_id: parameterValue });
901
+ }
902
+ }
903
+ }
904
+ options.otherArgs.headers['x-goog-request-params'] =
905
+ this._gaxModule.routingHeader.fromParams(routingParameter);
906
+ this.initialize();
907
+ return this.innerApiCalls.listDeliveryVehicles(request, options, callback);
908
+ }
909
+ /**
910
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
911
+ * @param {Object} request
912
+ * The request object that will be sent.
913
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
914
+ * Optional. The standard Delivery API request header.
915
+ * @param {string} request.parent
916
+ * Required. Must be in the format `providers/{provider}`.
917
+ * The `provider` must be the Google Cloud Project ID.
918
+ * For example, `sample-cloud-project`.
919
+ * @param {number} [request.pageSize]
920
+ * Optional. The maximum number of vehicles to return. The service may return
921
+ * fewer than this number. If you don't specify this number, then the server
922
+ * determines the number of results to return.
923
+ * @param {string} [request.pageToken]
924
+ * Optional. A page token, received from a previous `ListDeliveryVehicles`
925
+ * call. You must provide this in order to retrieve the subsequent page.
926
+ *
927
+ * When paginating, all other parameters provided to `ListDeliveryVehicles`
928
+ * must match the call that provided the page token.
929
+ * @param {string} [request.filter]
930
+ * Optional. A filter query to apply when listing delivery vehicles. See
931
+ * http://aip.dev/160 for examples of the filter syntax. If you don't specify
932
+ * a value, or if you specify an empty string for the filter, then all
933
+ * delivery vehicles are returned.
934
+ *
935
+ * Note that the only queries supported for `ListDeliveryVehicles` are
936
+ * on vehicle attributes (for example, `attributes.<key> = <value>` or
937
+ * `attributes.<key1> = <value1> AND attributes.<key2> = <value2>`). Also, all
938
+ * attributes are stored as strings, so the only supported comparisons against
939
+ * attributes are string comparisons. In order to compare against number or
940
+ * boolean values, the values must be explicitly quoted to be treated as
941
+ * strings (for example, `attributes.<key> = "10"` or
942
+ * `attributes.<key> = "true"`).
943
+ *
944
+ * The maximum number of restrictions allowed in a filter query is 50. A
945
+ * restriction is a part of the query of the form
946
+ * `attribute.<KEY> <COMPARATOR> <VALUE>`, for example `attributes.foo = bar`
947
+ * is 1 restriction.
948
+ * @param {google.geo.type.Viewport} [request.viewport]
949
+ * Optional. A filter that limits the vehicles returned to those whose last
950
+ * known location was in the rectangular area defined by the viewport.
951
+ * @param {object} [options]
952
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
953
+ * @returns {Stream}
954
+ * An object stream which emits an object representing {@link protos.maps.fleetengine.delivery.v1.DeliveryVehicle|DeliveryVehicle} on 'data' event.
955
+ * The client library will perform auto-pagination by default: it will call the API as many
956
+ * times as needed. Note that it can affect your quota.
957
+ * We recommend using `listDeliveryVehiclesAsync()`
958
+ * method described below for async iteration which you can stop as needed.
959
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
960
+ * for more details and examples.
961
+ */
962
+ listDeliveryVehiclesStream(request, options) {
963
+ var _a, _b;
964
+ request = request || {};
965
+ options = options || {};
966
+ options.otherArgs = options.otherArgs || {};
967
+ options.otherArgs.headers = options.otherArgs.headers || {};
968
+ const routingParameter = {};
969
+ {
970
+ const fieldValue = request.parent;
971
+ if (fieldValue !== undefined && fieldValue !== null) {
972
+ const match = fieldValue
973
+ .toString()
974
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
975
+ if (match) {
976
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
977
+ Object.assign(routingParameter, { provider_id: parameterValue });
978
+ }
979
+ }
980
+ }
981
+ options.otherArgs.headers['x-goog-request-params'] =
982
+ this._gaxModule.routingHeader.fromParams(routingParameter);
983
+ const defaultCallSettings = this._defaults['listDeliveryVehicles'];
984
+ const callSettings = defaultCallSettings.merge(options);
985
+ this.initialize();
986
+ return this.descriptors.page.listDeliveryVehicles.createStream(this.innerApiCalls.listDeliveryVehicles, request, callSettings);
987
+ }
988
+ /**
989
+ * Equivalent to `listDeliveryVehicles`, but returns an iterable object.
990
+ *
991
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
992
+ * @param {Object} request
993
+ * The request object that will be sent.
994
+ * @param {maps.fleetengine.delivery.v1.DeliveryRequestHeader} [request.header]
995
+ * Optional. The standard Delivery API request header.
996
+ * @param {string} request.parent
997
+ * Required. Must be in the format `providers/{provider}`.
998
+ * The `provider` must be the Google Cloud Project ID.
999
+ * For example, `sample-cloud-project`.
1000
+ * @param {number} [request.pageSize]
1001
+ * Optional. The maximum number of vehicles to return. The service may return
1002
+ * fewer than this number. If you don't specify this number, then the server
1003
+ * determines the number of results to return.
1004
+ * @param {string} [request.pageToken]
1005
+ * Optional. A page token, received from a previous `ListDeliveryVehicles`
1006
+ * call. You must provide this in order to retrieve the subsequent page.
1007
+ *
1008
+ * When paginating, all other parameters provided to `ListDeliveryVehicles`
1009
+ * must match the call that provided the page token.
1010
+ * @param {string} [request.filter]
1011
+ * Optional. A filter query to apply when listing delivery vehicles. See
1012
+ * http://aip.dev/160 for examples of the filter syntax. If you don't specify
1013
+ * a value, or if you specify an empty string for the filter, then all
1014
+ * delivery vehicles are returned.
1015
+ *
1016
+ * Note that the only queries supported for `ListDeliveryVehicles` are
1017
+ * on vehicle attributes (for example, `attributes.<key> = <value>` or
1018
+ * `attributes.<key1> = <value1> AND attributes.<key2> = <value2>`). Also, all
1019
+ * attributes are stored as strings, so the only supported comparisons against
1020
+ * attributes are string comparisons. In order to compare against number or
1021
+ * boolean values, the values must be explicitly quoted to be treated as
1022
+ * strings (for example, `attributes.<key> = "10"` or
1023
+ * `attributes.<key> = "true"`).
1024
+ *
1025
+ * The maximum number of restrictions allowed in a filter query is 50. A
1026
+ * restriction is a part of the query of the form
1027
+ * `attribute.<KEY> <COMPARATOR> <VALUE>`, for example `attributes.foo = bar`
1028
+ * is 1 restriction.
1029
+ * @param {google.geo.type.Viewport} [request.viewport]
1030
+ * Optional. A filter that limits the vehicles returned to those whose last
1031
+ * known location was in the rectangular area defined by the viewport.
1032
+ * @param {object} [options]
1033
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1034
+ * @returns {Object}
1035
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1036
+ * When you iterate the returned iterable, each element will be an object representing
1037
+ * {@link protos.maps.fleetengine.delivery.v1.DeliveryVehicle|DeliveryVehicle}. The API will be called under the hood as needed, once per the page,
1038
+ * so you can stop the iteration when you don't need more results.
1039
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1040
+ * for more details and examples.
1041
+ * @example <caption>include:samples/generated/v1/delivery_service.list_delivery_vehicles.js</caption>
1042
+ * region_tag:fleetengine_v1_generated_DeliveryService_ListDeliveryVehicles_async
1043
+ */
1044
+ listDeliveryVehiclesAsync(request, options) {
1045
+ var _a, _b;
1046
+ request = request || {};
1047
+ options = options || {};
1048
+ options.otherArgs = options.otherArgs || {};
1049
+ options.otherArgs.headers = options.otherArgs.headers || {};
1050
+ const routingParameter = {};
1051
+ {
1052
+ const fieldValue = request.parent;
1053
+ if (fieldValue !== undefined && fieldValue !== null) {
1054
+ const match = fieldValue
1055
+ .toString()
1056
+ .match(RegExp('(?<provider_id>providers/[^/]+)'));
1057
+ if (match) {
1058
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
1059
+ Object.assign(routingParameter, { provider_id: parameterValue });
1060
+ }
1061
+ }
1062
+ }
1063
+ options.otherArgs.headers['x-goog-request-params'] =
1064
+ this._gaxModule.routingHeader.fromParams(routingParameter);
1065
+ const defaultCallSettings = this._defaults['listDeliveryVehicles'];
1066
+ const callSettings = defaultCallSettings.merge(options);
1067
+ this.initialize();
1068
+ return this.descriptors.page.listDeliveryVehicles.asyncIterate(this.innerApiCalls['listDeliveryVehicles'], request, callSettings);
1069
+ }
1070
+ // --------------------
1071
+ // -- Path templates --
1072
+ // --------------------
1073
+ /**
1074
+ * Return a fully-qualified deliveryVehicle resource name string.
1075
+ *
1076
+ * @param {string} provider
1077
+ * @param {string} vehicle
1078
+ * @returns {string} Resource name string.
1079
+ */
1080
+ deliveryVehiclePath(provider, vehicle) {
1081
+ return this.pathTemplates.deliveryVehiclePathTemplate.render({
1082
+ provider: provider,
1083
+ vehicle: vehicle,
1084
+ });
1085
+ }
1086
+ /**
1087
+ * Parse the provider from DeliveryVehicle resource.
1088
+ *
1089
+ * @param {string} deliveryVehicleName
1090
+ * A fully-qualified path representing DeliveryVehicle resource.
1091
+ * @returns {string} A string representing the provider.
1092
+ */
1093
+ matchProviderFromDeliveryVehicleName(deliveryVehicleName) {
1094
+ return this.pathTemplates.deliveryVehiclePathTemplate.match(deliveryVehicleName).provider;
1095
+ }
1096
+ /**
1097
+ * Parse the vehicle from DeliveryVehicle resource.
1098
+ *
1099
+ * @param {string} deliveryVehicleName
1100
+ * A fully-qualified path representing DeliveryVehicle resource.
1101
+ * @returns {string} A string representing the vehicle.
1102
+ */
1103
+ matchVehicleFromDeliveryVehicleName(deliveryVehicleName) {
1104
+ return this.pathTemplates.deliveryVehiclePathTemplate.match(deliveryVehicleName).vehicle;
1105
+ }
1106
+ /**
1107
+ * Return a fully-qualified provider resource name string.
1108
+ *
1109
+ * @param {string} provider
1110
+ * @returns {string} Resource name string.
1111
+ */
1112
+ providerPath(provider) {
1113
+ return this.pathTemplates.providerPathTemplate.render({
1114
+ provider: provider,
1115
+ });
1116
+ }
1117
+ /**
1118
+ * Parse the provider from Provider resource.
1119
+ *
1120
+ * @param {string} providerName
1121
+ * A fully-qualified path representing Provider resource.
1122
+ * @returns {string} A string representing the provider.
1123
+ */
1124
+ matchProviderFromProviderName(providerName) {
1125
+ return this.pathTemplates.providerPathTemplate.match(providerName).provider;
1126
+ }
1127
+ /**
1128
+ * Return a fully-qualified task resource name string.
1129
+ *
1130
+ * @param {string} provider
1131
+ * @param {string} task
1132
+ * @returns {string} Resource name string.
1133
+ */
1134
+ taskPath(provider, task) {
1135
+ return this.pathTemplates.taskPathTemplate.render({
1136
+ provider: provider,
1137
+ task: task,
1138
+ });
1139
+ }
1140
+ /**
1141
+ * Parse the provider from Task resource.
1142
+ *
1143
+ * @param {string} taskName
1144
+ * A fully-qualified path representing Task resource.
1145
+ * @returns {string} A string representing the provider.
1146
+ */
1147
+ matchProviderFromTaskName(taskName) {
1148
+ return this.pathTemplates.taskPathTemplate.match(taskName).provider;
1149
+ }
1150
+ /**
1151
+ * Parse the task from Task resource.
1152
+ *
1153
+ * @param {string} taskName
1154
+ * A fully-qualified path representing Task resource.
1155
+ * @returns {string} A string representing the task.
1156
+ */
1157
+ matchTaskFromTaskName(taskName) {
1158
+ return this.pathTemplates.taskPathTemplate.match(taskName).task;
1159
+ }
1160
+ /**
1161
+ * Return a fully-qualified taskTrackingInfo resource name string.
1162
+ *
1163
+ * @param {string} provider
1164
+ * @param {string} tracking
1165
+ * @returns {string} Resource name string.
1166
+ */
1167
+ taskTrackingInfoPath(provider, tracking) {
1168
+ return this.pathTemplates.taskTrackingInfoPathTemplate.render({
1169
+ provider: provider,
1170
+ tracking: tracking,
1171
+ });
1172
+ }
1173
+ /**
1174
+ * Parse the provider from TaskTrackingInfo resource.
1175
+ *
1176
+ * @param {string} taskTrackingInfoName
1177
+ * A fully-qualified path representing TaskTrackingInfo resource.
1178
+ * @returns {string} A string representing the provider.
1179
+ */
1180
+ matchProviderFromTaskTrackingInfoName(taskTrackingInfoName) {
1181
+ return this.pathTemplates.taskTrackingInfoPathTemplate.match(taskTrackingInfoName).provider;
1182
+ }
1183
+ /**
1184
+ * Parse the tracking from TaskTrackingInfo resource.
1185
+ *
1186
+ * @param {string} taskTrackingInfoName
1187
+ * A fully-qualified path representing TaskTrackingInfo resource.
1188
+ * @returns {string} A string representing the tracking.
1189
+ */
1190
+ matchTrackingFromTaskTrackingInfoName(taskTrackingInfoName) {
1191
+ return this.pathTemplates.taskTrackingInfoPathTemplate.match(taskTrackingInfoName).tracking;
1192
+ }
1193
+ /**
1194
+ * Terminate the gRPC channel and close the client.
1195
+ *
1196
+ * The client will no longer be usable and all future behavior is undefined.
1197
+ * @returns {Promise} A promise that resolves when the client is closed.
1198
+ */
1199
+ close() {
1200
+ if (this.deliveryServiceStub && !this._terminated) {
1201
+ return this.deliveryServiceStub.then(stub => {
1202
+ this._terminated = true;
1203
+ stub.close();
1204
+ });
1205
+ }
1206
+ return Promise.resolve();
1207
+ }
1208
+ }
1209
+ exports.DeliveryServiceClient = DeliveryServiceClient;
1210
+ //# sourceMappingURL=delivery_service_client.js.map