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

Commit d6f183a

Browse files
feat: add from_service_account_info factory and fix sphinx identifiers (#80)
feat: add 'from_service_account_info' factory to clients fix: fix sphinx identifiers PiperOrigin-RevId: 350246057 Source-Author: Google APIs <noreply@google.com> Source-Date: Tue Jan 5 16:44:11 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 520682435235d9c503983a360a2090025aa47cd1 Source-Link: googleapis/googleapis@5206824
1 parent 33dc258 commit d6f183a

20 files changed

Lines changed: 319 additions & 232 deletions

File tree

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ exclude_lines =
1515
# This is added at the module level as a safeguard for if someone
1616
# generates the code and tries to run it without pip installing. This
1717
# makes it virtually impossible to test properly.
18-
except pkg_resources.DistributionNotFound
18+
except pkg_resources.DistributionNotFound
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DocumentUnderstandingService
2+
----------------------------------------------
3+
4+
.. automodule:: google.cloud.documentai_v1beta2.services.document_understanding_service
5+
:members:
6+
:inherited-members:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Services for Google Cloud Documentai v1beta2 API
22
================================================
3+
.. toctree::
4+
:maxdepth: 2
35

4-
.. automodule:: google.cloud.documentai_v1beta2.services.document_understanding_service
5-
:members:
6-
:inherited-members:
6+
document_understanding_service

docs/documentai_v1beta2/types.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Types for Google Cloud Documentai v1beta2 API
33

44
.. automodule:: google.cloud.documentai_v1beta2.types
55
:members:
6+
:undoc-members:
67
:show-inheritance:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DocumentProcessorService
2+
------------------------------------------
3+
4+
.. automodule:: google.cloud.documentai_v1beta3.services.document_processor_service
5+
:members:
6+
:inherited-members:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Services for Google Cloud Documentai v1beta3 API
22
================================================
3+
.. toctree::
4+
:maxdepth: 2
35

4-
.. automodule:: google.cloud.documentai_v1beta3.services.document_processor_service
5-
:members:
6-
:inherited-members:
6+
document_processor_service

docs/documentai_v1beta3/types.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Types for Google Cloud Documentai v1beta3 API
33

44
.. automodule:: google.cloud.documentai_v1beta3.types
55
:members:
6+
:undoc-members:
67
:show-inheritance:

google/cloud/documentai_v1beta2/services/document_understanding_service/async_client.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class DocumentUnderstandingServiceAsyncClient:
8585
DocumentUnderstandingServiceClient.parse_common_location_path
8686
)
8787

