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

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

Overview

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 client object.

Examples:


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

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

Yields:

  • (config)

    Configure the VehicleService client.

Yield Parameters:



149
150
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 149

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/maps/fleetengine/v1/vehicle_api_services_pb"

  # 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 = ::Gapic::ServiceStub.new(
    ::Google::Maps::FleetEngine::V1::VehicleService::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool,
    logger: @config.logger
  )

  @vehicle_service_stub.stub_logger&.info do |entry|
    entry.set_system_name
    entry.set_service
    entry.message = "Created client for #{entry.service}"
    entry.set_credentials_fields credentials
    entry.set "customEndpoint", @config.endpoint if @config.endpoint
    entry.set "defaultTimeout", @config.timeout if @config.timeout
    entry.set "quotaProject", @quota_project_id if @quota_project_id
  end
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::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



62
63
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
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 62

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:



119
120
121
122
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 119

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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 324

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent &&
     %r{^providers/[^/]+/?$}.match?(request.parent)
    header_params["provider_id"] = request.parent
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :create_vehicle, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 427

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name &&
     %r{^providers/[^/]+/?$}.match?(request.name)
    header_params["provider_id"] = request.name
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :get_vehicle, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_vehicles(request, options = nil) ⇒ ::Gapic::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::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::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::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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 860

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent &&
     %r{^providers/[^/]+/?$}.match?(request.parent)
    header_params["provider_id"] = request.parent
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :list_vehicles, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @vehicle_service_stub, :list_vehicles, request, response, operation, options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#loggerLogger

The logger used for request/response debug logging.

Returns:

  • (Logger)


205
206
207
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 205

def logger
  @vehicle_service_stub.logger
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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 1079

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent &&
     %r{^providers/[^/]+/?$}.match?(request.parent)
    header_params["provider_id"] = request.parent
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :search_vehicles, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


129
130
131
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 129

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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 555

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name &&
     %r{^providers/[^/]+/?$}.match?(request.name)
    header_params["provider_id"] = request.name
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_vehicle, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => 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::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:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

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

    if the RPC is aborted.



653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 653

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
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name &&
     %r{^providers/[^/]+/?$}.match?(request.name)
    header_params["provider_id"] = request.name
  end

  request_params_header = URI.encode_www_form header_params
  [:"x-goog-request-params"] ||= request_params_header

  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.call_rpc :update_vehicle_attributes, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end