google-shopping-merchant-promotions-v1 0.a → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +122 -0
  4. data/README.md +154 -8
  5. data/lib/google/shopping/merchant/promotions/v1/promotions_common_pb.rb +62 -0
  6. data/lib/google/shopping/merchant/promotions/v1/promotions_pb.rb +57 -0
  7. data/lib/google/shopping/merchant/promotions/v1/promotions_service/client.rb +684 -0
  8. data/lib/google/shopping/merchant/promotions/v1/promotions_service/credentials.rb +49 -0
  9. data/lib/google/shopping/merchant/promotions/v1/promotions_service/paths.rb +52 -0
  10. data/lib/google/shopping/merchant/promotions/v1/promotions_service/rest/client.rb +637 -0
  11. data/lib/google/shopping/merchant/promotions/v1/promotions_service/rest/service_stub.rb +267 -0
  12. data/lib/google/shopping/merchant/promotions/v1/promotions_service/rest.rb +54 -0
  13. data/lib/google/shopping/merchant/promotions/v1/promotions_service.rb +57 -0
  14. data/lib/google/shopping/merchant/promotions/v1/promotions_services_pb.rb +60 -0
  15. data/lib/google/shopping/merchant/promotions/v1/rest.rb +39 -0
  16. data/lib/google/shopping/merchant/promotions/v1/version.rb +7 -2
  17. data/lib/google/shopping/merchant/promotions/v1.rb +47 -0
  18. data/lib/google-shopping-merchant-promotions-v1.rb +21 -0
  19. data/proto_docs/README.md +4 -0
  20. data/proto_docs/google/api/client.rb +473 -0
  21. data/proto_docs/google/api/field_behavior.rb +85 -0
  22. data/proto_docs/google/api/launch_stage.rb +71 -0
  23. data/proto_docs/google/api/resource.rb +227 -0
  24. data/proto_docs/google/protobuf/duration.rb +98 -0
  25. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  26. data/proto_docs/google/shopping/merchant/promotions/v1/promotions.rb +176 -0
  27. data/proto_docs/google/shopping/merchant/promotions/v1/promotions_common.rb +446 -0
  28. data/proto_docs/google/shopping/type/types.rb +210 -0
  29. data/proto_docs/google/type/interval.rb +45 -0
  30. metadata +88 -9
