google-api-core 2.32.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 (134) hide show
  1. {google_api_core-2.32.0/google_api_core.egg-info → google_api_core-2.33.0}/PKG-INFO +1 -1
  2. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/__init__.py +1 -2
  3. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/_python_package_support.py +2 -4
  4. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/_python_version_support.py +3 -4
  5. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/bidi.py +1 -1
  6. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/bidi_async.py +1 -3
  7. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/client_logging.py +1 -2
  8. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/datetime_helpers.py +0 -1
  9. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/future/_helpers.py +0 -1
  10. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/future/async_future.py +2 -4
  11. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/future/polling.py +1 -2
  12. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/__init__.py +3 -1
  13. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/client_info.py +0 -1
  14. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/config.py +1 -4
  15. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/method_async.py +5 -3
  16. google_api_core-2.33.0/google/api_core/gapic_v1/requests.py +72 -0
  17. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/grpc_helpers_async.py +0 -1
  18. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operation.py +3 -3
  19. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operation_async.py +3 -3
  20. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/abstract_operations_base_client.py +2 -3
  21. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/abstract_operations_client.py +8 -7
  22. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_async_client.py +3 -2
  23. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_client.py +4 -4
  24. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_rest_client_async.py +5 -4
  25. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers.py +1 -0
  26. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers_async.py +2 -1
  27. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/__init__.py +1 -1
  28. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/base.py +7 -5
  29. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/rest.py +13 -9
  30. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/transports/rest_asyncio.py +31 -15
  31. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/path_template.py +2 -3
  32. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/protobuf_helpers.py +1 -4
  33. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/rest_streaming.py +2 -1
  34. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/rest_streaming_async.py +1 -0
  35. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/__init__.py +19 -16
  36. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/retry_base.py +2 -3
  37. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/retry_streaming.py +15 -14
  38. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/retry_streaming_async.py +17 -17
  39. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/retry_unary.py +10 -9
  40. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry/retry_unary_async.py +12 -11
  41. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/retry_async.py +10 -7
  42. google_api_core-2.33.0/google/api_core/universe.py +199 -0
  43. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/version.py +1 -1
  44. {google_api_core-2.32.0 → google_api_core-2.33.0/google_api_core.egg-info}/PKG-INFO +1 -1
  45. {google_api_core-2.32.0 → google_api_core-2.33.0}/google_api_core.egg-info/SOURCES.txt +2 -0
  46. {google_api_core-2.32.0 → google_api_core-2.33.0}/setup.py +0 -1
  47. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/gapic/test_config_async.py +0 -1
  48. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/gapic/test_method_async.py +8 -6
  49. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/operations_v1/test_operations_async_client.py +3 -4
  50. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/retry/test_retry_streaming_async.py +3 -2
  51. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/retry/test_retry_unary_async.py +1 -2
  52. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/test_bidi_async.py +1 -3
  53. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/test_grpc_helpers_async.py +4 -3
  54. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/test_operation_async.py +3 -6
  55. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/test_rest_streaming_async.py +5 -8
  56. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/helpers.py +2 -4
  57. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/gapic/test_config.py +0 -1
  58. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/gapic/test_method.py +1 -3
  59. google_api_core-2.33.0/tests/unit/gapic/test_requests.py +127 -0
  60. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/operations_v1/test_operations_client.py +52 -4
  61. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/operations_v1/test_operations_rest_client.py +19 -10
  62. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_base.py +6 -11
  63. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_imports.py +5 -3
  64. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_streaming.py +3 -3
  65. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/retry/test_retry_unary.py +3 -3
  66. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_bidi.py +1 -2
  67. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_client_options.py +3 -1
  68. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_datetime_helpers.py +1 -2
  69. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_extended_operation.py +1 -3
  70. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_grpc_helpers.py +3 -2
  71. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_iam.py +3 -2
  72. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_operation.py +3 -6
  73. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_path_template.py +2 -1
  74. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_protobuf_helpers.py +13 -12
  75. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_rest_streaming.py +2 -4
  76. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_timeout.py +2 -1
  77. google_api_core-2.33.0/tests/unit/test_universe.py +261 -0
  78. google_api_core-2.32.0/google/api_core/universe.py +0 -82
  79. google_api_core-2.32.0/tests/unit/test_universe.py +0 -63
  80. {google_api_core-2.32.0 → google_api_core-2.33.0}/LICENSE +0 -0
  81. {google_api_core-2.32.0 → google_api_core-2.33.0}/MANIFEST.in +0 -0
  82. {google_api_core-2.32.0 → google_api_core-2.33.0}/README.rst +0 -0
  83. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/_rest_streaming_base.py +3 -3
  84. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/bidi_base.py +0 -0
  85. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/client_info.py +0 -0
  86. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/client_options.py +1 -1
  87. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/exceptions.py +0 -0
  88. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/extended_operation.py +0 -0
  89. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/future/__init__.py +0 -0
  90. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/future/base.py +0 -0
  91. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/config_async.py +0 -0
  92. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/method.py +0 -0
  93. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/gapic_v1/routing_header.py +0 -0
  94. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/general_helpers.py +0 -0
  95. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/grpc_helpers.py +2 -2
  96. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/iam.py +0 -0
  97. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/__init__.py +3 -3
  98. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/operations_client_config.py +0 -0
  99. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/operations_v1/pagers_base.py +0 -0
  100. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/page_iterator.py +0 -0
  101. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/page_iterator_async.py +0 -0
  102. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/py.typed +0 -0
  103. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/rest_helpers.py +0 -0
  104. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/timeout.py +0 -0
  105. {google_api_core-2.32.0 → google_api_core-2.33.0}/google/api_core/version_header.py +0 -0
  106. {google_api_core-2.32.0 → google_api_core-2.33.0}/google_api_core.egg-info/dependency_links.txt +0 -0
  107. {google_api_core-2.32.0 → google_api_core-2.33.0}/google_api_core.egg-info/requires.txt +0 -0
  108. {google_api_core-2.32.0 → google_api_core-2.33.0}/google_api_core.egg-info/top_level.txt +0 -0
  109. {google_api_core-2.32.0 → google_api_core-2.33.0}/pyproject.toml +0 -0
  110. {google_api_core-2.32.0 → google_api_core-2.33.0}/setup.cfg +0 -0
  111. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/__init__.py +0 -0
  112. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/__init__.py +0 -0
  113. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/future/__init__.py +0 -0
  114. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/future/test_async_future.py +0 -0
  115. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/operations_v1/__init__.py +0 -0
  116. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/retry/__init__.py +0 -0
  117. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/asyncio/test_page_iterator_async.py +0 -0
  118. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/__init__.py +0 -0
  119. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/future/__init__.py +0 -0
  120. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/future/test__helpers.py +0 -0
  121. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/future/test_polling.py +0 -0
  122. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/gapic/test_client_info.py +0 -0
  123. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/gapic/test_routing_header.py +0 -0
  124. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/operations_v1/__init__.py +0 -0
  125. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/retry/__init__.py +0 -0
  126. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_client_info.py +0 -0
  127. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_client_logging.py +2 -2
  128. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_exceptions.py +0 -0
  129. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_packaging.py +0 -0
  130. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_page_iterator.py +0 -0
  131. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_python_package_support.py +4 -4
  132. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_python_version_support.py +0 -0
  133. {google_api_core-2.32.0 → google_api_core-2.33.0}/tests/unit/test_rest_helpers.py +0 -0
  134. {google_api_core-2.32.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.32.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"
@@ -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):
@@ -25,9 +25,10 @@ _has_grpc = importlib.util.find_spec("grpc") is not None
25
25
  # Older Python versions safely ignore this variable.
