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