class Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client

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.

Attributes

document_processor_service_stub[R]

@private

operations_client[R]

Get the associated client for long-running operations.

@return [::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Operations]

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the DocumentProcessorService Client class.

See {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all DocumentProcessorService clients
::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client.configure do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 59
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "DocumentAI", "V1beta3"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.process_document.timeout = 120.0
    default_config.rpcs.process_document.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.batch_process_documents.timeout = 120.0
    default_config.rpcs.batch_process_documents.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.review_document.timeout = 120.0
    default_config.rpcs.review_document.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new DocumentProcessorService client object.

@example

# 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

@yield [config] Configure the DocumentProcessorService client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 127
def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/documentai/v1beta3/document_processor_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.endpoint = @config.endpoint
  end

  @document_processor_service_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

batch_process_documents(request, options = nil) { |response, operation| ... } click to toggle source

LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.

@overload batch_process_documents(request, options = nil)

Pass arguments to `batch_process_documents` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload batch_process_documents(name: nil, input_configs: nil, output_config: nil, input_documents: nil, document_output_config: nil, skip_human_review: nil)

Pass arguments to `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).

@param name [::String]
  Required. The processor resource name.
@param input_configs [::Array<::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchInputConfig, ::Hash>]
  The input config for each single document in the batch process.
@param output_config [::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest::BatchOutputConfig, ::Hash]
  The overall output config for batch process.
@param input_documents [::Google::Cloud::DocumentAI::V1beta3::BatchDocumentsInputConfig, ::Hash]
  The input documents for batch process.
@param document_output_config [::Google::Cloud::DocumentAI::V1beta3::DocumentOutputConfig, ::Hash]
  The overall output config for batch process.
@param skip_human_review [::Boolean]
  Whether Human Review feature should be skipped for this request. Default to
  false.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 295
def batch_process_documents request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::BatchProcessRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.batch_process_documents.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.batch_process_documents.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.batch_process_documents.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :batch_process_documents, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
configure() { |config| ... } click to toggle source

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 {::Google::Cloud::DocumentAI::V1beta3::DocumentProcessorService::Client::Configuration} for a description of the configuration fields.

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 106
def configure
  yield @config if block_given?
  @config
end
create_processor(request, options = nil) { |response, operation| ... } click to toggle source

Creates a processor from the type processor that the user chose. The processor will be at “ENABLED” state by default after its creation.

@overload create_processor(request, options = nil)

Pass arguments to `create_processor` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload create_processor(parent: nil, processor: nil)

Pass arguments to `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).

@param parent [::String]
  Required. The parent (project and location) under which to create the processor.
  Format: projects/\\{project}/locations/\\{location}
@param 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.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::Processor] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::DocumentAI::V1beta3::Processor]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 515
def create_processor request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::CreateProcessorRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.create_processor.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_processor.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.create_processor.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :create_processor, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
delete_processor(request, options = nil) { |response, operation| ... } click to toggle source

Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.

@overload delete_processor(request, options = nil)

Pass arguments to `delete_processor` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload delete_processor(name: nil)

Pass arguments to `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).

@param name [::String]
  Required. The processor resource name to be deleted.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 584
def delete_processor request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DeleteProcessorRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.delete_processor.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_processor.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.delete_processor.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :delete_processor, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
disable_processor(request, options = nil) { |response, operation| ... } click to toggle source

Disables a processor

@overload disable_processor(request, options = nil)

Pass arguments to `disable_processor` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload disable_processor(name: nil)

Pass arguments to `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).

@param name [::String]
  Required. The processor resource name to be disabled.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 722
def disable_processor request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::DisableProcessorRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.disable_processor.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.disable_processor.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.disable_processor.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :disable_processor, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
enable_processor(request, options = nil) { |response, operation| ... } click to toggle source

Enables a processor

@overload enable_processor(request, options = nil)

Pass arguments to `enable_processor` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload enable_processor(name: nil)

