google-cloud-discovery_engine-v1 0.a → 0.1.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 (91) 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 +431 -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 +388 -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/document_service/client.rb +1155 -0
  13. data/lib/google/cloud/discovery_engine/v1/document_service/credentials.rb +47 -0
  14. data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +770 -0
  15. data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +135 -0
  16. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +956 -0
  17. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +935 -0
  18. data/lib/google/cloud/discovery_engine/v1/document_service/rest/service_stub.rb +518 -0
  19. data/lib/google/cloud/discovery_engine/v1/document_service/rest.rb +54 -0
  20. data/lib/google/cloud/discovery_engine/v1/document_service.rb +57 -0
  21. data/lib/google/cloud/discovery_engine/v1/rest.rb +41 -0
  22. data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +839 -0
  23. data/lib/google/cloud/discovery_engine/v1/schema_service/credentials.rb +47 -0
  24. data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +770 -0
  25. data/lib/google/cloud/discovery_engine/v1/schema_service/paths.rb +127 -0
  26. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +679 -0
  27. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +935 -0
  28. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/service_stub.rb +382 -0
  29. data/lib/google/cloud/discovery_engine/v1/schema_service/rest.rb +53 -0
  30. data/lib/google/cloud/discovery_engine/v1/schema_service.rb +56 -0
  31. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +493 -0
  32. data/lib/google/cloud/discovery_engine/v1/search_service/credentials.rb +47 -0
  33. data/lib/google/cloud/discovery_engine/v1/search_service/paths.rb +131 -0
  34. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +446 -0
  35. data/lib/google/cloud/discovery_engine/v1/search_service/rest/service_stub.rb +116 -0
  36. data/lib/google/cloud/discovery_engine/v1/search_service/rest.rb +52 -0
  37. data/lib/google/cloud/discovery_engine/v1/search_service.rb +55 -0
  38. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +640 -0
  39. data/lib/google/cloud/discovery_engine/v1/user_event_service/credentials.rb +47 -0
  40. data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +770 -0
  41. data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +131 -0
  42. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +544 -0
  43. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +935 -0
  44. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +250 -0
  45. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest.rb +53 -0
  46. data/lib/google/cloud/discovery_engine/v1/user_event_service.rb +56 -0
  47. data/lib/google/cloud/discovery_engine/v1/version.rb +7 -2
  48. data/lib/google/cloud/discovery_engine/v1.rb +49 -0
  49. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +45 -0
  50. data/lib/google/cloud/discoveryengine/v1/completion_service_pb.rb +49 -0
  51. data/lib/google/cloud/discoveryengine/v1/completion_service_services_pb.rb +45 -0
  52. data/lib/google/cloud/discoveryengine/v1/document_pb.rb +48 -0
  53. data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +58 -0
  54. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +79 -0
  55. data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +66 -0
  56. data/lib/google/cloud/discoveryengine/v1/purge_config_pb.rb +49 -0
  57. data/lib/google/cloud/discoveryengine/v1/schema_pb.rb +47 -0
  58. data/lib/google/cloud/discoveryengine/v1/schema_service_pb.rb +61 -0
  59. data/lib/google/cloud/discoveryengine/v1/schema_service_services_pb.rb +53 -0
  60. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +61 -0
  61. data/lib/google/cloud/discoveryengine/v1/search_service_services_pb.rb +45 -0
  62. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +58 -0
  63. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +53 -0
  64. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +59 -0
  65. data/lib/google-cloud-discovery_engine-v1.rb +21 -0
  66. data/proto_docs/README.md +4 -0
  67. data/proto_docs/google/api/client.rb +381 -0
  68. data/proto_docs/google/api/field_behavior.rb +71 -0
  69. data/proto_docs/google/api/httpbody.rb +80 -0
  70. data/proto_docs/google/api/launch_stage.rb +71 -0
  71. data/proto_docs/google/api/resource.rb +222 -0
  72. data/proto_docs/google/cloud/discoveryengine/v1/common.rb +89 -0
  73. data/proto_docs/google/cloud/discoveryengine/v1/completion_service.rb +98 -0
  74. data/proto_docs/google/cloud/discoveryengine/v1/document.rb +105 -0
  75. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +180 -0
  76. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +336 -0
  77. data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +84 -0
  78. data/proto_docs/google/cloud/discoveryengine/v1/schema.rb +45 -0
  79. data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +177 -0
  80. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +294 -0
  81. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +466 -0
  82. data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +64 -0
  83. data/proto_docs/google/longrunning/operations.rb +164 -0
  84. data/proto_docs/google/protobuf/any.rb +144 -0
  85. data/proto_docs/google/protobuf/duration.rb +98 -0
  86. data/proto_docs/google/protobuf/empty.rb +34 -0
  87. data/proto_docs/google/protobuf/struct.rb +96 -0
  88. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  89. data/proto_docs/google/rpc/status.rb +48 -0
  90. data/proto_docs/google/type/date.rb +53 -0
  91. metadata +243 -12
