Skip to content

Commit

Permalink
fix: adds comment with explicit hostname change (#94)
Browse files Browse the repository at this point in the history
* fix: adds switching code for client_options based upon location
  • Loading branch information
telpirion authored and dandhlee committed Jan 5, 2023
1 parent 604c3e6 commit 7947d2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def batch_process_documents(
timeout: int = 300,
):

client = documentai.DocumentProcessorServiceClient()
# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = {}
if location == "eu":
opts = {"api_endpoint": "eu-documentai.googleapis.com"}

client = documentai.DocumentProcessorServiceClient(client_options=opts)

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

Expand Down
8 changes: 6 additions & 2 deletions documentai/snippets/process_document_sample_v1beta3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def process_document_sample(
):
from google.cloud import documentai_v1beta3 as documentai

# Instantiates a client
client = documentai.DocumentProcessorServiceClient()
# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = {}
if location == "eu":
opts = {"api_endpoint": "eu-documentai.googleapis.com"}

client = documentai.DocumentProcessorServiceClient(client_options=opts)

# The full resource name of the processor, e.g.:
# projects/project-id/locations/location/processor/processor-id
Expand Down
8 changes: 7 additions & 1 deletion documentai/snippets/quickstart_sample_v1beta3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@


def quickstart(project_id: str, location: str, processor_id: str, file_path: str):
client = documentai.DocumentProcessorServiceClient()

# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = {}
if location == "eu":
opts = {"api_endpoint": "eu-documentai.googleapis.com"}

client = documentai.DocumentProcessorServiceClient(client_options=opts)

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

0 comments on commit 7947d2b

Please sign in to comment.