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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +1107 -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 +908 -0
  17. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/operations.rb +905 -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 +905 -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 +513 -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 +465 -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 +905 -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 +41 -0
  57. data/lib/google/cloud/discoveryengine/v1beta/completion_service_pb.rb +38 -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 +43 -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 +109 -0
  63. data/lib/google/cloud/discoveryengine/v1beta/purge_config_pb.rb +40 -0
  64. data/lib/google/cloud/discoveryengine/v1beta/recommendation_service_pb.rb +49 -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 +30 -0
  67. data/lib/google/cloud/discoveryengine/v1beta/schema_service_pb.rb +72 -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 +151 -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 +93 -0
  72. data/lib/google/cloud/discoveryengine/v1beta/user_event_service_pb.rb +39 -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 +286 -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 +605 -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 +141 -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 +129 -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,1107 @@
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)
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
+ #
721
+ # @yield [response, operation] Access the result along with the RPC operation
722
+ # @yieldparam response [::Gapic::Operation]
723
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
724
+ #
725
+ # @return [::Gapic::Operation]
726
+ #
727
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
728
+ #
729
+ # @example Basic example
730
+ # require "google/cloud/discovery_engine/v1beta"
731
+ #
732
+ # # Create a client object. The client can be reused for multiple calls.
733
+ # client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client.new
734
+ #
735
+ # # Create a request. To set request fields, pass in keyword arguments.
736
+ # request = Google::Cloud::DiscoveryEngine::V1beta::ImportDocumentsRequest.new
737
+ #
738
+ # # Call the import_documents method.
739
+ # result = client.import_documents request
740
+ #
741
+ # # The returned object is of type Gapic::Operation. You can use it to
742
+ # # check the status of an operation, cancel it, or wait for results.
743
+ # # Here is how to wait for a response.
744
+ # result.wait_until_done! timeout: 60
745
+ # if result.response?
746
+ # p result.response
747
+ # else
748
+ # puts "No response received."
749
+ # end
750
+ #
751
+ def import_documents request, options = nil
752
+ raise ::ArgumentError, "request must be provided" if request.nil?
753
+
754
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::ImportDocumentsRequest
755
+
756
+ # Converts hash and nil to an options object
757
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
758
+
759
+ # Customize the options with defaults
760
+ metadata = @config.rpcs.import_documents.metadata.to_h
761
+
762
+ # Set x-goog-api-client and x-goog-user-project headers
763
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
764
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
765
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
766
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
767
+
768
+ header_params = {}
769
+ if request.parent
770
+ header_params["parent"] = request.parent
771
+ end
772
+
773
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
774
+ metadata[:"x-goog-request-params"] ||= request_params_header
775
+
776
+ options.apply_defaults timeout: @config.rpcs.import_documents.timeout,
777
+ metadata: metadata,
778
+ retry_policy: @config.rpcs.import_documents.retry_policy
779
+
780
+ options.apply_defaults timeout: @config.timeout,
781
+ metadata: @config.metadata,
782
+ retry_policy: @config.retry_policy
783
+
784
+ @document_service_stub.call_rpc :import_documents, request, options: options do |response, operation|
785
+ response = ::Gapic::Operation.new response, @operations_client, options: options
786
+ yield response, operation if block_given?
787
+ return response
788
+ end
789
+ rescue ::GRPC::BadStatus => e
790
+ raise ::Google::Cloud::Error.from_error(e)
791
+ end
792
+
793
+ ##
794
+ # Permanently deletes all selected
795
+ # {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s in a branch.
796
+ #
797
+ # This process is asynchronous. Depending on the number of
798
+ # {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s to be deleted,
799
+ # this operation can take hours to complete. Before the delete operation
800
+ # completes, some {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s
801
+ # might still be returned by
802
+ # {::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client#get_document DocumentService.GetDocument}
803
+ # or
804
+ # {::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client#list_documents DocumentService.ListDocuments}.
805
+ #
806
+ # To get a list of the
807
+ # {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s to be deleted,
808
+ # set
809
+ # {::Google::Cloud::DiscoveryEngine::V1beta::PurgeDocumentsRequest#force PurgeDocumentsRequest.force}
810
+ # to false.
811
+ #
812
+ # @overload purge_documents(request, options = nil)
813
+ # Pass arguments to `purge_documents` via a request object, either of type
814
+ # {::Google::Cloud::DiscoveryEngine::V1beta::PurgeDocumentsRequest} or an equivalent Hash.
815
+ #
816
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::PurgeDocumentsRequest, ::Hash]
817
+ # A request object representing the call parameters. Required. To specify no
818
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
819
+ # @param options [::Gapic::CallOptions, ::Hash]
820
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
821
+ #
822
+ # @overload purge_documents(parent: nil, filter: nil, force: nil)
823
+ # Pass arguments to `purge_documents` via keyword arguments. Note that at
824
+ # least one keyword argument is required. To specify no parameters, or to keep all
825
+ # the default parameter values, pass an empty Hash as a request object (see above).
826
+ #
827
+ # @param parent [::String]
828
+ # Required. The parent resource name, such as
829
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
830
+ # @param filter [::String]
831
+ # Required. Filter matching documents to purge. Only currently supported
832
+ # value is
833
+ # `*` (all items).
834
+ # @param force [::Boolean]
835
+ # Actually performs the purge. If `force` is set to false, return the
836
+ # expected purge count without deleting any documents.
837
+ #
838
+ # @yield [response, operation] Access the result along with the RPC operation
839
+ # @yieldparam response [::Gapic::Operation]
840
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
841
+ #
842
+ # @return [::Gapic::Operation]
843
+ #
844
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
845
+ #
846
+ # @example Basic example
847
+ # require "google/cloud/discovery_engine/v1beta"
848
+ #
849
+ # # Create a client object. The client can be reused for multiple calls.
850
+ # client = Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client.new
851
+ #
852
+ # # Create a request. To set request fields, pass in keyword arguments.
853
+ # request = Google::Cloud::DiscoveryEngine::V1beta::PurgeDocumentsRequest.new
854
+ #
855
+ # # Call the purge_documents method.
856
+ # result = client.purge_documents request
857
+ #
858
+ # # The returned object is of type Gapic::Operation. You can use it to
859
+ # # check the status of an operation, cancel it, or wait for results.
860
+ # # Here is how to wait for a response.
861
+ # result.wait_until_done! timeout: 60
862
+ # if result.response?
863
+ # p result.response
864
+ # else
865
+ # puts "No response received."
866
+ # end
867
+ #
868
+ def purge_documents request, options = nil
869
+ raise ::ArgumentError, "request must be provided" if request.nil?
870
+
871
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::PurgeDocumentsRequest
872
+
873
+ # Converts hash and nil to an options object
874
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
875
+
876
+ # Customize the options with defaults
877
+ metadata = @config.rpcs.purge_documents.metadata.to_h
878
+
879
+ # Set x-goog-api-client and x-goog-user-project headers
880
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
881
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
882
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
883
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
884
+
885
+ header_params = {}
886
+ if request.parent
887
+ header_params["parent"] = request.parent
888
+ end
889
+
890
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
891
+ metadata[:"x-goog-request-params"] ||= request_params_header
892
+
893
+ options.apply_defaults timeout: @config.rpcs.purge_documents.timeout,
894
+ metadata: metadata,
895
+ retry_policy: @config.rpcs.purge_documents.retry_policy
896
+
897
+ options.apply_defaults timeout: @config.timeout,
898
+ metadata: @config.metadata,
899
+ retry_policy: @config.retry_policy
900
+
901
+ @document_service_stub.call_rpc :purge_documents, request, options: options do |response, operation|
902
+ response = ::Gapic::Operation.new response, @operations_client, options: options
903
+ yield response, operation if block_given?
904
+ return response
905
+ end
906
+ rescue ::GRPC::BadStatus => e
907
+ raise ::Google::Cloud::Error.from_error(e)
908
+ end
909
+
910
+ ##
911
+ # Configuration class for the DocumentService API.
912
+ #
913
+ # This class represents the configuration for DocumentService,
914
+ # providing control over timeouts, retry behavior, logging, transport
915
+ # parameters, and other low-level controls. Certain parameters can also be
916
+ # applied individually to specific RPCs. See
917
+ # {::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client::Configuration::Rpcs}
918
+ # for a list of RPCs that can be configured independently.
919
+ #
920
+ # Configuration can be applied globally to all clients, or to a single client
921
+ # on construction.
922
+ #
923
+ # @example
924
+ #
925
+ # # Modify the global config, setting the timeout for
926
+ # # get_document to 20 seconds,
927
+ # # and all remaining timeouts to 10 seconds.
928
+ # ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client.configure do |config|
929
+ # config.timeout = 10.0
930
+ # config.rpcs.get_document.timeout = 20.0
931
+ # end
932
+ #
933
+ # # Apply the above configuration only to a new client.
934
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::DocumentService::Client.new do |config|
935
+ # config.timeout = 10.0
936
+ # config.rpcs.get_document.timeout = 20.0
937
+ # end
938
+ #
939
+ # @!attribute [rw] endpoint
940
+ # The hostname or hostname:port of the service endpoint.
941
+ # Defaults to `"discoveryengine.googleapis.com"`.
942
+ # @return [::String]
943
+ # @!attribute [rw] credentials
944
+ # Credentials to send with calls. You may provide any of the following types:
945
+ # * (`String`) The path to a service account key file in JSON format
946
+ # * (`Hash`) A service account key as a Hash
947
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
948
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
949
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
950
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
951
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
952
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
953
+ # * (`nil`) indicating no credentials
954
+ # @return [::Object]
955
+ # @!attribute [rw] scope
956
+ # The OAuth scopes
957
+ # @return [::Array<::String>]
958
+ # @!attribute [rw] lib_name
959
+ # The library name as recorded in instrumentation and logging
960
+ # @return [::String]
961
+ # @!attribute [rw] lib_version
962
+ # The library version as recorded in instrumentation and logging
963
+ # @return [::String]
964
+ # @!attribute [rw] channel_args
965
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
966
+ # `GRPC::Core::Channel` object is provided as the credential.
967
+ # @return [::Hash]
968
+ # @!attribute [rw] interceptors
969
+ # An array of interceptors that are run before calls are executed.
970
+ # @return [::Array<::GRPC::ClientInterceptor>]
971
+ # @!attribute [rw] timeout
972
+ # The call timeout in seconds.
973
+ # @return [::Numeric]
974
+ # @!attribute [rw] metadata
975
+ # Additional gRPC headers to be sent with the call.
976
+ # @return [::Hash{::Symbol=>::String}]
977
+ # @!attribute [rw] retry_policy
978
+ # The retry policy. The value is a hash with the following keys:
979
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
980
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
981
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
982
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
983
+ # trigger a retry.
984
+ # @return [::Hash]
985
+ # @!attribute [rw] quota_project
986
+ # A separate project against which to charge quota.
987
+ # @return [::String]
988
+ #
989
+ class Configuration
990
+ extend ::Gapic::Config
991
+
992
+ config_attr :endpoint, "discoveryengine.googleapis.com", ::String
993
+ config_attr :credentials, nil do |value|
994
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
995
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
996
+ allowed.any? { |klass| klass === value }
997
+ end
998
+ config_attr :scope, nil, ::String, ::Array, nil
999
+ config_attr :lib_name, nil, ::String, nil
1000
+ config_attr :lib_version, nil, ::String, nil
1001
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1002
+ config_attr :interceptors, nil, ::Array, nil
1003
+ config_attr :timeout, nil, ::Numeric, nil
1004
+ config_attr :metadata, nil, ::Hash, nil
1005
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1006
+ config_attr :quota_project, nil, ::String, nil
1007
+
1008
+ # @private
1009
+ def initialize parent_config = nil
1010
+ @parent_config = parent_config unless parent_config.nil?
1011
+
1012
+ yield self if block_given?
1013
+ end
1014
+
1015
+ ##
1016
+ # Configurations for individual RPCs
1017
+ # @return [Rpcs]
1018
+ #
1019
+ def rpcs
1020
+ @rpcs ||= begin
1021
+ parent_rpcs = nil
1022
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1023
+ Rpcs.new parent_rpcs
1024
+ end
1025
+ end
1026
+
1027
+ ##
1028
+ # Configuration RPC class for the DocumentService API.
1029
+ #
1030
+ # Includes fields providing the configuration for each RPC in this service.
1031
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1032
+ # the following configuration fields:
1033
+ #
1034
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1035
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1036
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1037
+ # include the following keys:
1038
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1039
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1040
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1041
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1042
+ # trigger a retry.
1043
+ #
1044
+ class Rpcs
1045
+ ##
1046
+ # RPC-specific configuration for `get_document`
1047
+ # @return [::Gapic::Config::Method]
1048
+ #
1049
+ attr_reader :get_document
1050
+ ##
1051
+ # RPC-specific configuration for `list_documents`
1052
+ # @return [::Gapic::Config::Method]
1053
+ #
1054
+ attr_reader :list_documents
1055
+ ##
1056
+ # RPC-specific configuration for `create_document`
1057
+ # @return [::Gapic::Config::Method]
1058
+ #
1059
+ attr_reader :create_document
1060
+ ##
1061
+ # RPC-specific configuration for `update_document`
1062
+ # @return [::Gapic::Config::Method]
1063
+ #
1064
+ attr_reader :update_document
1065
+ ##
1066
+ # RPC-specific configuration for `delete_document`
1067
+ # @return [::Gapic::Config::Method]
1068
+ #
1069
+ attr_reader :delete_document
1070
+ ##
1071
+ # RPC-specific configuration for `import_documents`
1072
+ # @return [::Gapic::Config::Method]
1073
+ #
1074
+ attr_reader :import_documents
1075
+ ##
1076
+ # RPC-specific configuration for `purge_documents`
1077
+ # @return [::Gapic::Config::Method]
1078
+ #
1079
+ attr_reader :purge_documents
1080
+
1081
+ # @private
1082
+ def initialize parent_rpcs = nil
1083
+ get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
1084
+ @get_document = ::Gapic::Config::Method.new get_document_config
1085
+ list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
1086
+ @list_documents = ::Gapic::Config::Method.new list_documents_config
1087
+ create_document_config = parent_rpcs.create_document if parent_rpcs.respond_to? :create_document
1088
+ @create_document = ::Gapic::Config::Method.new create_document_config
1089
+ update_document_config = parent_rpcs.update_document if parent_rpcs.respond_to? :update_document
1090
+ @update_document = ::Gapic::Config::Method.new update_document_config
1091
+ delete_document_config = parent_rpcs.delete_document if parent_rpcs.respond_to? :delete_document
1092
+ @delete_document = ::Gapic::Config::Method.new delete_document_config
1093
+ import_documents_config = parent_rpcs.import_documents if parent_rpcs.respond_to? :import_documents
1094
+ @import_documents = ::Gapic::Config::Method.new import_documents_config
1095
+ purge_documents_config = parent_rpcs.purge_documents if parent_rpcs.respond_to? :purge_documents
1096
+ @purge_documents = ::Gapic::Config::Method.new purge_documents_config
1097
+
1098
+ yield self if block_given?
1099
+ end
1100
+ end
1101
+ end
1102
+ end
1103
+ end
1104
+ end
1105
+ end
1106
+ end
1107
+ end