Google Cloud Document Ai V1 Client - Class DocumentProcessorServiceClient (1.1.1)

Reference documentation and code samples for the Google Cloud Document Ai V1 Client class DocumentProcessorServiceClient.

Service Description: 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.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$documentProcessorServiceClient = new DocumentProcessorServiceClient();
try {
    $name = 'name';
    $operationResponse = $documentProcessorServiceClient->batchProcessDocuments($name);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $documentProcessorServiceClient->batchProcessDocuments($name);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $documentProcessorServiceClient->resumeOperation($operationName, 'batchProcessDocuments');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $documentProcessorServiceClient->close();
}

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Methods

humanReviewConfigName

Formats a string containing the fully-qualified path to represent a human_review_config resource.

Parameters
NameDescription
project string
location string
processor string
Returns
TypeDescription
stringThe formatted human_review_config resource.

locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

processorName

Formats a string containing the fully-qualified path to represent a processor resource.

Parameters
NameDescription
project string
location string
processor string
Returns
TypeDescription
stringThe formatted processor resource.

processorTypeName

Formats a string containing the fully-qualified path to represent a processor_type resource.

Parameters
NameDescription
project string
location string
processorType string
Returns
TypeDescription
stringThe formatted processor_type resource.

processorVersionName

Formats a string containing the fully-qualified path to represent a processor_version resource.

Parameters
NameDescription
project string
location string
processor string
processorVersion string
Returns
TypeDescription
stringThe formatted processor_version resource.

parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • humanReviewConfig: projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig
  • location: projects/{project}/locations/{location}
  • processor: projects/{project}/locations/{location}/processors/{processor}
  • processorType: projects/{project}/locations/{location}/processorTypes/{processor_type}
  • processorVersion: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

batchProcessDocuments

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

Parameters
NameDescription
name string

Required. The resource name of Processor or ProcessorVersion. Format: projects/{project}/locations/{location}/processors/{processor}, or projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}

optionalArgs array

Optional.

↳ inputDocuments BatchDocumentsInputConfig

The input documents for batch process.

↳ documentOutputConfig DocumentOutputConfig

The overall output config for batch process.

↳ skipHumanReview bool

Whether Human Review feature should be skipped for this request. Default to false.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\BatchProcessResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Rpc\Status;

/**
 * @param string $name The resource name of
 *                     [Processor][google.cloud.documentai.v1.Processor] or
 *                     [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion].
 *                     Format: `projects/{project}/locations/{location}/processors/{processor}`,
 *                     or
 *                     `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
 */
function batch_process_documents_sample(string $name): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->batchProcessDocuments($name);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var BatchProcessResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';

    batch_process_documents_sample($name);
}

createProcessor

Creates a processor from the type processor that the user chose.

The processor will be at "ENABLED" state by default after its creation.

Parameters
NameDescription
parent string

Required. The parent (project and location) under which to create the processor. Format: projects/{project}/locations/{location}

processor Google\Cloud\DocumentAI\V1\Processor

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.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\Processor
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\Processor;

/**
 * @param string $formattedParent The parent (project and location) under which to create the
 *                                processor. Format: `projects/{project}/locations/{location}`
 *                                Please see {@see DocumentProcessorServiceClient::locationName()} for help formatting this field.
 */
function create_processor_sample(string $formattedParent): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $processor = new Processor();

    // Call the API and handle any network failures.
    try {
        /** @var Processor $response */
        $response = $documentProcessorServiceClient->createProcessor($formattedParent, $processor);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = DocumentProcessorServiceClient::locationName('[PROJECT]', '[LOCATION]');

    create_processor_sample($formattedParent);
}

deleteProcessor

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

Parameters
NameDescription
name string

Required. The processor resource name to be deleted.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor resource name to be deleted. Please see
 *                              {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 */
function delete_processor_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->deleteProcessor($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    delete_processor_sample($formattedName);
}

deleteProcessorVersion

Deletes the processor version, all artifacts under the processor version will be deleted.

Parameters
NameDescription
name string

Required. The processor version resource name to be deleted.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor version resource name to be deleted. Please see
 *                              {@see DocumentProcessorServiceClient::processorVersionName()} for help formatting this field.
 */
function delete_processor_version_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->deleteProcessorVersion($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]',
        '[PROCESSOR_VERSION]'
    );

    delete_processor_version_sample($formattedName);
}

deployProcessorVersion

Deploys the processor version.

Parameters
NameDescription
name string

Required. The processor version resource name to be deployed.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DeployProcessorVersionResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor version resource name to be deployed. Please see
 *                              {@see DocumentProcessorServiceClient::processorVersionName()} for help formatting this field.
 */
function deploy_processor_version_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->deployProcessorVersion($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DeployProcessorVersionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]',
        '[PROCESSOR_VERSION]'
    );

    deploy_processor_version_sample($formattedName);
}

disableProcessor

Disables a processor

Parameters
NameDescription
name string

