google-cloud-discovery_engine-v1beta 0.a → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) 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/cloud/discovery_engine/v1beta/completion_service/client.rb +429 -0
  6. data/lib/google/cloud/discovery_engine/v1beta/completion_service/credentials.rb +47 -0
  7. data/lib/google/cloud/discovery_engine/v1beta/completion_service/paths.rb +78 -0
  8. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/client.rb +386 -0
  9. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest/service_stub.rb +114 -0
  10. data/lib/google/cloud/discovery_engine/v1beta/completion_service/rest.rb +52 -0
  11. data/lib/google/cloud/discovery_engine/v1beta/completion_service.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1beta/document_service/client.rb +1159 -0
  13. data/lib/google/cloud/discovery_engine/v1beta/document_service/credentials.rb +47 -0
  14. data/lib/google/cloud/discovery_engine/v1beta/document_service/operations.rb +768 -0
  15. data/lib/google/cloud/discovery_engine/v1beta/document_service/paths.rb +135 -0
  16. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb +960 -0
  17. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/operations.rb +919 -0
  18. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/service_stub.rb +518 -0
  19. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest.rb +55 -0
  20. data/lib/google/cloud/discovery_engine/v1beta/document_service.rb +58 -0
  21. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/client.rb +486 -0
  22. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/credentials.rb +47 -0
  23. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/paths.rb +135 -0
  24. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/rest/client.rb +443 -0
  25. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/rest/service_stub.rb +116 -0
  26. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service/rest.rb +52 -0
  27. data/lib/google/cloud/discovery_engine/v1beta/recommendation_service.rb +55 -0
  28. data/lib/google/cloud/discovery_engine/v1beta/rest.rb +42 -0
  29. data/lib/google/cloud/discovery_engine/v1beta/schema_service/client.rb +840 -0
  30. data/lib/google/cloud/discovery_engine/v1beta/schema_service/credentials.rb +47 -0
  31. data/lib/google/cloud/discovery_engine/v1beta/schema_service/operations.rb +768 -0
  32. data/lib/google/cloud/discovery_engine/v1beta/schema_service/paths.rb +127 -0
  33. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/client.rb +680 -0
  34. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/operations.rb +919 -0
  35. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest/service_stub.rb +382 -0
  36. data/lib/google/cloud/discovery_engine/v1beta/schema_service/rest.rb +53 -0
  37. data/lib/google/cloud/discovery_engine/v1beta/schema_service.rb +56 -0
  38. data/lib/google/cloud/discovery_engine/v1beta/search_service/client.rb +511 -0
  39. data/lib/google/cloud/discovery_engine/v1beta/search_service/credentials.rb +47 -0
  40. data/lib/google/cloud/discovery_engine/v1beta/search_service/paths.rb +131 -0
  41. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/client.rb +463 -0
  42. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/service_stub.rb +116 -0
  43. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest.rb +52 -0
  44. data/lib/google/cloud/discovery_engine/v1beta/search_service.rb +55 -0
  45. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/client.rb +638 -0
  46. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/credentials.rb +47 -0
  47. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/operations.rb +768 -0
  48. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/paths.rb +131 -0
  49. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/client.rb +542 -0
  50. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/operations.rb +919 -0
  51. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest/service_stub.rb +250 -0
  52. data/lib/google/cloud/discovery_engine/v1beta/user_event_service/rest.rb +53 -0
  53. data/lib/google/cloud/discovery_engine/v1beta/user_event_service.rb +56 -0
  54. data/lib/google/cloud/discovery_engine/v1beta/version.rb +7 -2
  55. data/lib/google/cloud/discovery_engine/v1beta.rb +50 -0
  56. data/lib/google/cloud/discoveryengine/v1beta/common_pb.rb +46 -0
  57. data/lib/google/cloud/discoveryengine/v1beta/completion_service_pb.rb +49 -0
  58. data/lib/google/cloud/discoveryengine/v1beta/completion_service_services_pb.rb +45 -0
  59. data/lib/google/cloud/discoveryengine/v1beta/document_pb.rb +48 -0
  60. data/lib/google/cloud/discoveryengine/v1beta/document_service_pb.rb +58 -0
  61. data/lib/google/cloud/discoveryengine/v1beta/document_service_services_pb.rb +81 -0
  62. data/lib/google/cloud/discoveryengine/v1beta/import_config_pb.rb +66 -0
  63. data/lib/google/cloud/discoveryengine/v1beta/purge_config_pb.rb +49 -0
  64. data/lib/google/cloud/discoveryengine/v1beta/recommendation_service_pb.rb +55 -0
  65. data/lib/google/cloud/discoveryengine/v1beta/recommendation_service_services_pb.rb +45 -0
  66. data/lib/google/cloud/discoveryengine/v1beta/schema_pb.rb +47 -0
  67. data/lib/google/cloud/discoveryengine/v1beta/schema_service_pb.rb +61 -0
  68. data/lib/google/cloud/discoveryengine/v1beta/schema_service_services_pb.rb +53 -0
  69. data/lib/google/cloud/discoveryengine/v1beta/search_service_pb.rb +71 -0
  70. data/lib/google/cloud/discoveryengine/v1beta/search_service_services_pb.rb +45 -0
  71. data/lib/google/cloud/discoveryengine/v1beta/user_event_pb.rb +58 -0
  72. data/lib/google/cloud/discoveryengine/v1beta/user_event_service_pb.rb +53 -0
  73. data/lib/google/cloud/discoveryengine/v1beta/user_event_service_services_pb.rb +59 -0
  74. data/lib/google-cloud-discovery_engine-v1beta.rb +21 -0
  75. data/proto_docs/README.md +4 -0
  76. data/proto_docs/google/api/client.rb +381 -0
  77. data/proto_docs/google/api/field_behavior.rb +71 -0
  78. data/proto_docs/google/api/httpbody.rb +80 -0
  79. data/proto_docs/google/api/launch_stage.rb +71 -0
  80. data/proto_docs/google/api/resource.rb +222 -0
  81. data/proto_docs/google/cloud/discoveryengine/v1beta/common.rb +107 -0
  82. data/proto_docs/google/cloud/discoveryengine/v1beta/completion_service.rb +98 -0
  83. data/proto_docs/google/cloud/discoveryengine/v1beta/document.rb +107 -0
  84. data/proto_docs/google/cloud/discoveryengine/v1beta/document_service.rb +181 -0
  85. data/proto_docs/google/cloud/discoveryengine/v1beta/import_config.rb +340 -0
  86. data/proto_docs/google/cloud/discoveryengine/v1beta/purge_config.rb +84 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1beta/recommendation_service.rb +210 -0
  88. data/proto_docs/google/cloud/discoveryengine/v1beta/schema.rb +45 -0
  89. data/proto_docs/google/cloud/discoveryengine/v1beta/schema_service.rb +180 -0
  90. data/proto_docs/google/cloud/discoveryengine/v1beta/search_service.rb +603 -0
  91. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event.rb +473 -0
  92. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event_service.rb +64 -0
  93. data/proto_docs/google/longrunning/operations.rb +164 -0
  94. data/proto_docs/google/protobuf/any.rb +144 -0
  95. data/proto_docs/google/protobuf/duration.rb +98 -0
  96. data/proto_docs/google/protobuf/empty.rb +34 -0
  97. data/proto_docs/google/protobuf/struct.rb +96 -0
  98. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  99. data/proto_docs/google/rpc/status.rb +48 -0
  100. data/proto_docs/google/type/date.rb +53 -0
  101. metadata +254 -12
