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

Commit be671a8

Browse files
chore: upgrade gapic-generator-python to 0.46.3 (#146)
PiperOrigin-RevId: 373649163 Source-Link: googleapis/googleapis@7e1b14e Source-Link: https://github.com/googleapis/googleapis-gen/commit/0a3c7d272d697796db75857bac73905c68e498c3 feat: Use non-regionalized default host name for documentai.googleapis.com feat: add confidence field to the PageAnchor.PageRef in document.proto. fix: add async client to %name_%version/init.py chore: add autogenerated snippets chore: remove auth, policy, and options from the reserved names list feat: support self-signed JWT flow for service accounts chore: enable GAPIC metadata generation chore: sort subpackages in %namespace/%name/init.py
1 parent c5609b6 commit be671a8

54 files changed

Lines changed: 1916 additions & 1504 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google/cloud/documentai/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
32
# Copyright 2020 Google LLC
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,12 +14,13 @@
1514
# limitations under the License.
1615
#
1716

18-
from google.cloud.documentai_v1.services.document_processor_service.async_client import (
19-
DocumentProcessorServiceAsyncClient,
20-
)
2117
from google.cloud.documentai_v1.services.document_processor_service.client import (
2218
DocumentProcessorServiceClient,
2319
)
20+
from google.cloud.documentai_v1.services.document_processor_service.async_client import (
21+
DocumentProcessorServiceAsyncClient,
22+
)
23+
2424
from google.cloud.documentai_v1.types.document import Document
2525
from google.cloud.documentai_v1.types.document_io import BatchDocumentsInputConfig
2626
from google.cloud.documentai_v1.types.document_io import DocumentOutputConfig
@@ -59,26 +59,26 @@
5959
from google.cloud.documentai_v1.types.geometry import Vertex
6060

6161
__all__ = (
62-
"BatchDocumentsInputConfig",
63-
"BatchProcessMetadata",
64-
"BatchProcessRequest",
65-
"BatchProcessResponse",
66-
"BoundingPoly",
67-
"CommonOperationMetadata",
62+
"DocumentProcessorServiceClient",
63+
"DocumentProcessorServiceAsyncClient",
6864
"Document",
65+
"BatchDocumentsInputConfig",
6966
"DocumentOutputConfig",
70-
"DocumentProcessorServiceAsyncClient",
71-
"DocumentProcessorServiceClient",
7267
"GcsDocument",
7368
"GcsDocuments",
7469
"GcsPrefix",
70+
"RawDocument",
71+
"BatchProcessMetadata",
72+
"BatchProcessRequest",
73+
"BatchProcessResponse",
74+
"CommonOperationMetadata",
7575
"HumanReviewStatus",
76-
"NormalizedVertex",
7776
"ProcessRequest",
7877
"ProcessResponse",
79-
"RawDocument",
8078
"ReviewDocumentOperationMetadata",
8179
"ReviewDocumentRequest",
8280
"ReviewDocumentResponse",
81+
"BoundingPoly",
82+
"NormalizedVertex",
8383
"Vertex",
8484
)

google/cloud/documentai_v1/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
32
# Copyright 2020 Google LLC
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +15,8 @@
1615
#
1716

1817
from .services.document_processor_service import DocumentProcessorServiceClient
18+
from .services.document_processor_service import DocumentProcessorServiceAsyncClient
19+
1920
from .types.document import Document
2021
from .types.document_io import BatchDocumentsInputConfig
2122
from .types.document_io import DocumentOutputConfig
@@ -37,8 +38,8 @@
3738
from .types.geometry import NormalizedVertex
3839
from .types.geometry import Vertex
3940

40-
4141
__all__ = (
42+
"DocumentProcessorServiceAsyncClient",
4243
"BatchDocumentsInputConfig",
4344
"BatchProcessMetadata",
4445
"BatchProcessRequest",
@@ -47,6 +48,7 @@
4748
"CommonOperationMetadata",
4849
"Document",
4950
"DocumentOutputConfig",
51+
"DocumentProcessorServiceClient",
5052
"GcsDocument",
5153
"GcsDocuments",
5254
"GcsPrefix",
@@ -59,5 +61,4 @@
5961
"ReviewDocumentRequest",
6062
"ReviewDocumentResponse",
6163
"Vertex",
62-
"DocumentProcessorServiceClient",
6364
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
3+
"language": "python",
4+
"libraryPackage": "google.cloud.documentai_v1",
5+
"protoPackage": "google.cloud.documentai.v1",
6+
"schema": "1.0",
7+
"services": {
8+
"DocumentProcessorService": {
9+
"clients": {
10+
"grpc": {
11+
"libraryClient": "DocumentProcessorServiceClient",
12+
"rpcs": {
13+
"BatchProcessDocuments": {
14+
"methods": [
15+
"batch_process_documents"
16+
]
17+
},
18+
"ProcessDocument": {
19+
"methods": [
20+
"process_document"
21+
]
22+
},
23+
"ReviewDocument": {
24+
"methods": [
25+
"review_document"
26+
]
27+
}
28+
}
29+
},
30+
"grpc-async": {
31+
"libraryClient": "DocumentProcessorServiceAsyncClient",
32+
"rpcs": {
33+
"BatchProcessDocuments": {
34+
"methods": [
35+
"batch_process_documents"
36+
]
37+
},
38+
"ProcessDocument": {
39+
"methods": [
40+
"process_document"
41+
]
42+
},
43+
"ReviewDocument": {
44+
"methods": [
45+
"review_document"
46+
]
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}

google/cloud/documentai_v1/services/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
32
# Copyright 2020 Google LLC
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
32
# Copyright 2020 Google LLC
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
1413
# See the License for the specific language governing permissions and
1514
# limitations under the License.
1615
#
17-
1816
from .client import DocumentProcessorServiceClient
1917
from .async_client import DocumentProcessorServiceAsyncClient
2018

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

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
32
# Copyright 2020 Google LLC
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,25 +13,23 @@
1413
# See the License for the specific language governing permissions and
1514
# limitations under the License.
1615
#
17-
1816
from collections import OrderedDict
1917
import functools
2018
import re
2119
from typing import Dict, Sequence, Tuple, Type, Union
2220
import pkg_resources
2321

2422
import google.api_core.client_options as ClientOptions # type: ignore
25-
from google.api_core import exceptions # type: ignore
23+
from google.api_core import exceptions as core_exceptions # type: ignore
2624
from google.api_core import gapic_v1 # type: ignore
2725
from google.api_core import retry as retries # type: ignore
28-
from google.auth import credentials # type: ignore
26+
from google.auth import credentials as ga_credentials # type: ignore
2927
from google.oauth2 import service_account # type: ignore
3028

3129
from google.api_core import operation # type: ignore
3230
from google.api_core import operation_async # type: ignore
3331
from google.cloud.documentai_v1.types import document
3432
from google.cloud.documentai_v1.types import document_processor_service
35-
3633
from .transports.base import DocumentProcessorServiceTransport, DEFAULT_CLIENT_INFO
3734
from .transports.grpc_asyncio import DocumentProcessorServiceGrpcAsyncIOTransport
3835
from .client import DocumentProcessorServiceClient
@@ -61,33 +58,28 @@ class DocumentProcessorServiceAsyncClient:
6158
parse_processor_path = staticmethod(
6259
DocumentProcessorServiceClient.parse_processor_path
6360
)
64-
6561
common_billing_account_path = staticmethod(
6662
DocumentProcessorServiceClient.common_billing_account_path
6763
)
6864
parse_common_billing_account_path = staticmethod(
6965
DocumentProcessorServiceClient.parse_common_billing_account_path
7066
)
71-
7267
common_folder_path = staticmethod(DocumentProcessorServiceClient.common_folder_path)
7368
parse_common_folder_path = staticmethod(
7469
DocumentProcessorServiceClient.parse_common_folder_path
7570
)
76-
7771
common_organization_path = staticmethod(
7872
DocumentProcessorServiceClient.common_organization_path
7973
)
8074
parse_common_organization_path = staticmethod(
8175
DocumentProcessorServiceClient.parse_common_organization_path
8276
)
83-
8477
common_project_path = staticmethod(
8578
DocumentProcessorServiceClient.common_project_path
8679
)
8780
parse_common_project_path = staticmethod(
8881
DocumentProcessorServiceClient.parse_common_project_path
8982
)
90-
9183
common_location_path = staticmethod(
9284
DocumentProcessorServiceClient.common_location_path
9385
)
@@ -97,7 +89,8 @@ class DocumentProcessorServiceAsyncClient:
9789

9890
@classmethod
9991
def from_service_account_info(cls, info: dict, *args, **kwargs):
100-
"""Creates an instance of this client using the provided credentials info.
92+
"""Creates an instance of this client using the provided credentials
93+
info.
10194
10295
Args:
10396
info (dict): The service account private key info.
@@ -112,7 +105,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
112105
@classmethod
113106
def from_service_account_file(cls, filename: str, *args, **kwargs):
114107
"""Creates an instance of this client using the provided credentials
115-
file.
108+
file.
116109
117110
Args:
118111
filename (str): The path to the service account private key json
@@ -129,7 +122,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
129122

130123
@property
131124
def transport(self) -> DocumentProcessorServiceTransport:
132-
"""Return the transport used by the client instance.
125+
"""Returns the transport used by the client instance.
133126
134127
Returns:
135128
DocumentProcessorServiceTransport: The transport used by the client instance.
@@ -144,12 +137,12 @@ def transport(self) -> DocumentProcessorServiceTransport:
144137
def __init__(
145138
self,
146139
*,
147-
credentials: credentials.Credentials = None,
140+
credentials: ga_credentials.Credentials = None,
148141
transport: Union[str, DocumentProcessorServiceTransport] = "grpc_asyncio",
149142
client_options: ClientOptions = None,
150143
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
151144
) -> None:
152-
"""Instantiate the document processor service client.
145+
"""Instantiates the document processor service client.
153146
154147
Args:
155148
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -181,7 +174,6 @@ def __init__(
181174
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
182175
creation failed for any reason.
183176
"""
184-
185177
self._client = DocumentProcessorServiceClient(
186178
credentials=credentials,
187179
transport=transport,
@@ -211,7 +203,6 @@ async def process_document(
211203
This corresponds to the ``name`` field
212204
on the ``request`` instance; if ``request`` is provided, this
213205
should not be set.
214-
215206
retry (google.api_core.retry.Retry): Designation of what errors, if any,
216207
should be retried.
217208
timeout (float): The timeout for this request.
@@ -238,7 +229,6 @@ async def process_document(
238229

239230
# If we have keyword arguments corresponding to fields on the
240231
# request, apply these.
241-
242232
if name is not None:
243233
request.name = name
244234

@@ -251,7 +241,8 @@ async def process_document(
251241
maximum=60.0,
252242
multiplier=1.3,
253243
predicate=retries.if_exception_type(
254-
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
244+
core_exceptions.DeadlineExceeded,
245+
core_exceptions.ServiceUnavailable,
255246
),
256247
deadline=120.0,
257248
),
@@ -294,7 +285,6 @@ async def batch_process_documents(
294285
This corresponds to the ``name`` field
295286
on the ``request`` instance; if ``request`` is provided, this
296287
should not be set.
297-
298288
retry (google.api_core.retry.Retry): Designation of what errors, if any,
299289
should be retried.
300290
timeout (float): The timeout for this request.
@@ -324,7 +314,6 @@ async def batch_process_documents(
324314

325315
# If we have keyword arguments corresponding to fields on the
326316
# request, apply these.
327-
328317
if name is not None:
329318
request.name = name
330319

@@ -337,7 +326,8 @@ async def batch_process_documents(
337326
maximum=60.0,
338327
multiplier=1.3,
339328
predicate=retries.if_exception_type(
340-
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
329+
core_exceptions.DeadlineExceeded,
330+
core_exceptions.ServiceUnavailable,
341331
),
342332
deadline=120.0,
343333
),
@@ -389,7 +379,6 @@ async def review_document(
389379
This corresponds to the ``human_review_config`` field
390380
on the ``request`` instance; if ``request`` is provided, this
391381
should not be set.
392-
393382
retry (google.api_core.retry.Retry): Designation of what errors, if any,
394383
should be retried.
395384
timeout (float): The timeout for this request.
@@ -419,7 +408,6 @@ async def review_document(
419408

420409
# If we have keyword arguments corresponding to fields on the
421410
# request, apply these.
422-
423411
if human_review_config is not None:
424412
request.human_review_config = human_review_config
425413

@@ -432,7 +420,8 @@ async def review_document(
432420
maximum=60.0,
433421
multiplier=1.3,
434422
predicate=retries.if_exception_type(
435-
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
423+
core_exceptions.DeadlineExceeded,
424+
core_exceptions.ServiceUnavailable,
436425
),
437426
deadline=120.0,
438427
),

0 commit comments

Comments
 (0)