Class: Google::Maps::FleetEngine::V1::VehicleService::Client
- Inherits:
-
Object
- Object
- Google::Maps::FleetEngine::V1::VehicleService::Client
- 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
-
.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) {|response, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Instantiates a new vehicle associated with an on-demand rideshare or deliveries provider.
-
#get_vehicle(request, options = nil) {|response, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Returns a vehicle from the Fleet Engine.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new VehicleService client object.
-
#list_vehicles(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Maps::FleetEngine::V1::Vehicle>
Returns a paginated list of vehicles associated with a provider that match the request options.
-
#search_vehicles(request, options = nil) {|response, 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) {|response, operation| ... } ⇒ ::Google::Maps::FleetEngine::V1::Vehicle
Writes updated vehicle data to the Fleet Engine.
-
#update_vehicle_attributes(request, options = nil) {|response, 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 client object.
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 |
# 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 ) end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the VehicleService Client class.
See Configuration for a description of the configuration fields.
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.
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.
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 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 304 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 [:"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 .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.call_rpc :create_vehicle, request, options: do |response, operation| yield response, operation if block_given? return response 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.
408 409 410 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 445 446 447 448 449 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 408 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 [:"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 .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.call_rpc :get_vehicle, request, options: do |response, operation| yield response, operation if block_given? return response 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.
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 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 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 844 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 [:"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 .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.call_rpc :list_vehicles, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @vehicle_service_stub, :list_vehicles, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => 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.
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 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 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 1063 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 [:"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 .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.call_rpc :search_vehicles, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#universe_domain ⇒ String
The effective universe domain
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.
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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 537 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 [:"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 .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.call_rpc :update_vehicle, request, options: do |response, operation| yield response, operation if block_given? return response 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.
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 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 |
# File 'lib/google/maps/fleet_engine/v1/vehicle_service/client.rb', line 636 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 [:"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 .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.call_rpc :update_vehicle_attributes, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |