Content-Length: 1200187 | pFad | https://github.com/googleapis/python-documentai/commit/038a7364fe0d2341a3bda1e40bfe23d864427ab7

53 chore: use gapic-generator-python 0.53.4 (#234) · googleapis/python-documentai@038a736 · GitHub
Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 038a736

Browse files
chore: use gapic-generator-python 0.53.4 (#234)
- [ ] 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: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
1 parent 1e3b969 commit 038a736

File tree

28 files changed

+252
-426
lines changed

28 files changed

+252
-426
lines changed

google/cloud/documentai_v1/services/document_processor_service/async_client.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
from typing import Dict, Sequence, Tuple, Type, Union
2020
import pkg_resources
2121

22-
import google.api_core.client_options as ClientOptions # type: ignore
22+
from google.api_core.client_options import ClientOptions # type: ignore
2323
from google.api_core import exceptions as core_exceptions # type: ignore
2424
from google.api_core import gapic_v1 # type: ignore
2525
from google.api_core import retry as retries # type: ignore
2626
from google.auth import credentials as ga_credentials # type: ignore
2727
from google.oauth2 import service_account # type: ignore
2828

29+
OptionalRetry = Union[retries.Retry, object]
30+
2931
from google.api_core import operation # type: ignore
3032
from google.api_core import operation_async # type: ignore
3133
from google.cloud.documentai_v1.types import document
@@ -183,17 +185,17 @@ def __init__(
183185

184186
async def process_document(
185187
self,
186-
request: document_processor_service.ProcessRequest = None,
188+
request: Union[document_processor_service.ProcessRequest, dict] = None,
187189
*,
188190
name: str = None,
189-
retry: retries.Retry = gapic_v1.method.DEFAULT,
191+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
190192
timeout: float = None,
191193
metadata: Sequence[Tuple[str, str]] = (),
192194
) -> document_processor_service.ProcessResponse:
193195
r"""Processes a single document.
194196
195197
Args:
196-
request (:class:`google.cloud.documentai_v1.types.ProcessRequest`):
198+
request (Union[google.cloud.documentai_v1.types.ProcessRequest, dict]):
197199
The request object. Request message for the process
198200
document method.
199201
name (:class:`str`):
@@ -264,18 +266,18 @@ async def process_document(
264266

265267
async def batch_process_documents(
266268
self,
267-
request: document_processor_service.BatchProcessRequest = None,
269+
request: Union[document_processor_service.BatchProcessRequest, dict] = None,
268270
*,
269271
name: str = None,
270-
retry: retries.Retry = gapic_v1.method.DEFAULT,
272+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
271273
timeout: float = None,
272274
metadata: Sequence[Tuple[str, str]] = (),
273275
) -> operation_async.AsyncOperation:
274276
r"""LRO endpoint to batch process many documents. The output is
275277
written to Cloud Storage as JSON in the [Document] format.
276278
277279
Args:
278-
request (:class:`google.cloud.documentai_v1.types.BatchProcessRequest`):
280+
request (Union[google.cloud.documentai_v1.types.BatchProcessRequest, dict]):
279281
The request object. Request message for batch process
280282
document method.
281283
name (:class:`str`):
@@ -357,18 +359,18 @@ async def batch_process_documents(
357359

358360
async def review_document(
359361
self,
360-
request: document_processor_service.ReviewDocumentRequest = None,
362+
request: Union[document_processor_service.ReviewDocumentRequest, dict] = None,
361363
*,
362364
human_review_config: str = None,
363-
retry: retries.Retry = gapic_v1.method.DEFAULT,
365+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
364366
timeout: float = None,
365367
metadata: Sequence[Tuple[str, str]] = (),
366368
) -> operation_async.AsyncOperation:
367369
r"""Send a document for Human Review. The input document
368370
should be processed by the specified processor.
369371
370372
Args:
371-
request (:class:`google.cloud.documentai_v1.types.ReviewDocumentRequest`):
373+
request (Union[google.cloud.documentai_v1.types.ReviewDocumentRequest, dict]):
372374
The request object. Request message for review document
373375
method.
374376
human_review_config (:class:`str`):

google/cloud/documentai_v1/services/document_processor_service/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from google.auth.exceptions import MutualTLSChannelError # type: ignore
3131
from google.oauth2 import service_account # type: ignore
3232

33+
OptionalRetry = Union[retries.Retry, object]
34+
3335
from google.api_core import operation # type: ignore
3436
from google.api_core import operation_async # type: ignore
3537
from google.cloud.documentai_v1.types import document
@@ -377,7 +379,7 @@ def process_document(
377379
request: Union[document_processor_service.ProcessRequest, dict] = None,
378380
*,
379381
name: str = None,
380-
retry: retries.Retry = gapic_v1.method.DEFAULT,
382+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
381383
timeout: float = None,
382384
metadata: Sequence[Tuple[str, str]] = (),
383385
) -> document_processor_service.ProcessResponse:
@@ -448,7 +450,7 @@ def batch_process_documents(
448450
request: Union[document_processor_service.BatchProcessRequest, dict] = None,
449451
*,
450452
name: str = None,
451-
retry: retries.Retry = gapic_v1.method.DEFAULT,
453+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
452454
timeout: float = None,
453455
metadata: Sequence[Tuple[str, str]] = (),
454456
) -> operation.Operation:
@@ -531,7 +533,7 @@ def review_document(
531533
request: Union[document_processor_service.ReviewDocumentRequest, dict] = None,
532534
*,
533535
human_review_config: str = None,
534-
retry: retries.Retry = gapic_v1.method.DEFAULT,
536+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
535537
timeout: float = None,
536538
metadata: Sequence[Tuple[str, str]] = (),
537539
) -> operation.Operation:

google/cloud/documentai_v1/services/document_processor_service/transports/base.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#
1616
import abc
1717
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18-
import packaging.version
1918
import pkg_resources
2019

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

42-
try:
43-
# google.auth.__version__ was added in 1.26.0
44-
_GOOGLE_AUTH_VERSION = google.auth.__version__
45-
except AttributeError:
46-
try: # try pkg_resources if it is available
47-
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
48-
except pkg_resources.DistributionNotFound: # pragma: NO COVER
49-
_GOOGLE_AUTH_VERSION = None
50-
5141

5242
class DocumentProcessorServiceTransport(abc.ABC):
5343
"""Abstract transport class for DocumentProcessorService."""
@@ -97,7 +87,7 @@ def __init__(
9787
host += ":443"
9888
self._host = host
9989

100-
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
90+
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
10191

10292
# Save the scopes.
10393
self._scopes = scopes
@@ -130,29 +120,6 @@ def __init__(
130120
# Save the credentials.
131121
self._credentials = credentials
132122

133-
# TODO(busunkim): This method is in the base transport
134-
# to avoid duplicating code across the transport classes. These functions
135-
# should be deleted once the minimum required versions of google-auth is increased.
136-
137-
# TODO: Remove this function once google-auth >= 1.25.0 is required
138-
@classmethod
139-
def _get_scopes_kwargs(
140-
cls, host: str, scopes: Optional[Sequence[str]]
141-
) -> Dict[str, Optional[Sequence[str]]]:
142-
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
143-
144-
scopes_kwargs = {}
145-
146-
if _GOOGLE_AUTH_VERSION and (
147-
packaging.version.parse(_GOOGLE_AUTH_VERSION)
148-
>= packaging.version.parse("1.25.0")
149-
):
150-
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
151-
else:
152-
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
153-
154-
return scopes_kwargs
155-
156123
def _prep_wrapped_messages(self, client_info):
157124
# Precompute the wrapped methods.
158125
self._wrapped_methods = {
@@ -213,7 +180,7 @@ def close(self):
213180
raise NotImplementedError()
214181

215182
@property
216-
def operations_client(self) -> operations_v1.OperationsClient:
183+
def operations_client(self):
217184
"""Return the client designed to process long-running operations."""
218185
raise NotImplementedError()
219186

google/cloud/documentai_v1/services/document_processor_service/transports/grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(
116116
self._grpc_channel = None
117117
self._ssl_channel_credentials = ssl_channel_credentials
118118
self._stubs: Dict[str, Callable] = {}
119-
self._operations_client = None
119+
self._operations_client: Optional[operations_v1.OperationsClient] = None
120120

121121
if api_mtls_endpoint:
122122
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)

google/cloud/documentai_v1/services/document_processor_service/transports/grpc_asyncio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from google.api_core import operations_v1 # type: ignore
2222
from google.auth import credentials as ga_credentials # type: ignore
2323
from google.auth.transport.grpc import SslCredentials # type: ignore
24-
import packaging.version
2524

2625
import grpc # type: ignore
2726
from grpc.experimental import aio # type: ignore
@@ -163,7 +162,7 @@ def __init__(
163162
self._grpc_channel = None
164163
self._ssl_channel_credentials = ssl_channel_credentials
165164
self._stubs: Dict[str, Callable] = {}
166-
self._operations_client = None
165+
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
167166

168167
if api_mtls_endpoint:
169168
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)

google/cloud/documentai_v1/types/document.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,27 @@ class Document(proto.Message):
3737
documents and allows for collaboration between users and
3838
Document Understanding AI to iterate and optimize for quality.
3939
40+
This message has `oneof`_ fields (mutually exclusive fields).
41+
For each oneof, at most one member field can be set at the same time.
42+
Setting any member of the oneof automatically clears all other
43+
members.
44+
45+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
46+
4047
Attributes:
4148
uri (str):
4249
Optional. Currently supports Google Cloud Storage URI of the
4350
form ``gs://bucket_name/object_name``. Object versioning is
4451
not supported. See `Google Cloud Storage Request
4552
URIs <https://cloud.google.com/storage/docs/reference-uris>`__
4653
for more info.
54+
This field is a member of `oneof`_ ``source``.
4755
content (bytes):
4856
Optional. Inline document content, represented as a stream
4957
of bytes. Note: As with all ``bytes`` fields, protobuffers
5058
use a pure binary representation, whereas JSON
5159
representations use base64.
60+
This field is a member of `oneof`_ ``source``.
5261
mime_type (str):
5362
An IANA published MIME type (also referred to
5463
as media type). For more information, see
@@ -683,24 +692,36 @@ class Entity(proto.Message):
683692
class NormalizedValue(proto.Message):
684693
r"""Parsed and normalized entity value.
685694
695+
This message has `oneof`_ fields (mutually exclusive fields).
696+
For each oneof, at most one member field can be set at the same time.
697+
Setting any member of the oneof automatically clears all other
698+
members.
699+
700+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
701+
686702
Attributes:
687703
money_value (google.type.money_pb2.Money):
688704
Money value. See also:
689705
https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
706+
This field is a member of `oneof`_ ``structured_value``.
690707
date_value (google.type.date_pb2.Date):
691708
Date value. Includes year, month, day. See
692709
also:
693710
https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
711+
This field is a member of `oneof`_ ``structured_value``.
694712
datetime_value (google.type.datetime_pb2.DateTime):
695713
DateTime value. Includes date, time, and
696714
timezone. See also:
697715
https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
716+
This field is a member of `oneof`_ ``structured_value``.
698717
address_value (google.type.postal_address_pb2.PostalAddress):
699718
Postal address. See also:
700719
https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
720+
This field is a member of `oneof`_ ``structured_value``.
701721
boolean_value (bool):
702722
Boolean value. Can be used for entities with
703723
binary values, or for checkboxes.
724+
This field is a member of `oneof`_ ``structured_value``.
704725
text (str):
705726
Required. Normalized entity value stored as a string. This
706727
field is populated for supported document type (e.g.
@@ -947,13 +968,22 @@ class Parent(proto.Message):
947968
class Revision(proto.Message):
948969
r"""Contains past or forward revisions of this document.
949970
971+
This message has `oneof`_ fields (mutually exclusive fields).
972+
For each oneof, at most one member field can be set at the same time.
973+
Setting any member of the oneof automatically clears all other
974+
members.
975+
976+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
977+
950978
Attributes:
951979
agent (str):
952980
If the change was made by a person specify
953981
the name or id of that person.
982+
This field is a member of `oneof`_ ``source``.
954983
processor (str):
955984
If the annotation was made by processor
956985
identify the processor by its resource name.
986+
This field is a member of `oneof`_ ``source``.
957987
id (str):
958988
Id of the revision. Unique within the
959989
context of the document.

google/cloud/documentai_v1/types/document_io.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,22 @@ class BatchDocumentsInputConfig(proto.Message):
8585
r"""The common config to specify a set of documents used as
8686
input.
8787
88+
This message has `oneof`_ fields (mutually exclusive fields).
89+
For each oneof, at most one member field can be set at the same time.
90+
Setting any member of the oneof automatically clears all other
91+
members.
92+
93+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
94+
8895
Attributes:
8996
gcs_prefix (google.cloud.documentai_v1.types.GcsPrefix):
9097
The set of documents that match the specified Cloud Storage
9198
[gcs_prefix].
99+
This field is a member of `oneof`_ ``source``.
92100
gcs_documents (google.cloud.documentai_v1.types.GcsDocuments):
93101
The set of documents individually specified
94102
on Cloud Storage.
103+
This field is a member of `oneof`_ ``source``.
95104
"""
96105

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

115128
class GcsOutputConfig(proto.Message):

google/cloud/documentai_v1/types/document_processor_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@
4141
class ProcessRequest(proto.Message):
4242
r"""Request message for the process document method.
4343
44+
This message has `oneof`_ fields (mutually exclusive fields).
45+
For each oneof, at most one member field can be set at the same time.
46+
Setting any member of the oneof automatically clears all other
47+
members.
48+
49+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
50+
4451
Attributes:
4552
inline_document (google.cloud.documentai_v1.types.Document):
4653
An inline document proto.
54+
This field is a member of `oneof`_ ``source``.
4755
raw_document (google.cloud.documentai_v1.types.RawDocument):
4856
A raw document content (bytes).
57+
This field is a member of `oneof`_ ``source``.
4958
name (str):
5059
Required. The processor resource name.
5160
skip_human_review (bool):
@@ -212,9 +221,12 @@ class IndividualProcessStatus(proto.Message):
212221
class ReviewDocumentRequest(proto.Message):
213222
r"""Request message for review document method.
214223
224+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
225+
215226
Attributes:
216227
inline_document (google.cloud.documentai_v1.types.Document):
217228
An inline document proto.
229+
This field is a member of `oneof`_ ``source``.
218230
human_review_config (str):
219231
Required. The resource name of the
220232
HumanReviewConfig that the document will be

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/python-documentai/commit/038a7364fe0d2341a3bda1e40bfe23d864427ab7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy