google-cloud-document_ai-v1beta3 0.23.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb +57 -40
  3. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/rest/client.rb +57 -40
  4. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/rest.rb +1 -1
  5. data/lib/google/cloud/document_ai/v1beta3/document_processor_service.rb +1 -1
  6. data/lib/google/cloud/document_ai/v1beta3/document_service/client.rb +932 -0
  7. data/lib/google/cloud/document_ai/v1beta3/document_service/credentials.rb +51 -0
  8. data/lib/google/cloud/document_ai/v1beta3/document_service/operations.rb +770 -0
  9. data/lib/google/cloud/document_ai/v1beta3/document_service/paths.rb +90 -0
  10. data/lib/google/cloud/document_ai/v1beta3/document_service/rest/client.rb +761 -0
  11. data/lib/google/cloud/document_ai/v1beta3/document_service/rest/operations.rb +815 -0
  12. data/lib/google/cloud/document_ai/v1beta3/document_service/rest/service_stub.rb +406 -0
  13. data/lib/google/cloud/document_ai/v1beta3/document_service/rest.rb +54 -0
  14. data/lib/google/cloud/document_ai/v1beta3/document_service.rb +56 -0
  15. data/lib/google/cloud/document_ai/v1beta3/rest.rb +1 -0
  16. data/lib/google/cloud/document_ai/v1beta3/version.rb +1 -1
  17. data/lib/google/cloud/document_ai/v1beta3.rb +1 -0
  18. data/lib/google/cloud/documentai/v1beta3/dataset_pb.rb +62 -0
  19. data/lib/google/cloud/documentai/v1beta3/document_io_pb.rb +1 -1
  20. data/lib/google/cloud/documentai/v1beta3/document_pb.rb +4 -1
  21. data/lib/google/cloud/documentai/v1beta3/document_processor_service_pb.rb +4 -1
  22. data/lib/google/cloud/documentai/v1beta3/document_processor_service_services_pb.rb +8 -6
  23. data/lib/google/cloud/documentai/v1beta3/document_schema_pb.rb +3 -1
  24. data/lib/google/cloud/documentai/v1beta3/document_service_pb.rb +78 -0
  25. data/lib/google/cloud/documentai/v1beta3/document_service_services_pb.rb +55 -0
  26. data/lib/google/cloud/documentai/v1beta3/processor_pb.rb +1 -1
  27. data/proto_docs/google/cloud/documentai/v1beta3/dataset.rb +187 -0
  28. data/proto_docs/google/cloud/documentai/v1beta3/document.rb +120 -27
  29. data/proto_docs/google/cloud/documentai/v1beta3/document_io.rb +10 -1
  30. data/proto_docs/google/cloud/documentai/v1beta3/document_processor_service.rb +261 -123
  31. data/proto_docs/google/cloud/documentai/v1beta3/document_schema.rb +44 -13
  32. data/proto_docs/google/cloud/documentai/v1beta3/document_service.rb +275 -0
  33. data/proto_docs/google/cloud/documentai/v1beta3/processor.rb +12 -10
  34. data/proto_docs/google/cloud/documentai/v1beta3/processor_type.rb +3 -2
  35. metadata +16 -2