Required. The processor resource name to be disabled.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DisableProcessorResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor resource name to be disabled. Please see
 *                              {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 */
function disable_processor_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->disableProcessor($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DisableProcessorResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    disable_processor_sample($formattedName);
}

enableProcessor

Enables a processor

Parameters
NameDescription
name string

Required. The processor resource name to be enabled.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\EnableProcessorResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor resource name to be enabled. Please see
 *                              {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 */
function enable_processor_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->enableProcessor($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var EnableProcessorResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    enable_processor_sample($formattedName);
}

fetchProcessorTypes

Fetches processor types. Note that we do not use ListProcessorTypes here because it is not paginated.

Parameters
NameDescription
parent string

Required. The project of processor type to list. The available processor types may depend on the allow-listing on projects. Format: projects/{project}/locations/{location}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\FetchProcessorTypesResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\FetchProcessorTypesResponse;

/**
 * @param string $formattedParent The project of processor type to list.
 *                                The available processor types may depend on the allow-listing on projects.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see DocumentProcessorServiceClient::locationName()} for help formatting this field.
 */
function fetch_processor_types_sample(string $formattedParent): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var FetchProcessorTypesResponse $response */
        $response = $documentProcessorServiceClient->fetchProcessorTypes($formattedParent);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = DocumentProcessorServiceClient::locationName('[PROJECT]', '[LOCATION]');

    fetch_processor_types_sample($formattedParent);
}

getProcessor

Gets a processor detail.

Parameters
NameDescription
name string

Required. The processor resource name.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\Processor
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\Processor;

/**
 * @param string $formattedName The processor resource name. Please see
 *                              {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 */
function get_processor_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var Processor $response */
        $response = $documentProcessorServiceClient->getProcessor($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    get_processor_sample($formattedName);
}

getProcessorType

Gets a processor type detail.

Parameters
NameDescription
name string

Required. The processor type resource name.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\ProcessorType
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ProcessorType;

/**
 * @param string $formattedName The processor type resource name. Please see
 *                              {@see DocumentProcessorServiceClient::processorTypeName()} for help formatting this field.
 */
function get_processor_type_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var ProcessorType $response */
        $response = $documentProcessorServiceClient->getProcessorType($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorTypeName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR_TYPE]'
    );

    get_processor_type_sample($formattedName);
}

getProcessorVersion

Gets a processor version detail.

Parameters
NameDescription
name string

Required. The processor resource name.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\ProcessorVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ProcessorVersion;

/**
 * @param string $formattedName The processor resource name. Please see
 *                              {@see DocumentProcessorServiceClient::processorVersionName()} for help formatting this field.
 */
function get_processor_version_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var ProcessorVersion $response */
        $response = $documentProcessorServiceClient->getProcessorVersion($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]',
        '[PROCESSOR_VERSION]'
    );

    get_processor_version_sample($formattedName);
}

listProcessorTypes

Lists the processor types that exist.

Parameters
NameDescription
parent string

Required. The location of processor type to list. The available processor types may depend on the allow-listing on projects. Format: projects/{project}/locations/{location}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ProcessorType;

/**
 * @param string $formattedParent The location of processor type to list.
 *                                The available processor types may depend on the allow-listing on projects.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see DocumentProcessorServiceClient::locationName()} for help formatting this field.
 */
function list_processor_types_sample(string $formattedParent): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $documentProcessorServiceClient->listProcessorTypes($formattedParent);

        /** @var ProcessorType $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = DocumentProcessorServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_processor_types_sample($formattedParent);
}

listProcessorVersions

Lists all versions of a processor.

Parameters
NameDescription
parent string

Required. The parent (project, location and processor) to list all versions. Format: projects/{project}/locations/{location}/processors/{processor}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ProcessorVersion;

/**
 * @param string $formattedParent The parent (project, location and processor) to list all
 *                                versions. Format:
 *                                `projects/{project}/locations/{location}/processors/{processor}`
 *                                Please see {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 */
function list_processor_versions_sample(string $formattedParent): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $documentProcessorServiceClient->listProcessorVersions($formattedParent);

        /** @var ProcessorVersion $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    list_processor_versions_sample($formattedParent);
}

listProcessors

Lists all processors which belong to this project.

Parameters
NameDescription
parent string

Required. The parent (project and location) which owns this collection of Processors. Format: projects/{project}/locations/{location}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\Processor;

/**
 * @param string $formattedParent The parent (project and location) which owns this collection of
 *                                Processors. Format: `projects/{project}/locations/{location}`
 *                                Please see {@see DocumentProcessorServiceClient::locationName()} for help formatting this field.
 */
