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