google-cloud-document_ai-v1beta3 0.8.0 → 0.9.3

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +8 -8
  3. data/README.md +1 -1
  4. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb +719 -62
  5. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/operations.rb +149 -37
  6. data/lib/google/cloud/document_ai/v1beta3/document_processor_service/paths.rb +17 -0
  7. data/lib/google/cloud/document_ai/v1beta3/version.rb +1 -1
  8. data/lib/google/cloud/documentai/v1beta3/document_io_pb.rb +1 -1
  9. data/lib/google/cloud/documentai/v1beta3/document_pb.rb +5 -2
  10. data/lib/google/cloud/documentai/v1beta3/document_processor_service_pb.rb +66 -18
  11. data/lib/google/cloud/documentai/v1beta3/document_processor_service_services_pb.rb +15 -1
  12. data/lib/google/cloud/documentai/v1beta3/geometry_pb.rb +1 -1
  13. data/lib/google/cloud/documentai/v1beta3/operation_metadata_pb.rb +36 -0
  14. data/lib/google/cloud/documentai/v1beta3/processor_pb.rb +45 -0
  15. data/lib/google/cloud/documentai/v1beta3/processor_type_pb.rb +32 -0
  16. data/proto_docs/google/api/field_behavior.rb +7 -1
  17. data/proto_docs/google/cloud/documentai/v1beta3/document.rb +12 -0
  18. data/proto_docs/google/cloud/documentai/v1beta3/document_processor_service.rb +149 -39
  19. data/proto_docs/google/cloud/documentai/v1beta3/geometry.rb +2 -2
  20. data/proto_docs/google/cloud/documentai/v1beta3/operation_metadata.rb +65 -0
  21. data/proto_docs/google/cloud/documentai/v1beta3/processor.rb +86 -0
  22. data/proto_docs/google/cloud/documentai/v1beta3/processor_type.rb +59 -0
  23. data/proto_docs/google/type/color.rb +16 -11
  24. data/proto_docs/google/type/date.rb +14 -11
  25. data/proto_docs/google/type/datetime.rb +9 -1
  26. data/proto_docs/google/type/money.rb +1 -1
  27. metadata +19 -7
@@ -44,13 +44,12 @@ module Google
44
44
  # See {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration}
45
45
  # for a description of the configuration fields.
46
46
  #
47
- # ## Example
47
+ # @example
48
48
  #
49
- # To modify the configuration for all DocumentProcessorService clients:
50
- #
51
- # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
52
- # config.timeout = 10.0
53
- # end
49
+ # # Modify the configuration for all DocumentProcessorService clients
50
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
54
53
  #
55
54
  # @yield [config] Configure the Client client.
56
55
  # @yieldparam config [Client::Configuration]
@@ -70,26 +69,17 @@ module Google
70
69
 
71
70
  default_config.rpcs.process_document.timeout = 120.0
72
71
  default_config.rpcs.process_document.retry_policy = {
73
- initial_delay: 0.1,
74
- max_delay: 60.0,
75
- multiplier: 1.3,
76
- retry_codes: [4, 14]
72
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
77
73
  }
78
74
 
79
75
  default_config.rpcs.batch_process_documents.timeout = 120.0
80
76
  default_config.rpcs.batch_process_documents.retry_policy = {
81
- initial_delay: 0.1,
82
- max_delay: 60.0,
83
- multiplier: 1.3,
84
- retry_codes: [4, 14]
77
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
85
78
  }
86
79
 
87
80
  default_config.rpcs.review_document.timeout = 120.0
88
81
  default_config.rpcs.review_document.retry_policy = {
89
- initial_delay: 0.1,
90
- max_delay: 60.0,
91
- multiplier: 1.3,
92
- retry_codes: [4, 14]
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
93
83
  }
94
84
 
95
85
  default_config
@@ -121,19 +111,15 @@ module Google
121
111
  ##
122
112
  # Create a new DocumentProcessorService client object.
123
113
  #
124
- # ## Examples
125
- #
126
- # To create a new DocumentProcessorService client with the default
127
- # configuration:
128
- #
129
- # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
114
+ # @example
130
115
  #
131
- # To create a new DocumentProcessorService client with a custom
132
- # configuration:
116
+ # # Create a client using the default configuration
117
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
133
118
  #
134
- # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
135
- # config.timeout = 10.0
136
- # end
119
+ # # Create a client using a custom configuration
120
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
121
+ # config.timeout = 10.0
122
+ # end
137
123
  #
138
124
  # @yield [config] Configure the DocumentProcessorService client.