function list_processors_sample(string $formattedParent): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $documentProcessorServiceClient->listProcessors($formattedParent);

        /** @var Processor $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = DocumentProcessorServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_processors_sample($formattedParent);
}

processDocument

Processes a single document.

Parameters
NameDescription
name string

Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format: projects/{project}/locations/{location}/processors/{processor}, or projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}

optionalArgs array

Optional.

↳ inlineDocument Document

An inline document proto.

↳ rawDocument RawDocument

A raw document content (bytes).

↳ skipHumanReview bool

Whether Human Review feature should be skipped for this request. Default to false.

↳ fieldMask FieldMask

Specifies which fields to include in ProcessResponse's document. Only supports top level document and pages field so it must be in the form of {document_field_name} or pages.{page_field_name}.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\DocumentAI\V1\ProcessResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ProcessResponse;

/**
 * @param string $name The resource name of the
 *                     [Processor][google.cloud.documentai.v1.Processor] or
 *                     [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]
 *                     to use for processing. If a
 *                     [Processor][google.cloud.documentai.v1.Processor] is specified, the server
 *                     will use its [default
 *                     version][google.cloud.documentai.v1.Processor.default_processor_version].
 *                     Format: `projects/{project}/locations/{location}/processors/{processor}`,
 *                     or
 *                     `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
 */
function process_document_sample(string $name): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var ProcessResponse $response */
        $response = $documentProcessorServiceClient->processDocument($name);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';

    process_document_sample($name);
}

reviewDocument

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

Parameters
NameDescription
humanReviewConfig string

Required. The resource name of the HumanReviewConfig that the document will be reviewed with.

optionalArgs array

Optional.

↳ inlineDocument Document

An inline document proto.

↳ enableSchemaValidation bool

Whether the validation should be performed on the ad-hoc review request.

↳ priority int

The priority of the human review task. For allowed values, use constants defined on Google\Cloud\DocumentAI\V1\ReviewDocumentRequest\Priority

↳ documentSchema DocumentSchema

The document schema of the human review task.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\ReviewDocumentResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedHumanReviewConfig The resource name of the HumanReviewConfig that the document will
 *                                           be reviewed with. Please see
 *                                           {@see DocumentProcessorServiceClient::humanReviewConfigName()} for help formatting this field.
 */
function review_document_sample(string $formattedHumanReviewConfig): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->reviewDocument($formattedHumanReviewConfig);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var ReviewDocumentResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedHumanReviewConfig = DocumentProcessorServiceClient::humanReviewConfigName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );

    review_document_sample($formattedHumanReviewConfig);
}

setDefaultProcessorVersion

Set the default (active) version of a Processor that will be used in ProcessDocument and BatchProcessDocuments.

Parameters
NameDescription
processor string

Required. The resource name of the Processor to change default version.

defaultProcessorVersion string

Required. The resource name of child ProcessorVersion to use as default. Format: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\SetDefaultProcessorVersionResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedProcessor               The resource name of the
 *                                                 [Processor][google.cloud.documentai.v1.Processor] to change default
 *                                                 version. Please see
 *                                                 {@see DocumentProcessorServiceClient::processorName()} for help formatting this field.
 * @param string $formattedDefaultProcessorVersion The resource name of child
 *                                                 [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to use as
 *                                                 default. Format:
 *                                                 `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}`
 *                                                 Please see {@see DocumentProcessorServiceClient::processorVersionName()} for help formatting this field.
 */
function set_default_processor_version_sample(
    string $formattedProcessor,
    string $formattedDefaultProcessorVersion
): void {
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->setDefaultProcessorVersion(
            $formattedProcessor,
            $formattedDefaultProcessorVersion
        );
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var SetDefaultProcessorVersionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedProcessor = DocumentProcessorServiceClient::processorName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]'
    );
    $formattedDefaultProcessorVersion = DocumentProcessorServiceClient::processorVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]',
        '[PROCESSOR_VERSION]'
    );

    set_default_processor_version_sample($formattedProcessor, $formattedDefaultProcessorVersion);
}

undeployProcessorVersion

Undeploys the processor version.

Parameters
NameDescription
name string

Required. The processor version resource name to be undeployed.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\DocumentAI\V1\UndeployProcessorVersionResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The processor version resource name to be undeployed. Please see
 *                              {@see DocumentProcessorServiceClient::processorVersionName()} for help formatting this field.
 */
function undeploy_processor_version_sample(string $formattedName): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $documentProcessorServiceClient->undeployProcessorVersion($formattedName);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var UndeployProcessorVersionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = DocumentProcessorServiceClient::processorVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[PROCESSOR]',
        '[PROCESSOR_VERSION]'
    );

    undeploy_processor_version_sample($formattedName);
}

getLocation

Gets information about a location.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

Resource name for the location.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\Location\Location;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function get_location_sample(): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $documentProcessorServiceClient->getLocation();
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

listLocations

Lists information about the supported locations for this service.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

The resource that owns the locations collection, if applicable.

↳ filter string

The standard list filter.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient;
use Google\Cloud\Location\Location;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_locations_sample(): void
{
    // Create a client.
    $documentProcessorServiceClient = new DocumentProcessorServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $documentProcessorServiceClient->listLocations();

        /** @var Location $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

Constants

SERVICE_NAME

Value: 'google.cloud.documentai.v1.DocumentProcessorService'

The name of the service.

SERVICE_ADDRESS

Value: 'documentai.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.