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

Commit

Permalink
chore: use gapic-generator-python 0.53.4 (#234)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Nov 1, 2021
1 parent 1e3b969 commit 038a736
Show file tree
Hide file tree
Showing 28 changed files with 252 additions and 426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.documentai_v1.types import document
Expand Down Expand Up @@ -183,17 +185,17 @@ def __init__(

async def process_document(
self,
request: document_processor_service.ProcessRequest = None,
request: Union[document_processor_service.ProcessRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> document_processor_service.ProcessResponse:
r"""Processes a single document.
Args:
request (:class:`google.cloud.documentai_v1.types.ProcessRequest`):
request (Union[google.cloud.documentai_v1.types.ProcessRequest, dict]):
The request object. Request message for the process
document method.
name (:class:`str`):
Expand Down Expand Up @@ -264,18 +266,18 @@ async def process_document(

async def batch_process_documents(
self,
request: document_processor_service.BatchProcessRequest = None,
request: Union[document_processor_service.BatchProcessRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""LRO endpoint to batch process many documents. The output is
written to Cloud Storage as JSON in the [Document] format.
Args:
request (:class:`google.cloud.documentai_v1.types.BatchProcessRequest`):
request (Union[google.cloud.documentai_v1.types.BatchProcessRequest, dict]):
The request object. Request message for batch process
document method.
name (:class:`str`):
Expand Down Expand Up @@ -357,18 +359,18 @@ async def batch_process_documents(

async def review_document(
self,
request: document_processor_service.ReviewDocumentRequest = None,
request: Union[document_processor_service.ReviewDocumentRequest, dict] = None,
*,
human_review_config: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Send a document for Human Review. The input document
should be processed by the specified processor.
Args:
request (:class:`google.cloud.documentai_v1.types.ReviewDocumentRequest`):
request (Union[google.cloud.documentai_v1.types.ReviewDocumentRequest, dict]):
The request object. Request message for review document
method.
human_review_config (:class:`str`):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.documentai_v1.types import document
Expand Down Expand Up @@ -377,7 +379,7 @@ def process_document(
request: Union[document_processor_service.ProcessRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> document_processor_service.ProcessResponse:
Expand Down Expand Up @@ -448,7 +450,7 @@ def batch_process_documents(
request: Union[document_processor_service.BatchProcessRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -531,7 +533,7 @@ def review_document(
request: Union[document_processor_service.ReviewDocumentRequest, dict] = None,
*,
human_review_config: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -39,15 +38,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class DocumentProcessorServiceTransport(abc.ABC):
"""Abstract transport class for DocumentProcessorService."""
Expand Down Expand Up @@ -97,7 +87,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -130,29 +120,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down Expand Up @@ -213,7 +180,7 @@ def close(self):
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
def operations_client(self):
"""Return the client designed to process long-running operations."""
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down Expand Up @@ -163,7 +162,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
30 changes: 30 additions & 0 deletions google/cloud/documentai_v1/types/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,27 @@ class Document(proto.Message):
documents and allows for collaboration between users and
Document Understanding AI to iterate and optimize for quality.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
uri (str):
Optional. Currently supports Google Cloud Storage URI of the
form ``gs://bucket_name/object_name``. Object versioning is
not supported. See `Google Cloud Storage Request
URIs <https://cloud.google.com/storage/docs/reference-uris>`__
for more info.
This field is a member of `oneof`_ ``source``.
content (bytes):
Optional. Inline document content, represented as a stream
of bytes. Note: As with all ``bytes`` fields, protobuffers
use a pure binary representation, whereas JSON
representations use base64.
This field is a member of `oneof`_ ``source``.
mime_type (str):
An IANA published MIME type (also referred to
as media type). For more information, see
Expand Down Expand Up @@ -683,24 +692,36 @@ class Entity(proto.Message):
class NormalizedValue(proto.Message):
r"""Parsed and normalized entity value.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
money_value (google.type.money_pb2.Money):
Money value. See also:
https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
This field is a member of `oneof`_ ``structured_value``.
date_value (google.type.date_pb2.Date):
Date value. Includes year, month, day. See
also:
https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
This field is a member of `oneof`_ ``structured_value``.
datetime_value (google.type.datetime_pb2.DateTime):
DateTime value. Includes date, time, and
timezone. See also:
https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
This field is a member of `oneof`_ ``structured_value``.
address_value (google.type.postal_address_pb2.PostalAddress):
Postal address. See also:
https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
This field is a member of `oneof`_ ``structured_value``.
boolean_value (bool):
Boolean value. Can be used for entities with
binary values, or for checkboxes.
This field is a member of `oneof`_ ``structured_value``.
text (str):
Required. Normalized entity value stored as a string. This
field is populated for supported document type (e.g.
Expand Down Expand Up @@ -947,13 +968,22 @@ class Parent(proto.Message):
class Revision(proto.Message):
r"""Contains past or forward revisions of this document.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
agent (str):
If the change was made by a person specify
the name or id of that person.
This field is a member of `oneof`_ ``source``.
processor (str):
If the annotation was made by processor
identify the processor by its resource name.
This field is a member of `oneof`_ ``source``.
id (str):
Id of the revision. Unique within the
context of the document.
Expand Down
13 changes: 13 additions & 0 deletions google/cloud/documentai_v1/types/document_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,22 @@ class BatchDocumentsInputConfig(proto.Message):
r"""The common config to specify a set of documents used as
input.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
gcs_prefix (google.cloud.documentai_v1.types.GcsPrefix):
The set of documents that match the specified Cloud Storage
[gcs_prefix].
This field is a member of `oneof`_ ``source``.
gcs_documents (google.cloud.documentai_v1.types.GcsDocuments):
The set of documents individually specified
on Cloud Storage.
This field is a member of `oneof`_ ``source``.
"""

gcs_prefix = proto.Field(
Expand All @@ -106,10 +115,14 @@ class DocumentOutputConfig(proto.Message):
r"""Config that controls the output of documents. All documents
will be written as a JSON file.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
gcs_output_config (google.cloud.documentai_v1.types.DocumentOutputConfig.GcsOutputConfig):
Output config to write the results to Cloud
Storage.
This field is a member of `oneof`_ ``destination``.
"""

class GcsOutputConfig(proto.Message):
Expand Down
12 changes: 12 additions & 0 deletions google/cloud/documentai_v1/types/document_processor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@
class ProcessRequest(proto.Message):
r"""Request message for the process document method.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
inline_document (google.cloud.documentai_v1.types.Document):
An inline document proto.
This field is a member of `oneof`_ ``source``.
raw_document (google.cloud.documentai_v1.types.RawDocument):
A raw document content (bytes).
This field is a member of `oneof`_ ``source``.
name (str):
Required. The processor resource name.
skip_human_review (bool):
Expand Down Expand Up @@ -212,9 +221,12 @@ class IndividualProcessStatus(proto.Message):
class ReviewDocumentRequest(proto.Message):
r"""Request message for review document method.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
inline_document (google.cloud.documentai_v1.types.Document):
An inline document proto.
This field is a member of `oneof`_ ``source``.
human_review_config (str):
Required. The resource name of the
HumanReviewConfig that the document will be
Expand Down
Loading

0 comments on commit 038a736

Please sign in to comment.