|
34 | 34 | from google.api_core.client_options import ClientOptions
|
35 | 35 | from google.auth import credentials as ga_credentials # type: ignore
|
36 | 36 | from google.oauth2 import service_account # type: ignore
|
37 |
| -import pkg_resources |
| 37 | + |
| 38 | +from google.cloud.documentai_v1 import gapic_version as package_version |
38 | 39 |
|
39 | 40 | try:
|
40 | 41 | OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
|
@@ -265,7 +266,7 @@ async def process_document(
|
265 | 266 | *,
|
266 | 267 | name: Optional[str] = None,
|
267 | 268 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
268 |
| - timeout: Optional[float] = None, |
| 269 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
269 | 270 | metadata: Sequence[Tuple[str, str]] = (),
|
270 | 271 | ) -> document_processor_service.ProcessResponse:
|
271 | 272 | r"""Processes a single document.
|
@@ -392,7 +393,7 @@ async def batch_process_documents(
|
392 | 393 | *,
|
393 | 394 | name: Optional[str] = None,
|
394 | 395 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
395 |
| - timeout: Optional[float] = None, |
| 396 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
396 | 397 | metadata: Sequence[Tuple[str, str]] = (),
|
397 | 398 | ) -> operation_async.AsyncOperation:
|
398 | 399 | r"""LRO endpoint to batch process many documents. The output is
|
@@ -423,7 +424,7 @@ async def sample_batch_process_documents():
|
423 | 424 |
|
424 | 425 | print("Waiting for operation to complete...")
|
425 | 426 |
|
426 |
| - response = await operation.result() |
| 427 | + response = (await operation).result() |
427 | 428 |
|
428 | 429 | # Handle the response
|
429 | 430 | print(response)
|
@@ -527,7 +528,7 @@ async def fetch_processor_types(
|
527 | 528 | *,
|
528 | 529 | parent: Optional[str] = None,
|
529 | 530 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
530 |
| - timeout: Optional[float] = None, |
| 531 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
531 | 532 | metadata: Sequence[Tuple[str, str]] = (),
|
532 | 533 | ) -> document_processor_service.FetchProcessorTypesResponse:
|
533 | 534 | r"""Fetches processor types. Note that we do not use
|
@@ -634,7 +635,7 @@ async def list_processor_types(
|
634 | 635 | *,
|
635 | 636 | parent: Optional[str] = None,
|
636 | 637 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
637 |
| - timeout: Optional[float] = None, |
| 638 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
638 | 639 | metadata: Sequence[Tuple[str, str]] = (),
|
639 | 640 | ) -> pagers.ListProcessorTypesAsyncPager:
|
640 | 641 | r"""Lists the processor types that exist.
|
@@ -753,7 +754,7 @@ async def list_processors(
|
753 | 754 | *,
|
754 | 755 | parent: Optional[str] = None,
|
755 | 756 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
756 |
| - timeout: Optional[float] = None, |
| 757 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
757 | 758 | metadata: Sequence[Tuple[str, str]] = (),
|
758 | 759 | ) -> pagers.ListProcessorsAsyncPager:
|
759 | 760 | r"""Lists all processors which belong to this project.
|
@@ -870,7 +871,7 @@ async def get_processor(
|
870 | 871 | *,
|
871 | 872 | name: Optional[str] = None,
|
872 | 873 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
873 |
| - timeout: Optional[float] = None, |
| 874 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
874 | 875 | metadata: Sequence[Tuple[str, str]] = (),
|
875 | 876 | ) -> processor.Processor:
|
876 | 877 | r"""Gets a processor detail.
|
@@ -975,7 +976,7 @@ async def get_processor_version(
|
975 | 976 | *,
|
976 | 977 | name: Optional[str] = None,
|
977 | 978 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
978 |
| - timeout: Optional[float] = None, |
| 979 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
979 | 980 | metadata: Sequence[Tuple[str, str]] = (),
|
980 | 981 | ) -> processor.ProcessorVersion:
|
981 | 982 | r"""Gets a processor version detail.
|
@@ -1086,7 +1087,7 @@ async def list_processor_versions(
|
1086 | 1087 | *,
|
1087 | 1088 | parent: Optional[str] = None,
|
1088 | 1089 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1089 |
| - timeout: Optional[float] = None, |
| 1090 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1090 | 1091 | metadata: Sequence[Tuple[str, str]] = (),
|
1091 | 1092 | ) -> pagers.ListProcessorVersionsAsyncPager:
|
1092 | 1093 | r"""Lists all versions of a processor.
|
@@ -1203,7 +1204,7 @@ async def delete_processor_version(
|
1203 | 1204 | *,
|
1204 | 1205 | name: Optional[str] = None,
|
1205 | 1206 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1206 |
| - timeout: Optional[float] = None, |
| 1207 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1207 | 1208 | metadata: Sequence[Tuple[str, str]] = (),
|
1208 | 1209 | ) -> operation_async.AsyncOperation:
|
1209 | 1210 | r"""Deletes the processor version, all artifacts under
|
@@ -1234,7 +1235,7 @@ async def sample_delete_processor_version():
|
1234 | 1235 |
|
1235 | 1236 | print("Waiting for operation to complete...")
|
1236 | 1237 |
|
1237 |
| - response = await operation.result() |
| 1238 | + response = (await operation).result() |
1238 | 1239 |
|
1239 | 1240 | # Handle the response
|
1240 | 1241 | print(response)
|
@@ -1330,7 +1331,7 @@ async def deploy_processor_version(
|
1330 | 1331 | *,
|
1331 | 1332 | name: Optional[str] = None,
|
1332 | 1333 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1333 |
| - timeout: Optional[float] = None, |
| 1334 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1334 | 1335 | metadata: Sequence[Tuple[str, str]] = (),
|
1335 | 1336 | ) -> operation_async.AsyncOperation:
|
1336 | 1337 | r"""Deploys the processor version.
|
@@ -1360,7 +1361,7 @@ async def sample_deploy_processor_version():
|
1360 | 1361 |
|
1361 | 1362 | print("Waiting for operation to complete...")
|
1362 | 1363 |
|
1363 |
| - response = await operation.result() |
| 1364 | + response = (await operation).result() |
1364 | 1365 |
|
1365 | 1366 | # Handle the response
|
1366 | 1367 | print(response)
|
@@ -1450,7 +1451,7 @@ async def undeploy_processor_version(
|
1450 | 1451 | *,
|
1451 | 1452 | name: Optional[str] = None,
|
1452 | 1453 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1453 |
| - timeout: Optional[float] = None, |
| 1454 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1454 | 1455 | metadata: Sequence[Tuple[str, str]] = (),
|
1455 | 1456 | ) -> operation_async.AsyncOperation:
|
1456 | 1457 | r"""Undeploys the processor version.
|
@@ -1480,7 +1481,7 @@ async def sample_undeploy_processor_version():
|
1480 | 1481 |
|
1481 | 1482 | print("Waiting for operation to complete...")
|
1482 | 1483 |
|
1483 |
| - response = await operation.result() |
| 1484 | + response = (await operation).result() |
1484 | 1485 |
|
1485 | 1486 | # Handle the response
|
1486 | 1487 | print(response)
|
@@ -1571,7 +1572,7 @@ async def create_processor(
|
1571 | 1572 | parent: Optional[str] = None,
|
1572 | 1573 | processor: Optional[gcd_processor.Processor] = None,
|
1573 | 1574 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1574 |
| - timeout: Optional[float] = None, |
| 1575 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1575 | 1576 | metadata: Sequence[Tuple[str, str]] = (),
|
1576 | 1577 | ) -> gcd_processor.Processor:
|
1577 | 1578 | r"""Creates a processor from the type processor that the
|
@@ -1692,7 +1693,7 @@ async def delete_processor(
|
1692 | 1693 | *,
|
1693 | 1694 | name: Optional[str] = None,
|
1694 | 1695 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1695 |
| - timeout: Optional[float] = None, |
| 1696 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1696 | 1697 | metadata: Sequence[Tuple[str, str]] = (),
|
1697 | 1698 | ) -> operation_async.AsyncOperation:
|
1698 | 1699 | r"""Deletes the processor, unloads all deployed model
|
@@ -1724,7 +1725,7 @@ async def sample_delete_processor():
|
1724 | 1725 |
|
1725 | 1726 | print("Waiting for operation to complete...")
|
1726 | 1727 |
|
1727 |
| - response = await operation.result() |
| 1728 | + response = (await operation).result() |
1728 | 1729 |
|
1729 | 1730 | # Handle the response
|
1730 | 1731 | print(response)
|
@@ -1819,7 +1820,7 @@ async def enable_processor(
|
1819 | 1820 | ] = None,
|
1820 | 1821 | *,
|
1821 | 1822 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1822 |
| - timeout: Optional[float] = None, |
| 1823 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1823 | 1824 | metadata: Sequence[Tuple[str, str]] = (),
|
1824 | 1825 | ) -> operation_async.AsyncOperation:
|
1825 | 1826 | r"""Enables a processor
|
@@ -1849,7 +1850,7 @@ async def sample_enable_processor():
|
1849 | 1850 |
|
1850 | 1851 | print("Waiting for operation to complete...")
|
1851 | 1852 |
|
1852 |
| - response = await operation.result() |
| 1853 | + response = (await operation).result() |
1853 | 1854 |
|
1854 | 1855 | # Handle the response
|
1855 | 1856 | print(response)
|
@@ -1916,7 +1917,7 @@ async def disable_processor(
|
1916 | 1917 | ] = None,
|
1917 | 1918 | *,
|
1918 | 1919 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
1919 |
| - timeout: Optional[float] = None, |
| 1920 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
1920 | 1921 | metadata: Sequence[Tuple[str, str]] = (),
|
1921 | 1922 | ) -> operation_async.AsyncOperation:
|
1922 | 1923 | r"""Disables a processor
|
@@ -1946,7 +1947,7 @@ async def sample_disable_processor():
|
1946 | 1947 |
|
1947 | 1948 | print("Waiting for operation to complete...")
|
1948 | 1949 |
|
1949 |
| - response = await operation.result() |
| 1950 | + response = (await operation).result() |
1950 | 1951 |
|
1951 | 1952 | # Handle the response
|
1952 | 1953 | print(response)
|
@@ -2013,7 +2014,7 @@ async def set_default_processor_version(
|
2013 | 2014 | ] = None,
|
2014 | 2015 | *,
|
2015 | 2016 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2016 |
| - timeout: Optional[float] = None, |
| 2017 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2017 | 2018 | metadata: Sequence[Tuple[str, str]] = (),
|
2018 | 2019 | ) -> operation_async.AsyncOperation:
|
2019 | 2020 | r"""Set the default (active) version of a
|
@@ -2049,7 +2050,7 @@ async def sample_set_default_processor_version():
|
2049 | 2050 |
|
2050 | 2051 | print("Waiting for operation to complete...")
|
2051 | 2052 |
|
2052 |
| - response = await operation.result() |
| 2053 | + response = (await operation).result() |
2053 | 2054 |
|
2054 | 2055 | # Handle the response
|
2055 | 2056 | print(response)
|
@@ -2120,7 +2121,7 @@ async def review_document(
|
2120 | 2121 | *,
|
2121 | 2122 | human_review_config: Optional[str] = None,
|
2122 | 2123 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2123 |
| - timeout: Optional[float] = None, |
| 2124 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2124 | 2125 | metadata: Sequence[Tuple[str, str]] = (),
|
2125 | 2126 | ) -> operation_async.AsyncOperation:
|
2126 | 2127 | r"""Send a document for Human Review. The input document
|
@@ -2155,7 +2156,7 @@ async def sample_review_document():
|
2155 | 2156 |
|
2156 | 2157 | print("Waiting for operation to complete...")
|
2157 | 2158 |
|
2158 |
| - response = await operation.result() |
| 2159 | + response = (await operation).result() |
2159 | 2160 |
|
2160 | 2161 | # Handle the response
|
2161 | 2162 | print(response)
|
@@ -2254,7 +2255,7 @@ async def list_operations(
|
2254 | 2255 | request: Optional[operations_pb2.ListOperationsRequest] = None,
|
2255 | 2256 | *,
|
2256 | 2257 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2257 |
| - timeout: Optional[float] = None, |
| 2258 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2258 | 2259 | metadata: Sequence[Tuple[str, str]] = (),
|
2259 | 2260 | ) -> operations_pb2.ListOperationsResponse:
|
2260 | 2261 | r"""Lists operations that match the specified filter in the request.
|
@@ -2308,7 +2309,7 @@ async def get_operation(
|
2308 | 2309 | request: Optional[operations_pb2.GetOperationRequest] = None,
|
2309 | 2310 | *,
|
2310 | 2311 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2311 |
| - timeout: Optional[float] = None, |
| 2312 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2312 | 2313 | metadata: Sequence[Tuple[str, str]] = (),
|
2313 | 2314 | ) -> operations_pb2.Operation:
|
2314 | 2315 | r"""Gets the latest state of a long-running operation.
|
@@ -2362,7 +2363,7 @@ async def cancel_operation(
|
2362 | 2363 | request: Optional[operations_pb2.CancelOperationRequest] = None,
|
2363 | 2364 | *,
|
2364 | 2365 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2365 |
| - timeout: Optional[float] = None, |
| 2366 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2366 | 2367 | metadata: Sequence[Tuple[str, str]] = (),
|
2367 | 2368 | ) -> None:
|
2368 | 2369 | r"""Starts asynchronous cancellation on a long-running operation.
|
@@ -2416,7 +2417,7 @@ async def get_location(
|
2416 | 2417 | request: Optional[locations_pb2.GetLocationRequest] = None,
|
2417 | 2418 | *,
|
2418 | 2419 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2419 |
| - timeout: Optional[float] = None, |
| 2420 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2420 | 2421 | metadata: Sequence[Tuple[str, str]] = (),
|
2421 | 2422 | ) -> locations_pb2.Location:
|
2422 | 2423 | r"""Gets information about a location.
|
@@ -2470,7 +2471,7 @@ async def list_locations(
|
2470 | 2471 | request: Optional[locations_pb2.ListLocationsRequest] = None,
|
2471 | 2472 | *,
|
2472 | 2473 | retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
2473 |
| - timeout: Optional[float] = None, |
| 2474 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
2474 | 2475 | metadata: Sequence[Tuple[str, str]] = (),
|
2475 | 2476 | ) -> locations_pb2.ListLocationsResponse:
|
2476 | 2477 | r"""Lists information about the supported locations for this service.
|
@@ -2526,14 +2527,9 @@ async def __aexit__(self, exc_type, exc, tb):
|
2526 | 2527 | await self.transport.close()
|
2527 | 2528 |
|
2528 | 2529 |
|
2529 |
| -try: |
2530 |
| - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
2531 |
| - gapic_version=pkg_resources.get_distribution( |
2532 |
| - "google-cloud-documentai", |
2533 |
| - ).version, |
2534 |
| - ) |
2535 |
| -except pkg_resources.DistributionNotFound: |
2536 |
| - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
| 2530 | +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
| 2531 | + gapic_version=package_version.__version__ |
| 2532 | +) |
2537 | 2533 |
|
2538 | 2534 |
|
2539 | 2535 | __all__ = ("DocumentProcessorServiceAsyncClient",)
|
0 commit comments