88+
from_service_account_info = (
89+
DocumentUnderstandingServiceClient.from_service_account_info
90+
)
8891
from_service_account_file = (
8992
DocumentUnderstandingServiceClient.from_service_account_file
9093
)
@@ -165,13 +168,14 @@ async def batch_process_documents(
165168
written to Cloud Storage as JSON in the [Document] format.
166169
167170
Args:
168-
request (:class:`~.document_understanding.BatchProcessDocumentsRequest`):
171+
request (:class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest`):
169172
The request object. Request to batch process documents
170173
as an asynchronous operation. The output is written to
171174
Cloud Storage as JSON in the [Document] format.
172-
requests (:class:`Sequence[~.document_understanding.ProcessDocumentRequest]`):
175+
requests (:class:`Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]`):
173176
Required. Individual requests for
174177
each document.
178+
175179
This corresponds to the ``requests`` field
176180
on the ``request`` instance; if ``request`` is provided, this
177181
should not be set.
@@ -183,14 +187,11 @@ async def batch_process_documents(
183187
sent along with the request as metadata.
184188
185189
Returns:
186-
~.operation_async.AsyncOperation:
190+
google.api_core.operation_async.AsyncOperation:
187191
An object representing a long-running operation.
188192
189-
The result type for the operation will be
190-
:class:``~.document_understanding.BatchProcessDocumentsResponse``:
191-
Response to an batch document processing request. This
192-
is returned in the LRO Operation after the operation is
193-
complete.
193+
The result type for the operation will be :class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsResponse` Response to an batch document processing request. This is returned in
194+
the LRO Operation after the operation is complete.
194195
195196
"""
196197
# Create or coerce a protobuf request object.
@@ -258,7 +259,7 @@ async def process_document(
258259
r"""Processes a single document.
259260
260261
Args:
261-
request (:class:`~.document_understanding.ProcessDocumentRequest`):
262+
request (:class:`google.cloud.documentai_v1beta2.types.ProcessDocumentRequest`):
262263
The request object. Request to process one document.
263264
264265
retry (google.api_core.retry.Retry): Designation of what errors, if any,
@@ -268,7 +269,7 @@ async def process_document(
268269
sent along with the request as metadata.
269270
270271
Returns:
271-
~.document.Document:
272+
google.cloud.documentai_v1beta2.types.Document:
272273
Document represents the canonical
273274
document resource in Document
274275
Understanding AI. It is an interchange

google/cloud/documentai_v1beta2/services/document_understanding_service/client.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ def _get_default_mtls_endpoint(api_endpoint):
122122
DEFAULT_ENDPOINT
123123
)
124124

125+
@classmethod
126+
def from_service_account_info(cls, info: dict, *args, **kwargs):
127+
"""Creates an instance of this client using the provided credentials info.
128+
129+
Args:
130+
info (dict): The service account private key info.
131+
args: Additional arguments to pass to the constructor.
132+
kwargs: Additional arguments to pass to the constructor.
133+
134+
Returns:
135+
DocumentUnderstandingServiceClient: The constructed client.
136+
"""
137+
credentials = service_account.Credentials.from_service_account_info(info)
138+
kwargs["credentials"] = credentials
139+
return cls(*args, **kwargs)
140+
125141
@classmethod
126142
def from_service_account_file(cls, filename: str, *args, **kwargs):
127143
"""Creates an instance of this client using the provided credentials
@@ -134,7 +150,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
134150
kwargs: Additional arguments to pass to the constructor.
135151
136152
Returns:
137-
{@api.name}: The constructed client.
153+
DocumentUnderstandingServiceClient: The constructed client.
138154
"""
139155
credentials = service_account.Credentials.from_service_account_file(filename)
140156
kwargs["credentials"] = credentials
@@ -226,10 +242,10 @@ def __init__(
226242
credentials identify the application to the service; if none
227243
are specified, the client will attempt to ascertain the
228244
credentials from the environment.
229-
transport (Union[str, ~.DocumentUnderstandingServiceTransport]): The
245+
transport (Union[str, DocumentUnderstandingServiceTransport]): The
230246
transport to use. If set to None, a transport is chosen
231247
automatically.
232-
client_options (client_options_lib.ClientOptions): Custom options for the
248+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
233249
client. It won't take effect if a ``transport`` instance is provided.
234250
(1) The ``api_endpoint`` property can be used to override the
235251
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -340,13 +356,14 @@ def batch_process_documents(
340356
written to Cloud Storage as JSON in the [Document] format.
341357
342358
Args:
343-
request (:class:`~.document_understanding.BatchProcessDocumentsRequest`):
359+
request (google.cloud.documentai_v1beta2.types.BatchProcessDocumentsRequest):
344360
The request object. Request to batch process documents
345361
as an asynchronous operation. The output is written to
346362
Cloud Storage as JSON in the [Document] format.
347-
requests (:class:`Sequence[~.document_understanding.ProcessDocumentRequest]`):
363+
requests (Sequence[google.cloud.documentai_v1beta2.types.ProcessDocumentRequest]):
348364
Required. Individual requests for
349365
each document.
366+
350367
This corresponds to the ``requests`` field
351368
on the ``request`` instance; if ``request`` is provided, this
352369
should not be set.
@@ -358,14 +375,11 @@ def batch_process_documents(
358375
sent along with the request as metadata.
359376
360377
Returns:
361-
~.operation.Operation:
378+
google.api_core.operation.Operation:
362379
An object representing a long-running operation.
363380
364-
The result type for the operation will be
365-
:class:``~.document_understanding.BatchProcessDocumentsResponse``:
366-
Response to an batch document processing request. This
367-
is returned in the LRO Operation after the operation is
368-
complete.
381+
The result type for the operation will be :class:`google.cloud.documentai_v1beta2.types.BatchProcessDocumentsResponse` Response to an batch document processing request. This is returned in
382+
the LRO Operation after the operation is complete.
369383
370384
"""
371385
# Create or coerce a protobuf request object.
@@ -426,7 +440,7 @@ def process_document(
426440
r"""Processes a single document.
427441
428442
Args:
429-
request (:class:`~.document_understanding.ProcessDocumentRequest`):
443+
request (google.cloud.documentai_v1beta2.types.ProcessDocumentRequest):
430444
The request object. Request to process one document.
431445
432446
retry (google.api_core.retry.Retry): Designation of what errors, if any,
@@ -436,7 +450,7 @@ def process_document(
436450
sent along with the request as metadata.
437451
438452
Returns:
439-
~.document.Document:
453+
google.cloud.documentai_v1beta2.types.Document:
440454
Document represents the canonical
441455
document resource in Document
442456
Understanding AI. It is an interchange

0 commit comments

Comments
 (0)