google-api-core 2.31.0__tar.gz → 2.33.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. {google_api_core-2.31.0/google_api_core.egg-info → google_api_core-2.33.0}/PKG-INFO +1 -1
  2. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/__init__.py +1 -2
  3. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/_python_package_support.py +2 -4
  4. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/_python_version_support.py +3 -4
  5. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/bidi.py +1 -1
  6. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/bidi_async.py +1 -3
  7. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/client_logging.py +1 -2
  8. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/datetime_helpers.py +0 -1
  9. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/exceptions.py +14 -4
  10. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/future/_helpers.py +0 -1
  11. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/future/async_future.py +2 -4
  12. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/future/polling.py +1 -2
  13. google_api_core-2.33.0/google/api_core/gapic_v1/__init__.py +57 -0
  14. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/client_info.py +0 -1
  15. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/config.py +1 -4
  16. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/method_async.py +5 -3
  17. google_api_core-2.33.0/google/api_core/gapic_v1/requests.py +72 -0
  18. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/grpc_helpers_async.py +0 -1
  19. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operation.py +3 -3
  20. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operation_async.py +3 -3
  21. google_api_core-2.33.0/google/api_core/operations_v1/__init__.py +81 -0
  22. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/abstract_operations_base_client.py +2 -3
  23. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/abstract_operations_client.py +8 -7
  24. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_async_client.py +3 -2
  25. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_client.py +4 -4
  26. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_rest_client_async.py +5 -4
  27. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers.py +1 -0
  28. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers_async.py +2 -1
  29. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/__init__.py +1 -1
  30. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/base.py +7 -5
  31. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/rest.py +13 -9
  32. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/rest_asyncio.py +31 -15
  33. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/path_template.py +2 -3
  34. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/protobuf_helpers.py +1 -4
  35. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/rest_streaming.py +2 -1
  36. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/rest_streaming_async.py +1 -0
  37. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/__init__.py +19 -16
  38. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/retry_base.py +2 -3
  39. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/retry_streaming.py +15 -14
  40. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/retry_streaming_async.py +17 -17
  41. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/retry_unary.py +10 -9
  42. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry/retry_unary_async.py +12 -11
  43. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/retry_async.py +10 -7
  44. google_api_core-2.33.0/google/api_core/universe.py +199 -0
  45. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/version.py +1 -1
  46. {google_api_core-2.31.0 → google_api_core-2.33.0/google_api_core.egg-info}/PKG-INFO +1 -1
  47. {google_api_core-2.31.0 → google_api_core-2.33.0}/google_api_core.egg-info/SOURCES.txt +2 -0
  48. {google_api_core-2.31.0 → google_api_core-2.33.0}/setup.py +0 -1
  49. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/gapic/test_config_async.py +0 -1
  50. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/gapic/test_method_async.py +8 -6
  51. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/operations_v1/test_operations_async_client.py +3 -4
  52. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/retry/test_retry_streaming_async.py +4 -3
  53. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/retry/test_retry_unary_async.py +1 -2
  54. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/test_bidi_async.py +1 -3
  55. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/test_grpc_helpers_async.py +4 -3
  56. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/test_operation_async.py +3 -6
  57. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/test_rest_streaming_async.py +5 -8
  58. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/helpers.py +2 -4
  59. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/gapic/test_config.py +0 -1
  60. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/gapic/test_method.py +1 -3
  61. google_api_core-2.33.0/tests/unit/gapic/test_requests.py +127 -0
  62. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/operations_v1/test_operations_client.py +52 -4
  63. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/operations_v1/test_operations_rest_client.py +19 -10
  64. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_base.py +6 -11
  65. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_imports.py +5 -3
  66. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_streaming.py +4 -4
  67. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_unary.py +3 -3
  68. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_bidi.py +1 -2
  69. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_client_options.py +3 -1
  70. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_datetime_helpers.py +1 -2
  71. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_exceptions.py +17 -1
  72. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_extended_operation.py +1 -3
  73. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_grpc_helpers.py +3 -2
  74. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_iam.py +3 -2
  75. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_operation.py +3 -6
  76. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_path_template.py +2 -1
  77. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_protobuf_helpers.py +13 -12
  78. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_python_version_support.py +20 -15
  79. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_rest_streaming.py +2 -4
  80. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_timeout.py +2 -1
  81. google_api_core-2.33.0/tests/unit/test_universe.py +261 -0
  82. google_api_core-2.31.0/google/api_core/gapic_v1/__init__.py +0 -29
  83. google_api_core-2.31.0/google/api_core/operations_v1/__init__.py +0 -40
  84. google_api_core-2.31.0/google/api_core/universe.py +0 -82
  85. google_api_core-2.31.0/tests/unit/test_universe.py +0 -63
  86. {google_api_core-2.31.0 → google_api_core-2.33.0}/LICENSE +0 -0
  87. {google_api_core-2.31.0 → google_api_core-2.33.0}/MANIFEST.in +0 -0
  88. {google_api_core-2.31.0 → google_api_core-2.33.0}/README.rst +0 -0
  89. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/_rest_streaming_base.py +3 -3
  90. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/bidi_base.py +0 -0
  91. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/client_info.py +0 -0
  92. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/client_options.py +1 -1
  93. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/extended_operation.py +0 -0
  94. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/future/__init__.py +0 -0
  95. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/future/base.py +0 -0
  96. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/config_async.py +0 -0
  97. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/method.py +0 -0
  98. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/routing_header.py +0 -0
  99. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/general_helpers.py +0 -0
  100. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/grpc_helpers.py +2 -2
  101. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/iam.py +0 -0
  102. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_client_config.py +0 -0
  103. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers_base.py +0 -0
  104. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/page_iterator.py +0 -0
  105. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/page_iterator_async.py +0 -0
  106. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/py.typed +0 -0
  107. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/rest_helpers.py +0 -0
  108. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/timeout.py +0 -0
  109. {google_api_core-2.31.0 → google_api_core-2.33.0}/google/api_core/version_header.py +0 -0
  110. {google_api_core-2.31.0 → google_api_core-2.33.0}/google_api_core.egg-info/dependency_links.txt +0 -0
  111. {google_api_core-2.31.0 → google_api_core-2.33.0}/google_api_core.egg-info/requires.txt +0 -0
  112. {google_api_core-2.31.0 → google_api_core-2.33.0}/google_api_core.egg-info/top_level.txt +0 -0
  113. {google_api_core-2.31.0 → google_api_core-2.33.0}/pyproject.toml +0 -0
  114. {google_api_core-2.31.0 → google_api_core-2.33.0}/setup.cfg +0 -0
  115. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/__init__.py +0 -0
  116. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/__init__.py +0 -0
  117. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/future/__init__.py +0 -0
  118. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/future/test_async_future.py +0 -0
  119. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/operations_v1/__init__.py +0 -0
  120. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/retry/__init__.py +0 -0
  121. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/asyncio/test_page_iterator_async.py +0 -0
  122. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/__init__.py +0 -0
  123. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/future/__init__.py +0 -0
  124. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/future/test__helpers.py +0 -0
  125. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/future/test_polling.py +0 -0
  126. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/gapic/test_client_info.py +0 -0
  127. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/gapic/test_routing_header.py +0 -0
  128. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/operations_v1/__init__.py +0 -0
  129. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/retry/__init__.py +0 -0
  130. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_client_info.py +0 -0
  131. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_client_logging.py +2 -2
  132. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_packaging.py +0 -0
  133. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_page_iterator.py +0 -0
  134. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_python_package_support.py +4 -4
  135. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_rest_helpers.py +0 -0
  136. {google_api_core-2.31.0 → google_api_core-2.33.0}/tests/unit/test_version_header.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-api-core
3
- Version: 2.31.0
3
+ Version: 2.33.0
4
4
  Summary: Google API client core library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache 2.0
@@ -17,8 +17,7 @@
17
17
  This package contains common code and utilities used by Google client libraries.
18
18
  """
19
19
 
20
- from google.api_core import _python_package_support
21
- from google.api_core import _python_version_support
20
+ from google.api_core import _python_package_support, _python_version_support
22
21
  from google.api_core import version as api_core_version
23
22
 
24
23
  __version__ = api_core_version.__version__
@@ -15,17 +15,15 @@
15
15
  """Code to check versions of dependencies used by Google Cloud Client Libraries."""
16
16
 
17
17
  import warnings
18
- from typing import Optional, Tuple
19
-
20
18
  from collections import namedtuple
19
+ from importlib import metadata
20
+ from typing import Optional, Tuple
21
21
 
22
22
  from ._python_version_support import (
23
23
  _flatten_message,
24
24
  _get_distribution_and_import_packages,
25
25
  )
26
26
 
27
- from importlib import metadata
28
-
29
27
  ParsedVersion = Tuple[int, ...]
30
28
 
31
29
  # Here we list all the packages for which we want to issue warnings
@@ -17,13 +17,12 @@
17
17
  import datetime
18
18
  import enum
19
19
  import functools
20
- from importlib import metadata
21
20
  import logging
22
- import warnings
23
21
  import sys
24
22
  import textwrap
25
- from typing import Any, List, NamedTuple, Optional, Dict, Tuple
26
-
23
+ import warnings
24
+ from importlib import metadata
25
+ from typing import Any, Dict, List, NamedTuple, Optional, Tuple
27
26
 
28
27
  _LOGGER = logging.getLogger(__name__)
29
28
 
@@ -113,7 +113,7 @@ class _RequestQueueGenerator(object):
113
113
  except queue_module.Empty:
114
114
  if not self._is_active():
115
115
  _LOGGER.debug(
116
- "Empty queue and inactive call, exiting request " "generator."
116
+ "Empty queue and inactive call, exiting request generator."
117
117
  )
118
118
  return
119
119
  else:
@@ -18,14 +18,12 @@ import asyncio
18
18
  import logging
19
19
  from typing import Callable, Optional, Union
20
20
 
21
+ from google.protobuf.message import Message as ProtobufMessage
21
22
  from grpc import aio
22
23
 
23
24
  from google.api_core import exceptions
24
25
  from google.api_core.bidi_base import BidiRpcBase
25
26
 
26
- from google.protobuf.message import Message as ProtobufMessage
27
-
28
-
29
27
  _LOGGER = logging.getLogger(__name__)
30
28
 
31
29
 
@@ -1,7 +1,6 @@
1
- import logging
2
1
  import json
2
+ import logging
3
3
  import os
4
-
5
4
  from typing import List, Optional
6
5
 
7
6
  _LOGGING_INITIALIZED = False
@@ -20,7 +20,6 @@ import re
20
20
 
21
21
  from google.protobuf import timestamp_pb2
22
22
 
23
-
24
23
  _UTC_EPOCH = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
25
24
  _RFC3339_MICROS = "%Y-%m-%dT%H:%M:%S.%fZ"
26
25
  _RFC3339_NO_FRACTION = "%Y-%m-%dT%H:%M:%S"
@@ -18,12 +18,11 @@ This module provides base classes for all errors raised by libraries based
18
18
  on :mod:`google.api_core`, including both HTTP and gRPC clients.
19
19
  """