26
26
  __lazy_modules__: Set[str] = {
27
27
  "google.api_core.gapic_v1.client_info",
28
+ "google.api_core.gapic_v1.requests",
28
29
  "google.api_core.gapic_v1.routing_header",
29
30
  }
30
- __all__ = ["client_info", "routing_header"]
31
+ __all__ = ["client_info", "requests", "routing_header"]
31
32
 
32
33
  if _has_grpc:
33
34
  __lazy_modules__.update(
@@ -41,6 +42,7 @@ if _has_grpc:
41
42
 
42
43
  from google.api_core.gapic_v1 import ( # noqa: E402
43
44
  client_info,
45
+ requests,
44
46
  routing_header,
45
47
  )
46
48
 
@@ -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.
@@ -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
 
@@ -14,23 +14,27 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- from typing import Callable, Dict, Optional, Sequence, Tuple, Union
18
17
  import warnings
18
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
19
19
 
20
+ import google.protobuf
21
+ import grpc
20
22
  from google.auth import credentials as ga_credentials # type: ignore
21
23
  from google.auth.transport.requests import AuthorizedSession # type: ignore
22
24
  from google.longrunning import operations_pb2 # type: ignore
23
- import google.protobuf
24
- from google.protobuf import empty_pb2 # type: ignore
25
- from google.protobuf import json_format # type: ignore
26
- import grpc
25
+ from google.protobuf import (
26
+ empty_pb2, # type: ignore
27
+ json_format, # type: ignore
28
+ )
27
29
  from requests import __version__ as requests_version
28
30
 
29
31
  from google.api_core import exceptions as core_exceptions # type: ignore
30
- from google.api_core import gapic_v1 # type: ignore
31
- from google.api_core import general_helpers
32
- from google.api_core import path_template # type: ignore
33
- from google.api_core import rest_helpers # type: ignore
32
+ from google.api_core import (
33
+ gapic_v1, # type: ignore
34
+ general_helpers,
35
+ path_template, # type: ignore
36
+ rest_helpers, # type: ignore
37
+ )
34
38
  from google.api_core import retry as retries # type: ignore
35
39
 
36
40
  from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
@@ -15,31 +15,39 @@
15
15
  #
16
16
 
17
17
  import json
18
- from typing import Any, Callable, Coroutine, Dict, Optional, Sequence, Tuple
19
18
  import warnings
19
+ from typing import Any, Callable, Coroutine, Dict, Optional, Sequence, Tuple
20
20
 
21
21
  from google.auth import __version__ as auth_version
22
22
 
23
23
  try:
24
- from google.auth.aio.transport.sessions import AsyncAuthorizedSession # type: ignore
24
+ from google.auth.aio.transport.sessions import (
25
+ AsyncAuthorizedSession, # type: ignore
26
+ )
25
27
  except ImportError as e: # pragma: NO COVER
26
28
  raise ImportError(
27
29
  "The `async_rest` extra of `google-api-core` is required to use long-running operations. Install it by running "
28
30
  "`pip install google-api-core[async_rest]`."
29
31
  ) from e
30
32
 
31
- from google.api_core import exceptions as core_exceptions # type: ignore
32
- from google.api_core import gapic_v1 # type: ignore
33
- from google.api_core import general_helpers
34
- from google.api_core import path_template # type: ignore
35
- from google.api_core import rest_helpers # type: ignore
36
- from google.api_core import retry_async as retries_async # type: ignore
37
33
  from google.auth.aio import credentials as ga_credentials_async # type: ignore
38
34
  from google.longrunning import operations_pb2 # type: ignore
39
- from google.protobuf import empty_pb2 # type: ignore
40
- from google.protobuf import json_format # type: ignore
35
+ from google.protobuf import (
36
+ empty_pb2, # type: ignore
37
+ json_format, # type: ignore
38
+ )
39
+
40
+ from google.api_core import exceptions as core_exceptions # type: ignore
41
+ from google.api_core import (
42
+ gapic_v1, # type: ignore
43
+ general_helpers,
44
+ path_template, # type: ignore
45
+ rest_helpers, # type: ignore
46
+ )
47
+ from google.api_core import retry_async as retries_async # type: ignore
41
48
 
42
- from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO, OperationsTransport
49
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
50
+ from .base import OperationsTransport
43
51
 
44
52
  DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
45
53
  gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
@@ -307,7 +315,9 @@ class AsyncOperationsRestTransport(OperationsTransport):
307
315
  if response.status_code >= 400:
308
316
  payload = json.loads(content.decode("utf-8"))
309
317
  request_url = "{host}{uri}".format(host=self._host, uri=uri)
310
- raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
318
+ raise core_exceptions.format_http_response_error(
319
+ response, method, request_url, payload
320
+ ) # type: ignore
311
321
 
312
322
  # Return the response
313
323
  api_response = operations_pb2.ListOperationsResponse()
@@ -385,7 +395,9 @@ class AsyncOperationsRestTransport(OperationsTransport):
385
395
  if response.status_code >= 400:
386
396
  payload = json.loads(content.decode("utf-8"))
387
397
  request_url = "{host}{uri}".format(host=self._host, uri=uri)
388
- raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
398
+ raise core_exceptions.format_http_response_error(
399
+ response, method, request_url, payload
400
+ ) # type: ignore
389
401
 
390
402
  # Return the response
391
403
  api_response = operations_pb2.Operation()
@@ -459,7 +471,9 @@ class AsyncOperationsRestTransport(OperationsTransport):
459
471
  content = await response.read()
460
472
  payload = json.loads(content.decode("utf-8"))
461
473
  request_url = "{host}{uri}".format(host=self._host, uri=uri)
462
- raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
474
+ raise core_exceptions.format_http_response_error(
475
+ response, method, request_url, payload
476
+ ) # type: ignore
463
477
 
464
478
  return empty_pb2.Empty()
465
479
 
@@ -539,7 +553,9 @@ class AsyncOperationsRestTransport(OperationsTransport):
539
553
  content = await response.read()
540
554
  payload = json.loads(content.decode("utf-8"))
541
555
  request_url = "{host}{uri}".format(host=self._host, uri=uri)
542
- raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore
556
+ raise core_exceptions.format_http_response_error(
557
+ response, method, request_url, payload
558
+ ) # type: ignore
543
559
 
544
560
  return empty_pb2.Empty()
545
561
 
@@ -25,10 +25,10 @@ in Google APIs for `resource names`_.
25
25
 
26
26
  from __future__ import unicode_literals
27
27
 
28
- from collections import deque
29
28
  import copy
30
29
  import functools
31
30
  import re
31
+ from collections import deque
32
32
 
33
33
  # Regular expression for extracting variable parts from a path template.
34
34
  # The variables can be expressed as:
@@ -321,8 +321,7 @@ def transcode(http_options, message=None, **request_kwargs):
321
321
  return request
322
322
 
323
323
  bindings_description = [
324
- '\n\tURI: "{}"'
325
- "\n\tRequired request fields:\n\t\t{}".format(
324
+ '\n\tURI: "{}"\n\tRequired request fields:\n\t\t{}'.format(
326
325
  uri,
327
326
  "\n\t\t".join(
328
327
  [