Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

# [START documentai_batch_process_documents_processor_version]
import re
from typing import Optional

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import InternalServerError
from google.api_core.exceptions import RetryError
from google.cloud import documentai
from google.cloud import documentai # type: ignore
from google.cloud import storage

# TODO(developer): Uncomment these variables before running the sample.
Expand All @@ -43,9 +44,9 @@ def batch_process_documents_processor_version(
input_mime_type: str,
gcs_output_bucket: str,
gcs_output_uri_prefix: str,
field_mask: str = None,
field_mask: Optional[str] = None,
timeout: int = 400,
):
) -> None:

# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from uuid import uuid4

Expand Down
7 changes: 4 additions & 3 deletions documentai/snippets/batch_process_documents_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

# [START documentai_batch_process_document]
import re
from typing import Optional

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import InternalServerError
from google.api_core.exceptions import RetryError
from google.cloud import documentai
from google.cloud import documentai # type: ignore
from google.cloud import storage

# TODO(developer): Uncomment these variables before running the sample.
Expand All @@ -41,9 +42,9 @@ def batch_process_documents(
input_mime_type: str,
gcs_output_bucket: str,
gcs_output_uri_prefix: str,
field_mask: str = None,
field_mask: Optional[str] = None,
timeout: int = 400,
):
) -> None:

# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")
Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/batch_process_documents_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from uuid import uuid4

Expand Down
6 changes: 3 additions & 3 deletions documentai/snippets/cancel_operation_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import FailedPrecondition
from google.api_core.exceptions import NotFound
from google.cloud import documentai
from google.longrunning.operations_pb2 import CancelOperationRequest
from google.cloud import documentai # type: ignore
from google.longrunning.operations_pb2 import CancelOperationRequest # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# operation_name = 'YOUR_OPERATION_NAME' # Format is 'projects/project_id/locations/location/operations/operation_id'


def cancel_operation_sample(location: str, operation_name: str):
def cancel_operation_sample(location: str, operation_name: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/cancel_operation_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import cancel_operation_sample
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/create_processor_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# [START documentai_create_processor]

from google.api_core.client_options import ClientOptions
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
Expand All @@ -27,7 +27,7 @@

def create_processor_sample(
project_id: str, location: str, processor_display_name: str, processor_type: str
):
) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/create_processor_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock
from uuid import uuid4
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/delete_processor_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import NotFound
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# processor_id = 'YOUR_PROCESSOR_ID'


def delete_processor_sample(project_id: str, location: str, processor_id: str):
def delete_processor_sample(project_id: str, location: str, processor_id: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/delete_processor_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock

Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/delete_processor_version_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import FailedPrecondition
from google.api_core.exceptions import InvalidArgument
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
Expand All @@ -29,7 +29,7 @@

def delete_processor_version_sample(
project_id: str, location: str, processor_id: str, processor_version_id: str
):
) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/delete_processor_version_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock

Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/deploy_processor_version_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import FailedPrecondition
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
Expand All @@ -28,7 +28,7 @@

def deploy_processor_version_sample(
project_id: str, location: str, processor_id: str, processor_version_id: str
):
) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/deploy_processor_version_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock

Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/disable_processor_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import FailedPrecondition
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# processor_id = 'YOUR_PROCESSOR_ID'


def disable_processor_sample(project_id: str, location: str, processor_id: str):
def disable_processor_sample(project_id: str, location: str, processor_id: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/disable_processor_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import disable_processor_sample
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/enable_processor_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import FailedPrecondition
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# processor_id = 'YOUR_PROCESSOR_ID'


def enable_processor_sample(project_id: str, location: str, processor_id: str):
def enable_processor_sample(project_id: str, location: str, processor_id: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/enable_processor_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import disable_processor_sample
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/evaluate_processor_version_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# [START documentai_evaluate_processor_version]

from google.api_core.client_options import ClientOptions
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
Expand All @@ -32,7 +32,7 @@ def evaluate_processor_version_sample(
processor_id: str,
processor_version_id: str,
gcs_input_uri: str,
):
) -> None:
# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock

Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/fetch_processor_types_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# [START documentai_fetch_processor_types]

from google.api_core.client_options import ClientOptions
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'


def fetch_processor_types_sample(project_id: str, location: str):
def fetch_processor_types_sample(project_id: str, location: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/fetch_processor_types_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import fetch_processor_types_sample
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/get_evaluation_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# [START documentai_get_evaluation]

from google.api_core.client_options import ClientOptions
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
Expand All @@ -32,7 +32,7 @@ def get_evaluation_sample(
processor_id: str,
processor_version_id: str,
evaluation_id: str,
):
) -> None:
# You must set the api_endpoint if you use a location other than 'us', e.g.:
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/get_evaluation_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os
from unittest import mock

Expand Down
6 changes: 3 additions & 3 deletions documentai/snippets/get_operation_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

from google.api_core.client_options import ClientOptions
from google.api_core.exceptions import NotFound
from google.cloud import documentai
from google.longrunning.operations_pb2 import GetOperationRequest
from google.cloud import documentai # type: ignore
from google.longrunning.operations_pb2 import GetOperationRequest # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# operation_name = 'YOUR_OPERATION_NAME' # Format is 'projects/project_id/locations/location/operations/operation_id'


def get_operation_sample(location: str, operation_name: str):
def get_operation_sample(location: str, operation_name: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/get_operation_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import get_operation_sample
Expand Down
4 changes: 2 additions & 2 deletions documentai/snippets/get_processor_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
# [START documentai_get_processor]

from google.api_core.client_options import ClientOptions
from google.cloud import documentai
from google.cloud import documentai # type: ignore

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'
# processor_id = 'YOUR_PROCESSOR_ID'


def get_processor_sample(project_id: str, location: str, processor_id: str):
def get_processor_sample(project_id: str, location: str, processor_id: str) -> None:
# You must set the api_endpoint if you use a location other than 'us'.
opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")

Expand Down
2 changes: 2 additions & 0 deletions documentai/snippets/get_processor_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
#

# flake8: noqa

import os

from documentai.snippets import get_processor_sample
Expand Down
Loading