Class v1.FleetRoutingClient (2.2.2)

A service for optimizing vehicle tours.

Validity of certain types of fields:

* google.protobuf.Timestamp * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. * seconds must be in [0, 253402300799], i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. * nanos must be unset or set to 0. * google.protobuf.Duration * seconds must be in [0, 253402300799], i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. * nanos must be unset or set to 0. * google.type.LatLng * latitude must be in [-90.0, 90.0]. * longitude must be in [-180.0, 180.0]. * at least one of latitude and longitude must be non-zero. v1

Package

@google-cloud/optimization

Constructors

(constructor)(opts, gaxInstance)

  constructor 
 ( 
 opts 
 ?: 
  
 ClientOptions 
 , 
  
 gaxInstance 
 ?: 
  
 typeof 
  
 gax 
  
 | 
  
 typeof 
  
 gax 
 . 
 fallback 
 ); 
 

Construct an instance of FleetRoutingClient.

Parameters
Name
Description
opts
ClientOptions
gaxInstance
typeof gax | typeof gax.fallback

: loaded instance of google-gax . Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new FleetRoutingClient({fallback: 'rest'}, gax); ```

Properties

apiEndpoint

  static 
  
 get 
  
 apiEndpoint 
 () 
 : 
  
 string 
 ; 
 

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

  auth 
 : 
  
 gax 
 . 
 GoogleAuth 
 ; 
 

descriptors

  descriptors 
 : 
  
 Descriptors 
 ; 
 

fleetRoutingStub

  fleetRoutingStub 
 ?: 
  
 Promise 
< { 
  
 [ 
 name 
 : 
  
 string 
 ] 
 : 
  
 Function 
 ; 
  
 }>; 
 

innerApiCalls

  innerApiCalls 
 : 
  
 { 
  
 [ 
 name 
 : 
  
 string 
 ] 
 : 
  
 Function 
 ; 
  
 }; 
 

operationsClient

  operationsClient 
 : 
  
 gax 
 . 
 OperationsClient 
 ; 
 

port

  static 
  
 get 
  
 port 
 () 
 : 
  
 number 
 ; 
 

The port for this API service.

scopes

  static 
  
 get 
  
 scopes 
 () 
 : 
  
 string 
 []; 
 

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

  static 
  
 get 
  
 servicePath 
 () 
 : 
  
 string 
 ; 
 

The DNS address for this API service.

warn

  warn 
 : 
  
 ( 
 code 
 : 
  
 string 
 , 
  
 message 
 : 
  
 string 
 , 
  
 warnType 
 ?: 
  
 string 
 ) 
  
 = 
>  
 void 
 ; 
 

Methods

batchOptimizeTours(request, options)

  batchOptimizeTours 
 ( 
 request 
 ?: 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursRequest 
 , 
  
 options 
 ?: 
  
 CallOptions 
 ) 
 : 
  
 Promise 
< [ 
  
 LROperation<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IAsyncModelMetadata 
> , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 IOperation 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 undefined 
  
 ]>; 
 

Optimizes vehicle tours for one or more OptimizeToursRequest messages as a batch.

This method is a Long Running Operation (LRO). The inputs for optimization ( OptimizeToursRequest messages) and outputs ( OptimizeToursResponse messages) are read/written from/to Cloud Storage in user-specified format. Like the OptimizeTours method, each OptimizeToursRequest contains a ShipmentModel and returns an OptimizeToursResponse containing ShipmentRoute s, which are a set of routes to be performed by vehicles minimizing the overall cost.

Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IBatchOptimizeToursRequest

The request object that will be sent.

options
CallOptions

Call options. See CallOptions for more details.

Returns
Type
Description
Promise <[ LROperation <protos. google.cloud.optimization.v1.IBatchOptimizeToursResponse , protos. google.cloud.optimization.v1.IAsyncModelMetadata >, protos. google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples.

Example
   
 /** 
 * TODO(developer): Uncomment these variables before running the sample. 
 */ 
  
 /** 
 *  Required. Target project and location to make a call. 
 *  Format: `projects/{project-id}/locations/{location-id}`. 
 *  If no location is specified, a region will be chosen automatically. 
 */ 
  
 // const parent = 'abc123' 
  
 /** 
 *  Required. Input/Output information each purchase model, such as file paths and data 
 *  formats. 
 */ 
  
 // const modelConfigs = 1234 
  
 // Imports the Optimization library 
  
 const 
  
 { 
 FleetRoutingClient 
 } 
  
 = 
  
 require 
 ( 
 ' @google-cloud/optimization 
' 
 ). 
 v1 
 ; 
  
 // Instantiates a client 
  
 const 
  
 optimizationClient 
  
 = 
  
 new 
  
  FleetRoutingClient 
 
 (); 
  
 async 
  
 function 
  
 callBatchOptimizeTours 
 () 
  
 { 
  
 // Construct request 
  
 const 
  
 request 
  
 = 
  
 { 
  
 parent 
 , 
  
 timeout 
 : 
  
 { 
  
 seconds 
 : 
  
 '1000' 
 , 
  
 }, 
  
 model 
 : 
  
 { 
  
 shipments 
 : 
  
 [ 
  
 { 
  
 deliveries 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 loadDemands 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 amount 
 , 
  
 }, 
  
 }, 
  
 pickups 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 }, 
  
 { 
  
 deliveries 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 loadDemands 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 amount 
 , 
  
 }, 
  
 }, 
  
 pickups 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 vehicles 
 : 
  
 [ 
  
 { 
  
 loadLimits 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 maxLoad 
 , 
  
 }, 
  
 }, 
  
 endLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 startLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 }, 
  
 { 
  
 loadLimits 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 maxLoad 
 , 
  
 }, 
  
 }, 
  
 endLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 startLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 }, 
  
 ], 
  
 }, 
  
 }; 
  
 // Run request 
  
 const 
  
 [ 
 operation 
 ] 
  
 = 
  
 await 
  
 optimizationClient 
 . 
 optimizeTours 
 ( 
 request 
 ); 
  
 console 
 . 
 log 
 ( 
 operation 
 ); 
  
 } 
  
 callBatchOptimizeTours 
 (); 
 

batchOptimizeTours(request, options, callback)

  batchOptimizeTours 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursRequest 
 , 
  
 options 
 : 
  
 CallOptions 
 , 
  
 callback 
 : 
  
 Callback<LROperation<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IAsyncModelMetadata 
> , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 IOperation 
  
 | 
  
 null 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 void 
 ; 
 
Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IBatchOptimizeToursRequest
options
CallOptions
callback
Callback < LROperation <protos. google.cloud.optimization.v1.IBatchOptimizeToursResponse , protos. google.cloud.optimization.v1.IAsyncModelMetadata >, protos. google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type
Description
void

batchOptimizeTours(request, callback)

  batchOptimizeTours 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursRequest 
 , 
  
 callback 
 : 
  
 Callback<LROperation<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IBatchOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IAsyncModelMetadata 
> , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 IOperation 
  
 | 
  
 null 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 void 
 ; 
 
Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IBatchOptimizeToursRequest
callback
Callback < LROperation <protos. google.cloud.optimization.v1.IBatchOptimizeToursResponse , protos. google.cloud.optimization.v1.IAsyncModelMetadata >, protos. google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type
Description
void

cancelOperation(request, options, callback)

  cancelOperation 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 CancelOperationRequest 
 , 
  
 options 
 ?: 
  
 gax 
 . 
 CallOptions 
  
 | 
  
 Callback<protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
 , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 CancelOperationRequest 
 , 
  
 {} 
  
 | 
  
 undefined 
  
 | 
  
 null 
> , 
  
 callback 
 ?: 
  
 Callback<protos 
 . 
 google 
 . 
 longrunning 
 . 
 CancelOperationRequest 
 , 
  
 protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
 , 
  
 {} 
  
 | 
  
 undefined 
  
 | 
  
 null 
> ) 
 : 
  
 Promise<protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
> ; 
 

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED . Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED .

Parameters
Name
Description
request
protos. google.longrunning.CancelOperationRequest

The request object that will be sent.

options
gax. CallOptions | Callback <protos. google.protobuf.Empty , protos. google.longrunning.CancelOperationRequest , {} | undefined | null>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback
Callback <protos. google.longrunning.CancelOperationRequest , protos. google.protobuf.Empty , {} | undefined | null>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
Type
Description
Promise <protos. google.protobuf.Empty >
Example
  const 
  
 client 
  
 = 
  
 longrunning 
 . 
 operationsClient 
 (); 
 await 
  
 client 
 . 
 cancelOperation 
 ({ 
 name 
 : 
  
 '' 
 }); 
 

checkBatchOptimizeToursProgress(name)

  checkBatchOptimizeToursProgress 
 ( 
 name 
 : 
  
 string 
 ) 
 : 
  
 Promise<LROperation<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 BatchOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 AsyncModelMetadata 
>> ; 
 

Check the status of the long running operation returned by batchOptimizeTours() .

Parameter
Name
Description
name
string

The operation name that will be passed.

Returns
Type
Description
Promise < LROperation <protos. google.cloud.optimization.v1.BatchOptimizeToursResponse , protos. google.cloud.optimization.v1.AsyncModelMetadata >>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples.

Example
   
 /** 
 * TODO(developer): Uncomment these variables before running the sample. 
 */ 
  
 /** 
 *  Required. Target project and location to make a call. 
 *  Format: `projects/{project-id}/locations/{location-id}`. 
 *  If no location is specified, a region will be chosen automatically. 
 */ 
  
 // const parent = 'abc123' 
  
 /** 
 *  Required. Input/Output information each purchase model, such as file paths and data 
 *  formats. 
 */ 
  
 // const modelConfigs = 1234 
  
 // Imports the Optimization library 
  
 const 
  
 { 
 FleetRoutingClient 
 } 
  
 = 
  
 require 
 ( 
 ' @google-cloud/optimization 
' 
 ). 
 v1 
 ; 
  
 // Instantiates a client 
  
 const 
  
 optimizationClient 
  
 = 
  
 new 
  
  FleetRoutingClient 
 
 (); 
  
 async 
  
 function 
  
 callBatchOptimizeTours 
 () 
  
 { 
  
 // Construct request 
  
 const 
  
 request 
  
 = 
  
 { 
  
 parent 
 , 
  
 timeout 
 : 
  
 { 
  
 seconds 
 : 
  
 '1000' 
 , 
  
 }, 
  
 model 
 : 
  
 { 
  
 shipments 
 : 
  
 [ 
  
 { 
  
 deliveries 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 loadDemands 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 amount 
 , 
  
 }, 
  
 }, 
  
 pickups 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 }, 
  
 { 
  
 deliveries 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 loadDemands 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 amount 
 , 
  
 }, 
  
 }, 
  
 pickups 
 : 
  
 [ 
  
 { 
  
 arrivalLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 duration 
 : 
  
 { 
  
 seconds 
 : 
  
 duration 
 , 
  
 }, 
  
 timeWindows 
 : 
  
 [ 
  
 { 
  
 endTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 startTime 
 : 
  
 new 
  
 Date 
 ( 
 date 
 ), 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 }, 
  
 ], 
  
 vehicles 
 : 
  
 [ 
  
 { 
  
 loadLimits 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 maxLoad 
 , 
  
 }, 
  
 }, 
  
 endLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 startLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 }, 
  
 { 
  
 loadLimits 
 : 
  
 { 
  
 weight 
 : 
  
 { 
  
 maxLoad 
 , 
  
 }, 
  
 }, 
  
 endLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 startLocation 
 : 
  
 { 
  
 latitude 
 , 
  
 longitude 
 , 
  
 }, 
  
 }, 
  
 ], 
  
 }, 
  
 }; 
  
 // Run request 
  
 const 
  
 [ 
 operation 
 ] 
  
 = 
  
 await 
  
 optimizationClient 
 . 
 optimizeTours 
 ( 
 request 
 ); 
  
 console 
 . 
 log 
 ( 
 operation 
 ); 
  
 } 
  
 callBatchOptimizeTours 
 (); 
 

close()

  close 
 () 
 : 
  
 Promise<void> 
 ; 
 

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
Type
Description
Promise <void>

{Promise} A promise that resolves when the client is closed.

deleteOperation(request, options, callback)

  deleteOperation 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 DeleteOperationRequest 
 , 
  
 options 
 ?: 
  
 gax 
 . 
 CallOptions 
  
 | 
  
 Callback<protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
 , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 DeleteOperationRequest 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> , 
  
 callback 
 ?: 
  
 Callback<protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
 , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 DeleteOperationRequest 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 Promise<protos 
 . 
 google 
 . 
 protobuf 
 . 
 Empty 
> ; 
 

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED .

Parameters
Name
Description
request
protos. google.longrunning.DeleteOperationRequest

The request object that will be sent.

options
gax. CallOptions | Callback <protos. google.protobuf.Empty , protos. google.longrunning.DeleteOperationRequest , {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback
Callback <protos. google.protobuf.Empty , protos. google.longrunning.DeleteOperationRequest , {} | null | undefined>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
Type
Description
Promise <protos. google.protobuf.Empty >
Example
  const 
  
 client 
  
 = 
  
 longrunning 
 . 
 operationsClient 
 (); 
 await 
  
 client 
 . 
 deleteOperation 
 ({ 
 name 
 : 
  
 '' 
 }); 
 

getOperation(request, options, callback)

  getOperation 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 GetOperationRequest 
 , 
  
 options 
 ?: 
  
 gax 
 . 
 CallOptions 
  
 | 
  
 Callback<protos 
 . 
 google 
 . 
 longrunning 
 . 
 Operation 
 , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 GetOperationRequest 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> , 
  
 callback 
 ?: 
  
 Callback<protos 
 . 
 google 
 . 
 longrunning 
 . 
 Operation 
 , 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 GetOperationRequest 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 Promise 
< [ 
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 Operation 
 ]>; 
 

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
Name
Description
request
protos. google.longrunning.GetOperationRequest

The request object that will be sent.

options
gax. CallOptions | Callback <protos. google.longrunning.Operation , protos. google.longrunning.GetOperationRequest , {} | null | undefined>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback
Callback <protos. google.longrunning.Operation , protos. google.longrunning.GetOperationRequest , {} | null | undefined>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call.

Returns
Type
Description
Promise <[protos. google.longrunning.Operation ]>
Example
  const 
  
 client 
  
 = 
  
 longrunning 
 . 
 operationsClient 
 (); 
 const 
  
 name 
  
 = 
  
 '' 
 ; 
 const 
  
 [ 
 response 
 ] 
  
 = 
  
 await 
  
 client 
 . 
 getOperation 
 ({ 
 name 
 }); 
 // doThingsWith(response) 
 

getProjectId()

  getProjectId 
 () 
 : 
  
 Promise<string> 
 ; 
 
Returns
Type
Description
Promise <string>

getProjectId(callback)

  getProjectId 
 ( 
 callback 
 : 
  
 Callback<string 
 , 
  
 undefined 
 , 
  
 undefined 
> ) 
 : 
  
 void 
 ; 
 
Parameter
Name
Description
callback
Callback <string, undefined, undefined>
Returns
Type
Description
void

initialize()

  initialize 
 () 
 : 
  
 Promise 
< { 
  
 [ 
 name 
 : 
  
 string 
 ] 
 : 
  
 Function 
 ; 
  
 }>; 
 

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
Type
Description
Promise <{ [name: string]: Function ; }>

{Promise} A promise that resolves to an authenticated service stub.

listOperationsAsync(request, options)

  listOperationsAsync 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 longrunning 
 . 
 ListOperationsRequest 
 , 
  
 options 
 ?: 
  
 gax 
 . 
 CallOptions 
 ) 
 : 
  
 AsyncIterable<protos 
 . 
 google 
 . 
 longrunning 
 . 
 ListOperationsResponse 
> ; 
 

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED . Returns an iterable object.

For-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters
Name
Description
request
protos. google.longrunning.ListOperationsRequest

The request object that will be sent.

options
gax. CallOptions

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns
Type
Description
AsyncIterable <protos. google.longrunning.ListOperationsResponse >

{Object} An iterable Object that conforms to iteration protocols .

Example
  const 
  
 client 
  
 = 
  
 longrunning 
 . 
 operationsClient 
 (); 
 for 
  
 await 
  
 ( 
 const 
  
 response 
  
 of 
  
 client 
 . 
 listOperationsAsync 
 ( 
 request 
 )); 
 // doThingsWith(response) 
 

optimizeTours(request, options)

  optimizeTours 
 ( 
 request 
 ?: 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
 , 
  
 options 
 ?: 
  
 CallOptions 
 ) 
 : 
  
 Promise 
< [ 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 undefined 
  
 ]>; 
 

Sends an OptimizeToursRequest containing a ShipmentModel and returns an OptimizeToursResponse containing ShipmentRoute s, which are a set of routes to be performed by vehicles minimizing the overall cost.

A ShipmentModel model consists mainly of Shipment s that need to be carried out and Vehicle s that can be used to transport the Shipment s. The ShipmentRoute s assign Shipment s to Vehicle s. More specifically, they assign a series of Visit s to each vehicle, where a Visit corresponds to a VisitRequest , which is a pickup or delivery for a Shipment .

The goal is to provide an assignment of ShipmentRoute s to Vehicle s that minimizes the total cost where cost has many components defined in the ShipmentModel .

Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IOptimizeToursRequest

The request object that will be sent.

options
CallOptions

Call options. See CallOptions for more details.

Returns
Type
Description
Promise <[ protos. google.cloud.optimization.v1.IOptimizeToursResponse , protos. google.cloud.optimization.v1.IOptimizeToursRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example
   
 /** 
 * This snippet has been automatically generated and should be regarded as a code template only. 
 * It will require modifications to work. 
 * It may require correct/in-range values for request initialization. 
 * TODO(developer): Uncomment these variables before running the sample. 
 */ 
  
 /** 
 *  Required. Target project and location to make a call. 
 *  Format: `projects/{project-id}/locations/{location-id}`. 
 *  If no location is specified, a region will be chosen automatically. 
 */ 
  
 // const parent = 'abc123' 
  
 /** 
 *  If this timeout is set, the server returns a response before the timeout 
 *  period has elapsed or the server deadline for synchronous requests is 
 *  reached, whichever is sooner. 
 *  For asynchronous requests, the server will generate a solution (if 
 *  possible) before the timeout has elapsed. 
 */ 
  
 // const timeout = {} 
  
 /** 
 *  Shipment model to solve. 
 */ 
  
 // const model = {} 
  
 /** 
 *  By default, the solving mode is `DEFAULT_SOLVE` (0). 
 */ 
  
 // const solvingMode = {} 
  
 /** 
 *  Truncates the number of validation errors returned. These errors are 
 *  typically attached to an INVALID_ARGUMENT error payload as a BadRequest 
 *  error detail (https://cloud.google.com/apis/design/errors#error_details), 
 *  unless solving_mode=VALIDATE_ONLY: see the 
 *  OptimizeToursResponse.validation_errors google.cloud.optimization.v1.OptimizeToursResponse.validation_errors 
 *  field. 
 *  This defaults to 100 and is capped at 10,000. 
 */ 
  
 // const maxValidationErrors = 1234 
  
 /** 
 *  Search mode used to solve the request. 
 */ 
  
 // const searchMode = {} 
  
 /** 
 *  Guide the optimization algorithm in finding a first solution that is 
 *  similar to a previous solution. 
 *  The model is constrained when the first solution is built. 
 *  Any shipments not performed on a route are implicitly skipped in the first 
 *  solution, but they may be performed in successive solutions. 
 *  The solution must satisfy some basic validity assumptions: 
 *    * for all routes, `vehicle_index` must be in range and not be duplicated. 
 *    * for all visits, `shipment_index` and `visit_request_index` must be 
 *      in range. 
 *    * a shipment may only be referenced on one route. 
 *    * the pickup of a pickup-delivery shipment must be performed before 
 *      the delivery. 
 *    * no more than one pickup alternative or delivery alternative of 
 *      a shipment may be performed. 
 *    * for all routes, times are increasing (i.e., `vehicle_start_time 
 *      <= visits0.start_time=""><= visits1.start_time="" ...="" *=""><= vehicle_end_time`).="" *="" *="" a="" shipment="" may="" only="" be="" performed="" on="" a="" vehicle="" that="" is="" allowed.="" a="" *="" vehicle="" is="" allowed="" if="" *="" shipment.allowed_vehicle_indices="" google.cloud.optimization.v1.shipment.allowed_vehicle_indices="" *="" is="" empty="" or="" its="" `vehicle_index`="" is="" included="" in="" *="" shipment.allowed_vehicle_indices="" google.cloud.optimization.v1.shipment.allowed_vehicle_indices.="" *="" if="" the="" injected="" solution="" is="" not="" feasible,="" a="" validation="" error="" is="" not="" *="" necessarily="" returned="" and="" an="" error="" indicating="" infeasibility="" may="" be="" returned="" *="" instead.="" */ 
 = 
 "" 
  
 const 
 = 
 "" 
  
 injectedfirstsolutionroutes 
 = 
 "1234" 
  
 *= 
 "" 
  
 *= 
 "" 
  
 constrain 
 = 
 "" 
  
 the 
 = 
 "" 
  
 optimization 
 = 
 "" 
  
 algorithm 
 = 
 "" 
  
 to 
 = 
 "" 
  
 find 
 = 
 "" 
  
 a 
 = 
 "" 
  
 final 
 = 
 "" 
  
 solution 
 = 
 "" 
  
 that 
 = 
 "" 
  
 is 
 = 
 "" 
  
 *= 
 "" 
  
 similar 
 = 
 "" 
  
 to 
 = 
 "" 
  
 a 
 = 
 "" 
  
 previous 
 = 
 "" 
  
 solution 
 . 
 = 
 "" 
  
 for 
 = 
 "" 
  
 example 
 , 
 = 
 "" 
  
 this 
 = 
 "" 
  
 may 
 = 
 "" 
  
 be 
 = 
 "" 
  
 used 
 = 
 "" 
  
 to 
 = 
 "" 
  
 freeze 
 = 
 "" 
  
 *= 
 "" 
  
 portions 
 = 
 "" 
  
 of 
 = 
 "" 
  
 routes 
 = 
 "" 
  
 which 
 = 
 "" 
  
 have 
 = 
 "" 
  
 already 
 = 
 "" 
  
 been 
 = 
 "" 
  
 completed 
 = 
 "" 
  
 or 
 = 
 "" 
  
 which 
 = 
 "" 
  
 are 
 = 
 "" 
  
 to 
 = 
 "" 
  
 be 
 = 
 "" 
  
 *= 
 "" 
  
 completed 
 = 
 "" 
  
 but 
 = 
 "" 
  
 must 
 = 
 "" 
  
 not 
 = 
 "" 
  
 be 
 = 
 "" 
  
 modified 
 . 
 = 
 "" 
  
 *= 
 "" 
  
 if 
 = 
 "" 
  
 the 
 = 
 "" 
  
 injected 
 = 
 "" 
  
 solution 
 = 
 "" 
  
 is 
 = 
 "" 
  
 not 
 = 
 "" 
  
 feasible 
 , 
 = 
 "" 
  
 a 
 = 
 "" 
  
 validation 
 = 
 "" 
  
 error 
 = 
 "" 
  
 is 
 = 
 "" 
  
 not 
 = 
 "" 
  
 *= 
 "" 
  
 necessarily 
 = 
 "" 
  
 returned 
 = 
 "" 
  
 and 
 = 
 "" 
  
 an 
 = 
 "" 
  
 error 
 = 
 "" 
  
 indicating 
 = 
 "" 
  
 infeasibility 
 = 
 "" 
  
 may 
 = 
 "" 
  
 be 
 = 
 "" 
  
 returned 
 = 
 "" 
  
 *= 
 "" 
  
 instead 
 . 
 = 
 "" 
  
 * 
 /="" const="" injectedsolutionconstraint="{}" *="" *="" if="" non-empty,="" the="" given="" routes="" will="" be="" refreshed,="" without="" modifying="" their="" *="" underlying="" sequence="" of="" visits="" or="" travel="" times:="" only="" other="" details="" will="" be="" *="" updated.="" this="" does="" not="" solve="" the="" model.="" *="" as="" of="" 2020/11,="" this="" only="" populates="" the="" polylines="" of="" non-empty="" routes="" and="" *="" requires="" that="" `populate_polylines`="" is="" true.="" *="" the="" `route_polyline`="" fields="" of="" the="" passed-in="" routes="" may="" be="" inconsistent="" *="" with="" route="" `transitions`.="" *="" this="" field="" must="" not="" be="" used="" together="" with="" `injected_first_solution_routes`="" *="" or="" `injected_solution_constraint`.="" *="" `shipment.ignore`="" and="" `vehicle.ignore`="" have="" no="" effect="" on="" the="" behavior.="" *="" polylines="" are="" still="" populated="" between="" all="" visits="" in="" all="" non-empty="" routes="" *="" regardless="" of="" whether="" the="" related="" shipments="" or="" vehicles="" are="" ignored.="" */="" const="" refreshdetailsroutes="1234" *="" *="" if="" true:="" *="" *="" uses="" *="" shipmentroute.vehicle_label="" google.cloud.optimization.v1.shipmentroute.vehicle_label="" *="" instead="" of="" `vehicle_index`="" to="" *="" match="" routes="" in="" an="" injected="" solution="" with="" vehicles="" in="" the="" request;="" *="" reuses="" the="" mapping="" of="" original="" *="" shipmentroute.vehicle_index="" google.cloud.optimization.v1.shipmentroute.vehicle_index="" *="" to="" new="" *="" shipmentroute.vehicle_index="" google.cloud.optimization.v1.shipmentroute.vehicle_index="" *="" to="" update="" *="" constraintrelaxation.vehicle_indices="" google.cloud.optimization.v1.injectedsolutionconstraint.constraintrelaxation.vehicle_indices="" *="" if="" non-empty,="" but="" the="" mapping="" must="" be="" unambiguous="" (i.e.,="" multiple="" *="" `shipmentroute`s="" must="" not="" share="" the="" same="" original="" `vehicle_index`).="" *="" *="" uses="" *="" shipmentroute.visit.shipment_label="" google.cloud.optimization.v1.shipmentroute.visit.shipment_label="" *="" instead="" of="" `shipment_index`="" *="" to="" match="" visits="" in="" an="" injected="" solution="" with="" shipments="" in="" the="" request;="" *="" *="" uses="" *="" skippedshipment.label="" google.cloud.optimization.v1.skippedshipment.label="" *="" instead="" of="" *="" skippedshipment.index="" google.cloud.optimization.v1.skippedshipment.index="" *="" to="" *="" match="" skipped="" shipments="" in="" the="" injected="" solution="" with="" request="" *="" shipments.="" *="" this="" interpretation="" applies="" to="" the="" `injected_first_solution_routes`,="" *="" `injected_solution_constraint`,="" and="" `refresh_details_routes`="" fields.="" *="" it="" can="" be="" used="" when="" shipment="" or="" vehicle="" indices="" in="" the="" request="" have="" *="" changed="" since="" the="" solution="" was="" created,="" perhaps="" because="" shipments="" or="" *="" vehicles="" have="" been="" removed="" from="" or="" added="" to="" the="" request.="" *="" if="" true,="" labels="" in="" the="" following="" categories="" must="" appear="" at="" most="" once="" in="" *="" their="" category:="" *="" *="" vehicle.label="" google.cloud.optimization.v1.vehicle.label="" in="" the="" *="" request;="" *="" *="" shipment.label="" google.cloud.optimization.v1.shipment.label="" in="" the="" *="" request;="" *="" *="" shipmentroute.vehicle_label="" google.cloud.optimization.v1.shipmentroute.vehicle_label="" in="" the="" injected="" solution;="" *="" *="" skippedshipment.label="" google.cloud.optimization.v1.skippedshipment.label="" and="" shipmentroute.visit.shipment_label="" google.cloud.optimization.v1.shipmentroute.visit.shipment_label="" in="" *="" the="" injected="" solution="" (except="" pickup/delivery="" visit="" pairs,="" whose="" *="" `shipment_label`="" must="" appear="" twice).="" *="" if="" a="" `vehicle_label`="" in="" the="" injected="" solution="" does="" not="" correspond="" to="" a="" *="" request="" vehicle,="" the="" corresponding="" route="" is="" removed="" from="" the="" solution="" *="" along="" with="" its="" visits.="" if="" a="" `shipment_label`="" in="" the="" injected="" solution="" does="" *="" not="" correspond="" to="" a="" request="" shipment,="" the="" corresponding="" visit="" is="" removed="" *="" from="" the="" solution.="" if="" a="" *="" skippedshipment.label="" google.cloud.optimization.v1.skippedshipment.label="" *="" in="" the="" injected="" solution="" does="" not="" correspond="" to="" a="" request="" shipment,="" the="" *="" `skippedshipment`="" is="" removed="" from="" the="" solution.="" *="" removing="" route="" visits="" or="" entire="" routes="" from="" an="" injected="" solution="" may="" *="" have="" an="" effect="" on="" the="" implied="" constraints,="" which="" may="" lead="" to="" change="" in="" *="" solution,="" validation="" errors,="" or="" infeasibility.="" *="" note:="" the="" caller="" must="" ensure="" that="" each="" *="" vehicle.label="" google.cloud.optimization.v1.vehicle.label="" (resp.="" *="" shipment.label="" google.cloud.optimization.v1.shipment.label)="" uniquely="" *="" identifies="" a="" vehicle="" (resp.="" shipment)="" entity="" used="" across="" the="" two="" relevant="" *="" requests:="" the="" past="" request="" that="" produced="" the="" `optimizetoursresponse`="" used="" *="" in="" the="" injected="" solution="" and="" the="" current="" request="" that="" includes="" the="" injected="" *="" solution.="" the="" uniqueness="" checks="" described="" above="" are="" not="" enough="" to="" guarantee="" *="" this="" requirement.="" */="" const="" interpretinjectedsolutionsusinglabels="true" *="" *="" consider="" traffic="" estimation="" in="" calculating="" `shipmentroute`="" fields="" *="" transition.travel_duration="" google.cloud.optimization.v1.shipmentroute.transition.travel_duration,="" *="" visit.start_time="" google.cloud.optimization.v1.shipmentroute.visit.start_time,="" *="" and="" `vehicle_end_time`;="" in="" setting="" the="" *="" shipmentroute.has_traffic_infeasibilities="" google.cloud.optimization.v1.shipmentroute.has_traffic_infeasibilities="" *="" field,="" and="" in="" calculating="" the="" *="" optimizetoursresponse.total_cost="" google.cloud.optimization.v1.optimizetoursresponse.total_cost="" *="" field.="" */="" const="" considerroadtraffic="true" *="" *="" if="" true,="" polylines="" will="" be="" populated="" in="" response="" `shipmentroute`s.="" */="" const="" populatepolylines="true" *="" *="" if="" true,="" polylines="" will="" be="" populated="" in="" response="" *="" shipmentroute.transitions="" google.cloud.optimization.v1.shipmentroute.transitions.="" *="" note="" that="" in="" this="" case,="" the="" polylines="" will="" also="" be="" populated="" in="" the="" *="" deprecated="" `travel_steps`.="" */="" const="" populatetransitionpolylines="true" *="" *="" if="" this="" is="" set,="" then="" the="" request="" can="" have="" a="" deadline="" *="" (see="" https://grpc.io/blog/deadlines)="" of="" up="" to="" 60="" minutes.="" *="" otherwise,="" the="" maximum="" deadline="" is="" only="" 30="" minutes.="" *="" note="" that="" long-lived="" requests="" have="" a="" significantly="" larger="" (but="" still="" small)="" *="" risk="" of="" interruption.="" */="" const="" allowlargedeadlinedespiteinterruptionrisk="true" *="" *="" if="" true,="" travel="" distances="" will="" be="" computed="" using="" geodesic="" distances="" instead="" *="" of="" google="" maps="" distances,="" and="" travel="" times="" will="" be="" computed="" using="" geodesic="" *="" distances="" with="" a="" speed="" defined="" by="" `geodesic_meters_per_second`.="" */="" const="" usegeodesicdistances="true" *="" *="" when="" `use_geodesic_distances`="" is="" true,="" this="" field="" must="" be="" set="" and="" defines="" *="" the="" speed="" applied="" to="" compute="" travel="" times.="" its="" value="" must="" be="" at="" least="" 1.0="" *="" meters/seconds.="" */="" const="" geodesicmeterspersecond="1234" *="" *="" label="" that="" may="" be="" used="" to="" identify="" this="" request,="" reported="" back="" in="" the="" *="" optimizetoursresponse.request_label="" google.cloud.optimization.v1.optimizetoursresponse.request_label.="" */="" const="" label='abc123' imports="" the="" optimization="" library="" const="" {fleetroutingclient}="require('@google-cloud/optimization').v1;" instantiates="" a="" client="" const="" optimizationclient="new" fleetroutingclient();="" async="" function="" calloptimizetours()="" {="" construct="" request="" const="" request="{" parent,="" };="" run="" request="" const="" response="await" optimizationclient.optimizetours(request);="" console.log(response);="" }="" calloptimizetours();="" 
> 

optimizeTours(request, options, callback)

  optimizeTours 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
 , 
  
 options 
 : 
  
 CallOptions 
 , 
  
 callback 
 : 
  
 Callback<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
  
 | 
  
 null 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 void 
 ; 
 
Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IOptimizeToursRequest
options
CallOptions
callback
Callback <protos. google.cloud.optimization.v1.IOptimizeToursResponse , protos. google.cloud.optimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>
Returns
Type
Description
void

optimizeTours(request, callback)

  optimizeTours 
 ( 
 request 
 : 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
 , 
  
 callback 
 : 
  
 Callback<protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursResponse 
 , 
  
 protos 
 . 
 google 
 . 
 cloud 
 . 
 optimization 
 . 
 v1 
 . 
 IOptimizeToursRequest 
  
 | 
  
 null 
  
 | 
  
 undefined 
 , 
  
 {} 
  
 | 
  
 null 
  
 | 
  
 undefined 
> ) 
 : 
  
 void 
 ; 
 
Parameters
Name
Description
request
protos. google.cloud.optimization.v1.IOptimizeToursRequest
callback
Callback <protos. google.cloud.optimization.v1.IOptimizeToursResponse , protos. google.cloud.optimization.v1.IOptimizeToursRequest | null | undefined, {} | null | undefined>
Returns
Type
Description
void
Design a Mobile Site
View Site in Mobile | Classic
Share by: