Skip to content

Commit 7947d2b

Browse files
telpiriondandhlee
authored andcommitted
fix: adds comment with explicit hostname change (#94)
* fix: adds switching code for client_options based upon location
1 parent 604c3e6 commit 7947d2b

3 files changed

+19
-4
lines changed

documentai/snippets/batch_process_documents_sample_v1beta3.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ def batch_process_documents(
3838
timeout: int = 300,
3939
):
4040

41-
client = documentai.DocumentProcessorServiceClient()
41+
# You must set the api_endpoint if you use a location other than 'us', e.g.:
42+
opts = {}
43+
if location == "eu":
44+
opts = {"api_endpoint": "eu-documentai.googleapis.com"}
45+
46+
client = documentai.DocumentProcessorServiceClient(client_options=opts)
4247

4348
destination_uri = f"{gcs_output_uri}/{gcs_output_uri_prefix}/"
4449

documentai/snippets/process_document_sample_v1beta3.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ def process_document_sample(
2727
):
2828
from google.cloud import documentai_v1beta3 as documentai
2929

30-
# Instantiates a client
31-
client = documentai.DocumentProcessorServiceClient()
30+
# You must set the api_endpoint if you use a location other than 'us', e.g.:
31+
opts = {}
32+
if location == "eu":
33+
opts = {"api_endpoint": "eu-documentai.googleapis.com"}
34+
35+
client = documentai.DocumentProcessorServiceClient(client_options=opts)
3236

3337
# The full resource name of the processor, e.g.:
3438
# projects/project-id/locations/location/processor/processor-id

documentai/snippets/quickstart_sample_v1beta3.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525

2626

2727
def quickstart(project_id: str, location: str, processor_id: str, file_path: str):
28-
client = documentai.DocumentProcessorServiceClient()
28+
29+
# You must set the api_endpoint if you use a location other than 'us', e.g.:
30+
opts = {}
31+
if location == "eu":
32+
opts = {"api_endpoint": "eu-documentai.googleapis.com"}
33+
34+
client = documentai.DocumentProcessorServiceClient(client_options=opts)
2935

3036
# The full resource name of the processor, e.g.:
3137
# projects/project-id/locations/location/processor/processor-id

0 commit comments

Comments
 (0)