google-cloud-discovery_engine-v1beta 0.a → 0.2.0

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