Class: Google::Maps::FleetEngine::V1::VehicleService::Rest::Client
- Inherits:
-
Object
- Object
- Google::Maps::FleetEngine::V1::VehicleService::Rest::Client
- 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
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the VehicleService Client class.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the VehicleService Client instance.
-
#create_vehicle(request, options = nil) {|result, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider.
-
#get_vehicle(request, options = nil) {|result, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Returns a vehicle from the Fleet Engine.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new VehicleService REST client object.
-
#list_vehicles(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle>
Returns a paginated list of vehicles associated with a provider that match the request options.
-
#logger ⇒ Logger
The logger used for request/response debug logging.
-
#search_vehicles(request, options = nil) {|result, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::SearchVehiclesResponse
Returns a list of vehicles that match the request options.
-
#universe_domain ⇒ String
The effective universe domain.
-
#update_vehicle(request, options = nil) {|result, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Writes updated vehicle data to the Fleet Engine.
-
#update_vehicle_attributes(request, options = nil) {|result, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::UpdateVehicleAttributesResponse
Partially updates a vehicle's attributes.
Methods included from Paths
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new VehicleService REST client object.
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 |
# 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, logger: @config.logger ) @vehicle_service_stub.logger(stub: true)&.info do |entry| entry.set_system_name entry.set_service entry. = "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.
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.
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.
316 317 318 319 320 321 322 323 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 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 316 def create_vehicle request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.create_vehicle.timeout, metadata: , retry_policy: @config.rpcs.create_vehicle.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.create_vehicle request, do |result, operation| yield result, operation if block_given? 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.
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 411 def get_vehicle request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.get_vehicle.timeout, metadata: , retry_policy: @config.rpcs.get_vehicle.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.get_vehicle request, do |result, operation| yield result, operation if block_given? 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.
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 820 def list_vehicles request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.list_vehicles.timeout, metadata: , retry_policy: @config.rpcs.list_vehicles.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.list_vehicles request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @vehicle_service_stub, :list_vehicles, "vehicles", request, result, yield result, operation if block_given? throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#logger ⇒ Logger
The logger used for request/response debug logging.
198 199 200 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 198 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.
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 1031 def search_vehicles request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.search_vehicles.timeout, metadata: , retry_policy: @config.rpcs.search_vehicles.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.search_vehicles request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#universe_domain ⇒ String
The effective universe domain
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.
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 531 def update_vehicle request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.update_vehicle.timeout, metadata: , retry_policy: @config.rpcs.update_vehicle.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.update_vehicle request, do |result, operation| yield result, operation if block_given? 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.
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/rest/client.rb', line 621 def update_vehicle_attributes request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .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 .apply_defaults timeout: @config.rpcs.update_vehicle_attributes.timeout, metadata: , retry_policy: @config.rpcs.update_vehicle_attributes.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @vehicle_service_stub.update_vehicle_attributes request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |