google-shopping-merchant-products-v1 0.a → 0.1.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 (42) 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/products/v1/product_inputs_service/client.rb +715 -0
  6. data/lib/google/shopping/merchant/products/v1/product_inputs_service/credentials.rb +49 -0
  7. data/lib/google/shopping/merchant/products/v1/product_inputs_service/paths.rb +66 -0
  8. data/lib/google/shopping/merchant/products/v1/product_inputs_service/rest/client.rb +668 -0
  9. data/lib/google/shopping/merchant/products/v1/product_inputs_service/rest/service_stub.rb +268 -0
  10. data/lib/google/shopping/merchant/products/v1/product_inputs_service/rest.rb +54 -0
  11. data/lib/google/shopping/merchant/products/v1/product_inputs_service.rb +57 -0
  12. data/lib/google/shopping/merchant/products/v1/productinputs_pb.rb +59 -0
  13. data/lib/google/shopping/merchant/products/v1/productinputs_services_pb.rb +69 -0
  14. data/lib/google/shopping/merchant/products/v1/products_common_pb.rb +91 -0
  15. data/lib/google/shopping/merchant/products/v1/products_pb.rb +56 -0
  16. data/lib/google/shopping/merchant/products/v1/products_service/client.rb +591 -0
  17. data/lib/google/shopping/merchant/products/v1/products_service/credentials.rb +49 -0
  18. data/lib/google/shopping/merchant/products/v1/products_service/paths.rb +66 -0
  19. data/lib/google/shopping/merchant/products/v1/products_service/rest/client.rb +551 -0
  20. data/lib/google/shopping/merchant/products/v1/products_service/rest/service_stub.rb +205 -0
  21. data/lib/google/shopping/merchant/products/v1/products_service/rest.rb +54 -0
  22. data/lib/google/shopping/merchant/products/v1/products_service.rb +57 -0
  23. data/lib/google/shopping/merchant/products/v1/products_services_pb.rb +57 -0
  24. data/lib/google/shopping/merchant/products/v1/rest.rb +40 -0
  25. data/lib/google/shopping/merchant/products/v1/version.rb +7 -2
  26. data/lib/google/shopping/merchant/products/v1.rb +48 -0
  27. data/lib/google-shopping-merchant-products-v1.rb +21 -0
  28. data/proto_docs/README.md +4 -0
  29. data/proto_docs/google/api/client.rb +473 -0
  30. data/proto_docs/google/api/field_behavior.rb +85 -0
  31. data/proto_docs/google/api/launch_stage.rb +71 -0
  32. data/proto_docs/google/api/resource.rb +227 -0
  33. data/proto_docs/google/protobuf/duration.rb +98 -0
  34. data/proto_docs/google/protobuf/empty.rb +34 -0
  35. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  36. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  37. data/proto_docs/google/shopping/merchant/products/v1/productinputs.rb +221 -0
  38. data/proto_docs/google/shopping/merchant/products/v1/products.rb +175 -0
  39. data/proto_docs/google/shopping/merchant/products/v1/products_common.rb +1303 -0
  40. data/proto_docs/google/shopping/type/types.rb +210 -0
  41. data/proto_docs/google/type/interval.rb +45 -0
  42. metadata +100 -9
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: google/shopping/merchant/products/v1/products.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require 'google/api/annotations_pb'
8
+ require 'google/api/client_pb'
9
+ require 'google/api/field_behavior_pb'
10
+ require 'google/api/resource_pb'
11
+ require 'google/shopping/merchant/products/v1/products_common_pb'
12
+ require 'google/shopping/type/types_pb'
13
+
14
+
15
+ descriptor_data = "\n3google/shopping/merchant/products/v1/products.proto\x12$google.shopping.merchant.products.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a:google/shopping/merchant/products/v1/products_common.proto\x1a google/shopping/type/types.proto\"\xef\x04\n\x07Product\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x0clegacy_local\x18\x0b \x01(\x08\x42\x03\xe0\x41\x03\x12\x15\n\x08offer_id\x18\x03 \x01(\tB\x03\xe0\x41\x03\x12\x1d\n\x10\x63ontent_language\x18\x04 \x01(\tB\x03\xe0\x41\x03\x12\x17\n\nfeed_label\x18\x05 \x01(\tB\x03\xe0\x41\x03\x12\x18\n\x0b\x64\x61ta_source\x18\x06 \x01(\tB\x03\xe0\x41\x03\x12 \n\x0eversion_number\x18\x07 \x01(\x03\x42\x03\xe0\x41\x03H\x00\x88\x01\x01\x12X\n\x12product_attributes\x18\r \x01(\x0b\x32\x37.google.shopping.merchant.products.v1.ProductAttributesB\x03\xe0\x41\x03\x12\x45\n\x11\x63ustom_attributes\x18\t \x03(\x0b\x32%.google.shopping.type.CustomAttributeB\x03\xe0\x41\x03\x12P\n\x0eproduct_status\x18\n \x01(\x0b\x32\x33.google.shopping.merchant.products.v1.ProductStatusB\x03\xe0\x41\x03\x12Z\n\x13\x61utomated_discounts\x18\x0c \x01(\x0b\x32\x38.google.shopping.merchant.products.v1.AutomatedDiscountsB\x03\xe0\x41\x03:N\xea\x41K\n\"merchantapi.googleapis.com/Product\x12%accounts/{account}/products/{product}B\x11\n\x0f_version_number\"M\n\x11GetProductRequest\x12\x38\n\x04name\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"merchantapi.googleapis.com/Product\"x\n\x13ListProductsRequest\x12:\n\x06parent\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\x12\"merchantapi.googleapis.com/Product\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"p\n\x14ListProductsResponse\x12?\n\x08products\x18\x01 \x03(\x0b\x32-.google.shopping.merchant.products.v1.Product\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xcf\x03\n\x0fProductsService\x12\xae\x01\n\nGetProduct\x12\x37.google.shopping.merchant.products.v1.GetProductRequest\x1a-.google.shopping.merchant.products.v1.Product\"8\xda\x41\x04name\x82\xd3\xe4\x93\x02+\x12)/products/v1/{name=accounts/*/products/*}\x12\xc1\x01\n\x0cListProducts\x12\x39.google.shopping.merchant.products.v1.ListProductsRequest\x1a:.google.shopping.merchant.products.v1.ListProductsResponse\":\xda\x41\x06parent\x82\xd3\xe4\x93\x02+\x12)/products/v1/{parent=accounts/*}/products\x1aG\xca\x41\x1amerchantapi.googleapis.com\xd2\x41\'https://www.googleapis.com/auth/contentB\xbb\x02\n(com.google.shopping.merchant.products.v1B\rProductsProtoP\x01ZJcloud.google.com/go/shopping/merchant/products/apiv1/productspb;productspb\xaa\x02$Google.Shopping.Merchant.Products.V1\xca\x02$Google\\Shopping\\Merchant\\Products\\V1\xea\x02(Google::Shopping::Merchant::Products::V1\xea\x41\x38\n\"merchantapi.googleapis.com/Account\x12\x12\x61\x63\x63ounts/{account}b\x06proto3"
16
+
17
+ pool = Google::Protobuf::DescriptorPool.generated_pool
18
+
19
+ begin
20
+ pool.add_serialized_file(descriptor_data)
21
+ rescue TypeError
22
+ # Compatibility code: will be removed in the next major version.
23
+ require 'google/protobuf/descriptor_pb'
24
+ parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data)
25
+ parsed.clear_dependency
26
+ serialized = parsed.class.encode(parsed)
27
+ file = pool.add_serialized_file(serialized)
28
+ warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}"
29
+ imports = [
30
+ ["google.shopping.merchant.products.v1.ProductAttributes", "google/shopping/merchant/products/v1/products_common.proto"],
31
+ ["google.shopping.type.CustomAttribute", "google/shopping/type/types.proto"],
32
+ ]
33
+ imports.each do |type_name, expected_filename|
34
+ import_file = pool.lookup(type_name).file_descriptor
35
+ if import_file.name != expected_filename
36
+ warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}"
37
+ end
38
+ end
39
+ warn "Each proto file must use a consistent fully-qualified name."
40
+ warn "This will become an error in the next major version."
41
+ end
42
+
43
+ module Google
44
+ module Shopping
45
+ module Merchant
46
+ module Products
47
+ module V1
48
+ Product = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.products.v1.Product").msgclass
49
+ GetProductRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.products.v1.GetProductRequest").msgclass
50
+ ListProductsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.products.v1.ListProductsRequest").msgclass
51
+ ListProductsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.shopping.merchant.products.v1.ListProductsResponse").msgclass
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,591 @@
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/products/v1/products_pb"
21
+
22
+ module Google
23
+ module Shopping
24
+ module Merchant
25
+ module Products
26
+ module V1
27
+ module ProductsService
28
+ ##
29
+ # Client for the ProductsService service.
30
+ #
31
+ # Service to use Product resource.
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 :products_service_stub
44
+
45
+ ##
46
+ # Configure the ProductsService Client class.
47
+ #
48
+ # See {::Google::Shopping::Merchant::Products::V1::ProductsService::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all ProductsService clients
54
+ # ::Google::Shopping::Merchant::Products::V1::ProductsService::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", "Products", "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 ProductsService 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::Products::V1::ProductsService::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
+ @products_service_stub.universe_domain
112
+ end
113
+
114
+ ##
115
+ # Create a new ProductsService client object.
116
+ #
117
+ # @example
118
+ #
119
+ # # Create a client using the default configuration
120
+ # client = ::Google::Shopping::Merchant::Products::V1::ProductsService::Client.new
121
+ #
122
+ # # Create a client using a custom configuration
123
+ # client = ::Google::Shopping::Merchant::Products::V1::ProductsService::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the ProductsService 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/products/v1/products_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
+ @products_service_stub = ::Gapic::ServiceStub.new(
159
+ ::Google::Shopping::Merchant::Products::V1::ProductsService::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
+ @products_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
+ @products_service_stub.logger
188
+ end
189
+
190
+ # Service calls
191
+
192
+ ##
193
+ # Retrieves the processed product from your Merchant Center account.
194
+ #
195
+ # After inserting, updating, or deleting a product input, it may take several
196
+ # minutes before the updated final product can be retrieved.
197
+ #
198
+ # @overload get_product(request, options = nil)
199
+ # Pass arguments to `get_product` via a request object, either of type
200
+ # {::Google::Shopping::Merchant::Products::V1::GetProductRequest} or an equivalent Hash.
201
+ #
202
+ # @param request [::Google::Shopping::Merchant::Products::V1::GetProductRequest, ::Hash]
203
+ # A request object representing the call parameters. Required. To specify no
204
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
205
+ # @param options [::Gapic::CallOptions, ::Hash]
206
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
207
+ #
208
+ # @overload get_product(name: nil)
209
+ # Pass arguments to `get_product` via keyword arguments. Note that at
210
+ # least one keyword argument is required. To specify no parameters, or to keep all
211
+ # the default parameter values, pass an empty Hash as a request object (see above).
212
+ #
213
+ # @param name [::String]
214
+ # Required. The name of the product to retrieve.
215
+ # Format:
216
+ # `accounts/{account}/products/{product}` where the last
217
+ # section `product` consists of:
218
+ # `content_language~feed_label~offer_id`
219
+ # example for product name is `accounts/123/products/en~US~sku123`. A legacy
220
+ # local product name would be `accounts/123/products/local~en~US~sku123`.
221
+ # Note: For calls to the v1beta version, the `product` section consists
222
+ # of: `channel~content_language~feed_label~offer_id`, for example:
223
+ # `accounts/123/products/online~en~US~sku123`.
224
+ #
225
+ # @yield [response, operation] Access the result along with the RPC operation
226
+ # @yieldparam response [::Google::Shopping::Merchant::Products::V1::Product]
227
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
228
+ #
229
+ # @return [::Google::Shopping::Merchant::Products::V1::Product]
230
+ #
231
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
232
+ #
233
+ # @example Basic example
234
+ # require "google/shopping/merchant/products/v1"
235
+ #
236
+ # # Create a client object. The client can be reused for multiple calls.
237
+ # client = Google::Shopping::Merchant::Products::V1::ProductsService::Client.new
238
+ #
239
+ # # Create a request. To set request fields, pass in keyword arguments.
240
+ # request = Google::Shopping::Merchant::Products::V1::GetProductRequest.new
241
+ #
242
+ # # Call the get_product method.
243
+ # result = client.get_product request
244
+ #
245
+ # # The returned object is of type Google::Shopping::Merchant::Products::V1::Product.
246
+ # p result
247
+ #
248
+ def get_product request, options = nil
249
+ raise ::ArgumentError, "request must be provided" if request.nil?
250
+
251
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Products::V1::GetProductRequest
252
+
253
+ # Converts hash and nil to an options object
254
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
255
+
256
+ # Customize the options with defaults
257
+ metadata = @config.rpcs.get_product.metadata.to_h
258
+
259
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
260
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
261
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
262
+ gapic_version: ::Google::Shopping::Merchant::Products::V1::VERSION
263
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
264
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
265
+
266
+ header_params = {}
267
+ if request.name
268
+ header_params["name"] = request.name
269
+ end
270
+
271
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
272
+ metadata[:"x-goog-request-params"] ||= request_params_header
273
+
274
+ options.apply_defaults timeout: @config.rpcs.get_product.timeout,
275
+ metadata: metadata,
276
+ retry_policy: @config.rpcs.get_product.retry_policy
277
+
278
+ options.apply_defaults timeout: @config.timeout,
279
+ metadata: @config.metadata,
280
+ retry_policy: @config.retry_policy
281
+
282
+ @products_service_stub.call_rpc :get_product, request, options: options do |response, operation|
283
+ yield response, operation if block_given?
284
+ end
285
+ rescue ::GRPC::BadStatus => e
286
+ raise ::Google::Cloud::Error.from_error(e)
287
+ end
288
+
289
+ ##
290
+ # Lists the processed products in your Merchant Center account. The response
291
+ # might contain fewer items than specified by `pageSize`. Rely on `pageToken`
292
+ # to determine if there are more items to be requested.
293
+ #
294
+ # After inserting, updating, or deleting a product input, it may take several
295
+ # minutes before the updated processed product can be retrieved.
296
+ #
297
+ # @overload list_products(request, options = nil)
298
+ # Pass arguments to `list_products` via a request object, either of type
299
+ # {::Google::Shopping::Merchant::Products::V1::ListProductsRequest} or an equivalent Hash.
300
+ #
301
+ # @param request [::Google::Shopping::Merchant::Products::V1::ListProductsRequest, ::Hash]
302
+ # A request object representing the call parameters. Required. To specify no
303
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
304
+ # @param options [::Gapic::CallOptions, ::Hash]
305
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
306
+ #
307
+ # @overload list_products(parent: nil, page_size: nil, page_token: nil)
308
+ # Pass arguments to `list_products` via keyword arguments. Note that at
309
+ # least one keyword argument is required. To specify no parameters, or to keep all
310
+ # the default parameter values, pass an empty Hash as a request object (see above).
311
+ #
312
+ # @param parent [::String]
313
+ # Required. The account to list processed products for.
314
+ # Format: `accounts/{account}`
315
+ # @param page_size [::Integer]
316
+ # The maximum number of products to return. The service may return fewer than
317
+ # this value.
318
+ # The maximum value is 1000; values above 1000 will be coerced to 1000.
319
+ # If unspecified, the default page size of 25 products will be returned.
320
+ # @param page_token [::String]
321
+ # A page token, received from a previous `ListProducts` call.
322
+ # Provide this to retrieve the subsequent page.
323
+ #
324
+ # When paginating, all other parameters provided to `ListProducts` must
325
+ # match the call that provided the page token.
326
+ #
327
+ # @yield [response, operation] Access the result along with the RPC operation
328
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Products::V1::Product>]
329
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
330
+ #
331
+ # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Products::V1::Product>]
332
+ #
333
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
334
+ #
335
+ # @example Basic example
336
+ # require "google/shopping/merchant/products/v1"
337
+ #
338
+ # # Create a client object. The client can be reused for multiple calls.
339
+ # client = Google::Shopping::Merchant::Products::V1::ProductsService::Client.new
340
+ #
341
+ # # Create a request. To set request fields, pass in keyword arguments.
342
+ # request = Google::Shopping::Merchant::Products::V1::ListProductsRequest.new
343
+ #
344
+ # # Call the list_products method.
345
+ # result = client.list_products request
346
+ #
347
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
348
+ # # over elements, and API calls will be issued to fetch pages as needed.
349
+ # result.each do |item|
350
+ # # Each element is of type ::Google::Shopping::Merchant::Products::V1::Product.
351
+ # p item
352
+ # end
353
+ #
354
+ def list_products request, options = nil
355
+ raise ::ArgumentError, "request must be provided" if request.nil?
356
+
357
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Products::V1::ListProductsRequest
358
+
359
+ # Converts hash and nil to an options object
360
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
361
+
362
+ # Customize the options with defaults
363
+ metadata = @config.rpcs.list_products.metadata.to_h
364
+
365
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
366
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
367
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
368
+ gapic_version: ::Google::Shopping::Merchant::Products::V1::VERSION
369
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
370
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
371
+
372
+ header_params = {}
373
+ if request.parent
374
+ header_params["parent"] = request.parent
375
+ end
376
+
377
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
378
+ metadata[:"x-goog-request-params"] ||= request_params_header
379
+
380
+ options.apply_defaults timeout: @config.rpcs.list_products.timeout,
381
+ metadata: metadata,
382
+ retry_policy: @config.rpcs.list_products.retry_policy
383
+
384
+ options.apply_defaults timeout: @config.timeout,
385
+ metadata: @config.metadata,
386
+ retry_policy: @config.retry_policy
387
+
388
+ @products_service_stub.call_rpc :list_products, request, options: options do |response, operation|
389
+ response = ::Gapic::PagedEnumerable.new @products_service_stub, :list_products, request, response, operation, options
390
+ yield response, operation if block_given?
391
+ throw :response, response
392
+ end
393
+ rescue ::GRPC::BadStatus => e
394
+ raise ::Google::Cloud::Error.from_error(e)
395
+ end
396
+
397
+ ##
398
+ # Configuration class for the ProductsService API.
399
+ #
400
+ # This class represents the configuration for ProductsService,
401
+ # providing control over timeouts, retry behavior, logging, transport
402
+ # parameters, and other low-level controls. Certain parameters can also be
403
+ # applied individually to specific RPCs. See
404
+ # {::Google::Shopping::Merchant::Products::V1::ProductsService::Client::Configuration::Rpcs}
405
+ # for a list of RPCs that can be configured independently.
406
+ #
407
+ # Configuration can be applied globally to all clients, or to a single client
408
+ # on construction.
409
+ #
410
+ # @example
411
+ #
412
+ # # Modify the global config, setting the timeout for
413
+ # # get_product to 20 seconds,
414
+ # # and all remaining timeouts to 10 seconds.
415
+ # ::Google::Shopping::Merchant::Products::V1::ProductsService::Client.configure do |config|
416
+ # config.timeout = 10.0
417
+ # config.rpcs.get_product.timeout = 20.0
418
+ # end
419
+ #
420
+ # # Apply the above configuration only to a new client.
421
+ # client = ::Google::Shopping::Merchant::Products::V1::ProductsService::Client.new do |config|
422
+ # config.timeout = 10.0
423
+ # config.rpcs.get_product.timeout = 20.0
424
+ # end
425
+ #
426
+ # @!attribute [rw] endpoint
427
+ # A custom service endpoint, as a hostname or hostname:port. The default is
428
+ # nil, indicating to use the default endpoint in the current universe domain.
429
+ # @return [::String,nil]
430
+ # @!attribute [rw] credentials
431
+ # Credentials to send with calls. You may provide any of the following types:
432
+ # * (`String`) The path to a service account key file in JSON format
433
+ # * (`Hash`) A service account key as a Hash
434
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
435
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
436
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
437
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
438
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
439
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
440
+ # * (`nil`) indicating no credentials
441
+ #
442
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
443
+ # external source for authentication to Google Cloud, you must validate it before
444
+ # providing it to a Google API client library. Providing an unvalidated credential
445
+ # configuration to Google APIs can compromise the security of your systems and data.
446
+ # For more information, refer to [Validate credential configurations from external
447
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
448
+ # @return [::Object]
449
+ # @!attribute [rw] scope
450
+ # The OAuth scopes
451
+ # @return [::Array<::String>]
452
+ # @!attribute [rw] lib_name
453
+ # The library name as recorded in instrumentation and logging
454
+ # @return [::String]
455
+ # @!attribute [rw] lib_version
456
+ # The library version as recorded in instrumentation and logging
457
+ # @return [::String]
458
+ # @!attribute [rw] channel_args
459
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
460
+ # `GRPC::Core::Channel` object is provided as the credential.
461
+ # @return [::Hash]
462
+ # @!attribute [rw] interceptors
463
+ # An array of interceptors that are run before calls are executed.
464
+ # @return [::Array<::GRPC::ClientInterceptor>]
465
+ # @!attribute [rw] timeout
466
+ # The call timeout in seconds.
467
+ # @return [::Numeric]
468
+ # @!attribute [rw] metadata
469
+ # Additional gRPC headers to be sent with the call.
470
+ # @return [::Hash{::Symbol=>::String}]
471
+ # @!attribute [rw] retry_policy
472
+ # The retry policy. The value is a hash with the following keys:
473
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
474
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
475
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
476
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
477
+ # trigger a retry.
478
+ # @return [::Hash]
479
+ # @!attribute [rw] quota_project
480
+ # A separate project against which to charge quota.
481
+ # @return [::String]
482
+ # @!attribute [rw] universe_domain
483
+ # The universe domain within which to make requests. This determines the
484
+ # default endpoint URL. The default value of nil uses the environment
485
+ # universe (usually the default "googleapis.com" universe).
486
+ # @return [::String,nil]
487
+ # @!attribute [rw] logger
488
+ # A custom logger to use for request/response debug logging, or the value
489
+ # `:default` (the default) to construct a default logger, or `nil` to
490
+ # explicitly disable logging.
491
+ # @return [::Logger,:default,nil]
492
+ #
493
+ class Configuration
494
+ extend ::Gapic::Config
495
+
496
+ # @private
497
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
498
+ DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
499
+
500
+ config_attr :endpoint, nil, ::String, nil
501
+ config_attr :credentials, nil do |value|
502
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
503
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel
504
+ allowed.any? { |klass| klass === value }
505
+ end
506
+ config_attr :scope, nil, ::String, ::Array, nil
507
+ config_attr :lib_name, nil, ::String, nil
508
+ config_attr :lib_version, nil, ::String, nil
509
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
510
+ config_attr :interceptors, nil, ::Array, nil
511
+ config_attr :timeout, nil, ::Numeric, nil
512
+ config_attr :metadata, nil, ::Hash, nil
513
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
514
+ config_attr :quota_project, nil, ::String, nil
515
+ config_attr :universe_domain, nil, ::String, nil
516
+ config_attr :logger, :default, ::Logger, nil, :default
517
+
518
+ # @private
519
+ def initialize parent_config = nil
520
+ @parent_config = parent_config unless parent_config.nil?
521
+
522
+ yield self if block_given?
523
+ end
524
+
525
+ ##
526
+ # Configurations for individual RPCs
527
+ # @return [Rpcs]
528
+ #
529
+ def rpcs
530
+ @rpcs ||= begin
531
+ parent_rpcs = nil
532
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
533
+ Rpcs.new parent_rpcs
534
+ end
535
+ end
536
+
537
+ ##
538
+ # Configuration for the channel pool
539
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
540
+ #
541
+ def channel_pool
542
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
543
+ end
544
+
545
+ ##
546
+ # Configuration RPC class for the ProductsService API.
547
+ #
548
+ # Includes fields providing the configuration for each RPC in this service.
549
+ # Each configuration object is of type `Gapic::Config::Method` and includes
550
+ # the following configuration fields:
551
+ #
552
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
553
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
554
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
555
+ # include the following keys:
556
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
557
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
558
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
559
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
560
+ # trigger a retry.
561
+ #
562
+ class Rpcs
563
+ ##
564
+ # RPC-specific configuration for `get_product`
565
+ # @return [::Gapic::Config::Method]
566
+ #
567
+ attr_reader :get_product
568
+ ##
569
+ # RPC-specific configuration for `list_products`
570
+ # @return [::Gapic::Config::Method]
571
+ #
572
+ attr_reader :list_products
573
+
574
+ # @private
575
+ def initialize parent_rpcs = nil
576
+ get_product_config = parent_rpcs.get_product if parent_rpcs.respond_to? :get_product
577
+ @get_product = ::Gapic::Config::Method.new get_product_config
578
+ list_products_config = parent_rpcs.list_products if parent_rpcs.respond_to? :list_products
579
+ @list_products = ::Gapic::Config::Method.new list_products_config
580
+
581
+ yield self if block_given?
582
+ end
583
+ end
584
+ end
585
+ end
586
+ end
587
+ end
588
+ end
589
+ end
590
+ end
591
+ end