google-maps-route_optimization-v1 0.a → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +122 -0
  4. data/README.md +153 -8
  5. data/lib/google/maps/route_optimization/v1/rest.rb +37 -0
  6. data/lib/google/maps/route_optimization/v1/route_optimization/client.rb +1272 -0
  7. data/lib/google/maps/route_optimization/v1/route_optimization/credentials.rb +47 -0
  8. data/lib/google/maps/route_optimization/v1/route_optimization/operations.rb +843 -0
  9. data/lib/google/maps/route_optimization/v1/route_optimization/rest/client.rb +1201 -0
  10. data/lib/google/maps/route_optimization/v1/route_optimization/rest/operations.rb +927 -0
  11. data/lib/google/maps/route_optimization/v1/route_optimization/rest/service_stub.rb +361 -0
  12. data/lib/google/maps/route_optimization/v1/route_optimization/rest.rb +68 -0
  13. data/lib/google/maps/route_optimization/v1/route_optimization.rb +71 -0
  14. data/lib/google/maps/route_optimization/v1/version.rb +7 -2
  15. data/lib/google/maps/route_optimization/v1.rb +45 -0
  16. data/lib/google/maps/routeoptimization/v1/route_optimization_service_pb.rb +93 -0
  17. data/lib/google/maps/routeoptimization/v1/route_optimization_service_services_pb.rb +148 -0
  18. data/lib/google-maps-route_optimization-v1.rb +21 -0
  19. data/proto_docs/README.md +4 -0
  20. data/proto_docs/google/api/client.rb +593 -0
  21. data/proto_docs/google/api/field_behavior.rb +85 -0
  22. data/proto_docs/google/api/launch_stage.rb +71 -0
  23. data/proto_docs/google/api/resource.rb +227 -0
  24. data/proto_docs/google/longrunning/operations.rb +191 -0
  25. data/proto_docs/google/maps/routeoptimization/v1/route_optimization_service.rb +2931 -0
  26. data/proto_docs/google/protobuf/any.rb +145 -0
  27. data/proto_docs/google/protobuf/duration.rb +98 -0
  28. data/proto_docs/google/protobuf/empty.rb +34 -0
  29. data/proto_docs/google/protobuf/timestamp.rb +128 -0
  30. data/proto_docs/google/rpc/status.rb +48 -0
  31. data/proto_docs/google/type/latlng.rb +38 -0
  32. metadata +66 -9
