google-cloud-discovery_engine-v1 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 (104) 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/v1/completion_service/client.rb +451 -0
  6. data/lib/google/cloud/discovery_engine/v1/completion_service/credentials.rb +47 -0
  7. data/lib/google/cloud/discovery_engine/v1/completion_service/paths.rb +78 -0
  8. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +408 -0
  9. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/service_stub.rb +114 -0
  10. data/lib/google/cloud/discovery_engine/v1/completion_service/rest.rb +52 -0
  11. data/lib/google/cloud/discovery_engine/v1/completion_service.rb +55 -0
  12. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +959 -0
  13. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/credentials.rb +47 -0
  14. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +176 -0
  15. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +797 -0
  16. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +450 -0
  17. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest.rb +52 -0
  18. data/lib/google/cloud/discovery_engine/v1/conversational_search_service.rb +55 -0
  19. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +1170 -0
  20. data/lib/google/cloud/discovery_engine/v1/document_service/credentials.rb +47 -0
  21. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +770 -0
  22. data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +135 -0
  23. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +971 -0
  24. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +977 -0
  25. data/lib/google/cloud/discovery_engine/v1/document_service/rest/service_stub.rb +518 -0
  26. data/lib/google/cloud/discovery_engine/v1/document_service/rest.rb +54 -0
  27. data/lib/google/cloud/discovery_engine/v1/document_service.rb +57 -0
  28. data/lib/google/cloud/discovery_engine/v1/rest.rb +42 -0
  29. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +853 -0
  30. data/lib/google/cloud/discovery_engine/v1/schema_service/credentials.rb +47 -0
  31. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +770 -0
  32. data/lib/google/cloud/discovery_engine/v1/schema_service/paths.rb +127 -0
  33. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +693 -0
  34. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +977 -0
  35. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/service_stub.rb +382 -0
  36. data/lib/google/cloud/discovery_engine/v1/schema_service/rest.rb +53 -0
  37. data/lib/google/cloud/discovery_engine/v1/schema_service.rb +56 -0
  38. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +529 -0
  39. data/lib/google/cloud/discovery_engine/v1/search_service/credentials.rb +47 -0
  40. data/lib/google/cloud/discovery_engine/v1/search_service/paths.rb +131 -0
  41. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +481 -0
  42. data/lib/google/cloud/discovery_engine/v1/search_service/rest/service_stub.rb +116 -0
  43. data/lib/google/cloud/discovery_engine/v1/search_service/rest.rb +52 -0
  44. data/lib/google/cloud/discovery_engine/v1/search_service.rb +55 -0
  45. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +654 -0
  46. data/lib/google/cloud/discovery_engine/v1/user_event_service/credentials.rb +47 -0
  47. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +770 -0
  48. data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +131 -0
  49. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +558 -0
  50. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +977 -0
  51. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +250 -0
  52. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest.rb +53 -0
  53. data/lib/google/cloud/discovery_engine/v1/user_event_service.rb +56 -0
  54. data/lib/google/cloud/discovery_engine/v1/version.rb +7 -2
  55. data/lib/google/cloud/discovery_engine/v1.rb +50 -0
  56. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +46 -0
  57. data/lib/google/cloud/discoveryengine/v1/completion_service_pb.rb +49 -0
  58. data/lib/google/cloud/discoveryengine/v1/completion_service_services_pb.rb +45 -0
  59. data/lib/google/cloud/discoveryengine/v1/conversation_pb.rb +54 -0
  60. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +61 -0
  61. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +67 -0
  62. data/lib/google/cloud/discoveryengine/v1/document_pb.rb +48 -0
  63. data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +58 -0
  64. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +79 -0
  65. data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +66 -0
  66. data/lib/google/cloud/discoveryengine/v1/purge_config_pb.rb +49 -0
  67. data/lib/google/cloud/discoveryengine/v1/schema_pb.rb +47 -0
  68. data/lib/google/cloud/discoveryengine/v1/schema_service_pb.rb +61 -0
  69. data/lib/google/cloud/discoveryengine/v1/schema_service_services_pb.rb +53 -0
  70. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +73 -0
  71. data/lib/google/cloud/discoveryengine/v1/search_service_services_pb.rb +45 -0
  72. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +58 -0
  73. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +53 -0
  74. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +59 -0
  75. data/lib/google-cloud-discovery_engine-v1.rb +21 -0
  76. data/proto_docs/README.md +4 -0
  77. data/proto_docs/google/api/client.rb +381 -0
  78. data/proto_docs/google/api/field_behavior.rb +85 -0
  79. data/proto_docs/google/api/httpbody.rb +80 -0
  80. data/proto_docs/google/api/launch_stage.rb +71 -0
  81. data/proto_docs/google/api/resource.rb +222 -0
  82. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +106 -0
  83. data/proto_docs/google/cloud/discoveryengine/v1/completion_service.rb +111 -0
  84. data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +113 -0
  85. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +206 -0
  86. data/proto_docs/google/cloud/discoveryengine/v1/document.rb +108 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +181 -0
  88. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +340 -0
  89. data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +84 -0
  90. data/proto_docs/google/cloud/discoveryengine/v1/schema.rb +45 -0
  91. data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +177 -0
  92. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +730 -0
  93. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +478 -0
  94. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +64 -0
  95. data/proto_docs/google/longrunning/operations.rb +164 -0
  96. data/proto_docs/google/protobuf/any.rb +144 -0
  97. data/proto_docs/google/protobuf/duration.rb +98 -0
  98. data/proto_docs/google/protobuf/empty.rb +34 -0
  99. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  100. data/proto_docs/google/protobuf/struct.rb +96 -0
  101. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  102. data/proto_docs/google/rpc/status.rb +48 -0
  103. data/proto_docs/google/type/date.rb +53 -0
  104. metadata +277 -13