20
20
 
21
- from __future__ import absolute_import
22
- from __future__ import unicode_literals
21
+ from __future__ import absolute_import, unicode_literals
23
22
 
24
23
  import http.client
25
- from typing import Optional, Dict
26
24
  import warnings
25
+ from typing import Dict, Optional
27
26
 
28
27
  from google.rpc import error_details_pb2
29
28
 
@@ -657,9 +656,20 @@ def from_grpc_error(rpc_exc):
657
656
  grpc is not None and isinstance(rpc_exc, grpc.Call)
658
657
  ) or _is_informative_grpc_error(rpc_exc):
659
658
  details, err_info = _parse_grpc_error_details(rpc_exc)
659
+ message = rpc_exc.details()
660
+ if (
661
+ grpc is not None
662
+ and rpc_exc.code() == grpc.StatusCode.UNIMPLEMENTED
663
+ and "Received http2 header with status: 404" in message
664
+ ):
665
+ message = (
666
+ f"{message}. This usually indicates that the 'api_endpoint' "
667
+ "configuration in ClientOptions is incorrect, contains a typo, "
668
+ "or is an invalid regional endpoint for this service."
669
+ )
660
670
  return from_grpc_status(
661
671
  rpc_exc.code(),
662
- rpc_exc.details(),
672
+ message,
663
673
  errors=(rpc_exc,),
664
674
  details=details,
665
675
  response=rpc_exc,
@@ -17,7 +17,6 @@
17
17
  import logging
18
18
  import threading
19
19
 
20
-
21
20
  _LOGGER = logging.getLogger(__name__)
22
21
 
23
22
 
@@ -16,9 +16,7 @@
16
16
 
17
17
  import asyncio
18
18
 
19
- from google.api_core import exceptions
20
- from google.api_core import retry
21
- from google.api_core import retry_async
19
+ from google.api_core import exceptions, retry, retry_async
22
20
  from google.api_core.future import base
23
21
 
24
22
 
@@ -101,7 +99,7 @@ class AsyncFuture(base.Future):
101
99
  await retry_(self._done_or_raise)()
102
100
  except exceptions.RetryError:
103
101
  raise asyncio.TimeoutError(
104
- "Operation did not complete within the designated " "timeout."
102
+ "Operation did not complete within the designated timeout."
105
103
  )
106
104
 
107
105
  async def result(self, timeout=None):
@@ -19,8 +19,7 @@ import concurrent.futures
19
19
 
20
20
  from google.api_core import exceptions
21
21
  from google.api_core import retry as retries
22
- from google.api_core.future import _helpers
23
- from google.api_core.future import base
22
+ from google.api_core.future import _helpers, base
24
23
 
25
24
 
26
25
  class _OperationNotComplete(Exception):
@@ -0,0 +1,57 @@
1
+ # Copyright 2017 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import importlib.util
16
+ from typing import Set
17
+
18
+ _has_grpc = importlib.util.find_spec("grpc") is not None
19
+
20
+ # PEP 0810: Explicit Lazy Imports
21
+ # Python 3.15+ natively intercepts and defers these imports.
22
+ # Developers can disable this behavior and force eager imports.
23
+ # For more information, see:
24
+ # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
25
+ # Older Python versions safely ignore this variable.
26
+ __lazy_modules__: Set[str] = {
27
+ "google.api_core.gapic_v1.client_info",
28
+ "google.api_core.gapic_v1.requests",
29
+ "google.api_core.gapic_v1.routing_header",
30
+ }
31
+ __all__ = ["client_info", "requests", "routing_header"]
32
+
33
+ if _has_grpc:
34
+ __lazy_modules__.update(
35
+ {
36
+ "google.api_core.gapic_v1.config",
37
+ "google.api_core.gapic_v1.config_async",
38
+ "google.api_core.gapic_v1.method",
39
+ "google.api_core.gapic_v1.method_async",
40
+ }
41
+ )
42
+
43
+ from google.api_core.gapic_v1 import ( # noqa: E402
44
+ client_info,
45
+ requests,
46
+ routing_header,
47
+ )
48
+
49
+ if _has_grpc:
50
+ from google.api_core.gapic_v1 import ( # noqa: F401
51
+ config,
52
+ config_async,
53
+ method,
54
+ method_async,
55
+ )
56
+
57
+ __all__.extend(["config", "config_async", "method", "method_async"])
@@ -20,7 +20,6 @@ such as the library and Python version, to API services.
20
20
 
21
21
  from google.api_core import client_info
22
22
 
23
-
24
23
  METRICS_METADATA_KEY = "x-goog-api-client"
25
24
 
26
25
 
@@ -22,10 +22,7 @@ import collections
22
22
 
23
23
  import grpc
24
24
 
25
- from google.api_core import exceptions
26
- from google.api_core import retry
27
- from google.api_core import timeout
28
-
25
+ from google.api_core import exceptions, retry, timeout
29
26
 
30
27
  _MILLIS_PER_SECOND = 1000.0
31
28
 
@@ -21,9 +21,11 @@ import functools
21
21
 
22
22
  from google.api_core import grpc_helpers_async
23
23
  from google.api_core.gapic_v1 import client_info
24
- from google.api_core.gapic_v1.method import _GapicCallable
25
- from google.api_core.gapic_v1.method import DEFAULT # noqa: F401
26
- from google.api_core.gapic_v1.method import USE_DEFAULT_METADATA # noqa: F401
24
+ from google.api_core.gapic_v1.method import ( # noqa: F401
25
+ DEFAULT,
26
+ USE_DEFAULT_METADATA,
27
+ _GapicCallable,
28
+ )
27
29
 
28
30
  _DEFAULT_ASYNC_TRANSPORT_KIND = "grpc_asyncio"
29
31
 
@@ -0,0 +1,72 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2026 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ """Helpers for preparing and structuring API requests.
18
+
19
+ This module provides utilities to preprocess request parameters and objects
20
+ before invoking API methods, such as automatically generating request IDs
21
+ if they are not already set.
22
+ """
23
+
24
+ import uuid
25
+ from typing import Union
26
+
27
+ import google.protobuf.message
28
+
29
+
30
+ def setup_request_id(
31
+ request: Union[google.protobuf.message.Message, dict, None],
32
+ field_name: str,
33
+ is_proto3_optional: bool,
34
+ ) -> None:
35
+ """Populate a UUID4 field in the request if it is not already set.
36
+
37
+ This helper is used to ensure request idempotency by automatically
38
+ generating a unique identifier (such as `request_id`) for requests
39
+ that support it. If a request is retried, the same identifier can be
40
+ sent on subsequent retries, allowing the server to recognize the retried
41
+ request and prevent duplicate processing (e.g., creating duplicate
42
+ resources).
43
+
44
+ Args:
45
+ request (Union[google.protobuf.message.Message, dict]): The
46
+ request object.
47
+ field_name (str): The name of the field to populate.
48
+ is_proto3_optional (bool): Whether the field is proto3 optional.
49
+ """
50
+ if request is None:
51
+ return
52
+
53
+ if isinstance(request, dict):
54
+ if is_proto3_optional:
55
+ if field_name not in request or request[field_name] is None:
56
+ request[field_name] = str(uuid.uuid4())
57
+ elif not request.get(field_name):
58
+ request[field_name] = str(uuid.uuid4())
59
+ return
60
+
61
+ if is_proto3_optional:
62
+ try:
63
+ # Pure protobuf messages
64
+ if not request.HasField(field_name):
65
+ setattr(request, field_name, str(uuid.uuid4()))
66
+ except (AttributeError, ValueError):
67
+ # Proto-plus messages or other objects
68
+ if getattr(request, field_name, None) is None:
69
+ setattr(request, field_name, str(uuid.uuid4()))
70
+ else:
71
+ if not getattr(request, field_name, None):
72
+ setattr(request, field_name, str(uuid.uuid4()))
@@ -21,7 +21,6 @@ functions. This module is implementing the same surface with AsyncIO semantics.
21
21
  import asyncio
22
22
  import functools
23
23
  import warnings
24
-
25
24
  from typing import AsyncGenerator, Generic, Iterator, Optional, TypeVar
26
25
 
27
26
  import grpc
@@ -39,13 +39,13 @@ Or asynchronously using callbacks and :meth:`Operation.add_done_callback`:
39
39
  import functools
40
40
  import threading
41
41
 
42
- from google.api_core import exceptions
43
- from google.api_core import protobuf_helpers
44
- from google.api_core.future import polling
45
42
  from google.longrunning import operations_pb2
46
43
  from google.protobuf import json_format
47
44
  from google.rpc import code_pb2
48
45
 
46
+ from google.api_core import exceptions, protobuf_helpers
47
+ from google.api_core.future import polling
48
+
49
49
 
50
50
  class Operation(polling.PollingFuture):
51
51
  """A Future for interacting with a Google API Long-Running Operation.
@@ -39,12 +39,12 @@ Or asynchronously using callbacks and :meth:`Operation.add_done_callback`:
39
39
  import functools
40
40
  import threading
41
41
 
42
- from google.api_core import exceptions
43
- from google.api_core import protobuf_helpers
44
- from google.api_core.future import async_future
45
42
  from google.longrunning import operations_pb2
46
43
  from google.rpc import code_pb2
47
44
 
45
+ from google.api_core import exceptions, protobuf_helpers
46
+ from google.api_core.future import async_future
47
+
48
48
 
49
49
  class AsyncOperation(async_future.AsyncFuture):
50
50
  """A Future for interacting with a Google API Long-Running Operation.
@@ -0,0 +1,81 @@
1
+ # Copyright 2017 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Package for interacting with the google.longrunning.operations meta-API."""
16
+
17
+ import importlib.util
18
+ from typing import Set
19
+
20
+ try:
21
+ _has_async_rest = (
22
+ importlib.util.find_spec("google.auth.aio.transport.sessions") is not None
23
+ )
24
+ except ModuleNotFoundError:
25
+ _has_async_rest = False
26
+
27
+ # PEP 0810: Explicit Lazy Imports
28
+ # Python 3.15+ natively intercepts and defers these imports.
29
+ # Developers can disable this behavior and force eager imports.
30
+ # For more information, see:
31
+ # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
32
+ # Older Python versions safely ignore this variable.
33
+ # NOTE: We statically define all modules here (including async ones) to ensure
34
+ # static analysis tools (mypy, pyright, Ruff) can easily parse them. If async
35
+ # support is not present, the imports are ignored, making their presence safe.
36
+ __lazy_modules__: Set[str] = {
37
+ "google.api_core.operations_v1.abstract_operations_client",
38
+ "google.api_core.operations_v1.operations_async_client",
39
+ "google.api_core.operations_v1.operations_client",
40
+ "google.api_core.operations_v1.transports.rest",
41
+ "google.api_core.operations_v1.transports.rest_asyncio",
42
+ "google.api_core.operations_v1.operations_rest_client_async",
43
+ }
44
+
45
+ __all__ = [
46
+ "AbstractOperationsClient",
47
+ "OperationsAsyncClient",
48
+ "OperationsClient",
49
+ "OperationsRestTransport",
50
+ ]
51
+
52
+
53
+ from google.api_core.operations_v1.abstract_operations_client import ( # noqa: E402
54
+ AbstractOperationsClient,
55
+ )
56
+ from google.api_core.operations_v1.operations_async_client import ( # noqa: E402
57
+ OperationsAsyncClient,
58
+ )
59
+ from google.api_core.operations_v1.operations_client import ( # noqa: E402
60
+ OperationsClient,
61
+ )
62
+ from google.api_core.operations_v1.transports.rest import ( # noqa: E402
63
+ OperationsRestTransport,
64
+ )
65
+
66
+ if _has_async_rest:
67
+ try:
68
+ # On Python 3.15+, PEP 0810 lazy loading means these imports will succeed
69
+ # instantly (returning a lazy proxy). Any actual ImportErrors (e.g., due to
70
+ # missing aiohttp/auth dependencies) are deferred until the proxies are accessed.
71
+ from google.api_core.operations_v1.operations_rest_client_async import ( # noqa: E402, F401
72
+ AsyncOperationsRestClient,
73
+ )
74
+ from google.api_core.operations_v1.transports.rest_asyncio import ( # noqa: E402, F401
75
+ AsyncOperationsRestTransport,
76
+ )
77
+
78
+ __all__.extend(["AsyncOperationsRestClient", "AsyncOperationsRestTransport"])
79
+ except ImportError:
80
+ # Fallback for older python/environments when importlib find_spec succeeds but actual import fails
81
+ pass
@@ -13,9 +13,9 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- from collections import OrderedDict
17
16
  import os
18
17
  import re
18
+ from collections import OrderedDict
19
19
  from typing import Dict, Optional, Type, Union
20
20
 
21
21
  from google.api_core import client_options as client_options_lib # type: ignore
@@ -358,8 +358,7 @@ class AbstractOperationsBaseClient(metaclass=AbstractOperationsBaseClientMeta):
358
358
  )
359
359
  if client_options.scopes:
360
360
  raise ValueError(
361
- "When providing a transport instance, provide its scopes "
362
- "directly."
361
+ "When providing a transport instance, provide its scopes directly."
363
362
  )
364
363
  self._transport = transport
365
364
  else:
@@ -15,21 +15,22 @@
15
15
  #
16
16
  from typing import Optional, Sequence, Tuple, Union
17
17
 
18
+ import grpc
19
+ from google.auth import credentials as ga_credentials # type: ignore
20
+ from google.longrunning import operations_pb2
21
+ from google.oauth2 import service_account # type: ignore
22
+
18
23
  from google.api_core import client_options as client_options_lib # type: ignore
19
24
  from google.api_core import gapic_v1 # type: ignore
20
25
  from google.api_core import retry as retries # type: ignore
21
26
  from google.api_core.operations_v1 import pagers
27
+ from google.api_core.operations_v1.abstract_operations_base_client import (
28
+ AbstractOperationsBaseClient,
29
+ )
22
30
  from google.api_core.operations_v1.transports.base import (
23
31
  DEFAULT_CLIENT_INFO,
24
32
  OperationsTransport,
25
33
  )
26
- from google.api_core.operations_v1.abstract_operations_base_client import (
27
- AbstractOperationsBaseClient,
28
- )
29
- from google.auth import credentials as ga_credentials # type: ignore
30
- from google.longrunning import operations_pb2
31
- from google.oauth2 import service_account # type: ignore
32
- import grpc
33
34
 