@@ -0,0 +1,932 @@
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/documentai/v1beta3/document_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module DocumentAI
26
+ module V1beta3
27
+ module DocumentService
28
+ ##
29
+ # Client for the DocumentService service.
30
+ #
31
+ # Service to call Cloud DocumentAI to manage document collection (dataset).
32
+ #
33
+ class Client
34
+ include Paths
35
+
36
+ # @private
37
+ attr_reader :document_service_stub
38
+
39
+ ##
40
+ # Configure the DocumentService Client class.
41
+ #
42
+ # See {::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # @example
46
+ #
47
+ # # Modify the configuration for all DocumentService clients
48
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "DocumentAI", "V1beta3"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config
69
+ end
70
+ yield @configure if block_given?
71
+ @configure
72
+ end
73
+
74
+ ##
75
+ # Configure the DocumentService Client instance.
76
+ #
77
+ # The configuration is set to the derived mode, meaning that values can be changed,
78
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
79
+ # should be made on {Client.configure}.
80
+ #
81
+ # See {::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client::Configuration}
82
+ # for a description of the configuration fields.
83
+ #
84
+ # @yield [config] Configure the Client client.
85
+ # @yieldparam config [Client::Configuration]
86
+ #
87
+ # @return [Client::Configuration]
88
+ #
89
+ def configure
90
+ yield @config if block_given?
91
+ @config
92
+ end
93
+
94
+ ##
95
+ # Create a new DocumentService client object.
96
+ #
97
+ # @example
98
+ #
99
+ # # Create a client using the default configuration
100
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
101
+ #
102
+ # # Create a client using a custom configuration
103
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new do |config|
104
+ # config.timeout = 10.0
105
+ # end
106
+ #
107
+ # @yield [config] Configure the DocumentService client.
108
+ # @yieldparam config [Client::Configuration]
109
+ #
110
+ def initialize
111
+ # These require statements are intentionally placed here to initialize
112
+ # the gRPC module only when it's required.
113
+ # See https://github.com/googleapis/toolkit/issues/446
114
+ require "gapic/grpc"
115
+ require "google/cloud/documentai/v1beta3/document_service_services_pb"
116
+
117
+ # Create the configuration object
118
+ @config = Configuration.new Client.configure
119
+
120
+ # Yield the configuration if needed
121
+ yield @config if block_given?
122
+
123
+ # Create credentials
124
+ credentials = @config.credentials
125
+ # Use self-signed JWT if the endpoint is unchanged from default,
126
+ # but only if the default endpoint does not have a region prefix.
127
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
128
+ !@config.endpoint.split(".").first.include?("-")
129
+ credentials ||= Credentials.default scope: @config.scope,
130
+ enable_self_signed_jwt: enable_self_signed_jwt
131
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
132
+ credentials = Credentials.new credentials, scope: @config.scope
133
+ end
134
+ @quota_project_id = @config.quota_project
135
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
136
+
137
+ @operations_client = Operations.new do |config|
138
+ config.credentials = credentials
139
+ config.quota_project = @quota_project_id
140
+ config.endpoint = @config.endpoint
141
+ end
142
+
143
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
144
+ config.credentials = credentials
145
+ config.quota_project = @quota_project_id
146
+ config.endpoint = @config.endpoint
147
+ end
148
+
149
+ @document_service_stub = ::Gapic::ServiceStub.new(
150
+ ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Stub,
151
+ credentials: credentials,
152
+ endpoint: @config.endpoint,
153
+ channel_args: @config.channel_args,
154
+ interceptors: @config.interceptors
155
+ )
156
+ end
157
+
158
+ ##
159
+ # Get the associated client for long-running operations.
160
+ #
161
+ # @return [::Google::Cloud::DocumentAI::V1beta3::DocumentService::Operations]
162
+ #
163
+ attr_reader :operations_client
164
+
165
+ ##
166
+ # Get the associated client for mix-in of the Locations.
167
+ #
168
+ # @return [Google::Cloud::Location::Locations::Client]
169
+ #
170
+ attr_reader :location_client
171
+
172
+ # Service calls
173
+
174
+ ##
175
+ # Updates metadata associated with a dataset.
176
+ #
177
+ # @overload update_dataset(request, options = nil)
178
+ # Pass arguments to `update_dataset` via a request object, either of type
179
+ # {::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetRequest} or an equivalent Hash.
180
+ #
181
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetRequest, ::Hash]
182
+ # A request object representing the call parameters. Required. To specify no
183
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
184
+ # @param options [::Gapic::CallOptions, ::Hash]
185
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
186
+ #
187
+ # @overload update_dataset(dataset: nil, update_mask: nil)
188
+ # Pass arguments to `update_dataset` via keyword arguments. Note that at
189
+ # least one keyword argument is required. To specify no parameters, or to keep all
190
+ # the default parameter values, pass an empty Hash as a request object (see above).
191
+ #
192
+ # @param dataset [::Google::Cloud::DocumentAI::V1beta3::Dataset, ::Hash]
193
+ # Required. The `name` field of the `Dataset` is used to identify the
194
+ # resource to be updated.
195
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
196
+ # The update mask applies to the resource.
197
+ #
198
+ # @yield [response, operation] Access the result along with the RPC operation
199
+ # @yieldparam response [::Gapic::Operation]
200
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
201
+ #
202
+ # @return [::Gapic::Operation]
203
+ #
204
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
205
+ #
206
+ # @example Basic example
207
+ # require "google/cloud/document_ai/v1beta3"
208
+ #
209
+ # # Create a client object. The client can be reused for multiple calls.
210
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
211
+ #
212
+ # # Create a request. To set request fields, pass in keyword arguments.
213
+ # request = Google::Cloud::DocumentAI::V1beta3::UpdateDatasetRequest.new
214
+ #
215
+ # # Call the update_dataset method.
216
+ # result = client.update_dataset request
217
+ #
218
+ # # The returned object is of type Gapic::Operation. You can use it to
219
+ # # check the status of an operation, cancel it, or wait for results.
220
+ # # Here is how to wait for a response.
221
+ # result.wait_until_done! timeout: 60
222
+ # if result.response?
223
+ # p result.response
224
+ # else
225
+ # puts "No response received."
226
+ # end
227
+ #
228
+ def update_dataset request, options = nil
229
+ raise ::ArgumentError, "request must be provided" if request.nil?
230
+
231
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetRequest
232
+
233
+ # Converts hash and nil to an options object
234
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
235
+
236
+ # Customize the options with defaults
237
+ metadata = @config.rpcs.update_dataset.metadata.to_h
238
+
239
+ # Set x-goog-api-client and x-goog-user-project headers
240
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
241
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
242
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
243
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
244
+
245
+ header_params = {}
246
+ if request.dataset&.name
247
+ header_params["dataset.name"] = request.dataset.name
248
+ end
249
+
250
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
+ metadata[:"x-goog-request-params"] ||= request_params_header
252
+
253
+ options.apply_defaults timeout: @config.rpcs.update_dataset.timeout,
254
+ metadata: metadata,
255
+ retry_policy: @config.rpcs.update_dataset.retry_policy
256
+
257
+ options.apply_defaults timeout: @config.timeout,
258
+ metadata: @config.metadata,
259
+ retry_policy: @config.retry_policy
260
+
261
+ @document_service_stub.call_rpc :update_dataset, request, options: options do |response, operation|
262
+ response = ::Gapic::Operation.new response, @operations_client, options: options
263
+ yield response, operation if block_given?
264
+ return response
265
+ end
266
+ rescue ::GRPC::BadStatus => e
267
+ raise ::Google::Cloud::Error.from_error(e)
268
+ end
269
+
270
+ ##
271
+ # Import documents into a dataset.
272
+ #
273
+ # @overload import_documents(request, options = nil)
274
+ # Pass arguments to `import_documents` via a request object, either of type
275
+ # {::Google::Cloud::DocumentAI::V1beta3::ImportDocumentsRequest} or an equivalent Hash.
276
+ #
277
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::ImportDocumentsRequest, ::Hash]
278
+ # A request object representing the call parameters. Required. To specify no
279
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
280
+ # @param options [::Gapic::CallOptions, ::Hash]
281
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
282
+ #
283
+ # @overload import_documents(dataset: nil, batch_documents_import_configs: nil)
284
+ # Pass arguments to `import_documents` via keyword arguments. Note that at
285
+ # least one keyword argument is required. To specify no parameters, or to keep all
286
+ # the default parameter values, pass an empty Hash as a request object (see above).
287
+ #
288
+ # @param dataset [::String]
289
+ # Required. The dataset resource name.
290
+ # Format:
291
+ # projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset
292
+ # @param batch_documents_import_configs [::Array<::Google::Cloud::DocumentAI::V1beta3::ImportDocumentsRequest::BatchDocumentsImportConfig, ::Hash>]
293
+ # Required. The Cloud Storage uri containing raw documents that must be
294
+ # imported.
295
+ #
296
+ # @yield [response, operation] Access the result along with the RPC operation
297
+ # @yieldparam response [::Gapic::Operation]
298
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
299
+ #
300
+ # @return [::Gapic::Operation]
301
+ #
302
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
303
+ #
304
+ # @example Basic example
305
+ # require "google/cloud/document_ai/v1beta3"
306
+ #
307
+ # # Create a client object. The client can be reused for multiple calls.
308
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
309
+ #
310
+ # # Create a request. To set request fields, pass in keyword arguments.
311
+ # request = Google::Cloud::DocumentAI::V1beta3::ImportDocumentsRequest.new
312
+ #
313
+ # # Call the import_documents method.
314
+ # result = client.import_documents request
315
+ #
316
+ # # The returned object is of type Gapic::Operation. You can use it to
317
+ # # check the status of an operation, cancel it, or wait for results.
318
+ # # Here is how to wait for a response.
319
+ # result.wait_until_done! timeout: 60
320
+ # if result.response?
321
+ # p result.response
322
+ # else
323
+ # puts "No response received."
324
+ # end
325
+ #
326
+ def import_documents request, options = nil
327
+ raise ::ArgumentError, "request must be provided" if request.nil?
328
+
329
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ImportDocumentsRequest
330
+
331
+ # Converts hash and nil to an options object
332
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
333
+
334
+ # Customize the options with defaults
335
+ metadata = @config.rpcs.import_documents.metadata.to_h
336
+
337
+ # Set x-goog-api-client and x-goog-user-project headers
338
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
339
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
340
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
341
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
342
+
343
+ header_params = {}
344
+ if request.dataset
345
+ header_params["dataset"] = request.dataset
346
+ end
347
+
348
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
349
+ metadata[:"x-goog-request-params"] ||= request_params_header
350
+
351
+ options.apply_defaults timeout: @config.rpcs.import_documents.timeout,
352
+ metadata: metadata,
353
+ retry_policy: @config.rpcs.import_documents.retry_policy
354
+
355
+ options.apply_defaults timeout: @config.timeout,
356
+ metadata: @config.metadata,
357
+ retry_policy: @config.retry_policy
358
+
359
+ @document_service_stub.call_rpc :import_documents, request, options: options do |response, operation|
360
+ response = ::Gapic::Operation.new response, @operations_client, options: options
361
+ yield response, operation if block_given?
362
+ return response
363
+ end
364
+ rescue ::GRPC::BadStatus => e
365
+ raise ::Google::Cloud::Error.from_error(e)
366
+ end
367
+
368
+ ##
369
+ # Returns relevant fields present in the requested document.
370
+ #
371
+ # @overload get_document(request, options = nil)
372
+ # Pass arguments to `get_document` via a request object, either of type
373
+ # {::Google::Cloud::DocumentAI::V1beta3::GetDocumentRequest} or an equivalent Hash.
374
+ #
375
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::GetDocumentRequest, ::Hash]
376
+ # A request object representing the call parameters. Required. To specify no
377
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
378
+ # @param options [::Gapic::CallOptions, ::Hash]
379
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
380
+ #
381
+ # @overload get_document(dataset: nil, document_id: nil, read_mask: nil, page_range: nil)
382
+ # Pass arguments to `get_document` via keyword arguments. Note that at
383
+ # least one keyword argument is required. To specify no parameters, or to keep all
384
+ # the default parameter values, pass an empty Hash as a request object (see above).
385
+ #
386
+ # @param dataset [::String]
387
+ # Required. The resource name of the dataset that the document belongs to .
388
+ # Format:
389
+ # projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset
390
+ # @param document_id [::Google::Cloud::DocumentAI::V1beta3::DocumentId, ::Hash]
391
+ # Required. Document identifier.
392
+ # @param read_mask [::Google::Protobuf::FieldMask, ::Hash]
393
+ # If set, only fields listed here will be returned. Otherwise, all fields
394
+ # will be returned by default.
395
+ # @param page_range [::Google::Cloud::DocumentAI::V1beta3::DocumentPageRange, ::Hash]
396
+ # List of pages for which the fields specified in the `read_mask` must
397
+ # be served.
398
+ #
399
+ # @yield [response, operation] Access the result along with the RPC operation
400
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::GetDocumentResponse]
401
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
402
+ #
403
+ # @return [::Google::Cloud::DocumentAI::V1beta3::GetDocumentResponse]
404
+ #
405
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
406
+ #
407
+ # @example Basic example
408
+ # require "google/cloud/document_ai/v1beta3"
409
+ #
410
+ # # Create a client object. The client can be reused for multiple calls.
411
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
412
+ #
413
+ # # Create a request. To set request fields, pass in keyword arguments.
414
+ # request = Google::Cloud::DocumentAI::V1beta3::GetDocumentRequest.new
415
+ #
416
+ # # Call the get_document method.
417
+ # result = client.get_document request
418
+ #
419
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::GetDocumentResponse.
420
+ # p result
421
+ #
422
+ def get_document request, options = nil
423
+ raise ::ArgumentError, "request must be provided" if request.nil?
424
+
425
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::GetDocumentRequest
426
+
427
+ # Converts hash and nil to an options object
428
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
429
+
430
+ # Customize the options with defaults
431
+ metadata = @config.rpcs.get_document.metadata.to_h
432
+
433
+ # Set x-goog-api-client and x-goog-user-project headers
434
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
435
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
436
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
437
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
438
+
439
+ header_params = {}
440
+ if request.dataset
441
+ header_params["dataset"] = request.dataset
442
+ end
443
+
444
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
445
+ metadata[:"x-goog-request-params"] ||= request_params_header
446
+
447
+ options.apply_defaults timeout: @config.rpcs.get_document.timeout,
448
+ metadata: metadata,
449
+ retry_policy: @config.rpcs.get_document.retry_policy
450
+
451
+ options.apply_defaults timeout: @config.timeout,
452
+ metadata: @config.metadata,
453
+ retry_policy: @config.retry_policy
454
+
455
+ @document_service_stub.call_rpc :get_document, request, options: options do |response, operation|
456
+ yield response, operation if block_given?
457
+ return response
458
+ end
459
+ rescue ::GRPC::BadStatus => e
460
+ raise ::Google::Cloud::Error.from_error(e)
461
+ end
462
+
463
+ ##
464
+ # Deletes a set of documents.
465
+ #
466
+ # @overload batch_delete_documents(request, options = nil)
467
+ # Pass arguments to `batch_delete_documents` via a request object, either of type
468
+ # {::Google::Cloud::DocumentAI::V1beta3::BatchDeleteDocumentsRequest} or an equivalent Hash.
469
+ #
470
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::BatchDeleteDocumentsRequest, ::Hash]
471
+ # A request object representing the call parameters. Required. To specify no
472
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
473
+ # @param options [::Gapic::CallOptions, ::Hash]
474
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
475
+ #
476
+ # @overload batch_delete_documents(dataset: nil, dataset_documents: nil)
477
+ # Pass arguments to `batch_delete_documents` via keyword arguments. Note that at
478
+ # least one keyword argument is required. To specify no parameters, or to keep all
479
+ # the default parameter values, pass an empty Hash as a request object (see above).
480
+ #
481
+ # @param dataset [::String]
482
+ # Required. The dataset resource name.
483
+ # Format:
484
+ # projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset
485
+ # @param dataset_documents [::Google::Cloud::DocumentAI::V1beta3::BatchDatasetDocuments, ::Hash]
486
+ # Required. Dataset documents input. If given `filter`, all documents
487
+ # satisfying the filter will be deleted. If given documentIds, a maximum of
488
+ # 50 documents can be deleted in a batch. The request will be rejected if
489
+ # more than 50 document_ids are provided.
490
+ #
491
+ # @yield [response, operation] Access the result along with the RPC operation
492
+ # @yieldparam response [::Gapic::Operation]
493
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
494
+ #
495
+ # @return [::Gapic::Operation]
496
+ #
497
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
498
+ #
499
+ # @example Basic example
500
+ # require "google/cloud/document_ai/v1beta3"
501
+ #
502
+ # # Create a client object. The client can be reused for multiple calls.
503
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
504
+ #
505
+ # # Create a request. To set request fields, pass in keyword arguments.
506
+ # request = Google::Cloud::DocumentAI::V1beta3::BatchDeleteDocumentsRequest.new
507
+ #
508
+ # # Call the batch_delete_documents method.
509
+ # result = client.batch_delete_documents request
510
+ #
511
+ # # The returned object is of type Gapic::Operation. You can use it to
512
+ # # check the status of an operation, cancel it, or wait for results.
513
+ # # Here is how to wait for a response.
514
+ # result.wait_until_done! timeout: 60
515
+ # if result.response?
516
+ # p result.response
517
+ # else
518
+ # puts "No response received."
519
+ # end
520
+ #
521
+ def batch_delete_documents request, options = nil
522
+ raise ::ArgumentError, "request must be provided" if request.nil?
523
+
524
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::BatchDeleteDocumentsRequest
525
+
526
+ # Converts hash and nil to an options object
527
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
528
+
529
+ # Customize the options with defaults
530
+ metadata = @config.rpcs.batch_delete_documents.metadata.to_h
531
+
532
+ # Set x-goog-api-client and x-goog-user-project headers
533
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
534
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
535
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
536
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
537
+
538
+ header_params = {}
539
+ if request.dataset
540
+ header_params["dataset"] = request.dataset
541
+ end
542
+
543
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
544
+ metadata[:"x-goog-request-params"] ||= request_params_header
545
+
546
+ options.apply_defaults timeout: @config.rpcs.batch_delete_documents.timeout,
547
+ metadata: metadata,
548
+ retry_policy: @config.rpcs.batch_delete_documents.retry_policy
549
+
550
+ options.apply_defaults timeout: @config.timeout,
551
+ metadata: @config.metadata,
552
+ retry_policy: @config.retry_policy
553
+
554
+ @document_service_stub.call_rpc :batch_delete_documents, request, options: options do |response, operation|
555
+ response = ::Gapic::Operation.new response, @operations_client, options: options
556
+ yield response, operation if block_given?
557
+ return response
558
+ end
559
+ rescue ::GRPC::BadStatus => e
560
+ raise ::Google::Cloud::Error.from_error(e)
561
+ end
562
+
563
+ ##
564
+ # Gets the `DatasetSchema` of a `Dataset`.
565
+ #
566
+ # @overload get_dataset_schema(request, options = nil)
567
+ # Pass arguments to `get_dataset_schema` via a request object, either of type
568
+ # {::Google::Cloud::DocumentAI::V1beta3::GetDatasetSchemaRequest} or an equivalent Hash.
569
+ #
570
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::GetDatasetSchemaRequest, ::Hash]
571
+ # A request object representing the call parameters. Required. To specify no
572
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
573
+ # @param options [::Gapic::CallOptions, ::Hash]
574
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
575
+ #
576
+ # @overload get_dataset_schema(name: nil, visible_fields_only: nil)
577
+ # Pass arguments to `get_dataset_schema` via keyword arguments. Note that at
578
+ # least one keyword argument is required. To specify no parameters, or to keep all
579
+ # the default parameter values, pass an empty Hash as a request object (see above).
580
+ #
581
+ # @param name [::String]
582
+ # Required. The dataset schema resource name.
583
+ # Format:
584
+ # projects/\\{project}/locations/\\{location}/processors/\\{processor}/dataset/datasetSchema
585
+ # @param visible_fields_only [::Boolean]
586
+ # If set, only returns the visible fields of the schema.
587
+ #
588
+ # @yield [response, operation] Access the result along with the RPC operation
589
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::DatasetSchema]
590
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
591
+ #
592
+ # @return [::Google::Cloud::DocumentAI::V1beta3::DatasetSchema]
593
+ #
594
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
595
+ #
596
+ # @example Basic example
597
+ # require "google/cloud/document_ai/v1beta3"
598
+ #
599
+ # # Create a client object. The client can be reused for multiple calls.
600
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
601
+ #
602
+ # # Create a request. To set request fields, pass in keyword arguments.
603
+ # request = Google::Cloud::DocumentAI::V1beta3::GetDatasetSchemaRequest.new
604
+ #
605
+ # # Call the get_dataset_schema method.
606
+ # result = client.get_dataset_schema request
607
+ #
608
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::DatasetSchema.
609
+ # p result
610
+ #
611
+ def get_dataset_schema request, options = nil
612
+ raise ::ArgumentError, "request must be provided" if request.nil?
613
+
614
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::GetDatasetSchemaRequest
615
+
616
+ # Converts hash and nil to an options object
617
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
618
+
619
+ # Customize the options with defaults
620
+ metadata = @config.rpcs.get_dataset_schema.metadata.to_h
621
+
622
+ # Set x-goog-api-client and x-goog-user-project headers
623
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
624
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
625
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
626
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
627
+
628
+ header_params = {}
629
+ if request.name
630
+ header_params["name"] = request.name
631
+ end
632
+
633
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
634
+ metadata[:"x-goog-request-params"] ||= request_params_header
635
+
636
+ options.apply_defaults timeout: @config.rpcs.get_dataset_schema.timeout,
637
+ metadata: metadata,
638
+ retry_policy: @config.rpcs.get_dataset_schema.retry_policy
639
+
640
+ options.apply_defaults timeout: @config.timeout,
641
+ metadata: @config.metadata,
642
+ retry_policy: @config.retry_policy
643
+
644
+ @document_service_stub.call_rpc :get_dataset_schema, request, options: options do |response, operation|
645
+ yield response, operation if block_given?
646
+ return response
647
+ end
648
+ rescue ::GRPC::BadStatus => e
649
+ raise ::Google::Cloud::Error.from_error(e)
650
+ end
651
+
652
+ ##
653
+ # Updates a `DatasetSchema`.
654
+ #
655
+ # @overload update_dataset_schema(request, options = nil)
656
+ # Pass arguments to `update_dataset_schema` via a request object, either of type
657
+ # {::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetSchemaRequest} or an equivalent Hash.
658
+ #
659
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetSchemaRequest, ::Hash]
660
+ # A request object representing the call parameters. Required. To specify no
661
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
662
+ # @param options [::Gapic::CallOptions, ::Hash]
663
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
664
+ #
665
+ # @overload update_dataset_schema(dataset_schema: nil, update_mask: nil)
666
+ # Pass arguments to `update_dataset_schema` via keyword arguments. Note that at
667
+ # least one keyword argument is required. To specify no parameters, or to keep all
668
+ # the default parameter values, pass an empty Hash as a request object (see above).
669
+ #
670
+ # @param dataset_schema [::Google::Cloud::DocumentAI::V1beta3::DatasetSchema, ::Hash]
671
+ # Required. The name field of the `DatasetSchema` is used to identify the
672
+ # resource to be updated.
673
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
674
+ # The update mask applies to the resource.
675
+ #
676
+ # @yield [response, operation] Access the result along with the RPC operation
677
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::DatasetSchema]
678
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
679
+ #
680
+ # @return [::Google::Cloud::DocumentAI::V1beta3::DatasetSchema]
681
+ #
682
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
683
+ #
684
+ # @example Basic example
685
+ # require "google/cloud/document_ai/v1beta3"
686
+ #
687
+ # # Create a client object. The client can be reused for multiple calls.
688
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new
689
+ #
690
+ # # Create a request. To set request fields, pass in keyword arguments.
691
+ # request = Google::Cloud::DocumentAI::V1beta3::UpdateDatasetSchemaRequest.new
692
+ #
693
+ # # Call the update_dataset_schema method.
694
+ # result = client.update_dataset_schema request
695
+ #
696
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::DatasetSchema.
697
+ # p result
698
+ #
699
+ def update_dataset_schema request, options = nil
700
+ raise ::ArgumentError, "request must be provided" if request.nil?
701
+
702
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::UpdateDatasetSchemaRequest
703
+
704
+ # Converts hash and nil to an options object
705
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
706
+
707
+ # Customize the options with defaults
708
+ metadata = @config.rpcs.update_dataset_schema.metadata.to_h
709
+
710
+ # Set x-goog-api-client and x-goog-user-project headers
711
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
712
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
713
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
714
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
715
+
716
+ header_params = {}
717
+ if request.dataset_schema&.name
718
+ header_params["dataset_schema.name"] = request.dataset_schema.name
719
+ end
720
+
721
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
722
+ metadata[:"x-goog-request-params"] ||= request_params_header
723
+
724
+ options.apply_defaults timeout: @config.rpcs.update_dataset_schema.timeout,
725
+ metadata: metadata,
726
+ retry_policy: @config.rpcs.update_dataset_schema.retry_policy
727
+
728
+ options.apply_defaults timeout: @config.timeout,
729
+ metadata: @config.metadata,
730
+ retry_policy: @config.retry_policy
731
+
732
+ @document_service_stub.call_rpc :update_dataset_schema, request, options: options do |response, operation|
733
+ yield response, operation if block_given?
734
+ return response
735
+ end
736
+ rescue ::GRPC::BadStatus => e
737
+ raise ::Google::Cloud::Error.from_error(e)
738
+ end
739
+
740
+ ##
741
+ # Configuration class for the DocumentService API.
742
+ #
743
+ # This class represents the configuration for DocumentService,
744
+ # providing control over timeouts, retry behavior, logging, transport
745
+ # parameters, and other low-level controls. Certain parameters can also be
746
+ # applied individually to specific RPCs. See
747
+ # {::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client::Configuration::Rpcs}
748
+ # for a list of RPCs that can be configured independently.
749
+ #
750
+ # Configuration can be applied globally to all clients, or to a single client
751
+ # on construction.
752
+ #
753
+ # @example
754
+ #
755
+ # # Modify the global config, setting the timeout for
756
+ # # update_dataset to 20 seconds,
757
+ # # and all remaining timeouts to 10 seconds.
758
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.configure do |config|
759
+ # config.timeout = 10.0
760
+ # config.rpcs.update_dataset.timeout = 20.0
761
+ # end
762
+ #
763
+ # # Apply the above configuration only to a new client.
764
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentService::Client.new do |config|
765
+ # config.timeout = 10.0
766
+ # config.rpcs.update_dataset.timeout = 20.0
767
+ # end
768
+ #
769
+ # @!attribute [rw] endpoint
770
+ # The hostname or hostname:port of the service endpoint.
771
+ # Defaults to `"documentai.googleapis.com"`.
772
+ # @return [::String]
773
+ # @!attribute [rw] credentials
774
+ # Credentials to send with calls. You may provide any of the following types:
775
+ # * (`String`) The path to a service account key file in JSON format
776
+ # * (`Hash`) A service account key as a Hash
777
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
778
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
779
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
780
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
781
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
782
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
783
+ # * (`nil`) indicating no credentials
784
+ # @return [::Object]
785
+ # @!attribute [rw] scope
786
+ # The OAuth scopes
787
+ # @return [::Array<::String>]
788
+ # @!attribute [rw] lib_name
789
+ # The library name as recorded in instrumentation and logging
790
+ # @return [::String]
791
+ # @!attribute [rw] lib_version
792
+ # The library version as recorded in instrumentation and logging
793
+ # @return [::String]
794
+ # @!attribute [rw] channel_args
795
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
796
+ # `GRPC::Core::Channel` object is provided as the credential.
797
+ # @return [::Hash]
798
+ # @!attribute [rw] interceptors
799
+ # An array of interceptors that are run before calls are executed.
800
+ # @return [::Array<::GRPC::ClientInterceptor>]
801
+ # @!attribute [rw] timeout
802
+ # The call timeout in seconds.
803
+ # @return [::Numeric]
804
+ # @!attribute [rw] metadata
805
+ # Additional gRPC headers to be sent with the call.
806
+ # @return [::Hash{::Symbol=>::String}]
807
+ # @!attribute [rw] retry_policy
808
+ # The retry policy. The value is a hash with the following keys:
809
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
810
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
811
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
812
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
813
+ # trigger a retry.
814
+ # @return [::Hash]
815
+ # @!attribute [rw] quota_project
816
+ # A separate project against which to charge quota.
817
+ # @return [::String]
818
+ #
819
+ class Configuration
820
+ extend ::Gapic::Config
821
+
822
+ DEFAULT_ENDPOINT = "documentai.googleapis.com"
823
+
824
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
825
+ config_attr :credentials, nil do |value|
826
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
827
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
828
+ allowed.any? { |klass| klass === value }
829
+ end
830
+ config_attr :scope, nil, ::String, ::Array, nil
831
+ config_attr :lib_name, nil, ::String, nil
832
+ config_attr :lib_version, nil, ::String, nil
833
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
834
+ config_attr :interceptors, nil, ::Array, nil
835
+ config_attr :timeout, nil, ::Numeric, nil
836
+ config_attr :metadata, nil, ::Hash, nil
837
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
838
+ config_attr :quota_project, nil, ::String, nil
839
+
840
+ # @private
841
+ def initialize parent_config = nil
842
+ @parent_config = parent_config unless parent_config.nil?
843
+
844
+ yield self if block_given?
845
+ end
846
+
847
+ ##
848
+ # Configurations for individual RPCs
849
+ # @return [Rpcs]
850
+ #
851
+ def rpcs
852
+ @rpcs ||= begin
853
+ parent_rpcs = nil
854
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
855
+ Rpcs.new parent_rpcs
856
+ end
857
+ end
858
+
859
+ ##
860
+ # Configuration RPC class for the DocumentService API.
861
+ #
862
+ # Includes fields providing the configuration for each RPC in this service.
863
+ # Each configuration object is of type `Gapic::Config::Method` and includes
864
+ # the following configuration fields:
865
+ #
866
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
867
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
868
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
869
+ # include the following keys:
870
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
871
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
872
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
873
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
874
+ # trigger a retry.
875
+ #
876
+ class Rpcs
877
+ ##
878
+ # RPC-specific configuration for `update_dataset`
879
+ # @return [::Gapic::Config::Method]
880
+ #
881
+ attr_reader :update_dataset
882
+ ##
883
+ # RPC-specific configuration for `import_documents`
884
+ # @return [::Gapic::Config::Method]
885
+ #
886
+ attr_reader :import_documents
887
+ ##
888
+ # RPC-specific configuration for `get_document`
889
+ # @return [::Gapic::Config::Method]
890
+ #
891
+ attr_reader :get_document
892
+ ##
893
+ # RPC-specific configuration for `batch_delete_documents`
894
+ # @return [::Gapic::Config::Method]
895
+ #
896
+ attr_reader :batch_delete_documents
897
+ ##
898
+ # RPC-specific configuration for `get_dataset_schema`
899
+ # @return [::Gapic::Config::Method]
900
+ #
901
+ attr_reader :get_dataset_schema
902
+ ##
903
+ # RPC-specific configuration for `update_dataset_schema`
904
+ # @return [::Gapic::Config::Method]
905
+ #
906
+ attr_reader :update_dataset_schema
907
+
908
+ # @private
909
+ def initialize parent_rpcs = nil
910
+ update_dataset_config = parent_rpcs.update_dataset if parent_rpcs.respond_to? :update_dataset
911
+ @update_dataset = ::Gapic::Config::Method.new update_dataset_config
912
+ import_documents_config = parent_rpcs.import_documents if parent_rpcs.respond_to? :import_documents
913
+ @import_documents = ::Gapic::Config::Method.new import_documents_config
914
+ get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
915
+ @get_document = ::Gapic::Config::Method.new get_document_config
916
+ batch_delete_documents_config = parent_rpcs.batch_delete_documents if parent_rpcs.respond_to? :batch_delete_documents
917
+ @batch_delete_documents = ::Gapic::Config::Method.new batch_delete_documents_config
918
+ get_dataset_schema_config = parent_rpcs.get_dataset_schema if parent_rpcs.respond_to? :get_dataset_schema
919
+ @get_dataset_schema = ::Gapic::Config::Method.new get_dataset_schema_config
920
+ update_dataset_schema_config = parent_rpcs.update_dataset_schema if parent_rpcs.respond_to? :update_dataset_schema
921
+ @update_dataset_schema = ::Gapic::Config::Method.new update_dataset_schema_config
922
+
923
+ yield self if block_given?
924
+ end
925
+ end
926
+ end
927
+ end
928
+ end
929
+ end
930
+ end
931
+ end
932
+ end