google-cloud-discovery_engine-v1 0.6.0 → 0.8.0

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