139
125
  # @yieldparam config [Client::Configuration]
@@ -153,14 +139,13 @@ module Google
153
139
 
154
140
  # Create credentials
155
141
  credentials = @config.credentials
156
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
142
+ # Use self-signed JWT if the endpoint is unchanged from default,
157
143
  # but only if the default endpoint does not have a region prefix.
158
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
159
- @config.endpoint == Client.configure.endpoint &&
144
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
160
145
  !@config.endpoint.split(".").first.include?("-")
161
146
  credentials ||= Credentials.default scope: @config.scope,
162
147
  enable_self_signed_jwt: enable_self_signed_jwt
163
- if credentials.is_a?(String) || credentials.is_a?(Hash)
148
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
164
149
  credentials = Credentials.new credentials, scope: @config.scope
165
150
  end
166
151
  @quota_project_id = @config.quota_project
@@ -227,6 +212,21 @@ module Google
227
212
  #
228
213
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
229
214
  #
215
+ # @example Basic example
216
+ # require "google/cloud/document_ai/v1beta3"
217
+ #
218
+ # # Create a client object. The client can be reused for multiple calls.
219
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
220
+ #
221
+ # # Create a request. To set request fields, pass in keyword arguments.
222
+ # request = Google::Cloud::DocumentAI::V1beta3::ProcessRequest.new
223
+ #
224
+ # # Call the process_document method.
225
+ # result = client.process_document request
226
+ #
227
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::ProcessResponse.
228
+ # p result
229
+ #
230
230
  def process_document request, options = nil
231
231
  raise ::ArgumentError, "request must be provided" if request.nil?
232
232
 
@@ -244,16 +244,20 @@ module Google
244
244
  gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
245
245
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
246
246
 
247
- header_params = {
248
- "name" => request.name
249
- }
247
+ header_params = {}
248
+ if request.name
249
+ header_params["name"] = request.name
250
+ end
251
+
250
252
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
253
  metadata[:"x-goog-request-params"] ||= request_params_header
252
254
 
253
255
  options.apply_defaults timeout: @config.rpcs.process_document.timeout,
254
256
  metadata: metadata,
255
257
  retry_policy: @config.rpcs.process_document.retry_policy
256
- options.apply_defaults metadata: @config.metadata,
258
+
259
+ options.apply_defaults timeout: @config.timeout,
260
+ metadata: @config.metadata,
257
261
  retry_policy: @config.retry_policy
258
262
 
259
263
  @document_processor_service_stub.call_rpc :process_document, request, options: options do |response, operation|
@@ -305,6 +309,28 @@ module Google
305
309
  #
306
310
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
307
311
  #
312
+ # @example Basic example
313
+ # require "google/cloud/document_ai/v1beta3"
314
+ #
315
+ # # Create a client object. The client can be reused for multiple calls.
316
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
317
+ #
318
+ # # Create a request. To set request fields, pass in keyword arguments.
319
+ # request = Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest.new
320
+ #
321
+ # # Call the batch_process_documents method.
322
+ # result = client.batch_process_documents request
323
+ #
324
+ # # The returned object is of type Gapic::Operation. You can use this
325
+ # # object to check the status of an operation, cancel it, or wait
326
+ # # for results. Here is how to block until completion:
327
+ # result.wait_until_done! timeout: 60
328
+ # if result.response?
329
+ # p result.response
330
+ # else
331
+ # puts "Error!"
332
+ # end
333
+ #
308
334
  def batch_process_documents request, options = nil
309
335
  raise ::ArgumentError, "request must be provided" if request.nil?
310
336
 
@@ -322,16 +348,20 @@ module Google
322
348
  gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
323
349
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
324
350
 
325
- header_params = {
326
- "name" => request.name
327
- }
351
+ header_params = {}
352
+ if request.name
353
+ header_params["name"] = request.name
354
+ end
355
+
328
356
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
329
357
  metadata[:"x-goog-request-params"] ||= request_params_header
330
358
 
331
359
  options.apply_defaults timeout: @config.rpcs.batch_process_documents.timeout,
332
360
  metadata: metadata,
333
361
  retry_policy: @config.rpcs.batch_process_documents.retry_policy
334
- options.apply_defaults metadata: @config.metadata,
362
+
363
+ options.apply_defaults timeout: @config.timeout,
364
+ metadata: @config.metadata,
335
365
  retry_policy: @config.retry_policy
336
366
 
337
367
  @document_processor_service_stub.call_rpc :batch_process_documents, request, options: options do |response, operation|