@@ -0,0 +1,684 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/shopping/merchant/promotions/v1/promotions_pb"
21
+
22
+ module Google
23
+ module Shopping
24
+ module Merchant
25
+ module Promotions
26
+ module V1
27
+ module PromotionsService
28
+ ##
29
+ # Client for the PromotionsService service.
30
+ #
31
+ # Service to manage promotions for products.
32
+ #
33
+ class Client
34
+ # @private
35
+ API_VERSION = ""
36
+
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$"
39
+
40
+ include Paths
41
+
42
+ # @private
43
+ attr_reader :promotions_service_stub
44
+
45
+ ##
46
+ # Configure the PromotionsService Client class.
47
+ #
48
+ # See {::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all PromotionsService clients
54
+ # ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.configure do |config|
55
+ # config.timeout = 10.0
56
+ # end
57
+ #
58
+ # @yield [config] Configure the Client client.
59
+ # @yieldparam config [Client::Configuration]
60
+ #
61
+ # @return [Client::Configuration]
62
+ #
63
+ def self.configure
64
+ @configure ||= begin
65
+ namespace = ["Google", "Shopping", "Merchant", "Promotions", "V1"]
66
+ parent_config = while namespace.any?
67
+ parent_name = namespace.join "::"
68
+ parent_const = const_get parent_name
69
+ break parent_const.configure if parent_const.respond_to? :configure
70
+ namespace.pop
71
+ end
72
+ default_config = Client::Configuration.new parent_config
73
+
74
+ default_config.timeout = 60.0
75
+ default_config.retry_policy = {
76
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
77
+ }
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the PromotionsService Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # The effective universe domain
107
+ #
108
+ # @return [String]
109
+ #
110
+ def universe_domain
111
+ @promotions_service_stub.universe_domain
112
+ end
113
+
114
+ ##
115
+ # Create a new PromotionsService client object.
116
+ #
117
+ # @example
118
+ #
119
+ # # Create a client using the default configuration
120
+ # client = ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new
121
+ #
122
+ # # Create a client using a custom configuration
123
+ # client = ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the PromotionsService client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ def initialize
131
+ # These require statements are intentionally placed here to initialize
132
+ # the gRPC module only when it's required.
133
+ # See https://github.com/googleapis/toolkit/issues/446
134
+ require "gapic/grpc"
135
+ require "google/shopping/merchant/promotions/v1/promotions_services_pb"
136
+
137
+ # Create the configuration object
138
+ @config = Configuration.new Client.configure
139
+
140
+ # Yield the configuration if needed
141
+ yield @config if block_given?
142
+
143
+ # Create credentials
144
+ credentials = @config.credentials
145
+ # Use self-signed JWT if the endpoint is unchanged from default,
146
+ # but only if the default endpoint does not have a region prefix.
147
+ enable_self_signed_jwt = @config.endpoint.nil? ||
148
+ (@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
+ @promotions_service_stub = ::Gapic::ServiceStub.new(
159
+ ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Stub,
160
+ credentials: credentials,
161
+ endpoint: @config.endpoint,
162
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
163
+ universe_domain: @config.universe_domain,
164
+ channel_args: @config.channel_args,
165
+ interceptors: @config.interceptors,
166
+ channel_pool_config: @config.channel_pool,
167
+ logger: @config.logger
168
+ )
169
+
170
+ @promotions_service_stub.stub_logger&.info do |entry|
171
+ entry.set_system_name
172
+ entry.set_service
173
+ entry.message = "Created client for #{entry.service}"
174
+ entry.set_credentials_fields credentials
175
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
176
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
177
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
178
+ end
179
+ end
180
+
181
+ ##
182
+ # The logger used for request/response debug logging.
183
+ #
184
+ # @return [Logger]
185
+ #
186
+ def logger
187
+ @promotions_service_stub.logger
188
+ end
189
+
190
+ # Service calls
191
+
192
+ ##
193
+ # Inserts a promotion for your Merchant Center account. If the promotion
194
+ # already exists, then it updates the promotion instead.
195
+ #
196
+ # @overload insert_promotion(request, options = nil)
197
+ # Pass arguments to `insert_promotion` via a request object, either of type
198
+ # {::Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest} or an equivalent Hash.
199
+ #
200
+ # @param request [::Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest, ::Hash]
201
+ # A request object representing the call parameters. Required. To specify no
202
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
203
+ # @param options [::Gapic::CallOptions, ::Hash]
204
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
205
+ #
206
+ # @overload insert_promotion(parent: nil, promotion: nil, data_source: nil)
207
+ # Pass arguments to `insert_promotion` via keyword arguments. Note that at
208
+ # least one keyword argument is required. To specify no parameters, or to keep all
209
+ # the default parameter values, pass an empty Hash as a request object (see above).
210
+ #
211
+ # @param parent [::String]
212
+ # Required. The account where the promotion will be inserted.
213
+ # Format: accounts/\\{account}
214
+ # @param promotion [::Google::Shopping::Merchant::Promotions::V1::Promotion, ::Hash]
215
+ # Required. The promotion to insert.
216
+ # @param data_source [::String]
217
+ # Required. The data source of the
218
+ # [promotion](https://support.google.com/merchants/answer/6396268?sjid=5155774230887277618-NC)
219
+ # Format:
220
+ # `accounts/{account}/dataSources/{datasource}`.
221
+ #
222
+ # @yield [response, operation] Access the result along with the RPC operation
223
+ # @yieldparam response [::Google::Shopping::Merchant::Promotions::V1::Promotion]
224
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
225
+ #
226
+ # @return [::Google::Shopping::Merchant::Promotions::V1::Promotion]
227
+ #
228
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
229
+ #
230
+ # @example Basic example
231
+ # require "google/shopping/merchant/promotions/v1"
232
+ #
233
+ # # Create a client object. The client can be reused for multiple calls.
234
+ # client = Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new
235
+ #
236
+ # # Create a request. To set request fields, pass in keyword arguments.
237
+ # request = Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest.new
238
+ #
239
+ # # Call the insert_promotion method.
240
+ # result = client.insert_promotion request
241
+ #
242
+ # # The returned object is of type Google::Shopping::Merchant::Promotions::V1::Promotion.
243
+ # p result
244
+ #
245
+ def insert_promotion request, options = nil
246
+ raise ::ArgumentError, "request must be provided" if request.nil?
247
+
248
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest
249
+
250
+ # Converts hash and nil to an options object
251
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
252
+
253
+ # Customize the options with defaults
254
+ metadata = @config.rpcs.insert_promotion.metadata.to_h
255
+
256
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
257
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
258
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
259
+ gapic_version: ::Google::Shopping::Merchant::Promotions::V1::VERSION
260
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
261
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
262
+
263
+ header_params = {}
264
+ if request.parent
265
+ header_params["parent"] = request.parent
266
+ end
267
+
268
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
269
+ metadata[:"x-goog-request-params"] ||= request_params_header
270
+
271
+ options.apply_defaults timeout: @config.rpcs.insert_promotion.timeout,
272
+ metadata: metadata,
273
+ retry_policy: @config.rpcs.insert_promotion.retry_policy
274
+
275
+ options.apply_defaults timeout: @config.timeout,
276
+ metadata: @config.metadata,
277
+ retry_policy: @config.retry_policy
278
+
279
+ @promotions_service_stub.call_rpc :insert_promotion, request, options: options do |response, operation|
280
+ yield response, operation if block_given?
281
+ end
282
+ rescue ::GRPC::BadStatus => e
283
+ raise ::Google::Cloud::Error.from_error(e)
284
+ end
285
+
286
+ ##
287
+ # Retrieves the promotion from your Merchant Center account.
288
+ #
289
+ # After inserting or updating a promotion input, it may take several
290
+ # minutes before the updated promotion can be retrieved.
291
+ #
292
+ # @overload get_promotion(request, options = nil)
293
+ # Pass arguments to `get_promotion` via a request object, either of type
294
+ # {::Google::Shopping::Merchant::Promotions::V1::GetPromotionRequest} or an equivalent Hash.
295
+ #
296
+ # @param request [::Google::Shopping::Merchant::Promotions::V1::GetPromotionRequest, ::Hash]
297
+ # A request object representing the call parameters. Required. To specify no
298
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
299
+ # @param options [::Gapic::CallOptions, ::Hash]
300
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
301
+ #
302
+ # @overload get_promotion(name: nil)
303
+ # Pass arguments to `get_promotion` via keyword arguments. Note that at
304
+ # least one keyword argument is required. To specify no parameters, or to keep all
305
+ # the default parameter values, pass an empty Hash as a request object (see above).
306
+ #
307
+ # @param name [::String]
308
+ # Required. The name of the promotion to retrieve.
309
+ # Format: `accounts/{account}/promotions/{promotions}`
310
+ #
311
+ # @yield [response, operation] Access the result along with the RPC operation
312
+ # @yieldparam response [::Google::Shopping::Merchant::Promotions::V1::Promotion]
313
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
314
+ #
315
+ # @return [::Google::Shopping::Merchant::Promotions::V1::Promotion]
316
+ #
317
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
318
+ #
319
+ # @example Basic example
320
+ # require "google/shopping/merchant/promotions/v1"
321
+ #
322
+ # # Create a client object. The client can be reused for multiple calls.
323
+ # client = Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new
324
+ #
325
+ # # Create a request. To set request fields, pass in keyword arguments.
326
+ # request = Google::Shopping::Merchant::Promotions::V1::GetPromotionRequest.new
327
+ #
328
+ # # Call the get_promotion method.
329
+ # result = client.get_promotion request
330
+ #
331
+ # # The returned object is of type Google::Shopping::Merchant::Promotions::V1::Promotion.
332
+ # p result
333
+ #
334
+ def get_promotion request, options = nil
335
+ raise ::ArgumentError, "request must be provided" if request.nil?
336
+
337
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1::GetPromotionRequest
338
+
339
+ # Converts hash and nil to an options object
340
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
341
+
342
+ # Customize the options with defaults
343
+ metadata = @config.rpcs.get_promotion.metadata.to_h
344
+
345
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
346
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
347
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
348
+ gapic_version: ::Google::Shopping::Merchant::Promotions::V1::VERSION
349
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
350
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
351
+
352
+ header_params = {}
353
+ if request.name
354
+ header_params["name"] = request.name
355
+ end
356
+
357
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
358
+ metadata[:"x-goog-request-params"] ||= request_params_header
359
+
360
+ options.apply_defaults timeout: @config.rpcs.get_promotion.timeout,
361
+ metadata: metadata,
362
+ retry_policy: @config.rpcs.get_promotion.retry_policy
363
+
364
+ options.apply_defaults timeout: @config.timeout,
365
+ metadata: @config.metadata,
366
+ retry_policy: @config.retry_policy
367
+
368
+ @promotions_service_stub.call_rpc :get_promotion, request, options: options do |response, operation|
369
+ yield response, operation if block_given?
370
+ end
371
+ rescue ::GRPC::BadStatus => e
372
+ raise ::Google::Cloud::Error.from_error(e)
373
+ end
374
+
375
+ ##
376
+ # Lists the promotions in your Merchant Center account. The
377
+ # response might contain fewer items than specified by `pageSize`. Rely on
378
+ # `pageToken` to determine if there are more items to be requested.
379
+ #
380
+ # After inserting or updating a promotion, it may take several minutes before
381
+ # the updated processed promotion can be retrieved.
382
+ #
383
+ # @overload list_promotions(request, options = nil)
384
+ # Pass arguments to `list_promotions` via a request object, either of type
385
+ # {::Google::Shopping::Merchant::Promotions::V1::ListPromotionsRequest} or an equivalent Hash.
386
+ #
387
+ # @param request [::Google::Shopping::Merchant::Promotions::V1::ListPromotionsRequest, ::Hash]
388
+ # A request object representing the call parameters. Required. To specify no
389
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
390
+ # @param options [::Gapic::CallOptions, ::Hash]
391
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
392
+ #
393
+ # @overload list_promotions(parent: nil, page_size: nil, page_token: nil)
394
+ # Pass arguments to `list_promotions` via keyword arguments. Note that at
395
+ # least one keyword argument is required. To specify no parameters, or to keep all
396
+ # the default parameter values, pass an empty Hash as a request object (see above).
397
+ #
398
+ # @param parent [::String]
399
+ # Required. The account to list processed promotions for.
400
+ # Format: `accounts/{account}`
401
+ # @param page_size [::Integer]
402
+ # Optional. The maximum number of promotions to return. The service may
403
+ # return fewer than this value. The maximum value is 250; values above 250
404
+ # will be coerced to 250. If unspecified, the maximum number of promotions
405
+ # will be returned.
406
+ # @param page_token [::String]
407
+ # Optional. A page token, received from a previous `ListPromotions` call.
408
+ # Provide this to retrieve the subsequent page.
409
+ #
410
+ # When paginating, all other parameters provided to `ListPromotions` must
411
+ # match the call that provided the page token.
412
+ #
413
+ # @yield [response, operation] Access the result along with the RPC operation
414
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Promotions::V1::Promotion>]
415
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
416
+ #
417
+ # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Promotions::V1::Promotion>]
418
+ #
419
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
420
+ #
421
+ # @example Basic example
422
+ # require "google/shopping/merchant/promotions/v1"
423
+ #
424
+ # # Create a client object. The client can be reused for multiple calls.
425
+ # client = Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new
426
+ #
427
+ # # Create a request. To set request fields, pass in keyword arguments.
428
+ # request = Google::Shopping::Merchant::Promotions::V1::ListPromotionsRequest.new
429
+ #
430
+ # # Call the list_promotions method.
431
+ # result = client.list_promotions request
432
+ #
433
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
434
+ # # over elements, and API calls will be issued to fetch pages as needed.
435
+ # result.each do |item|
436
+ # # Each element is of type ::Google::Shopping::Merchant::Promotions::V1::Promotion.
437
+ # p item
438
+ # end
439
+ #
440
+ def list_promotions request, options = nil
441
+ raise ::ArgumentError, "request must be provided" if request.nil?
442
+
443
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1::ListPromotionsRequest
444
+
445
+ # Converts hash and nil to an options object
446
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
447
+
448
+ # Customize the options with defaults
449
+ metadata = @config.rpcs.list_promotions.metadata.to_h
450
+
451
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
452
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
453
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
454
+ gapic_version: ::Google::Shopping::Merchant::Promotions::V1::VERSION
455
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
456
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
457
+
458
+ header_params = {}
459
+ if request.parent
460
+ header_params["parent"] = request.parent
461
+ end
462
+
463
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
464
+ metadata[:"x-goog-request-params"] ||= request_params_header
465
+
466
+ options.apply_defaults timeout: @config.rpcs.list_promotions.timeout,
467
+ metadata: metadata,
468
+ retry_policy: @config.rpcs.list_promotions.retry_policy
469
+
470
+ options.apply_defaults timeout: @config.timeout,
471
+ metadata: @config.metadata,
472
+ retry_policy: @config.retry_policy
473
+
474
+ @promotions_service_stub.call_rpc :list_promotions, request, options: options do |response, operation|
475
+ response = ::Gapic::PagedEnumerable.new @promotions_service_stub, :list_promotions, request, response, operation, options
476
+ yield response, operation if block_given?
477
+ throw :response, response
478
+ end
479
+ rescue ::GRPC::BadStatus => e
480
+ raise ::Google::Cloud::Error.from_error(e)
481
+ end
482
+
483
+ ##
484
+ # Configuration class for the PromotionsService API.
485
+ #
486
+ # This class represents the configuration for PromotionsService,
487
+ # providing control over timeouts, retry behavior, logging, transport
488
+ # parameters, and other low-level controls. Certain parameters can also be
489
+ # applied individually to specific RPCs. See
490
+ # {::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client::Configuration::Rpcs}
491
+ # for a list of RPCs that can be configured independently.
492
+ #
493
+ # Configuration can be applied globally to all clients, or to a single client
494
+ # on construction.
495
+ #
496
+ # @example
497
+ #
498
+ # # Modify the global config, setting the timeout for
499
+ # # insert_promotion to 20 seconds,
500
+ # # and all remaining timeouts to 10 seconds.
501
+ # ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.configure do |config|
502
+ # config.timeout = 10.0
503
+ # config.rpcs.insert_promotion.timeout = 20.0
504
+ # end
505
+ #
506
+ # # Apply the above configuration only to a new client.
507
+ # client = ::Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client.new do |config|
508
+ # config.timeout = 10.0
509
+ # config.rpcs.insert_promotion.timeout = 20.0
510
+ # end
511
+ #
512
+ # @!attribute [rw] endpoint
513
+ # A custom service endpoint, as a hostname or hostname:port. The default is
514
+ # nil, indicating to use the default endpoint in the current universe domain.
515
+ # @return [::String,nil]
516
+ # @!attribute [rw] credentials
517
+ # Credentials to send with calls. You may provide any of the following types:
518
+ # * (`String`) The path to a service account key file in JSON format
519
+ # * (`Hash`) A service account key as a Hash
520
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
521
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
522
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
523
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
524
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
525
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
526
+ # * (`nil`) indicating no credentials
527
+ #
528
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
529
+ # external source for authentication to Google Cloud, you must validate it before
530
+ # providing it to a Google API client library. Providing an unvalidated credential
531
+ # configuration to Google APIs can compromise the security of your systems and data.
532
+ # For more information, refer to [Validate credential configurations from external
533
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
534
+ # @return [::Object]
535
+ # @!attribute [rw] scope
536
+ # The OAuth scopes
537
+ # @return [::Array<::String>]
538
+ # @!attribute [rw] lib_name
539
+ # The library name as recorded in instrumentation and logging
540
+ # @return [::String]
541
+ # @!attribute [rw] lib_version
542
+ # The library version as recorded in instrumentation and logging
543
+ # @return [::String]
544
+ # @!attribute [rw] channel_args
545
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
546
+ # `GRPC::Core::Channel` object is provided as the credential.
547
+ # @return [::Hash]
548
+ # @!attribute [rw] interceptors
549
+ # An array of interceptors that are run before calls are executed.
550
+ # @return [::Array<::GRPC::ClientInterceptor>]
551
+ # @!attribute [rw] timeout
552
+ # The call timeout in seconds.
553
+ # @return [::Numeric]
554
+ # @!attribute [rw] metadata
555
+ # Additional gRPC headers to be sent with the call.
556
+ # @return [::Hash{::Symbol=>::String}]
557
+ # @!attribute [rw] retry_policy
558
+ # The retry policy. The value is a hash with the following keys:
559
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
560
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
561
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
562
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
563
+ # trigger a retry.
564
+ # @return [::Hash]
565
+ # @!attribute [rw] quota_project
566
+ # A separate project against which to charge quota.
567
+ # @return [::String]
568
+ # @!attribute [rw] universe_domain
569
+ # The universe domain within which to make requests. This determines the
570
+ # default endpoint URL. The default value of nil uses the environment
571
+ # universe (usually the default "googleapis.com" universe).
572
+ # @return [::String,nil]
573
+ # @!attribute [rw] logger
574
+ # A custom logger to use for request/response debug logging, or the value
575
+ # `:default` (the default) to construct a default logger, or `nil` to
576
+ # explicitly disable logging.
577
+ # @return [::Logger,:default,nil]
578
+ #
579
+ class Configuration
580
+ extend ::Gapic::Config
581
+
582
+ # @private
583
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
584
+ DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
585
+
586
+ config_attr :endpoint, nil, ::String, nil
587
+ config_attr :credentials, nil do |value|
588
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
589
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel
590
+ allowed.any? { |klass| klass === value }
591
+ end
592
+ config_attr :scope, nil, ::String, ::Array, nil
593
+ config_attr :lib_name, nil, ::String, nil
594
+ config_attr :lib_version, nil, ::String, nil
595
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
596
+ config_attr :interceptors, nil, ::Array, nil
597
+ config_attr :timeout, nil, ::Numeric, nil
598
+ config_attr :metadata, nil, ::Hash, nil
599
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
600
+ config_attr :quota_project, nil, ::String, nil
601
+ config_attr :universe_domain, nil, ::String, nil
602
+ config_attr :logger, :default, ::Logger, nil, :default
603
+
604
+ # @private
605
+ def initialize parent_config = nil
606
+ @parent_config = parent_config unless parent_config.nil?
607
+
608
+ yield self if block_given?
609
+ end
610
+
611
+ ##
612
+ # Configurations for individual RPCs
613
+ # @return [Rpcs]
614
+ #
615
+ def rpcs
616
+ @rpcs ||= begin
617
+ parent_rpcs = nil
618
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
619
+ Rpcs.new parent_rpcs
620
+ end
621
+ end
622
+
623
+ ##
624
+ # Configuration for the channel pool
625
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
626
+ #
627
+ def channel_pool
628
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
629
+ end
630
+
631
+ ##
632
+ # Configuration RPC class for the PromotionsService API.
633
+ #
634
+ # Includes fields providing the configuration for each RPC in this service.
635
+ # Each configuration object is of type `Gapic::Config::Method` and includes
636
+ # the following configuration fields:
637
+ #
638
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
639
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
640
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
641
+ # include the following keys:
642
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
643
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
644
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
645
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
646
+ # trigger a retry.
647
+ #
648
+ class Rpcs
649
+ ##
650
+ # RPC-specific configuration for `insert_promotion`
651
+ # @return [::Gapic::Config::Method]
652
+ #
653
+ attr_reader :insert_promotion
654
+ ##
655
+ # RPC-specific configuration for `get_promotion`
656
+ # @return [::Gapic::Config::Method]
657
+ #
658
+ attr_reader :get_promotion
659
+ ##
660
+ # RPC-specific configuration for `list_promotions`
661
+ # @return [::Gapic::Config::Method]
662
+ #
663
+ attr_reader :list_promotions
664
+
665
+ # @private
666
+ def initialize parent_rpcs = nil
667
+ insert_promotion_config = parent_rpcs.insert_promotion if parent_rpcs.respond_to? :insert_promotion
668
+ @insert_promotion = ::Gapic::Config::Method.new insert_promotion_config
669
+ get_promotion_config = parent_rpcs.get_promotion if parent_rpcs.respond_to? :get_promotion
670
+ @get_promotion = ::Gapic::Config::Method.new get_promotion_config
671
+ list_promotions_config = parent_rpcs.list_promotions if parent_rpcs.respond_to? :list_promotions
672
+ @list_promotions = ::Gapic::Config::Method.new list_promotions_config
673
+
674
+ yield self if block_given?
675
+ end
676
+ end
677
+ end
678
+ end
679
+ end
680
+ end
681
+ end
682
+ end
683
+ end
684
+ end