@@ -0,0 +1,654 @@
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/v1/user_event_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module DiscoveryEngine
26
+ module V1
27
+ module UserEventService
28
+ ##
29
+ # Client for the UserEventService service.
30
+ #
31
+ # Service for ingesting end user actions on a website to Discovery Engine API.
32
+ #
33
+ class Client
34
+ include Paths
35
+
36
+ # @private
37
+ attr_reader :user_event_service_stub
38
+
39
+ ##
40
+ # Configure the UserEventService Client class.
41
+ #
42
+ # See {::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # @example
46
+ #
47
+ # # Modify the configuration for all UserEventService clients
48
+ # ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "DiscoveryEngine", "V1"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.timeout = 30.0
69
+ default_config.retry_policy = {
70
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
71
+ }
72
+
73
+ default_config.rpcs.import_user_events.timeout = 300.0
74
+ default_config.rpcs.import_user_events.retry_policy = {
75
+ initial_delay: 1.0, max_delay: 30.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 UserEventService 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::UserEventService::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
+ # Create a new UserEventService client object.
106
+ #
107
+ # @example
108
+ #
109
+ # # Create a client using the default configuration
110
+ # client = ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new
111
+ #
112
+ # # Create a client using a custom configuration
113
+ # client = ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new do |config|
114
+ # config.timeout = 10.0
115
+ # end
116
+ #
117
+ # @yield [config] Configure the UserEventService client.
118
+ # @yieldparam config [Client::Configuration]
119
+ #
120
+ def initialize
121
+ # These require statements are intentionally placed here to initialize
122
+ # the gRPC module only when it's required.
123
+ # See https://github.com/googleapis/toolkit/issues/446
124
+ require "gapic/grpc"
125
+ require "google/cloud/discoveryengine/v1/user_event_service_services_pb"
126
+
127
+ # Create the configuration object
128
+ @config = Configuration.new Client.configure
129
+
130
+ # Yield the configuration if needed
131
+ yield @config if block_given?
132
+
133
+ # Create credentials
134
+ credentials = @config.credentials
135
+ # Use self-signed JWT if the endpoint is unchanged from default,
136
+ # but only if the default endpoint does not have a region prefix.
137
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
138
+ !@config.endpoint.split(".").first.include?("-")
139
+ credentials ||= Credentials.default scope: @config.scope,
140
+ enable_self_signed_jwt: enable_self_signed_jwt
141
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
142
+ credentials = Credentials.new credentials, scope: @config.scope
143
+ end
144
+ @quota_project_id = @config.quota_project
145
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
146
+
147
+ @operations_client = Operations.new do |config|
148
+ config.credentials = credentials
149
+ config.quota_project = @quota_project_id
150
+ config.endpoint = @config.endpoint
151
+ end
152
+
153
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
154
+ config.credentials = credentials
155
+ config.quota_project = @quota_project_id
156
+ config.endpoint = @config.endpoint
157
+ end
158
+
159
+ @user_event_service_stub = ::Gapic::ServiceStub.new(
160
+ ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Stub,
161
+ credentials: credentials,
162
+ endpoint: @config.endpoint,
163
+ channel_args: @config.channel_args,
164
+ interceptors: @config.interceptors
165
+ )
166
+ end
167
+
168
+ ##
169
+ # Get the associated client for long-running operations.
170
+ #
171
+ # @return [::Google::Cloud::DiscoveryEngine::V1::UserEventService::Operations]
172
+ #
173
+ attr_reader :operations_client
174
+
175
+ ##
176
+ # Get the associated client for mix-in of the Locations.
177
+ #
178
+ # @return [Google::Cloud::Location::Locations::Client]
179
+ #
180
+ attr_reader :location_client
181
+
182
+ # Service calls
183
+
184
+ ##
185
+ # Writes a single user event.
186
+ #
187
+ # @overload write_user_event(request, options = nil)
188
+ # Pass arguments to `write_user_event` via a request object, either of type
189
+ # {::Google::Cloud::DiscoveryEngine::V1::WriteUserEventRequest} or an equivalent Hash.
190
+ #
191
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::WriteUserEventRequest, ::Hash]
192
+ # A request object representing the call parameters. Required. To specify no
193
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
194
+ # @param options [::Gapic::CallOptions, ::Hash]
195
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
196
+ #
197
+ # @overload write_user_event(parent: nil, user_event: nil)
198
+ # Pass arguments to `write_user_event` via keyword arguments. Note that at
199
+ # least one keyword argument is required. To specify no parameters, or to keep all
200
+ # the default parameter values, pass an empty Hash as a request object (see above).
201
+ #
202
+ # @param parent [::String]
203
+ # Required. The parent DataStore resource name, such as
204
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`.
205
+ # @param user_event [::Google::Cloud::DiscoveryEngine::V1::UserEvent, ::Hash]
206
+ # Required. User event to write.
207
+ #
208
+ # @yield [response, operation] Access the result along with the RPC operation
209
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::UserEvent]
210
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
211
+ #
212
+ # @return [::Google::Cloud::DiscoveryEngine::V1::UserEvent]
213
+ #
214
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
215
+ #
216
+ # @example Basic example
217
+ # require "google/cloud/discovery_engine/v1"
218
+ #
219
+ # # Create a client object. The client can be reused for multiple calls.
220
+ # client = Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new
221
+ #
222
+ # # Create a request. To set request fields, pass in keyword arguments.
223
+ # request = Google::Cloud::DiscoveryEngine::V1::WriteUserEventRequest.new
224
+ #
225
+ # # Call the write_user_event method.
226
+ # result = client.write_user_event request
227
+ #
228
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::UserEvent.
229
+ # p result
230
+ #
231
+ def write_user_event request, options = nil
232
+ raise ::ArgumentError, "request must be provided" if request.nil?
233
+
234
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::WriteUserEventRequest
235
+
236
+ # Converts hash and nil to an options object
237
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
238
+
239
+ # Customize the options with defaults
240
+ metadata = @config.rpcs.write_user_event.metadata.to_h
241
+
242
+ # Set x-goog-api-client and x-goog-user-project headers
243
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
244
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
245
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
246
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
247
+
248
+ header_params = {}
249
+ if request.parent
250
+ header_params["parent"] = request.parent
251
+ end
252
+
253
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
254
+ metadata[:"x-goog-request-params"] ||= request_params_header
255
+
256
+ options.apply_defaults timeout: @config.rpcs.write_user_event.timeout,
257
+ metadata: metadata,
258
+ retry_policy: @config.rpcs.write_user_event.retry_policy
259
+
260
+ options.apply_defaults timeout: @config.timeout,
261
+ metadata: @config.metadata,
262
+ retry_policy: @config.retry_policy
263
+
264
+ @user_event_service_stub.call_rpc :write_user_event, request, options: options do |response, operation|
265
+ yield response, operation if block_given?
266
+ return response
267
+ end
268
+ rescue ::GRPC::BadStatus => e
269
+ raise ::Google::Cloud::Error.from_error(e)
270
+ end
271
+
272
+ ##
273
+ # Writes a single user event from the browser. This uses a GET request to
274
+ # due to browser restriction of POST-ing to a third-party domain.
275
+ #
276
+ # This method is used only by the Discovery Engine API JavaScript pixel and
277
+ # Google Tag Manager. Users should not call this method directly.
278
+ #
279
+ # @overload collect_user_event(request, options = nil)
280
+ # Pass arguments to `collect_user_event` via a request object, either of type
281
+ # {::Google::Cloud::DiscoveryEngine::V1::CollectUserEventRequest} or an equivalent Hash.
282
+ #
283
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::CollectUserEventRequest, ::Hash]
284
+ # A request object representing the call parameters. Required. To specify no
285
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
286
+ # @param options [::Gapic::CallOptions, ::Hash]
287
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
288
+ #
289
+ # @overload collect_user_event(parent: nil, user_event: nil, uri: nil, ets: nil)
290
+ # Pass arguments to `collect_user_event` via keyword arguments. Note that at
291
+ # least one keyword argument is required. To specify no parameters, or to keep all
292
+ # the default parameter values, pass an empty Hash as a request object (see above).
293
+ #
294
+ # @param parent [::String]
295
+ # Required. The parent DataStore resource name, such as
296
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`.
297
+ # @param user_event [::String]
298
+ # Required. URL encoded UserEvent proto with a length limit of 2,000,000
299
+ # characters.
300
+ # @param uri [::String]
301
+ # The URL including cgi-parameters but excluding the hash fragment with a
302
+ # length limit of 5,000 characters. This is often more useful than the
303
+ # referer URL, because many browsers only send the domain for third-party
304
+ # requests.
305
+ # @param ets [::Integer]
306
+ # The event timestamp in milliseconds. This prevents browser caching of
307
+ # otherwise identical get requests. The name is abbreviated to reduce the
308
+ # payload bytes.
309
+ #
310
+ # @yield [response, operation] Access the result along with the RPC operation
311
+ # @yieldparam response [::Google::Api::HttpBody]
312
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
313
+ #
314
+ # @return [::Google::Api::HttpBody]
315
+ #
316
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
317
+ #
318
+ # @example Basic example
319
+ # require "google/cloud/discovery_engine/v1"
320
+ #
321
+ # # Create a client object. The client can be reused for multiple calls.
322
+ # client = Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new
323
+ #
324
+ # # Create a request. To set request fields, pass in keyword arguments.
325
+ # request = Google::Cloud::DiscoveryEngine::V1::CollectUserEventRequest.new
326
+ #
327
+ # # Call the collect_user_event method.
328
+ # result = client.collect_user_event request
329
+ #
330
+ # # The returned object is of type Google::Api::HttpBody.
331
+ # p result
332
+ #
333
+ def collect_user_event request, options = nil
334
+ raise ::ArgumentError, "request must be provided" if request.nil?
335
+
336
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CollectUserEventRequest
337
+
338
+ # Converts hash and nil to an options object
339
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
340
+
341
+ # Customize the options with defaults
342
+ metadata = @config.rpcs.collect_user_event.metadata.to_h
343
+
344
+ # Set x-goog-api-client and x-goog-user-project headers
345
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
346
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
347
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
348
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
349
+
350
+ header_params = {}
351
+ if request.parent
352
+ header_params["parent"] = request.parent
353
+ end
354
+
355
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
356
+ metadata[:"x-goog-request-params"] ||= request_params_header
357
+
358
+ options.apply_defaults timeout: @config.rpcs.collect_user_event.timeout,
359
+ metadata: metadata,
360
+ retry_policy: @config.rpcs.collect_user_event.retry_policy
361
+
362
+ options.apply_defaults timeout: @config.timeout,
363
+ metadata: @config.metadata,
364
+ retry_policy: @config.retry_policy
365
+
366
+ @user_event_service_stub.call_rpc :collect_user_event, request, options: options do |response, operation|
367
+ yield response, operation if block_given?
368
+ return response
369
+ end
370
+ rescue ::GRPC::BadStatus => e
371
+ raise ::Google::Cloud::Error.from_error(e)
372
+ end
373
+
374
+ ##
375
+ # Bulk import of User events. Request processing might be
376
+ # synchronous. Events that already exist are skipped.
377
+ # Use this method for backfilling historical user events.
378
+ #
379
+ # Operation.response is of type ImportResponse. Note that it is
380
+ # possible for a subset of the items to be successfully inserted.
381
+ # Operation.metadata is of type ImportMetadata.
382
+ #
383
+ # @overload import_user_events(request, options = nil)
384
+ # Pass arguments to `import_user_events` via a request object, either of type
385
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportUserEventsRequest} or an equivalent Hash.
386
+ #
387
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ImportUserEventsRequest, ::Hash]
388
+ # A request object representing the call parameters. Required. To specify no
389
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
390
+ # @param options [::Gapic::CallOptions, ::Hash]
391
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
392
+ #
393
+ # @overload import_user_events(inline_source: nil, gcs_source: nil, bigquery_source: nil, parent: nil, error_config: nil)
394
+ # Pass arguments to `import_user_events` via keyword arguments. Note that at
395
+ # least one keyword argument is required. To specify no parameters, or to keep all
396
+ # the default parameter values, pass an empty Hash as a request object (see above).
397
+ #
398
+ # @param inline_source [::Google::Cloud::DiscoveryEngine::V1::ImportUserEventsRequest::InlineSource, ::Hash]
399
+ # The Inline source for the input content for UserEvents.
400
+ # @param gcs_source [::Google::Cloud::DiscoveryEngine::V1::GcsSource, ::Hash]
401
+ # Cloud Storage location for the input content.
402
+ # @param bigquery_source [::Google::Cloud::DiscoveryEngine::V1::BigQuerySource, ::Hash]
403
+ # BigQuery input source.
404
+ # @param parent [::String]
405
+ # Required. Parent DataStore resource name, of the form
406
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
407
+ # @param error_config [::Google::Cloud::DiscoveryEngine::V1::ImportErrorConfig, ::Hash]
408
+ # The desired location of errors incurred during the Import. Cannot be set
409
+ # for inline user event imports.
410
+ #
411
+ # @yield [response, operation] Access the result along with the RPC operation
412
+ # @yieldparam response [::Gapic::Operation]
413
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
414
+ #
415
+ # @return [::Gapic::Operation]
416
+ #
417
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
418
+ #
419
+ # @example Basic example
420
+ # require "google/cloud/discovery_engine/v1"
421
+ #
422
+ # # Create a client object. The client can be reused for multiple calls.
423
+ # client = Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new
424
+ #
425
+ # # Create a request. To set request fields, pass in keyword arguments.
426
+ # request = Google::Cloud::DiscoveryEngine::V1::ImportUserEventsRequest.new
427
+ #
428
+ # # Call the import_user_events method.
429
+ # result = client.import_user_events request
430
+ #
431
+ # # The returned object is of type Gapic::Operation. You can use it to
432
+ # # check the status of an operation, cancel it, or wait for results.
433
+ # # Here is how to wait for a response.
434
+ # result.wait_until_done! timeout: 60
435
+ # if result.response?
436
+ # p result.response
437
+ # else
438
+ # puts "No response received."
439
+ # end
440
+ #
441
+ def import_user_events request, options = nil
442
+ raise ::ArgumentError, "request must be provided" if request.nil?
443
+
444
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ImportUserEventsRequest
445
+
446
+ # Converts hash and nil to an options object
447
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
448
+
449
+ # Customize the options with defaults
450
+ metadata = @config.rpcs.import_user_events.metadata.to_h
451
+
452
+ # Set x-goog-api-client and x-goog-user-project headers
453
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
454
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
455
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
456
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
457
+
458
+ header_params = {}
459
+ if request.parent
460
+ header_params["parent"] = request.parent
461
+ end
462
+
463
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
464
+ metadata[:"x-goog-request-params"] ||= request_params_header
465
+
466
+ options.apply_defaults timeout: @config.rpcs.import_user_events.timeout,
467
+ metadata: metadata,
468
+ retry_policy: @config.rpcs.import_user_events.retry_policy
469
+
470
+ options.apply_defaults timeout: @config.timeout,
471
+ metadata: @config.metadata,
472
+ retry_policy: @config.retry_policy
473
+
474
+ @user_event_service_stub.call_rpc :import_user_events, request, options: options do |response, operation|
475
+ response = ::Gapic::Operation.new response, @operations_client, options: options
476
+ yield response, operation if block_given?
477
+ return response
478
+ end
479
+ rescue ::GRPC::BadStatus => e
480
+ raise ::Google::Cloud::Error.from_error(e)
481
+ end
482
+
483
+ ##
484
+ # Configuration class for the UserEventService API.
485
+ #
486
+ # This class represents the configuration for UserEventService,
487
+ # providing control over timeouts, retry behavior, logging, transport
488
+ # parameters, and other low-level controls. Certain parameters can also be
489
+ # applied individually to specific RPCs. See
490
+ # {::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client::Configuration::Rpcs}
491
+ # for a list of RPCs that can be configured independently.
492
+ #
493
+ # Configuration can be applied globally to all clients, or to a single client
494
+ # on construction.
495
+ #
496
+ # @example
497
+ #
498
+ # # Modify the global config, setting the timeout for
499
+ # # write_user_event to 20 seconds,
500
+ # # and all remaining timeouts to 10 seconds.
501
+ # ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.configure do |config|
502
+ # config.timeout = 10.0
503
+ # config.rpcs.write_user_event.timeout = 20.0
504
+ # end
505
+ #
506
+ # # Apply the above configuration only to a new client.
507
+ # client = ::Google::Cloud::DiscoveryEngine::V1::UserEventService::Client.new do |config|
508
+ # config.timeout = 10.0
509
+ # config.rpcs.write_user_event.timeout = 20.0
510
+ # end
511
+ #
512
+ # @!attribute [rw] endpoint
513
+ # The hostname or hostname:port of the service endpoint.
514
+ # Defaults to `"discoveryengine.googleapis.com"`.
515
+ # @return [::String]
516
+ # @!attribute [rw] credentials
517
+ # Credentials to send with calls. You may provide any of the following types:
518
+ # * (`String`) The path to a service account key file in JSON format
519
+ # * (`Hash`) A service account key as a Hash
520
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
521
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
522
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
523
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
524
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
525
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
526
+ # * (`nil`) indicating no credentials
527
+ # @return [::Object]
528
+ # @!attribute [rw] scope
529
+ # The OAuth scopes
530
+ # @return [::Array<::String>]
531
+ # @!attribute [rw] lib_name
532
+ # The library name as recorded in instrumentation and logging
533
+ # @return [::String]
534
+ # @!attribute [rw] lib_version
535
+ # The library version as recorded in instrumentation and logging
536
+ # @return [::String]
537
+ # @!attribute [rw] channel_args
538
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
539
+ # `GRPC::Core::Channel` object is provided as the credential.
540
+ # @return [::Hash]
541
+ # @!attribute [rw] interceptors
542
+ # An array of interceptors that are run before calls are executed.
543
+ # @return [::Array<::GRPC::ClientInterceptor>]
544
+ # @!attribute [rw] timeout
545
+ # The call timeout in seconds.
546
+ # @return [::Numeric]
547
+ # @!attribute [rw] metadata
548
+ # Additional gRPC headers to be sent with the call.
549
+ # @return [::Hash{::Symbol=>::String}]
550
+ # @!attribute [rw] retry_policy
551
+ # The retry policy. The value is a hash with the following keys:
552
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
553
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
554
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
555
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
556
+ # trigger a retry.
557
+ # @return [::Hash]
558
+ # @!attribute [rw] quota_project
559
+ # A separate project against which to charge quota.
560
+ # @return [::String]
561
+ #
562
+ class Configuration
563
+ extend ::Gapic::Config
564
+
565
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
566
+
567
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
568
+ config_attr :credentials, nil do |value|
569
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
570
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
571
+ allowed.any? { |klass| klass === value }
572
+ end
573
+ config_attr :scope, nil, ::String, ::Array, nil
574
+ config_attr :lib_name, nil, ::String, nil
575
+ config_attr :lib_version, nil, ::String, nil
576
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
577
+ config_attr :interceptors, nil, ::Array, nil
578
+ config_attr :timeout, nil, ::Numeric, nil
579
+ config_attr :metadata, nil, ::Hash, nil
580
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
581
+ config_attr :quota_project, nil, ::String, nil
582
+
583
+ # @private
584
+ def initialize parent_config = nil
585
+ @parent_config = parent_config unless parent_config.nil?
586
+
587
+ yield self if block_given?
588
+ end
589
+
590
+ ##
591
+ # Configurations for individual RPCs
592
+ # @return [Rpcs]
593
+ #
594
+ def rpcs
595
+ @rpcs ||= begin
596
+ parent_rpcs = nil
597
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
598
+ Rpcs.new parent_rpcs
599
+ end
600
+ end
601
+
602
+ ##
603
+ # Configuration RPC class for the UserEventService API.
604
+ #
605
+ # Includes fields providing the configuration for each RPC in this service.
606
+ # Each configuration object is of type `Gapic::Config::Method` and includes
607
+ # the following configuration fields:
608
+ #
609
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
610
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
611
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
612
+ # include the following keys:
613
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
614
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
615
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
616
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
617
+ # trigger a retry.
618
+ #
619
+ class Rpcs
620
+ ##
621
+ # RPC-specific configuration for `write_user_event`
622
+ # @return [::Gapic::Config::Method]
623
+ #
624
+ attr_reader :write_user_event
625
+ ##
626
+ # RPC-specific configuration for `collect_user_event`
627
+ # @return [::Gapic::Config::Method]
628
+ #
629
+ attr_reader :collect_user_event
630
+ ##
631
+ # RPC-specific configuration for `import_user_events`
632
+ # @return [::Gapic::Config::Method]
633
+ #
634
+ attr_reader :import_user_events
635
+
636
+ # @private
637
+ def initialize parent_rpcs = nil
638
+ write_user_event_config = parent_rpcs.write_user_event if parent_rpcs.respond_to? :write_user_event
639
+ @write_user_event = ::Gapic::Config::Method.new write_user_event_config
640
+ collect_user_event_config = parent_rpcs.collect_user_event if parent_rpcs.respond_to? :collect_user_event
641
+ @collect_user_event = ::Gapic::Config::Method.new collect_user_event_config
642
+ import_user_events_config = parent_rpcs.import_user_events if parent_rpcs.respond_to? :import_user_events
643
+ @import_user_events = ::Gapic::Config::Method.new import_user_events_config
644
+
645
+ yield self if block_given?
646
+ end
647
+ end
648
+ end
649
+ end
650
+ end
651
+ end
652
+ end
653
+ end
654
+ end