@@ -343,6 +373,562 @@ module Google
343
373
  raise ::Google::Cloud::Error.from_error(e)
344
374
  end
345
375
 
376
+ ##
377
+ # Fetches processor types.
378
+ #
379
+ # @overload fetch_processor_types(request, options = nil)
380
+ # Pass arguments to `fetch_processor_types` via a request object, either of type
381
+ # {::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest} or an equivalent Hash.
382
+ #
383
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest, ::Hash]
384
+ # A request object representing the call parameters. Required. To specify no
385
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
386
+ # @param options [::Gapic::CallOptions, ::Hash]
387
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
388
+ #
389
+ # @overload fetch_processor_types(parent: nil)
390
+ # Pass arguments to `fetch_processor_types` via keyword arguments. Note that at
391
+ # least one keyword argument is required. To specify no parameters, or to keep all
392
+ # the default parameter values, pass an empty Hash as a request object (see above).
393
+ #
394
+ # @param parent [::String]
395
+ # Required. The project of processor type to list.
396
+ # Format: projects/\\{project}/locations/\\{location}
397
+ #
398
+ # @yield [response, operation] Access the result along with the RPC operation
399
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse]
400
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
401
+ #
402
+ # @return [::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse]
403
+ #
404
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
405
+ #
406
+ # @example Basic example
407
+ # require "google/cloud/document_ai/v1beta3"
408
+ #
409
+ # # Create a client object. The client can be reused for multiple calls.
410
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
411
+ #
412
+ # # Create a request. To set request fields, pass in keyword arguments.
413
+ # request = Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest.new
414
+ #
415
+ # # Call the fetch_processor_types method.
416
+ # result = client.fetch_processor_types request
417
+ #
418
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse.
419
+ # p result
420
+ #
421
+ def fetch_processor_types request, options = nil
422
+ raise ::ArgumentError, "request must be provided" if request.nil?
423
+
424
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest
425
+
426
+ # Converts hash and nil to an options object
427
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
428
+
429
+ # Customize the options with defaults
430
+ metadata = @config.rpcs.fetch_processor_types.metadata.to_h
431
+
432
+ # Set x-goog-api-client and x-goog-user-project headers
433
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
434
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
435
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
436
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
437
+
438
+ header_params = {}
439
+ if request.parent
440
+ header_params["parent"] = request.parent
441
+ end
442
+
443
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
444
+ metadata[:"x-goog-request-params"] ||= request_params_header
445
+
446
+ options.apply_defaults timeout: @config.rpcs.fetch_processor_types.timeout,
447
+ metadata: metadata,
448
+ retry_policy: @config.rpcs.fetch_processor_types.retry_policy
449
+
450
+ options.apply_defaults timeout: @config.timeout,
451
+ metadata: @config.metadata,
452
+ retry_policy: @config.retry_policy
453
+
454
+ @document_processor_service_stub.call_rpc :fetch_processor_types, request, options: options do |response, operation|
455
+ yield response, operation if block_given?
456
+ return response
457
+ end
458
+ rescue ::GRPC::BadStatus => e
459
+ raise ::Google::Cloud::Error.from_error(e)
460
+ end
461
+
462
+ ##
463
+ # Lists all processors which belong to this project.
464
+ #
465
+ # @overload list_processors(request, options = nil)
466
+ # Pass arguments to `list_processors` via a request object, either of type
467
+ # {::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest} or an equivalent Hash.
468
+ #
469
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest, ::Hash]
470
+ # A request object representing the call parameters. Required. To specify no
471
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
472
+ # @param options [::Gapic::CallOptions, ::Hash]
473
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
474
+ #
475
+ # @overload list_processors(parent: nil, page_size: nil, page_token: nil)
476
+ # Pass arguments to `list_processors` via keyword arguments. Note that at
477
+ # least one keyword argument is required. To specify no parameters, or to keep all
478
+ # the default parameter values, pass an empty Hash as a request object (see above).
479
+ #
480
+ # @param parent [::String]
481
+ # Required. The parent (project and location) which owns this collection of Processors.
482
+ # Format: projects/\\{project}/locations/\\{location}
483
+ # @param page_size [::Integer]
484
+ # The maximum number of processors to return.
485
+ # If unspecified, at most 50 processors will be returned.
486
+ # The maximum value is 100; values above 100 will be coerced to 100.
487
+ # @param page_token [::String]
488
+ # We will return the processors sorted by creation time. The page token
489
+ # will point to the next processor.
490
+ #
491
+ # @yield [response, operation] Access the result along with the RPC operation
492
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>]
493
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
494
+ #
495
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>]
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::DocumentProcessorService::Client.new
504
+ #
505
+ # # Create a request. To set request fields, pass in keyword arguments.
506
+ # request = Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest.new
507
+ #
508
+ # # Call the list_processors method.
509
+ # result = client.list_processors request
510
+ #
511
+ # # The returned object is of type Gapic::PagedEnumerable. You can
512
+ # # iterate over all elements by calling #each, and the enumerable
513
+ # # will lazily make API calls to fetch subsequent pages. Other
514
+ # # methods are also available for managing paging directly.
515
+ # result.each do |response|
516
+ # # Each element is of type ::Google::Cloud::DocumentAI::V1beta3::Processor.
517
+ # p response
518
+ # end
519
+ #
520
+ def list_processors request, options = nil
521
+ raise ::ArgumentError, "request must be provided" if request.nil?
522
+
523
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest
524
+
525
+ # Converts hash and nil to an options object
526
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
527
+
528
+ # Customize the options with defaults
529
+ metadata = @config.rpcs.list_processors.metadata.to_h
530
+
531
+ # Set x-goog-api-client and x-goog-user-project headers
532
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
533
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
534
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
535
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
536
+
537
+ header_params = {}
538
+ if request.parent
539
+ header_params["parent"] = request.parent
540
+ end
541
+
542
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
543
+ metadata[:"x-goog-request-params"] ||= request_params_header
544
+
545
+ options.apply_defaults timeout: @config.rpcs.list_processors.timeout,
546
+ metadata: metadata,
547
+ retry_policy: @config.rpcs.list_processors.retry_policy
548
+
549
+ options.apply_defaults timeout: @config.timeout,
550
+ metadata: @config.metadata,
551
+ retry_policy: @config.retry_policy
552
+
553
+ @document_processor_service_stub.call_rpc :list_processors, request, options: options do |response, operation|
554
+ response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processors, request, response, operation, options
555
+ yield response, operation if block_given?
556
+ return response
557
+ end
558
+ rescue ::GRPC::BadStatus => e
559
+ raise ::Google::Cloud::Error.from_error(e)
560
+ end
561
+
562
+ ##
563
+ # Creates a processor from the type processor that the user chose.
564
+ # The processor will be at "ENABLED" state by default after its creation.
565
+ #
566
+ # @overload create_processor(request, options = nil)
567
+ # Pass arguments to `create_processor` via a request object, either of type
568
+ # {::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest} or an equivalent Hash.
569
+ #
570
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest, ::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 create_processor(parent: nil, processor: nil)
577
+ # Pass arguments to `create_processor` 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 parent [::String]
582
+ # Required. The parent (project and location) under which to create the processor.
583
+ # Format: projects/\\{project}/locations/\\{location}
584
+ # @param processor [::Google::Cloud::DocumentAI::V1beta3::Processor, ::Hash]
585
+ # Required. The processor to be created, requires [processor_type] and [display_name]
586
+ # to be set. Also, the processor is under CMEK if CMEK fields are set.
587
+ #
588
+ # @yield [response, operation] Access the result along with the RPC operation
589
+ # @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::Processor]
590
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
591
+ #
592
+ # @return [::Google::Cloud::DocumentAI::V1beta3::Processor]
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::DocumentProcessorService::Client.new
601
+ #
602
+ # # Create a request. To set request fields, pass in keyword arguments.
603
+ # request = Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest.new
604
+ #
605
+ # # Call the create_processor method.
606
+ # result = client.create_processor request
607
+ #
608
+ # # The returned object is of type Google::Cloud::DocumentAI::V1beta3::Processor.
609
+ # p result
610
+ #
611
+ def create_processor 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::CreateProcessorRequest
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.create_processor.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.parent
630
+ header_params["parent"] = request.parent
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.create_processor.timeout,
637
+ metadata: metadata,
638
+ retry_policy: @config.rpcs.create_processor.retry_policy
639
+
640
+ options.apply_defaults timeout: @config.timeout,
641
+ metadata: @config.metadata,
642
+ retry_policy: @config.retry_policy
643
+
644
+ @document_processor_service_stub.call_rpc :create_processor, 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
+ # Deletes the processor, unloads all deployed model artifacts if it was
654
+ # enabled and then deletes all artifacts associated with this processor.
655
+ #
656
+ # @overload delete_processor(request, options = nil)
657
+ # Pass arguments to `delete_processor` via a request object, either of type
658
+ # {::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest} or an equivalent Hash.
659
+ #
660
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest, ::Hash]
661
+ # A request object representing the call parameters. Required. To specify no
662
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
663
+ # @param options [::Gapic::CallOptions, ::Hash]
664
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
665
+ #
666
+ # @overload delete_processor(name: nil)
667
+ # Pass arguments to `delete_processor` via keyword arguments. Note that at
668
+ # least one keyword argument is required. To specify no parameters, or to keep all
669
+ # the default parameter values, pass an empty Hash as a request object (see above).
670
+ #
671
+ # @param name [::String]
672
+ # Required. The processor resource name to be deleted.
673
+ #
674
+ # @yield [response, operation] Access the result along with the RPC operation
675
+ # @yieldparam response [::Gapic::Operation]
676
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
677
+ #
678
+ # @return [::Gapic::Operation]
679
+ #
680
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
681
+ #
682
+ # @example Basic example
683
+ # require "google/cloud/document_ai/v1beta3"
684
+ #
685
+ # # Create a client object. The client can be reused for multiple calls.
686
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
687
+ #
688
+ # # Create a request. To set request fields, pass in keyword arguments.
689
+ # request = Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest.new
690
+ #
691
+ # # Call the delete_processor method.
692
+ # result = client.delete_processor request
693
+ #
694
+ # # The returned object is of type Gapic::Operation. You can use this
695
+ # # object to check the status of an operation, cancel it, or wait
696
+ # # for results. Here is how to block until completion:
697
+ # result.wait_until_done! timeout: 60
698
+ # if result.response?
699
+ # p result.response
700
+ # else
701
+ # puts "Error!"
702
+ # end
703
+ #
704
+ def delete_processor request, options = nil
705
+ raise ::ArgumentError, "request must be provided" if request.nil?
706
+
707
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest
708
+
709
+ # Converts hash and nil to an options object
710
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
711
+
712
+ # Customize the options with defaults
713
+ metadata = @config.rpcs.delete_processor.metadata.to_h
714
+
715
+ # Set x-goog-api-client and x-goog-user-project headers
716
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
717
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
718
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
719
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
720
+
721
+ header_params = {}
722
+ if request.name
723
+ header_params["name"] = request.name
724
+ end
725
+
726
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
727
+ metadata[:"x-goog-request-params"] ||= request_params_header
728
+
729
+ options.apply_defaults timeout: @config.rpcs.delete_processor.timeout,
730
+ metadata: metadata,
731
+ retry_policy: @config.rpcs.delete_processor.retry_policy
732
+
733
+ options.apply_defaults timeout: @config.timeout,
734
+ metadata: @config.metadata,
735
+ retry_policy: @config.retry_policy
736
+
737
+ @document_processor_service_stub.call_rpc :delete_processor, request, options: options do |response, operation|
738
+ response = ::Gapic::Operation.new response, @operations_client, options: options
739
+ yield response, operation if block_given?
740
+ return response
741
+ end
742
+ rescue ::GRPC::BadStatus => e
743
+ raise ::Google::Cloud::Error.from_error(e)
744
+ end
745
+
746
+ ##
747
+ # Enables a processor
748
+ #
749
+ # @overload enable_processor(request, options = nil)
750
+ # Pass arguments to `enable_processor` via a request object, either of type
751
+ # {::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest} or an equivalent Hash.
752
+ #
753
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest, ::Hash]
754
+ # A request object representing the call parameters. Required. To specify no
755
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
756
+ # @param options [::Gapic::CallOptions, ::Hash]
757
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
758
+ #
759
+ # @overload enable_processor(name: nil)
760
+ # Pass arguments to `enable_processor` via keyword arguments. Note that at
761
+ # least one keyword argument is required. To specify no parameters, or to keep all
762
+ # the default parameter values, pass an empty Hash as a request object (see above).
763
+ #
764
+ # @param name [::String]
765
+ # Required. The processor resource name to be enabled.
766
+ #
767
+ # @yield [response, operation] Access the result along with the RPC operation
768
+ # @yieldparam response [::Gapic::Operation]
769
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
770
+ #
771
+ # @return [::Gapic::Operation]
772
+ #
773
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
774
+ #
775
+ # @example Basic example
776
+ # require "google/cloud/document_ai/v1beta3"
777
+ #
778
+ # # Create a client object. The client can be reused for multiple calls.
779
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
780
+ #
781
+ # # Create a request. To set request fields, pass in keyword arguments.
782
+ # request = Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest.new
783
+ #
784
+ # # Call the enable_processor method.
785
+ # result = client.enable_processor request
786
+ #
787
+ # # The returned object is of type Gapic::Operation. You can use this
788
+ # # object to check the status of an operation, cancel it, or wait
789
+ # # for results. Here is how to block until completion:
790
+ # result.wait_until_done! timeout: 60
791
+ # if result.response?
792
+ # p result.response
793
+ # else
794
+ # puts "Error!"
795
+ # end
796
+ #
797
+ def enable_processor request, options = nil
798
+ raise ::ArgumentError, "request must be provided" if request.nil?
799
+
800
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest
801
+
802
+ # Converts hash and nil to an options object
803
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
804
+
805
+ # Customize the options with defaults
806
+ metadata = @config.rpcs.enable_processor.metadata.to_h
807
+
808
+ # Set x-goog-api-client and x-goog-user-project headers
809
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
810
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
811
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
812
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
813
+
814
+ header_params = {}
815
+ if request.name
816
+ header_params["name"] = request.name
817
+ end
818
+
819
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
820
+ metadata[:"x-goog-request-params"] ||= request_params_header
821
+
822
+ options.apply_defaults timeout: @config.rpcs.enable_processor.timeout,
823
+ metadata: metadata,
824
+ retry_policy: @config.rpcs.enable_processor.retry_policy
825
+
826
+ options.apply_defaults timeout: @config.timeout,
827
+ metadata: @config.metadata,
828
+ retry_policy: @config.retry_policy
829
+
830
+ @document_processor_service_stub.call_rpc :enable_processor, request, options: options do |response, operation|
831
+ response = ::Gapic::Operation.new response, @operations_client, options: options
832
+ yield response, operation if block_given?
833
+ return response
834
+ end
835
+ rescue ::GRPC::BadStatus => e
836
+ raise ::Google::Cloud::Error.from_error(e)
837
+ end
838
+
839
+ ##
840
+ # Disables a processor
841
+ #
842
+ # @overload disable_processor(request, options = nil)
843
+ # Pass arguments to `disable_processor` via a request object, either of type
844
+ # {::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest} or an equivalent Hash.
845
+ #
846
+ # @param request [::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest, ::Hash]
847
+ # A request object representing the call parameters. Required. To specify no
848
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
849
+ # @param options [::Gapic::CallOptions, ::Hash]
850
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
851
+ #
852
+ # @overload disable_processor(name: nil)
853
+ # Pass arguments to `disable_processor` via keyword arguments. Note that at
854
+ # least one keyword argument is required. To specify no parameters, or to keep all
855
+ # the default parameter values, pass an empty Hash as a request object (see above).
856
+ #
857
+ # @param name [::String]
858
+ # Required. The processor resource name to be disabled.
859
+ #
860
+ # @yield [response, operation] Access the result along with the RPC operation
861
+ # @yieldparam response [::Gapic::Operation]
862
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
863
+ #
864
+ # @return [::Gapic::Operation]
865
+ #
866
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
867
+ #
868
+ # @example Basic example
869
+ # require "google/cloud/document_ai/v1beta3"
870
+ #
871
+ # # Create a client object. The client can be reused for multiple calls.
872
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
873
+ #
874
+ # # Create a request. To set request fields, pass in keyword arguments.
875
+ # request = Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest.new
876
+ #
877
+ # # Call the disable_processor method.
878
+ # result = client.disable_processor request
879
+ #
880
+ # # The returned object is of type Gapic::Operation. You can use this
881
+ # # object to check the status of an operation, cancel it, or wait
882
+ # # for results. Here is how to block until completion:
883
+ # result.wait_until_done! timeout: 60
884
+ # if result.response?
885
+ # p result.response
886
+ # else
887
+ # puts "Error!"
888
+ # end
889
+ #
890
+ def disable_processor request, options = nil
891
+ raise ::ArgumentError, "request must be provided" if request.nil?
892
+
893
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest
894
+
895
+ # Converts hash and nil to an options object
896
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
897
+
898
+ # Customize the options with defaults
899
+ metadata = @config.rpcs.disable_processor.metadata.to_h
900
+
901
+ # Set x-goog-api-client and x-goog-user-project headers
902
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
903
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
904
+ gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
905
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
906
+
907
+ header_params = {}
908
+ if request.name
909
+ header_params["name"] = request.name
910
+ end
911
+
912
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
913
+ metadata[:"x-goog-request-params"] ||= request_params_header
914
+
915
+ options.apply_defaults timeout: @config.rpcs.disable_processor.timeout,
916
+ metadata: metadata,
917
+ retry_policy: @config.rpcs.disable_processor.retry_policy
918
+
919
+ options.apply_defaults timeout: @config.timeout,
920
+ metadata: @config.metadata,
921
+ retry_policy: @config.retry_policy
922
+
923
+ @document_processor_service_stub.call_rpc :disable_processor, request, options: options do |response, operation|
924
+ response = ::Gapic::Operation.new response, @operations_client, options: options
925
+ yield response, operation if block_given?
926
+ return response
927
+ end
928
+ rescue ::GRPC::BadStatus => e
929
+ raise ::Google::Cloud::Error.from_error(e)
930
+ end
931
+
346
932
  ##
