@googlemaps/fleetengine 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,904 @@
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.VehicleServiceClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ /**
23
+ * Client JSON configuration object, loaded from
24
+ * `src/v1/vehicle_service_client_config.json`.
25
+ * This file defines retry strategy and timeouts for all API methods in this library.
26
+ */
27
+ const gapicConfig = require("./vehicle_service_client_config.json");
28
+ const version = require('../../../package.json').version;
29
+ /**
30
+ * Vehicle management service.
31
+ * @class
32
+ * @memberof v1
33
+ */
34
+ class VehicleServiceClient {
35
+ /**
36
+ * Construct an instance of VehicleServiceClient.
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 VehicleServiceClient({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) && (opts === null || opts === void 0 ? void 0 : opts.universeDomain) && (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
86
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
87
+ }
88
+ const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
89
+ this._universeDomain = (_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';
90
+ this._servicePath = 'fleetengine.' + this._universeDomain;
91
+ const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
92
+ this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
93
+ const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
94
+ const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
95
+ 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');
96
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
97
+ // Request numeric enum values if REST transport is used.
98
+ opts.numericEnums = true;
99
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
100
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
101
+ opts['scopes'] = staticMembers.scopes;
102
+ }
103
+ // Load google-gax module synchronously if needed
104
+ if (!gaxInstance) {
105
+ gaxInstance = require('google-gax');
106
+ }
107
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
108
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
109
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
110
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
111
+ // Save options to use in initialize() method.
112
+ this._opts = opts;
113
+ // Save the auth object to the client, for use by other methods.
114
+ this.auth = this._gaxGrpc.auth;
115
+ // Set useJWTAccessWithScope on the auth object.
116
+ this.auth.useJWTAccessWithScope = true;
117
+ // Set defaultServicePath on the auth object.
118
+ this.auth.defaultServicePath = this._servicePath;
119
+ // Set the default scopes in auth client if needed.
120
+ if (servicePath === this._servicePath) {
121
+ this.auth.defaultScopes = staticMembers.scopes;
122
+ }
123
+ // Determine the client header string.
124
+ const clientHeader = [
125
+ `gax/${this._gaxModule.version}`,
126
+ `gapic/${version}`,
127
+ ];
128
+ if (typeof process === 'object' && 'versions' in process) {
129
+ clientHeader.push(`gl-node/${process.versions.node}`);
130
+ }
131
+ else {
132
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
133
+ }
134
+ if (!opts.fallback) {
135
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
136
+ }
137
+ else {
138
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
139
+ }
140
+ if (opts.libName && opts.libVersion) {
141
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
142
+ }
143
+ // Load the applicable protos.
144
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
145
+ // This API contains "path templates"; forward-slash-separated
146
+ // identifiers to uniquely identify resources within the API.
147
+ // Create useful helper objects for these.
148
+ this.pathTemplates = {
149
+ tripPathTemplate: new this._gaxModule.PathTemplate('providers/{provider}/trips/{trip}'),
150
+ vehiclePathTemplate: new this._gaxModule.PathTemplate('providers/{provider}/vehicles/{vehicle}'),
151
+ };
152
+ // Some of the methods on this service return "paged" results,
153
+ // (e.g. 50 results at a time, with tokens to get subsequent
154
+ // pages). Denote the keys used for pagination and results.
155
+ this.descriptors.page = {
156
+ listVehicles: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vehicles')
157
+ };
158
+ // Put together the default options sent with requests.
159
+ this._defaults = this._gaxGrpc.constructSettings('maps.fleetengine.v1.VehicleService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
160
+ // Set up a dictionary of "inner API calls"; the core implementation
161
+ // of calling the API is handled in `google-gax`, with this code
162
+ // merely providing the destination and request information.
163
+ this.innerApiCalls = {};
164
+ // Add a warn function to the client constructor so it can be easily tested.
165
+ this.warn = this._gaxModule.warn;
166
+ }
167
+ /**
168
+ * Initialize the client.
169
+ * Performs asynchronous operations (such as authentication) and prepares the client.
170
+ * This function will be called automatically when any class method is called for the
171
+ * first time, but if you need to initialize it before calling an actual method,
172
+ * feel free to call initialize() directly.
173
+ *
174
+ * You can await on this method if you want to make sure the client is initialized.
175
+ *
176
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
177
+ */
178
+ initialize() {
179
+ // If the client stub promise is already initialized, return immediately.
180
+ if (this.vehicleServiceStub) {
181
+ return this.vehicleServiceStub;
182
+ }
183
+ // Put together the "service stub" for
184
+ // maps.fleetengine.v1.VehicleService.
185
+ this.vehicleServiceStub = this._gaxGrpc.createStub(this._opts.fallback ?
186
+ this._protos.lookupService('maps.fleetengine.v1.VehicleService') :
187
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
188
+ this._protos.maps.fleetengine.v1.VehicleService, this._opts, this._providedCustomServicePath);
189
+ // Iterate over each of the methods that the service provides
190
+ // and create an API call method for each.
191
+ const vehicleServiceStubMethods = ['createVehicle', 'getVehicle', 'updateVehicle', 'updateVehicleLocation', 'updateVehicleAttributes', 'listVehicles', 'searchVehicles', 'searchFuzzedVehicles'];
192
+ for (const methodName of vehicleServiceStubMethods) {
193
+ const callPromise = this.vehicleServiceStub.then(stub => (...args) => {
194
+ if (this._terminated) {
195
+ return Promise.reject('The client has already been closed.');
196
+ }
197
+ const func = stub[methodName];
198
+ return func.apply(stub, args);
199
+ }, (err) => () => {
200
+ throw err;
201
+ });
202
+ const descriptor = this.descriptors.page[methodName] ||
203
+ undefined;
204
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
205
+ this.innerApiCalls[methodName] = apiCall;
206
+ }
207
+ return this.vehicleServiceStub;
208
+ }
209
+ /**
210
+ * The DNS address for this API service.
211
+ * @deprecated Use the apiEndpoint method of the client instance.
212
+ * @returns {string} The DNS address for this service.
213
+ */
214
+ static get servicePath() {
215
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
216
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
217
+ }
218
+ return 'fleetengine.googleapis.com';
219
+ }
220
+ /**
221
+ * The DNS address for this API service - same as servicePath.
222
+ * @deprecated Use the apiEndpoint method of the client instance.
223
+ * @returns {string} The DNS address for this service.
224
+ */
225
+ static get apiEndpoint() {
226
+ if (typeof process === 'object' && typeof process.emitWarning === 'function') {
227
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
228
+ }
229
+ return 'fleetengine.googleapis.com';
230
+ }
231
+ /**
232
+ * The DNS address for this API service.
233
+ * @returns {string} The DNS address for this service.
234
+ */
235
+ get apiEndpoint() {
236
+ return this._servicePath;
237
+ }
238
+ get universeDomain() {
239
+ return this._universeDomain;
240
+ }
241
+ /**
242
+ * The port for this API service.
243
+ * @returns {number} The default port for this service.
244
+ */
245
+ static get port() {
246
+ return 443;
247
+ }
248
+ /**
249
+ * The scopes needed to make gRPC calls for every method defined
250
+ * in this service.
251
+ * @returns {string[]} List of default scopes.
252
+ */
253
+ static get scopes() {
254
+ return [
255
+ 'https://www.googleapis.com/auth/cloud-platform'
256
+ ];
257
+ }
258
+ /**
259
+ * Return the project ID used by this class.
260
+ * @returns {Promise} A promise that resolves to string containing the project ID.
261
+ */
262
+ getProjectId(callback) {
263
+ if (callback) {
264
+ this.auth.getProjectId(callback);
265
+ return;
266
+ }
267
+ return this.auth.getProjectId();
268
+ }
269
+ createVehicle(request, optionsOrCallback, callback) {
270
+ var _a, _b;
271
+ request = request || {};
272
+ let options;
273
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
274
+ callback = optionsOrCallback;
275
+ options = {};
276
+ }
277
+ else {
278
+ options = optionsOrCallback;
279
+ }
280
+ options = options || {};
281
+ options.otherArgs = options.otherArgs || {};
282
+ options.otherArgs.headers = options.otherArgs.headers || {};
283
+ let routingParameter = {};
284
+ {
285
+ const fieldValue = request.parent;
286
+ if (fieldValue !== undefined && fieldValue !== null) {
287
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
288
+ if (match) {
289
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
290
+ Object.assign(routingParameter, { provider_id: parameterValue });
291
+ }
292
+ }
293
+ }
294
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
295
+ this.initialize();
296
+ return this.innerApiCalls.createVehicle(request, options, callback);
297
+ }
298
+ getVehicle(request, optionsOrCallback, callback) {
299
+ var _a, _b;
300
+ request = request || {};
301
+ let options;
302
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
303
+ callback = optionsOrCallback;
304
+ options = {};
305
+ }
306
+ else {
307
+ options = optionsOrCallback;
308
+ }
309
+ options = options || {};
310
+ options.otherArgs = options.otherArgs || {};
311
+ options.otherArgs.headers = options.otherArgs.headers || {};
312
+ let routingParameter = {};
313
+ {
314
+ const fieldValue = request.name;
315
+ if (fieldValue !== undefined && fieldValue !== null) {
316
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
317
+ if (match) {
318
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
319
+ Object.assign(routingParameter, { provider_id: parameterValue });
320
+ }
321
+ }
322
+ }
323
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
324
+ this.initialize();
325
+ return this.innerApiCalls.getVehicle(request, options, callback);
326
+ }
327
+ updateVehicle(request, optionsOrCallback, callback) {
328
+ var _a, _b;
329
+ request = request || {};
330
+ let options;
331
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
332
+ callback = optionsOrCallback;
333
+ options = {};
334
+ }
335
+ else {
336
+ options = optionsOrCallback;
337
+ }
338
+ options = options || {};
339
+ options.otherArgs = options.otherArgs || {};
340
+ options.otherArgs.headers = options.otherArgs.headers || {};
341
+ let routingParameter = {};
342
+ {
343
+ const fieldValue = request.name;
344
+ if (fieldValue !== undefined && fieldValue !== null) {
345
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
346
+ if (match) {
347
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
348
+ Object.assign(routingParameter, { provider_id: parameterValue });
349
+ }
350
+ }
351
+ }
352
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
353
+ this.initialize();
354
+ return this.innerApiCalls.updateVehicle(request, options, callback);
355
+ }
356
+ updateVehicleLocation(request, optionsOrCallback, callback) {
357
+ var _a, _b;
358
+ request = request || {};
359
+ let options;
360
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
361
+ callback = optionsOrCallback;
362
+ options = {};
363
+ }
364
+ else {
365
+ options = optionsOrCallback;
366
+ }
367
+ options = options || {};
368
+ options.otherArgs = options.otherArgs || {};
369
+ options.otherArgs.headers = options.otherArgs.headers || {};
370
+ let routingParameter = {};
371
+ {
372
+ const fieldValue = request.name;
373
+ if (fieldValue !== undefined && fieldValue !== null) {
374
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
375
+ if (match) {
376
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
377
+ Object.assign(routingParameter, { provider_id: parameterValue });
378
+ }
379
+ }
380
+ }
381
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
382
+ this.initialize();
383
+ this.warn('DEP$VehicleService-$UpdateVehicleLocation', 'UpdateVehicleLocation is deprecated and may be removed in a future version.', 'DeprecationWarning');
384
+ return this.innerApiCalls.updateVehicleLocation(request, options, callback);
385
+ }
386
+ updateVehicleAttributes(request, optionsOrCallback, callback) {
387
+ var _a, _b;
388
+ request = request || {};
389
+ let options;
390
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
391
+ callback = optionsOrCallback;
392
+ options = {};
393
+ }
394
+ else {
395
+ options = optionsOrCallback;
396
+ }
397
+ options = options || {};
398
+ options.otherArgs = options.otherArgs || {};
399
+ options.otherArgs.headers = options.otherArgs.headers || {};
400
+ let routingParameter = {};
401
+ {
402
+ const fieldValue = request.name;
403
+ if (fieldValue !== undefined && fieldValue !== null) {
404
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
405
+ if (match) {
406
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
407
+ Object.assign(routingParameter, { provider_id: parameterValue });
408
+ }
409
+ }
410
+ }
411
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
412
+ this.initialize();
413
+ return this.innerApiCalls.updateVehicleAttributes(request, options, callback);
414
+ }
415
+ searchVehicles(request, optionsOrCallback, callback) {
416
+ var _a, _b;
417
+ request = request || {};
418
+ let options;
419
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
420
+ callback = optionsOrCallback;
421
+ options = {};
422
+ }
423
+ else {
424
+ options = optionsOrCallback;
425
+ }
426
+ options = options || {};
427
+ options.otherArgs = options.otherArgs || {};
428
+ options.otherArgs.headers = options.otherArgs.headers || {};
429
+ let routingParameter = {};
430
+ {
431
+ const fieldValue = request.parent;
432
+ if (fieldValue !== undefined && fieldValue !== null) {
433
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
434
+ if (match) {
435
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
436
+ Object.assign(routingParameter, { provider_id: parameterValue });
437
+ }
438
+ }
439
+ }
440
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
441
+ this.initialize();
442
+ return this.innerApiCalls.searchVehicles(request, options, callback);
443
+ }
444
+ searchFuzzedVehicles(request, optionsOrCallback, callback) {
445
+ var _a, _b;
446
+ request = request || {};
447
+ let options;
448
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
449
+ callback = optionsOrCallback;
450
+ options = {};
451
+ }
452
+ else {
453
+ options = optionsOrCallback;
454
+ }
455
+ options = options || {};
456
+ options.otherArgs = options.otherArgs || {};
457
+ options.otherArgs.headers = options.otherArgs.headers || {};
458
+ let routingParameter = {};
459
+ {
460
+ const fieldValue = request.parent;
461
+ if (fieldValue !== undefined && fieldValue !== null) {
462
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
463
+ if (match) {
464
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
465
+ Object.assign(routingParameter, { provider_id: parameterValue });
466
+ }
467
+ }
468
+ }
469
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
470
+ this.initialize();
471
+ this.warn('DEP$VehicleService-$SearchFuzzedVehicles', 'SearchFuzzedVehicles is deprecated and may be removed in a future version.', 'DeprecationWarning');
472
+ return this.innerApiCalls.searchFuzzedVehicles(request, options, callback);
473
+ }
474
+ listVehicles(request, optionsOrCallback, callback) {
475
+ var _a, _b;
476
+ request = request || {};
477
+ let options;
478
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
479
+ callback = optionsOrCallback;
480
+ options = {};
481
+ }
482
+ else {
483
+ options = optionsOrCallback;
484
+ }
485
+ options = options || {};
486
+ options.otherArgs = options.otherArgs || {};
487
+ options.otherArgs.headers = options.otherArgs.headers || {};
488
+ let routingParameter = {};
489
+ {
490
+ const fieldValue = request.parent;
491
+ if (fieldValue !== undefined && fieldValue !== null) {
492
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
493
+ if (match) {
494
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
495
+ Object.assign(routingParameter, { provider_id: parameterValue });
496
+ }
497
+ }
498
+ }
499
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
500
+ this.initialize();
501
+ return this.innerApiCalls.listVehicles(request, options, callback);
502
+ }
503
+ /**
504
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
505
+ * @param {Object} request
506
+ * The request object that will be sent.
507
+ * @param {maps.fleetengine.v1.RequestHeader} request.header
508
+ * The standard Fleet Engine request header.
509
+ * @param {string} request.parent
510
+ * Required. Must be in the format `providers/{provider}`.
511
+ * The provider must be the Project ID (for example, `sample-cloud-project`)
512
+ * of the Google Cloud Project of which the service account making
513
+ * this call is a member.
514
+ * @param {number} request.pageSize
515
+ * The maximum number of vehicles to return.
516
+ * Default value: 100.
517
+ * @param {string} request.pageToken
518
+ * The value of the `next_page_token` provided by a previous call to
519
+ * `ListVehicles` so that you can paginate through groups of vehicles. The
520
+ * value is undefined if the filter criteria of the request is not the same as
521
+ * the filter criteria for the previous call to `ListVehicles`.
522
+ * @param {google.protobuf.Int32Value} request.minimumCapacity
523
+ * Specifies the required minimum capacity of the vehicle. All vehicles
524
+ * returned will have a `maximum_capacity` greater than or equal to this
525
+ * value. If set, must be greater or equal to 0.
526
+ * @param {number[]} request.tripTypes
527
+ * Restricts the response to vehicles that support at least one of the
528
+ * specified trip types.
529
+ * @param {google.protobuf.Duration} request.maximumStaleness
530
+ * Restricts the response to vehicles that have sent location updates to Fleet
531
+ * Engine within the specified duration. Stationary vehicles still
532
+ * transmitting their locations are not considered stale. If present, must be
533
+ * a valid positive duration.
534
+ * @param {number[]} request.vehicleTypeCategories
535
+ * Required. Restricts the response to vehicles with one of the specified type
536
+ * categories. `UNKNOWN` is not allowed.
537
+ * @param {string[]} request.requiredAttributes
538
+ * Callers can form complex logical operations using any combination of the
539
+ * `required_attributes`, `required_one_of_attributes`, and
540
+ * `required_one_of_attribute_sets` fields.
541
+ *
542
+ * `required_attributes` is a list; `required_one_of_attributes` uses a
543
+ * message which allows a list of lists. In combination, the two fields allow
544
+ * the composition of this expression:
545
+ *
546
+ * ```
547
+ * (required_attributes[0] AND required_attributes[1] AND ...)
548
+ * AND
549
+ * (required_one_of_attributes{@link protos.0|0} OR required_one_of_attributes{@link protos.1|0} OR
550
+ * ...)
551
+ * AND
552
+ * (required_one_of_attributes{@link protos.0|1} OR required_one_of_attributes{@link protos.1|1} OR
553
+ * ...)
554
+ * ```
555
+ *
556
+ * Restricts the response to vehicles with the specified attributes. This
557
+ * field is a conjunction/AND operation. A max of 50 required_attributes is
558
+ * allowed. This matches the maximum number of attributes allowed on a
559
+ * vehicle. Each repeated string should be of the format "key:value".
560
+ * @param {string[]} request.requiredOneOfAttributes
561
+ * Restricts the response to vehicles with at least one of the specified
562
+ * attributes in each `VehicleAttributeList`. Within each list, a vehicle must
563
+ * match at least one of the attributes. This field is an inclusive
564
+ * disjunction/OR operation in each `VehicleAttributeList` and a
565
+ * conjunction/AND operation across the collection of `VehicleAttributeList`.
566
+ * Each repeated string should be of the format
567
+ * "key1:value1|key2:value2|key3:value3".
568
+ * @param {string[]} request.requiredOneOfAttributeSets
569
+ * `required_one_of_attribute_sets` provides additional functionality.
570
+ *
571
+ * Similar to `required_one_of_attributes`, `required_one_of_attribute_sets`
572
+ * uses a message which allows a list of lists, allowing expressions such as
573
+ * this one:
574
+ *
575
+ * ```
576
+ * (required_attributes[0] AND required_attributes[1] AND ...)
577
+ * AND
578
+ * (
579
+ * (required_one_of_attribute_sets{@link protos.0|0} AND
580
+ * required_one_of_attribute_sets{@link protos.1|0} AND
581
+ * ...)
582
+ * OR
583
+ * (required_one_of_attribute_sets{@link protos.0|1} AND
584
+ * required_one_of_attribute_sets{@link protos.1|1} AND
585
+ * ...)
586
+ * )
587
+ * ```
588
+ *
589
+ * Restricts the response to vehicles that match all the attributes in a
590
+ * `VehicleAttributeList`. Within each list, a vehicle must match all of the
591
+ * attributes. This field is a conjunction/AND operation in each
592
+ * `VehicleAttributeList` and inclusive disjunction/OR operation across the
593
+ * collection of `VehicleAttributeList`. Each repeated string should be of the
594
+ * format "key1:value1|key2:value2|key3:value3".
595
+ * @param {maps.fleetengine.v1.VehicleState} request.vehicleState
596
+ * Restricts the response to vehicles that have this vehicle state.
597
+ * @param {boolean} request.onTripOnly
598
+ * Only return the vehicles with current trip(s).
599
+ * @param {string} [request.filter]
600
+ * Optional. A filter query to apply when listing vehicles. See
601
+ * http://aip.dev/160 for examples of the filter syntax.
602
+ *
603
+ * This field is designed to replace the `required_attributes`,
604
+ * `required_one_of_attributes`, and `required_one_of_attributes_sets` fields.
605
+ * If a non-empty value is specified here, the following fields must be empty:
606
+ * `required_attributes`, `required_one_of_attributes`, and
607
+ * `required_one_of_attributes_sets`.
608
+ *
609
+ * This filter functions as an AND clause with other constraints,
610
+ * such as `vehicle_state` or `on_trip_only`.
611
+ *
612
+ * Note that the only queries supported are on vehicle attributes (for
613
+ * example, `attributes.<key> = <value>` or `attributes.<key1> = <value1> AND
614
+ * attributes.<key2> = <value2>`). The maximum number of restrictions allowed
615
+ * in a filter query is 50.
616
+ *
617
+ * Also, all attributes are stored as strings, so the only supported
618
+ * comparisons against attributes are string comparisons. In order to compare
619
+ * against number or boolean values, the values must be explicitly quoted to
620
+ * be treated as strings (for example, `attributes.<key> = "10"` or
621
+ * `attributes.<key> = "true"`).
622
+ * @param {google.geo.type.Viewport} [request.viewport]
623
+ * Optional. A filter that limits the vehicles returned to those whose last
624
+ * known location was in the rectangular area defined by the viewport.
625
+ * @param {object} [options]
626
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
627
+ * @returns {Stream}
628
+ * An object stream which emits an object representing {@link protos.maps.fleetengine.v1.Vehicle|Vehicle} on 'data' event.
629
+ * The client library will perform auto-pagination by default: it will call the API as many
630
+ * times as needed. Note that it can affect your quota.
631
+ * We recommend using `listVehiclesAsync()`
632
+ * method described below for async iteration which you can stop as needed.
633
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
634
+ * for more details and examples.
635
+ */
636
+ listVehiclesStream(request, options) {
637
+ var _a, _b;
638
+ request = request || {};
639
+ options = options || {};
640
+ options.otherArgs = options.otherArgs || {};
641
+ options.otherArgs.headers = options.otherArgs.headers || {};
642
+ let routingParameter = {};
643
+ {
644
+ const fieldValue = request.parent;
645
+ if (fieldValue !== undefined && fieldValue !== null) {
646
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
647
+ if (match) {
648
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
649
+ Object.assign(routingParameter, { provider_id: parameterValue });
650
+ }
651
+ }
652
+ }
653
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
654
+ const defaultCallSettings = this._defaults['listVehicles'];
655
+ const callSettings = defaultCallSettings.merge(options);
656
+ this.initialize();
657
+ return this.descriptors.page.listVehicles.createStream(this.innerApiCalls.listVehicles, request, callSettings);
658
+ }
659
+ /**
660
+ * Equivalent to `listVehicles`, but returns an iterable object.
661
+ *
662
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
663
+ * @param {Object} request
664
+ * The request object that will be sent.
665
+ * @param {maps.fleetengine.v1.RequestHeader} request.header
666
+ * The standard Fleet Engine request header.
667
+ * @param {string} request.parent
668
+ * Required. Must be in the format `providers/{provider}`.
669
+ * The provider must be the Project ID (for example, `sample-cloud-project`)
670
+ * of the Google Cloud Project of which the service account making
671
+ * this call is a member.
672
+ * @param {number} request.pageSize
673
+ * The maximum number of vehicles to return.
674
+ * Default value: 100.
675
+ * @param {string} request.pageToken
676
+ * The value of the `next_page_token` provided by a previous call to
677
+ * `ListVehicles` so that you can paginate through groups of vehicles. The
678
+ * value is undefined if the filter criteria of the request is not the same as
679
+ * the filter criteria for the previous call to `ListVehicles`.
680
+ * @param {google.protobuf.Int32Value} request.minimumCapacity
681
+ * Specifies the required minimum capacity of the vehicle. All vehicles
682
+ * returned will have a `maximum_capacity` greater than or equal to this
683
+ * value. If set, must be greater or equal to 0.
684
+ * @param {number[]} request.tripTypes
685
+ * Restricts the response to vehicles that support at least one of the
686
+ * specified trip types.
687
+ * @param {google.protobuf.Duration} request.maximumStaleness
688
+ * Restricts the response to vehicles that have sent location updates to Fleet
689
+ * Engine within the specified duration. Stationary vehicles still
690
+ * transmitting their locations are not considered stale. If present, must be
691
+ * a valid positive duration.
692
+ * @param {number[]} request.vehicleTypeCategories
693
+ * Required. Restricts the response to vehicles with one of the specified type
694
+ * categories. `UNKNOWN` is not allowed.
695
+ * @param {string[]} request.requiredAttributes
696
+ * Callers can form complex logical operations using any combination of the
697
+ * `required_attributes`, `required_one_of_attributes`, and
698
+ * `required_one_of_attribute_sets` fields.
699
+ *
700
+ * `required_attributes` is a list; `required_one_of_attributes` uses a
701
+ * message which allows a list of lists. In combination, the two fields allow
702
+ * the composition of this expression:
703
+ *
704
+ * ```
705
+ * (required_attributes[0] AND required_attributes[1] AND ...)
706
+ * AND
707
+ * (required_one_of_attributes{@link protos.0|0} OR required_one_of_attributes{@link protos.1|0} OR
708
+ * ...)
709
+ * AND
710
+ * (required_one_of_attributes{@link protos.0|1} OR required_one_of_attributes{@link protos.1|1} OR
711
+ * ...)
712
+ * ```
713
+ *
714
+ * Restricts the response to vehicles with the specified attributes. This
715
+ * field is a conjunction/AND operation. A max of 50 required_attributes is
716
+ * allowed. This matches the maximum number of attributes allowed on a
717
+ * vehicle. Each repeated string should be of the format "key:value".
718
+ * @param {string[]} request.requiredOneOfAttributes
719
+ * Restricts the response to vehicles with at least one of the specified
720
+ * attributes in each `VehicleAttributeList`. Within each list, a vehicle must
721
+ * match at least one of the attributes. This field is an inclusive
722
+ * disjunction/OR operation in each `VehicleAttributeList` and a
723
+ * conjunction/AND operation across the collection of `VehicleAttributeList`.
724
+ * Each repeated string should be of the format
725
+ * "key1:value1|key2:value2|key3:value3".
726
+ * @param {string[]} request.requiredOneOfAttributeSets
727
+ * `required_one_of_attribute_sets` provides additional functionality.
728
+ *
729
+ * Similar to `required_one_of_attributes`, `required_one_of_attribute_sets`
730
+ * uses a message which allows a list of lists, allowing expressions such as
731
+ * this one:
732
+ *
733
+ * ```
734
+ * (required_attributes[0] AND required_attributes[1] AND ...)
735
+ * AND
736
+ * (
737
+ * (required_one_of_attribute_sets{@link protos.0|0} AND
738
+ * required_one_of_attribute_sets{@link protos.1|0} AND
739
+ * ...)
740
+ * OR
741
+ * (required_one_of_attribute_sets{@link protos.0|1} AND
742
+ * required_one_of_attribute_sets{@link protos.1|1} AND
743
+ * ...)
744
+ * )
745
+ * ```
746
+ *
747
+ * Restricts the response to vehicles that match all the attributes in a
748
+ * `VehicleAttributeList`. Within each list, a vehicle must match all of the
749
+ * attributes. This field is a conjunction/AND operation in each
750
+ * `VehicleAttributeList` and inclusive disjunction/OR operation across the
751
+ * collection of `VehicleAttributeList`. Each repeated string should be of the
752
+ * format "key1:value1|key2:value2|key3:value3".
753
+ * @param {maps.fleetengine.v1.VehicleState} request.vehicleState
754
+ * Restricts the response to vehicles that have this vehicle state.
755
+ * @param {boolean} request.onTripOnly
756
+ * Only return the vehicles with current trip(s).
757
+ * @param {string} [request.filter]
758
+ * Optional. A filter query to apply when listing vehicles. See
759
+ * http://aip.dev/160 for examples of the filter syntax.
760
+ *
761
+ * This field is designed to replace the `required_attributes`,
762
+ * `required_one_of_attributes`, and `required_one_of_attributes_sets` fields.
763
+ * If a non-empty value is specified here, the following fields must be empty:
764
+ * `required_attributes`, `required_one_of_attributes`, and
765
+ * `required_one_of_attributes_sets`.
766
+ *
767
+ * This filter functions as an AND clause with other constraints,
768
+ * such as `vehicle_state` or `on_trip_only`.
769
+ *
770
+ * Note that the only queries supported are on vehicle attributes (for
771
+ * example, `attributes.<key> = <value>` or `attributes.<key1> = <value1> AND
772
+ * attributes.<key2> = <value2>`). The maximum number of restrictions allowed
773
+ * in a filter query is 50.
774
+ *
775
+ * Also, all attributes are stored as strings, so the only supported
776
+ * comparisons against attributes are string comparisons. In order to compare
777
+ * against number or boolean values, the values must be explicitly quoted to
778
+ * be treated as strings (for example, `attributes.<key> = "10"` or
779
+ * `attributes.<key> = "true"`).
780
+ * @param {google.geo.type.Viewport} [request.viewport]
781
+ * Optional. A filter that limits the vehicles returned to those whose last
782
+ * known location was in the rectangular area defined by the viewport.
783
+ * @param {object} [options]
784
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
785
+ * @returns {Object}
786
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
787
+ * When you iterate the returned iterable, each element will be an object representing
788
+ * {@link protos.maps.fleetengine.v1.Vehicle|Vehicle}. The API will be called under the hood as needed, once per the page,
789
+ * so you can stop the iteration when you don't need more results.
790
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
791
+ * for more details and examples.
792
+ * @example <caption>include:samples/generated/v1/vehicle_service.list_vehicles.js</caption>
793
+ * region_tag:fleetengine_v1_generated_VehicleService_ListVehicles_async
794
+ */
795
+ listVehiclesAsync(request, options) {
796
+ var _a, _b;
797
+ request = request || {};
798
+ options = options || {};
799
+ options.otherArgs = options.otherArgs || {};
800
+ options.otherArgs.headers = options.otherArgs.headers || {};
801
+ let routingParameter = {};
802
+ {
803
+ const fieldValue = request.parent;
804
+ if (fieldValue !== undefined && fieldValue !== null) {
805
+ const match = fieldValue.toString().match(RegExp('(?<provider_id>providers/[^/]+)'));
806
+ if (match) {
807
+ const parameterValue = (_b = (_a = match.groups) === null || _a === void 0 ? void 0 : _a['provider_id']) !== null && _b !== void 0 ? _b : fieldValue;
808
+ Object.assign(routingParameter, { provider_id: parameterValue });
809
+ }
810
+ }
811
+ }
812
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
813
+ const defaultCallSettings = this._defaults['listVehicles'];
814
+ const callSettings = defaultCallSettings.merge(options);
815
+ this.initialize();
816
+ return this.descriptors.page.listVehicles.asyncIterate(this.innerApiCalls['listVehicles'], request, callSettings);
817
+ }
818
+ // --------------------
819
+ // -- Path templates --
820
+ // --------------------
821
+ /**
822
+ * Return a fully-qualified trip resource name string.
823
+ *
824
+ * @param {string} provider
825
+ * @param {string} trip
826
+ * @returns {string} Resource name string.
827
+ */
828
+ tripPath(provider, trip) {
829
+ return this.pathTemplates.tripPathTemplate.render({
830
+ provider: provider,
831
+ trip: trip,
832
+ });
833
+ }
834
+ /**
835
+ * Parse the provider from Trip resource.
836
+ *
837
+ * @param {string} tripName
838
+ * A fully-qualified path representing Trip resource.
839
+ * @returns {string} A string representing the provider.
840
+ */
841
+ matchProviderFromTripName(tripName) {
842
+ return this.pathTemplates.tripPathTemplate.match(tripName).provider;
843
+ }
844
+ /**
845
+ * Parse the trip from Trip resource.
846
+ *
847
+ * @param {string} tripName
848
+ * A fully-qualified path representing Trip resource.
849
+ * @returns {string} A string representing the trip.
850
+ */
851
+ matchTripFromTripName(tripName) {
852
+ return this.pathTemplates.tripPathTemplate.match(tripName).trip;
853
+ }
854
+ /**
855
+ * Return a fully-qualified vehicle resource name string.
856
+ *
857
+ * @param {string} provider
858
+ * @param {string} vehicle
859
+ * @returns {string} Resource name string.
860
+ */
861
+ vehiclePath(provider, vehicle) {
862
+ return this.pathTemplates.vehiclePathTemplate.render({
863
+ provider: provider,
864
+ vehicle: vehicle,
865
+ });
866
+ }
867
+ /**
868
+ * Parse the provider from Vehicle resource.
869
+ *
870
+ * @param {string} vehicleName
871
+ * A fully-qualified path representing Vehicle resource.
872
+ * @returns {string} A string representing the provider.
873
+ */
874
+ matchProviderFromVehicleName(vehicleName) {
875
+ return this.pathTemplates.vehiclePathTemplate.match(vehicleName).provider;
876
+ }
877
+ /**
878
+ * Parse the vehicle from Vehicle resource.
879
+ *
880
+ * @param {string} vehicleName
881
+ * A fully-qualified path representing Vehicle resource.
882
+ * @returns {string} A string representing the vehicle.
883
+ */
884
+ matchVehicleFromVehicleName(vehicleName) {
885
+ return this.pathTemplates.vehiclePathTemplate.match(vehicleName).vehicle;
886
+ }
887
+ /**
888
+ * Terminate the gRPC channel and close the client.
889
+ *
890
+ * The client will no longer be usable and all future behavior is undefined.
891
+ * @returns {Promise} A promise that resolves when the client is closed.
892
+ */
893
+ close() {
894
+ if (this.vehicleServiceStub && !this._terminated) {
895
+ return this.vehicleServiceStub.then(stub => {
896
+ this._terminated = true;
897
+ stub.close();
898
+ });
899
+ }
900
+ return Promise.resolve();
901
+ }
902
+ }
903
+ exports.VehicleServiceClient = VehicleServiceClient;
904
+ //# sourceMappingURL=vehicle_service_client.js.map