@@ -0,0 +1,486 @@
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/cloud/discoveryengine/v1beta/recommendation_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module DiscoveryEngine
25
+ module V1beta
26
+ module RecommendationService
27
+ ##
28
+ # Client for the RecommendationService service.
29
+ #
30
+ # Service for making recommendations.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :recommendation_service_stub
37
+
38
+ ##
39
+ # Configure the RecommendationService Client class.
40
+ #
41
+ # See {::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
46
+ # # Modify the configuration for all RecommendationService clients
47
+ # ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::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", "Cloud", "DiscoveryEngine", "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 = 5.0
68
+ default_config.retry_policy = {
69
+ initial_delay: 0.1, max_delay: 5.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 RecommendationService 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::Cloud::DiscoveryEngine::V1beta::RecommendationService::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 RecommendationService client object.
100
+ #
101
+ # @example
102
+ #
103
+ # # Create a client using the default configuration
104
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client.new
105
+ #
106
+ # # Create a client using a custom configuration
107
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client.new do |config|
108
+ # config.timeout = 10.0
109
+ # end
110
+ #
111
+ # @yield [config] Configure the RecommendationService 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/cloud/discoveryengine/v1beta/recommendation_service_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 == Client.configure.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
+ @recommendation_service_stub = ::Gapic::ServiceStub.new(
142
+ ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Stub,
143
+ credentials: credentials,
144
+ endpoint: @config.endpoint,
145
+ channel_args: @config.channel_args,
146
+ interceptors: @config.interceptors
147
+ )
148
+ end
149
+
150
+ # Service calls
151
+
152
+ ##
153
+ # Makes a recommendation, which requires a contextual user event.
154
+ #
155
+ # @overload recommend(request, options = nil)
156
+ # Pass arguments to `recommend` via a request object, either of type
157
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RecommendRequest} or an equivalent Hash.
158
+ #
159
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::RecommendRequest, ::Hash]
160
+ # A request object representing the call parameters. Required. To specify no
161
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
162
+ # @param options [::Gapic::CallOptions, ::Hash]
163
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
164
+ #
165
+ # @overload recommend(serving_config: nil, user_event: nil, page_size: nil, filter: nil, validate_only: nil, params: nil, user_labels: nil)
166
+ # Pass arguments to `recommend` via keyword arguments. Note that at
167
+ # least one keyword argument is required. To specify no parameters, or to keep all
168
+ # the default parameter values, pass an empty Hash as a request object (see above).
169
+ #
170
+ # @param serving_config [::String]
171
+ # Required. Full resource name of the format:
172
+ # `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*`
173
+ #
174
+ # Before you can request recommendations from your model, you must create at
175
+ # least one serving config for it.
176
+ # @param user_event [::Google::Cloud::DiscoveryEngine::V1beta::UserEvent, ::Hash]
177
+ # Required. Context about the user, what they are looking at and what action
178
+ # they took to trigger the Recommend request. Note that this user event
179
+ # detail won't be ingested to userEvent logs. Thus, a separate userEvent
180
+ # write request is required for event logging.
181
+ #
182
+ # Don't set
183
+ # {::Google::Cloud::DiscoveryEngine::V1beta::UserEvent#user_pseudo_id UserEvent.user_pseudo_id}
184
+ # or
185
+ # {::Google::Cloud::DiscoveryEngine::V1beta::UserInfo#user_id UserEvent.user_info.user_id}
186
+ # to the same fixed ID for different users. If you are trying to receive
187
+ # non-personalized recommendations (not recommended; this can negatively
188
+ # impact model performance), instead set
189
+ # {::Google::Cloud::DiscoveryEngine::V1beta::UserEvent#user_pseudo_id UserEvent.user_pseudo_id}
190
+ # to a random unique ID and leave
191
+ # {::Google::Cloud::DiscoveryEngine::V1beta::UserInfo#user_id UserEvent.user_info.user_id}
192
+ # unset.
193
+ # @param page_size [::Integer]
194
+ # Maximum number of results to return. Set this property
195
+ # to the number of recommendation results needed. If zero, the service will
196
+ # choose a reasonable default. The maximum allowed value is 100. Values
197
+ # above 100 will be coerced to 100.
198
+ # @param filter [::String]
199
+ # Filter for restricting recommendation results with a length limit of 5,000
200
+ # characters. Currently, only filter expressions on the `filter_tags`
201
+ # attribute is supported.
202
+ #
203
+ #
204
+ # Examples:
205
+ #
206
+ # * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))`
207
+ # * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))`
208
+ #
209
+ # If your filter blocks all results, the API will return generic
210
+ # (unfiltered) popular Documents. If you only want results strictly matching
211
+ # the filters, set `strictFiltering` to True in
212
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RecommendRequest#params RecommendRequest.params}
213
+ # to receive empty results instead.
214
+ #
215
+ # Note that the API will never return
216
+ # {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s with
217
+ # `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices.
218
+ # @param validate_only [::Boolean]
219
+ # Use validate only mode for this recommendation query. If set to true, a
220
+ # fake model will be used that returns arbitrary Document IDs.
221
+ # Note that the validate only mode should only be used for testing the API,
222
+ # or if the model is not ready.
223
+ # @param params [::Hash{::String => ::Google::Protobuf::Value, ::Hash}]
224
+ # Additional domain specific parameters for the recommendations.
225
+ #
226
+ # Allowed values:
227
+ #
228
+ # * `returnDocument`: Boolean. If set to true, the associated Document
229
+ # object will be returned in
230
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse::RecommendationResult#document RecommendResponse.RecommendationResult.document}.
231
+ # * `returnScore`: Boolean. If set to true, the recommendation 'score'
232
+ # corresponding to each returned Document will be set in
233
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse::RecommendationResult#metadata RecommendResponse.RecommendationResult.metadata}.
234
+ # The given 'score' indicates the probability of a Document conversion
235
+ # given the user's context and history.
236
+ # * `strictFiltering`: Boolean. True by default. If set to false, the service
237
+ # will return generic (unfiltered) popular Documents instead of empty if
238
+ # your filter blocks all recommendation results.
239
+ # * `diversityLevel`: String. Default empty. If set to be non-empty, then
240
+ # it needs to be one of:
241
+ # * `no-diversity`
242
+ # * `low-diversity`
243
+ # * `medium-diversity`
244
+ # * `high-diversity`
245
+ # * `auto-diversity`
246
+ # This gives request-level control and adjusts recommendation results
247
+ # based on Document category.
248
+ # @param user_labels [::Hash{::String => ::String}]
249
+ # The user labels applied to a resource must meet the following requirements:
250
+ #
251
+ # * Each resource can have multiple labels, up to a maximum of 64.
252
+ # * Each label must be a key-value pair.
253
+ # * Keys have a minimum length of 1 character and a maximum length of 63
254
+ # characters and cannot be empty. Values can be empty and have a maximum
255
+ # length of 63 characters.
256
+ # * Keys and values can contain only lowercase letters, numeric characters,
257
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
258
+ # international characters are allowed.
259
+ # * The key portion of a label must be unique. However, you can use the same
260
+ # key with multiple resources.
261
+ # * Keys must start with a lowercase letter or international character.
262
+ #
263
+ # See [Requirements for
264
+ # labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
265
+ # for more details.
266
+ #
267
+ # @yield [response, operation] Access the result along with the RPC operation
268
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse]
269
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
270
+ #
271
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
274
+ #
275
+ # @example Basic example
276
+ # require "google/cloud/discovery_engine/v1beta"
277
+ #
278
+ # # Create a client object. The client can be reused for multiple calls.
279
+ # client = Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client.new
280
+ #
281
+ # # Create a request. To set request fields, pass in keyword arguments.
282
+ # request = Google::Cloud::DiscoveryEngine::V1beta::RecommendRequest.new
283
+ #
284
+ # # Call the recommend method.
285
+ # result = client.recommend request
286
+ #
287
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1beta::RecommendResponse.
288
+ # p result
289
+ #
290
+ def recommend request, options = nil
291
+ raise ::ArgumentError, "request must be provided" if request.nil?
292
+
293
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::RecommendRequest
294
+
295
+ # Converts hash and nil to an options object
296
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
297
+
298
+ # Customize the options with defaults
299
+ metadata = @config.rpcs.recommend.metadata.to_h
300
+
301
+ # Set x-goog-api-client and x-goog-user-project headers
302
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
303
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
304
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
305
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
306
+
307
+ header_params = {}
308
+ if request.serving_config
309
+ header_params["serving_config"] = request.serving_config
310
+ end
311
+
312
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
313
+ metadata[:"x-goog-request-params"] ||= request_params_header
314
+
315
+ options.apply_defaults timeout: @config.rpcs.recommend.timeout,
316
+ metadata: metadata,
317
+ retry_policy: @config.rpcs.recommend.retry_policy
318
+
319
+ options.apply_defaults timeout: @config.timeout,
320
+ metadata: @config.metadata,
321
+ retry_policy: @config.retry_policy
322
+
323
+ @recommendation_service_stub.call_rpc :recommend, request, options: options do |response, operation|
324
+ yield response, operation if block_given?
325
+ return response
326
+ end
327
+ rescue ::GRPC::BadStatus => e
328
+ raise ::Google::Cloud::Error.from_error(e)
329
+ end
330
+
331
+ ##
332
+ # Configuration class for the RecommendationService API.
333
+ #
334
+ # This class represents the configuration for RecommendationService,
335
+ # providing control over timeouts, retry behavior, logging, transport
336
+ # parameters, and other low-level controls. Certain parameters can also be
337
+ # applied individually to specific RPCs. See
338
+ # {::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client::Configuration::Rpcs}
339
+ # for a list of RPCs that can be configured independently.
340
+ #
341
+ # Configuration can be applied globally to all clients, or to a single client
342
+ # on construction.
343
+ #
344
+ # @example
345
+ #
346
+ # # Modify the global config, setting the timeout for
347
+ # # recommend to 20 seconds,
348
+ # # and all remaining timeouts to 10 seconds.
349
+ # ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client.configure do |config|
350
+ # config.timeout = 10.0
351
+ # config.rpcs.recommend.timeout = 20.0
352
+ # end
353
+ #
354
+ # # Apply the above configuration only to a new client.
355
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::RecommendationService::Client.new do |config|
356
+ # config.timeout = 10.0
357
+ # config.rpcs.recommend.timeout = 20.0
358
+ # end
359
+ #
360
+ # @!attribute [rw] endpoint
361
+ # The hostname or hostname:port of the service endpoint.
362
+ # Defaults to `"discoveryengine.googleapis.com"`.
363
+ # @return [::String]
364
+ # @!attribute [rw] credentials
365
+ # Credentials to send with calls. You may provide any of the following types:
366
+ # * (`String`) The path to a service account key file in JSON format
367
+ # * (`Hash`) A service account key as a Hash
368
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
369
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
370
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
371
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
372
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
373
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
374
+ # * (`nil`) indicating no credentials
375
+ # @return [::Object]
376
+ # @!attribute [rw] scope
377
+ # The OAuth scopes
378
+ # @return [::Array<::String>]
379
+ # @!attribute [rw] lib_name
380
+ # The library name as recorded in instrumentation and logging
381
+ # @return [::String]
382
+ # @!attribute [rw] lib_version
383
+ # The library version as recorded in instrumentation and logging
384
+ # @return [::String]
385
+ # @!attribute [rw] channel_args
386
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
387
+ # `GRPC::Core::Channel` object is provided as the credential.
388
+ # @return [::Hash]
389
+ # @!attribute [rw] interceptors
390
+ # An array of interceptors that are run before calls are executed.
391
+ # @return [::Array<::GRPC::ClientInterceptor>]
392
+ # @!attribute [rw] timeout
393
+ # The call timeout in seconds.
394
+ # @return [::Numeric]
395
+ # @!attribute [rw] metadata
396
+ # Additional gRPC headers to be sent with the call.
397
+ # @return [::Hash{::Symbol=>::String}]
398
+ # @!attribute [rw] retry_policy
399
+ # The retry policy. The value is a hash with the following keys:
400
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
401
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
402
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
403
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
404
+ # trigger a retry.
405
+ # @return [::Hash]
406
+ # @!attribute [rw] quota_project
407
+ # A separate project against which to charge quota.
408
+ # @return [::String]
409
+ #
410
+ class Configuration
411
+ extend ::Gapic::Config
412
+
413
+ config_attr :endpoint, "discoveryengine.googleapis.com", ::String
414
+ config_attr :credentials, nil do |value|
415
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
416
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
417
+ allowed.any? { |klass| klass === value }
418
+ end
419
+ config_attr :scope, nil, ::String, ::Array, nil
420
+ config_attr :lib_name, nil, ::String, nil
421
+ config_attr :lib_version, nil, ::String, nil
422
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
423
+ config_attr :interceptors, nil, ::Array, nil
424
+ config_attr :timeout, nil, ::Numeric, nil
425
+ config_attr :metadata, nil, ::Hash, nil
426
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
427
+ config_attr :quota_project, nil, ::String, nil
428
+
429
+ # @private
430
+ def initialize parent_config = nil
431
+ @parent_config = parent_config unless parent_config.nil?
432
+
433
+ yield self if block_given?
434
+ end
435
+
436
+ ##
437
+ # Configurations for individual RPCs
438
+ # @return [Rpcs]
439
+ #
440
+ def rpcs
441
+ @rpcs ||= begin
442
+ parent_rpcs = nil
443
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
444
+ Rpcs.new parent_rpcs
445
+ end
446
+ end
447
+
448
+ ##
449
+ # Configuration RPC class for the RecommendationService API.
450
+ #
451
+ # Includes fields providing the configuration for each RPC in this service.
452
+ # Each configuration object is of type `Gapic::Config::Method` and includes
453
+ # the following configuration fields:
454
+ #
455
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
456
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
457
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
458
+ # include the following keys:
459
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
460
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
461
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
462
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
463
+ # trigger a retry.
464
+ #
465
+ class Rpcs
466
+ ##
467
+ # RPC-specific configuration for `recommend`
468
+ # @return [::Gapic::Config::Method]
469
+ #
470
+ attr_reader :recommend
471
+
472
+ # @private
473
+ def initialize parent_rpcs = nil
474
+ recommend_config = parent_rpcs.recommend if parent_rpcs.respond_to? :recommend
475
+ @recommend = ::Gapic::Config::Method.new recommend_config
476
+
477
+ yield self if block_given?
478
+ end
479
+ end
480
+ end
481
+ end
482
+ end
483
+ end
484
+ end
485
+ end
486
+ end
@@ -0,0 +1,47 @@
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 Cloud
23
+ module DiscoveryEngine
24
+ module V1beta
25
+ module RecommendationService
26
+ # Credentials for the RecommendationService API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "GOOGLE_CLOUD_CREDENTIALS",
33
+ "GOOGLE_CLOUD_KEYFILE",
34
+ "GCLOUD_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
36
+ "GOOGLE_CLOUD_KEYFILE_JSON",
37
+ "GCLOUD_KEYFILE_JSON"
38
+ ]
39
+ self.paths = [
40
+ "~/.config/google_cloud/application_default_credentials.json"
41
+ ]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,135 @@
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
+
20
+ module Google
21
+ module Cloud
22
+ module DiscoveryEngine
23
+ module V1beta
24
+ module RecommendationService
25
+ # Path helper methods for the RecommendationService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Document resource string.
29
+ #
30
+ # @overload document_path(project:, location:, data_store:, branch:, document:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}`
34
+ #
35
+ # @param project [String]
36
+ # @param location [String]
37
+ # @param data_store [String]
38
+ # @param branch [String]
39
+ # @param document [String]
40
+ #
41
+ # @overload document_path(project:, location:, collection:, data_store:, branch:, document:)
42
+ # The resource will be in the following format:
43
+ #
44
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`
45
+ #
46
+ # @param project [String]
47
+ # @param location [String]
48
+ # @param collection [String]
49
+ # @param data_store [String]
50
+ # @param branch [String]
51
+ # @param document [String]
52
+ #
53
+ # @return [::String]
54
+ def document_path **args
55
+ resources = {
56
+ "branch:data_store:document:location:project" => (proc do |project:, location:, data_store:, branch:, document:|
57
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
58
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
59
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
60
+ raise ::ArgumentError, "branch cannot contain /" if branch.to_s.include? "/"
61
+
62
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/branches/#{branch}/documents/#{document}"
63
+ end),
64
+ "branch:collection:data_store:document:location:project" => (proc do |project:, location:, collection:, data_store:, branch:, document:|
65
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
66
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
67
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
68
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
69
+ raise ::ArgumentError, "branch cannot contain /" if branch.to_s.include? "/"
70
+
71
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/branches/#{branch}/documents/#{document}"
72
+ end)
73
+ }
74
+
75
+ resource = resources[args.keys.sort.join(":")]
76
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
77
+ resource.call(**args)
78
+ end
79
+
80
+ ##
81
+ # Create a fully-qualified ServingConfig resource string.
82
+ #
83
+ # @overload serving_config_path(project:, location:, data_store:, serving_config:)
84
+ # The resource will be in the following format:
85
+ #
86
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}`
87
+ #
88
+ # @param project [String]
89
+ # @param location [String]
90
+ # @param data_store [String]
91
+ # @param serving_config [String]
92
+ #
93
+ # @overload serving_config_path(project:, location:, collection:, data_store:, serving_config:)
94
+ # The resource will be in the following format:
95
+ #
96
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}`
97
+ #
98
+ # @param project [String]
99
+ # @param location [String]
100
+ # @param collection [String]
101
+ # @param data_store [String]
102
+ # @param serving_config [String]
103
+ #
104
+ # @return [::String]
105
+ def serving_config_path **args
106
+ resources = {
107
+ "data_store:location:project:serving_config" => (proc do |project:, location:, data_store:, serving_config:|
108
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
109
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
110
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
111
+
112
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
113
+ end),
114
+ "collection:data_store:location:project:serving_config" => (proc do |project:, location:, collection:, data_store:, serving_config:|
115
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
116
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
117
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
118
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
119
+
120
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
121
+ end)
122
+ }
123
+
124
+ resource = resources[args.keys.sort.join(":")]
125
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
126
+ resource.call(**args)
127
+ end
128
+
129
+ extend self
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end