google-shopping-merchant-data_sources-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 (45) 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/data_sources/v1/data_sources_service/client.rb +967 -0
  6. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service/credentials.rb +49 -0
  7. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service/paths.rb +66 -0
  8. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service/rest/client.rb +899 -0
  9. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service/rest/service_stub.rb +452 -0
  10. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service/rest.rb +56 -0
  11. data/lib/google/shopping/merchant/data_sources/v1/data_sources_service.rb +59 -0
  12. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/client.rb +467 -0
  13. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/credentials.rb +49 -0
  14. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/paths.rb +54 -0
  15. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/rest/client.rb +434 -0
  16. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/rest/service_stub.rb +144 -0
  17. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service/rest.rb +54 -0
  18. data/lib/google/shopping/merchant/data_sources/v1/file_uploads_service.rb +57 -0
  19. data/lib/google/shopping/merchant/data_sources/v1/rest.rb +40 -0
  20. data/lib/google/shopping/merchant/data_sources/v1/version.rb +7 -2
  21. data/lib/google/shopping/merchant/data_sources/v1.rb +48 -0
  22. data/lib/google/shopping/merchant/datasources/v1/datasources_pb.rb +64 -0
  23. data/lib/google/shopping/merchant/datasources/v1/datasources_services_pb.rb +65 -0
  24. data/lib/google/shopping/merchant/datasources/v1/datasourcetypes_pb.rb +57 -0
  25. data/lib/google/shopping/merchant/datasources/v1/fileinputs_pb.rb +52 -0
  26. data/lib/google/shopping/merchant/datasources/v1/fileuploads_pb.rb +55 -0
  27. data/lib/google/shopping/merchant/datasources/v1/fileuploads_services_pb.rb +48 -0
  28. data/lib/google-shopping-merchant-data_sources-v1.rb +21 -0
  29. data/proto_docs/README.md +4 -0
  30. data/proto_docs/google/api/client.rb +473 -0
  31. data/proto_docs/google/api/field_behavior.rb +85 -0
  32. data/proto_docs/google/api/launch_stage.rb +71 -0
  33. data/proto_docs/google/api/resource.rb +227 -0
  34. data/proto_docs/google/protobuf/duration.rb +98 -0
  35. data/proto_docs/google/protobuf/empty.rb +34 -0
  36. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  37. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  38. data/proto_docs/google/shopping/merchant/datasources/v1/datasources.rb +231 -0
  39. data/proto_docs/google/shopping/merchant/datasources/v1/datasourcetypes.rb +298 -0
  40. data/proto_docs/google/shopping/merchant/datasources/v1/fileinputs.rb +145 -0
  41. data/proto_docs/google/shopping/merchant/datasources/v1/fileuploads.rb +131 -0
  42. data/proto_docs/google/shopping/type/types.rb +210 -0
  43. data/proto_docs/google/type/dayofweek.rb +49 -0
  44. data/proto_docs/google/type/timeofday.rb +45 -0
  45. metadata +103 -9
