google-cloud-commerce-consumer-procurement-v1 0.a → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/README.md +144 -8
  5. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/client.rb +680 -0
  6. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/credentials.rb +51 -0
  7. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/operations.rb +783 -0
  8. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/paths.rb +90 -0
  9. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/rest/client.rb +630 -0
  10. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/rest/operations.rb +874 -0
  11. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/rest/service_stub.rb +230 -0
  12. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/rest.rb +65 -0
  13. data/lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service.rb +68 -0
  14. data/lib/google/cloud/commerce/consumer/procurement/v1/order_pb.rb +60 -0
  15. data/lib/google/cloud/commerce/consumer/procurement/v1/procurement_service_pb.rb +58 -0
  16. data/lib/google/cloud/commerce/consumer/procurement/v1/procurement_service_services_pb.rb +74 -0
  17. data/lib/google/cloud/commerce/consumer/procurement/v1/rest.rb +41 -0
  18. data/lib/google/cloud/commerce/consumer/procurement/v1/version.rb +7 -2
  19. data/lib/google/cloud/commerce/consumer/procurement/v1.rb +49 -0
  20. data/lib/google-cloud-commerce-consumer-procurement-v1.rb +21 -0
  21. data/proto_docs/README.md +4 -0
  22. data/proto_docs/google/api/client.rb +381 -0
  23. data/proto_docs/google/api/field_behavior.rb +85 -0
  24. data/proto_docs/google/api/launch_stage.rb +71 -0
  25. data/proto_docs/google/api/resource.rb +222 -0
  26. data/proto_docs/google/cloud/commerce/consumer/procurement/v1/order.rb +262 -0
  27. data/proto_docs/google/cloud/commerce/consumer/procurement/v1/procurement_service.rb +122 -0
  28. data/proto_docs/google/longrunning/operations.rb +164 -0
  29. data/proto_docs/google/protobuf/any.rb +144 -0
  30. data/proto_docs/google/protobuf/duration.rb +98 -0
  31. data/proto_docs/google/protobuf/empty.rb +34 -0
  32. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  33. data/proto_docs/google/rpc/status.rb +48 -0
  34. metadata +188 -13
