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