google-shopping-merchant-reports-v1beta 0.a → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/README.md +144 -8
  5. data/lib/google/shopping/merchant/reports/v1beta/report_service/client.rb +426 -0
  6. data/lib/google/shopping/merchant/reports/v1beta/report_service/credentials.rb +49 -0
  7. data/lib/google/shopping/merchant/reports/v1beta/report_service/rest/client.rb +390 -0
  8. data/lib/google/shopping/merchant/reports/v1beta/report_service/rest/service_stub.rb +110 -0
  9. data/lib/google/shopping/merchant/reports/v1beta/report_service/rest.rb +54 -0
  10. data/lib/google/shopping/merchant/reports/v1beta/report_service.rb +57 -0
  11. data/lib/google/shopping/merchant/reports/v1beta/reports_pb.rb +84 -0
  12. data/lib/google/shopping/merchant/reports/v1beta/reports_services_pb.rb +50 -0
  13. data/lib/google/shopping/merchant/reports/v1beta/rest.rb +39 -0
  14. data/lib/google/shopping/merchant/reports/v1beta/version.rb +7 -2
  15. data/lib/google/shopping/merchant/reports/v1beta.rb +47 -0
  16. data/lib/google-shopping-merchant-reports-v1beta.rb +21 -0
  17. data/proto_docs/README.md +4 -0
  18. data/proto_docs/google/api/client.rb +381 -0
  19. data/proto_docs/google/api/field_behavior.rb +85 -0
  20. data/proto_docs/google/api/launch_stage.rb +71 -0
  21. data/proto_docs/google/api/resource.rb +222 -0
  22. data/proto_docs/google/protobuf/duration.rb +98 -0
  23. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  24. data/proto_docs/google/shopping/merchant/reports/v1beta/reports.rb +1260 -0
  25. data/proto_docs/google/shopping/type/types.rb +175 -0
  26. data/proto_docs/google/type/date.rb +53 -0
  27. metadata +200 -12
@@ -0,0 +1,426 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/shopping/merchant/reports/v1beta/reports_pb"
21
+
22
+ module Google
23
+ module Shopping
24
+ module Merchant
25
+ module Reports
26
+ module V1beta
27
+ module ReportService
28
+ ##
29
+ # Client for the ReportService service.
30
+ #
31
+ # Service for retrieving reports and insights about your products, their
32
+ # performance, and their competitive environment on Google.
33
+ #
34
+ class Client
35
+ # @private
36
+ attr_reader :report_service_stub
37
+
38
+ ##
39
+ # Configure the ReportService Client class.
40
+ #
41
+ # See {::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
46
+ # # Modify the configuration for all ReportService clients
47
+ # ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
50
+ #
51
+ # @yield [config] Configure the Client client.
52
+ # @yieldparam config [Client::Configuration]
53
+ #
54
+ # @return [Client::Configuration]
55
+ #
56
+ def self.configure
57
+ @configure ||= begin
58
+ namespace = ["Google", "Shopping", "Merchant", "Reports", "V1beta"]
59
+ parent_config = while namespace.any?
60
+ parent_name = namespace.join "::"
61
+ parent_const = const_get parent_name
62
+ break parent_const.configure if parent_const.respond_to? :configure
63
+ namespace.pop
64
+ end
65
+ default_config = Client::Configuration.new parent_config
66
+
67
+ default_config.timeout = 60.0
68
+ default_config.retry_policy = {
69
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
70
+ }
71
+
72
+ default_config
73
+ end
74
+ yield @configure if block_given?
75
+ @configure
76
+ end
77
+
78
+ ##
79
+ # Configure the ReportService Client instance.
80
+ #
81
+ # The configuration is set to the derived mode, meaning that values can be changed,
82
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
83
+ # should be made on {Client.configure}.
84
+ #
85
+ # See {::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client::Configuration}
86
+ # for a description of the configuration fields.
87
+ #
88
+ # @yield [config] Configure the Client client.
89
+ # @yieldparam config [Client::Configuration]
90
+ #
91
+ # @return [Client::Configuration]
92
+ #
93
+ def configure
94
+ yield @config if block_given?
95
+ @config
96
+ end
97
+
98
+ ##
99
+ # Create a new ReportService client object.
100
+ #
101
+ # @example
102
+ #
103
+ # # Create a client using the default configuration
104
+ # client = ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.new
105
+ #
106
+ # # Create a client using a custom configuration
107
+ # client = ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.new do |config|
108
+ # config.timeout = 10.0
109
+ # end
110
+ #
111
+ # @yield [config] Configure the ReportService client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ def initialize
115
+ # These require statements are intentionally placed here to initialize
116
+ # the gRPC module only when it's required.
117
+ # See https://github.com/googleapis/toolkit/issues/446
118
+ require "gapic/grpc"
119
+ require "google/shopping/merchant/reports/v1beta/reports_services_pb"
120
+
121
+ # Create the configuration object
122
+ @config = Configuration.new Client.configure
123
+
124
+ # Yield the configuration if needed
125
+ yield @config if block_given?
126
+
127
+ # Create credentials
128
+ credentials = @config.credentials
129
+ # Use self-signed JWT if the endpoint is unchanged from default,
130
+ # but only if the default endpoint does not have a region prefix.
131
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
132
+ !@config.endpoint.split(".").first.include?("-")
133
+ credentials ||= Credentials.default scope: @config.scope,
134
+ enable_self_signed_jwt: enable_self_signed_jwt
135
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
136
+ credentials = Credentials.new credentials, scope: @config.scope
137
+ end
138
+ @quota_project_id = @config.quota_project
139
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
140
+
141
+ @report_service_stub = ::Gapic::ServiceStub.new(
142
+ ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Stub,
143
+ credentials: credentials,
144
+ endpoint: @config.endpoint,
145
+ channel_args: @config.channel_args,
146
+ interceptors: @config.interceptors,
147
+ channel_pool_config: @config.channel_pool
148
+ )
149
+ end
150
+
151
+ # Service calls
152
+
153
+ ##
154
+ # Retrieves a report defined by a search query. The response might contain
155
+ # fewer rows than specified by `page_size`. Rely on `next_page_token` to
156
+ # determine if there are more rows to be requested.
157
+ #
158
+ # @overload search(request, options = nil)
159
+ # Pass arguments to `search` via a request object, either of type
160
+ # {::Google::Shopping::Merchant::Reports::V1beta::SearchRequest} or an equivalent Hash.
161
+ #
162
+ # @param request [::Google::Shopping::Merchant::Reports::V1beta::SearchRequest, ::Hash]
163
+ # A request object representing the call parameters. Required. To specify no
164
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
165
+ # @param options [::Gapic::CallOptions, ::Hash]
166
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
167
+ #
168
+ # @overload search(parent: nil, query: nil, page_size: nil, page_token: nil)
169
+ # Pass arguments to `search` via keyword arguments. Note that at
170
+ # least one keyword argument is required. To specify no parameters, or to keep all
171
+ # the default parameter values, pass an empty Hash as a request object (see above).
172
+ #
173
+ # @param parent [::String]
174
+ # Required. Id of the account making the call. Must be a standalone account
175
+ # or an MCA subaccount. Format: accounts/\\{account}
176
+ # @param query [::String]
177
+ # Required. Query that defines a report to be retrieved.
178
+ #
179
+ # For details on how to construct your query, see the Query Language
180
+ # guide. For the full list of available tables and fields, see the Available
181
+ # fields.
182
+ # @param page_size [::Integer]
183
+ # Optional. Number of `ReportRows` to retrieve in a single page. Defaults to
184
+ # the maximum of 1000. Values above 1000 are coerced to 1000.
185
+ # @param page_token [::String]
186
+ # Optional. Token of the page to retrieve. If not specified, the first page
187
+ # of results is returned. In order to request the next page of results, the
188
+ # value obtained from `next_page_token` in the previous response should be
189
+ # used.
190
+ #
191
+ # @yield [response, operation] Access the result along with the RPC operation
192
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Reports::V1beta::ReportRow>]
193
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
194
+ #
195
+ # @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Reports::V1beta::ReportRow>]
196
+ #
197
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
198
+ #
199
+ # @example Basic example
200
+ # require "google/shopping/merchant/reports/v1beta"
201
+ #
202
+ # # Create a client object. The client can be reused for multiple calls.
203
+ # client = Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.new
204
+ #
205
+ # # Create a request. To set request fields, pass in keyword arguments.
206
+ # request = Google::Shopping::Merchant::Reports::V1beta::SearchRequest.new
207
+ #
208
+ # # Call the search method.
209
+ # result = client.search request
210
+ #
211
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
212
+ # # over elements, and API calls will be issued to fetch pages as needed.
213
+ # result.each do |item|
214
+ # # Each element is of type ::Google::Shopping::Merchant::Reports::V1beta::ReportRow.
215
+ # p item
216
+ # end
217
+ #
218
+ def search request, options = nil
219
+ raise ::ArgumentError, "request must be provided" if request.nil?
220
+
221
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Reports::V1beta::SearchRequest
222
+
223
+ # Converts hash and nil to an options object
224
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
225
+
226
+ # Customize the options with defaults
227
+ metadata = @config.rpcs.search.metadata.to_h
228
+
229
+ # Set x-goog-api-client and x-goog-user-project headers
230
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
231
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
232
+ gapic_version: ::Google::Shopping::Merchant::Reports::V1beta::VERSION
233
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
234
+
235
+ header_params = {}
236
+ if request.parent
237
+ header_params["parent"] = request.parent
238
+ end
239
+
240
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
241
+ metadata[:"x-goog-request-params"] ||= request_params_header
242
+
243
+ options.apply_defaults timeout: @config.rpcs.search.timeout,
244
+ metadata: metadata,
245
+ retry_policy: @config.rpcs.search.retry_policy
246
+
247
+ options.apply_defaults timeout: @config.timeout,
248
+ metadata: @config.metadata,
249
+ retry_policy: @config.retry_policy
250
+
251
+ @report_service_stub.call_rpc :search, request, options: options do |response, operation|
252
+ response = ::Gapic::PagedEnumerable.new @report_service_stub, :search, request, response, operation, options
253
+ yield response, operation if block_given?
254
+ return response
255
+ end
256
+ rescue ::GRPC::BadStatus => e
257
+ raise ::Google::Cloud::Error.from_error(e)
258
+ end
259
+
260
+ ##
261
+ # Configuration class for the ReportService API.
262
+ #
263
+ # This class represents the configuration for ReportService,
264
+ # providing control over timeouts, retry behavior, logging, transport
265
+ # parameters, and other low-level controls. Certain parameters can also be
266
+ # applied individually to specific RPCs. See
267
+ # {::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client::Configuration::Rpcs}
268
+ # for a list of RPCs that can be configured independently.
269
+ #
270
+ # Configuration can be applied globally to all clients, or to a single client
271
+ # on construction.
272
+ #
273
+ # @example
274
+ #
275
+ # # Modify the global config, setting the timeout for
276
+ # # search to 20 seconds,
277
+ # # and all remaining timeouts to 10 seconds.
278
+ # ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.configure do |config|
279
+ # config.timeout = 10.0
280
+ # config.rpcs.search.timeout = 20.0
281
+ # end
282
+ #
283
+ # # Apply the above configuration only to a new client.
284
+ # client = ::Google::Shopping::Merchant::Reports::V1beta::ReportService::Client.new do |config|
285
+ # config.timeout = 10.0
286
+ # config.rpcs.search.timeout = 20.0
287
+ # end
288
+ #
289
+ # @!attribute [rw] endpoint
290
+ # The hostname or hostname:port of the service endpoint.
291
+ # Defaults to `"merchantapi.googleapis.com"`.
292
+ # @return [::String]
293
+ # @!attribute [rw] credentials
294
+ # Credentials to send with calls. You may provide any of the following types:
295
+ # * (`String`) The path to a service account key file in JSON format
296
+ # * (`Hash`) A service account key as a Hash
297
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
298
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
299
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
300
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
301
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
302
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
303
+ # * (`nil`) indicating no credentials
304
+ # @return [::Object]
305
+ # @!attribute [rw] scope
306
+ # The OAuth scopes
307
+ # @return [::Array<::String>]
308
+ # @!attribute [rw] lib_name
309
+ # The library name as recorded in instrumentation and logging
310
+ # @return [::String]
311
+ # @!attribute [rw] lib_version
312
+ # The library version as recorded in instrumentation and logging
313
+ # @return [::String]
314
+ # @!attribute [rw] channel_args
315
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
316
+ # `GRPC::Core::Channel` object is provided as the credential.
317
+ # @return [::Hash]
318
+ # @!attribute [rw] interceptors
319
+ # An array of interceptors that are run before calls are executed.
320
+ # @return [::Array<::GRPC::ClientInterceptor>]
321
+ # @!attribute [rw] timeout
322
+ # The call timeout in seconds.
323
+ # @return [::Numeric]
324
+ # @!attribute [rw] metadata
325
+ # Additional gRPC headers to be sent with the call.
326
+ # @return [::Hash{::Symbol=>::String}]
327
+ # @!attribute [rw] retry_policy
328
+ # The retry policy. The value is a hash with the following keys:
329
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
330
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
331
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
332
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
333
+ # trigger a retry.
334
+ # @return [::Hash]
335
+ # @!attribute [rw] quota_project
336
+ # A separate project against which to charge quota.
337
+ # @return [::String]
338
+ #
339
+ class Configuration
340
+ extend ::Gapic::Config
341
+
342
+ DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
343
+
344
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
345
+ config_attr :credentials, nil do |value|
346
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
347
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
348
+ allowed.any? { |klass| klass === value }
349
+ end
350
+ config_attr :scope, nil, ::String, ::Array, nil
351
+ config_attr :lib_name, nil, ::String, nil
352
+ config_attr :lib_version, nil, ::String, nil
353
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
354
+ config_attr :interceptors, nil, ::Array, nil
355
+ config_attr :timeout, nil, ::Numeric, nil
356
+ config_attr :metadata, nil, ::Hash, nil
357
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
358
+ config_attr :quota_project, nil, ::String, nil
359
+
360
+ # @private
361
+ def initialize parent_config = nil
362
+ @parent_config = parent_config unless parent_config.nil?
363
+
364
+ yield self if block_given?
365
+ end
366
+
367
+ ##
368
+ # Configurations for individual RPCs
369
+ # @return [Rpcs]
370
+ #
371
+ def rpcs
372
+ @rpcs ||= begin
373
+ parent_rpcs = nil
374
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
375
+ Rpcs.new parent_rpcs
376
+ end
377
+ end
378
+
379
+ ##
380
+ # Configuration for the channel pool
381
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
382
+ #
383
+ def channel_pool
384
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
385
+ end
386
+
387
+ ##
388
+ # Configuration RPC class for the ReportService API.
389
+ #
390
+ # Includes fields providing the configuration for each RPC in this service.
391
+ # Each configuration object is of type `Gapic::Config::Method` and includes
392
+ # the following configuration fields:
393
+ #
394
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
395
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
396
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
397
+ # include the following keys:
398
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
399
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
400
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
401
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
402
+ # trigger a retry.
403
+ #
404
+ class Rpcs
405
+ ##
406
+ # RPC-specific configuration for `search`
407
+ # @return [::Gapic::Config::Method]
408
+ #
409
+ attr_reader :search
410
+
411
+ # @private
412
+ def initialize parent_rpcs = nil
413
+ search_config = parent_rpcs.search if parent_rpcs.respond_to? :search
414
+ @search = ::Gapic::Config::Method.new search_config
415
+
416
+ yield self if block_given?
417
+ end
418
+ end
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Shopping
23
+ module Merchant
24
+ module Reports
25
+ module V1beta
26
+ module ReportService
27
+ # Credentials for the ReportService API.
28
+ class Credentials < ::Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/content"
31
+ ]
32
+ self.env_vars = [
33
+ "GOOGLE_CLOUD_CREDENTIALS",
34
+ "GOOGLE_CLOUD_KEYFILE",
35
+ "GCLOUD_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
37
+ "GOOGLE_CLOUD_KEYFILE_JSON",
38
+ "GCLOUD_KEYFILE_JSON"
39
+ ]
40
+ self.paths = [
41
+ "~/.config/google_cloud/application_default_credentials.json"
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end