@@ -0,0 +1,630 @@
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 "google/cloud/errors"
20
+ require "google/cloud/commerce/consumer/procurement/v1/procurement_service_pb"
21
+ require "google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Commerce
26
+ module Consumer
27
+ module Procurement
28
+ module V1
29
+ module ConsumerProcurementService
30
+ module Rest
31
+ ##
32
+ # REST client for the ConsumerProcurementService service.
33
+ #
34
+ # ConsumerProcurementService allows customers to make purchases of products
35
+ # served by the Cloud Commerce platform.
36
+ #
37
+ #
38
+ # When purchases are made, the
39
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client ConsumerProcurementService}
40
+ # programs the appropriate backends, including both Google's own
41
+ # infrastructure, as well as third-party systems, and to enable billing setup
42
+ # for charging for the procured item.
43
+ #
44
+ class Client
45
+ include Paths
46
+
47
+ # @private
48
+ attr_reader :consumer_procurement_service_stub
49
+
50
+ ##
51
+ # Configure the ConsumerProcurementService Client class.
52
+ #
53
+ # See {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client::Configuration}
54
+ # for a description of the configuration fields.
55
+ #
56
+ # @example
57
+ #
58
+ # # Modify the configuration for all ConsumerProcurementService clients
59
+ # ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.configure do |config|
60
+ # config.timeout = 10.0
61
+ # end
62
+ #
63
+ # @yield [config] Configure the Client client.
64
+ # @yieldparam config [Client::Configuration]
65
+ #
66
+ # @return [Client::Configuration]
67
+ #
68
+ def self.configure
69
+ @configure ||= begin
70
+ namespace = ["Google", "Cloud", "Commerce", "Consumer", "Procurement", "V1"]
71
+ parent_config = while namespace.any?
72
+ parent_name = namespace.join "::"
73
+ parent_const = const_get parent_name
74
+ break parent_const.configure if parent_const.respond_to? :configure
75
+ namespace.pop
76
+ end
77
+ default_config = Client::Configuration.new parent_config
78
+
79
+ default_config.rpcs.place_order.timeout = 60.0
80
+
81
+ default_config.rpcs.get_order.timeout = 60.0
82
+ default_config.rpcs.get_order.retry_policy = {
83
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
84
+ }
85
+
86
+ default_config.rpcs.list_orders.timeout = 60.0
87
+ default_config.rpcs.list_orders.retry_policy = {
88
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
89
+ }
90
+
91
+ default_config
92
+ end
93
+ yield @configure if block_given?
94
+ @configure
95
+ end
96
+
97
+ ##
98
+ # Configure the ConsumerProcurementService Client instance.
99
+ #
100
+ # The configuration is set to the derived mode, meaning that values can be changed,
101
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
102
+ # should be made on {Client.configure}.
103
+ #
104
+ # See {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client::Configuration}
105
+ # for a description of the configuration fields.
106
+ #
107
+ # @yield [config] Configure the Client client.
108
+ # @yieldparam config [Client::Configuration]
109
+ #
110
+ # @return [Client::Configuration]
111
+ #
112
+ def configure
113
+ yield @config if block_given?
114
+ @config
115
+ end
116
+
117
+ ##
118
+ # Create a new ConsumerProcurementService REST client object.
119
+ #
120
+ # @example
121
+ #
122
+ # # Create a client using the default configuration
123
+ # client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new
124
+ #
125
+ # # Create a client using a custom configuration
126
+ # client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new do |config|
127
+ # config.timeout = 10.0
128
+ # end
129
+ #
130
+ # @yield [config] Configure the ConsumerProcurementService client.
131
+ # @yieldparam config [Client::Configuration]
132
+ #
133
+ def initialize
134
+ # Create the configuration object
135
+ @config = Configuration.new Client.configure
136
+
137
+ # Yield the configuration if needed
138
+ yield @config if block_given?
139
+
140
+ # Create credentials
141
+ credentials = @config.credentials
142
+ # Use self-signed JWT if the endpoint is unchanged from default,
143
+ # but only if the default endpoint does not have a region prefix.
144
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
145
+ !@config.endpoint.split(".").first.include?("-")
146
+ credentials ||= Credentials.default scope: @config.scope,
147
+ enable_self_signed_jwt: enable_self_signed_jwt
148
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
149
+ credentials = Credentials.new credentials, scope: @config.scope
150
+ end
151
+
152
+ @quota_project_id = @config.quota_project
153
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
154
+
155
+ @operations_client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Operations.new do |config|
156
+ config.credentials = credentials
157
+ config.quota_project = @quota_project_id
158
+ config.endpoint = @config.endpoint
159
+ end
160
+
161
+ @consumer_procurement_service_stub = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
162
+ end
163
+
164
+ ##
165
+ # Get the associated client for long-running operations.
166
+ #
167
+ # @return [::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Operations]
168
+ #
169
+ attr_reader :operations_client
170
+
171
+ # Service calls
172
+
173
+ ##
174
+ # Creates a new {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order}.
175
+ #
176
+ # This API only supports GCP spend-based committed use
177
+ # discounts specified by GCP documentation.
178
+ #
179
+ # The returned long-running operation is in-progress until the backend
180
+ # completes the creation of the resource. Once completed, the order is
181
+ # in
182
+ # [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE].
183
+ # In case of failure, the order resource will be removed.
184
+ #
185
+ # @overload place_order(request, options = nil)
186
+ # Pass arguments to `place_order` via a request object, either of type
187
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest} or an equivalent Hash.
188
+ #
189
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest, ::Hash]
190
+ # A request object representing the call parameters. Required. To specify no
191
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
192
+ # @param options [::Gapic::CallOptions, ::Hash]
193
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
194
+ #
195
+ # @overload place_order(parent: nil, display_name: nil, line_item_info: nil, request_id: nil)
196
+ # Pass arguments to `place_order` via keyword arguments. Note that at
197
+ # least one keyword argument is required. To specify no parameters, or to keep all
198
+ # the default parameter values, pass an empty Hash as a request object (see above).
199
+ #
200
+ # @param parent [::String]
201
+ # Required. The resource name of the parent resource.
202
+ # This field has the form `billingAccounts/{billing-account-id}`.
203
+ # @param display_name [::String]
204
+ # Required. The user-specified name of the order being placed.
205
+ # @param line_item_info [::Array<::Google::Cloud::Commerce::Consumer::Procurement::V1::LineItemInfo, ::Hash>]
206
+ # Optional. Places order for offer. Required when an offer-based order is
207
+ # being placed.
208
+ # @param request_id [::String]
209
+ # Optional. A unique identifier for this request.
210
+ # The server will ignore subsequent requests that provide a duplicate request
211
+ # ID for at least 120 minutes after the first request.
212
+ #
213
+ # The request ID must be a valid
214
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format).
215
+ # @yield [result, operation] Access the result along with the TransportOperation object
216
+ # @yieldparam result [::Gapic::Operation]
217
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
218
+ #
219
+ # @return [::Gapic::Operation]
220
+ #
221
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
222
+ #
223
+ # @example Basic example
224
+ # require "google/cloud/commerce/consumer/procurement/v1"
225
+ #
226
+ # # Create a client object. The client can be reused for multiple calls.
227
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new
228
+ #
229
+ # # Create a request. To set request fields, pass in keyword arguments.
230
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest.new
231
+ #
232
+ # # Call the place_order method.
233
+ # result = client.place_order request
234
+ #
235
+ # # The returned object is of type Gapic::Operation. You can use it to
236
+ # # check the status of an operation, cancel it, or wait for results.
237
+ # # Here is how to wait for a response.
238
+ # result.wait_until_done! timeout: 60
239
+ # if result.response?
240
+ # p result.response
241
+ # else
242
+ # puts "No response received."
243
+ # end
244
+ #
245
+ def place_order request, options = nil
246
+ raise ::ArgumentError, "request must be provided" if request.nil?
247
+
248
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest
249
+
250
+ # Converts hash and nil to an options object
251
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
252
+
253
+ # Customize the options with defaults
254
+ call_metadata = @config.rpcs.place_order.metadata.to_h
255
+
256
+ # Set x-goog-api-client and x-goog-user-project headers
257
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
258
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
259
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
260
+ transports_version_send: [:rest]
261
+
262
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
263
+
264
+ options.apply_defaults timeout: @config.rpcs.place_order.timeout,
265
+ metadata: call_metadata,
266
+ retry_policy: @config.rpcs.place_order.retry_policy
267
+
268
+ options.apply_defaults timeout: @config.timeout,
269
+ metadata: @config.metadata,
270
+ retry_policy: @config.retry_policy
271
+
272
+ @consumer_procurement_service_stub.place_order request, options do |result, operation|
273
+ result = ::Gapic::Operation.new result, @operations_client, options: options
274
+ yield result, operation if block_given?
275
+ return result
276
+ end
277
+ rescue ::Gapic::Rest::Error => e
278
+ raise ::Google::Cloud::Error.from_error(e)
279
+ end
280
+
281
+ ##
282
+ # Returns the requested
283
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order} resource.
284
+ #
285
+ # @overload get_order(request, options = nil)
286
+ # Pass arguments to `get_order` via a request object, either of type
287
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest} or an equivalent Hash.
288
+ #
289
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest, ::Hash]
290
+ # A request object representing the call parameters. Required. To specify no
291
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
292
+ # @param options [::Gapic::CallOptions, ::Hash]
293
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
294
+ #
295
+ # @overload get_order(name: nil)
296
+ # Pass arguments to `get_order` via keyword arguments. Note that at
297
+ # least one keyword argument is required. To specify no parameters, or to keep all
298
+ # the default parameter values, pass an empty Hash as a request object (see above).
299
+ #
300
+ # @param name [::String]
301
+ # Required. The name of the order to retrieve.
302
+ # @yield [result, operation] Access the result along with the TransportOperation object
303
+ # @yieldparam result [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
304
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
305
+ #
306
+ # @return [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
307
+ #
308
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
309
+ #
310
+ # @example Basic example
311
+ # require "google/cloud/commerce/consumer/procurement/v1"
312
+ #
313
+ # # Create a client object. The client can be reused for multiple calls.
314
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new
315
+ #
316
+ # # Create a request. To set request fields, pass in keyword arguments.
317
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest.new
318
+ #
319
+ # # Call the get_order method.
320
+ # result = client.get_order request
321
+ #
322
+ # # The returned object is of type Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
323
+ # p result
324
+ #
325
+ def get_order request, options = nil
326
+ raise ::ArgumentError, "request must be provided" if request.nil?
327
+
328
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest
329
+
330
+ # Converts hash and nil to an options object
331
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
332
+
333
+ # Customize the options with defaults
334
+ call_metadata = @config.rpcs.get_order.metadata.to_h
335
+
336
+ # Set x-goog-api-client and x-goog-user-project headers
337
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
338
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
339
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
340
+ transports_version_send: [:rest]
341
+
342
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
343
+
344
+ options.apply_defaults timeout: @config.rpcs.get_order.timeout,
345
+ metadata: call_metadata,
346
+ retry_policy: @config.rpcs.get_order.retry_policy
347
+
348
+ options.apply_defaults timeout: @config.timeout,
349
+ metadata: @config.metadata,
350
+ retry_policy: @config.retry_policy
351
+
352
+ @consumer_procurement_service_stub.get_order request, options do |result, operation|
353
+ yield result, operation if block_given?
354
+ return result
355
+ end
356
+ rescue ::Gapic::Rest::Error => e
357
+ raise ::Google::Cloud::Error.from_error(e)
358
+ end
359
+
360
+ ##
361
+ # Lists {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order}
362
+ # resources that the user has access to, within the scope of the parent
363
+ # resource.
364
+ #
365
+ # @overload list_orders(request, options = nil)
366
+ # Pass arguments to `list_orders` via a request object, either of type
367
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest} or an equivalent Hash.
368
+ #
369
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest, ::Hash]
370
+ # A request object representing the call parameters. Required. To specify no
371
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
372
+ # @param options [::Gapic::CallOptions, ::Hash]
373
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
374
+ #
375
+ # @overload list_orders(parent: nil, page_size: nil, page_token: nil, filter: nil)
376
+ # Pass arguments to `list_orders` via keyword arguments. Note that at
377
+ # least one keyword argument is required. To specify no parameters, or to keep all
378
+ # the default parameter values, pass an empty Hash as a request object (see above).
379
+ #
380
+ # @param parent [::String]
381
+ # Required. The parent resource to query for orders.
382
+ # This field has the form `billingAccounts/{billing-account-id}`.
383
+ # @param page_size [::Integer]
384
+ # The maximum number of entries requested.
385
+ # The default page size is 25 and the maximum page size is 200.
386
+ # @param page_token [::String]
387
+ # The token for fetching the next page.
388
+ # @param filter [::String]
389
+ # Filter that you can use to limit the list request.
390
+ #
391
+ # A query string that can match a selected set of attributes
392
+ # with string values. For example, `display_name=abc`.
393
+ # Supported query attributes are
394
+ #
395
+ # * `display_name`
396
+ #
397
+ # If the query contains special characters other than letters,
398
+ # underscore, or digits, the phrase must be quoted with double quotes. For
399
+ # example, `display_name="foo:bar"`, where the display name needs to be
400
+ # quoted because it contains special character colon.
401
+ #
402
+ # Queries can be combined with `OR`, and `NOT` to form more complex queries.
403
+ # You can also group them to force a desired evaluation order.
404
+ # For example, `display_name=abc OR display_name=def`.
405
+ # @yield [result, operation] Access the result along with the TransportOperation object
406
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
407
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
408
+ #
409
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
410
+ #
411
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
412
+ #
413
+ # @example Basic example
414
+ # require "google/cloud/commerce/consumer/procurement/v1"
415
+ #
416
+ # # Create a client object. The client can be reused for multiple calls.
417
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new
418
+ #
419
+ # # Create a request. To set request fields, pass in keyword arguments.
420
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest.new
421
+ #
422
+ # # Call the list_orders method.
423
+ # result = client.list_orders request
424
+ #
425
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
426
+ # # over elements, and API calls will be issued to fetch pages as needed.
427
+ # result.each do |item|
428
+ # # Each element is of type ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
429
+ # p item
430
+ # end
431
+ #
432
+ def list_orders request, options = nil
433
+ raise ::ArgumentError, "request must be provided" if request.nil?
434
+
435
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest
436
+
437
+ # Converts hash and nil to an options object
438
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
439
+
440
+ # Customize the options with defaults
441
+ call_metadata = @config.rpcs.list_orders.metadata.to_h
442
+
443
+ # Set x-goog-api-client and x-goog-user-project headers
444
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
445
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
446
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
447
+ transports_version_send: [:rest]
448
+
449
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
450
+
451
+ options.apply_defaults timeout: @config.rpcs.list_orders.timeout,
452
+ metadata: call_metadata,
453
+ retry_policy: @config.rpcs.list_orders.retry_policy
454
+
455
+ options.apply_defaults timeout: @config.timeout,
456
+ metadata: @config.metadata,
457
+ retry_policy: @config.retry_policy
458
+
459
+ @consumer_procurement_service_stub.list_orders request, options do |result, operation|
460
+ result = ::Gapic::Rest::PagedEnumerable.new @consumer_procurement_service_stub, :list_orders, "orders", request, result, options
461
+ yield result, operation if block_given?
462
+ return result
463
+ end
464
+ rescue ::Gapic::Rest::Error => e
465
+ raise ::Google::Cloud::Error.from_error(e)
466
+ end
467
+
468
+ ##
469
+ # Configuration class for the ConsumerProcurementService REST API.
470
+ #
471
+ # This class represents the configuration for ConsumerProcurementService REST,
472
+ # providing control over timeouts, retry behavior, logging, transport
473
+ # parameters, and other low-level controls. Certain parameters can also be
474
+ # applied individually to specific RPCs. See
475
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client::Configuration::Rpcs}
476
+ # for a list of RPCs that can be configured independently.
477
+ #
478
+ # Configuration can be applied globally to all clients, or to a single client
479
+ # on construction.
480
+ #
481
+ # @example
482
+ #
483
+ # # Modify the global config, setting the timeout for
484
+ # # place_order to 20 seconds,
485
+ # # and all remaining timeouts to 10 seconds.
486
+ # ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.configure do |config|
487
+ # config.timeout = 10.0
488
+ # config.rpcs.place_order.timeout = 20.0
489
+ # end
490
+ #
491
+ # # Apply the above configuration only to a new client.
492
+ # client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new do |config|
493
+ # config.timeout = 10.0
494
+ # config.rpcs.place_order.timeout = 20.0
495
+ # end
496
+ #
497
+ # @!attribute [rw] endpoint
498
+ # The hostname or hostname:port of the service endpoint.
499
+ # Defaults to `"cloudcommerceconsumerprocurement.googleapis.com"`.
500
+ # @return [::String]
501
+ # @!attribute [rw] credentials
502
+ # Credentials to send with calls. You may provide any of the following types:
503
+ # * (`String`) The path to a service account key file in JSON format
504
+ # * (`Hash`) A service account key as a Hash
505
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
506
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
507
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
508
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
509
+ # * (`nil`) indicating no credentials
510
+ # @return [::Object]
511
+ # @!attribute [rw] scope
512
+ # The OAuth scopes
513
+ # @return [::Array<::String>]
514
+ # @!attribute [rw] lib_name
515
+ # The library name as recorded in instrumentation and logging
516
+ # @return [::String]
517
+ # @!attribute [rw] lib_version
518
+ # The library version as recorded in instrumentation and logging
519
+ # @return [::String]
520
+ # @!attribute [rw] timeout
521
+ # The call timeout in seconds.
522
+ # @return [::Numeric]
523
+ # @!attribute [rw] metadata
524
+ # Additional headers to be sent with the call.
525
+ # @return [::Hash{::Symbol=>::String}]
526
+ # @!attribute [rw] retry_policy
527
+ # The retry policy. The value is a hash with the following keys:
528
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
529
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
530
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
531
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
532
+ # trigger a retry.
533
+ # @return [::Hash]
534
+ # @!attribute [rw] quota_project
535
+ # A separate project against which to charge quota.
536
+ # @return [::String]
537
+ #
538
+ class Configuration
539
+ extend ::Gapic::Config
540
+
541
+ DEFAULT_ENDPOINT = "cloudcommerceconsumerprocurement.googleapis.com"
542
+
543
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
544
+ config_attr :credentials, nil do |value|
545
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
546
+ allowed.any? { |klass| klass === value }
547
+ end
548
+ config_attr :scope, nil, ::String, ::Array, nil
549
+ config_attr :lib_name, nil, ::String, nil
550
+ config_attr :lib_version, nil, ::String, nil
551
+ config_attr :timeout, nil, ::Numeric, nil
552
+ config_attr :metadata, nil, ::Hash, nil
553
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
554
+ config_attr :quota_project, nil, ::String, nil
555
+
556
+ # @private
557
+ def initialize parent_config = nil
558
+ @parent_config = parent_config unless parent_config.nil?
559
+
560
+ yield self if block_given?
561
+ end
562
+
563
+ ##
564
+ # Configurations for individual RPCs
565
+ # @return [Rpcs]
566
+ #
567
+ def rpcs
568
+ @rpcs ||= begin
569
+ parent_rpcs = nil
570
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
571
+ Rpcs.new parent_rpcs
572
+ end
573
+ end
574
+
575
+ ##
576
+ # Configuration RPC class for the ConsumerProcurementService API.
577
+ #
578
+ # Includes fields providing the configuration for each RPC in this service.
579
+ # Each configuration object is of type `Gapic::Config::Method` and includes
580
+ # the following configuration fields:
581
+ #
582
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
583
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
584
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
585
+ # include the following keys:
586
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
587
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
588
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
589
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
590
+ # trigger a retry.
591
+ #
592
+ class Rpcs
593
+ ##
594
+ # RPC-specific configuration for `place_order`
595
+ # @return [::Gapic::Config::Method]
596
+ #
597
+ attr_reader :place_order
598
+ ##
599
+ # RPC-specific configuration for `get_order`
600
+ # @return [::Gapic::Config::Method]
601
+ #
602
+ attr_reader :get_order
603
+ ##
604
+ # RPC-specific configuration for `list_orders`
605
+ # @return [::Gapic::Config::Method]
606
+ #
607
+ attr_reader :list_orders
608
+
609
+ # @private
610
+ def initialize parent_rpcs = nil
611
+ place_order_config = parent_rpcs.place_order if parent_rpcs.respond_to? :place_order
612
+ @place_order = ::Gapic::Config::Method.new place_order_config
613
+ get_order_config = parent_rpcs.get_order if parent_rpcs.respond_to? :get_order
614
+ @get_order = ::Gapic::Config::Method.new get_order_config
615
+ list_orders_config = parent_rpcs.list_orders if parent_rpcs.respond_to? :list_orders
616
+ @list_orders = ::Gapic::Config::Method.new list_orders_config
617
+
618
+ yield self if block_given?
619
+ end
620
+ end
621
+ end
622
+ end
623
+ end
624
+ end
625
+ end
626
+ end
627
+ end
628
+ end
629
+ end
630
+ end