34
35
  OptionalRetry = Union[retries.Retry, object]
35
36
 
@@ -24,12 +24,13 @@
24
24
 
25
25
  import functools
26
26
 
27
+ from google.longrunning import operations_pb2
28
+ from grpc import Compression
29
+
27
30
  from google.api_core import exceptions as core_exceptions
28
31
  from google.api_core import gapic_v1, page_iterator_async
29
32
  from google.api_core import retry_async as retries
30
33
  from google.api_core import timeout as timeouts
31
- from google.longrunning import operations_pb2
32
- from grpc import Compression
33
34
 
34
35
 
35
36
  class OperationsAsyncClient:
@@ -37,13 +37,13 @@ automatically by another client class to deal with operations.
37
37
 
38
38
  import functools
39
39
 
40
+ from google.longrunning import operations_pb2
41
+ from grpc import Compression
42
+
40
43
  from google.api_core import exceptions as core_exceptions
41
- from google.api_core import gapic_v1
42
- from google.api_core import page_iterator
44
+ from google.api_core import gapic_v1, page_iterator
43
45
  from google.api_core import retry as retries
44
46
  from google.api_core import timeout as timeouts
45
- from google.longrunning import operations_pb2
46
- from grpc import Compression
47
47
 
48
48
 
49
49
  class OperationsClient(object):
