diff --git a/document-ai/batch_parse_form.js b/document-ai/batch_parse_form.js index 242c1c9742..4812d4a926 100644 --- a/document-ai/batch_parse_form.js +++ b/document-ai/batch_parse_form.js @@ -19,6 +19,7 @@ const uuid = require('uuid'); async function main( projectId = 'YOUR_PROJECT_ID', + location = 'YOUR_PROJECT_LOCATION', gcsOutputUri = 'output-bucket', gcsOutputUriPrefix = uuid.v4(), gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' @@ -28,6 +29,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsOutputUri = 'YOUR_STORAGE_BUCKET'; // const gcsOutputUriPrefix = 'YOUR_STORAGE_PREFIX'; // const gcsInputUri = 'GCS URI of the PDF to process'; @@ -42,7 +44,7 @@ async function main( const storage = new Storage(); async function parseFormGCS(inputUri, outputUri, outputUriPrefix) { - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; // Configure the batch process request. const request = { diff --git a/document-ai/batch_parse_table.js b/document-ai/batch_parse_table.js index 028cc1343f..98136962f3 100644 --- a/document-ai/batch_parse_table.js +++ b/document-ai/batch_parse_table.js @@ -19,6 +19,7 @@ const uuid = require('uuid'); async function main( projectId = 'YOUR_PROJECT_ID', + location = 'YOUR_PROJECT_LOCATION', gcsOutputUri = 'output-bucket', gcsOutputUriPrefix = uuid.v4(), gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' @@ -28,6 +29,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsOutputUri = 'YOUR_STORAGE_BUCKET'; // const gcsOutputUriPrefix = 'YOUR_STORAGE_PREFIX'; // const gcsInputUri = 'YOUR_SOURCE_PDF'; @@ -42,7 +44,7 @@ async function main( const storage = new Storage(); async function parseTableGCS(inputUri, outputUri, outputUriPrefix) { - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; // Configure the batch process request. const request = { diff --git a/document-ai/parse_form.js b/document-ai/parse_form.js index edac82f810..72e27d3c44 100644 --- a/document-ai/parse_form.js +++ b/document-ai/parse_form.js @@ -15,13 +15,9 @@ 'use strict'; -/** - * Process a single PDF as a form. - * @param {string} projectId your Google Cloud project ID - * @param {string} gcsInputUri Cloud Storage URI of the PDF document to parse - */ async function main( projectId, + location, gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' ) { // [START documentai_parse_form] @@ -29,6 +25,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsInputUri = 'YOUR_SOURCE_PDF'; const { @@ -38,7 +35,7 @@ async function main( async function parseForm() { // Configure the request for processing the PDF - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; const request = { parent, inputConfig: { diff --git a/document-ai/parse_table.js b/document-ai/parse_table.js index b8059357a4..d368ca869c 100644 --- a/document-ai/parse_table.js +++ b/document-ai/parse_table.js @@ -15,13 +15,9 @@ 'use strict'; -/** - * Process a single PDF. - * @param {string} projectId your Google Cloud project ID - * @param {string} gcsInputUri Cloud Storage URI of the PDF document to parse - */ async function main( projectId, + location, gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' ) { // [START documentai_parse_table] @@ -29,6 +25,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsInputUri = 'YOUR_SOURCE_PDF'; const { @@ -38,7 +35,7 @@ async function main( async function parseTable() { // Configure the request for processing the PDF - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; const request = { parent, inputConfig: { diff --git a/document-ai/parse_with_model.js b/document-ai/parse_with_model.js index 08c99a5252..3285756159 100644 --- a/document-ai/parse_with_model.js +++ b/document-ai/parse_with_model.js @@ -15,14 +15,9 @@ 'use strict'; -/** - * Process a single PDF. - * @param {string} projectId your Google Cloud project ID - * @param {string} autoMLModel AutoML Natural Language model to use - * @param {string} gcsInputUri Cloud Storage URI of the PDF document to parse - */ async function main( projectId, + location, autoMLModel, gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' ) { @@ -31,6 +26,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const autoMLModel = 'Full resource name of AutoML Natural Language model'; // const gcsInputUri = 'YOUR_SOURCE_PDF'; @@ -41,7 +37,7 @@ async function main( async function parseWithModel() { // Configure the request for processing the PDF - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; const request = { parent, inputConfig: { diff --git a/document-ai/quickstart.js b/document-ai/quickstart.js index 9741973141..4ac5bf6699 100644 --- a/document-ai/quickstart.js +++ b/document-ai/quickstart.js @@ -15,13 +15,9 @@ 'use strict'; -/** - * Process a single PDF. - * @param {string} projectId your Google Cloud project ID - * @param {string} gcsInputUri Cloud Storage URI of the PDF document to parse - */ async function main( projectId, + location, gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' ) { // [START documentai_quickstart] @@ -29,6 +25,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsInputUri = 'YOUR_SOURCE_PDF'; const { @@ -38,7 +35,7 @@ async function main( async function quickstart() { // Configure the request for processing the PDF - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; const request = { parent, inputConfig: { diff --git a/document-ai/set_endpoint.js b/document-ai/set_endpoint.js index d47f64e76d..fef1ff80d9 100644 --- a/document-ai/set_endpoint.js +++ b/document-ai/set_endpoint.js @@ -15,13 +15,9 @@ 'use strict'; -/** - * Process a single PDF. - * @param {string} projectId your Google Cloud project ID - * @param {string} gcsInputUri Cloud Storage URI of the PDF document to parse - */ async function main( projectId, + location = 'eu', gcsInputUri = 'gs://cloud-samples-data/documentai/invoice.pdf' ) { // [START documentai_set_endpoint] @@ -29,6 +25,7 @@ async function main( * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' // const gcsInputUri = 'YOUR_SOURCE_PDF'; const { @@ -41,7 +38,7 @@ async function main( async function setEndpoint() { // Configure the request for processing the PDF - const parent = `projects/${projectId}`; + const parent = `projects/${projectId}/locations/${location}`; const request = { parent, inputConfig: { diff --git a/document-ai/test/batch_parse_form.test.js b/document-ai/test/batch_parse_form.test.js index 55bf7a088f..9c8b57e973 100644 --- a/document-ai/test/batch_parse_form.test.js +++ b/document-ai/test/batch_parse_form.test.js @@ -28,6 +28,7 @@ const cmd = 'node batch_parse_form.js'; const testParseForm = { projectId: process.env.GCLOUD_PROJECT, + location: 'us', gcsOutputUriPrefix: uuid.v4(), }; @@ -44,7 +45,7 @@ describe('Document AI batch parse form', () => { it('should parse the GCS invoice example as a form', async () => { const output = execSync( - `${cmd} ${testParseForm.projectId} gs://${bucketName}` + `${cmd} ${testParseForm.projectId} ${testParseForm.location} gs://${bucketName}` ); assert.match(output, /Extracted key value pair:/); }); diff --git a/document-ai/test/batch_parse_table.test.js b/document-ai/test/batch_parse_table.test.js index 65b78ba1b3..6844b13557 100644 --- a/document-ai/test/batch_parse_table.test.js +++ b/document-ai/test/batch_parse_table.test.js @@ -28,6 +28,7 @@ const cmd = 'node batch_parse_table.js'; const testParseTable = { projectId: process.env.GCLOUD_PROJECT, + location: 'us', gcsOutputUriPrefix: uuid.v4(), }; @@ -44,7 +45,7 @@ describe('Document AI batch parse table', () => { it('should parse the GCS invoice example as as table', async () => { const output = execSync( - `${cmd} ${testParseTable.projectId} gs://${bucketName}` + `${cmd} ${testParseTable.projectId} ${testParseTable.location} gs://${bucketName}` ); assert.match(output, /First detected language:/); }); diff --git a/document-ai/test/parse_form.test.js b/document-ai/test/parse_form.test.js index 4108a23f2c..8052ceb632 100644 --- a/document-ai/test/parse_form.test.js +++ b/document-ai/test/parse_form.test.js @@ -23,10 +23,11 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; +const LOCATION = 'us'; describe('Document AI parse form', () => { it('should parse the GCS invoice example as a form', async () => { - const stdout = execSync(`node ./parse_form.js ${projectId}`, { + const stdout = execSync(`node ./parse_form.js ${projectId} ${LOCATION}`, { cwd, }); assert.match(stdout, /Extracted key value pair:/); diff --git a/document-ai/test/parse_table.test.js b/document-ai/test/parse_table.test.js index fcace94dee..060e825f4d 100644 --- a/document-ai/test/parse_table.test.js +++ b/document-ai/test/parse_table.test.js @@ -23,10 +23,11 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; +const LOCATION = 'us'; describe('Document AI parse table', () => { it('should parse the GCS invoice example as as table', async () => { - const stdout = execSync(`node ./parse_table.js ${projectId}`, { + const stdout = execSync(`node ./parse_table.js ${projectId} ${LOCATION}`, { cwd, }); assert.match(stdout, /Header row/); diff --git a/document-ai/test/parse_with_model.test.js b/document-ai/test/parse_with_model.test.js index b976bda61a..a2f0afed65 100644 --- a/document-ai/test/parse_with_model.test.js +++ b/document-ai/test/parse_with_model.test.js @@ -23,6 +23,7 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; +const LOCATION = 'us'; const MODEL_NAME = process.env.MODEL_NAME || 'projects/1046198160504/locations/us-central1/models/TCN7483069430457434112'; @@ -30,7 +31,7 @@ const MODEL_NAME = describe('Document AI parse with AutoML model', () => { it('should run use an AutoML model to parse a PDF', async () => { const stdout = execSync( - `node ./parse_with_model.js ${projectId} ${MODEL_NAME}`, + `node ./parse_with_model.js ${projectId} ${LOCATION} ${MODEL_NAME}`, { cwd, } diff --git a/document-ai/test/quickstart.test.js b/document-ai/test/quickstart.test.js index 63c2285ba6..8a44c2d6c8 100644 --- a/document-ai/test/quickstart.test.js +++ b/document-ai/test/quickstart.test.js @@ -23,10 +23,11 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; +const LOCATION = 'us'; describe('Quickstart', () => { it('should run quickstart', async () => { - const stdout = execSync(`node ./quickstart.js ${projectId}`, { + const stdout = execSync(`node ./quickstart.js ${projectId} ${LOCATION}`, { cwd, }); assert.match(stdout, /Entity/); diff --git a/document-ai/test/set_endpoint.test.js b/document-ai/test/set_endpoint.test.js index 92c96a11c5..f8b52acdcd 100644 --- a/document-ai/test/set_endpoint.test.js +++ b/document-ai/test/set_endpoint.test.js @@ -23,10 +23,11 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); const projectId = process.env.GCLOUD_PROJECT; +const LOCATION = 'eu'; describe('Document AI set endpoint', () => { it('should process a PDF in another region', async () => { - const stdout = execSync(`node ./set_endpoint.js ${projectId}`, { + const stdout = execSync(`node ./set_endpoint.js ${projectId} ${LOCATION}`, { cwd, }); assert.match(stdout, /Entity/);