|
16 | 16 | # [START documentai_batch_process_document]
|
17 | 17 | import re
|
18 | 18 |
|
19 |
| -from google.cloud import documentai_v1beta3 as documentai |
| 19 | +from google.cloud import documentai_v1 as documentai |
20 | 20 | from google.cloud import storage
|
21 | 21 |
|
22 | 22 | # TODO(developer): Uncomment these variables before running the sample.
|
@@ -47,23 +47,25 @@ def batch_process_documents(
|
47 | 47 |
|
48 | 48 | destination_uri = f"{gcs_output_uri}/{gcs_output_uri_prefix}/"
|
49 | 49 |
|
| 50 | + gcs_documents = documentai.GcsDocuments( |
| 51 | + documents=[{"gcs_uri": gcs_input_uri, "mime_type": "application/pdf"}] |
| 52 | + ) |
| 53 | + |
50 | 54 | # 'mime_type' can be 'application/pdf', 'image/tiff',
|
51 | 55 | # and 'image/gif', or 'application/json'
|
52 |
| - input_config = documentai.types.document_processor_service.BatchProcessRequest.BatchInputConfig( |
53 |
| - gcs_source=gcs_input_uri, mime_type="application/pdf" |
54 |
| - ) |
| 56 | + input_config = documentai.BatchDocumentsInputConfig(gcs_documents=gcs_documents) |
55 | 57 |
|
56 | 58 | # Where to write results
|
57 |
| - output_config = documentai.types.document_processor_service.BatchProcessRequest.BatchOutputConfig( |
58 |
| - gcs_destination=destination_uri |
| 59 | + output_config = documentai.DocumentOutputConfig( |
| 60 | + gcs_output_config={"gcs_uri": destination_uri} |
59 | 61 | )
|
60 | 62 |
|
61 | 63 | # Location can be 'us' or 'eu'
|
62 | 64 | name = f"projects/{project_id}/locations/{location}/processors/{processor_id}"
|
63 | 65 | request = documentai.types.document_processor_service.BatchProcessRequest(
|
64 | 66 | name=name,
|
65 |
| - input_configs=[input_config], |
66 |
| - output_config=output_config, |
| 67 | + input_documents=input_config, |
| 68 | + document_output_config=output_config, |
67 | 69 | )
|
68 | 70 |
|
69 | 71 | operation = client.batch_process_documents(request)
|
|
0 commit comments