Class: Google::Maps::FleetEngine::V1::VehicleService::Rest::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb

Overview

REST client for the VehicleService service.

Vehicle management service.

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#vehicle_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new VehicleService REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the VehicleService client.

Yield Parameters:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 151

def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @vehicle_service_stub = ::Google::Maps::FleetEngine::V1::VehicleService::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the VehicleService Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all VehicleService clients
::Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 64

def self.configure
  @configure ||= begin
    namespace = ["Google", "Maps", "FleetEngine", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.create_vehicle.timeout = 15.0
    default_config.rpcs.create_vehicle.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.get_vehicle.timeout = 15.0
    default_config.rpcs.get_vehicle.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.update_vehicle.timeout = 15.0
    default_config.rpcs.update_vehicle.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.update_vehicle_attributes.timeout = 15.0
    default_config.rpcs.update_vehicle_attributes.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.search_vehicles.timeout = 15.0
    default_config.rpcs.search_vehicles.retry_policy = {
      initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#configure {|config| ... } ⇒ Client::Configuration

Configure the VehicleService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



121
122
123
124
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 121

def configure
  yield @config if block_given?
  @config
end

#create_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle #create_vehicle(header: nil, parent: nil, vehicle_id: nil, vehicle: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

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.

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::CreateVehicleRequest.new

# Call the create_vehicle method.
result = client.create_vehicle request

# The returned object is of type Google::Maps::FleetEngine::V1::Vehicle.
p result

Overloads:

  • #create_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to create_vehicle via a request object, either of type CreateVehicleRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::CreateVehicleRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_vehicle(header: nil, parent: nil, vehicle_id: nil, vehicle: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to create_vehicle via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • parent (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}. The provider must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • vehicle_id (::String) (defaults to: nil)

      Required. Unique Vehicle ID. Subject to the following restrictions:

      • Must be a valid Unicode string.
      • Limited to a maximum length of 64 characters.
      • Normalized according to Unicode Normalization Form C.
      • May not contain any of the following ASCII characters: '/', ':', '?', ',', or '#'.
    • vehicle (::Google::Maps::FleetEngine::V1::Vehicle, ::Hash) (defaults to: nil)

      Required. The Vehicle entity to create. When creating a Vehicle, the following fields are required:

      • vehicleState
      • supportedTripTypes
      • maximumCapacity
      • vehicleType

      When creating a Vehicle, the following fields are ignored:

      • 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.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 296

def create_vehicle request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::CreateVehicleRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_vehicle..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_vehicle.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_vehicle.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.create_vehicle request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle #get_vehicle(header: nil, name: nil, current_route_segment_version: nil, waypoints_version: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

Returns a vehicle from the Fleet Engine.

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::GetVehicleRequest.new

# Call the get_vehicle method.
result = client.get_vehicle request

# The returned object is of type Google::Maps::FleetEngine::V1::Vehicle.
p result

Overloads:

  • #get_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to get_vehicle via a request object, either of type GetVehicleRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::GetVehicleRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_vehicle(header: nil, name: nil, current_route_segment_version: nil, waypoints_version: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to get_vehicle via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • name (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}/vehicles/{vehicle}. The provider must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • current_route_segment_version (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      Indicates the minimum timestamp (exclusive) for which Vehicle.current_route_segment is retrieved. If the route is unchanged since this timestamp, the current_route_segment field is not set in the response. If a minimum is unspecified, the current_route_segment is always retrieved.

    • waypoints_version (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      Indicates the minimum timestamp (exclusive) for which Vehicle.waypoints data is retrieved. If the waypoints are unchanged since this timestamp, the vehicle.waypoints data is not set in the response. If this field is unspecified, vehicle.waypoints is always retrieved.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 392

def get_vehicle request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::GetVehicleRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_vehicle..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_vehicle.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_vehicle.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.get_vehicle request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_vehicles(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle> #list_vehicles(header: nil, parent: nil, page_size: nil, page_token: nil, minimum_capacity: nil, trip_types: nil, maximum_staleness: nil, vehicle_type_categories: nil, required_attributes: nil, required_one_of_attributes: nil, required_one_of_attribute_sets: nil, vehicle_state: nil, on_trip_only: nil, filter: nil, viewport: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle>

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

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::ListVehiclesRequest.new

# Call the list_vehicles method.
result = client.list_vehicles request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Maps::FleetEngine::V1::Vehicle.
  p item
end

Overloads:

  • #list_vehicles(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle>

    Pass arguments to list_vehicles via a request object, either of type ListVehiclesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::ListVehiclesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_vehicles(header: nil, parent: nil, page_size: nil, page_token: nil, minimum_capacity: nil, trip_types: nil, maximum_staleness: nil, vehicle_type_categories: nil, required_attributes: nil, required_one_of_attributes: nil, required_one_of_attribute_sets: nil, vehicle_state: nil, on_trip_only: nil, filter: nil, viewport: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle>

    Pass arguments to list_vehicles via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • parent (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}. The provider must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • page_size (::Integer) (defaults to: nil)

      The maximum number of vehicles to return. Default value: 100.

    • page_token (::String) (defaults to: nil)

      The value of the next_page_token provided by a previous call to ListVehicles so that you can paginate through groups of vehicles. The value is undefined if the filter criteria of the request is not the same as the filter criteria for the previous call to ListVehicles.

    • minimum_capacity (::Google::Protobuf::Int32Value, ::Hash) (defaults to: nil)

      Specifies the required minimum capacity of the vehicle. All vehicles returned will have a maximum_capacity greater than or equal to this value. If set, must be greater or equal to 0.

    • trip_types (::Array<::Google::Maps::FleetEngine::V1::TripType>) (defaults to: nil)

      Restricts the response to vehicles that support at least one of the specified trip types.

    • maximum_staleness (::Google::Protobuf::Duration, ::Hash) (defaults to: nil)

      Restricts the response to vehicles that have sent location updates to Fleet Engine within the specified duration. Stationary vehicles still transmitting their locations are not considered stale. If present, must be a valid positive duration.

    • vehicle_type_categories (::Array<::Google::Maps::FleetEngine::V1::Vehicle::VehicleType::Category>) (defaults to: nil)

      Required. Restricts the response to vehicles with one of the specified type categories. UNKNOWN is not allowed.

    • required_attributes (::Array<::String>) (defaults to: nil)

      Callers can form complex logical operations using any combination of the required_attributes, required_one_of_attributes, and required_one_of_attribute_sets fields.

      required_attributes is a list; required_one_of_attributes uses a message which allows a list of lists. In combination, the two fields allow the composition of this expression:

      (required_attributes[0] AND required_attributes[1] AND ...)
      AND
      (required_one_of_attributes[0][0] OR required_one_of_attributes[0][1] OR
      ...)
      AND
      (required_one_of_attributes[1][0] OR required_one_of_attributes[1][1] OR
      ...)
      

      Restricts the response to vehicles with the specified attributes. This field is a conjunction/AND operation. A max of 50 required_attributes is allowed. This matches the maximum number of attributes allowed on a vehicle. Each repeated string should be of the format "key:value".

    • required_one_of_attributes (::Array<::String>) (defaults to: nil)

      Restricts the response to vehicles with at least one of the specified attributes in each VehicleAttributeList. Within each list, a vehicle must match at least one of the attributes. This field is an inclusive disjunction/OR operation in each VehicleAttributeList and a conjunction/AND operation across the collection of VehicleAttributeList. Each repeated string should be of the format "key1:value1|key2:value2|key3:value3".

    • required_one_of_attribute_sets (::Array<::String>) (defaults to: nil)

      required_one_of_attribute_sets provides additional functionality.

      Similar to required_one_of_attributes, required_one_of_attribute_sets uses a message which allows a list of lists, allowing expressions such as this one:

      (required_attributes[0] AND required_attributes[1] AND ...)
      AND
      (
        (required_one_of_attribute_sets[0][0] AND
        required_one_of_attribute_sets[0][1] AND
        ...)
        OR
        (required_one_of_attribute_sets[1][0] AND
        required_one_of_attribute_sets[1][1] AND
        ...)
      )
      

      Restricts the response to vehicles that match all the attributes in a VehicleAttributeList. Within each list, a vehicle must match all of the attributes. This field is a conjunction/AND operation in each VehicleAttributeList and inclusive disjunction/OR operation across the collection of VehicleAttributeList. Each repeated string should be of the format "key1:value1|key2:value2|key3:value3".

    • vehicle_state (::Google::Maps::FleetEngine::V1::VehicleState) (defaults to: nil)

      Restricts the response to vehicles that have this vehicle state.

    • on_trip_only (::Boolean) (defaults to: nil)

      Only return the vehicles with current trip(s).

    • filter (::String) (defaults to: nil)

      Optional. A filter query to apply when listing vehicles. See http://aip.dev/160 for examples of the filter syntax.

      This field is designed to replace the required_attributes, required_one_of_attributes, and required_one_of_attributes_sets fields. If a non-empty value is specified here, the following fields must be empty: required_attributes, required_one_of_attributes, and required_one_of_attributes_sets.

      This filter functions as an AND clause with other constraints, such as vehicle_state or on_trip_only.

      Note that the only queries supported are on vehicle attributes (for example, attributes.<key> = <value> or attributes.<key1> = <value1> AND attributes.<key2> = <value2>). The maximum number of restrictions allowed in a filter query is 50.

      Also, all attributes are stored as strings, so the only supported comparisons against attributes are string comparisons. In order to compare against number or boolean values, the values must be explicitly quoted to be treated as strings (for example, attributes.<key> = "10" or attributes.<key> = "true").

    • viewport (::Google::Geo::Type::Viewport, ::Hash) (defaults to: nil)

      Optional. A filter that limits the vehicles returned to those whose last known location was in the rectangular area defined by the viewport.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 804

def list_vehicles request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::ListVehiclesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_vehicles..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_vehicles.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_vehicles.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.list_vehicles request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @vehicle_service_stub, :list_vehicles, "vehicles", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#search_vehicles(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::SearchVehiclesResponse #search_vehicles(header: nil, parent: nil, pickup_point: nil, dropoff_point: nil, pickup_radius_meters: nil, count: nil, minimum_capacity: nil, trip_types: nil, maximum_staleness: nil, vehicle_types: nil, required_attributes: nil, required_one_of_attributes: nil, required_one_of_attribute_sets: nil, order_by: nil, include_back_to_back: nil, trip_id: nil, current_trips_present: nil, filter: nil) ⇒ ::Google::Maps::FleetEngine::V1::SearchVehiclesResponse

Returns a list of vehicles that match the request options.

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::SearchVehiclesRequest.new

# Call the search_vehicles method.
result = client.search_vehicles request

# The returned object is of type Google::Maps::FleetEngine::V1::SearchVehiclesResponse.
p result

Overloads:

  • #search_vehicles(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::SearchVehiclesResponse

    Pass arguments to search_vehicles via a request object, either of type SearchVehiclesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::SearchVehiclesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #search_vehicles(header: nil, parent: nil, pickup_point: nil, dropoff_point: nil, pickup_radius_meters: nil, count: nil, minimum_capacity: nil, trip_types: nil, maximum_staleness: nil, vehicle_types: nil, required_attributes: nil, required_one_of_attributes: nil, required_one_of_attribute_sets: nil, order_by: nil, include_back_to_back: nil, trip_id: nil, current_trips_present: nil, filter: nil) ⇒ ::Google::Maps::FleetEngine::V1::SearchVehiclesResponse

    Pass arguments to search_vehicles via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • parent (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}. The provider must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • pickup_point (::Google::Maps::FleetEngine::V1::TerminalLocation, ::Hash) (defaults to: nil)

      Required. The pickup point to search near.

    • dropoff_point (::Google::Maps::FleetEngine::V1::TerminalLocation, ::Hash) (defaults to: nil)

      The customer's intended dropoff location. The field is required if trip_types contains TripType.SHARED.

    • pickup_radius_meters (::Integer) (defaults to: nil)

      Required. Defines the vehicle search radius around the pickup point. Only vehicles within the search radius will be returned. Value must be between 400 and 10000 meters (inclusive).

    • count (::Integer) (defaults to: nil)

      Required. Specifies the maximum number of vehicles to return. The value must be between 1 and 50 (inclusive).

    • minimum_capacity (::Integer) (defaults to: nil)

      Required. Specifies the number of passengers being considered for a trip. The value must be greater than or equal to one. The driver is not considered in the capacity value.

    • trip_types (::Array<::Google::Maps::FleetEngine::V1::TripType>) (defaults to: nil)

      Required. Represents the type of proposed trip. Must include exactly one type. UNKNOWN_TRIP_TYPE is not allowed. Restricts the search to only those vehicles that can support that trip type.

    • maximum_staleness (::Google::Protobuf::Duration, ::Hash) (defaults to: nil)

      Restricts the search to only those vehicles that have sent location updates to Fleet Engine within the specified duration. Stationary vehicles still transmitting their locations are not considered stale. If this field is not set, the server uses five minutes as the default value.

    • vehicle_types (::Array<::Google::Maps::FleetEngine::V1::Vehicle::VehicleType, ::Hash>) (defaults to: nil)

      Required. Restricts the search to vehicles with one of the specified types. At least one vehicle type must be specified. VehicleTypes with a category of UNKNOWN are not allowed.

    • required_attributes (::Array<::Google::Maps::FleetEngine::V1::VehicleAttribute, ::Hash>) (defaults to: nil)

      Callers can form complex logical operations using any combination of the required_attributes, required_one_of_attributes, and required_one_of_attribute_sets fields.

      required_attributes is a list; required_one_of_attributes uses a message which allows a list of lists. In combination, the two fields allow the composition of this expression:

      (required_attributes[0] AND required_attributes[1] AND ...)
      AND
      (required_one_of_attributes[0][0] OR required_one_of_attributes[0][1] OR
      ...)
      AND
      (required_one_of_attributes[1][0] OR required_one_of_attributes[1][1] OR
      ...)
      

      Restricts the search to only those vehicles with the specified attributes. This field is a conjunction/AND operation. A max of 50 required_attributes is allowed. This matches the maximum number of attributes allowed on a vehicle.

    • required_one_of_attributes (::Array<::Google::Maps::FleetEngine::V1::VehicleAttributeList, ::Hash>) (defaults to: nil)

      Restricts the search to only those vehicles with at least one of the specified attributes in each VehicleAttributeList. Within each list, a vehicle must match at least one of the attributes. This field is an inclusive disjunction/OR operation in each VehicleAttributeList and a conjunction/AND operation across the collection of VehicleAttributeList.

    • required_one_of_attribute_sets (::Array<::Google::Maps::FleetEngine::V1::VehicleAttributeList, ::Hash>) (defaults to: nil)

      required_one_of_attribute_sets provides additional functionality.

      Similar to required_one_of_attributes, required_one_of_attribute_sets uses a message which allows a list of lists, allowing expressions such as this one:

      (required_attributes[0] AND required_attributes[1] AND ...)
      AND
      (
        (required_one_of_attribute_sets[0][0] AND
        required_one_of_attribute_sets[0][1] AND
        ...)
        OR
        (required_one_of_attribute_sets[1][0] AND
        required_one_of_attribute_sets[1][1] AND
        ...)
      )
      

      Restricts the search to only those vehicles with all the attributes in a VehicleAttributeList. Within each list, a vehicle must match all of the attributes. This field is a conjunction/AND operation in each VehicleAttributeList and inclusive disjunction/OR operation across the collection of VehicleAttributeList.

    • order_by (::Google::Maps::FleetEngine::V1::SearchVehiclesRequest::VehicleMatchOrder) (defaults to: nil)

      Required. Specifies the desired ordering criterion for results.

    • include_back_to_back (::Boolean) (defaults to: nil)

      This indicates if vehicles with a single active trip are eligible for this search. This field is only used when current_trips_present is unspecified. When current_trips_present is unspecified and this field is false, vehicles with assigned trips are excluded from the search results. When current_trips_present is unspecified and this field is true, search results can include vehicles with one active trip that has a status of ENROUTE_TO_DROPOFF. When current_trips_present is specified, this field cannot be set to true.

      The default value is false.

    • trip_id (::String) (defaults to: nil)

      Indicates the trip associated with this SearchVehicleRequest.

    • current_trips_present (::Google::Maps::FleetEngine::V1::SearchVehiclesRequest::CurrentTripsPresent) (defaults to: nil)

      This indicates if vehicles with active trips are eligible for this search. This must be set to something other than CURRENT_TRIPS_PRESENT_UNSPECIFIED if trip_type includes SHARED.

    • filter (::String) (defaults to: nil)

      Optional. A filter query to apply when searching vehicles. See http://aip.dev/160 for examples of the filter syntax.

      This field is designed to replace the required_attributes, required_one_of_attributes, and required_one_of_attributes_sets fields. If a non-empty value is specified here, the following fields must be empty: required_attributes, required_one_of_attributes, and required_one_of_attributes_sets.

      This filter functions as an AND clause with other constraints, such as minimum_capacity or vehicle_types.

      Note that the only queries supported are on vehicle attributes (for example, attributes.<key> = <value> or attributes.<key1> = <value1> AND attributes.<key2> = <value2>). The maximum number of restrictions allowed in a filter query is 50.

      Also, all attributes are stored as strings, so the only supported comparisons against attributes are string comparisons. In order to compare against number or boolean values, the values must be explicitly quoted to be treated as strings (for example, attributes.<key> = "10" or attributes.<key> = "true").

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 1015

def search_vehicles request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::SearchVehiclesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.search_vehicles..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.search_vehicles.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.search_vehicles.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.search_vehicles request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


131
132
133
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 131

def universe_domain
  @vehicle_service_stub.universe_domain
end

#update_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle #update_vehicle(header: nil, name: nil, vehicle: nil, update_mask: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

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.

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::UpdateVehicleRequest.new

# Call the update_vehicle method.
result = client.update_vehicle request

# The returned object is of type Google::Maps::FleetEngine::V1::Vehicle.
p result

Overloads:

  • #update_vehicle(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to update_vehicle via a request object, either of type UpdateVehicleRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::UpdateVehicleRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_vehicle(header: nil, name: nil, vehicle: nil, update_mask: nil) ⇒ ::Google::Maps::FleetEngine::V1::Vehicle

    Pass arguments to update_vehicle via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • name (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}/vehicles/{vehicle}. The {provider} must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • vehicle (::Google::Maps::FleetEngine::V1::Vehicle, ::Hash) (defaults to: nil)

      Required. The Vehicle entity values to apply. When updating a Vehicle, the following fields may not be updated as they are managed by the server.

      • available_capacity
      • current_route_segment_version
      • current_trips
      • name
      • waypoints_version

      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.

    • update_mask (::Google::Protobuf::FieldMask, ::Hash) (defaults to: nil)

      Required. A field mask indicating which fields of the Vehicle to update. At least one field name must be provided.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 513

def update_vehicle request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::UpdateVehicleRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_vehicle..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_vehicle.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_vehicle.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.update_vehicle request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_vehicle_attributes(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse #update_vehicle_attributes(header: nil, name: nil, attributes: nil) ⇒ ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse

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.

Examples:

Basic example

require "google/maps/fleet_engine/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Maps::FleetEngine::V1::VehicleService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Maps::FleetEngine::V1::UpdateVehicleAttributesRequest.new

# Call the update_vehicle_attributes method.
result = client.update_vehicle_attributes request

# The returned object is of type Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse.
p result

Overloads:

  • #update_vehicle_attributes(request, options = nil) ⇒ ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse

    Pass arguments to update_vehicle_attributes via a request object, either of type UpdateVehicleAttributesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_vehicle_attributes(header: nil, name: nil, attributes: nil) ⇒ ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse

    Pass arguments to update_vehicle_attributes via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • header (::Google::Maps::FleetEngine::V1::RequestHeader, ::Hash) (defaults to: nil)

      The standard Fleet Engine request header.

    • name (::String) (defaults to: nil)

      Required. Must be in the format providers/{provider}/vehicles/{vehicle}. The provider must be the Project ID (for example, sample-cloud-project) of the Google Cloud Project of which the service account making this call is a member.

    • attributes (::Array<::Google::Maps::FleetEngine::V1::VehicleAttribute, ::Hash>) (defaults to: nil)

      Required. The vehicle attributes to update. Unmentioned attributes are not altered or removed.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 604

def update_vehicle_attributes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_vehicle_attributes..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Maps::FleetEngine::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_vehicle_attributes.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_vehicle_attributes.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @vehicle_service_stub.update_vehicle_attributes request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end