347
933
  # Send a document for Human Review. The input document should be processed by
348
934
  # the specified processor.
@@ -357,7 +943,7 @@ module Google
357
943
  # @param options [::Gapic::CallOptions, ::Hash]
358
944
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
359
945
  #
360
- # @overload review_document(inline_document: nil, human_review_config: nil, document: nil)
946
+ # @overload review_document(inline_document: nil, human_review_config: nil, document: nil, enable_schema_validation: nil, priority: nil)
361
947
  # Pass arguments to `review_document` via keyword arguments. Note that at
362
948
  # least one keyword argument is required. To specify no parameters, or to keep all
363
949
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -369,6 +955,10 @@ module Google
369
955
  # reviewed with.
370
956
  # @param document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
371
957
  # The document that needs human review.
958
+ # @param enable_schema_validation [::Boolean]
959
+ # Whether the validation should be performed on the ad-hoc review request.
960
+ # @param priority [::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest::Priority]
961
+ # The priority of the human review task.
372
962
  #
373
963
  # @yield [response, operation] Access the result along with the RPC operation
374
964
  # @yieldparam response [::Gapic::Operation]
@@ -378,6 +968,28 @@ module Google
378
968
  #
379
969
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
380
970
  #
971
+ # @example Basic example
972
+ # require "google/cloud/document_ai/v1beta3"
973
+ #
974
+ # # Create a client object. The client can be reused for multiple calls.
975
+ # client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new
976
+ #
977
+ # # Create a request. To set request fields, pass in keyword arguments.
978
+ # request = Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest.new
979
+ #
980
+ # # Call the review_document method.
981
+ # result = client.review_document request
982
+ #
983
+ # # The returned object is of type Gapic::Operation. You can use this
984
+ # # object to check the status of an operation, cancel it, or wait
985
+ # # for results. Here is how to block until completion:
986
+ # result.wait_until_done! timeout: 60
987
+ # if result.response?
988
+ # p result.response
989
+ # else
990
+ # puts "Error!"
991
+ # end
992
+ #
381
993
  def review_document request, options = nil
