Skip to content

Commit 79cbb09

Browse files
telpirionAce Nassri
authored andcommitted
samples: updates v1beta3 to v1; renames v1beta2 samples (#198)
1 parent 9123754 commit 79cbb09

17 files changed

+48
-37
lines changed
File renamed without changes.

document-ai/batch_parse_table.js renamed to document-ai/batch-parse-table.v1beta2.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ async function main(
123123
const [headerRow] = table.headerRows;
124124

125125
console.log('Results from first table processed:');
126-
console.log(
127-
`First detected language: ${page1.detectedLanguages[0].languageCode}`
128-
);
129126

130127
console.log('Header row:');
131128
for (const tableCell of headerRow.cells) {

document-ai/batch-process-document.v1beta3.js renamed to document-ai/batch-process-document.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function main(
3939
// Imports the Google Cloud client library
4040
const {
4141
DocumentProcessorServiceClient,
42-
} = require('@google-cloud/documentai').v1beta3;
42+
} = require('@google-cloud/documentai').v1;
4343
const {Storage} = require('@google-cloud/storage');
4444

4545
// Instantiates Document AI, Storage clients
@@ -54,14 +54,20 @@ async function main(
5454
// Configure the batch process request.
5555
const request = {
5656
name,
57-
inputConfigs: [
58-
{
59-
gcsSource: gcsInputUri,
60-
mimeType: 'application/pdf',
57+
inputDocuments: {
58+
gcsDocuments: {
59+
documents: [
60+
{
61+
gcsUri: gcsInputUri,
62+
mimeType: 'application/pdf',
63+
},
64+
],
65+
},
66+
},
67+
documentOutputConfig: {
68+
gcsOutputConfig: {
69+
gcsUri: `${gcsOutputUri}/${gcsOutputUriPrefix}/`,
6170
},
62-
],
63-
outputConfig: {
64-
gcsDestination: `${gcsOutputUri}/${gcsOutputUriPrefix}/`,
6571
},
6672
};
6773

@@ -73,7 +79,6 @@ async function main(
7379

7480
// Wait for operation to complete.
7581
await operation.promise();
76-
7782
console.log('Document processing complete.');
7883

7984
// Query Storage bucket for the results file(s).
File renamed without changes.
File renamed without changes.
File renamed without changes.

document-ai/process-document.v1beta3.js renamed to document-ai/process-document.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function main(projectId, location, processorId, filePath) {
2727

2828
const {
2929
DocumentProcessorServiceClient,
30-
} = require('@google-cloud/documentai').v1beta3;
30+
} = require('@google-cloud/documentai').v1;
3131

3232
// Instantiates a client
3333
const client = new DocumentProcessorServiceClient();
@@ -47,7 +47,7 @@ async function main(projectId, location, processorId, filePath) {
4747

4848
const request = {
4949
name,
50-
document: {
50+
rawDocument: {
5151
content: encodedImage,
5252
mimeType: 'application/pdf',
5353
},

document-ai/quickstart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function main(projectId, location, processorId, filePath) {
2727

2828
const {
2929
DocumentProcessorServiceClient,
30-
} = require('@google-cloud/documentai').v1beta3;
30+
} = require('@google-cloud/documentai').v1;
3131

3232
// Instantiates a client
3333
const client = new DocumentProcessorServiceClient();
@@ -47,7 +47,7 @@ async function main(projectId, location, processorId, filePath) {
4747

4848
const request = {
4949
name,
50-
document: {
50+
rawDocument: {
5151
content: encodedImage,
5252
mimeType: 'application/pdf',
5353
},
File renamed without changes.

document-ai/test/batch_parse_form.test.js renamed to document-ai/test/batch-parse-form.v1beta2.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2424

2525
const storage = new Storage();
2626
const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;
27-
const cmd = 'node batch_parse_form.js';
27+
const cmd = 'node batch-parse-form.v1beta2.js';
2828

2929
const testParseForm = {
3030
projectId: process.env.GCLOUD_PROJECT,
3131
location: 'us',
3232
gcsOutputUriPrefix: uuid.v4(),
3333
};
3434

35-
describe('Document AI batch parse form', () => {
35+
describe('Document AI batch parse form (v1beta2)', () => {
3636
before(async () => {
3737
await storage.createBucket(bucketName);
3838
});

0 commit comments

Comments
 (0)