@@ -15,17 +15,18 @@
15
15
  #
16
16
  from typing import Optional, Sequence, Tuple, Union
17
17
 
18
+ from google.longrunning import operations_pb2
19
+
18
20
  from google.api_core import client_options as client_options_lib # type: ignore
19
21
  from google.api_core import gapic_v1 # type: ignore
20
22
  from google.api_core.operations_v1 import pagers_async as pagers
23
+ from google.api_core.operations_v1.abstract_operations_base_client import (
24
+ AbstractOperationsBaseClient,
25
+ )
21
26
  from google.api_core.operations_v1.transports.base import (
22
27
  DEFAULT_CLIENT_INFO,
23
28
  OperationsTransport,
24
29
  )
25
- from google.api_core.operations_v1.abstract_operations_base_client import (
26
- AbstractOperationsBaseClient,
27
- )
28
- from google.longrunning import operations_pb2
29
30
 
30
31
  try:
31
32
  from google.auth.aio import credentials as ga_credentials # type: ignore
@@ -21,6 +21,7 @@ from typing import (
21
21
  )
22
22
 
23
23
  from google.longrunning import operations_pb2
24
+
24
25
  from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
25
26
 
26
27
 
@@ -14,13 +14,14 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  from typing import (
17
- Callable,
18
17
  AsyncIterator,
18
+ Callable,
19
19
  Sequence,
20
20
  Tuple,
21
21
  )
