### Example: Get Processor Details in Node.js Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Demonstrates how to get processor details using the Document AI Node.js client library. Ensure the processor name is correctly set and the library is installed. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The processor resource name. */ // const name = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callGetProcessor() { // Construct request const request = { name, }; // Run request const response = await documentaiClient.getProcessor(request); console.log(response); } callGetProcessor(); ``` -------------------------------- ### Get Processor Details with Node.js Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Fetches details for a specific processor. This example requires the '@google-cloud/documentai' library and instantiates a client. Ensure the 'name' variable is correctly set. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The processor resource name. */ // const name = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callGetProcessor() { // Construct request const request = { name, }; // Run request const response = await documentaiClient.getProcessor(request); console.log(response); } callGetProcessor(); ``` -------------------------------- ### Example: Get Operation using Document AI Client Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Example of how to retrieve a long-running operation using the operationsClient. Requires a valid operation name. ```javascript const client = longrunning.operationsClient(); const name = ''; const [response] = await client.getOperation({name}); // doThingsWith(response) ``` -------------------------------- ### Create Processor Example Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Example of how to create a Document AI processor. Ensure you have the correct values for `parent` and `processor` before running. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The parent (project and location) under which to create the * processor. Format: `projects/{project}/locations/{location}` */ // const parent = 'abc123' /** * Required. The processor to be created, requires * Processor.type google.cloud.documentai.v1beta3.Processor.type and * Processor.display_name google.cloud.documentai.v1beta3.Processor.display_name * to be set. Also, the * Processor.kms_key_name google.cloud.documentai.v1beta3.Processor.kms_key_name * field must be set if the processor is under CMEK. */ // const processor = {} // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callCreateProcessor() { // Construct request const request = { parent, processor, }; // Run request const response = await documentaiClient.createProcessor(request); console.log(response); } callCreateProcessor(); ``` -------------------------------- ### Install Cloud Document AI Node.js Client Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest Install the client library using npm. This is the first step to using the Document AI API in your Node.js applications. ```bash npm install @google-cloud/documentai ``` -------------------------------- ### Import Processor Version Node.js Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Imports a processor version into Document AI. Ensure the client library is installed and authenticated. This example requires the `parent` variable to be set to the destination processor's resource name. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * The source processor version to import from. The source processor version * and destination processor need to be in the same environment and region. */ // const processorVersionSource = 'abc123' /** * The source processor version to import from. It can be from a different * environment and region than the destination processor. */ // const externalProcessorVersionSource = {} /** * Required. The destination processor name to create the processor version * in. Format: * `projects/{project}/locations/{location}/processors/{processor}` */ // const parent = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callImportProcessorVersion() { // Construct request const request = { parent, }; // Run request const [operation] = await documentaiClient.importProcessorVersion(request); const [response] = await operation.promise(); console.log(response); } callImportProcessorVersion(); ``` -------------------------------- ### Undeploy Processor Version Example Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Example of how to undeploy a Document AI processor version using the Node.js client library. Ensure the 'name' variable is correctly set to the processor version resource name. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The processor version resource name to be undeployed. */ // const name = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callUndeployProcessorVersion() { // Construct request const request = { name, }; // Run request const [operation] = await documentaiClient.undeployProcessorVersion(request); const [response] = await operation.promise(); console.log(response); } callUndeployProcessorVersion(); ``` -------------------------------- ### Get location information Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Retrieve information about a specific Google Cloud location. This example uses an async/await pattern. ```javascript const [response] = await client.getLocation(request); ``` -------------------------------- ### Example: List Processor Types Async Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Demonstrates how to use `listProcessorTypesAsync` to iterate through processor types. Ensure correct request parameters and client instantiation. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The location of processor types to list. * Format: `projects/{project}/locations/{location}`. */ // const parent = 'abc123' /** * The maximum number of processor types to return. * If unspecified, at most `100` processor types will be returned. * The maximum value is `500`. Values above `500` will be coerced to `500`. */ // const pageSize = 1234 /** * Used to retrieve the next page of results, empty if at the end of the list. */ // const pageToken = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callListProcessorTypes() { // Construct request const request = { parent, }; // Run request const iterable = documentaiClient.listProcessorTypesAsync(request); for await (const response of iterable) { console.log(response); } } callListProcessorTypes(); ``` -------------------------------- ### Example: List Processor Types Async Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Demonstrates how to use `listProcessorTypesAsync` to retrieve and log processor types. Ensure the `parent` variable is correctly set to your project and location. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The location of processor types to list. * Format: `projects/{project}/locations/{location}`. */ // const parent = 'abc123' /** * The maximum number of processor types to return. * If unspecified, at most `100` processor types will be returned. * The maximum value is `500`. Values above `500` will be coerced to `500`. */ // const pageSize = 1234 /** * Used to retrieve the next page of results, empty if at the end of the list. */ // const pageToken = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callListProcessorTypes() { // Construct request const request = { parent, }; // Run request const iterable = documentaiClient.listProcessorTypesAsync(request); for await (const response of iterable) { console.log(response); } } callListProcessorTypes(); ``` -------------------------------- ### Review Document Node.js Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Submits a document for human review in Document AI. This example requires the `humanReviewConfig` variable to be set to the HumanReviewConfig resource name. Ensure the client library is installed and authenticated. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * An inline document proto. */ // const inlineDocument = {} /** * Required. The resource name of the * HumanReviewConfig google.cloud.documentai.v1beta3.HumanReviewConfig that * the document will be reviewed with. */ // const humanReviewConfig = 'abc123' /** * The document that needs human review. */ // const document = {} /** * Whether the validation should be performed on the ad-hoc review request. */ // const enableSchemaValidation = true /** * The priority of the human review task. */ // const priority = {} /** * The document schema of the human review task. */ // const documentSchema = {} // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callReviewDocument() { // Construct request const request = { humanReviewConfig, }; // Run request const [operation] = await documentaiClient.reviewDocument(request); const [response] = await operation.promise(); console.log(response); } callReviewDocument(); ``` -------------------------------- ### Instantiate Publishing Class Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.api.publishing Constructs a new Publishing instance. Use this to initialize a Publishing object with specific properties. ```typescript constructor(properties?: google.api.IPublishing); ``` -------------------------------- ### Process a single document using Document AI Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Use this method to process a single document with Document AI. Ensure you have the Document AI library installed and properly configured. The example includes placeholders for request parameters that need to be defined. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * An inline document proto. */ // const inlineDocument = {} /** * A raw document content (bytes). */ // const rawDocument = {} /** * A raw document on Google Cloud Storage. */ // const gcsDocument = {} /** * Required. 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}` */ // const name = 'abc123' /** * Whether human review should be skipped for this request. Default to * `false`. */ // const skipHumanReview = true /** * Specifies which fields to include in the * ProcessResponse.document google.cloud.documentai.v1.ProcessResponse.document * output. Only supports top-level document and pages field, so it must be in * the form of `{document_field_name}` or `pages.{page_field_name}`. */ // const fieldMask = {} /** * Inference-time options for the process API */ // const processOptions = {} /** * Optional. The labels with user-defined metadata for the request. * Label keys and values can be no longer than 63 characters * (Unicode codepoints) and can only contain lowercase letters, numeric * characters, underscores, and dashes. International characters are allowed. * Label values are optional. Label keys must start with a letter. */ // const labels = [1,2,3,4] /** * Optional. Option to remove images from the document. */ // const imagelessMode = true // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callProcessDocument() { // Construct request const request = { name, }; // Run request const response = await documentaiClient.processDocument(request); console.log(response); } callProcessDocument(); ``` -------------------------------- ### Batch Process Documents with Document AI Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Initiates a batch process for documents using the Document AI API. Ensure the 'name' variable is correctly set to your processor or processor version resource name. This example requires the `@google-cloud/documentai` library to be installed. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The resource name of * Processor google.cloud.documentai.v1beta3.Processor or * ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion. * Format: `projects/{project}/locations/{location}/processors/{processor}`, * or * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` */ // const name = 'abc123' /** * The input config for each single document in the batch process. */ // const inputConfigs = [1,2,3,4] /** * The overall output config for batch process. */ // const outputConfig = {} /** * The input documents for the * BatchProcessDocuments google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments * method. */ // const inputDocuments = {} /** * The output configuration for the * BatchProcessDocuments google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments * method. */ // const documentOutputConfig = {} /** * Whether human review should be skipped for this request. Default to * `false`. */ // const skipHumanReview = true /** * Inference-time options for the process API */ // const processOptions = {} /** * Optional. The labels with user-defined metadata for the request. * Label keys and values can be no longer than 63 characters * (Unicode codepoints) and can only contain lowercase letters, numeric * characters, underscores, and dashes. International characters are allowed. * Label values are optional. Label keys must start with a letter. */ // const labels = [1,2,3,4] // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callBatchProcessDocuments() { // Construct request const request = { name, }; // Run request const [operation] = await documentaiClient.batchProcessDocuments(request); const [response] = await operation.promise(); console.log(response); } callBatchProcessDocuments(); ``` -------------------------------- ### VisualElement Constructor Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1.document.page.visualelement?hl=de Details on how to construct a new VisualElement instance. ```APIDOC ## Constructors ### (constructor)(properties) Constructs a new VisualElement. #### Parameters - **properties** (IVisualElement) - Optional - Properties to set ``` -------------------------------- ### Get Operation Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Gets the status of an asynchronous operation. ```APIDOC ## GET /v1/{name=projects/*/locations/*/operations/*} ### Description Gets the status of a long-running operation. ### Method GET ### Endpoint `/v1/{name=projects/*/locations/*/operations/*}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation resource. ### Response #### Success Response (200) - **name** (string) - The name of the operation. - **done** (boolean) - Whether the operation is done. - **response** (object) - The response of the operation if done. - **error** (object) - The error result if the operation failed. #### Response Example ```json { "name": "projects/123456789/locations/us/operations/ABCDEFG123456789", "done": true, "response": { "@type": "type.googleapis.com/google.cloud.documentai.v1.BatchProcessResponse", "outputConfig": { "gcsDestination": { "uri": "gs://cloud-samples-data/documentai/output/" } } } } ``` ``` -------------------------------- ### Instantiate StyleInfo Class (TypeScript) Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1beta3.document.page.token.styleinfo Constructs a new StyleInfo instance. Use this to create a StyleInfo object with specified properties. ```typescript constructor(properties?: google.cloud.documentai.v1beta3.Document.Page.Token.IStyleInfo); ``` -------------------------------- ### Get Evaluation Request Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/overview.html Request to get an evaluation. ```APIDOC ## protos.google.cloud.documentai.v1beta3.GetEvaluationRequest ### Description Represents a GetEvaluationRequest. #### Request Body - **name** (string) - Required - The name of the evaluation to retrieve. ``` -------------------------------- ### Get Dataset Schema Request Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/overview.html Request to get the dataset schema. ```APIDOC ## protos.google.cloud.documentai.v1beta3.GetDatasetSchemaRequest ### Description Represents a GetDatasetSchemaRequest. #### Request Body - **name** (string) - Required - The name of the dataset schema to retrieve. ``` -------------------------------- ### Initialize Client Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Initializes the Document AI client, performing necessary asynchronous setup like authentication. This can be called directly or will be invoked automatically on the first method call. ```typescript initialize(): Promise<{ [name: string]: Function; }>; ``` -------------------------------- ### Get Metadata Type URL Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1.documentschema.metadata?hl=zh-cn Gets the default type URL for Metadata. ```APIDOC ## GET /getTypeUrl ### Description Gets the default type url for Metadata. ### Method GET ### Endpoint /getTypeUrl ### Parameters #### Path Parameters None #### Query Parameters - **typeUrlPrefix** (string) - Optional - Your custom typeUrlPrefix (default "type.googleapis.com") ### Request Example ```json { "typeUrlPrefix": "type.googleapis.com" } ``` ### Response #### Success Response (200) - **string** - The default type url. #### Response Example ```json { "typeUrl": "type.googleapis.com/google.cloud.documentai.v1.DocumentSchema.Metadata" } ``` ``` -------------------------------- ### Instantiate StyleInfo Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1.document.page.token.styleinfo?hl=es-419 Constructs a new StyleInfo instance. Use this to create a StyleInfo object with specific properties. ```typescript constructor(properties?: google.cloud.documentai.v1.Document.Page.Token.IStyleInfo); ``` -------------------------------- ### GET /v1beta3/operations/{operationId} Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Gets the latest state of a long-running operation. This method can be used to poll the operation result at intervals. ```APIDOC ## GET /v1beta3/operations/{operationId} ### Description Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. ### Method GET ### Endpoint /v1beta3/operations/{operationId} ### Parameters #### Path Parameters - **operationId** (string) - Required - The ID of the operation to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```javascript const client = longrunning.operationsClient(); const name = ''; // Replace with the operation name const [response] = await client.getOperation({name}); // doThingsWith(response) ``` ### Response #### Success Response (200) - **Operation** (object) - Represents the latest state of a long-running operation. #### Response Example ```json { "name": "operations/12345", "metadata": { ... }, "done": false, "response": { ... } } ``` ``` -------------------------------- ### List Processor Versions (Callback with Options) Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Lists all versions of a processor using a callback function. This overload includes CallOptions. ```APIDOC ## POST /websites/cloud_google_nodejs_reference_documentai/listProcessorVersions ### Description Lists all versions of a processor using a callback function. This overload includes CallOptions. ### Method POST ### Endpoint /websites/cloud_google_nodejs_reference_documentai/listProcessorVersions ### Parameters #### Query Parameters - **request** (protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest) - Required - The request object that will be sent. - **options** (CallOptions) - Required - Call options. See CallOptions for more details. - **callback** (PaginationCallback) - Required - The callback function to handle the response. ### Response #### Success Response (200) - **void** - The operation does not return a value directly; results are handled by the callback. ### Request Example ```json { "example": "request body for listProcessorVersions with callback and options" } ``` ### Response Example ```json { "example": "callback response handling" } ``` -------------------------------- ### Get Processor Version (Callback, Simplified) Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient A simplified callback-based signature for getting a processor version. This version omits the options parameter. ```typescript getProcessorVersion(request: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, callback: Callback): void; ``` -------------------------------- ### Instantiate RubySettings Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.api.rubysettings?hl=fr Constructs a new RubySettings instance. Use this to initialize settings with specific properties. ```typescript constructor(properties?: google.api.IRubySettings); ``` -------------------------------- ### Import Processor Version using Promise Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Imports a processor version from a source processor version using a promise-based approach. Ensure the source and destination processors are in the same environment and region. Requires initialization of the Documentai library and client. ```javascript importProcessorVersion(request?: protos.google.cloud.documentai.v1beta3.IImportProcessorVersionRequest, options?: CallOptions): Promise<[ LROperation, protos.google.longrunning.IOperation | undefined, {} | undefined ]>; ``` ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * The source processor version to import from. The source processor version * and destination processor need to be in the same environment and region. */ // const processorVersionSource = 'abc123' /** * The source processor version to import from. It can be from a different * environment and region than the destination processor. */ // const externalProcessorVersionSource = {} /** * Required. The destination processor name to create the processor version * in. Format: * `projects/{project}/locations/{location}/processors/{processor}` */ // const parent = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callImportProcessorVersion() { // Construct request const request = { parent, }; // Run request const [operation] = await documentaiClient.importProcessorVersion(request); const [response] = await operation.promise(); console.log(response); } callImportProcessorVersion(); ``` -------------------------------- ### GET /v1beta3/projects/{projectId}/locations/{locationId}/processors/{processorId}/processorVersions/{processorVersionId} Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Gets a processor version detail. This method retrieves detailed information about a specific version of a Document AI processor. ```APIDOC ## GET /v1beta3/projects/{projectId}/locations/{locationId}/processors/{processorId}/processorVersions/{processorVersionId} ### Description Gets a processor version detail. This method retrieves detailed information about a specific version of a Document AI processor. ### Method GET ### Endpoint /v1beta3/projects/{projectId}/locations/{locationId}/processors/{processorId}/processorVersions/{processorVersionId} ### Parameters #### Path Parameters - **name** (string) - Required - The processor resource name. Example: `projects/123/locations/us/processors/456/processorVersions/789` ### Request Example ```javascript // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callGetProcessorVersion() { // Construct request const request = { name: 'projects/my-project/locations/us/processors/my-processor/processorVersions/my-version', }; // Run request const response = await documentaiClient.getProcessorVersion(request); console.log(response); } callGetProcessorVersion(); ``` ### Response #### Success Response (200) - **processorVersion** (object) - The processor version details. - **name** (string) - The resource name of the processor version. - **type** (string) - The type of the processor version. - **createTime** (string) - The time when the processor version was created. - **updateTime** (string) - The time when the processor version was last updated. - **state** (string) - The state of the processor version. #### Response Example ```json { "processorVersion": { "name": "projects/123/locations/us/processors/456/processorVersions/789", "type": "FORM_PARSER", "createTime": "2023-10-27T10:00:00Z", "updateTime": "2023-10-27T10:00:00Z", "state": "DEPLOYED" } } ``` ``` -------------------------------- ### GET /v1/projects/{projectId}/locations/{locationId}/processorTypes/{processorTypeId} Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Retrieves a specific processor type's details. This method allows you to get information about a particular type of processor available in Document AI. ```APIDOC ## GET /v1/projects/{projectId}/locations/{locationId}/processorTypes/{processorTypeId} ### Description Retrieves a specific processor type's details. This method allows you to get information about a particular type of processor available in Document AI. ### Method GET ### Endpoint /v1/projects/{projectId}/locations/{locationId}/processorTypes/{processorTypeId} ### Parameters #### Path Parameters - **projectId** (string) - Required - The Google Cloud project ID. - **locationId** (string) - Required - The location ID for the processor type. - **processorTypeId** (string) - Required - The ID of the processor type to retrieve. ### Request Example ```javascript // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callGetProcessorType() { const projectId = 'your-project-id'; const locationId = 'us'; const processorTypeId = 'FORM_PARSER'; // Example processor type ID const formattedName = documentaiClient.processorTypePath(projectId, locationId, processorTypeId); const request = { name: formattedName, }; // Run request const response = await documentaiClient.getProcessorType(request); console.log(response); } callGetProcessorType(); ``` ### Response #### Success Response (200) - **name** (string) - The resource name of the processor type. - **displayName** (string) - The display name of the processor type. - **allowCreation** (boolean) - Whether this processor type allows creation of new processors. #### Response Example ```json { "name": "projects/123456789/locations/us/processorTypes/FORM_PARSER", "displayName": "Form Parser", "allowCreation": true } ``` ``` -------------------------------- ### Initialize Client Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Initializes the Document AI client. This method performs asynchronous operations like authentication and prepares the client for use. It can be called automatically or explicitly. ```APIDOC ## POST /initialize ### Description Initializes the client. Performs asynchronous operations (such as authentication) and prepares the client. ### Method POST ### Endpoint /initialize ### Parameters None ### Request Example None ### Response #### Success Response (200) - **stub** (object) - An authenticated service stub. #### Response Example ```json { "someMethod": function() { ... }, "anotherMethod": function() { ... } } ``` ``` -------------------------------- ### Processor Management - createProcessor() Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Creates a new processor. This method requires the `documentai.processors.create` permission. ```APIDOC ## createProcessor(request, options) ### Description Creates a processor from the provided request. The processor will be in the `ENABLED` state by default after its creation. Note that this method requires the `documentai.processors.create` permission on the project, which is highly privileged. A user or service account with this permission can create new processors that can interact with any gcs bucket in your project. ### Method `createProcessor(request?: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, options?: CallOptions): Promise<[ protos.google.cloud.documentai.v1beta3.IProcessor, protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest | undefined, {} | undefined ]>` ### Parameters #### Request Body - **request** (`ICreateProcessorRequest`) - Required - The request object that will be sent. - **options** (`CallOptions`) - Optional - Call options. See CallOptions for more details. ### Request Example ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The parent (project and location) under which to create the * processor. Format: `projects/{project}/locations/{location}` */ // const parent = 'abc123' /** * Required. The processor to be created, requires * Processor.type google.cloud.documentai.v1beta3.Processor.type and * Processor.display_name google.cloud.documentai.v1beta3.Processor.display_name * to be set. Also, the * Processor.kms_key_name google.cloud.documentai.v1beta3.Processor.kms_key_name * field must be set if the processor is under CMEK. */ // const processor = {} // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callCreateProcessor() { // Construct request const request = { parent, processor, }; // Run request const response = await documentaiClient.createProcessor(request); console.log(response); } callCreateProcessor(); ``` ### Response #### Success Response (200) - **`IProcessor`** - Represents the created processor. - **`ICreateProcessorRequest | undefined`** - The request object used. - **`{}` | undefined** - Additional undefined properties. #### Response Example ```json { "example": "response body" } ``` ``` ```APIDOC ## createProcessor(request, options, callback) ### Description Creates a processor using a callback for asynchronous handling. ### Method `createProcessor(request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, options: CallOptions, callback: Callback): void` ### Parameters #### Request Body - **request** (`ICreateProcessorRequest`) - The request object. - **options** (`CallOptions`) - Call options. - **callback** (`Callback<...>`) - The callback function to handle the response. ``` ```APIDOC ## createProcessor(request, callback) ### Description Creates a processor using a callback for asynchronous handling, without explicit options. ### Method `createProcessor(request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, callback: Callback): void` ### Parameters #### Request Body - **request** (`ICreateProcessorRequest`) - The request object. - **callback** (`Callback<...>`) - The callback function to handle the response. ``` -------------------------------- ### Get Processor Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient Retrieves a document processor. ```APIDOC ## GET /v1/projects/{projectId}/locations/{locationId}/processors/{processorId} ### Description Retrieves a document processor. ### Method GET ### Endpoint `/v1/projects/{projectId}/locations/{locationId}/processors/{processorId}` ### Parameters #### Path Parameters - **projectId** (string) - Required - The Google Cloud project ID. - **locationId** (string) - Required - The location of the processor. - **processorId** (string) - Required - The ID of the processor to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the processor. - **displayName** (string) - The display name of the processor. - **type** (string) - The processor type. - **state** (string) - The current state of the processor. #### Response Example ```json { "name": "projects/123456789/locations/us/processors/ABCDEFG123456789", "displayName": "My OCR Processor", "type": "OCR_PROCESSOR", "state": "ENABLED" } ``` ``` -------------------------------- ### Deploy Document AI Processor Version Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1.documentprocessorserviceclient This Node.js snippet demonstrates how to deploy a processor version using the Document AI client library. It requires the processor version's resource name. Ensure the `name` variable is correctly set and uncommented before execution. ```javascript /** * This snippet 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. * TODO(developer): Uncomment these variables before running the sample. */ /** * Required. The processor version resource name to be deployed. */ // const name = 'abc123' // Imports the Documentai library const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; // Instantiates a client const documentaiClient = new DocumentProcessorServiceClient(); async function callDeployProcessorVersion() { // Construct request const request = { name, }; // Run request const [operation] = await documentaiClient.deployProcessorVersion(request); const [response] = await operation.promise(); console.log(response); } callDeployProcessorVersion(); ``` -------------------------------- ### getTypeUrl Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.protobuf.generatedcodeinfo.annotation-class Gets the default type url for Annotation. ```APIDOC ## getTypeUrl(typeUrlPrefix) ### Description Gets the default type url for Annotation. ### Method `static getTypeUrl` ### Parameters #### Parameters - **typeUrlPrefix** (string) - Optional - your custom typeUrlPrefix(default "type.googleapis.com") ### Returns - **string** - The default type url ``` -------------------------------- ### List Processor Versions (Promise) Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/v1beta3.documentprocessorserviceclient Lists all versions of a processor. This method returns a Promise that resolves to an array containing processor versions, request details, and response details. Auto-pagination is enabled by default. ```APIDOC ## POST /websites/cloud_google_nodejs_reference_documentai/listProcessorVersions ### Description Lists all versions of a processor. This method returns a Promise that resolves to an array containing processor versions, request details, and response details. Auto-pagination is enabled by default. ### Method POST ### Endpoint /websites/cloud_google_nodejs_reference_documentai/listProcessorVersions ### Parameters #### Query Parameters - **request** (protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest) - Optional - The request object that will be sent. - **options** (CallOptions) - Optional - Call options. See CallOptions for more details. ### Response #### Success Response (200) - **Promise<[protos.google.cloud.documentai.v1beta3.IProcessorVersion[], protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest | null, protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse]>** - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using `listProcessorVersionsAsync()` method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples. ### Request Example ```json { "example": "request body for listProcessorVersions" } ``` ### Response Example ```json { "example": "response array with processor versions" } ``` -------------------------------- ### RubySettings Class Overview Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.api.rubysettings?hl=ko Provides details about the RubySettings class, its package, constructors, properties, and methods. ```APIDOC ## Class protos.google.api.RubySettings Represents a RubySettings. ### Package @google-cloud/documentai ### Constructors #### (constructor)(properties) Constructs a new RubySettings. **Parameter** --- **Name** | **Description** `properties` | `IRubySettings` - Properties to set ### Properties #### common ```typescript public common?: (google.api.ICommonLanguageSettings|null); ``` RubySettings common. ### Methods #### create(properties) ```typescript public static create(properties?: google.api.IRubySettings): google.api.RubySettings; ``` Creates a new RubySettings instance using the specified properties. **Parameter** --- **Name** | **Description** `properties` | `IRubySettings` - Properties to set **Returns** --- **Type** | **Description** `RubySettings` | RubySettings instance #### decode(reader, length) ```typescript public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RubySettings; ``` Decodes a RubySettings message from the specified reader or buffer. **Parameters** --- **Name** | **Description** `reader` | `(Reader|Uint8Array)` - Reader or buffer to decode from `length` | `number` - Message length if known beforehand **Returns** --- **Type** | **Description** `RubySettings` | RubySettings #### decodeDelimited(reader) ```typescript public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RubySettings; ``` Decodes a RubySettings message from the specified reader or buffer, length delimited. **Parameter** --- **Name** | **Description** `reader` | `(Reader|Uint8Array)` - Reader or buffer to decode from **Returns** --- **Type** | **Description** `RubySettings` | RubySettings #### encode(message, writer) ```typescript public static encode(message: google.api.IRubySettings, writer?: $protobuf.Writer): $protobuf.Writer; ``` Encodes the specified RubySettings message. Does not implicitly messages. **Parameters** --- **Name** | **Description** `message` | `IRubySettings` - RubySettings message or plain object to encode `writer` | `$protobuf.Writer` - Writer to encode to **Returns** --- **Type** | **Description** `$protobuf.Writer` | Writer #### encodeDelimited(message, writer) ```typescript public static encodeDelimited(message: google.api.IRubySettings, writer?: $protobuf.Writer): $protobuf.Writer; ``` Encodes the specified RubySettings message, length delimited. Does not implicitly messages. **Parameters** --- **Name** | **Description** `message` | `IRubySettings` - RubySettings message or plain object to encode `writer` | `$protobuf.Writer` - Writer to encode to **Returns** --- **Type** | **Description** `$protobuf.Writer` | Writer #### fromObject(object) ```typescript public static fromObject(object: { [k: string]: any }): google.api.RubySettings; ``` Creates a RubySettings message from a plain object. Also converts values to their respective internal types. **Parameter** --- **Name** | **Description** `object` | `{ [k: string]: any }` - Plain object **Returns** --- **Type** | **Description** `RubySettings` | RubySettings ``` -------------------------------- ### getTypeUrl Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1.evaluation.multiconfidencemetrics-class?hl=ja Gets the default type url for MultiConfidenceMetrics ```APIDOC ## getTypeUrl(typeUrlPrefix) ### Description Gets the default type url for MultiConfidenceMetrics ### Method `public static` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **typeUrlPrefix** (string) - Optional - your custom typeUrlPrefix(default "type.googleapis.com") ### Request Example None ### Response #### Success Response (200) - **Type**: `string` - The default type url #### Response Example None ``` -------------------------------- ### getTypeUrl Source: https://docs.cloud.google.com/nodejs/docs/reference/documentai/latest/documentai/protos.google.cloud.documentai.v1.documentoutputconfig.gcsoutputconfig-class Gets the default type url for GcsOutputConfig. ```APIDOC ## getTypeUrl(typeUrlPrefix) ### Description Gets the default type url for GcsOutputConfig. ### Parameters - **typeUrlPrefix** (string) - Optional - Your custom typeUrlPrefix (default "type.googleapis.com") ### Returns - **string** - The default type url ```