Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

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
Eric Schmidt committed Mar 11, 2021
1 parent dabe48e commit bb639f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion samples/snippets/batch_process_documents_sample_v1beta3.py
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 samples/snippets/process_document_sample_v1beta3.py
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 samples/snippets/quickstart_sample_v1beta3.py
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 bb639f9

Please sign in to comment.