Local Rides and Deliveries API v1 - Package cloud.google.com/go/maps/fleetengine/apiv1 (v1.18.0)

Package fleetengine is an auto-generated package for the Local Rides and Deliveries API.

Enables Fleet Engine for access to the On Demand Rides and Deliveries and Last Mile Fleet Solution APIs. Customer’s use of Google Maps Content in the Cloud Logging Services is subject to the Google Maps Platform Terms of Service located at https://cloud.google.com/maps-platform/terms (at https://cloud.google.com/maps-platform/terms ).

General documentation

For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview . Some information on this page includes:

Example usage

To get started with this package, create a client.

 // go get cloud.google.com/go/maps/fleetengine/apiv1@latest 
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // 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. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
 NewTripClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

 req 
  
 := 
  
& fleetenginepb 
 . 
 CreateTripRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#CreateTripRequest. 
 } 
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateTrip 
 ( 
 ctx 
 , 
  
 req 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 // TODO: Use resp. 
 _ 
  
 = 
  
 resp 

Use of Context

The ctx passed to NewTripClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

TripCallOptions

  type 
  
 TripCallOptions 
  
 struct 
  
 { 
  
 CreateTrip 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetTrip 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ReportBillableTrip 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SearchTrips 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateTrip 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

TripCallOptions contains the retry settings for each method of TripClient.

TripClient

  type 
  
 TripClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  TripCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

TripClient is a client for interacting with Local Rides and Deliveries API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Trip management service.

func NewTripClient

  func 
  
 NewTripClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  TripClient 
 
 , 
  
  error 
 
 ) 
 

NewTripClient creates a new trip service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Trip management service.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*TripClient) Close

  func 
  
 ( 
 c 
  
 * 
  TripClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*TripClient) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  TripClient 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*TripClient) CreateTrip

CreateTrip creates a trip in the Fleet Engine and returns the new trip.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 CreateTripRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#CreateTripRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateTrip 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*TripClient) GetTrip

GetTrip get information about a single trip.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 GetTripRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#GetTripRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetTrip 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*TripClient) ReportBillableTrip

ReportBillableTrip report billable trip usage.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 ReportBillableTripRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#ReportBillableTripRequest. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 ReportBillableTrip 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*TripClient) SearchTrips

SearchTrips get all the trips for a specific vehicle.

Examples

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 SearchTripsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#SearchTripsRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 SearchTrips 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 fleetenginepb 
 . 
 SearchTripsResponse 
 ) 
  
 } 
 } 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 SearchTripsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#SearchTripsRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 SearchTrips 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*TripClient) UpdateTrip

UpdateTrip updates trip data.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewTripClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 UpdateTripRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#UpdateTripRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateTrip 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

TripIterator

  type 
  
 TripIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  fleetenginepb 
 
 . 
  Trip 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

TripIterator manages a stream of *fleetenginepb.Trip.

func (*TripIterator) All

  func 
  
 ( 
 it 
  
 * 
  TripIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 fleetenginepb 
 . 
 Trip 
 , 
  
 error 
 ] 
 

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*TripIterator) Next

  func 
  
 ( 
 it 
  
 * 
  TripIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  fleetenginepb 
 
 . 
  Trip 
 
 , 
  
  error 
 
 ) 
 

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*TripIterator) PageInfo

  func 
  
 ( 
 it 
  
 * 
  TripIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

VehicleCallOptions

  type 
  
 VehicleCallOptions 
  
 struct 
  
 { 
  
 CreateVehicle 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetVehicle 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateVehicle 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateVehicleAttributes 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListVehicles 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SearchVehicles 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

VehicleCallOptions contains the retry settings for each method of VehicleClient.

VehicleClient

  type 
  
 VehicleClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  VehicleCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

VehicleClient is a client for interacting with Local Rides and Deliveries API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Vehicle management service.

func NewVehicleClient

  func 
  
 NewVehicleClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  VehicleClient 
 
 , 
  
  error 
 
 ) 
 

NewVehicleClient creates a new vehicle service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Vehicle management service.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*VehicleClient) Close

  func 
  
 ( 
 c 
  
 * 
  VehicleClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*VehicleClient) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  VehicleClient 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*VehicleClient) CreateVehicle

