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,680 @@
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
+ channel_pool_config: @config.channel_pool
171
+ )
172
+ end
173
+
174
+ ##
175
+ # Get the associated client for long-running operations.
176
+ #
177
+ # @return [::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Operations]
178
+ #
179
+ attr_reader :operations_client
180
+
181
+ # Service calls
182
+
183
+ ##
184
+ # Creates a new {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order}.
185
+ #
186
+ # This API only supports GCP spend-based committed use
187
+ # discounts specified by GCP documentation.
188
+ #
189
+ # The returned long-running operation is in-progress until the backend
190
+ # completes the creation of the resource. Once completed, the order is
191
+ # in
192
+ # [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE].
193
+ # In case of failure, the order resource will be removed.
194
+ #
195
+ # @overload place_order(request, options = nil)
196
+ # Pass arguments to `place_order` via a request object, either of type
197
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest} or an equivalent Hash.
198
+ #
199
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest, ::Hash]
200
+ # A request object representing the call parameters. Required. To specify no
201
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
202
+ # @param options [::Gapic::CallOptions, ::Hash]
203
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
204
+ #
205
+ # @overload place_order(parent: nil, display_name: nil, line_item_info: nil, request_id: nil)
206
+ # Pass arguments to `place_order` via keyword arguments. Note that at
207
+ # least one keyword argument is required. To specify no parameters, or to keep all
208
+ # the default parameter values, pass an empty Hash as a request object (see above).
209
+ #
210
+ # @param parent [::String]
211
+ # Required. The resource name of the parent resource.
212
+ # This field has the form `billingAccounts/{billing-account-id}`.
213
+ # @param display_name [::String]
214
+ # Required. The user-specified name of the order being placed.
215
+ # @param line_item_info [::Array<::Google::Cloud::Commerce::Consumer::Procurement::V1::LineItemInfo, ::Hash>]
216
+ # Optional. Places order for offer. Required when an offer-based order is
217
+ # being placed.
218
+ # @param request_id [::String]
219
+ # Optional. A unique identifier for this request.
220
+ # The server will ignore subsequent requests that provide a duplicate request
221
+ # ID for at least 120 minutes after the first request.
222
+ #
223
+ # The request ID must be a valid
224
+ # [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format).
225
+ #
226
+ # @yield [response, operation] Access the result along with the RPC operation
227
+ # @yieldparam response [::Gapic::Operation]
228
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
229
+ #
230
+ # @return [::Gapic::Operation]
231
+ #
232
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
233
+ #
234
+ # @example Basic example
235
+ # require "google/cloud/commerce/consumer/procurement/v1"
236
+ #
237
+ # # Create a client object. The client can be reused for multiple calls.
238
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client.new
239
+ #
240
+ # # Create a request. To set request fields, pass in keyword arguments.
241
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest.new
242
+ #
243
+ # # Call the place_order method.
244
+ # result = client.place_order request
245
+ #
246
+ # # The returned object is of type Gapic::Operation. You can use it to
247
+ # # check the status of an operation, cancel it, or wait for results.
248
+ # # Here is how to wait for a response.
249
+ # result.wait_until_done! timeout: 60
250
+ # if result.response?
251
+ # p result.response
252
+ # else
253
+ # puts "No response received."
254
+ # end
255
+ #
256
+ def place_order request, options = nil
257
+ raise ::ArgumentError, "request must be provided" if request.nil?
258
+
259
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest
260
+
261
+ # Converts hash and nil to an options object
262
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
263
+
264
+ # Customize the options with defaults
265
+ metadata = @config.rpcs.place_order.metadata.to_h
266
+
267
+ # Set x-goog-api-client and x-goog-user-project headers
268
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
269
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
270
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION
271
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
272
+
273
+ header_params = {}
274
+ if request.parent
275
+ header_params["parent"] = request.parent
276
+ end
277
+
278
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
279
+ metadata[:"x-goog-request-params"] ||= request_params_header
280
+
281
+ options.apply_defaults timeout: @config.rpcs.place_order.timeout,
282
+ metadata: metadata,
283
+ retry_policy: @config.rpcs.place_order.retry_policy
284
+
285
+ options.apply_defaults timeout: @config.timeout,
286
+ metadata: @config.metadata,
287
+ retry_policy: @config.retry_policy
288
+
289
+ @consumer_procurement_service_stub.call_rpc :place_order, request, options: options do |response, operation|
290
+ response = ::Gapic::Operation.new response, @operations_client, options: options
291
+ yield response, operation if block_given?
292
+ return response
293
+ end
294
+ rescue ::GRPC::BadStatus => e
295
+ raise ::Google::Cloud::Error.from_error(e)
296
+ end
297
+
298
+ ##
299
+ # Returns the requested
300
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order} resource.
301
+ #
302
+ # @overload get_order(request, options = nil)
303
+ # Pass arguments to `get_order` via a request object, either of type
304
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest} or an equivalent Hash.
305
+ #
306
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest, ::Hash]
307
+ # A request object representing the call parameters. Required. To specify no
308
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
309
+ # @param options [::Gapic::CallOptions, ::Hash]
310
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
311
+ #
312
+ # @overload get_order(name: nil)
313
+ # Pass arguments to `get_order` via keyword arguments. Note that at
314
+ # least one keyword argument is required. To specify no parameters, or to keep all
315
+ # the default parameter values, pass an empty Hash as a request object (see above).
316
+ #
317
+ # @param name [::String]
318
+ # Required. The name of the order to retrieve.
319
+ #
320
+ # @yield [response, operation] Access the result along with the RPC operation
321
+ # @yieldparam response [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
322
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
323
+ #
324
+ # @return [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
325
+ #
326
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
327
+ #
328
+ # @example Basic example
329
+ # require "google/cloud/commerce/consumer/procurement/v1"
330
+ #
331
+ # # Create a client object. The client can be reused for multiple calls.
332
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client.new
333
+ #
334
+ # # Create a request. To set request fields, pass in keyword arguments.
335
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest.new
336
+ #
337
+ # # Call the get_order method.
338
+ # result = client.get_order request
339
+ #
340
+ # # The returned object is of type Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
341
+ # p result
342
+ #
343
+ def get_order request, options = nil
344
+ raise ::ArgumentError, "request must be provided" if request.nil?
345
+
346
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest
347
+
348
+ # Converts hash and nil to an options object
349
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
350
+
351
+ # Customize the options with defaults
352
+ metadata = @config.rpcs.get_order.metadata.to_h
353
+
354
+ # Set x-goog-api-client and x-goog-user-project headers
355
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
356
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
357
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION
358
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
+
360
+ header_params = {}
361
+ if request.name
362
+ header_params["name"] = request.name
363
+ end
364
+
365
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
366
+ metadata[:"x-goog-request-params"] ||= request_params_header
367
+
368
+ options.apply_defaults timeout: @config.rpcs.get_order.timeout,
369
+ metadata: metadata,
370
+ retry_policy: @config.rpcs.get_order.retry_policy
371
+
372
+ options.apply_defaults timeout: @config.timeout,
373
+ metadata: @config.metadata,
374
+ retry_policy: @config.retry_policy
375
+
376
+ @consumer_procurement_service_stub.call_rpc :get_order, request, options: options do |response, operation|
377
+ yield response, operation if block_given?
378
+ return response
379
+ end
380
+ rescue ::GRPC::BadStatus => e
381
+ raise ::Google::Cloud::Error.from_error(e)
382
+ end
383
+
384
+ ##
385
+ # Lists {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order}
386
+ # resources that the user has access to, within the scope of the parent
387
+ # resource.
388
+ #
389
+ # @overload list_orders(request, options = nil)
390
+ # Pass arguments to `list_orders` via a request object, either of type
391
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest} or an equivalent Hash.
392
+ #
393
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest, ::Hash]
394
+ # A request object representing the call parameters. Required. To specify no
395
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
396
+ # @param options [::Gapic::CallOptions, ::Hash]
397
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
398
+ #
399
+ # @overload list_orders(parent: nil, page_size: nil, page_token: nil, filter: nil)
400
+ # Pass arguments to `list_orders` via keyword arguments. Note that at
401
+ # least one keyword argument is required. To specify no parameters, or to keep all
402
+ # the default parameter values, pass an empty Hash as a request object (see above).
403
+ #
404
+ # @param parent [::String]
405
+ # Required. The parent resource to query for orders.
406
+ # This field has the form `billingAccounts/{billing-account-id}`.
407
+ # @param page_size [::Integer]
408
+ # The maximum number of entries requested.
409
+ # The default page size is 25 and the maximum page size is 200.
410
+ # @param page_token [::String]
411
+ # The token for fetching the next page.
412
+ # @param filter [::String]
413
+ # Filter that you can use to limit the list request.
414
+ #
415
+ # A query string that can match a selected set of attributes
416
+ # with string values. For example, `display_name=abc`.
417
+ # Supported query attributes are
418
+ #
419
+ # * `display_name`
420
+ #
421
+ # If the query contains special characters other than letters,
422
+ # underscore, or digits, the phrase must be quoted with double quotes. For
423
+ # example, `display_name="foo:bar"`, where the display name needs to be
424
+ # quoted because it contains special character colon.
425
+ #
426
+ # Queries can be combined with `OR`, and `NOT` to form more complex queries.
427
+ # You can also group them to force a desired evaluation order.
428
+ # For example, `display_name=abc OR display_name=def`.
429
+ #
430
+ # @yield [response, operation] Access the result along with the RPC operation
431
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
432
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
433
+ #
434
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
435
+ #
436
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
437
+ #
438
+ # @example Basic example
439
+ # require "google/cloud/commerce/consumer/procurement/v1"
440
+ #
441
+ # # Create a client object. The client can be reused for multiple calls.
442
+ # client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client.new
443
+ #
444
+ # # Create a request. To set request fields, pass in keyword arguments.
445
+ # request = Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest.new
446
+ #
447
+ # # Call the list_orders method.
448
+ # result = client.list_orders request
449
+ #
450
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
451
+ # # over elements, and API calls will be issued to fetch pages as needed.
452
+ # result.each do |item|
453
+ # # Each element is of type ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
454
+ # p item
455
+ # end
456
+ #
457
+ def list_orders request, options = nil
458
+ raise ::ArgumentError, "request must be provided" if request.nil?
459
+
460
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest
461
+
462
+ # Converts hash and nil to an options object
463
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
464
+
465
+ # Customize the options with defaults
466
+ metadata = @config.rpcs.list_orders.metadata.to_h
467
+
468
+ # Set x-goog-api-client and x-goog-user-project headers
469
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
470
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
471
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION
472
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
473
+
474
+ header_params = {}
475
+ if request.parent
476
+ header_params["parent"] = request.parent
477
+ end
478
+
479
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
480
+ metadata[:"x-goog-request-params"] ||= request_params_header
481
+
482
+ options.apply_defaults timeout: @config.rpcs.list_orders.timeout,
483
+ metadata: metadata,
484
+ retry_policy: @config.rpcs.list_orders.retry_policy
485
+
486
+ options.apply_defaults timeout: @config.timeout,
487
+ metadata: @config.metadata,
488
+ retry_policy: @config.retry_policy
489
+
490
+ @consumer_procurement_service_stub.call_rpc :list_orders, request, options: options do |response, operation|
491
+ response = ::Gapic::PagedEnumerable.new @consumer_procurement_service_stub, :list_orders, request, response, operation, options
492
+ yield response, operation if block_given?
493
+ return response
494
+ end
495
+ rescue ::GRPC::BadStatus => e
496
+ raise ::Google::Cloud::Error.from_error(e)
497
+ end
498
+
499
+ ##
500
+ # Configuration class for the ConsumerProcurementService API.
501
+ #
502
+ # This class represents the configuration for ConsumerProcurementService,
503
+ # providing control over timeouts, retry behavior, logging, transport
504
+ # parameters, and other low-level controls. Certain parameters can also be
505
+ # applied individually to specific RPCs. See
506
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client::Configuration::Rpcs}
507
+ # for a list of RPCs that can be configured independently.
508
+ #
509
+ # Configuration can be applied globally to all clients, or to a single client
510
+ # on construction.
511
+ #
512
+ # @example
513
+ #
514
+ # # Modify the global config, setting the timeout for
515
+ # # place_order to 20 seconds,
516
+ # # and all remaining timeouts to 10 seconds.
517
+ # ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client.configure do |config|
518
+ # config.timeout = 10.0
519
+ # config.rpcs.place_order.timeout = 20.0
520
+ # end
521
+ #
522
+ # # Apply the above configuration only to a new client.
523
+ # client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Client.new do |config|
524
+ # config.timeout = 10.0
525
+ # config.rpcs.place_order.timeout = 20.0
526
+ # end
527
+ #
528
+ # @!attribute [rw] endpoint
529
+ # The hostname or hostname:port of the service endpoint.
530
+ # Defaults to `"cloudcommerceconsumerprocurement.googleapis.com"`.
531
+ # @return [::String]
532
+ # @!attribute [rw] credentials
533
+ # Credentials to send with calls. You may provide any of the following types:
534
+ # * (`String`) The path to a service account key file in JSON format
535
+ # * (`Hash`) A service account key as a Hash
536
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
537
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
538
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
539
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
540
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
541
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
542
+ # * (`nil`) indicating no credentials
543
+ # @return [::Object]
544
+ # @!attribute [rw] scope
545
+ # The OAuth scopes
546
+ # @return [::Array<::String>]
547
+ # @!attribute [rw] lib_name
548
+ # The library name as recorded in instrumentation and logging
549
+ # @return [::String]
550
+ # @!attribute [rw] lib_version
551
+ # The library version as recorded in instrumentation and logging
552
+ # @return [::String]
553
+ # @!attribute [rw] channel_args
554
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
555
+ # `GRPC::Core::Channel` object is provided as the credential.
556
+ # @return [::Hash]
557
+ # @!attribute [rw] interceptors
558
+ # An array of interceptors that are run before calls are executed.
559
+ # @return [::Array<::GRPC::ClientInterceptor>]
560
+ # @!attribute [rw] timeout
561
+ # The call timeout in seconds.
562
+ # @return [::Numeric]
563
+ # @!attribute [rw] metadata
564
+ # Additional gRPC headers to be sent with the call.
565
+ # @return [::Hash{::Symbol=>::String}]
566
+ # @!attribute [rw] retry_policy
567
+ # The retry policy. The value is a hash with the following keys:
568
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
569
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
570
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
571
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
572
+ # trigger a retry.
573
+ # @return [::Hash]
574
+ # @!attribute [rw] quota_project
575
+ # A separate project against which to charge quota.
576
+ # @return [::String]
577
+ #
578
+ class Configuration
579
+ extend ::Gapic::Config
580
+
581
+ DEFAULT_ENDPOINT = "cloudcommerceconsumerprocurement.googleapis.com"
582
+
583
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
584
+ config_attr :credentials, nil do |value|
585
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
586
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
587
+ allowed.any? { |klass| klass === value }
588
+ end
589
+ config_attr :scope, nil, ::String, ::Array, nil
590
+ config_attr :lib_name, nil, ::String, nil
591
+ config_attr :lib_version, nil, ::String, nil
592
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
593
+ config_attr :interceptors, nil, ::Array, nil
594
+ config_attr :timeout, nil, ::Numeric, nil
595
+ config_attr :metadata, nil, ::Hash, nil
596
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
597
+ config_attr :quota_project, nil, ::String, nil
598
+
599
+ # @private
600
+ def initialize parent_config = nil
601
+ @parent_config = parent_config unless parent_config.nil?
602
+
603
+ yield self if block_given?
604
+ end
605
+
606
+ ##
607
+ # Configurations for individual RPCs
608
+ # @return [Rpcs]
609
+ #
610
+ def rpcs
611
+ @rpcs ||= begin
612
+ parent_rpcs = nil
613
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
614
+ Rpcs.new parent_rpcs
615
+ end
616
+ end
617
+
618
+ ##
619
+ # Configuration for the channel pool
620
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
621
+ #
622
+ def channel_pool
623
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
624
+ end
625
+
626
+ ##
627
+ # Configuration RPC class for the ConsumerProcurementService API.
628
+ #
629
+ # Includes fields providing the configuration for each RPC in this service.
630
+ # Each configuration object is of type `Gapic::Config::Method` and includes
631
+ # the following configuration fields:
632
+ #
633
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
634
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
635
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
636
+ # include the following keys:
637
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
638
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
639
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
640
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
641
+ # trigger a retry.
642
+ #
643
+ class Rpcs
644
+ ##
645
+ # RPC-specific configuration for `place_order`
646
+ # @return [::Gapic::Config::Method]
647
+ #
648
+ attr_reader :place_order
649
+ ##
650
+ # RPC-specific configuration for `get_order`
651
+ # @return [::Gapic::Config::Method]
652
+ #
653
+ attr_reader :get_order
654
+ ##
655
+ # RPC-specific configuration for `list_orders`
656
+ # @return [::Gapic::Config::Method]
657
+ #
658
+ attr_reader :list_orders
659
+
660
+ # @private
661
+ def initialize parent_rpcs = nil
662
+ place_order_config = parent_rpcs.place_order if parent_rpcs.respond_to? :place_order
663
+ @place_order = ::Gapic::Config::Method.new place_order_config
664
+ get_order_config = parent_rpcs.get_order if parent_rpcs.respond_to? :get_order
665
+ @get_order = ::Gapic::Config::Method.new get_order_config
666
+ list_orders_config = parent_rpcs.list_orders if parent_rpcs.respond_to? :list_orders
667
+ @list_orders = ::Gapic::Config::Method.new list_orders_config
668
+
669
+ yield self if block_given?
670
+ end
671
+ end
672
+ end
673
+ end
674
+ end
675
+ end
676
+ end
677
+ end
678
+ end
679
+ end
680
+ end