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,90 @@
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
+
20
+ module Google
21
+ module Cloud
22
+ module Commerce
23
+ module Consumer
24
+ module Procurement
25
+ module V1
26
+ module ConsumerProcurementService
27
+ # Path helper methods for the ConsumerProcurementService API.
28
+ module Paths
29
+ ##
30
+ # Create a fully-qualified BillingAccount resource string.
31
+ #
32
+ # The resource will be in the following format:
33
+ #
34
+ # `billingAccounts/{billing_account}`
35
+ #
36
+ # @param billing_account [String]
37
+ #
38
+ # @return [::String]
39
+ def billing_account_path billing_account:
40
+ "billingAccounts/#{billing_account}"
41
+ end
42
+
43
+ ##
44
+ # Create a fully-qualified Offer resource string.
45
+ #
46
+ # @overload offer_path(service:, offer:)
47
+ # The resource will be in the following format:
48
+ #
49
+ # `services/{service}/standardOffers/{offer}`
50
+ #
51
+ # @param service [String]
52
+ # @param offer [String]
53
+ #
54
+ # @overload offer_path(consumer_billing_account:, offer:)
55
+ # The resource will be in the following format:
56
+ #
57
+ # `billingAccounts/{consumer_billing_account}/offers/{offer}`
58
+ #
59
+ # @param consumer_billing_account [String]
60
+ # @param offer [String]
61
+ #
62
+ # @return [::String]
63
+ def offer_path **args
64
+ resources = {
65
+ "offer:service" => (proc do |service:, offer:|
66
+ raise ::ArgumentError, "service cannot contain /" if service.to_s.include? "/"
67
+
68
+ "services/#{service}/standardOffers/#{offer}"
69
+ end),
70
+ "consumer_billing_account:offer" => (proc do |consumer_billing_account:, offer:|
71
+ raise ::ArgumentError, "consumer_billing_account cannot contain /" if consumer_billing_account.to_s.include? "/"
72
+
73
+ "billingAccounts/#{consumer_billing_account}/offers/#{offer}"
74
+ end)
75
+ }
76
+
77
+ resource = resources[args.keys.sort.join(":")]
78
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
79
+ resource.call(**args)
80
+ end
81
+
82
+ extend self
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,571 @@
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
+ def place_order request, options = nil
223
+ raise ::ArgumentError, "request must be provided" if request.nil?
224
+
225
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest
226
+
227
+ # Converts hash and nil to an options object
228
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
229
+
230
+ # Customize the options with defaults
231
+ call_metadata = @config.rpcs.place_order.metadata.to_h
232
+
233
+ # Set x-goog-api-client and x-goog-user-project headers
234
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
235
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
236
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
237
+ transports_version_send: [:rest]
238
+
239
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
240
+
241
+ options.apply_defaults timeout: @config.rpcs.place_order.timeout,
242
+ metadata: call_metadata,
243
+ retry_policy: @config.rpcs.place_order.retry_policy
244
+
245
+ options.apply_defaults timeout: @config.timeout,
246
+ metadata: @config.metadata,
247
+ retry_policy: @config.retry_policy
248
+
249
+ @consumer_procurement_service_stub.place_order request, options do |result, operation|
250
+ result = ::Gapic::Operation.new result, @operations_client, options: options
251
+ yield result, operation if block_given?
252
+ return result
253
+ end
254
+ rescue ::Gapic::Rest::Error => e
255
+ raise ::Google::Cloud::Error.from_error(e)
256
+ end
257
+
258
+ ##
259
+ # Returns the requested
260
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order} resource.
261
+ #
262
+ # @overload get_order(request, options = nil)
263
+ # Pass arguments to `get_order` via a request object, either of type
264
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest} or an equivalent Hash.
265
+ #
266
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest, ::Hash]
267
+ # A request object representing the call parameters. Required. To specify no
268
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
269
+ # @param options [::Gapic::CallOptions, ::Hash]
270
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
271
+ #
272
+ # @overload get_order(name: nil)
273
+ # Pass arguments to `get_order` via keyword arguments. Note that at
274
+ # least one keyword argument is required. To specify no parameters, or to keep all
275
+ # the default parameter values, pass an empty Hash as a request object (see above).
276
+ #
277
+ # @param name [::String]
278
+ # Required. The name of the order to retrieve.
279
+ # @yield [result, operation] Access the result along with the TransportOperation object
280
+ # @yieldparam result [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
281
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
282
+ #
283
+ # @return [::Google::Cloud::Commerce::Consumer::Procurement::V1::Order]
284
+ #
285
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
286
+ def get_order request, options = nil
287
+ raise ::ArgumentError, "request must be provided" if request.nil?
288
+
289
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest
290
+
291
+ # Converts hash and nil to an options object
292
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
293
+
294
+ # Customize the options with defaults
295
+ call_metadata = @config.rpcs.get_order.metadata.to_h
296
+
297
+ # Set x-goog-api-client and x-goog-user-project headers
298
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
299
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
300
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
301
+ transports_version_send: [:rest]
302
+
303
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
304
+
305
+ options.apply_defaults timeout: @config.rpcs.get_order.timeout,
306
+ metadata: call_metadata,
307
+ retry_policy: @config.rpcs.get_order.retry_policy
308
+
309
+ options.apply_defaults timeout: @config.timeout,
310
+ metadata: @config.metadata,
311
+ retry_policy: @config.retry_policy
312
+
313
+ @consumer_procurement_service_stub.get_order request, options do |result, operation|
314
+ yield result, operation if block_given?
315
+ return result
316
+ end
317
+ rescue ::Gapic::Rest::Error => e
318
+ raise ::Google::Cloud::Error.from_error(e)
319
+ end
320
+
321
+ ##
322
+ # Lists {::Google::Cloud::Commerce::Consumer::Procurement::V1::Order Order}
323
+ # resources that the user has access to, within the scope of the parent
324
+ # resource.
325
+ #
326
+ # @overload list_orders(request, options = nil)
327
+ # Pass arguments to `list_orders` via a request object, either of type
328
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest} or an equivalent Hash.
329
+ #
330
+ # @param request [::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest, ::Hash]
331
+ # A request object representing the call parameters. Required. To specify no
332
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
333
+ # @param options [::Gapic::CallOptions, ::Hash]
334
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
335
+ #
336
+ # @overload list_orders(parent: nil, page_size: nil, page_token: nil, filter: nil)
337
+ # Pass arguments to `list_orders` via keyword arguments. Note that at
338
+ # least one keyword argument is required. To specify no parameters, or to keep all
339
+ # the default parameter values, pass an empty Hash as a request object (see above).
340
+ #
341
+ # @param parent [::String]
342
+ # Required. The parent resource to query for orders.
343
+ # This field has the form `billingAccounts/{billing-account-id}`.
344
+ # @param page_size [::Integer]
345
+ # The maximum number of entries requested.
346
+ # The default page size is 25 and the maximum page size is 200.
347
+ # @param page_token [::String]
348
+ # The token for fetching the next page.
349
+ # @param filter [::String]
350
+ # Filter that you can use to limit the list request.
351
+ #
352
+ # A query string that can match a selected set of attributes
353
+ # with string values. For example, `display_name=abc`.
354
+ # Supported query attributes are
355
+ #
356
+ # * `display_name`
357
+ #
358
+ # If the query contains special characters other than letters,
359
+ # underscore, or digits, the phrase must be quoted with double quotes. For
360
+ # example, `display_name="foo:bar"`, where the display name needs to be
361
+ # quoted because it contains special character colon.
362
+ #
363
+ # Queries can be combined with `OR`, and `NOT` to form more complex queries.
364
+ # You can also group them to force a desired evaluation order.
365
+ # For example, `display_name=abc OR display_name=def`.
366
+ # @yield [result, operation] Access the result along with the TransportOperation object
367
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
368
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
369
+ #
370
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>]
371
+ #
372
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
373
+ def list_orders request, options = nil
374
+ raise ::ArgumentError, "request must be provided" if request.nil?
375
+
376
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest
377
+
378
+ # Converts hash and nil to an options object
379
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
380
+
381
+ # Customize the options with defaults
382
+ call_metadata = @config.rpcs.list_orders.metadata.to_h
383
+
384
+ # Set x-goog-api-client and x-goog-user-project headers
385
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
386
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
387
+ gapic_version: ::Google::Cloud::Commerce::Consumer::Procurement::V1::VERSION,
388
+ transports_version_send: [:rest]
389
+
390
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
391
+
392
+ options.apply_defaults timeout: @config.rpcs.list_orders.timeout,
393
+ metadata: call_metadata,
394
+ retry_policy: @config.rpcs.list_orders.retry_policy
395
+
396
+ options.apply_defaults timeout: @config.timeout,
397
+ metadata: @config.metadata,
398
+ retry_policy: @config.retry_policy
399
+
400
+ @consumer_procurement_service_stub.list_orders request, options do |result, operation|
401
+ result = ::Gapic::Rest::PagedEnumerable.new @consumer_procurement_service_stub, :list_orders, "orders", request, result, options
402
+ yield result, operation if block_given?
403
+ return result
404
+ end
405
+ rescue ::Gapic::Rest::Error => e
406
+ raise ::Google::Cloud::Error.from_error(e)
407
+ end
408
+
409
+ ##
410
+ # Configuration class for the ConsumerProcurementService REST API.
411
+ #
412
+ # This class represents the configuration for ConsumerProcurementService REST,
413
+ # providing control over timeouts, retry behavior, logging, transport
414
+ # parameters, and other low-level controls. Certain parameters can also be
415
+ # applied individually to specific RPCs. See
416
+ # {::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client::Configuration::Rpcs}
417
+ # for a list of RPCs that can be configured independently.
418
+ #
419
+ # Configuration can be applied globally to all clients, or to a single client
420
+ # on construction.
421
+ #
422
+ # @example
423
+ #
424
+ # # Modify the global config, setting the timeout for
425
+ # # place_order to 20 seconds,
426
+ # # and all remaining timeouts to 10 seconds.
427
+ # ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.configure do |config|
428
+ # config.timeout = 10.0
429
+ # config.rpcs.place_order.timeout = 20.0
430
+ # end
431
+ #
432
+ # # Apply the above configuration only to a new client.
433
+ # client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new do |config|
434
+ # config.timeout = 10.0
435
+ # config.rpcs.place_order.timeout = 20.0
436
+ # end
437
+ #
438
+ # @!attribute [rw] endpoint
439
+ # The hostname or hostname:port of the service endpoint.
440
+ # Defaults to `"cloudcommerceconsumerprocurement.googleapis.com"`.
441
+ # @return [::String]
442
+ # @!attribute [rw] credentials
443
+ # Credentials to send with calls. You may provide any of the following types:
444
+ # * (`String`) The path to a service account key file in JSON format
445
+ # * (`Hash`) A service account key as a Hash
446
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
447
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
448
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
449
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
450
+ # * (`nil`) indicating no credentials
451
+ # @return [::Object]
452
+ # @!attribute [rw] scope
453
+ # The OAuth scopes
454
+ # @return [::Array<::String>]
455
+ # @!attribute [rw] lib_name
456
+ # The library name as recorded in instrumentation and logging
457
+ # @return [::String]
458
+ # @!attribute [rw] lib_version
459
+ # The library version as recorded in instrumentation and logging
460
+ # @return [::String]
461
+ # @!attribute [rw] timeout
462
+ # The call timeout in seconds.
463
+ # @return [::Numeric]
464
+ # @!attribute [rw] metadata
465
+ # Additional headers to be sent with the call.
466
+ # @return [::Hash{::Symbol=>::String}]
467
+ # @!attribute [rw] retry_policy
468
+ # The retry policy. The value is a hash with the following keys:
469
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
470
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
471
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
472
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
473
+ # trigger a retry.
474
+ # @return [::Hash]
475
+ # @!attribute [rw] quota_project
476
+ # A separate project against which to charge quota.
477
+ # @return [::String]
478
+ #
479
+ class Configuration
480
+ extend ::Gapic::Config
481
+
482
+ DEFAULT_ENDPOINT = "cloudcommerceconsumerprocurement.googleapis.com"
483
+
484
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
485
+ config_attr :credentials, nil do |value|
486
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
487
+ allowed.any? { |klass| klass === value }
488
+ end
489
+ config_attr :scope, nil, ::String, ::Array, nil
490
+ config_attr :lib_name, nil, ::String, nil
491
+ config_attr :lib_version, nil, ::String, nil
492
+ config_attr :timeout, nil, ::Numeric, nil
493
+ config_attr :metadata, nil, ::Hash, nil
494
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
495
+ config_attr :quota_project, nil, ::String, nil
496
+
497
+ # @private
498
+ def initialize parent_config = nil
499
+ @parent_config = parent_config unless parent_config.nil?
500
+
501
+ yield self if block_given?
502
+ end
503
+
504
+ ##
505
+ # Configurations for individual RPCs
506
+ # @return [Rpcs]
507
+ #
508
+ def rpcs
509
+ @rpcs ||= begin
510
+ parent_rpcs = nil
511
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
512
+ Rpcs.new parent_rpcs
513
+ end
514
+ end
515
+
516
+ ##
517
+ # Configuration RPC class for the ConsumerProcurementService API.
518
+ #
519
+ # Includes fields providing the configuration for each RPC in this service.
520
+ # Each configuration object is of type `Gapic::Config::Method` and includes
521
+ # the following configuration fields:
522
+ #
523
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
524
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
525
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
526
+ # include the following keys:
527
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
528
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
529
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
530
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
531
+ # trigger a retry.
532
+ #
533
+ class Rpcs
534
+ ##
535
+ # RPC-specific configuration for `place_order`
536
+ # @return [::Gapic::Config::Method]
537
+ #
538
+ attr_reader :place_order
539
+ ##
540
+ # RPC-specific configuration for `get_order`
541
+ # @return [::Gapic::Config::Method]
542
+ #
543
+ attr_reader :get_order
544
+ ##
545
+ # RPC-specific configuration for `list_orders`
546
+ # @return [::Gapic::Config::Method]
547
+ #
548
+ attr_reader :list_orders
549
+
550
+ # @private
551
+ def initialize parent_rpcs = nil
552
+ place_order_config = parent_rpcs.place_order if parent_rpcs.respond_to? :place_order
553
+ @place_order = ::Gapic::Config::Method.new place_order_config
554
+ get_order_config = parent_rpcs.get_order if parent_rpcs.respond_to? :get_order
555
+ @get_order = ::Gapic::Config::Method.new get_order_config
556
+ list_orders_config = parent_rpcs.list_orders if parent_rpcs.respond_to? :list_orders
557
+ @list_orders = ::Gapic::Config::Method.new list_orders_config
558
+
559
+ yield self if block_given?
560
+ end
561
+ end
562
+ end
563
+ end
564
+ end
565
+ end
566
+ end
567
+ end
568
+ end
569
+ end
570
+ end
571
+ end