Client for the DocumentProcessorService service.
Service to call Cloud DocumentAI to process documents according to the processor's definition. Processors are built using state-of-the-art Google AI such as natural language, computer vision, and translation to extract structured information from unstructured or semi-structured documents.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the DocumentProcessorService Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all DocumentProcessorService clients ::Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.configure do |config| config.timeout = 10.0 end
#batch_process_documents
def batch_process_documents(request, options = nil) -> ::Gapic::Operation
def batch_process_documents(name: nil, input_documents: nil, document_output_config: nil, skip_human_review: nil) -> ::Gapic::Operation
LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
def batch_process_documents(request, options = nil) -> ::Gapic::Operation
batch_process_documents
via a request object, either of type
BatchProcessRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1::BatchProcessRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_process_documents(name: nil, input_documents: nil, document_output_config: nil, skip_human_review: nil) -> ::Gapic::Operation
batch_process_documents
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. The processor resource name.
- input_documents (::Google::Cloud::DocumentAI::V1::BatchDocumentsInputConfig, ::Hash) — The input documents for batch process.
- document_output_config (::Google::Cloud::DocumentAI::V1::DocumentOutputConfig, ::Hash) — The overall output config for batch process.
- skip_human_review (::Boolean) — Whether Human Review feature should be skipped for this request. Default to false.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1::BatchProcessRequest.new # Call the batch_process_documents method. result = client.batch_process_documents request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the DocumentProcessorService Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#initialize
def initialize() { |config| ... } -> Client
Create a new DocumentProcessorService client object.
- (config) — Configure the DocumentProcessorService client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new do |config| config.timeout = 10.0 end
#operations_client
def operations_client() -> ::Google::Cloud::DocumentAI::V1::DocumentProcessorService::Operations
Get the associated client for long-running operations.
#process_document
def process_document(request, options = nil) -> ::Google::Cloud::DocumentAI::V1::ProcessResponse
def process_document(inline_document: nil, raw_document: nil, name: nil, skip_human_review: nil) -> ::Google::Cloud::DocumentAI::V1::ProcessResponse
Processes a single document.
def process_document(request, options = nil) -> ::Google::Cloud::DocumentAI::V1::ProcessResponse
process_document
via a request object, either of type
ProcessRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1::ProcessRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def process_document(inline_document: nil, raw_document: nil, name: nil, skip_human_review: nil) -> ::Google::Cloud::DocumentAI::V1::ProcessResponse
process_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- inline_document (::Google::Cloud::DocumentAI::V1::Document, ::Hash) — An inline document proto.
- raw_document (::Google::Cloud::DocumentAI::V1::RawDocument, ::Hash) — A raw document content (bytes).
- name (::String) — Required. The processor resource name.
- skip_human_review (::Boolean) — Whether Human Review feature should be skipped for this request. Default to false.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DocumentAI::V1::ProcessResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1::ProcessRequest.new # Call the process_document method. result = client.process_document request # The returned object is of type Google::Cloud::DocumentAI::V1::ProcessResponse. p result
#review_document
def review_document(request, options = nil) -> ::Gapic::Operation
def review_document(inline_document: nil, human_review_config: nil, enable_schema_validation: nil, priority: nil) -> ::Gapic::Operation
Send a document for Human Review. The input document should be processed by the specified processor.
def review_document(request, options = nil) -> ::Gapic::Operation
review_document
via a request object, either of type
ReviewDocumentRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1::ReviewDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def review_document(inline_document: nil, human_review_config: nil, enable_schema_validation: nil, priority: nil) -> ::Gapic::Operation
review_document
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- inline_document (::Google::Cloud::DocumentAI::V1::Document, ::Hash) — An inline document proto.
- human_review_config (::String) — Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
- enable_schema_validation (::Boolean) — Whether the validation should be performed on the ad-hoc review request.
- priority (::Google::Cloud::DocumentAI::V1::ReviewDocumentRequest::Priority) — The priority of the human review task.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1::ReviewDocumentRequest.new # Call the review_document method. result = client.review_document request # The returned object is of type Gapic::Operation. You can use this # object to check the status of an operation, cancel it, or wait # for results. Here is how to block until completion: result.wait_until_done! timeout: 60 if result.response? p result.response else puts "Error!" end