Pass arguments to `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).

@param name [::String]
  Required. The processor resource name to be enabled.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 653
def enable_processor request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::EnableProcessorRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.enable_processor.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.enable_processor.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.enable_processor.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :enable_processor, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
fetch_processor_types(request, options = nil) { |response, operation| ... } click to toggle source

Fetches processor types.

@overload fetch_processor_types(request, options = nil)

Pass arguments to `fetch_processor_types` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload fetch_processor_types(parent: nil)

Pass arguments to `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).

@param parent [::String]
  Required. The project of processor type to list.
  Format: projects/\\{project}/locations/\\{location}

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesResponse]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 365
def fetch_processor_types request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::FetchProcessorTypesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.fetch_processor_types.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.fetch_processor_types.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.fetch_processor_types.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :fetch_processor_types, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
list_processors(request, options = nil) { |response, operation| ... } click to toggle source

Lists all processors which belong to this project.

@overload list_processors(request, options = nil)

Pass arguments to `list_processors` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload list_processors(parent: nil, page_size: nil, page_token: nil)

Pass arguments to `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).

@param parent [::String]
  Required. The parent (project and location) which owns this collection of Processors.
  Format: projects/\\{project}/locations/\\{location}
@param 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.
@param page_token [::String]
  We will return the processors sorted by creation time. The page token
  will point to the next processor.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::DocumentAI::V1beta3::Processor>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 441
def list_processors request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ListProcessorsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.list_processors.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "parent" => request.parent
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_processors.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_processors.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :list_processors, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @document_processor_service_stub, :list_processors, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
process_document(request, options = nil) { |response, operation| ... } click to toggle source

Processes a single document.

@overload process_document(request, options = nil)

Pass arguments to `process_document` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::ProcessRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload process_document(inline_document: nil, raw_document: nil, name: nil, document: nil, skip_human_review: nil)

Pass arguments to `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).

@param inline_document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
  An inline document proto.
@param raw_document [::Google::Cloud::DocumentAI::V1beta3::RawDocument, ::Hash]
  A raw document content (bytes).
@param name [::String]
  Required. The processor resource name.
@param document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
  The document payload, the [content] and [mime_type] fields must be set.
@param skip_human_review [::Boolean]
  Whether Human Review feature should be skipped for this request. Default to
  false.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::DocumentAI::V1beta3::ProcessResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Google::Cloud::DocumentAI::V1beta3::ProcessResponse]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 215
def process_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ProcessRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.process_document.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "name" => request.name
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.process_document.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.process_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :process_document, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end
review_document(request, options = nil) { |response, operation| ... } click to toggle source

Send a document for Human Review. The input document should be processed by the specified processor.

@overload review_document(request, options = nil)

Pass arguments to `review_document` via a request object, either of type
{::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest} or an equivalent Hash.

@param 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.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

@overload review_document(inline_document: nil, human_review_config: nil, document: nil, enable_schema_validation: nil, priority: nil)

Pass arguments to `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).

@param inline_document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
  An inline document proto.
@param human_review_config [::String]
  Required. The resource name of the HumanReviewConfig that the document will be
  reviewed with.
@param document [::Google::Cloud::DocumentAI::V1beta3::Document, ::Hash]
  The document that needs human review.
@param enable_schema_validation [::Boolean]
  Whether the validation should be performed on the ad-hoc review request.
@param priority [::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest::Priority]
  The priority of the human review task.

@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::Operation] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::Operation]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/document_ai/v1beta3/document_processor_service/client.rb, line 801
def review_document request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DocumentAI::V1beta3::ReviewDocumentRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  metadata = @config.rpcs.review_document.metadata.to_h

  # Set x-goog-api-client and x-goog-user-project headers
  metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::DocumentAI::V1beta3::VERSION
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {
    "human_review_config" => request.human_review_config
  }
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  metadata[:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.review_document.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.review_document.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @document_processor_service_stub.call_rpc :review_document, request, options: options do |response, operation|
    response = ::Gapic::Operation.new response, @operations_client, options: options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end