382
994
  raise ::ArgumentError, "request must be provided" if request.nil?
383
995
 
@@ -395,16 +1007,20 @@ module Google
395
1007
  gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
396
1008
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
397
1009
 
398
- header_params = {
399
- "human_review_config" => request.human_review_config
400
- }
1010
+ header_params = {}
1011
+ if request.human_review_config
1012
+ header_params["human_review_config"] = request.human_review_config
1013
+ end
1014
+
401
1015
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
402
1016
  metadata[:"x-goog-request-params"] ||= request_params_header
403
1017
 
404
1018
  options.apply_defaults timeout: @config.rpcs.review_document.timeout,
405
1019
  metadata: metadata,
406
1020
  retry_policy: @config.rpcs.review_document.retry_policy
407
- options.apply_defaults metadata: @config.metadata,
1021
+
1022
+ options.apply_defaults timeout: @config.timeout,
1023
+ metadata: @config.metadata,
408
1024
  retry_policy: @config.retry_policy
409
1025
 
410
1026
  @document_processor_service_stub.call_rpc :review_document, request, options: options do |response, operation|
@@ -429,26 +1045,25 @@ module Google
429
1045
  # Configuration can be applied globally to all clients, or to a single client
430
1046
  # on construction.
431
1047
  #
432
- # # Examples
1048
+ # @example
433
1049
  #