22
22
 
23
23
  from google.longrunning import operations_pb2
24
+
24
25
  from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
25
26
 
26
27
 
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  from collections import OrderedDict
17
- from typing import cast, Dict, Tuple
17
+ from typing import Dict, Tuple, cast
18
18
 
19
19
  from .base import OperationsTransport
20
20
  from .rest import OperationsRestTransport
@@ -15,23 +15,25 @@
15
15
  #
16
16
  import abc
17
17
  import re
18
- from typing import Awaitable, Callable, Optional, Sequence, Union
19
18
  import warnings
19
+ from typing import Awaitable, Callable, Optional, Sequence, Union
20
20
 
21
21
  import google.auth # type: ignore
22
+ import google.protobuf
22
23
  from google.auth import credentials as ga_credentials # type: ignore
23
24
  from google.longrunning import operations_pb2
24
25
  from google.oauth2 import service_account # type: ignore
25
- import google.protobuf
26
26
  from google.protobuf import empty_pb2, json_format # type: ignore
27
27
  from grpc import Compression
28
28
 
29
29
  import google.api_core # type: ignore
30
30
  from google.api_core import exceptions as core_exceptions # type: ignore
31
- from google.api_core import gapic_v1 # type: ignore
32
- from google.api_core import general_helpers
31
+ from google.api_core import (
32
+ gapic_v1, # type: ignore
33
+ general_helpers,
34
+ version,
35
+ )
33
36
  from google.api_core import retry as retries # type: ignore
34
- from google.api_core import version
35
37
 
36
38
  PROTOBUF_VERSION = google.protobuf.__version__
37
39