google-cloud-retail-v2 0.12.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/retail/v2/catalog_service/client.rb +18 -6
  4. data/lib/google/cloud/retail/v2/catalog_service/rest/client.rb +1220 -0
  5. data/lib/google/cloud/retail/v2/catalog_service/rest/service_stub.rb +704 -0
  6. data/lib/google/cloud/retail/v2/catalog_service/rest.rb +52 -0
  7. data/lib/google/cloud/retail/v2/catalog_service.rb +6 -0
  8. data/lib/google/cloud/retail/v2/completion_service/client.rb +18 -4
  9. data/lib/google/cloud/retail/v2/completion_service/operations.rb +12 -14
  10. data/lib/google/cloud/retail/v2/completion_service/rest/client.rb +533 -0
  11. data/lib/google/cloud/retail/v2/completion_service/rest/operations.rb +828 -0
  12. data/lib/google/cloud/retail/v2/completion_service/rest/service_stub.rb +167 -0
  13. data/lib/google/cloud/retail/v2/completion_service/rest.rb +56 -0
  14. data/lib/google/cloud/retail/v2/completion_service.rb +6 -0
  15. data/lib/google/cloud/retail/v2/control_service/client.rb +18 -6
  16. data/lib/google/cloud/retail/v2/control_service/rest/client.rb +680 -0
  17. data/lib/google/cloud/retail/v2/control_service/rest/service_stub.rb +345 -0
  18. data/lib/google/cloud/retail/v2/control_service/rest.rb +52 -0
  19. data/lib/google/cloud/retail/v2/control_service.rb +6 -0
  20. data/lib/google/cloud/retail/v2/prediction_service/client.rb +14 -0
  21. data/lib/google/cloud/retail/v2/prediction_service/rest/client.rb +486 -0
  22. data/lib/google/cloud/retail/v2/prediction_service/rest/service_stub.rb +116 -0
  23. data/lib/google/cloud/retail/v2/prediction_service/rest.rb +52 -0
  24. data/lib/google/cloud/retail/v2/prediction_service.rb +6 -0
  25. data/lib/google/cloud/retail/v2/product_service/client.rb +42 -30
  26. data/lib/google/cloud/retail/v2/product_service/operations.rb +12 -14
  27. data/lib/google/cloud/retail/v2/product_service/rest/client.rb +1649 -0
  28. data/lib/google/cloud/retail/v2/product_service/rest/operations.rb +828 -0
  29. data/lib/google/cloud/retail/v2/product_service/rest/service_stub.rb +705 -0
  30. data/lib/google/cloud/retail/v2/product_service/rest.rb +54 -0
  31. data/lib/google/cloud/retail/v2/product_service.rb +6 -0
  32. data/lib/google/cloud/retail/v2/rest.rb +44 -0
  33. data/lib/google/cloud/retail/v2/search_service/client.rb +18 -6
  34. data/lib/google/cloud/retail/v2/search_service/rest/client.rb +598 -0
  35. data/lib/google/cloud/retail/v2/search_service/rest/service_stub.rb +116 -0
  36. data/lib/google/cloud/retail/v2/search_service/rest.rb +55 -0
  37. data/lib/google/cloud/retail/v2/search_service.rb +6 -0
  38. data/lib/google/cloud/retail/v2/serving_config_service/client.rb +18 -6
  39. data/lib/google/cloud/retail/v2/serving_config_service/rest/client.rb +825 -0
  40. data/lib/google/cloud/retail/v2/serving_config_service/rest/service_stub.rb +465 -0
  41. data/lib/google/cloud/retail/v2/serving_config_service/rest.rb +52 -0
  42. data/lib/google/cloud/retail/v2/serving_config_service.rb +6 -0
  43. data/lib/google/cloud/retail/v2/user_event_service/client.rb +26 -12
  44. data/lib/google/cloud/retail/v2/user_event_service/operations.rb +12 -14
  45. data/lib/google/cloud/retail/v2/user_event_service/rest/client.rb +755 -0
  46. data/lib/google/cloud/retail/v2/user_event_service/rest/operations.rb +828 -0
  47. data/lib/google/cloud/retail/v2/user_event_service/rest/service_stub.rb +347 -0
  48. data/lib/google/cloud/retail/v2/user_event_service/rest.rb +53 -0
  49. data/lib/google/cloud/retail/v2/user_event_service.rb +6 -0
  50. data/lib/google/cloud/retail/v2/version.rb +1 -1
  51. data/lib/google/cloud/retail/v2.rb +5 -0
  52. metadata +58 -8