434
- # To modify the global config, setting the timeout for process_document
435
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1050
+ # # Modify the global config, setting the timeout for
1051
+ # # process_document to 20 seconds,
1052
+ # # and all remaining timeouts to 10 seconds.
1053
+ # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
1054
+ # config.timeout = 10.0
1055
+ # config.rpcs.process_document.timeout = 20.0
1056
+ # end
436
1057
  #
437
- # ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
438
- # config.timeout = 10.0
439
- # config.rpcs.process_document.timeout = 20.0
440
- # end
441
- #
442
- # To apply the above configuration only to a new client:
443
- #
444
- # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
445
- # config.timeout = 10.0
446
- # config.rpcs.process_document.timeout = 20.0
447
- # end
1058
+ # # Apply the above configuration only to a new client.
1059
+ # client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config|
1060
+ # config.timeout = 10.0
1061
+ # config.rpcs.process_document.timeout = 20.0
1062
+ # end
448
1063
  #
449
1064
  # @!attribute [rw] endpoint
450
1065
  # The hostname or hostname:port of the service endpoint.
451
- # Defaults to `"us-documentai.googleapis.com"`.
1066
+ # Defaults to `"documentai.googleapis.com"`.
452
1067
  # @return [::String]
453
1068
  # @!attribute [rw] credentials
