google-cloud-discovery_engine-v1 0.6.0 → 0.7.0

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