@@ -0,0 +1,1155 @@
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/document_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module DiscoveryEngine
25
+ module V1
26
+ module DocumentService
27
+ ##
28
+ # Client for the DocumentService service.
29
+ #
30
+ # Service for ingesting {::Google::Cloud::DiscoveryEngine::V1::Document Document}
31
+ # information of the customer's website.
32
+ #
33
+ class Client
34
+ include Paths
35
+
36
+ # @private
37
+ attr_reader :document_service_stub
38
+
39
+ ##
40
+ # Configure the DocumentService Client class.
41
+ #
42
+ # See {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # @example
46
+ #
47
+ # # Modify the configuration for all DocumentService clients
48
+ # ::Google::Cloud::DiscoveryEngine::V1::DocumentService::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_documents.timeout = 300.0
74
+ default_config.rpcs.import_documents.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 DocumentService 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::DocumentService::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 DocumentService client object.
106
+ #
107
+ # @example
108
+ #
109
+ # # Create a client using the default configuration
110
+ # client = ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
111
+ #
112
+ # # Create a client using a custom configuration
113
+ # client = ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new do |config|
114
+ # config.timeout = 10.0
115
+ # end
116
+ #
117
+ # @yield [config] Configure the DocumentService 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/document_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
+ @document_service_stub = ::Gapic::ServiceStub.new(
154
+ ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Stub,
155
+ credentials: credentials,
156
+ endpoint: @config.endpoint,
157
+ channel_args: @config.channel_args,
158
+ interceptors: @config.interceptors
159
+ )
160
+ end
161
+
162
+ ##
163
+ # Get the associated client for long-running operations.
164
+ #
165
+ # @return [::Google::Cloud::DiscoveryEngine::V1::DocumentService::Operations]
166
+ #
167
+ attr_reader :operations_client
168
+
169
+ # Service calls
170
+
171
+ ##
172
+ # Gets a {::Google::Cloud::DiscoveryEngine::V1::Document Document}.
173
+ #
174
+ # @overload get_document(request, options = nil)
175
+ # Pass arguments to `get_document` via a request object, either of type
176
+ # {::Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest} or an equivalent Hash.
177
+ #
178
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest, ::Hash]
179
+ # A request object representing the call parameters. Required. To specify no
180
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
181
+ # @param options [::Gapic::CallOptions, ::Hash]
182
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
183
+ #
184
+ # @overload get_document(name: nil)
185
+ # Pass arguments to `get_document` via keyword arguments. Note that at
186
+ # least one keyword argument is required. To specify no parameters, or to keep all
187
+ # the default parameter values, pass an empty Hash as a request object (see above).
188
+ #
189
+ # @param name [::String]
190
+ # Required. Full resource name of
191
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, such as
192
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
193
+ #
194
+ # If the caller does not have permission to access the
195
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, regardless of whether
196
+ # or not it exists, a `PERMISSION_DENIED` error is returned.
197
+ #
198
+ # If the requested {::Google::Cloud::DiscoveryEngine::V1::Document Document} does
199
+ # not exist, a `NOT_FOUND` error is returned.
200
+ #
201
+ # @yield [response, operation] Access the result along with the RPC operation
202
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Document]
203
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
204
+ #
205
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Document]
206
+ #
207
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
208
+ #
209
+ # @example Basic example
210
+ # require "google/cloud/discovery_engine/v1"
211
+ #
212
+ # # Create a client object. The client can be reused for multiple calls.
213
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
214
+ #
215
+ # # Create a request. To set request fields, pass in keyword arguments.
216
+ # request = Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest.new
217
+ #
218
+ # # Call the get_document method.
219
+ # result = client.get_document request
220
+ #
221
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document.
222
+ # p result
223
+ #
224
+ def get_document request, options = nil
225
+ raise ::ArgumentError, "request must be provided" if request.nil?
226
+
227
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GetDocumentRequest
228
+
229
+ # Converts hash and nil to an options object
230
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
231
+
232
+ # Customize the options with defaults
233
+ metadata = @config.rpcs.get_document.metadata.to_h
234
+
235
+ # Set x-goog-api-client and x-goog-user-project headers
236
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
237
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
238
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
239
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
240
+
241
+ header_params = {}
242
+ if request.name
243
+ header_params["name"] = request.name
244
+ end
245
+
246
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
247
+ metadata[:"x-goog-request-params"] ||= request_params_header
248
+
249
+ options.apply_defaults timeout: @config.rpcs.get_document.timeout,
250
+ metadata: metadata,
251
+ retry_policy: @config.rpcs.get_document.retry_policy
252
+
253
+ options.apply_defaults timeout: @config.timeout,
254
+ metadata: @config.metadata,
255
+ retry_policy: @config.retry_policy
256
+
257
+ @document_service_stub.call_rpc :get_document, request, options: options do |response, operation|
258
+ yield response, operation if block_given?
259
+ return response
260
+ end
261
+ rescue ::GRPC::BadStatus => e
262
+ raise ::Google::Cloud::Error.from_error(e)
263
+ end
264
+
265
+ ##
266
+ # Gets a list of {::Google::Cloud::DiscoveryEngine::V1::Document Document}s.
267
+ #
268
+ # @overload list_documents(request, options = nil)
269
+ # Pass arguments to `list_documents` via a request object, either of type
270
+ # {::Google::Cloud::DiscoveryEngine::V1::ListDocumentsRequest} or an equivalent Hash.
271
+ #
272
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ListDocumentsRequest, ::Hash]
273
+ # A request object representing the call parameters. Required. To specify no
274
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
275
+ # @param options [::Gapic::CallOptions, ::Hash]
276
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
277
+ #
278
+ # @overload list_documents(parent: nil, page_size: nil, page_token: nil)
279
+ # Pass arguments to `list_documents` via keyword arguments. Note that at
280
+ # least one keyword argument is required. To specify no parameters, or to keep all
281
+ # the default parameter values, pass an empty Hash as a request object (see above).
282
+ #
283
+ # @param parent [::String]
284
+ # Required. The parent branch resource name, such as
285
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
286
+ # Use `default_branch` as the branch ID, to list documents under the default
287
+ # branch.
288
+ #
289
+ # If the caller does not have permission to list [Documents][]s under this
290
+ # branch, regardless of whether or not this branch exists, a
291
+ # `PERMISSION_DENIED` error is returned.
292
+ # @param page_size [::Integer]
293
+ # Maximum number of {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to
294
+ # return. If unspecified, defaults to 100. The maximum allowed value is 1000.
295
+ # Values above 1000 will be coerced to 1000.
296
+ #
297
+ # If this field is negative, an `INVALID_ARGUMENT` error is returned.
298
+ # @param page_token [::String]
299
+ # A page token
300
+ # {::Google::Cloud::DiscoveryEngine::V1::ListDocumentsResponse#next_page_token ListDocumentsResponse.next_page_token},
301
+ # received from a previous
302
+ # {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#list_documents DocumentService.ListDocuments}
303
+ # call. Provide this to retrieve the subsequent page.
304
+ #
305
+ # When paginating, all other parameters provided to
306
+ # {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#list_documents DocumentService.ListDocuments}
307
+ # must match the call that provided the page token. Otherwise, an
308
+ # `INVALID_ARGUMENT` error is returned.
309
+ #
310
+ # @yield [response, operation] Access the result along with the RPC operation
311
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>]
312
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
313
+ #
314
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::DiscoveryEngine::V1::Document>]
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::DocumentService::Client.new
323
+ #
324
+ # # Create a request. To set request fields, pass in keyword arguments.
325
+ # request = Google::Cloud::DiscoveryEngine::V1::ListDocumentsRequest.new
326
+ #
327
+ # # Call the list_documents method.
328
+ # result = client.list_documents request
329
+ #
330
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
331
+ # # over elements, and API calls will be issued to fetch pages as needed.
332
+ # result.each do |item|
333
+ # # Each element is of type ::Google::Cloud::DiscoveryEngine::V1::Document.
334
+ # p item
335
+ # end
336
+ #
337
+ def list_documents request, options = nil
338
+ raise ::ArgumentError, "request must be provided" if request.nil?
339
+
340
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ListDocumentsRequest
341
+
342
+ # Converts hash and nil to an options object
343
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
344
+
345
+ # Customize the options with defaults
346
+ metadata = @config.rpcs.list_documents.metadata.to_h
347
+
348
+ # Set x-goog-api-client and x-goog-user-project headers
349
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
350
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
351
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
352
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
353
+
354
+ header_params = {}
355
+ if request.parent
356
+ header_params["parent"] = request.parent
357
+ end
358
+
359
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
360
+ metadata[:"x-goog-request-params"] ||= request_params_header
361
+
362
+ options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
363
+ metadata: metadata,
364
+ retry_policy: @config.rpcs.list_documents.retry_policy
365
+
366
+ options.apply_defaults timeout: @config.timeout,
367
+ metadata: @config.metadata,
368
+ retry_policy: @config.retry_policy
369
+
370
+ @document_service_stub.call_rpc :list_documents, request, options: options do |response, operation|
371
+ response = ::Gapic::PagedEnumerable.new @document_service_stub, :list_documents, request, response, operation, options
372
+ yield response, operation if block_given?
373
+ return response
374
+ end
375
+ rescue ::GRPC::BadStatus => e
376
+ raise ::Google::Cloud::Error.from_error(e)
377
+ end
378
+
379
+ ##
380
+ # Creates a {::Google::Cloud::DiscoveryEngine::V1::Document Document}.
381
+ #
382
+ # @overload create_document(request, options = nil)
383
+ # Pass arguments to `create_document` via a request object, either of type
384
+ # {::Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest} or an equivalent Hash.
385
+ #
386
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest, ::Hash]
387
+ # A request object representing the call parameters. Required. To specify no
388
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
389
+ # @param options [::Gapic::CallOptions, ::Hash]
390
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
391
+ #
392
+ # @overload create_document(parent: nil, document: nil, document_id: nil)
393
+ # Pass arguments to `create_document` via keyword arguments. Note that at
394
+ # least one keyword argument is required. To specify no parameters, or to keep all
395
+ # the default parameter values, pass an empty Hash as a request object (see above).
396
+ #
397
+ # @param parent [::String]
398
+ # Required. The parent resource name, such as
399
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
400
+ # @param document [::Google::Cloud::DiscoveryEngine::V1::Document, ::Hash]
401
+ # Required. The {::Google::Cloud::DiscoveryEngine::V1::Document Document} to
402
+ # create.
403
+ # @param document_id [::String]
404
+ # Required. The ID to use for the
405
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, which will become the
406
+ # final component of the
407
+ # {::Google::Cloud::DiscoveryEngine::V1::Document#name Document.name}.
408
+ #
409
+ # If the caller does not have permission to create the
410
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, regardless of whether
411
+ # or not it exists, a `PERMISSION_DENIED` error is returned.
412
+ #
413
+ # This field must be unique among all
414
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s with the same
415
+ # {::Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest#parent parent}.
416
+ # Otherwise, an `ALREADY_EXISTS` error is returned.
417
+ #
418
+ # This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034)
419
+ # standard with a length limit of 63 characters. Otherwise, an
420
+ # `INVALID_ARGUMENT` error is returned.
421
+ #
422
+ # @yield [response, operation] Access the result along with the RPC operation
423
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Document]
424
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
425
+ #
426
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Document]
427
+ #
428
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
429
+ #
430
+ # @example Basic example
431
+ # require "google/cloud/discovery_engine/v1"
432
+ #
433
+ # # Create a client object. The client can be reused for multiple calls.
434
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
435
+ #
436
+ # # Create a request. To set request fields, pass in keyword arguments.
437
+ # request = Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest.new
438
+ #
439
+ # # Call the create_document method.
440
+ # result = client.create_document request
441
+ #
442
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document.
443
+ # p result
444
+ #
445
+ def create_document request, options = nil
446
+ raise ::ArgumentError, "request must be provided" if request.nil?
447
+
448
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CreateDocumentRequest
449
+
450
+ # Converts hash and nil to an options object
451
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
452
+
453
+ # Customize the options with defaults
454
+ metadata = @config.rpcs.create_document.metadata.to_h
455
+
456
+ # Set x-goog-api-client and x-goog-user-project headers
457
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
458
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
459
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
460
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
461
+
462
+ header_params = {}
463
+ if request.parent
464
+ header_params["parent"] = request.parent
465
+ end
466
+
467
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
468
+ metadata[:"x-goog-request-params"] ||= request_params_header
469
+
470
+ options.apply_defaults timeout: @config.rpcs.create_document.timeout,
471
+ metadata: metadata,
472
+ retry_policy: @config.rpcs.create_document.retry_policy
473
+
474
+ options.apply_defaults timeout: @config.timeout,
475
+ metadata: @config.metadata,
476
+ retry_policy: @config.retry_policy
477
+
478
+ @document_service_stub.call_rpc :create_document, request, options: options do |response, operation|
479
+ yield response, operation if block_given?
480
+ return response
481
+ end
482
+ rescue ::GRPC::BadStatus => e
483
+ raise ::Google::Cloud::Error.from_error(e)
484
+ end
485
+
486
+ ##
487
+ # Updates a {::Google::Cloud::DiscoveryEngine::V1::Document Document}.
488
+ #
489
+ # @overload update_document(request, options = nil)
490
+ # Pass arguments to `update_document` via a request object, either of type
491
+ # {::Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest} or an equivalent Hash.
492
+ #
493
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest, ::Hash]
494
+ # A request object representing the call parameters. Required. To specify no
495
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
496
+ # @param options [::Gapic::CallOptions, ::Hash]
497
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
498
+ #
499
+ # @overload update_document(document: nil, allow_missing: nil)
500
+ # Pass arguments to `update_document` via keyword arguments. Note that at
501
+ # least one keyword argument is required. To specify no parameters, or to keep all
502
+ # the default parameter values, pass an empty Hash as a request object (see above).
503
+ #
504
+ # @param document [::Google::Cloud::DiscoveryEngine::V1::Document, ::Hash]
505
+ # Required. The document to update/create.
506
+ #
507
+ # If the caller does not have permission to update the
508
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, regardless of whether
509
+ # or not it exists, a `PERMISSION_DENIED` error is returned.
510
+ #
511
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Document Document} to update does
512
+ # not exist and
513
+ # {::Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest#allow_missing allow_missing}
514
+ # is not set, a `NOT_FOUND` error is returned.
515
+ # @param allow_missing [::Boolean]
516
+ # If set to true, and the
517
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document} is not found, a new
518
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document} will be created.
519
+ #
520
+ # @yield [response, operation] Access the result along with the RPC operation
521
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::Document]
522
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
523
+ #
524
+ # @return [::Google::Cloud::DiscoveryEngine::V1::Document]
525
+ #
526
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
527
+ #
528
+ # @example Basic example
529
+ # require "google/cloud/discovery_engine/v1"
530
+ #
531
+ # # Create a client object. The client can be reused for multiple calls.
532
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
533
+ #
534
+ # # Create a request. To set request fields, pass in keyword arguments.
535
+ # request = Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest.new
536
+ #
537
+ # # Call the update_document method.
538
+ # result = client.update_document request
539
+ #
540
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Document.
541
+ # p result
542
+ #
543
+ def update_document request, options = nil
544
+ raise ::ArgumentError, "request must be provided" if request.nil?
545
+
546
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::UpdateDocumentRequest
547
+
548
+ # Converts hash and nil to an options object
549
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
550
+
551
+ # Customize the options with defaults
552
+ metadata = @config.rpcs.update_document.metadata.to_h
553
+
554
+ # Set x-goog-api-client and x-goog-user-project headers
555
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
556
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
557
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
558
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
559
+
560
+ header_params = {}
561
+ if request.document&.name
562
+ header_params["document.name"] = request.document.name
563
+ end
564
+
565
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
566
+ metadata[:"x-goog-request-params"] ||= request_params_header
567
+
568
+ options.apply_defaults timeout: @config.rpcs.update_document.timeout,
569
+ metadata: metadata,
570
+ retry_policy: @config.rpcs.update_document.retry_policy
571
+
572
+ options.apply_defaults timeout: @config.timeout,
573
+ metadata: @config.metadata,
574
+ retry_policy: @config.retry_policy
575
+
576
+ @document_service_stub.call_rpc :update_document, request, options: options do |response, operation|
577
+ yield response, operation if block_given?
578
+ return response
579
+ end
580
+ rescue ::GRPC::BadStatus => e
581
+ raise ::Google::Cloud::Error.from_error(e)
582
+ end
583
+
584
+ ##
585
+ # Deletes a {::Google::Cloud::DiscoveryEngine::V1::Document Document}.
586
+ #
587
+ # @overload delete_document(request, options = nil)
588
+ # Pass arguments to `delete_document` via a request object, either of type
589
+ # {::Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest} or an equivalent Hash.
590
+ #
591
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest, ::Hash]
592
+ # A request object representing the call parameters. Required. To specify no
593
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
594
+ # @param options [::Gapic::CallOptions, ::Hash]
595
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
596
+ #
597
+ # @overload delete_document(name: nil)
598
+ # Pass arguments to `delete_document` via keyword arguments. Note that at
599
+ # least one keyword argument is required. To specify no parameters, or to keep all
600
+ # the default parameter values, pass an empty Hash as a request object (see above).
601
+ #
602
+ # @param name [::String]
603
+ # Required. Full resource name of
604
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, such as
605
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`.
606
+ #
607
+ # If the caller does not have permission to delete the
608
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}, regardless of whether
609
+ # or not it exists, a `PERMISSION_DENIED` error is returned.
610
+ #
611
+ # If the {::Google::Cloud::DiscoveryEngine::V1::Document Document} to delete does
612
+ # not exist, a `NOT_FOUND` error is returned.
613
+ #
614
+ # @yield [response, operation] Access the result along with the RPC operation
615
+ # @yieldparam response [::Google::Protobuf::Empty]
616
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
617
+ #
618
+ # @return [::Google::Protobuf::Empty]
619
+ #
620
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
621
+ #
622
+ # @example Basic example
623
+ # require "google/cloud/discovery_engine/v1"
624
+ #
625
+ # # Create a client object. The client can be reused for multiple calls.
626
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
627
+ #
628
+ # # Create a request. To set request fields, pass in keyword arguments.
629
+ # request = Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest.new
630
+ #
631
+ # # Call the delete_document method.
632
+ # result = client.delete_document request
633
+ #
634
+ # # The returned object is of type Google::Protobuf::Empty.
635
+ # p result
636
+ #
637
+ def delete_document request, options = nil
638
+ raise ::ArgumentError, "request must be provided" if request.nil?
639
+
640
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::DeleteDocumentRequest
641
+
642
+ # Converts hash and nil to an options object
643
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
644
+
645
+ # Customize the options with defaults
646
+ metadata = @config.rpcs.delete_document.metadata.to_h
647
+
648
+ # Set x-goog-api-client and x-goog-user-project headers
649
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
650
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
651
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
652
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
653
+
654
+ header_params = {}
655
+ if request.name
656
+ header_params["name"] = request.name
657
+ end
658
+
659
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
660
+ metadata[:"x-goog-request-params"] ||= request_params_header
661
+
662
+ options.apply_defaults timeout: @config.rpcs.delete_document.timeout,
663
+ metadata: metadata,
664
+ retry_policy: @config.rpcs.delete_document.retry_policy
665
+
666
+ options.apply_defaults timeout: @config.timeout,
667
+ metadata: @config.metadata,
668
+ retry_policy: @config.retry_policy
669
+
670
+ @document_service_stub.call_rpc :delete_document, request, options: options do |response, operation|
671
+ yield response, operation if block_given?
672
+ return response
673
+ end
674
+ rescue ::GRPC::BadStatus => e
675
+ raise ::Google::Cloud::Error.from_error(e)
676
+ end
677
+
678
+ ##
679
+ # Bulk import of multiple
680
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s. Request processing
681
+ # may be synchronous. Non-existing items will be created.
682
+ #
683
+ # Note: It is possible for a subset of the
684
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to be successfully
685
+ # updated.
686
+ #
687
+ # @overload import_documents(request, options = nil)
688
+ # Pass arguments to `import_documents` via a request object, either of type
689
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest} or an equivalent Hash.
690
+ #
691
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest, ::Hash]
692
+ # A request object representing the call parameters. Required. To specify no
693
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
694
+ # @param options [::Gapic::CallOptions, ::Hash]
695
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
696
+ #
697
+ # @overload import_documents(inline_source: nil, gcs_source: nil, bigquery_source: nil, parent: nil, error_config: nil, reconciliation_mode: nil, auto_generate_ids: nil, id_field: nil)
698
+ # Pass arguments to `import_documents` via keyword arguments. Note that at
699
+ # least one keyword argument is required. To specify no parameters, or to keep all
700
+ # the default parameter values, pass an empty Hash as a request object (see above).
701
+ #
702
+ # @param inline_source [::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::InlineSource, ::Hash]
703
+ # The Inline source for the input content for documents.
704
+ # @param gcs_source [::Google::Cloud::DiscoveryEngine::V1::GcsSource, ::Hash]
705
+ # Cloud Storage location for the input content.
706
+ # @param bigquery_source [::Google::Cloud::DiscoveryEngine::V1::BigQuerySource, ::Hash]
707
+ # BigQuery input source.
708
+ # @param parent [::String]
709
+ # Required. The parent branch resource name, such as
710
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
711
+ # Requires create/update permission.
712
+ # @param error_config [::Google::Cloud::DiscoveryEngine::V1::ImportErrorConfig, ::Hash]
713
+ # The desired location of errors incurred during the Import.
714
+ # @param reconciliation_mode [::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::ReconciliationMode]
715
+ # The mode of reconciliation between existing documents and the documents to
716
+ # be imported. Defaults to
717
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::ReconciliationMode::INCREMENTAL ReconciliationMode.INCREMENTAL}.
718
+ # @param auto_generate_ids [::Boolean]
719
+ # Whether to automatically generate IDs for the documents if absent.
720
+ #
721
+ # If set to `true`,
722
+ # {::Google::Cloud::DiscoveryEngine::V1::Document#id Document.id}s are
723
+ # automatically generated based on the hash of the payload, where IDs may not
724
+ # be consistent during multiple imports. In which case
725
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest::ReconciliationMode::FULL ReconciliationMode.FULL}
726
+ # is highly recommended to avoid duplicate contents. If unset or set to
727
+ # `false`, {::Google::Cloud::DiscoveryEngine::V1::Document#id Document.id}s have
728
+ # to be specified using
729
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest#id_field id_field},
730
+ # otherwises, documents without IDs will fail to be imported.
731
+ #
732
+ # Only set this field when using
733
+ # {::Google::Cloud::DiscoveryEngine::V1::GcsSource GcsSource} or
734
+ # {::Google::Cloud::DiscoveryEngine::V1::BigQuerySource BigQuerySource}, and when
735
+ # {::Google::Cloud::DiscoveryEngine::V1::GcsSource#data_schema GcsSource.data_schema}
736
+ # or
737
+ # {::Google::Cloud::DiscoveryEngine::V1::BigQuerySource#data_schema BigQuerySource.data_schema}
738
+ # is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown.
739
+ # @param id_field [::String]
740
+ # The field in the Cloud Storage and BigQuery sources that indicates the
741
+ # unique IDs of the documents.
742
+ #
743
+ # For {::Google::Cloud::DiscoveryEngine::V1::GcsSource GcsSource} it is the key of
744
+ # the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`.
745
+ # For {::Google::Cloud::DiscoveryEngine::V1::BigQuerySource BigQuerySource} it is
746
+ # the column name of the BigQuery table where the unique ids are stored.
747
+ #
748
+ # The values of the JSON field or the BigQuery column will be used as the
749
+ # {::Google::Cloud::DiscoveryEngine::V1::Document#id Document.id}s. The JSON field
750
+ # or the BigQuery column must be of string type, and the values must be set
751
+ # as valid strings conform to [RFC-1034](https://tools.ietf.org/html/rfc1034)
752
+ # with 1-63 characters. Otherwise, documents without valid IDs will fail to
753
+ # be imported.
754
+ #
755
+ # Only set this field when using
756
+ # {::Google::Cloud::DiscoveryEngine::V1::GcsSource GcsSource} or
757
+ # {::Google::Cloud::DiscoveryEngine::V1::BigQuerySource BigQuerySource}, and when
758
+ # {::Google::Cloud::DiscoveryEngine::V1::GcsSource#data_schema GcsSource.data_schema}
759
+ # or
760
+ # {::Google::Cloud::DiscoveryEngine::V1::BigQuerySource#data_schema BigQuerySource.data_schema}
761
+ # is `custom`. And only set this field when
762
+ # {::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest#auto_generate_ids auto_generate_ids}
763
+ # is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown.
764
+ #
765
+ # If it is unset, a default value `_id` is used when importing from the
766
+ # allowed data sources.
767
+ #
768
+ # @yield [response, operation] Access the result along with the RPC operation
769
+ # @yieldparam response [::Gapic::Operation]
770
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
771
+ #
772
+ # @return [::Gapic::Operation]
773
+ #
774
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
775
+ #
776
+ # @example Basic example
777
+ # require "google/cloud/discovery_engine/v1"
778
+ #
779
+ # # Create a client object. The client can be reused for multiple calls.
780
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
781
+ #
782
+ # # Create a request. To set request fields, pass in keyword arguments.
783
+ # request = Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest.new
784
+ #
785
+ # # Call the import_documents method.
786
+ # result = client.import_documents request
787
+ #
788
+ # # The returned object is of type Gapic::Operation. You can use it to
789
+ # # check the status of an operation, cancel it, or wait for results.
790
+ # # Here is how to wait for a response.
791
+ # result.wait_until_done! timeout: 60
792
+ # if result.response?
793
+ # p result.response
794
+ # else
795
+ # puts "No response received."
796
+ # end
797
+ #
798
+ def import_documents request, options = nil
799
+ raise ::ArgumentError, "request must be provided" if request.nil?
800
+
801
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::ImportDocumentsRequest
802
+
803
+ # Converts hash and nil to an options object
804
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
805
+
806
+ # Customize the options with defaults
807
+ metadata = @config.rpcs.import_documents.metadata.to_h
808
+
809
+ # Set x-goog-api-client and x-goog-user-project headers
810
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
811
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
812
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
813
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
814
+
815
+ header_params = {}
816
+ if request.parent
817
+ header_params["parent"] = request.parent
818
+ end
819
+
820
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
821
+ metadata[:"x-goog-request-params"] ||= request_params_header
822
+
823
+ options.apply_defaults timeout: @config.rpcs.import_documents.timeout,
824
+ metadata: metadata,
825
+ retry_policy: @config.rpcs.import_documents.retry_policy
826
+
827
+ options.apply_defaults timeout: @config.timeout,
828
+ metadata: @config.metadata,
829
+ retry_policy: @config.retry_policy
830
+
831
+ @document_service_stub.call_rpc :import_documents, request, options: options do |response, operation|
832
+ response = ::Gapic::Operation.new response, @operations_client, options: options
833
+ yield response, operation if block_given?
834
+ return response
835
+ end
836
+ rescue ::GRPC::BadStatus => e
837
+ raise ::Google::Cloud::Error.from_error(e)
838
+ end
839
+
840
+ ##
841
+ # Permanently deletes all selected
842
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s in a branch.
843
+ #
844
+ # This process is asynchronous. Depending on the number of
845
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s to be deleted, this
846
+ # operation can take hours to complete. Before the delete operation
847
+ # completes, some {::Google::Cloud::DiscoveryEngine::V1::Document Document}s might
848
+ # still be returned by
849
+ # {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#get_document DocumentService.GetDocument}
850
+ # or
851
+ # {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client#list_documents DocumentService.ListDocuments}.
852
+ #
853
+ # To get a list of the {::Google::Cloud::DiscoveryEngine::V1::Document Document}s
854
+ # to be deleted, set
855
+ # {::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest#force PurgeDocumentsRequest.force}
856
+ # to false.
857
+ #
858
+ # @overload purge_documents(request, options = nil)
859
+ # Pass arguments to `purge_documents` via a request object, either of type
860
+ # {::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest} or an equivalent Hash.
861
+ #
862
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest, ::Hash]
863
+ # A request object representing the call parameters. Required. To specify no
864
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
865
+ # @param options [::Gapic::CallOptions, ::Hash]
866
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
867
+ #
868
+ # @overload purge_documents(parent: nil, filter: nil, force: nil)
869
+ # Pass arguments to `purge_documents` via keyword arguments. Note that at
870
+ # least one keyword argument is required. To specify no parameters, or to keep all
871
+ # the default parameter values, pass an empty Hash as a request object (see above).
872
+ #
873
+ # @param parent [::String]
874
+ # Required. The parent resource name, such as
875
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
876
+ # @param filter [::String]
877
+ # Required. Filter matching documents to purge. Only currently supported
878
+ # value is
879
+ # `*` (all items).
880
+ # @param force [::Boolean]
881
+ # Actually performs the purge. If `force` is set to false, return the
882
+ # expected purge count without deleting any documents.
883
+ #
884
+ # @yield [response, operation] Access the result along with the RPC operation
885
+ # @yieldparam response [::Gapic::Operation]
886
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
887
+ #
888
+ # @return [::Gapic::Operation]
889
+ #
890
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
891
+ #
892
+ # @example Basic example
893
+ # require "google/cloud/discovery_engine/v1"
894
+ #
895
+ # # Create a client object. The client can be reused for multiple calls.
896
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new
897
+ #
898
+ # # Create a request. To set request fields, pass in keyword arguments.
899
+ # request = Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest.new
900
+ #
901
+ # # Call the purge_documents method.
902
+ # result = client.purge_documents request
903
+ #
904
+ # # The returned object is of type Gapic::Operation. You can use it to
905
+ # # check the status of an operation, cancel it, or wait for results.
906
+ # # Here is how to wait for a response.
907
+ # result.wait_until_done! timeout: 60
908
+ # if result.response?
909
+ # p result.response
910
+ # else
911
+ # puts "No response received."
912
+ # end
913
+ #
914
+ def purge_documents request, options = nil
915
+ raise ::ArgumentError, "request must be provided" if request.nil?
916
+
917
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest
918
+
919
+ # Converts hash and nil to an options object
920
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
921
+
922
+ # Customize the options with defaults
923
+ metadata = @config.rpcs.purge_documents.metadata.to_h
924
+
925
+ # Set x-goog-api-client and x-goog-user-project headers
926
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
927
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
928
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
929
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
930
+
931
+ header_params = {}
932
+ if request.parent
933
+ header_params["parent"] = request.parent
934
+ end
935
+
936
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
937
+ metadata[:"x-goog-request-params"] ||= request_params_header
938
+
939
+ options.apply_defaults timeout: @config.rpcs.purge_documents.timeout,
940
+ metadata: metadata,
941
+ retry_policy: @config.rpcs.purge_documents.retry_policy
942
+
943
+ options.apply_defaults timeout: @config.timeout,
944
+ metadata: @config.metadata,
945
+ retry_policy: @config.retry_policy
946
+
947
+ @document_service_stub.call_rpc :purge_documents, request, options: options do |response, operation|
948
+ response = ::Gapic::Operation.new response, @operations_client, options: options
949
+ yield response, operation if block_given?
950
+ return response
951
+ end
952
+ rescue ::GRPC::BadStatus => e
953
+ raise ::Google::Cloud::Error.from_error(e)
954
+ end
955
+
956
+ ##
957
+ # Configuration class for the DocumentService API.
958
+ #
959
+ # This class represents the configuration for DocumentService,
960
+ # providing control over timeouts, retry behavior, logging, transport
961
+ # parameters, and other low-level controls. Certain parameters can also be
962
+ # applied individually to specific RPCs. See
963
+ # {::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client::Configuration::Rpcs}
964
+ # for a list of RPCs that can be configured independently.
965
+ #
966
+ # Configuration can be applied globally to all clients, or to a single client
967
+ # on construction.
968
+ #
969
+ # @example
970
+ #
971
+ # # Modify the global config, setting the timeout for
972
+ # # get_document to 20 seconds,
973
+ # # and all remaining timeouts to 10 seconds.
974
+ # ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.configure do |config|
975
+ # config.timeout = 10.0
976
+ # config.rpcs.get_document.timeout = 20.0
977
+ # end
978
+ #
979
+ # # Apply the above configuration only to a new client.
980
+ # client = ::Google::Cloud::DiscoveryEngine::V1::DocumentService::Client.new do |config|
981
+ # config.timeout = 10.0
982
+ # config.rpcs.get_document.timeout = 20.0
983
+ # end
984
+ #
985
+ # @!attribute [rw] endpoint
986
+ # The hostname or hostname:port of the service endpoint.
987
+ # Defaults to `"discoveryengine.googleapis.com"`.
988
+ # @return [::String]
989
+ # @!attribute [rw] credentials
990
+ # Credentials to send with calls. You may provide any of the following types:
991
+ # * (`String`) The path to a service account key file in JSON format
992
+ # * (`Hash`) A service account key as a Hash
993
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
994
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
995
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
996
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
997
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
998
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
999
+ # * (`nil`) indicating no credentials
1000
+ # @return [::Object]
1001
+ # @!attribute [rw] scope
1002
+ # The OAuth scopes
1003
+ # @return [::Array<::String>]
1004
+ # @!attribute [rw] lib_name
1005
+ # The library name as recorded in instrumentation and logging
1006
+ # @return [::String]
1007
+ # @!attribute [rw] lib_version
1008
+ # The library version as recorded in instrumentation and logging
1009
+ # @return [::String]
1010
+ # @!attribute [rw] channel_args
1011
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1012
+ # `GRPC::Core::Channel` object is provided as the credential.
1013
+ # @return [::Hash]
1014
+ # @!attribute [rw] interceptors
1015
+ # An array of interceptors that are run before calls are executed.
1016
+ # @return [::Array<::GRPC::ClientInterceptor>]
1017
+ # @!attribute [rw] timeout
1018
+ # The call timeout in seconds.
1019
+ # @return [::Numeric]
1020
+ # @!attribute [rw] metadata
1021
+ # Additional gRPC headers to be sent with the call.
1022
+ # @return [::Hash{::Symbol=>::String}]
1023
+ # @!attribute [rw] retry_policy
1024
+ # The retry policy. The value is a hash with the following keys:
1025
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1026
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1027
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1028
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1029
+ # trigger a retry.
1030
+ # @return [::Hash]
1031
+ # @!attribute [rw] quota_project
1032
+ # A separate project against which to charge quota.
1033
+ # @return [::String]
1034
+ #
1035
+ class Configuration
1036
+ extend ::Gapic::Config
1037
+
1038
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
1039
+
1040
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
1041
+ config_attr :credentials, nil do |value|
1042
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1043
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1044
+ allowed.any? { |klass| klass === value }
1045
+ end
1046
+ config_attr :scope, nil, ::String, ::Array, nil
1047
+ config_attr :lib_name, nil, ::String, nil
1048
+ config_attr :lib_version, nil, ::String, nil
1049
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1050
+ config_attr :interceptors, nil, ::Array, nil
1051
+ config_attr :timeout, nil, ::Numeric, nil
1052
+ config_attr :metadata, nil, ::Hash, nil
1053
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1054
+ config_attr :quota_project, nil, ::String, nil
1055
+
1056
+ # @private
1057
+ def initialize parent_config = nil
1058
+ @parent_config = parent_config unless parent_config.nil?
1059
+
1060
+ yield self if block_given?
1061
+ end
1062
+
1063
+ ##
1064
+ # Configurations for individual RPCs
1065
+ # @return [Rpcs]
1066
+ #
1067
+ def rpcs
1068
+ @rpcs ||= begin
1069
+ parent_rpcs = nil
1070
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1071
+ Rpcs.new parent_rpcs
1072
+ end
1073
+ end
1074
+
1075
+ ##
1076
+ # Configuration RPC class for the DocumentService API.
1077
+ #
1078
+ # Includes fields providing the configuration for each RPC in this service.
1079
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1080
+ # the following configuration fields:
1081
+ #
1082
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1083
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1084
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1085
+ # include the following keys:
1086
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1087
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1088
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1089
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1090
+ # trigger a retry.
1091
+ #
1092
+ class Rpcs
1093
+ ##
1094
+ # RPC-specific configuration for `get_document`
1095
+ # @return [::Gapic::Config::Method]
1096
+ #
1097
+ attr_reader :get_document
1098
+ ##
1099
+ # RPC-specific configuration for `list_documents`
1100
+ # @return [::Gapic::Config::Method]
1101
+ #
1102
+ attr_reader :list_documents
1103
+ ##
1104
+ # RPC-specific configuration for `create_document`
1105
+ # @return [::Gapic::Config::Method]
1106
+ #
1107
+ attr_reader :create_document
1108
+ ##
1109
+ # RPC-specific configuration for `update_document`
1110
+ # @return [::Gapic::Config::Method]
1111
+ #
1112
+ attr_reader :update_document
1113
+ ##
1114
+ # RPC-specific configuration for `delete_document`
1115
+ # @return [::Gapic::Config::Method]
1116
+ #
1117
+ attr_reader :delete_document
1118
+ ##
1119
+ # RPC-specific configuration for `import_documents`
1120
+ # @return [::Gapic::Config::Method]
1121
+ #
1122
+ attr_reader :import_documents
1123
+ ##
1124
+ # RPC-specific configuration for `purge_documents`
1125
+ # @return [::Gapic::Config::Method]
1126
+ #
1127
+ attr_reader :purge_documents
1128
+
1129
+ # @private
1130
+ def initialize parent_rpcs = nil
1131
+ get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
1132
+ @get_document = ::Gapic::Config::Method.new get_document_config
1133
+ list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
1134
+ @list_documents = ::Gapic::Config::Method.new list_documents_config
1135
+ create_document_config = parent_rpcs.create_document if parent_rpcs.respond_to? :create_document
1136
+ @create_document = ::Gapic::Config::Method.new create_document_config
1137
+ update_document_config = parent_rpcs.update_document if parent_rpcs.respond_to? :update_document
1138
+ @update_document = ::Gapic::Config::Method.new update_document_config
1139
+ delete_document_config = parent_rpcs.delete_document if parent_rpcs.respond_to? :delete_document
1140
+ @delete_document = ::Gapic::Config::Method.new delete_document_config
1141
+ import_documents_config = parent_rpcs.import_documents if parent_rpcs.respond_to? :import_documents
1142
+ @import_documents = ::Gapic::Config::Method.new import_documents_config
1143
+ purge_documents_config = parent_rpcs.purge_documents if parent_rpcs.respond_to? :purge_documents
1144
+ @purge_documents = ::Gapic::Config::Method.new purge_documents_config
1145
+
1146
+ yield self if block_given?
1147
+ end
1148
+ end
1149
+ end
1150
+ end
1151
+ end
1152
+ end
1153
+ end
1154
+ end
1155
+ end