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::V1beta3::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_configs: nil, output_config: 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::V1beta3::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_configs: nil, output_config: 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_configs (::Array<::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchInputConfig, ::Hash>) — The input config for each single document in the batch process.
- output_config (::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchOutputConfig, ::Hash) — The overall output config for batch process.
- input_documents (::Google::Cloud::DocumentAI::V1beta3::BatchDocumentsInputConfig, ::Hash) — The input documents for batch process.
- document_output_config (::Google::Cloud::DocumentAI::V1beta3::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/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::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)
#create_processor
def create_processor(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::Processor
def create_processor(parent: nil, processor: nil) -> ::Google::Cloud::DocumentAI::V1beta3::Processor
Creates a processor from the type processor that the user chose. The processor will be at "ENABLED" state by default after its creation.
def create_processor(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::Processor
create_processor
via a request object, either of type
CreateProcessorRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest, ::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 create_processor(parent: nil, processor: nil) -> ::Google::Cloud::DocumentAI::V1beta3::Processor
create_processor
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).
- parent (::String) — Required. The parent (project and location) under which to create the processor. Format: projects/{project}/locations/{location}
- processor (::Google::Cloud::DocumentAI::V1beta3::Processor, ::Hash) — Required. The processor to be created, requires [processor_type] and [display_name] to be set. Also, the processor is under CMEK if CMEK fields are set.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DocumentAI::V1beta3::Processor)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest.new # Call the create_processor method. result = client.create_processor request # The returned object is of type Google::Cloud::DocumentAI::V1beta3::Processor. p result
#delete_processor
def delete_processor(request, options = nil) -> ::Gapic::Operation
def delete_processor(name: nil) -> ::Gapic::Operation
Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
def delete_processor(request, options = nil) -> ::Gapic::Operation
delete_processor
via a request object, either of type
Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest, ::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 delete_processor(name: nil) -> ::Gapic::Operation
delete_processor
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 to be deleted.
- (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/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest.new # Call the delete_processor method. result = client.delete_processor 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
#disable_processor
def disable_processor(request, options = nil) -> ::Gapic::Operation
def disable_processor(name: nil) -> ::Gapic::Operation
Disables a processor
def disable_processor(request, options = nil) -> ::Gapic::Operation
disable_processor
via a request object, either of type
Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest, ::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 disable_processor(name: nil) -> ::Gapic::Operation
disable_processor
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 to be disabled.
- (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/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest.new # Call the disable_processor method. result = client.disable_processor 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
#enable_processor
def enable_processor(request, options = nil) -> ::Gapic::Operation
def enable_processor(name: nil) -> ::Gapic::Operation
Enables a processor
def enable_processor(request, options = nil) -> ::Gapic::Operation
enable_processor
via a request object, either of type
EnableProcessorRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest, ::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 enable_processor(name: nil) -> ::Gapic::Operation
enable_processor
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 to be enabled.
- (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/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest.new # Call the enable_processor method. result = client.enable_processor 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
#fetch_processor_types
def fetch_processor_types(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
def fetch_processor_types(parent: nil) -> ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
Fetches processor types.
def fetch_processor_types(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
fetch_processor_types
via a request object, either of type
FetchProcessorTypesRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest, ::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 fetch_processor_types(parent: nil) -> ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse
fetch_processor_types
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).
- parent (::String) — Required. The project of processor type to list. Format: projects/{project}/locations/{location}
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest.new # Call the fetch_processor_types method. result = client.fetch_processor_types request # The returned object is of type Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse. p result
#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::V1beta3::DocumentProcessorService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new do |config| config.timeout = 10.0 end
#list_processors
def list_processors(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
def list_processors(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
Lists all processors which belong to this project.
def list_processors(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
list_processors
via a request object, either of type
ListProcessorsRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest, ::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 list_processors(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>
list_processors
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).
- parent (::String) — Required. The parent (project and location) which owns this collection of Processors. Format: projects/{project}/locations/{location}
- page_size (::Integer) — The maximum number of processors to return. If unspecified, at most 50 processors will be returned. The maximum value is 100; values above 100 will be coerced to 100.
- page_token (::String) — We will return the processors sorted by creation time. The page token will point to the next processor.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest.new # Call the list_processors method. result = client.list_processors request # The returned object is of type Gapic::PagedEnumerable. You can # iterate over all elements by calling #each, and the enumerable # will lazily make API calls to fetch subsequent pages. Other # methods are also available for managing paging directly. result.each do |response| # Each element is of type ::Google::Cloud::DocumentAI::V1beta3::Processor. p response end
#operations_client
def operations_client() -> ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Operations
Get the associated client for long-running operations.
#process_document
def process_document(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse
def process_document(inline_document: nil, raw_document: nil, name: nil, document: nil, skip_human_review: nil) -> ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse
Processes a single document.
def process_document(request, options = nil) -> ::Google::Cloud::DocumentAI::V1beta3::ProcessResponse
process_document
via a request object, either of type
ProcessRequest or an equivalent Hash.
- request (::Google::Cloud::DocumentAI::V1beta3::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, document: nil, skip_human_review: nil) -> ::Google::Cloud::DocumentAI::V1beta3::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::V1beta3::Document, ::Hash) — An inline document proto.
- raw_document (::Google::Cloud::DocumentAI::V1beta3::RawDocument, ::Hash) — A raw document content (bytes).
- name (::String) — Required. The processor resource name.
- document (::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash) — The document payload, the [content] and [mime_type] fields must be set.
- 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::V1beta3::ProcessResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/document_ai/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::ProcessRequest.new # Call the process_document method. result = client.process_document request # The returned object is of type Google::Cloud::DocumentAI::V1beta3::ProcessResponse. p result
#review_document
def review_document(request, options = nil) -> ::Gapic::Operation
def review_document(inline_document: nil, human_review_config: nil, document: 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::V1beta3::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, document: 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::V1beta3::Document, ::Hash) — An inline document proto.
- human_review_config (::String) — Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
- document (::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash) — The document that needs human review.
- enable_schema_validation (::Boolean) — Whether the validation should be performed on the ad-hoc review request.
- priority (::Google::Cloud::DocumentAI::V1beta3::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/v1beta3" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::DocumentAI::V1beta3::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