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

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