@@ -0,0 +1,899 @@
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/datasources/v1/datasources_pb"
21
+ require "google/shopping/merchant/data_sources/v1/data_sources_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Shopping
25
+ module Merchant
26
+ module DataSources
27
+ module V1
28
+ module DataSourcesService
29
+ module Rest
30
+ ##
31
+ # REST client for the DataSourcesService service.
32
+ #
33
+ # Service to manage primary, supplemental, inventory and other data sources.
34
+ # See more in the [Merchant
35
+ # Center](https://support.google.com/merchants/answer/7439058) help article.
36
+ #
37
+ class Client
38
+ # @private
39
+ API_VERSION = ""
40
+
41
+ # @private
42
+ DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$"
43
+
44
+ include Paths
45
+
46
+ # @private
47
+ attr_reader :data_sources_service_stub
48
+
49
+ ##
50
+ # Configure the DataSourcesService Client class.
51
+ #
52
+ # See {::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client::Configuration}
53
+ # for a description of the configuration fields.
54
+ #
55
+ # @example
56
+ #
57
+ # # Modify the configuration for all DataSourcesService clients
58
+ # ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.configure do |config|
59
+ # config.timeout = 10.0
60
+ # end
61
+ #
62
+ # @yield [config] Configure the Client client.
63
+ # @yieldparam config [Client::Configuration]
64
+ #
65
+ # @return [Client::Configuration]
66
+ #
67
+ def self.configure
68
+ @configure ||= begin
69
+ namespace = ["Google", "Shopping", "Merchant", "DataSources", "V1"]
70
+ parent_config = while namespace.any?
71
+ parent_name = namespace.join "::"
72
+ parent_const = const_get parent_name
73
+ break parent_const.configure if parent_const.respond_to? :configure
74
+ namespace.pop
75
+ end
76
+ default_config = Client::Configuration.new parent_config
77
+
78
+ default_config.timeout = 60.0
79
+ default_config.retry_policy = {
80
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
81
+ }
82
+
83
+ default_config
84
+ end
85
+ yield @configure if block_given?
86
+ @configure
87
+ end
88
+
89
+ ##
90
+ # Configure the DataSourcesService Client instance.
91
+ #
92
+ # The configuration is set to the derived mode, meaning that values can be changed,
93
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
94
+ # should be made on {Client.configure}.
95
+ #
96
+ # See {::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client::Configuration}
97
+ # for a description of the configuration fields.
98
+ #
99
+ # @yield [config] Configure the Client client.
100
+ # @yieldparam config [Client::Configuration]
101
+ #
102
+ # @return [Client::Configuration]
103
+ #
104
+ def configure
105
+ yield @config if block_given?
106
+ @config
107
+ end
108
+
109
+ ##
110
+ # The effective universe domain
111
+ #
112
+ # @return [String]
113
+ #
114
+ def universe_domain
115
+ @data_sources_service_stub.universe_domain
116
+ end
117
+
118
+ ##
119
+ # Create a new DataSourcesService REST client object.
120
+ #
121
+ # @example
122
+ #
123
+ # # Create a client using the default configuration
124
+ # client = ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
125
+ #
126
+ # # Create a client using a custom configuration
127
+ # client = ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new do |config|
128
+ # config.timeout = 10.0
129
+ # end
130
+ #
131
+ # @yield [config] Configure the DataSourcesService client.
132
+ # @yieldparam config [Client::Configuration]
133
+ #
134
+ def initialize
135
+ # Create the configuration object
136
+ @config = Configuration.new Client.configure
137
+
138
+ # Yield the configuration if needed
139
+ yield @config if block_given?
140
+
141
+ # Create credentials
142
+ credentials = @config.credentials
143
+ # Use self-signed JWT if the endpoint is unchanged from default,
144
+ # but only if the default endpoint does not have a region prefix.
145
+ enable_self_signed_jwt = @config.endpoint.nil? ||
146
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
147
+ !@config.endpoint.split(".").first.include?("-"))
148
+ credentials ||= Credentials.default scope: @config.scope,
149
+ enable_self_signed_jwt: enable_self_signed_jwt
150
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
151
+ credentials = Credentials.new credentials, scope: @config.scope
152
+ end
153
+
154
+ @quota_project_id = @config.quota_project
155
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
156
+
157
+ @data_sources_service_stub = ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::ServiceStub.new(
158
+ endpoint: @config.endpoint,
159
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
160
+ universe_domain: @config.universe_domain,
161
+ credentials: credentials,
162
+ logger: @config.logger
163
+ )
164
+
165
+ @data_sources_service_stub.logger(stub: true)&.info do |entry|
166
+ entry.set_system_name
167
+ entry.set_service
168
+ entry.message = "Created client for #{entry.service}"
169
+ entry.set_credentials_fields credentials
170
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
171
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
172
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
173
+ end
174
+ end
175
+
176
+ ##
177
+ # The logger used for request/response debug logging.
178
+ #
179
+ # @return [Logger]
180
+ #
181
+ def logger
182
+ @data_sources_service_stub.logger
183
+ end
184
+
185
+ # Service calls
186
+
187
+ ##
188
+ # Retrieves the data source configuration for the given account.
189
+ #
190
+ # @overload get_data_source(request, options = nil)
191
+ # Pass arguments to `get_data_source` via a request object, either of type
192
+ # {::Google::Shopping::Merchant::DataSources::V1::GetDataSourceRequest} or an equivalent Hash.
193
+ #
194
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::GetDataSourceRequest, ::Hash]
195
+ # A request object representing the call parameters. Required. To specify no
196
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
197
+ # @param options [::Gapic::CallOptions, ::Hash]
198
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
199
+ #
200
+ # @overload get_data_source(name: nil)
201
+ # Pass arguments to `get_data_source` via keyword arguments. Note that at
202
+ # least one keyword argument is required. To specify no parameters, or to keep all
203
+ # the default parameter values, pass an empty Hash as a request object (see above).
204
+ #
205
+ # @param name [::String]
206
+ # Required. The name of the data source to retrieve.
207
+ # Format: `accounts/{account}/dataSources/{datasource}`
208
+ # @yield [result, operation] Access the result along with the TransportOperation object
209
+ # @yieldparam result [::Google::Shopping::Merchant::DataSources::V1::DataSource]
210
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
211
+ #
212
+ # @return [::Google::Shopping::Merchant::DataSources::V1::DataSource]
213
+ #
214
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
215
+ #
216
+ # @example Basic example
217
+ # require "google/shopping/merchant/data_sources/v1"
218
+ #
219
+ # # Create a client object. The client can be reused for multiple calls.
220
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
221
+ #
222
+ # # Create a request. To set request fields, pass in keyword arguments.
223
+ # request = Google::Shopping::Merchant::DataSources::V1::GetDataSourceRequest.new
224
+ #
225
+ # # Call the get_data_source method.
226
+ # result = client.get_data_source request
227
+ #
228
+ # # The returned object is of type Google::Shopping::Merchant::DataSources::V1::DataSource.
229
+ # p result
230
+ #
231
+ def get_data_source request, options = nil
232
+ raise ::ArgumentError, "request must be provided" if request.nil?
233
+
234
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::GetDataSourceRequest
235
+
236
+ # Converts hash and nil to an options object
237
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
238
+
239
+ # Customize the options with defaults
240
+ call_metadata = @config.rpcs.get_data_source.metadata.to_h
241
+
242
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
243
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
244
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
245
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
246
+ transports_version_send: [:rest]
247
+
248
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
249
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
250
+
251
+ options.apply_defaults timeout: @config.rpcs.get_data_source.timeout,
252
+ metadata: call_metadata,
253
+ retry_policy: @config.rpcs.get_data_source.retry_policy
254
+
255
+ options.apply_defaults timeout: @config.timeout,
256
+ metadata: @config.metadata,
257
+ retry_policy: @config.retry_policy
258
+
259
+ @data_sources_service_stub.get_data_source request, options do |result, operation|
260
+ yield result, operation if block_given?
261
+ end
262
+ rescue ::Gapic::Rest::Error => e
263
+ raise ::Google::Cloud::Error.from_error(e)
264
+ end
265
+
266
+ ##
267
+ # Lists the configurations for data sources for the given account.
268
+ #
269
+ # @overload list_data_sources(request, options = nil)
270
+ # Pass arguments to `list_data_sources` via a request object, either of type
271
+ # {::Google::Shopping::Merchant::DataSources::V1::ListDataSourcesRequest} or an equivalent Hash.
272
+ #
273
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::ListDataSourcesRequest, ::Hash]
274
+ # A request object representing the call parameters. Required. To specify no
275
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
276
+ # @param options [::Gapic::CallOptions, ::Hash]
277
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
278
+ #
279
+ # @overload list_data_sources(parent: nil, page_size: nil, page_token: nil)
280
+ # Pass arguments to `list_data_sources` via keyword arguments. Note that at
281
+ # least one keyword argument is required. To specify no parameters, or to keep all
282
+ # the default parameter values, pass an empty Hash as a request object (see above).
283
+ #
284
+ # @param parent [::String]
285
+ # Required. The account to list data sources for.
286
+ # Format: `accounts/{account}`
287
+ # @param page_size [::Integer]
288
+ # Optional. The maximum number of data sources to return. The service may
289
+ # return fewer than this value. The maximum value is 1000; values above 1000
290
+ # will be coerced to 1000. If unspecified, the maximum number of data sources
291
+ # will be returned.
292
+ # @param page_token [::String]
293
+ # Optional. A page token, received from a previous `ListDataSources` call.
294
+ # Provide this to retrieve the subsequent page.
295
+ #
296
+ # When paginating, all other parameters provided to `ListDataSources`
297
+ # must match the call that provided the page token.
298
+ # @yield [result, operation] Access the result along with the TransportOperation object
299
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::DataSources::V1::DataSource>]
300
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
301
+ #
302
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Shopping::Merchant::DataSources::V1::DataSource>]
303
+ #
304
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
305
+ #
306
+ # @example Basic example
307
+ # require "google/shopping/merchant/data_sources/v1"
308
+ #
309
+ # # Create a client object. The client can be reused for multiple calls.
310
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
311
+ #
312
+ # # Create a request. To set request fields, pass in keyword arguments.
313
+ # request = Google::Shopping::Merchant::DataSources::V1::ListDataSourcesRequest.new
314
+ #
315
+ # # Call the list_data_sources method.
316
+ # result = client.list_data_sources request
317
+ #
318
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
319
+ # # over elements, and API calls will be issued to fetch pages as needed.
320
+ # result.each do |item|
321
+ # # Each element is of type ::Google::Shopping::Merchant::DataSources::V1::DataSource.
322
+ # p item
323
+ # end
324
+ #
325
+ def list_data_sources request, options = nil
326
+ raise ::ArgumentError, "request must be provided" if request.nil?
327
+
328
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::ListDataSourcesRequest
329
+
330
+ # Converts hash and nil to an options object
331
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
332
+
333
+ # Customize the options with defaults
334
+ call_metadata = @config.rpcs.list_data_sources.metadata.to_h
335
+
336
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
337
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
338
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
339
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
340
+ transports_version_send: [:rest]
341
+
342
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
343
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
344
+
345
+ options.apply_defaults timeout: @config.rpcs.list_data_sources.timeout,
346
+ metadata: call_metadata,
347
+ retry_policy: @config.rpcs.list_data_sources.retry_policy
348
+
349
+ options.apply_defaults timeout: @config.timeout,
350
+ metadata: @config.metadata,
351
+ retry_policy: @config.retry_policy
352
+
353
+ @data_sources_service_stub.list_data_sources request, options do |result, operation|
354
+ result = ::Gapic::Rest::PagedEnumerable.new @data_sources_service_stub, :list_data_sources, "data_sources", request, result, options
355
+ yield result, operation if block_given?
356
+ throw :response, result
357
+ end
358
+ rescue ::Gapic::Rest::Error => e
359
+ raise ::Google::Cloud::Error.from_error(e)
360
+ end
361
+
362
+ ##
363
+ # Creates the new data source configuration for the given account.
364
+ # This method always creates a new data source.
365
+ #
366
+ # @overload create_data_source(request, options = nil)
367
+ # Pass arguments to `create_data_source` via a request object, either of type
368
+ # {::Google::Shopping::Merchant::DataSources::V1::CreateDataSourceRequest} or an equivalent Hash.
369
+ #
370
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::CreateDataSourceRequest, ::Hash]
371
+ # A request object representing the call parameters. Required. To specify no
372
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
373
+ # @param options [::Gapic::CallOptions, ::Hash]
374
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
375
+ #
376
+ # @overload create_data_source(parent: nil, data_source: nil)
377
+ # Pass arguments to `create_data_source` via keyword arguments. Note that at
378
+ # least one keyword argument is required. To specify no parameters, or to keep all
379
+ # the default parameter values, pass an empty Hash as a request object (see above).
380
+ #
381
+ # @param parent [::String]
382
+ # Required. The account where this data source will be created.
383
+ # Format: `accounts/{account}`
384
+ # @param data_source [::Google::Shopping::Merchant::DataSources::V1::DataSource, ::Hash]
385
+ # Required. The data source to create.
386
+ # @yield [result, operation] Access the result along with the TransportOperation object
387
+ # @yieldparam result [::Google::Shopping::Merchant::DataSources::V1::DataSource]
388
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
389
+ #
390
+ # @return [::Google::Shopping::Merchant::DataSources::V1::DataSource]
391
+ #
392
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
393
+ #
394
+ # @example Basic example
395
+ # require "google/shopping/merchant/data_sources/v1"
396
+ #
397
+ # # Create a client object. The client can be reused for multiple calls.
398
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
399
+ #
400
+ # # Create a request. To set request fields, pass in keyword arguments.
401
+ # request = Google::Shopping::Merchant::DataSources::V1::CreateDataSourceRequest.new
402
+ #
403
+ # # Call the create_data_source method.
404
+ # result = client.create_data_source request
405
+ #
406
+ # # The returned object is of type Google::Shopping::Merchant::DataSources::V1::DataSource.
407
+ # p result
408
+ #
409
+ def create_data_source request, options = nil
410
+ raise ::ArgumentError, "request must be provided" if request.nil?
411
+
412
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::CreateDataSourceRequest
413
+
414
+ # Converts hash and nil to an options object
415
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
416
+
417
+ # Customize the options with defaults
418
+ call_metadata = @config.rpcs.create_data_source.metadata.to_h
419
+
420
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
421
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
422
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
423
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
424
+ transports_version_send: [:rest]
425
+
426
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
427
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
428
+
429
+ options.apply_defaults timeout: @config.rpcs.create_data_source.timeout,
430
+ metadata: call_metadata,
431
+ retry_policy: @config.rpcs.create_data_source.retry_policy
432
+
433
+ options.apply_defaults timeout: @config.timeout,
434
+ metadata: @config.metadata,
435
+ retry_policy: @config.retry_policy
436
+
437
+ @data_sources_service_stub.create_data_source request, options do |result, operation|
438
+ yield result, operation if block_given?
439
+ end
440
+ rescue ::Gapic::Rest::Error => e
441
+ raise ::Google::Cloud::Error.from_error(e)
442
+ end
443
+
444
+ ##
445
+ # Updates the existing data source configuration. The fields that are
446
+ # set in the update mask but not provided in the resource will be deleted.
447
+ #
448
+ # @overload update_data_source(request, options = nil)
449
+ # Pass arguments to `update_data_source` via a request object, either of type
450
+ # {::Google::Shopping::Merchant::DataSources::V1::UpdateDataSourceRequest} or an equivalent Hash.
451
+ #
452
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::UpdateDataSourceRequest, ::Hash]
453
+ # A request object representing the call parameters. Required. To specify no
454
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
455
+ # @param options [::Gapic::CallOptions, ::Hash]
456
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
457
+ #
458
+ # @overload update_data_source(data_source: nil, update_mask: nil)
459
+ # Pass arguments to `update_data_source` via keyword arguments. Note that at
460
+ # least one keyword argument is required. To specify no parameters, or to keep all
461
+ # the default parameter values, pass an empty Hash as a request object (see above).
462
+ #
463
+ # @param data_source [::Google::Shopping::Merchant::DataSources::V1::DataSource, ::Hash]
464
+ # Required. The data source resource to update.
465
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
466
+ # Required. The list of data source fields to be updated.
467
+ #
468
+ # Fields specified in the update mask without a value specified in the
469
+ # body will be deleted from the data source.
470
+ #
471
+ # Providing special "*" value for full data source replacement is not
472
+ # supported.
473
+ #
474
+ # For example, If you insert `updateMask=displayName` in the request, it will
475
+ # only update the `displayName` leaving all other fields untouched.
476
+ # @yield [result, operation] Access the result along with the TransportOperation object
477
+ # @yieldparam result [::Google::Shopping::Merchant::DataSources::V1::DataSource]
478
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
479
+ #
480
+ # @return [::Google::Shopping::Merchant::DataSources::V1::DataSource]
481
+ #
482
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
483
+ #
484
+ # @example Basic example
485
+ # require "google/shopping/merchant/data_sources/v1"
486
+ #
487
+ # # Create a client object. The client can be reused for multiple calls.
488
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
489
+ #
490
+ # # Create a request. To set request fields, pass in keyword arguments.
491
+ # request = Google::Shopping::Merchant::DataSources::V1::UpdateDataSourceRequest.new
492
+ #
493
+ # # Call the update_data_source method.
494
+ # result = client.update_data_source request
495
+ #
496
+ # # The returned object is of type Google::Shopping::Merchant::DataSources::V1::DataSource.
497
+ # p result
498
+ #
499
+ def update_data_source request, options = nil
500
+ raise ::ArgumentError, "request must be provided" if request.nil?
501
+
502
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::UpdateDataSourceRequest
503
+
504
+ # Converts hash and nil to an options object
505
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
506
+
507
+ # Customize the options with defaults
508
+ call_metadata = @config.rpcs.update_data_source.metadata.to_h
509
+
510
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
511
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
512
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
513
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
514
+ transports_version_send: [:rest]
515
+
516
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
517
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
518
+
519
+ options.apply_defaults timeout: @config.rpcs.update_data_source.timeout,
520
+ metadata: call_metadata,
521
+ retry_policy: @config.rpcs.update_data_source.retry_policy
522
+
523
+ options.apply_defaults timeout: @config.timeout,
524
+ metadata: @config.metadata,
525
+ retry_policy: @config.retry_policy
526
+
527
+ @data_sources_service_stub.update_data_source request, options do |result, operation|
528
+ yield result, operation if block_given?
529
+ end
530
+ rescue ::Gapic::Rest::Error => e
531
+ raise ::Google::Cloud::Error.from_error(e)
532
+ end
533
+
534
+ ##
535
+ # Deletes a data source from your Merchant Center account.
536
+ #
537
+ # @overload delete_data_source(request, options = nil)
538
+ # Pass arguments to `delete_data_source` via a request object, either of type
539
+ # {::Google::Shopping::Merchant::DataSources::V1::DeleteDataSourceRequest} or an equivalent Hash.
540
+ #
541
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::DeleteDataSourceRequest, ::Hash]
542
+ # A request object representing the call parameters. Required. To specify no
543
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
544
+ # @param options [::Gapic::CallOptions, ::Hash]
545
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
546
+ #
547
+ # @overload delete_data_source(name: nil)
548
+ # Pass arguments to `delete_data_source` via keyword arguments. Note that at
549
+ # least one keyword argument is required. To specify no parameters, or to keep all
550
+ # the default parameter values, pass an empty Hash as a request object (see above).
551
+ #
552
+ # @param name [::String]
553
+ # Required. The name of the data source to delete.
554
+ # Format: `accounts/{account}/dataSources/{datasource}`
555
+ # @yield [result, operation] Access the result along with the TransportOperation object
556
+ # @yieldparam result [::Google::Protobuf::Empty]
557
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
558
+ #
559
+ # @return [::Google::Protobuf::Empty]
560
+ #
561
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
562
+ #
563
+ # @example Basic example
564
+ # require "google/shopping/merchant/data_sources/v1"
565
+ #
566
+ # # Create a client object. The client can be reused for multiple calls.
567
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
568
+ #
569
+ # # Create a request. To set request fields, pass in keyword arguments.
570
+ # request = Google::Shopping::Merchant::DataSources::V1::DeleteDataSourceRequest.new
571
+ #
572
+ # # Call the delete_data_source method.
573
+ # result = client.delete_data_source request
574
+ #
575
+ # # The returned object is of type Google::Protobuf::Empty.
576
+ # p result
577
+ #
578
+ def delete_data_source request, options = nil
579
+ raise ::ArgumentError, "request must be provided" if request.nil?
580
+
581
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::DeleteDataSourceRequest
582
+
583
+ # Converts hash and nil to an options object
584
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
585
+
586
+ # Customize the options with defaults
587
+ call_metadata = @config.rpcs.delete_data_source.metadata.to_h
588
+
589
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
590
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
591
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
592
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
593
+ transports_version_send: [:rest]
594
+
595
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
596
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
597
+
598
+ options.apply_defaults timeout: @config.rpcs.delete_data_source.timeout,
599
+ metadata: call_metadata,
600
+ retry_policy: @config.rpcs.delete_data_source.retry_policy
601
+
602
+ options.apply_defaults timeout: @config.timeout,
603
+ metadata: @config.metadata,
604
+ retry_policy: @config.retry_policy
605
+
606
+ @data_sources_service_stub.delete_data_source request, options do |result, operation|
607
+ yield result, operation if block_given?
608
+ end
609
+ rescue ::Gapic::Rest::Error => e
610
+ raise ::Google::Cloud::Error.from_error(e)
611
+ end
612
+
613
+ ##
614
+ # Performs the data fetch immediately (even outside fetch schedule) on a
615
+ # data source from your Merchant Center Account. If you need to call
616
+ # this method more than once per day, you should use the Products service to
617
+ # update your product data instead.
618
+ # This method only works on data sources with a file input set.
619
+ #
620
+ # @overload fetch_data_source(request, options = nil)
621
+ # Pass arguments to `fetch_data_source` via a request object, either of type
622
+ # {::Google::Shopping::Merchant::DataSources::V1::FetchDataSourceRequest} or an equivalent Hash.
623
+ #
624
+ # @param request [::Google::Shopping::Merchant::DataSources::V1::FetchDataSourceRequest, ::Hash]
625
+ # A request object representing the call parameters. Required. To specify no
626
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
627
+ # @param options [::Gapic::CallOptions, ::Hash]
628
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
629
+ #
630
+ # @overload fetch_data_source(name: nil)
631
+ # Pass arguments to `fetch_data_source` via keyword arguments. Note that at
632
+ # least one keyword argument is required. To specify no parameters, or to keep all
633
+ # the default parameter values, pass an empty Hash as a request object (see above).
634
+ #
635
+ # @param name [::String]
636
+ # Required. The name of the data source resource to fetch.
637
+ # Format: `accounts/{account}/dataSources/{datasource}`
638
+ # @yield [result, operation] Access the result along with the TransportOperation object
639
+ # @yieldparam result [::Google::Protobuf::Empty]
640
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
641
+ #
642
+ # @return [::Google::Protobuf::Empty]
643
+ #
644
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
645
+ #
646
+ # @example Basic example
647
+ # require "google/shopping/merchant/data_sources/v1"
648
+ #
649
+ # # Create a client object. The client can be reused for multiple calls.
650
+ # client = Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new
651
+ #
652
+ # # Create a request. To set request fields, pass in keyword arguments.
653
+ # request = Google::Shopping::Merchant::DataSources::V1::FetchDataSourceRequest.new
654
+ #
655
+ # # Call the fetch_data_source method.
656
+ # result = client.fetch_data_source request
657
+ #
658
+ # # The returned object is of type Google::Protobuf::Empty.
659
+ # p result
660
+ #
661
+ def fetch_data_source request, options = nil
662
+ raise ::ArgumentError, "request must be provided" if request.nil?
663
+
664
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::DataSources::V1::FetchDataSourceRequest
665
+
666
+ # Converts hash and nil to an options object
667
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
668
+
669
+ # Customize the options with defaults
670
+ call_metadata = @config.rpcs.fetch_data_source.metadata.to_h
671
+
672
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
673
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
674
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
675
+ gapic_version: ::Google::Shopping::Merchant::DataSources::V1::VERSION,
676
+ transports_version_send: [:rest]
677
+
678
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
679
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
680
+
681
+ options.apply_defaults timeout: @config.rpcs.fetch_data_source.timeout,
682
+ metadata: call_metadata,
683
+ retry_policy: @config.rpcs.fetch_data_source.retry_policy
684
+
685
+ options.apply_defaults timeout: @config.timeout,
686
+ metadata: @config.metadata,
687
+ retry_policy: @config.retry_policy
688
+
689
+ @data_sources_service_stub.fetch_data_source request, options do |result, operation|
690
+ yield result, operation if block_given?
691
+ end
692
+ rescue ::Gapic::Rest::Error => e
693
+ raise ::Google::Cloud::Error.from_error(e)
694
+ end
695
+
696
+ ##
697
+ # Configuration class for the DataSourcesService REST API.
698
+ #
699
+ # This class represents the configuration for DataSourcesService REST,
700
+ # providing control over timeouts, retry behavior, logging, transport
701
+ # parameters, and other low-level controls. Certain parameters can also be
702
+ # applied individually to specific RPCs. See
703
+ # {::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client::Configuration::Rpcs}
704
+ # for a list of RPCs that can be configured independently.
705
+ #
706
+ # Configuration can be applied globally to all clients, or to a single client
707
+ # on construction.
708
+ #
709
+ # @example
710
+ #
711
+ # # Modify the global config, setting the timeout for
712
+ # # get_data_source to 20 seconds,
713
+ # # and all remaining timeouts to 10 seconds.
714
+ # ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.configure do |config|
715
+ # config.timeout = 10.0
716
+ # config.rpcs.get_data_source.timeout = 20.0
717
+ # end
718
+ #
719
+ # # Apply the above configuration only to a new client.
720
+ # client = ::Google::Shopping::Merchant::DataSources::V1::DataSourcesService::Rest::Client.new do |config|
721
+ # config.timeout = 10.0
722
+ # config.rpcs.get_data_source.timeout = 20.0
723
+ # end
724
+ #
725
+ # @!attribute [rw] endpoint
726
+ # A custom service endpoint, as a hostname or hostname:port. The default is
727
+ # nil, indicating to use the default endpoint in the current universe domain.
728
+ # @return [::String,nil]
729
+ # @!attribute [rw] credentials
730
+ # Credentials to send with calls. You may provide any of the following types:
731
+ # * (`String`) The path to a service account key file in JSON format
732
+ # * (`Hash`) A service account key as a Hash
733
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
734
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
735
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
736
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
737
+ # * (`nil`) indicating no credentials
738
+ #
739
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
740
+ # external source for authentication to Google Cloud, you must validate it before
741
+ # providing it to a Google API client library. Providing an unvalidated credential
742
+ # configuration to Google APIs can compromise the security of your systems and data.
743
+ # For more information, refer to [Validate credential configurations from external
744
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
745
+ # @return [::Object]
746
+ # @!attribute [rw] scope
747
+ # The OAuth scopes
748
+ # @return [::Array<::String>]
749
+ # @!attribute [rw] lib_name
750
+ # The library name as recorded in instrumentation and logging
751
+ # @return [::String]
752
+ # @!attribute [rw] lib_version
753
+ # The library version as recorded in instrumentation and logging
754
+ # @return [::String]
755
+ # @!attribute [rw] timeout
756
+ # The call timeout in seconds.
757
+ # @return [::Numeric]
758
+ # @!attribute [rw] metadata
759
+ # Additional headers to be sent with the call.
760
+ # @return [::Hash{::Symbol=>::String}]
761
+ # @!attribute [rw] retry_policy
762
+ # The retry policy. The value is a hash with the following keys:
763
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
764
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
765
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
766
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
767
+ # trigger a retry.
768
+ # @return [::Hash]
769
+ # @!attribute [rw] quota_project
770
+ # A separate project against which to charge quota.
771
+ # @return [::String]
772
+ # @!attribute [rw] universe_domain
773
+ # The universe domain within which to make requests. This determines the
774
+ # default endpoint URL. The default value of nil uses the environment
775
+ # universe (usually the default "googleapis.com" universe).
776
+ # @return [::String,nil]
777
+ # @!attribute [rw] logger
778
+ # A custom logger to use for request/response debug logging, or the value
779
+ # `:default` (the default) to construct a default logger, or `nil` to
780
+ # explicitly disable logging.
781
+ # @return [::Logger,:default,nil]
782
+ #
783
+ class Configuration
784
+ extend ::Gapic::Config
785
+
786
+ # @private
787
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
788
+ DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
789
+
790
+ config_attr :endpoint, nil, ::String, nil
791
+ config_attr :credentials, nil do |value|
792
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
793
+ allowed.any? { |klass| klass === value }
794
+ end
795
+ config_attr :scope, nil, ::String, ::Array, nil
796
+ config_attr :lib_name, nil, ::String, nil
797
+ config_attr :lib_version, nil, ::String, nil
798
+ config_attr :timeout, nil, ::Numeric, nil
799
+ config_attr :metadata, nil, ::Hash, nil
800
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
801
+ config_attr :quota_project, nil, ::String, nil
802
+ config_attr :universe_domain, nil, ::String, nil
803
+ config_attr :logger, :default, ::Logger, nil, :default
804
+
805
+ # @private
806
+ def initialize parent_config = nil
807
+ @parent_config = parent_config unless parent_config.nil?
808
+
809
+ yield self if block_given?
810
+ end
811
+
812
+ ##
813
+ # Configurations for individual RPCs
814
+ # @return [Rpcs]
815
+ #
816
+ def rpcs
817
+ @rpcs ||= begin
818
+ parent_rpcs = nil
819
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
820
+ Rpcs.new parent_rpcs
821
+ end
822
+ end
823
+
824
+ ##
825
+ # Configuration RPC class for the DataSourcesService API.
826
+ #
827
+ # Includes fields providing the configuration for each RPC in this service.
828
+ # Each configuration object is of type `Gapic::Config::Method` and includes
829
+ # the following configuration fields:
830
+ #
831
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
832
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
833
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
834
+ # include the following keys:
835
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
836
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
837
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
838
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
839
+ # trigger a retry.
840
+ #
841
+ class Rpcs
842
+ ##
843
+ # RPC-specific configuration for `get_data_source`
844
+ # @return [::Gapic::Config::Method]
845
+ #
846
+ attr_reader :get_data_source
847
+ ##
848
+ # RPC-specific configuration for `list_data_sources`
849
+ # @return [::Gapic::Config::Method]
850
+ #
851
+ attr_reader :list_data_sources
852
+ ##
853
+ # RPC-specific configuration for `create_data_source`
854
+ # @return [::Gapic::Config::Method]
855
+ #
856
+ attr_reader :create_data_source
857
+ ##
858
+ # RPC-specific configuration for `update_data_source`
859
+ # @return [::Gapic::Config::Method]
860
+ #
861
+ attr_reader :update_data_source
862
+ ##
863
+ # RPC-specific configuration for `delete_data_source`
864
+ # @return [::Gapic::Config::Method]
865
+ #
866
+ attr_reader :delete_data_source
867
+ ##
868
+ # RPC-specific configuration for `fetch_data_source`
869
+ # @return [::Gapic::Config::Method]
870
+ #
871
+ attr_reader :fetch_data_source
872
+
873
+ # @private
874
+ def initialize parent_rpcs = nil
875
+ get_data_source_config = parent_rpcs.get_data_source if parent_rpcs.respond_to? :get_data_source
876
+ @get_data_source = ::Gapic::Config::Method.new get_data_source_config
877
+ list_data_sources_config = parent_rpcs.list_data_sources if parent_rpcs.respond_to? :list_data_sources
878
+ @list_data_sources = ::Gapic::Config::Method.new list_data_sources_config
879
+ create_data_source_config = parent_rpcs.create_data_source if parent_rpcs.respond_to? :create_data_source
880
+ @create_data_source = ::Gapic::Config::Method.new create_data_source_config
881
+ update_data_source_config = parent_rpcs.update_data_source if parent_rpcs.respond_to? :update_data_source
882
+ @update_data_source = ::Gapic::Config::Method.new update_data_source_config
883
+ delete_data_source_config = parent_rpcs.delete_data_source if parent_rpcs.respond_to? :delete_data_source
884
+ @delete_data_source = ::Gapic::Config::Method.new delete_data_source_config
885
+ fetch_data_source_config = parent_rpcs.fetch_data_source if parent_rpcs.respond_to? :fetch_data_source
886
+ @fetch_data_source = ::Gapic::Config::Method.new fetch_data_source_config
887
+
888
+ yield self if block_given?
889
+ end
890
+ end
891
+ end
892
+ end
893
+ end
894
+ end
895
+ end
896
+ end
897
+ end
898
+ end
899
+ end