454
1069
  # Credentials to send with calls. You may provide any of the following types:
@@ -499,7 +1114,7 @@ module Google
499
1114
  class Configuration
500
1115
  extend ::Gapic::Config
501
1116
 
502
- config_attr :endpoint, "us-documentai.googleapis.com", ::String
1117
+ config_attr :endpoint, "documentai.googleapis.com", ::String
503
1118
  config_attr :credentials, nil do |value|
504
1119
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
505
1120
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
@@ -563,6 +1178,36 @@ module Google
563
1178
  #
564
1179
  attr_reader :batch_process_documents
565
1180
  ##
1181
+ # RPC-specific configuration for `fetch_processor_types`
1182
+ # @return [::Gapic::Config::Method]
1183
+ #
1184
+ attr_reader :fetch_processor_types
1185
+ ##
1186
+ # RPC-specific configuration for `list_processors`
1187
+ # @return [::Gapic::Config::Method]
1188
+ #
1189
+ attr_reader :list_processors
1190
+ ##
1191
+ # RPC-specific configuration for `create_processor`
1192
+ # @return [::Gapic::Config::Method]
1193
+ #
1194
+ attr_reader :create_processor
1195
+ ##
1196
+ # RPC-specific configuration for `delete_processor`
1197
+ # @return [::Gapic::Config::Method]
1198
+ #
1199
+ attr_reader :delete_processor
1200
+ ##
1201
+ # RPC-specific configuration for `enable_processor`
1202
+ # @return [::Gapic::Config::Method]
1203
+ #
1204
+ attr_reader :enable_processor
1205
+ ##
1206
+ # RPC-specific configuration for `disable_processor`
1207
+ # @return [::Gapic::Config::Method]
1208
+ #
1209
+ attr_reader :disable_processor
1210
+ ##
566
1211
  # RPC-specific configuration for `review_document`