@@ -0,0 +1,828 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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 "gapic/operation"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Retail
24
+ module V2
25
+ module CompletionService
26
+ module Rest
27
+ # Service that implements Longrunning Operations API.
28
+ class Operations
29
+ # @private
30
+ attr_reader :operations_stub
31
+
32
+ ##
33
+ # Configuration for the CompletionService Operations API.
34
+ #
35
+ # @yield [config] Configure the Operations client.
36
+ # @yieldparam config [Operations::Configuration]
37
+ #
38
+ # @return [Operations::Configuration]
39
+ #
40
+ def self.configure
41
+ @configure ||= Operations::Configuration.new
42
+ yield @configure if block_given?
43
+ @configure
44
+ end
45
+
46
+ ##
47
+ # Configure the CompletionService Operations instance.
48
+ #
49
+ # The configuration is set to the derived mode, meaning that values can be changed,
50
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
51
+ # should be made on {Operations.configure}.
52
+ #
53
+ # @yield [config] Configure the Operations client.
54
+ # @yieldparam config [Operations::Configuration]
55
+ #
56
+ # @return [Operations::Configuration]
57
+ #
58
+ def configure
59
+ yield @config if block_given?
60
+ @config
61
+ end
62
+
63
+ ##
64
+ # Create a new Operations client object.
65
+ #
66
+ # @yield [config] Configure the Client client.
67
+ # @yieldparam config [Operations::Configuration]
68
+ #
69
+ def initialize
70
+ # Create the configuration object
71
+ @config = Configuration.new Operations.configure
72
+
73
+ # Yield the configuration if needed
74
+ yield @config if block_given?
75
+
76
+ # Create credentials
77
+ credentials = @config.credentials
78
+ credentials ||= Credentials.default scope: @config.scope
79
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
80
+ credentials = Credentials.new credentials, scope: @config.scope
81
+ end
82
+
83
+ @quota_project_id = @config.quota_project
84
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
85
+
86
+ @operations_stub = OperationsServiceStub.new(
87
+ endpoint: @config.endpoint,
88
+ credentials: credentials
89
+ )
90
+
91
+ # Used by an LRO wrapper for some methods of this service
92
+ @operations_client = self
93
+ end
94
+
95
+ # Service calls
96
+
97
+ ##
98
+ # Lists operations that match the specified filter in the request. If the
99
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
100
+ #
101
+ # NOTE: the `name` binding allows API services to override the binding
102
+ # to use different resource name schemes, such as `users/*/operations`. To
103
+ # override the binding, API services can add a binding such as
104
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
105
+ # For backwards compatibility, the default name includes the operations
106
+ # collection id, however overriding users must ensure the name binding
107
+ # is the parent resource, without the operations collection id.
108
+ #
109
+ # @overload list_operations(request, options = nil)
110
+ # Pass arguments to `list_operations` via a request object, either of type
111
+ # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
112
+ #
113
+ # @param request [::Google::Longrunning::ListOperationsRequest, ::Hash]
114
+ # A request object representing the call parameters. Required. To specify no
115
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
116
+ # @param options [::Gapic::CallOptions, ::Hash]
117
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
118
+ #
119
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
120
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
121
+ # least one keyword argument is required. To specify no parameters, or to keep all
122
+ # the default parameter values, pass an empty Hash as a request object (see above).
123
+ #
124
+ # @param name [::String]
125
+ # The name of the operation's parent resource.
126
+ # @param filter [::String]
127
+ # The standard list filter.
128
+ # @param page_size [::Integer]
129
+ # The standard list page size.
130
+ # @param page_token [::String]
131
+ # The standard list page token.
132
+ # @yield [result, operation] Access the result along with the TransportOperation object
133
+ # @yieldparam result [::Gapic::Operation]
134
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
135
+ #
136
+ # @return [::Gapic::Operation]
137
+ #
138
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
139
+ def list_operations request, options = nil
140
+ raise ::ArgumentError, "request must be provided" if request.nil?
141
+
142
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest
143
+
144
+ # Converts hash and nil to an options object
145
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
146
+
147
+ # Customize the options with defaults
148
+ call_metadata = @config.rpcs.list_operations.metadata.to_h
149
+
150
+ # Set x-goog-api-client and x-goog-user-project headers
151
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
152
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
153
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
154
+ transports_version_send: [:rest]
155
+
156
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
157
+
158
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
159
+ metadata: call_metadata,
160
+ retry_policy: @config.rpcs.list_operations.retry_policy
161
+
162
+ options.apply_defaults timeout: @config.timeout,
163
+ metadata: @config.metadata,
164
+ retry_policy: @config.retry_policy
165
+
166
+ @operations_stub.list_operations request, options do |result, operation|
167
+ result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
168
+ yield result, operation if block_given?
169
+ return result
170
+ end
171
+ rescue ::Gapic::Rest::Error => e
172
+ raise ::Google::Cloud::Error.from_error(e)
173
+ end
174
+
175
+ ##
176
+ # Gets the latest state of a long-running operation. Clients can use this
177
+ # method to poll the operation result at intervals as recommended by the API
178
+ # service.
179
+ #
180
+ # @overload get_operation(request, options = nil)
181
+ # Pass arguments to `get_operation` via a request object, either of type
182
+ # {::Google::Longrunning::GetOperationRequest} or an equivalent Hash.
183
+ #
184
+ # @param request [::Google::Longrunning::GetOperationRequest, ::Hash]
185
+ # A request object representing the call parameters. Required. To specify no
186
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
187
+ # @param options [::Gapic::CallOptions, ::Hash]
188
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
189
+ #
190
+ # @overload get_operation(name: nil)
191
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
192
+ # least one keyword argument is required. To specify no parameters, or to keep all
193
+ # the default parameter values, pass an empty Hash as a request object (see above).
194
+ #
195
+ # @param name [::String]
196
+ # The name of the operation resource.
197
+ # @yield [result, operation] Access the result along with the TransportOperation object
198
+ # @yieldparam result [::Gapic::Operation]
199
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
200
+ #
201
+ # @return [::Gapic::Operation]
202
+ #
203
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
204
+ def get_operation request, options = nil
205
+ raise ::ArgumentError, "request must be provided" if request.nil?
206
+
207
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest
208
+
209
+ # Converts hash and nil to an options object
210
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
211
+
212
+ # Customize the options with defaults
213
+ call_metadata = @config.rpcs.get_operation.metadata.to_h
214
+
215
+ # Set x-goog-api-client and x-goog-user-project headers
216
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
217
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
218
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
219
+ transports_version_send: [:rest]
220
+
221
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
222
+
223
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
224
+ metadata: call_metadata,
225
+ retry_policy: @config.rpcs.get_operation.retry_policy
226
+
227
+ options.apply_defaults timeout: @config.timeout,
228
+ metadata: @config.metadata,
229
+ retry_policy: @config.retry_policy
230
+
231
+ @operations_stub.get_operation request, options do |result, operation|
232
+ result = ::Gapic::Operation.new result, @operations_client, options: options
233
+ yield result, operation if block_given?
234
+ return result
235
+ end
236
+ rescue ::Gapic::Rest::Error => e
237
+ raise ::Google::Cloud::Error.from_error(e)
238
+ end
239
+
240
+ ##
241
+ # Deletes a long-running operation. This method indicates that the client is
242
+ # no longer interested in the operation result. It does not cancel the
243
+ # operation. If the server doesn't support this method, it returns
244
+ # `google.rpc.Code.UNIMPLEMENTED`.
245
+ #
246
+ # @overload delete_operation(request, options = nil)
247
+ # Pass arguments to `delete_operation` via a request object, either of type
248
+ # {::Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
249
+ #
250
+ # @param request [::Google::Longrunning::DeleteOperationRequest, ::Hash]
251
+ # A request object representing the call parameters. Required. To specify no
252
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
253
+ # @param options [::Gapic::CallOptions, ::Hash]
254
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
255
+ #
256
+ # @overload delete_operation(name: nil)
257
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
258
+ # least one keyword argument is required. To specify no parameters, or to keep all
259
+ # the default parameter values, pass an empty Hash as a request object (see above).
260
+ #
261
+ # @param name [::String]
262
+ # The name of the operation resource to be deleted.
263
+ # @yield [result, operation] Access the result along with the TransportOperation object
264
+ # @yieldparam result [::Google::Protobuf::Empty]
265
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
266
+ #
267
+ # @return [::Google::Protobuf::Empty]
268
+ #
269
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
270
+ def delete_operation request, options = nil
271
+ raise ::ArgumentError, "request must be provided" if request.nil?
272
+
273
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest
274
+
275
+ # Converts hash and nil to an options object
276
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
277
+
278
+ # Customize the options with defaults
279
+ call_metadata = @config.rpcs.delete_operation.metadata.to_h
280
+
281
+ # Set x-goog-api-client and x-goog-user-project headers
282
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
283
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
284
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
285
+ transports_version_send: [:rest]
286
+
287
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
288
+
289
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
290
+ metadata: call_metadata,
291
+ retry_policy: @config.rpcs.delete_operation.retry_policy
292
+
293
+ options.apply_defaults timeout: @config.timeout,
294
+ metadata: @config.metadata,
295
+ retry_policy: @config.retry_policy
296
+
297
+ @operations_stub.delete_operation request, options do |result, operation|
298
+ yield result, operation if block_given?
299
+ return result
300
+ end
301
+ rescue ::Gapic::Rest::Error => e
302
+ raise ::Google::Cloud::Error.from_error(e)
303
+ end
304
+
305
+ ##
306
+ # Starts asynchronous cancellation on a long-running operation. The server
307
+ # makes a best effort to cancel the operation, but success is not
308
+ # guaranteed. If the server doesn't support this method, it returns
309
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
310
+ # Operations.GetOperation or
311
+ # other methods to check whether the cancellation succeeded or whether the
312
+ # operation completed despite cancellation. On successful cancellation,
313
+ # the operation is not deleted; instead, it becomes an operation with
314
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
315
+ # corresponding to `Code.CANCELLED`.
316
+ #
317
+ # @overload cancel_operation(request, options = nil)
318
+ # Pass arguments to `cancel_operation` via a request object, either of type
319
+ # {::Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
320
+ #
321
+ # @param request [::Google::Longrunning::CancelOperationRequest, ::Hash]
322
+ # A request object representing the call parameters. Required. To specify no
323
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
324
+ # @param options [::Gapic::CallOptions, ::Hash]
325
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
326
+ #
327
+ # @overload cancel_operation(name: nil)
328
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
329
+ # least one keyword argument is required. To specify no parameters, or to keep all
330
+ # the default parameter values, pass an empty Hash as a request object (see above).
331
+ #
332
+ # @param name [::String]
333
+ # The name of the operation resource to be cancelled.
334
+ # @yield [result, operation] Access the result along with the TransportOperation object
335
+ # @yieldparam result [::Google::Protobuf::Empty]
336
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
337
+ #
338
+ # @return [::Google::Protobuf::Empty]
339
+ #
340
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
341
+ def cancel_operation request, options = nil
342
+ raise ::ArgumentError, "request must be provided" if request.nil?
343
+
344
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest
345
+
346
+ # Converts hash and nil to an options object
347
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
348
+
349
+ # Customize the options with defaults
350
+ call_metadata = @config.rpcs.cancel_operation.metadata.to_h
351
+
352
+ # Set x-goog-api-client and x-goog-user-project headers
353
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
354
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
355
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
356
+ transports_version_send: [:rest]
357
+
358
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
+
360
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
361
+ metadata: call_metadata,
362
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
363
+
364
+ options.apply_defaults timeout: @config.timeout,
365
+ metadata: @config.metadata,
366
+ retry_policy: @config.retry_policy
367
+
368
+ @operations_stub.cancel_operation request, options do |result, operation|
369
+ yield result, operation if block_given?
370
+ return result
371
+ end
372
+ rescue ::Gapic::Rest::Error => e
373
+ raise ::Google::Cloud::Error.from_error(e)
374
+ end
375
+
376
+ ##
377
+ # Configuration class for the Operations REST API.
378
+ #
379
+ # This class represents the configuration for Operations REST,
380
+ # providing control over timeouts, retry behavior, logging, transport
381
+ # parameters, and other low-level controls. Certain parameters can also be
382
+ # applied individually to specific RPCs. See
383
+ # {::Google::Longrunning::Operations::Rest::Client::Configuration::Rpcs}
384
+ # for a list of RPCs that can be configured independently.
385
+ #
386
+ # Configuration can be applied globally to all clients, or to a single client
387
+ # on construction.
388
+ #
389
+ # @example
390
+ #
391
+ # # Modify the global config, setting the timeout for
392
+ # # list_operations to 20 seconds,
393
+ # # and all remaining timeouts to 10 seconds.
394
+ # ::Google::Longrunning::Operations::Rest::Client.configure do |config|
395
+ # config.timeout = 10.0
396
+ # config.rpcs.list_operations.timeout = 20.0
397
+ # end
398
+ #
399
+ # # Apply the above configuration only to a new client.
400
+ # client = ::Google::Longrunning::Operations::Rest::Client.new do |config|
401
+ # config.timeout = 10.0
402
+ # config.rpcs.list_operations.timeout = 20.0
403
+ # end
404
+ #
405
+ # @!attribute [rw] endpoint
406
+ # The hostname or hostname:port of the service endpoint.
407
+ # Defaults to `"retail.googleapis.com"`.
408
+ # @return [::String]
409
+ # @!attribute [rw] credentials
410
+ # Credentials to send with calls. You may provide any of the following types:
411
+ # * (`String`) The path to a service account key file in JSON format
412
+ # * (`Hash`) A service account key as a Hash
413
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
414
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
415
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
416
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
417
+ # * (`nil`) indicating no credentials
418
+ # @return [::Object]
419
+ # @!attribute [rw] scope
420
+ # The OAuth scopes
421
+ # @return [::Array<::String>]
422
+ # @!attribute [rw] lib_name
423
+ # The library name as recorded in instrumentation and logging
424
+ # @return [::String]
425
+ # @!attribute [rw] lib_version
426
+ # The library version as recorded in instrumentation and logging
427
+ # @return [::String]
428
+ # @!attribute [rw] timeout
429
+ # The call timeout in seconds.
430
+ # @return [::Numeric]
431
+ # @!attribute [rw] metadata
432
+ # Additional headers to be sent with the call.
433
+ # @return [::Hash{::Symbol=>::String}]
434
+ # @!attribute [rw] retry_policy
435
+ # The retry policy. The value is a hash with the following keys:
436
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
437
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
438
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
439
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
440
+ # trigger a retry.
441
+ # @return [::Hash]
442
+ # @!attribute [rw] quota_project
443
+ # A separate project against which to charge quota.
444
+ # @return [::String]
445
+ #
446
+ class Configuration
447
+ extend ::Gapic::Config
448
+
449
+ config_attr :endpoint, "retail.googleapis.com", ::String
450
+ config_attr :credentials, nil do |value|
451
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
452
+ allowed.any? { |klass| klass === value }
453
+ end
454
+ config_attr :scope, nil, ::String, ::Array, nil
455
+ config_attr :lib_name, nil, ::String, nil
456
+ config_attr :lib_version, nil, ::String, nil
457
+ config_attr :timeout, nil, ::Numeric, nil
458
+ config_attr :metadata, nil, ::Hash, nil
459
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
460
+ config_attr :quota_project, nil, ::String, nil
461
+
462
+ # @private
463
+ def initialize parent_config = nil
464
+ @parent_config = parent_config unless parent_config.nil?
465
+
466
+ yield self if block_given?
467
+ end
468
+
469
+ ##
470
+ # Configurations for individual RPCs
471
+ # @return [Rpcs]
472
+ #
473
+ def rpcs
474
+ @rpcs ||= begin
475
+ parent_rpcs = nil
476
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
477
+ Rpcs.new parent_rpcs
478
+ end
479
+ end
480
+
481
+ ##
482
+ # Configuration RPC class for the Operations API.
483
+ #
484
+ # Includes fields providing the configuration for each RPC in this service.
485
+ # Each configuration object is of type `Gapic::Config::Method` and includes
486
+ # the following configuration fields:
487
+ #
488
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
489
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
490
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
491
+ # include the following keys:
492
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
493
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
494
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
495
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
496
+ # trigger a retry.
497
+ #
498
+ class Rpcs
499
+ ##
500
+ # RPC-specific configuration for `list_operations`
501
+ # @return [::Gapic::Config::Method]
502
+ #
503
+ attr_reader :list_operations
504
+ ##
505
+ # RPC-specific configuration for `get_operation`
506
+ # @return [::Gapic::Config::Method]
507
+ #
508
+ attr_reader :get_operation
509
+ ##
510
+ # RPC-specific configuration for `delete_operation`
511
+ # @return [::Gapic::Config::Method]
512
+ #
513
+ attr_reader :delete_operation
514
+ ##
515
+ # RPC-specific configuration for `cancel_operation`
516
+ # @return [::Gapic::Config::Method]
517
+ #
518
+ attr_reader :cancel_operation
519
+
520
+ # @private
521
+ def initialize parent_rpcs = nil
522
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
523
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
524
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
525
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
526
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
527
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
528
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
529
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
530
+
531
+ yield self if block_given?
532
+ end
533
+ end
534
+ end
535
+ end
536
+
537
+ ##
538
+ # @private
539
+ # REST service stub for the Longrunning Operations API.
540
+ # Service stub contains baseline method implementations
541
+ # including transcoding, making the REST call, and deserialing the response.
542
+ class OperationsServiceStub
543
+ def initialize endpoint:, credentials:
544
+ # These require statements are intentionally placed here to initialize
545
+ # the REST modules only when it's required.
546
+ require "gapic/rest"
547
+
548
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
549
+ end
550
+
551
+ ##
552
+ # Baseline implementation for the list_operations REST call
553
+ #
554
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
555
+ # A request object representing the call parameters. Required.
556
+ # @param options [::Gapic::CallOptions]
557
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
558
+ #
559
+ # @yield [result, operation] Access the result along with the TransportOperation object
560
+ # @yieldparam result [::Google::Longrunning::ListOperationsResponse]
561
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
562
+ #
563
+ # @return [::Google::Longrunning::ListOperationsResponse]
564
+ # A result object deserialized from the server's reply
565
+ def list_operations request_pb, options = nil
566
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
567
+
568
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_list_operations_request request_pb
569
+ query_string_params = if query_string_params.any?
570
+ query_string_params.to_h { |p| p.split("=", 2) }
571
+ else
572
+ {}
573
+ end
574
+
575
+ response = @client_stub.make_http_request(
576
+ verb,
577
+ uri: uri,
578
+ body: body || "",
579
+ params: query_string_params,
580
+ options: options
581
+ )
582
+ operation = ::Gapic::Rest::TransportOperation.new response
583
+ result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
584
+
585
+ yield result, operation if block_given?
586
+ result
587
+ end
588
+
589
+ ##
590
+ # Baseline implementation for the get_operation REST call
591
+ #
592
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
593
+ # A request object representing the call parameters. Required.
594
+ # @param options [::Gapic::CallOptions]
595
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
596
+ #
597
+ # @yield [result, operation] Access the result along with the TransportOperation object
598
+ # @yieldparam result [::Google::Longrunning::Operation]
599
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
600
+ #
601
+ # @return [::Google::Longrunning::Operation]
602
+ # A result object deserialized from the server's reply
603
+ def get_operation request_pb, options = nil
604
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
605
+
606
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_get_operation_request request_pb
607
+ query_string_params = if query_string_params.any?
608
+ query_string_params.to_h { |p| p.split("=", 2) }
609
+ else
610
+ {}
611
+ end
612
+
613
+ response = @client_stub.make_http_request(
614
+ verb,
615
+ uri: uri,
616
+ body: body || "",
617
+ params: query_string_params,
618
+ options: options
619
+ )
620
+ operation = ::Gapic::Rest::TransportOperation.new response
621
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
622
+
623
+ yield result, operation if block_given?
624
+ result
625
+ end
626
+
627
+ ##
628
+ # Baseline implementation for the delete_operation REST call
629
+ #
630
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
631
+ # A request object representing the call parameters. Required.
632
+ # @param options [::Gapic::CallOptions]
633
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
634
+ #
635
+ # @yield [result, operation] Access the result along with the TransportOperation object
636
+ # @yieldparam result [::Google::Protobuf::Empty]
637
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
638
+ #
639
+ # @return [::Google::Protobuf::Empty]
640
+ # A result object deserialized from the server's reply
641
+ def delete_operation request_pb, options = nil
642
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
643
+
644
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_delete_operation_request request_pb
645
+ query_string_params = if query_string_params.any?
646
+ query_string_params.to_h { |p| p.split("=", 2) }
647
+ else
648
+ {}
649
+ end
650
+
651
+ response = @client_stub.make_http_request(
652
+ verb,
653
+ uri: uri,
654
+ body: body || "",
655
+ params: query_string_params,
656
+ options: options
657
+ )
658
+ operation = ::Gapic::Rest::TransportOperation.new response
659
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
660
+
661
+ yield result, operation if block_given?
662
+ result
663
+ end
664
+
665
+ ##
666
+ # Baseline implementation for the cancel_operation REST call
667
+ #
668
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
669
+ # A request object representing the call parameters. Required.
670
+ # @param options [::Gapic::CallOptions]
671
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
672
+ #
673
+ # @yield [result, operation] Access the result along with the TransportOperation object
674
+ # @yieldparam result [::Google::Protobuf::Empty]
675
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
676
+ #
677
+ # @return [::Google::Protobuf::Empty]
678
+ # A result object deserialized from the server's reply
679
+ def cancel_operation request_pb, options = nil
680
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
681
+
682
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_cancel_operation_request request_pb
683
+ query_string_params = if query_string_params.any?
684
+ query_string_params.to_h { |p| p.split("=", 2) }
685
+ else
686
+ {}
687
+ end
688
+
689
+ response = @client_stub.make_http_request(
690
+ verb,
691
+ uri: uri,
692
+ body: body || "",
693
+ params: query_string_params,
694
+ options: options
695
+ )
696
+ operation = ::Gapic::Rest::TransportOperation.new response
697
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
698
+
699
+ yield result, operation if block_given?
700
+ result
701
+ end
702
+
703
+ ##
704
+ # @private
705
+ #
706
+ # GRPC transcoding helper method for the list_operations REST call
707
+ #
708
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
709
+ # A request object representing the call parameters. Required.
710
+ # @return [Array(String, [String, nil], Hash{String => String})]
711
+ # Uri, Body, Query string parameters
712
+ def self.transcode_list_operations_request request_pb
713
+ transcoder = Gapic::Rest::GrpcTranscoder.new
714
+ .with_bindings(
715
+ uri_method: :get,
716
+ uri_template: "/v2/{name}/operations",
717
+ matches: [
718
+ ["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
719
+ ]
720
+ )
721
+ .with_bindings(
722
+ uri_method: :get,
723
+ uri_template: "/v2/{name}/operations",
724
+ matches: [
725
+ ["name", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/?$}, false]
726
+ ]
727
+ )
728
+ .with_bindings(
729
+ uri_method: :get,
730
+ uri_template: "/v2/{name}/operations",
731
+ matches: [
732
+ ["name", %r{^projects/[^/]+/?$}, false]
733
+ ]
734
+ )
735
+ transcoder.transcode request_pb
736
+ end
737
+
738
+ ##
739
+ # @private
740
+ #
741
+ # GRPC transcoding helper method for the get_operation REST call
742
+ #
743
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
744
+ # A request object representing the call parameters. Required.
745
+ # @return [Array(String, [String, nil], Hash{String => String})]
746
+ # Uri, Body, Query string parameters
747
+ def self.transcode_get_operation_request request_pb
748
+ transcoder = Gapic::Rest::GrpcTranscoder.new
749
+ .with_bindings(
750
+ uri_method: :get,
751
+ uri_template: "/v2/{name}",
752
+ matches: [
753
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
754
+ ]
755
+ )
756
+ .with_bindings(
757
+ uri_method: :get,
758
+ uri_template: "/v2/{name}",
759
+ matches: [
760
+ ["name", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/branches/[^/]+/operations/[^/]+/?$}, false]
761
+ ]
762
+ )
763
+ .with_bindings(
764
+ uri_method: :get,
765
+ uri_template: "/v2/{name}",
766
+ matches: [
767
+ ["name", %r{^projects/[^/]+/locations/[^/]+/catalogs/[^/]+/operations/[^/]+/?$}, false]
768
+ ]
769
+ )
770
+ .with_bindings(
771
+ uri_method: :get,
772
+ uri_template: "/v2/{name}",
773
+ matches: [
774
+ ["name", %r{^projects/[^/]+/operations/[^/]+/?$}, false]
775
+ ]
776
+ )
777
+ transcoder.transcode request_pb
778
+ end
779
+
780
+ ##
781
+ # @private
782
+ #
783
+ # GRPC transcoding helper method for the delete_operation REST call
784
+ #
785
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
786
+ # A request object representing the call parameters. Required.
787
+ # @return [Array(String, [String, nil], Hash{String => String})]
788
+ # Uri, Body, Query string parameters
789
+ def self.transcode_delete_operation_request request_pb
790
+ transcoder = Gapic::Rest::GrpcTranscoder.new
791
+ .with_bindings(
792
+ uri_method: :delete,
793
+ uri_template: "/v1/{name}",
794
+ matches: [
795
+ ["name", %r{^operations(?:/.*)?$}, true]
796
+ ]
797
+ )
798
+ transcoder.transcode request_pb
799
+ end
800
+
801
+ ##
802
+ # @private
803
+ #
804
+ # GRPC transcoding helper method for the cancel_operation REST call
805
+ #
806
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
807
+ # A request object representing the call parameters. Required.
808
+ # @return [Array(String, [String, nil], Hash{String => String})]
809
+ # Uri, Body, Query string parameters
810
+ def self.transcode_cancel_operation_request request_pb
811
+ transcoder = Gapic::Rest::GrpcTranscoder.new
812
+ .with_bindings(
813
+ uri_method: :post,
814
+ uri_template: "/v1/{name}:cancel",
815
+ body: "*",
816
+ matches: [
817
+ ["name", %r{^operations(?:/.*)?$}, true]
818
+ ]
819
+ )
820
+ transcoder.transcode request_pb
821
+ end
822
+ end
823
+ end
824
+ end
825
+ end
826
+ end
827
+ end
828
+ end