@@ -0,0 +1,1272 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2026 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/maps/routeoptimization/v1/route_optimization_service_pb"
21
+
22
+ module Google
23
+ module Maps
24
+ module RouteOptimization
25
+ module V1
26
+ module RouteOptimization
27
+ ##
28
+ # Client for the RouteOptimization service.
29
+ #
30
+ # A service for optimizing vehicle tours.
31
+ #
32
+ # Validity of certain types of fields:
33
+ #
34
+ # * `google.protobuf.Timestamp`
35
+ # * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00.
36
+ # * seconds must be in [0, 253402300799],
37
+ # i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
38
+ # * nanos must be unset or set to 0.
39
+ # * `google.protobuf.Duration`
40
+ # * seconds must be in [0, 253402300799],
41
+ # i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
42
+ # * nanos must be unset or set to 0.
43
+ # * `google.type.LatLng`
44
+ # * latitude must be in [-90.0, 90.0].
45
+ # * longitude must be in [-180.0, 180.0].
46
+ # * at least one of latitude and longitude must be non-zero.
47
+ #
48
+ class Client
49
+ # @private
50
+ API_VERSION = ""
51
+
52
+ # @private
53
+ DEFAULT_ENDPOINT_TEMPLATE = "routeoptimization.$UNIVERSE_DOMAIN$"
54
+
55
+ # @private
56
+ attr_reader :route_optimization_stub
57
+
58
+ ##
59
+ # Configure the RouteOptimization Client class.
60
+ #
61
+ # See {::Google::Maps::RouteOptimization::V1::RouteOptimization::Client::Configuration}
62
+ # for a description of the configuration fields.
63
+ #
64
+ # @example
65
+ #
66
+ # # Modify the configuration for all RouteOptimization clients
67
+ # ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.configure do |config|
68
+ # config.timeout = 10.0
69
+ # end
70
+ #
71
+ # @yield [config] Configure the Client client.
72
+ # @yieldparam config [Client::Configuration]
73
+ #
74
+ # @return [Client::Configuration]
75
+ #
76
+ def self.configure
77
+ @configure ||= begin
78
+ namespace = ["Google", "Maps", "RouteOptimization", "V1"]
79
+ parent_config = while namespace.any?
80
+ parent_name = namespace.join "::"
81
+ parent_const = const_get parent_name
82
+ break parent_const.configure if parent_const.respond_to? :configure
83
+ namespace.pop
84
+ end
85
+ default_config = Client::Configuration.new parent_config
86
+
87
+ default_config.rpcs.optimize_tours.timeout = 3600.0
88
+ default_config.rpcs.optimize_tours.retry_policy = {
89
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
90
+ }
91
+
92
+ default_config
93
+ end
94
+ yield @configure if block_given?
95
+ @configure
96
+ end
97
+
98
+ ##
99
+ # Configure the RouteOptimization Client instance.
100
+ #
101
+ # The configuration is set to the derived mode, meaning that values can be changed,
102
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
103
+ # should be made on {Client.configure}.
104
+ #
105
+ # See {::Google::Maps::RouteOptimization::V1::RouteOptimization::Client::Configuration}
106
+ # for a description of the configuration fields.
107
+ #
108
+ # @yield [config] Configure the Client client.
109
+ # @yieldparam config [Client::Configuration]
110
+ #
111
+ # @return [Client::Configuration]
112
+ #
113
+ def configure
114
+ yield @config if block_given?
115
+ @config
116
+ end
117
+
118
+ ##
119
+ # The effective universe domain
120
+ #
121
+ # @return [String]
122
+ #
123
+ def universe_domain
124
+ @route_optimization_stub.universe_domain
125
+ end
126
+
127
+ ##
128
+ # Create a new RouteOptimization client object.
129
+ #
130
+ # @example
131
+ #
132
+ # # Create a client using the default configuration
133
+ # client = ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new
134
+ #
135
+ # # Create a client using a custom configuration
136
+ # client = ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new do |config|
137
+ # config.timeout = 10.0
138
+ # end
139
+ #
140
+ # @yield [config] Configure the RouteOptimization client.
141
+ # @yieldparam config [Client::Configuration]
142
+ #
143
+ def initialize
144
+ # These require statements are intentionally placed here to initialize
145
+ # the gRPC module only when it's required.
146
+ # See https://github.com/googleapis/toolkit/issues/446
147
+ require "gapic/grpc"
148
+ require "google/maps/routeoptimization/v1/route_optimization_service_services_pb"
149
+
150
+ # Create the configuration object
151
+ @config = Configuration.new Client.configure
152
+
153
+ # Yield the configuration if needed
154
+ yield @config if block_given?
155
+
156
+ # Create credentials
157
+ credentials = @config.credentials
158
+ # Use self-signed JWT if the endpoint is unchanged from default,
159
+ # but only if the default endpoint does not have a region prefix.
160
+ enable_self_signed_jwt = @config.endpoint.nil? ||
161
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
162
+ !@config.endpoint.split(".").first.include?("-"))
163
+ credentials ||= Credentials.default scope: @config.scope,
164
+ enable_self_signed_jwt: enable_self_signed_jwt
165
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
166
+ credentials = Credentials.new credentials, scope: @config.scope
167
+ end
168
+ @quota_project_id = @config.quota_project
169
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
170
+
171
+ @operations_client = Operations.new do |config|
172
+ config.credentials = credentials
173
+ config.quota_project = @quota_project_id
174
+ config.endpoint = @config.endpoint
175
+ config.universe_domain = @config.universe_domain
176
+ end
177
+
178
+ @route_optimization_stub = ::Gapic::ServiceStub.new(
179
+ ::Google::Maps::RouteOptimization::V1::RouteOptimization::Stub,
180
+ credentials: credentials,
181
+ endpoint: @config.endpoint,
182
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
183
+ universe_domain: @config.universe_domain,
184
+ channel_args: @config.channel_args,
185
+ interceptors: @config.interceptors,
186
+ channel_pool_config: @config.channel_pool,
187
+ logger: @config.logger
188
+ )
189
+
190
+ @route_optimization_stub.stub_logger&.info do |entry|
191
+ entry.set_system_name
192
+ entry.set_service
193
+ entry.message = "Created client for #{entry.service}"
194
+ entry.set_credentials_fields credentials
195
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
196
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
197
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
198
+ end
199
+ end
200
+
201
+ ##
202
+ # Get the associated client for long-running operations.
203
+ #
204
+ # @return [::Google::Maps::RouteOptimization::V1::RouteOptimization::Operations]
205
+ #
206
+ attr_reader :operations_client
207
+
208
+ ##
209
+ # The logger used for request/response debug logging.
210
+ #
211
+ # @return [Logger]
212
+ #
213
+ def logger
214
+ @route_optimization_stub.logger
215
+ end
216
+
217
+ # Service calls
218
+
219
+ ##
220
+ # Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an
221
+ # `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of
222
+ # routes to be performed by vehicles minimizing the overall cost.
223
+ #
224
+ # A `ShipmentModel` model consists mainly of `Shipment`s that need to be
225
+ # carried out and `Vehicle`s that can be used to transport the `Shipment`s.
226
+ # The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically,
227
+ # they assign a series of `Visit`s to each vehicle, where a `Visit`
228
+ # corresponds to a `VisitRequest`, which is a pickup or delivery for a
229
+ # `Shipment`.
230
+ #
231
+ # The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that
232
+ # minimizes the total cost where cost has many components defined in the
233
+ # `ShipmentModel`.
234
+ #
235
+ # @overload optimize_tours(request, options = nil)
236
+ # Pass arguments to `optimize_tours` via a request object, either of type
237
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursRequest} or an equivalent Hash.
238
+ #
239
+ # @param request [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest, ::Hash]
240
+ # A request object representing the call parameters. Required. To specify no
241
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
242
+ # @param options [::Gapic::CallOptions, ::Hash]
243
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
244
+ #
245
+ # @overload optimize_tours(parent: nil, timeout: nil, model: nil, solving_mode: nil, search_mode: nil, injected_first_solution_routes: nil, injected_solution_constraint: nil, refresh_details_routes: nil, interpret_injected_solutions_using_labels: nil, consider_road_traffic: nil, populate_polylines: nil, populate_transition_polylines: nil, allow_large_deadline_despite_interruption_risk: nil, use_geodesic_distances: nil, geodesic_meters_per_second: nil, max_validation_errors: nil, label: nil)
246
+ # Pass arguments to `optimize_tours` via keyword arguments. Note that at
247
+ # least one keyword argument is required. To specify no parameters, or to keep all
248
+ # the default parameter values, pass an empty Hash as a request object (see above).
249
+ #
250
+ # @param parent [::String]
251
+ # Required. Target project or location to make a call.
252
+ #
253
+ # Format:
254
+ # * `projects/{project-id}`
255
+ # * `projects/{project-id}/locations/{location-id}`
256
+ #
257
+ # If no location is specified, a region will be chosen automatically.
258
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
259
+ # If this timeout is set, the server returns a response before the timeout
260
+ # period has elapsed or the server deadline for synchronous requests is
261
+ # reached, whichever is sooner.
262
+ #
263
+ # For asynchronous requests, the server will generate a solution (if
264
+ # possible) before the timeout has elapsed.
265
+ # @param model [::Google::Maps::RouteOptimization::V1::ShipmentModel, ::Hash]
266
+ # Shipment model to solve.
267
+ # @param solving_mode [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest::SolvingMode]
268
+ # By default, the solving mode is `DEFAULT_SOLVE` (0).
269
+ # @param search_mode [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest::SearchMode]
270
+ # Search mode used to solve the request.
271
+ # @param injected_first_solution_routes [::Array<::Google::Maps::RouteOptimization::V1::ShipmentRoute, ::Hash>]
272
+ # Guide the optimization algorithm in finding a first solution that is
273
+ # similar to a previous solution.
274
+ #
275
+ # The model is constrained when the first solution is built.
276
+ # Any shipments not performed on a route are implicitly skipped in the first
277
+ # solution, but they may be performed in successive solutions.
278
+ #
279
+ # The solution must satisfy some basic validity assumptions:
280
+ #
281
+ # * for all routes, `vehicle_index` must be in range and not be duplicated.
282
+ # * for all visits, `shipment_index` and `visit_request_index` must be
283
+ # in range.
284
+ # * a shipment may only be referenced on one route.
285
+ # * the pickup of a pickup-delivery shipment must be performed before
286
+ # the delivery.
287
+ # * no more than one pickup alternative or delivery alternative of
288
+ # a shipment may be performed.
289
+ # * for all routes, times are increasing (i.e., `vehicle_start_time
290
+ # <= visits[0].start_time <= visits[1].start_time ...
291
+ # <= vehicle_end_time`).
292
+ # * a shipment may only be performed on a vehicle that is allowed. A
293
+ # vehicle is allowed if
294
+ # {::Google::Maps::RouteOptimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}
295
+ # is empty or its `vehicle_index` is included in
296
+ # {::Google::Maps::RouteOptimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}.
297
+ #
298
+ # If the injected solution is not feasible, a validation error is not
299
+ # necessarily returned and an error indicating infeasibility may be returned
300
+ # instead.
301
+ # @param injected_solution_constraint [::Google::Maps::RouteOptimization::V1::InjectedSolutionConstraint, ::Hash]
302
+ # Constrain the optimization algorithm to find a final solution that is
303
+ # similar to a previous solution. For example, this may be used to freeze
304
+ # portions of routes which have already been completed or which are to be
305
+ # completed but must not be modified.
306
+ #
307
+ # If the injected solution is not feasible, a validation error is not
308
+ # necessarily returned and an error indicating infeasibility may be returned
309
+ # instead.
310
+ # @param refresh_details_routes [::Array<::Google::Maps::RouteOptimization::V1::ShipmentRoute, ::Hash>]
311
+ # If non-empty, the given routes will be refreshed, without modifying their
312
+ # underlying sequence of visits or travel times: only other details will be
313
+ # updated. This does not solve the model.
314
+ #
315
+ # As of 2020/11, this only populates the polylines of non-empty routes and
316
+ # requires that `populate_polylines` is true.
317
+ #
318
+ # The `route_polyline` fields of the passed-in routes may be inconsistent
319
+ # with route `transitions`.
320
+ #
321
+ # This field must not be used together with `injected_first_solution_routes`
322
+ # or `injected_solution_constraint`.
323
+ #
324
+ # `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
325
+ # Polylines are still populated between all visits in all non-empty routes
326
+ # regardless of whether the related shipments or vehicles are ignored.
327
+ # @param interpret_injected_solutions_using_labels [::Boolean]
328
+ # If true:
329
+ #
330
+ # * uses
331
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label}
332
+ # instead of `vehicle_index` to
333
+ # match routes in an injected solution with vehicles in the request;
334
+ # reuses the mapping of original
335
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
336
+ # to new
337
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
338
+ # to update
339
+ # {::Google::Maps::RouteOptimization::V1::InjectedSolutionConstraint::ConstraintRelaxation#vehicle_indices ConstraintRelaxation.vehicle_indices}
340
+ # if non-empty, but the mapping must be unambiguous (i.e., multiple
341
+ # `ShipmentRoute`s must not share the same original `vehicle_index`).
342
+ # * uses
343
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label}
344
+ # instead of `shipment_index`
345
+ # to match visits in an injected solution with shipments in the request;
346
+ # * uses
347
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label}
348
+ # instead of
349
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#index SkippedShipment.index}
350
+ # to
351
+ # match skipped shipments in the injected solution with request
352
+ # shipments.
353
+ #
354
+ # This interpretation applies to the `injected_first_solution_routes`,
355
+ # `injected_solution_constraint`, and `refresh_details_routes` fields.
356
+ # It can be used when shipment or vehicle indices in the request have
357
+ # changed since the solution was created, perhaps because shipments or
358
+ # vehicles have been removed from or added to the request.
359
+ #
360
+ # If true, labels in the following categories must appear at most once in
361
+ # their category:
362
+ #
363
+ # * {::Google::Maps::RouteOptimization::V1::Vehicle#label Vehicle.label} in the
364
+ # request;
365
+ # * {::Google::Maps::RouteOptimization::V1::Shipment#label Shipment.label} in
366
+ # the request;
367
+ # * {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label} in the injected solution;
368
+ # * {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label} and {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label} in
369
+ # the injected solution (except pickup/delivery visit pairs, whose
370
+ # `shipment_label` must appear twice).
371
+ #
372
+ # If a `vehicle_label` in the injected solution does not correspond to a
373
+ # request vehicle, the corresponding route is removed from the solution
374
+ # along with its visits. If a `shipment_label` in the injected solution does
375
+ # not correspond to a request shipment, the corresponding visit is removed
376
+ # from the solution. If a
377
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label}
378
+ # in the injected solution does not correspond to a request shipment, the
379
+ # `SkippedShipment` is removed from the solution.
380
+ #
381
+ # Removing route visits or entire routes from an injected solution may
382
+ # have an effect on the implied constraints, which may lead to change in
383
+ # solution, validation errors, or infeasibility.
384
+ #
385
+ # NOTE: The caller must ensure that each
386
+ # {::Google::Maps::RouteOptimization::V1::Vehicle#label Vehicle.label} (resp.
387
+ # {::Google::Maps::RouteOptimization::V1::Shipment#label Shipment.label}) uniquely
388
+ # identifies a vehicle (resp. shipment) entity used across the two relevant
389
+ # requests: the past request that produced the `OptimizeToursResponse` used
390
+ # in the injected solution and the current request that includes the injected
391
+ # solution. The uniqueness checks described above are not enough to guarantee
392
+ # this requirement.
393
+ # @param consider_road_traffic [::Boolean]
394
+ # Consider traffic estimation in calculating `ShipmentRoute` fields
395
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Transition#travel_duration Transition.travel_duration},
396
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#start_time Visit.start_time},
397
+ # and `vehicle_end_time`; in setting the
398
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#has_traffic_infeasibilities ShipmentRoute.has_traffic_infeasibilities}
399
+ # field, and in calculating the
400
+ # [OptimizeToursResponse.total_cost][google.maps.routeoptimization.v1.OptimizeToursResponse.total_cost]
401
+ # field.
402
+ # @param populate_polylines [::Boolean]
403
+ # If true, polylines will be populated in response `ShipmentRoute`s.
404
+ # @param populate_transition_polylines [::Boolean]
405
+ # If true, polylines and route tokens will be populated in response
406
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#transitions ShipmentRoute.transitions}.
407
+ # @param allow_large_deadline_despite_interruption_risk [::Boolean]
408
+ # If this is set, then the request can have a deadline
409
+ # (see https://grpc.io/blog/deadlines) of up to 60 minutes.
410
+ # Otherwise, the maximum deadline is only 30 minutes.
411
+ # Note that long-lived requests have a significantly larger (but still small)
412
+ # risk of interruption.
413
+ # @param use_geodesic_distances [::Boolean]
414
+ # If true, travel distances will be computed using geodesic distances instead
415
+ # of Google Maps distances, and travel times will be computed using geodesic
416
+ # distances with a speed defined by `geodesic_meters_per_second`.
417
+ # @param geodesic_meters_per_second [::Float]
418
+ # When `use_geodesic_distances` is true, this field must be set and defines
419
+ # the speed applied to compute travel times. Its value must be at least 1.0
420
+ # meters/seconds.
421
+ # @param max_validation_errors [::Integer]
422
+ # Truncates the number of validation errors returned. These errors are
423
+ # typically attached to an INVALID_ARGUMENT error payload as a BadRequest
424
+ # error detail (https://cloud.google.com/apis/design/errors#error_details),
425
+ # unless solving_mode=VALIDATE_ONLY: see the
426
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursResponse#validation_errors OptimizeToursResponse.validation_errors}
427
+ # field.
428
+ # This defaults to 100 and is capped at 10,000.
429
+ # @param label [::String]
430
+ # Label that may be used to identify this request, reported back in the
431
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursResponse#request_label OptimizeToursResponse.request_label}.
432
+ #
433
+ # @yield [response, operation] Access the result along with the RPC operation
434
+ # @yieldparam response [::Google::Maps::RouteOptimization::V1::OptimizeToursResponse]
435
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
436
+ #
437
+ # @return [::Google::Maps::RouteOptimization::V1::OptimizeToursResponse]
438
+ #
439
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
440
+ #
441
+ # @example Basic example
442
+ # require "google/maps/route_optimization/v1"
443
+ #
444
+ # # Create a client object. The client can be reused for multiple calls.
445
+ # client = Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new
446
+ #
447
+ # # Create a request. To set request fields, pass in keyword arguments.
448
+ # request = Google::Maps::RouteOptimization::V1::OptimizeToursRequest.new
449
+ #
450
+ # # Call the optimize_tours method.
451
+ # result = client.optimize_tours request
452
+ #
453
+ # # The returned object is of type Google::Maps::RouteOptimization::V1::OptimizeToursResponse.
454
+ # p result
455
+ #
456
+ def optimize_tours request, options = nil
457
+ raise ::ArgumentError, "request must be provided" if request.nil?
458
+
459
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::RouteOptimization::V1::OptimizeToursRequest
460
+
461
+ # Converts hash and nil to an options object
462
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
463
+
464
+ # Customize the options with defaults
465
+ metadata = @config.rpcs.optimize_tours.metadata.to_h
466
+
467
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
468
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
469
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
470
+ gapic_version: ::Google::Maps::RouteOptimization::V1::VERSION
471
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
472
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
473
+
474
+ header_params = {}
475
+ if request.parent
476
+ header_params["parent"] = request.parent
477
+ end
478
+
479
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
480
+ metadata[:"x-goog-request-params"] ||= request_params_header
481
+
482
+ options.apply_defaults timeout: @config.rpcs.optimize_tours.timeout,
483
+ metadata: metadata,
484
+ retry_policy: @config.rpcs.optimize_tours.retry_policy
485
+
486
+ options.apply_defaults timeout: @config.timeout,
487
+ metadata: @config.metadata,
488
+ retry_policy: @config.retry_policy
489
+
490
+ @route_optimization_stub.call_rpc :optimize_tours, request, options: options do |response, operation|
491
+ yield response, operation if block_given?
492
+ end
493
+ rescue ::GRPC::BadStatus => e
494
+ raise ::Google::Cloud::Error.from_error(e)
495
+ end
496
+
497
+ ##
498
+ # Optimizes vehicle tours for one or more `OptimizeToursRequest`
499
+ # messages as a batch.
500
+ #
501
+ # This method is a Long Running Operation (LRO). The inputs for optimization
502
+ # (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse`
503
+ # messages) are read from and written to Cloud Storage in user-specified
504
+ # format. Like the `OptimizeTours` method, each `OptimizeToursRequest`
505
+ # contains a `ShipmentModel` and returns an `OptimizeToursResponse`
506
+ # containing `ShipmentRoute` fields, which are a set of routes to be
507
+ # performed by vehicles minimizing the overall cost.
508
+ #
509
+ # The user can poll `operations.get` to check the status of the LRO:
510
+ #
511
+ # If the LRO `done` field is false, then at least one request is still
512
+ # being processed. Other requests may have completed successfully and their
513
+ # results are available in Cloud Storage.
514
+ #
515
+ # If the LRO's `done` field is true, then all requests have been processed.
516
+ # Any successfully processed requests will have their results available in
517
+ # Cloud Storage. Any requests that failed will not have their results
518
+ # available in Cloud Storage. If the LRO's `error` field is set, then it
519
+ # contains the error from one of the failed requests.
520
+ #
521
+ # @overload batch_optimize_tours(request, options = nil)
522
+ # Pass arguments to `batch_optimize_tours` via a request object, either of type
523
+ # {::Google::Maps::RouteOptimization::V1::BatchOptimizeToursRequest} or an equivalent Hash.
524
+ #
525
+ # @param request [::Google::Maps::RouteOptimization::V1::BatchOptimizeToursRequest, ::Hash]
526
+ # A request object representing the call parameters. Required. To specify no
527
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
528
+ # @param options [::Gapic::CallOptions, ::Hash]
529
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
530
+ #
531
+ # @overload batch_optimize_tours(parent: nil, model_configs: nil)
532
+ # Pass arguments to `batch_optimize_tours` via keyword arguments. Note that at
533
+ # least one keyword argument is required. To specify no parameters, or to keep all
534
+ # the default parameter values, pass an empty Hash as a request object (see above).
535
+ #
536
+ # @param parent [::String]
537
+ # Required. Target project and location to make a call.
538
+ #
539
+ # Format:
540
+ # * `projects/{project-id}`
541
+ # * `projects/{project-id}/locations/{location-id}`
542
+ #
543
+ # If no location is specified, a region will be chosen automatically.
544
+ # @param model_configs [::Array<::Google::Maps::RouteOptimization::V1::BatchOptimizeToursRequest::AsyncModelConfig, ::Hash>]
545
+ # Required. Input/Output information each purchase model, such as file paths
546
+ # and data formats.
547
+ #
548
+ # @yield [response, operation] Access the result along with the RPC operation
549
+ # @yieldparam response [::Gapic::Operation]
550
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
551
+ #
552
+ # @return [::Gapic::Operation]
553
+ #
554
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
555
+ #
556
+ # @example Basic example
557
+ # require "google/maps/route_optimization/v1"
558
+ #
559
+ # # Create a client object. The client can be reused for multiple calls.
560
+ # client = Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new
561
+ #
562
+ # # Create a request. To set request fields, pass in keyword arguments.
563
+ # request = Google::Maps::RouteOptimization::V1::BatchOptimizeToursRequest.new
564
+ #
565
+ # # Call the batch_optimize_tours method.
566
+ # result = client.batch_optimize_tours request
567
+ #
568
+ # # The returned object is of type Gapic::Operation. You can use it to
569
+ # # check the status of an operation, cancel it, or wait for results.
570
+ # # Here is how to wait for a response.
571
+ # result.wait_until_done! timeout: 60
572
+ # if result.response?
573
+ # p result.response
574
+ # else
575
+ # puts "No response received."
576
+ # end
577
+ #
578
+ def batch_optimize_tours request, options = nil
579
+ raise ::ArgumentError, "request must be provided" if request.nil?
580
+
581
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::RouteOptimization::V1::BatchOptimizeToursRequest
582
+
583
+ # Converts hash and nil to an options object
584
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
585
+
586
+ # Customize the options with defaults
587
+ metadata = @config.rpcs.batch_optimize_tours.metadata.to_h
588
+
589
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
590
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
591
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
592
+ gapic_version: ::Google::Maps::RouteOptimization::V1::VERSION
593
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
594
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
595
+
596
+ header_params = {}
597
+ if request.parent
598
+ header_params["parent"] = request.parent
599
+ end
600
+
601
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
602
+ metadata[:"x-goog-request-params"] ||= request_params_header
603
+
604
+ options.apply_defaults timeout: @config.rpcs.batch_optimize_tours.timeout,
605
+ metadata: metadata,
606
+ retry_policy: @config.rpcs.batch_optimize_tours.retry_policy
607
+
608
+ options.apply_defaults timeout: @config.timeout,
609
+ metadata: @config.metadata,
610
+ retry_policy: @config.retry_policy
611
+
612
+ @route_optimization_stub.call_rpc :batch_optimize_tours, request, options: options do |response, operation|
613
+ response = ::Gapic::Operation.new response, @operations_client, options: options
614
+ yield response, operation if block_given?
615
+ throw :response, response
616
+ end
617
+ rescue ::GRPC::BadStatus => e
618
+ raise ::Google::Cloud::Error.from_error(e)
619
+ end
620
+
621
+ ##
622
+ # This is a variant of the
623
+ # {::Google::Maps::RouteOptimization::V1::RouteOptimization::Client#optimize_tours OptimizeTours}
624
+ # method designed for
625
+ # optimizations with large timeout values. It should be preferred over the
626
+ # `OptimizeTours` method for optimizations that take longer than
627
+ # a few minutes.
628
+ #
629
+ # The returned {::Google::Longrunning::Operation long-running operation} (LRO)
630
+ # will have a name of the format
631
+ # `<parent>/operations/<operation_id>` and can be used to track
632
+ # progress of the computation. The
633
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
634
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursLongRunningMetadata OptimizeToursLongRunningMetadata}.
635
+ # The {::Google::Longrunning::Operation#response response} field type is
636
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursResponse OptimizeToursResponse},
637
+ # if successful.
638
+ #
639
+ # Experimental: See
640
+ # https://developers.google.com/maps/tt/route-optimization/experimental/otlr/make-request
641
+ # for more details.
642
+ #
643
+ # @overload optimize_tours_long_running(request, options = nil)
644
+ # Pass arguments to `optimize_tours_long_running` via a request object, either of type
645
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursRequest} or an equivalent Hash.
646
+ #
647
+ # @param request [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest, ::Hash]
648
+ # A request object representing the call parameters. Required. To specify no
649
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
650
+ # @param options [::Gapic::CallOptions, ::Hash]
651
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
652
+ #
653
+ # @overload optimize_tours_long_running(parent: nil, timeout: nil, model: nil, solving_mode: nil, search_mode: nil, injected_first_solution_routes: nil, injected_solution_constraint: nil, refresh_details_routes: nil, interpret_injected_solutions_using_labels: nil, consider_road_traffic: nil, populate_polylines: nil, populate_transition_polylines: nil, allow_large_deadline_despite_interruption_risk: nil, use_geodesic_distances: nil, geodesic_meters_per_second: nil, max_validation_errors: nil, label: nil)
654
+ # Pass arguments to `optimize_tours_long_running` via keyword arguments. Note that at
655
+ # least one keyword argument is required. To specify no parameters, or to keep all
656
+ # the default parameter values, pass an empty Hash as a request object (see above).
657
+ #
658
+ # @param parent [::String]
659
+ # Required. Target project or location to make a call.
660
+ #
661
+ # Format:
662
+ # * `projects/{project-id}`
663
+ # * `projects/{project-id}/locations/{location-id}`
664
+ #
665
+ # If no location is specified, a region will be chosen automatically.
666
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
667
+ # If this timeout is set, the server returns a response before the timeout
668
+ # period has elapsed or the server deadline for synchronous requests is
669
+ # reached, whichever is sooner.
670
+ #
671
+ # For asynchronous requests, the server will generate a solution (if
672
+ # possible) before the timeout has elapsed.
673
+ # @param model [::Google::Maps::RouteOptimization::V1::ShipmentModel, ::Hash]
674
+ # Shipment model to solve.
675
+ # @param solving_mode [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest::SolvingMode]
676
+ # By default, the solving mode is `DEFAULT_SOLVE` (0).
677
+ # @param search_mode [::Google::Maps::RouteOptimization::V1::OptimizeToursRequest::SearchMode]
678
+ # Search mode used to solve the request.
679
+ # @param injected_first_solution_routes [::Array<::Google::Maps::RouteOptimization::V1::ShipmentRoute, ::Hash>]
680
+ # Guide the optimization algorithm in finding a first solution that is
681
+ # similar to a previous solution.
682
+ #
683
+ # The model is constrained when the first solution is built.
684
+ # Any shipments not performed on a route are implicitly skipped in the first
685
+ # solution, but they may be performed in successive solutions.
686
+ #
687
+ # The solution must satisfy some basic validity assumptions:
688
+ #
689
+ # * for all routes, `vehicle_index` must be in range and not be duplicated.
690
+ # * for all visits, `shipment_index` and `visit_request_index` must be
691
+ # in range.
692
+ # * a shipment may only be referenced on one route.
693
+ # * the pickup of a pickup-delivery shipment must be performed before
694
+ # the delivery.
695
+ # * no more than one pickup alternative or delivery alternative of
696
+ # a shipment may be performed.
697
+ # * for all routes, times are increasing (i.e., `vehicle_start_time
698
+ # <= visits[0].start_time <= visits[1].start_time ...
699
+ # <= vehicle_end_time`).
700
+ # * a shipment may only be performed on a vehicle that is allowed. A
701
+ # vehicle is allowed if
702
+ # {::Google::Maps::RouteOptimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}
703
+ # is empty or its `vehicle_index` is included in
704
+ # {::Google::Maps::RouteOptimization::V1::Shipment#allowed_vehicle_indices Shipment.allowed_vehicle_indices}.
705
+ #
706
+ # If the injected solution is not feasible, a validation error is not
707
+ # necessarily returned and an error indicating infeasibility may be returned
708
+ # instead.
709
+ # @param injected_solution_constraint [::Google::Maps::RouteOptimization::V1::InjectedSolutionConstraint, ::Hash]
710
+ # Constrain the optimization algorithm to find a final solution that is
711
+ # similar to a previous solution. For example, this may be used to freeze
712
+ # portions of routes which have already been completed or which are to be
713
+ # completed but must not be modified.
714
+ #
715
+ # If the injected solution is not feasible, a validation error is not
716
+ # necessarily returned and an error indicating infeasibility may be returned
717
+ # instead.
718
+ # @param refresh_details_routes [::Array<::Google::Maps::RouteOptimization::V1::ShipmentRoute, ::Hash>]
719
+ # If non-empty, the given routes will be refreshed, without modifying their
720
+ # underlying sequence of visits or travel times: only other details will be
721
+ # updated. This does not solve the model.
722
+ #
723
+ # As of 2020/11, this only populates the polylines of non-empty routes and
724
+ # requires that `populate_polylines` is true.
725
+ #
726
+ # The `route_polyline` fields of the passed-in routes may be inconsistent
727
+ # with route `transitions`.
728
+ #
729
+ # This field must not be used together with `injected_first_solution_routes`
730
+ # or `injected_solution_constraint`.
731
+ #
732
+ # `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
733
+ # Polylines are still populated between all visits in all non-empty routes
734
+ # regardless of whether the related shipments or vehicles are ignored.
735
+ # @param interpret_injected_solutions_using_labels [::Boolean]
736
+ # If true:
737
+ #
738
+ # * uses
739
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label}
740
+ # instead of `vehicle_index` to
741
+ # match routes in an injected solution with vehicles in the request;
742
+ # reuses the mapping of original
743
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
744
+ # to new
745
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_index ShipmentRoute.vehicle_index}
746
+ # to update
747
+ # {::Google::Maps::RouteOptimization::V1::InjectedSolutionConstraint::ConstraintRelaxation#vehicle_indices ConstraintRelaxation.vehicle_indices}
748
+ # if non-empty, but the mapping must be unambiguous (i.e., multiple
749
+ # `ShipmentRoute`s must not share the same original `vehicle_index`).
750
+ # * uses
751
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label}
752
+ # instead of `shipment_index`
753
+ # to match visits in an injected solution with shipments in the request;
754
+ # * uses
755
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label}
756
+ # instead of
757
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#index SkippedShipment.index}
758
+ # to
759
+ # match skipped shipments in the injected solution with request
760
+ # shipments.
761
+ #
762
+ # This interpretation applies to the `injected_first_solution_routes`,
763
+ # `injected_solution_constraint`, and `refresh_details_routes` fields.
764
+ # It can be used when shipment or vehicle indices in the request have
765
+ # changed since the solution was created, perhaps because shipments or
766
+ # vehicles have been removed from or added to the request.
767
+ #
768
+ # If true, labels in the following categories must appear at most once in
769
+ # their category:
770
+ #
771
+ # * {::Google::Maps::RouteOptimization::V1::Vehicle#label Vehicle.label} in the
772
+ # request;
773
+ # * {::Google::Maps::RouteOptimization::V1::Shipment#label Shipment.label} in
774
+ # the request;
775
+ # * {::Google::Maps::RouteOptimization::V1::ShipmentRoute#vehicle_label ShipmentRoute.vehicle_label} in the injected solution;
776
+ # * {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label} and {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#shipment_label ShipmentRoute.Visit.shipment_label} in
777
+ # the injected solution (except pickup/delivery visit pairs, whose
778
+ # `shipment_label` must appear twice).
779
+ #
780
+ # If a `vehicle_label` in the injected solution does not correspond to a
781
+ # request vehicle, the corresponding route is removed from the solution
782
+ # along with its visits. If a `shipment_label` in the injected solution does
783
+ # not correspond to a request shipment, the corresponding visit is removed
784
+ # from the solution. If a
785
+ # {::Google::Maps::RouteOptimization::V1::SkippedShipment#label SkippedShipment.label}
786
+ # in the injected solution does not correspond to a request shipment, the
787
+ # `SkippedShipment` is removed from the solution.
788
+ #
789
+ # Removing route visits or entire routes from an injected solution may
790
+ # have an effect on the implied constraints, which may lead to change in
791
+ # solution, validation errors, or infeasibility.
792
+ #
793
+ # NOTE: The caller must ensure that each
794
+ # {::Google::Maps::RouteOptimization::V1::Vehicle#label Vehicle.label} (resp.
795
+ # {::Google::Maps::RouteOptimization::V1::Shipment#label Shipment.label}) uniquely
796
+ # identifies a vehicle (resp. shipment) entity used across the two relevant
797
+ # requests: the past request that produced the `OptimizeToursResponse` used
798
+ # in the injected solution and the current request that includes the injected
799
+ # solution. The uniqueness checks described above are not enough to guarantee
800
+ # this requirement.
801
+ # @param consider_road_traffic [::Boolean]
802
+ # Consider traffic estimation in calculating `ShipmentRoute` fields
803
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Transition#travel_duration Transition.travel_duration},
804
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute::Visit#start_time Visit.start_time},
805
+ # and `vehicle_end_time`; in setting the
806
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#has_traffic_infeasibilities ShipmentRoute.has_traffic_infeasibilities}
807
+ # field, and in calculating the
808
+ # [OptimizeToursResponse.total_cost][google.maps.routeoptimization.v1.OptimizeToursResponse.total_cost]
809
+ # field.
810
+ # @param populate_polylines [::Boolean]
811
+ # If true, polylines will be populated in response `ShipmentRoute`s.
812
+ # @param populate_transition_polylines [::Boolean]
813
+ # If true, polylines and route tokens will be populated in response
814
+ # {::Google::Maps::RouteOptimization::V1::ShipmentRoute#transitions ShipmentRoute.transitions}.
815
+ # @param allow_large_deadline_despite_interruption_risk [::Boolean]
816
+ # If this is set, then the request can have a deadline
817
+ # (see https://grpc.io/blog/deadlines) of up to 60 minutes.
818
+ # Otherwise, the maximum deadline is only 30 minutes.
819
+ # Note that long-lived requests have a significantly larger (but still small)
820
+ # risk of interruption.
821
+ # @param use_geodesic_distances [::Boolean]
822
+ # If true, travel distances will be computed using geodesic distances instead
823
+ # of Google Maps distances, and travel times will be computed using geodesic
824
+ # distances with a speed defined by `geodesic_meters_per_second`.
825
+ # @param geodesic_meters_per_second [::Float]
826
+ # When `use_geodesic_distances` is true, this field must be set and defines
827
+ # the speed applied to compute travel times. Its value must be at least 1.0
828
+ # meters/seconds.
829
+ # @param max_validation_errors [::Integer]
830
+ # Truncates the number of validation errors returned. These errors are
831
+ # typically attached to an INVALID_ARGUMENT error payload as a BadRequest
832
+ # error detail (https://cloud.google.com/apis/design/errors#error_details),
833
+ # unless solving_mode=VALIDATE_ONLY: see the
834
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursResponse#validation_errors OptimizeToursResponse.validation_errors}
835
+ # field.
836
+ # This defaults to 100 and is capped at 10,000.
837
+ # @param label [::String]
838
+ # Label that may be used to identify this request, reported back in the
839
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursResponse#request_label OptimizeToursResponse.request_label}.
840
+ #
841
+ # @yield [response, operation] Access the result along with the RPC operation
842
+ # @yieldparam response [::Gapic::Operation]
843
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
844
+ #
845
+ # @return [::Gapic::Operation]
846
+ #
847
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
848
+ #
849
+ # @example Basic example
850
+ # require "google/maps/route_optimization/v1"
851
+ #
852
+ # # Create a client object. The client can be reused for multiple calls.
853
+ # client = Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new
854
+ #
855
+ # # Create a request. To set request fields, pass in keyword arguments.
856
+ # request = Google::Maps::RouteOptimization::V1::OptimizeToursRequest.new
857
+ #
858
+ # # Call the optimize_tours_long_running method.
859
+ # result = client.optimize_tours_long_running request
860
+ #
861
+ # # The returned object is of type Gapic::Operation. You can use it to
862
+ # # check the status of an operation, cancel it, or wait for results.
863
+ # # Here is how to wait for a response.
864
+ # result.wait_until_done! timeout: 60
865
+ # if result.response?
866
+ # p result.response
867
+ # else
868
+ # puts "No response received."
869
+ # end
870
+ #
871
+ def optimize_tours_long_running request, options = nil
872
+ raise ::ArgumentError, "request must be provided" if request.nil?
873
+
874
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::RouteOptimization::V1::OptimizeToursRequest
875
+
876
+ # Converts hash and nil to an options object
877
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
878
+
879
+ # Customize the options with defaults
880
+ metadata = @config.rpcs.optimize_tours_long_running.metadata.to_h
881
+
882
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
883
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
884
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
885
+ gapic_version: ::Google::Maps::RouteOptimization::V1::VERSION
886
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
887
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
888
+
889
+ header_params = {}
890
+ if request.parent
891
+ header_params["parent"] = request.parent
892
+ end
893
+
894
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
895
+ metadata[:"x-goog-request-params"] ||= request_params_header
896
+
897
+ options.apply_defaults timeout: @config.rpcs.optimize_tours_long_running.timeout,
898
+ metadata: metadata,
899
+ retry_policy: @config.rpcs.optimize_tours_long_running.retry_policy
900
+
901
+ options.apply_defaults timeout: @config.timeout,
902
+ metadata: @config.metadata,
903
+ retry_policy: @config.retry_policy
904
+
905
+ @route_optimization_stub.call_rpc :optimize_tours_long_running, request, options: options do |response, operation|
906
+ response = ::Gapic::Operation.new response, @operations_client, options: options
907
+ yield response, operation if block_given?
908
+ throw :response, response
909
+ end
910
+ rescue ::GRPC::BadStatus => e
911
+ raise ::Google::Cloud::Error.from_error(e)
912
+ end
913
+
914
+ ##
915
+ # This is a variant of the
916
+ # {::Google::Maps::RouteOptimization::V1::RouteOptimization::Client#optimize_tours_long_running OptimizeToursLongRunning}
917
+ # method designed for optimizations with large timeout values and large
918
+ # input/output sizes.
919
+ #
920
+ # The client specifies the URI of the `OptimizeToursRequest` stored
921
+ # in Google Cloud Storage and the server writes the `OptimizeToursResponse`
922
+ # to a client-specified Google Cloud Storage URI.
923
+ #
924
+ # This method should be preferred over the `OptimizeTours` method for
925
+ # optimizations that take longer than a few minutes and input/output sizes
926
+ # that are larger than 8MB, though it can be used for shorter and smaller
927
+ # optimizations as well.
928
+ #
929
+ # The returned {::Google::Longrunning::Operation long-running operation} (LRO)
930
+ # will have a name of the format
931
+ # `<parent>/operations/<operation_id>` and can be used to track
932
+ # progress of the computation. The
933
+ # {::Google::Longrunning::Operation#metadata metadata} field type is
934
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursUriMetadata OptimizeToursLongRunningMetadata}.
935
+ # The {::Google::Longrunning::Operation#response response} field type is
936
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursUriResponse OptimizeToursUriResponse},
937
+ # if successful.
938
+ #
939
+ # Experimental: See
940
+ # https://developers.google.com/maps/tt/route-optimization/experimental/otlr/make-request
941
+ # for more details.
942
+ #
943
+ # @overload optimize_tours_uri(request, options = nil)
944
+ # Pass arguments to `optimize_tours_uri` via a request object, either of type
945
+ # {::Google::Maps::RouteOptimization::V1::OptimizeToursUriRequest} or an equivalent Hash.
946
+ #
947
+ # @param request [::Google::Maps::RouteOptimization::V1::OptimizeToursUriRequest, ::Hash]
948
+ # A request object representing the call parameters. Required. To specify no
949
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
950
+ # @param options [::Gapic::CallOptions, ::Hash]
951
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
952
+ #
953
+ # @overload optimize_tours_uri(parent: nil, input: nil, output: nil)
954
+ # Pass arguments to `optimize_tours_uri` via keyword arguments. Note that at
955
+ # least one keyword argument is required. To specify no parameters, or to keep all
956
+ # the default parameter values, pass an empty Hash as a request object (see above).
957
+ #
958
+ # @param parent [::String]
959
+ # Required. Target project or location to make a call.
960
+ #
961
+ # Format:
962
+ # * `projects/{project-id}`
963
+ # * `projects/{project-id}/locations/{location-id}`
964
+ #
965
+ # If no location is specified, a region will be chosen automatically.
966
+ # @param input [::Google::Maps::RouteOptimization::V1::Uri, ::Hash]
967
+ # Required. The URI of the Cloud Storage object containing the
968
+ # `OptimizeToursRequest`.
969
+ # @param output [::Google::Maps::RouteOptimization::V1::Uri, ::Hash]
970
+ # Required. The URI of the Cloud Storage object that will contain the
971
+ # `OptimizeToursResponse`.
972
+ #
973
+ # @yield [response, operation] Access the result along with the RPC operation
974
+ # @yieldparam response [::Gapic::Operation]
975
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
976
+ #
977
+ # @return [::Gapic::Operation]
978
+ #
979
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
980
+ #
981
+ # @example Basic example
982
+ # require "google/maps/route_optimization/v1"
983
+ #
984
+ # # Create a client object. The client can be reused for multiple calls.
985
+ # client = Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new
986
+ #
987
+ # # Create a request. To set request fields, pass in keyword arguments.
988
+ # request = Google::Maps::RouteOptimization::V1::OptimizeToursUriRequest.new
989
+ #
990
+ # # Call the optimize_tours_uri method.
991
+ # result = client.optimize_tours_uri request
992
+ #
993
+ # # The returned object is of type Gapic::Operation. You can use it to
994
+ # # check the status of an operation, cancel it, or wait for results.
995
+ # # Here is how to wait for a response.
996
+ # result.wait_until_done! timeout: 60
997
+ # if result.response?
998
+ # p result.response
999
+ # else
1000
+ # puts "No response received."
1001
+ # end
1002
+ #
1003
+ def optimize_tours_uri request, options = nil
1004
+ raise ::ArgumentError, "request must be provided" if request.nil?
1005
+
1006
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Maps::RouteOptimization::V1::OptimizeToursUriRequest
1007
+
1008
+ # Converts hash and nil to an options object
1009
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1010
+
1011
+ # Customize the options with defaults
1012
+ metadata = @config.rpcs.optimize_tours_uri.metadata.to_h
1013
+
1014
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
1015
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1016
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1017
+ gapic_version: ::Google::Maps::RouteOptimization::V1::VERSION
1018
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
1019
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1020
+
1021
+ header_params = {}
1022
+ if request.parent
1023
+ header_params["parent"] = request.parent
1024
+ end
1025
+
1026
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1027
+ metadata[:"x-goog-request-params"] ||= request_params_header
1028
+
1029
+ options.apply_defaults timeout: @config.rpcs.optimize_tours_uri.timeout,
1030
+ metadata: metadata,
1031
+ retry_policy: @config.rpcs.optimize_tours_uri.retry_policy
1032
+
1033
+ options.apply_defaults timeout: @config.timeout,
1034
+ metadata: @config.metadata,
1035
+ retry_policy: @config.retry_policy
1036
+
1037
+ @route_optimization_stub.call_rpc :optimize_tours_uri, request, options: options do |response, operation|
1038
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1039
+ yield response, operation if block_given?
1040
+ throw :response, response
1041
+ end
1042
+ rescue ::GRPC::BadStatus => e
1043
+ raise ::Google::Cloud::Error.from_error(e)
1044
+ end
1045
+
1046
+ ##
1047
+ # Configuration class for the RouteOptimization API.
1048
+ #
1049
+ # This class represents the configuration for RouteOptimization,
1050
+ # providing control over timeouts, retry behavior, logging, transport
1051
+ # parameters, and other low-level controls. Certain parameters can also be
1052
+ # applied individually to specific RPCs. See
1053
+ # {::Google::Maps::RouteOptimization::V1::RouteOptimization::Client::Configuration::Rpcs}
1054
+ # for a list of RPCs that can be configured independently.
1055
+ #
1056
+ # Configuration can be applied globally to all clients, or to a single client
1057
+ # on construction.
1058
+ #
1059
+ # @example
1060
+ #
1061
+ # # Modify the global config, setting the timeout for
1062
+ # # optimize_tours to 20 seconds,
1063
+ # # and all remaining timeouts to 10 seconds.
1064
+ # ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.configure do |config|
1065
+ # config.timeout = 10.0
1066
+ # config.rpcs.optimize_tours.timeout = 20.0
1067
+ # end
1068
+ #
1069
+ # # Apply the above configuration only to a new client.
1070
+ # client = ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new do |config|
1071
+ # config.timeout = 10.0
1072
+ # config.rpcs.optimize_tours.timeout = 20.0
1073
+ # end
1074
+ #
1075
+ # @!attribute [rw] endpoint
1076
+ # A custom service endpoint, as a hostname or hostname:port. The default is
1077
+ # nil, indicating to use the default endpoint in the current universe domain.
1078
+ # @return [::String,nil]
1079
+ # @!attribute [rw] credentials
1080
+ # Credentials to send with calls. You may provide any of the following types:
1081
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1082
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1083
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1084
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1085
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1086
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1087
+ # * (`nil`) indicating no credentials
1088
+ #
1089
+ # @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
1090
+ # is deprecated. Providing an unvalidated credential configuration to
1091
+ # Google APIs can compromise the security of your systems and data.
1092
+ #
1093
+ # @example
1094
+ #
1095
+ # # The recommended way to provide credentials is to use the `make_creds` method
1096
+ # # on the appropriate credentials class for your environment.
1097
+ #
1098
+ # require "googleauth"
1099
+ #
1100
+ # credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
1101
+ # json_key_io: ::File.open("/path/to/keyfile.json")
1102
+ # )
1103
+ #
1104
+ # client = ::Google::Maps::RouteOptimization::V1::RouteOptimization::Client.new do |config|
1105
+ # config.credentials = credentials
1106
+ # end
1107
+ #
1108
+ # @note Warning: If you accept a credential configuration (JSON file or Hash) from an
1109
+ # external source for authentication to Google Cloud, you must validate it before
1110
+ # providing it to a Google API client library. Providing an unvalidated credential
1111
+ # configuration to Google APIs can compromise the security of your systems and data.
1112
+ # For more information, refer to [Validate credential configurations from external
1113
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
1114
+ # @return [::Object]
1115
+ # @!attribute [rw] scope
1116
+ # The OAuth scopes
1117
+ # @return [::Array<::String>]
1118
+ # @!attribute [rw] lib_name
1119
+ # The library name as recorded in instrumentation and logging
1120
+ # @return [::String]
1121
+ # @!attribute [rw] lib_version
1122
+ # The library version as recorded in instrumentation and logging
1123
+ # @return [::String]
1124
+ # @!attribute [rw] channel_args
1125
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1126
+ # `GRPC::Core::Channel` object is provided as the credential.
1127
+ # @return [::Hash]
1128
+ # @!attribute [rw] interceptors
1129
+ # An array of interceptors that are run before calls are executed.
1130
+ # @return [::Array<::GRPC::ClientInterceptor>]
1131
+ # @!attribute [rw] timeout
1132
+ # The call timeout in seconds.
1133
+ # @return [::Numeric]
1134
+ # @!attribute [rw] metadata
1135
+ # Additional gRPC headers to be sent with the call.
1136
+ # @return [::Hash{::Symbol=>::String}]
1137
+ # @!attribute [rw] retry_policy
1138
+ # The retry policy. The value is a hash with the following keys:
1139
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1140
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1141
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1142
+ # * `:jitter` (*type:* `Numeric`) - The jitter in seconds. Default: 1.0.
1143
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1144
+ # trigger a retry.
1145
+ # @return [::Hash]
1146
+ # @!attribute [rw] quota_project
1147
+ # A separate project against which to charge quota.
1148
+ # @return [::String]
1149
+ # @!attribute [rw] universe_domain
1150
+ # The universe domain within which to make requests. This determines the
1151
+ # default endpoint URL. The default value of nil uses the environment
1152
+ # universe (usually the default "googleapis.com" universe).
1153
+ # @return [::String,nil]
1154
+ # @!attribute [rw] logger
1155
+ # A custom logger to use for request/response debug logging, or the value
1156
+ # `:default` (the default) to construct a default logger, or `nil` to
1157
+ # explicitly disable logging.
1158
+ # @return [::Logger,:default,nil]
1159
+ #
1160
+ class Configuration
1161
+ extend ::Gapic::Config
1162
+
1163
+ # @private
1164
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
1165
+ DEFAULT_ENDPOINT = "routeoptimization.googleapis.com"
1166
+
1167
+ config_attr :endpoint, nil, ::String, nil
1168
+ config_attr :credentials, nil do |value|
1169
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
1170
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel
1171
+ allowed.any? { |klass| klass === value }
1172
+ end
1173
+ config_attr :scope, nil, ::String, ::Array, nil
1174
+ config_attr :lib_name, nil, ::String, nil
1175
+ config_attr :lib_version, nil, ::String, nil
1176
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1177
+ config_attr :interceptors, nil, ::Array, nil
1178
+ config_attr :timeout, nil, ::Numeric, nil
1179
+ config_attr :metadata, nil, ::Hash, nil
1180
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1181
+ config_attr :quota_project, nil, ::String, nil
1182
+ config_attr :universe_domain, nil, ::String, nil
1183
+ config_attr :logger, :default, ::Logger, nil, :default
1184
+
1185
+ # @private
1186
+ def initialize parent_config = nil
1187
+ @parent_config = parent_config unless parent_config.nil?
1188
+
1189
+ yield self if block_given?
1190
+ end
1191
+
1192
+ ##
1193
+ # Configurations for individual RPCs
1194
+ # @return [Rpcs]
1195
+ #
1196
+ def rpcs
1197
+ @rpcs ||= begin
1198
+ parent_rpcs = nil
1199
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1200
+ Rpcs.new parent_rpcs
1201
+ end
1202
+ end
1203
+
1204
+ ##
1205
+ # Configuration for the channel pool
1206
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
1207
+ #
1208
+ def channel_pool
1209
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
1210
+ end
1211
+
1212
+ ##
1213
+ # Configuration RPC class for the RouteOptimization API.
1214
+ #
1215
+ # Includes fields providing the configuration for each RPC in this service.
1216
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1217
+ # the following configuration fields:
1218
+ #
1219
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1220
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1221
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1222
+ # include the following keys:
1223
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1224
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1225
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1226
+ # * `:jitter` (*type:* `Numeric`) - The jitter in seconds. Default: 1.0.
1227
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1228
+ # trigger a retry.
1229
+ #
1230
+ class Rpcs
1231
+ ##
1232
+ # RPC-specific configuration for `optimize_tours`
1233
+ # @return [::Gapic::Config::Method]
1234
+ #
1235
+ attr_reader :optimize_tours
1236
+ ##
1237
+ # RPC-specific configuration for `batch_optimize_tours`
1238
+ # @return [::Gapic::Config::Method]
1239
+ #
1240
+ attr_reader :batch_optimize_tours
1241
+ ##
1242
+ # RPC-specific configuration for `optimize_tours_long_running`
1243
+ # @return [::Gapic::Config::Method]
1244
+ #
1245
+ attr_reader :optimize_tours_long_running
1246
+ ##
1247
+ # RPC-specific configuration for `optimize_tours_uri`
1248
+ # @return [::Gapic::Config::Method]
1249
+ #
1250
+ attr_reader :optimize_tours_uri
1251
+
1252
+ # @private
1253
+ def initialize parent_rpcs = nil
1254
+ optimize_tours_config = parent_rpcs.optimize_tours if parent_rpcs.respond_to? :optimize_tours
1255
+ @optimize_tours = ::Gapic::Config::Method.new optimize_tours_config
1256
+ batch_optimize_tours_config = parent_rpcs.batch_optimize_tours if parent_rpcs.respond_to? :batch_optimize_tours
1257
+ @batch_optimize_tours = ::Gapic::Config::Method.new batch_optimize_tours_config
1258
+ optimize_tours_long_running_config = parent_rpcs.optimize_tours_long_running if parent_rpcs.respond_to? :optimize_tours_long_running
1259
+ @optimize_tours_long_running = ::Gapic::Config::Method.new optimize_tours_long_running_config
1260
+ optimize_tours_uri_config = parent_rpcs.optimize_tours_uri if parent_rpcs.respond_to? :optimize_tours_uri
1261
+ @optimize_tours_uri = ::Gapic::Config::Method.new optimize_tours_uri_config
1262
+
1263
+ yield self if block_given?
1264
+ end
1265
+ end
1266
+ end
1267
+ end
1268
+ end
1269
+ end
1270
+ end
1271
+ end
1272
+ end