567
1212
  # @return [::Gapic::Config::Method]
568
1213
  #
@@ -574,6 +1219,18 @@ module Google
574
1219
  @process_document = ::Gapic::Config::Method.new process_document_config
575
1220
  batch_process_documents_config = parent_rpcs.batch_process_documents if parent_rpcs.respond_to? :batch_process_documents
576
1221
  @batch_process_documents = ::Gapic::Config::Method.new batch_process_documents_config
1222
+ fetch_processor_types_config = parent_rpcs.fetch_processor_types if parent_rpcs.respond_to? :fetch_processor_types
1223
+ @fetch_processor_types = ::Gapic::Config::Method.new fetch_processor_types_config
1224
+ list_processors_config = parent_rpcs.list_processors if parent_rpcs.respond_to? :list_processors
1225
+ @list_processors = ::Gapic::Config::Method.new list_processors_config
1226
+ create_processor_config = parent_rpcs.create_processor if parent_rpcs.respond_to? :create_processor
1227
+ @create_processor = ::Gapic::Config::Method.new create_processor_config
1228
+ delete_processor_config = parent_rpcs.delete_processor if parent_rpcs.respond_to? :delete_processor
1229
+ @delete_processor = ::Gapic::Config::Method.new delete_processor_config
1230
+ enable_processor_config = parent_rpcs.enable_processor if parent_rpcs.respond_to? :enable_processor
1231
+ @enable_processor = ::Gapic::Config::Method.new enable_processor_config
1232
+ disable_processor_config = parent_rpcs.disable_processor if parent_rpcs.respond_to? :disable_processor
1233
+ @disable_processor = ::Gapic::Config::Method.new disable_processor_config
577
1234
  review_document_config = parent_rpcs.review_document if parent_rpcs.respond_to? :review_document
578
1235
  @review_document = ::Gapic::Config::Method.new review_document_config
579
1236