CreateVehicle instantiates a new vehicle associated with an on-demand rideshare or deliveries provider. Each Vehicle must have a unique vehicle ID.

The following Vehicle fields are required when creating a Vehicle:

 vehicleState

supportedTripTypes

maximumCapacity

vehicleType 

The following Vehicle fields are ignored when creating a Vehicle:

 name

currentTrips

availableCapacity

current_route_segment

current_route_segment_end_point

current_route_segment_version

current_route_segment_traffic

route

waypoints

waypoints_version

remaining_distance_meters

remaining_time_seconds

eta_to_next_waypoint

navigation_status 

All other fields are optional and used if provided.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 CreateVehicleRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#CreateVehicleRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateVehicle 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*VehicleClient) GetVehicle

GetVehicle returns a vehicle from the Fleet Engine.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 GetVehicleRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#GetVehicleRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetVehicle 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*VehicleClient) ListVehicles

ListVehicles returns a paginated list of vehicles associated with a provider that match the request options.

Examples

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 ListVehiclesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#ListVehiclesRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListVehicles 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 // If you need to access the underlying RPC response, 
  
 // you can do so by casting the `Response` as below. 
  
 // Otherwise, remove this line. Only populated after 
  
 // first call to Next(). Not safe for concurrent access. 
  
 _ 
  
 = 
  
 it 
 . 
 Response 
 .( 
 * 
 fleetenginepb 
 . 
 ListVehiclesResponse 
 ) 
  
 } 
 } 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 ListVehiclesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#ListVehiclesRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 ListVehicles 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*VehicleClient) SearchVehicles

SearchVehicles returns a list of vehicles that match the request options.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 SearchVehiclesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#SearchVehiclesRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 SearchVehicles 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*VehicleClient) UpdateVehicle

UpdateVehicle writes updated vehicle data to the Fleet Engine.

When updating a Vehicle, the following fields cannot be updated since they are managed by the server:

 currentTrips

availableCapacity

current_route_segment_version

waypoints_version 

The vehicle name also cannot be updated.

If the attributes field is updated, all the vehicle’s attributes are replaced with the attributes provided in the request. If you want to update only some attributes, see the UpdateVehicleAttributes method. Likewise, the waypoints field can be updated, but must contain all the waypoints currently on the vehicle, and no other waypoints.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 UpdateVehicleRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#UpdateVehicleRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateVehicle 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*VehicleClient) UpdateVehicleAttributes

UpdateVehicleAttributes partially updates a vehicle’s attributes. Only the attributes mentioned in the request will be updated, other attributes will NOT be altered. Note: this is different in UpdateVehicle, where the whole attributes field will be replaced by the one in UpdateVehicleRequest, attributes not in the request would be removed.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 fleetengine 
  
 "cloud.google.com/go/maps/fleetengine/apiv1" 
  
 fleetenginepb 
  
 "cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 fleetengine 
 . 
  NewVehicleClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
 Close 
 () 
  
 req 
  
 := 
  
& fleetenginepb 
 . 
 UpdateVehicleAttributesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/maps/fleetengine/apiv1/fleetenginepb#UpdateVehicleAttributesRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateVehicleAttributes 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

VehicleIterator

  type 
  
 VehicleIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  fleetenginepb 
 
 . 
  Vehicle 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

VehicleIterator manages a stream of *fleetenginepb.Vehicle.

func (*VehicleIterator) All

  func 
  
 ( 
 it 
  
 * 
  VehicleIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 fleetenginepb 
 . 
 Vehicle 
 , 
  
 error 
 ] 
 

All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.

func (*VehicleIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*VehicleIterator) PageInfo

  func 
  
 ( 
 it 
  
 * 
  VehicleIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

Create a Mobile Website
View Site in Mobile | Classic
Share by: