google-cloud-retail-v2 0.18.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/google/cloud/retail/v2/analytics_service/client.rb +486 -0
  5. data/lib/google/cloud/retail/v2/analytics_service/credentials.rb +51 -0
  6. data/lib/google/cloud/retail/v2/analytics_service/operations.rb +801 -0
  7. data/lib/google/cloud/retail/v2/analytics_service/rest/client.rb +453 -0
  8. data/lib/google/cloud/retail/v2/analytics_service/rest/operations.rb +930 -0
  9. data/lib/google/cloud/retail/v2/analytics_service/rest/service_stub.rb +129 -0
  10. data/lib/google/cloud/retail/v2/analytics_service/rest.rb +53 -0
  11. data/lib/google/cloud/retail/v2/analytics_service.rb +56 -0
  12. data/lib/google/cloud/retail/v2/analytics_service_pb.rb +48 -0
  13. data/lib/google/cloud/retail/v2/analytics_service_services_pb.rb +49 -0
  14. data/lib/google/cloud/retail/v2/catalog_pb.rb +1 -1
  15. data/lib/google/cloud/retail/v2/catalog_service_pb.rb +1 -1
  16. data/lib/google/cloud/retail/v2/common_pb.rb +1 -1
  17. data/lib/google/cloud/retail/v2/completion_service_pb.rb +1 -1
  18. data/lib/google/cloud/retail/v2/control_pb.rb +1 -1
  19. data/lib/google/cloud/retail/v2/control_service_pb.rb +1 -1
  20. data/lib/google/cloud/retail/v2/export_config_pb.rb +58 -0
  21. data/lib/google/cloud/retail/v2/import_config_pb.rb +1 -1
  22. data/lib/google/cloud/retail/v2/model_pb.rb +1 -1
  23. data/lib/google/cloud/retail/v2/model_service_pb.rb +1 -1
  24. data/lib/google/cloud/retail/v2/prediction_service_pb.rb +1 -1
  25. data/lib/google/cloud/retail/v2/product_pb.rb +1 -1
  26. data/lib/google/cloud/retail/v2/product_service_pb.rb +1 -1
  27. data/lib/google/cloud/retail/v2/purge_config_pb.rb +1 -1
  28. data/lib/google/cloud/retail/v2/rest.rb +2 -1
  29. data/lib/google/cloud/retail/v2/search_service_pb.rb +1 -1
  30. data/lib/google/cloud/retail/v2/serving_config_pb.rb +1 -1
  31. data/lib/google/cloud/retail/v2/serving_config_service_pb.rb +1 -1
  32. data/lib/google/cloud/retail/v2/user_event_pb.rb +1 -1
  33. data/lib/google/cloud/retail/v2/user_event_service_pb.rb +1 -1
  34. data/lib/google/cloud/retail/v2/version.rb +1 -1
  35. data/lib/google/cloud/retail/v2.rb +3 -2
  36. data/proto_docs/google/cloud/retail/v2/export_config.rb +180 -0
  37. metadata +16 -116
@@ -0,0 +1,453 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/retail/v2/analytics_service_pb"
21
+ require "google/cloud/retail/v2/analytics_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Retail
27
+ module V2
28
+ module AnalyticsService
29
+ module Rest
30
+ ##
31
+ # REST client for the AnalyticsService service.
32
+ #
33
+ # Service for managing & accessing retail search business metric.
34
+ # Retail recommendation business metric is currently not available.
35
+ #
36
+ class Client
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "retail.$UNIVERSE_DOMAIN$"
39
+
40
+ # @private
41
+ attr_reader :analytics_service_stub
42
+
43
+ ##
44
+ # Configure the AnalyticsService Client class.
45
+ #
46
+ # See {::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # @example
50
+ #
51
+ # # Modify the configuration for all AnalyticsService clients
52
+ # ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "Retail", "V2"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.export_analytics_metrics.timeout = 60.0
73
+ default_config.rpcs.export_analytics_metrics.retry_policy = {
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
75
+ }
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the AnalyticsService Client instance.
85
+ #
86
+ # The configuration is set to the derived mode, meaning that values can be changed,
87
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
88
+ # should be made on {Client.configure}.
89
+ #
90
+ # See {::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client::Configuration}
91
+ # for a description of the configuration fields.
92
+ #
93
+ # @yield [config] Configure the Client client.
94
+ # @yieldparam config [Client::Configuration]
95
+ #
96
+ # @return [Client::Configuration]
97
+ #
98
+ def configure
99
+ yield @config if block_given?
100
+ @config
101
+ end
102
+
103
+ ##
104
+ # The effective universe domain
105
+ #
106
+ # @return [String]
107
+ #
108
+ def universe_domain
109
+ @analytics_service_stub.universe_domain
110
+ end
111
+
112
+ ##
113
+ # Create a new AnalyticsService REST client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the AnalyticsService client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
129
+ # Create the configuration object
130
+ @config = Configuration.new Client.configure
131
+
132
+ # Yield the configuration if needed
133
+ yield @config if block_given?
134
+
135
+ # Create credentials
136
+ credentials = @config.credentials
137
+ # Use self-signed JWT if the endpoint is unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.endpoint.nil? ||
140
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
141
+ !@config.endpoint.split(".").first.include?("-"))
142
+ credentials ||= Credentials.default scope: @config.scope,
143
+ enable_self_signed_jwt: enable_self_signed_jwt
144
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
145
+ credentials = Credentials.new credentials, scope: @config.scope
146
+ end
147
+
148
+ @quota_project_id = @config.quota_project
149
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
150
+
151
+ @operations_client = ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Operations.new do |config|
152
+ config.credentials = credentials
153
+ config.quota_project = @quota_project_id
154
+ config.endpoint = @config.endpoint
155
+ config.universe_domain = @config.universe_domain
156
+ end
157
+
158
+ @analytics_service_stub = ::Google::Cloud::Retail::V2::AnalyticsService::Rest::ServiceStub.new(
159
+ endpoint: @config.endpoint,
160
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
161
+ universe_domain: @config.universe_domain,
162
+ credentials: credentials
163
+ )
164
+
165
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
166
+ config.credentials = credentials
167
+ config.quota_project = @quota_project_id
168
+ config.endpoint = @analytics_service_stub.endpoint
169
+ config.universe_domain = @analytics_service_stub.universe_domain
170
+ end
171
+ end
172
+
173
+ ##
174
+ # Get the associated client for long-running operations.
175
+ #
176
+ # @return [::Google::Cloud::Retail::V2::AnalyticsService::Rest::Operations]
177
+ #
178
+ attr_reader :operations_client
179
+
180
+ ##
181
+ # Get the associated client for mix-in of the Locations.
182
+ #
183
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
184
+ #
185
+ attr_reader :location_client
186
+
187
+ # Service calls
188
+
189
+ ##
190
+ # Exports analytics metrics.
191
+ #
192
+ # `Operation.response` is of type `ExportAnalyticsMetricsResponse`.
193
+ # `Operation.metadata` is of type `ExportMetadata`.
194
+ #
195
+ # @overload export_analytics_metrics(request, options = nil)
196
+ # Pass arguments to `export_analytics_metrics` via a request object, either of type
197
+ # {::Google::Cloud::Retail::V2::ExportAnalyticsMetricsRequest} or an equivalent Hash.
198
+ #
199
+ # @param request [::Google::Cloud::Retail::V2::ExportAnalyticsMetricsRequest, ::Hash]
200
+ # A request object representing the call parameters. Required. To specify no
201
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
202
+ # @param options [::Gapic::CallOptions, ::Hash]
203
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
204
+ #
205
+ # @overload export_analytics_metrics(catalog: nil, output_config: nil, filter: nil)
206
+ # Pass arguments to `export_analytics_metrics` via keyword arguments. Note that at
207
+ # least one keyword argument is required. To specify no parameters, or to keep all
208
+ # the default parameter values, pass an empty Hash as a request object (see above).
209
+ #
210
+ # @param catalog [::String]
211
+ # Required. Full resource name of the parent catalog.
212
+ # Expected format: `projects/*/locations/*/catalogs/*`
213
+ # @param output_config [::Google::Cloud::Retail::V2::OutputConfig, ::Hash]
214
+ # Required. The output location of the data.
215
+ # @param filter [::String]
216
+ # A filtering expression to specify restrictions on returned metrics.
217
+ # The expression is a sequence of terms. Each term applies a restriction to
218
+ # the returned metrics. Use this expression to restrict results to a
219
+ # specific time range.
220
+ #
221
+ # Currently we expect only one types of fields:
222
+ #
223
+ # * `timestamp`: This can be specified twice, once with a
224
+ # less than operator and once with a greater than operator. The
225
+ # `timestamp` restriction should result in one, contiguous, valid,
226
+ # `timestamp` range.
227
+ #
228
+ # Some examples of valid filters expressions:
229
+ #
230
+ # * Example 1: `timestamp > "2012-04-23T18:25:43.511Z"
231
+ # timestamp < "2012-04-23T18:30:43.511Z"`
232
+ # * Example 2: `timestamp > "2012-04-23T18:25:43.511Z"`
233
+ # @yield [result, operation] Access the result along with the TransportOperation object
234
+ # @yieldparam result [::Gapic::Operation]
235
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
236
+ #
237
+ # @return [::Gapic::Operation]
238
+ #
239
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
240
+ #
241
+ # @example Basic example
242
+ # require "google/cloud/retail/v2"
243
+ #
244
+ # # Create a client object. The client can be reused for multiple calls.
245
+ # client = Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.new
246
+ #
247
+ # # Create a request. To set request fields, pass in keyword arguments.
248
+ # request = Google::Cloud::Retail::V2::ExportAnalyticsMetricsRequest.new
249
+ #
250
+ # # Call the export_analytics_metrics method.
251
+ # result = client.export_analytics_metrics request
252
+ #
253
+ # # The returned object is of type Gapic::Operation. You can use it to
254
+ # # check the status of an operation, cancel it, or wait for results.
255
+ # # Here is how to wait for a response.
256
+ # result.wait_until_done! timeout: 60
257
+ # if result.response?
258
+ # p result.response
259
+ # else
260
+ # puts "No response received."
261
+ # end
262
+ #
263
+ def export_analytics_metrics request, options = nil
264
+ raise ::ArgumentError, "request must be provided" if request.nil?
265
+
266
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Retail::V2::ExportAnalyticsMetricsRequest
267
+
268
+ # Converts hash and nil to an options object
269
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
270
+
271
+ # Customize the options with defaults
272
+ call_metadata = @config.rpcs.export_analytics_metrics.metadata.to_h
273
+
274
+ # Set x-goog-api-client and x-goog-user-project headers
275
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
276
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
277
+ gapic_version: ::Google::Cloud::Retail::V2::VERSION,
278
+ transports_version_send: [:rest]
279
+
280
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
281
+
282
+ options.apply_defaults timeout: @config.rpcs.export_analytics_metrics.timeout,
283
+ metadata: call_metadata,
284
+ retry_policy: @config.rpcs.export_analytics_metrics.retry_policy
285
+
286
+ options.apply_defaults timeout: @config.timeout,
287
+ metadata: @config.metadata,
288
+ retry_policy: @config.retry_policy
289
+
290
+ @analytics_service_stub.export_analytics_metrics request, options do |result, operation|
291
+ result = ::Gapic::Operation.new result, @operations_client, options: options
292
+ yield result, operation if block_given?
293
+ return result
294
+ end
295
+ rescue ::Gapic::Rest::Error => e
296
+ raise ::Google::Cloud::Error.from_error(e)
297
+ end
298
+
299
+ ##
300
+ # Configuration class for the AnalyticsService REST API.
301
+ #
302
+ # This class represents the configuration for AnalyticsService REST,
303
+ # providing control over timeouts, retry behavior, logging, transport
304
+ # parameters, and other low-level controls. Certain parameters can also be
305
+ # applied individually to specific RPCs. See
306
+ # {::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client::Configuration::Rpcs}
307
+ # for a list of RPCs that can be configured independently.
308
+ #
309
+ # Configuration can be applied globally to all clients, or to a single client
310
+ # on construction.
311
+ #
312
+ # @example
313
+ #
314
+ # # Modify the global config, setting the timeout for
315
+ # # export_analytics_metrics to 20 seconds,
316
+ # # and all remaining timeouts to 10 seconds.
317
+ # ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.configure do |config|
318
+ # config.timeout = 10.0
319
+ # config.rpcs.export_analytics_metrics.timeout = 20.0
320
+ # end
321
+ #
322
+ # # Apply the above configuration only to a new client.
323
+ # client = ::Google::Cloud::Retail::V2::AnalyticsService::Rest::Client.new do |config|
324
+ # config.timeout = 10.0
325
+ # config.rpcs.export_analytics_metrics.timeout = 20.0
326
+ # end
327
+ #
328
+ # @!attribute [rw] endpoint
329
+ # A custom service endpoint, as a hostname or hostname:port. The default is
330
+ # nil, indicating to use the default endpoint in the current universe domain.
331
+ # @return [::String,nil]
332
+ # @!attribute [rw] credentials
333
+ # Credentials to send with calls. You may provide any of the following types:
334
+ # * (`String`) The path to a service account key file in JSON format
335
+ # * (`Hash`) A service account key as a Hash
336
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
337
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
338
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
339
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
340
+ # * (`nil`) indicating no credentials
341
+ # @return [::Object]
342
+ # @!attribute [rw] scope
343
+ # The OAuth scopes
344
+ # @return [::Array<::String>]
345
+ # @!attribute [rw] lib_name
346
+ # The library name as recorded in instrumentation and logging
347
+ # @return [::String]
348
+ # @!attribute [rw] lib_version
349
+ # The library version as recorded in instrumentation and logging
350
+ # @return [::String]
351
+ # @!attribute [rw] timeout
352
+ # The call timeout in seconds.
353
+ # @return [::Numeric]
354
+ # @!attribute [rw] metadata
355
+ # Additional headers to be sent with the call.
356
+ # @return [::Hash{::Symbol=>::String}]
357
+ # @!attribute [rw] retry_policy
358
+ # The retry policy. The value is a hash with the following keys:
359
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
360
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
361
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
362
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
363
+ # trigger a retry.
364
+ # @return [::Hash]
365
+ # @!attribute [rw] quota_project
366
+ # A separate project against which to charge quota.
367
+ # @return [::String]
368
+ # @!attribute [rw] universe_domain
369
+ # The universe domain within which to make requests. This determines the
370
+ # default endpoint URL. The default value of nil uses the environment
371
+ # universe (usually the default "googleapis.com" universe).
372
+ # @return [::String,nil]
373
+ #
374
+ class Configuration
375
+ extend ::Gapic::Config
376
+
377
+ # @private
378
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
379
+ DEFAULT_ENDPOINT = "retail.googleapis.com"
380
+
381
+ config_attr :endpoint, nil, ::String, nil
382
+ config_attr :credentials, nil do |value|
383
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
384
+ allowed.any? { |klass| klass === value }
385
+ end
386
+ config_attr :scope, nil, ::String, ::Array, nil
387
+ config_attr :lib_name, nil, ::String, nil
388
+ config_attr :lib_version, nil, ::String, nil
389
+ config_attr :timeout, nil, ::Numeric, nil
390
+ config_attr :metadata, nil, ::Hash, nil
391
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
392
+ config_attr :quota_project, nil, ::String, nil
393
+ config_attr :universe_domain, nil, ::String, nil
394
+
395
+ # @private
396
+ def initialize parent_config = nil
397
+ @parent_config = parent_config unless parent_config.nil?
398
+
399
+ yield self if block_given?
400
+ end
401
+
402
+ ##
403
+ # Configurations for individual RPCs
404
+ # @return [Rpcs]
405
+ #
406
+ def rpcs
407
+ @rpcs ||= begin
408
+ parent_rpcs = nil
409
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
410
+ Rpcs.new parent_rpcs
411
+ end
412
+ end
413
+
414
+ ##
415
+ # Configuration RPC class for the AnalyticsService API.
416
+ #
417
+ # Includes fields providing the configuration for each RPC in this service.
418
+ # Each configuration object is of type `Gapic::Config::Method` and includes
419
+ # the following configuration fields:
420
+ #
421
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
422
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
423
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
424
+ # include the following keys:
425
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
426
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
427
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
428
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
429
+ # trigger a retry.
430
+ #
431
+ class Rpcs
432
+ ##
433
+ # RPC-specific configuration for `export_analytics_metrics`
434
+ # @return [::Gapic::Config::Method]
435
+ #
436
+ attr_reader :export_analytics_metrics
437
+
438
+ # @private
439
+ def initialize parent_rpcs = nil
440
+ export_analytics_metrics_config = parent_rpcs.export_analytics_metrics if parent_rpcs.respond_to? :export_analytics_metrics
441
+ @export_analytics_metrics = ::Gapic::Config::Method.new export_analytics_metrics_config
442
+
443
+ yield self if block_given?
444
+ end
445
+ end
446
+ end
447
+ end
448
+ end
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end