google-api-core 2.25.1__tar.gz → 2.25.2__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 (124) hide show
  1. {google_api_core-2.25.1/google_api_core.egg-info → google_api_core-2.25.2}/PKG-INFO +1 -1
  2. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/client_options.py +9 -2
  3. google_api_core-2.25.2/google/api_core/general_helpers.py +52 -0
  4. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/grpc_helpers.py +10 -7
  5. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/grpc_helpers_async.py +8 -3
  6. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/transports/base.py +13 -7
  7. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/transports/rest.py +19 -12
  8. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/transports/rest_asyncio.py +21 -0
  9. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/version.py +1 -1
  10. {google_api_core-2.25.1 → google_api_core-2.25.2/google_api_core.egg-info}/PKG-INFO +1 -1
  11. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/gapic/test_method_async.py +5 -1
  12. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/test_operation_async.py +2 -2
  13. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/gapic/test_method.py +5 -1
  14. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/operations_v1/test_operations_rest_client.py +33 -2
  15. google_api_core-2.25.1/google/api_core/general_helpers.py +0 -16
  16. {google_api_core-2.25.1 → google_api_core-2.25.2}/LICENSE +0 -0
  17. {google_api_core-2.25.1 → google_api_core-2.25.2}/MANIFEST.in +0 -0
  18. {google_api_core-2.25.1 → google_api_core-2.25.2}/README.rst +0 -0
  19. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/__init__.py +0 -0
  20. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/_rest_streaming_base.py +0 -0
  21. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/bidi.py +0 -0
  22. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/client_info.py +0 -0
  23. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/client_logging.py +0 -0
  24. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/datetime_helpers.py +0 -0
  25. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/exceptions.py +0 -0
  26. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/extended_operation.py +0 -0
  27. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/future/__init__.py +0 -0
  28. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/future/_helpers.py +0 -0
  29. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/future/async_future.py +0 -0
  30. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/future/base.py +0 -0
  31. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/future/polling.py +0 -0
  32. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/__init__.py +0 -0
  33. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/client_info.py +0 -0
  34. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/config.py +0 -0
  35. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/config_async.py +0 -0
  36. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/method.py +0 -0
  37. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/method_async.py +0 -0
  38. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/gapic_v1/routing_header.py +0 -0
  39. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/iam.py +0 -0
  40. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operation.py +0 -0
  41. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operation_async.py +0 -0
  42. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/__init__.py +0 -0
  43. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/abstract_operations_base_client.py +0 -0
  44. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/abstract_operations_client.py +0 -0
  45. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/operations_async_client.py +0 -0
  46. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/operations_client.py +0 -0
  47. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/operations_client_config.py +0 -0
  48. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/operations_rest_client_async.py +0 -0
  49. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/pagers.py +0 -0
  50. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/pagers_async.py +0 -0
  51. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/pagers_base.py +0 -0
  52. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/operations_v1/transports/__init__.py +0 -0
  53. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/page_iterator.py +0 -0
  54. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/page_iterator_async.py +0 -0
  55. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/path_template.py +0 -0
  56. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/protobuf_helpers.py +0 -0
  57. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/py.typed +0 -0
  58. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/rest_helpers.py +0 -0
  59. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/rest_streaming.py +0 -0
  60. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/rest_streaming_async.py +0 -0
  61. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/__init__.py +0 -0
  62. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/retry_base.py +0 -0
  63. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/retry_streaming.py +0 -0
  64. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/retry_streaming_async.py +0 -0
  65. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/retry_unary.py +0 -0
  66. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry/retry_unary_async.py +0 -0
  67. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/retry_async.py +0 -0
  68. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/timeout.py +0 -0
  69. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/universe.py +0 -0
  70. {google_api_core-2.25.1 → google_api_core-2.25.2}/google/api_core/version_header.py +0 -0
  71. {google_api_core-2.25.1 → google_api_core-2.25.2}/google_api_core.egg-info/SOURCES.txt +0 -0
  72. {google_api_core-2.25.1 → google_api_core-2.25.2}/google_api_core.egg-info/dependency_links.txt +0 -0
  73. {google_api_core-2.25.1 → google_api_core-2.25.2}/google_api_core.egg-info/requires.txt +0 -0
  74. {google_api_core-2.25.1 → google_api_core-2.25.2}/google_api_core.egg-info/top_level.txt +0 -0
  75. {google_api_core-2.25.1 → google_api_core-2.25.2}/pyproject.toml +0 -0
  76. {google_api_core-2.25.1 → google_api_core-2.25.2}/setup.cfg +0 -0
  77. {google_api_core-2.25.1 → google_api_core-2.25.2}/setup.py +0 -0
  78. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/__init__.py +0 -0
  79. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/__init__.py +0 -0
  80. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/future/__init__.py +0 -0
  81. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/future/test_async_future.py +0 -0
  82. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/gapic/test_config_async.py +0 -0
  83. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/operations_v1/__init__.py +0 -0
  84. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/operations_v1/test_operations_async_client.py +0 -0
  85. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/retry/__init__.py +0 -0
  86. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/retry/test_retry_streaming_async.py +0 -0
  87. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/retry/test_retry_unary_async.py +0 -0
  88. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/test_grpc_helpers_async.py +0 -0
  89. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/test_page_iterator_async.py +0 -0
  90. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/asyncio/test_rest_streaming_async.py +0 -0
  91. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/helpers.py +0 -0
  92. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/__init__.py +0 -0
  93. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/future/__init__.py +0 -0
  94. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/future/test__helpers.py +0 -0
  95. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/future/test_polling.py +0 -0
  96. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/gapic/test_client_info.py +0 -0
  97. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/gapic/test_config.py +0 -0
  98. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/gapic/test_routing_header.py +0 -0
  99. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/operations_v1/__init__.py +0 -0
  100. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/operations_v1/test_operations_client.py +0 -0
  101. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/retry/__init__.py +0 -0
  102. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/retry/test_retry_base.py +0 -0
  103. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/retry/test_retry_imports.py +0 -0
  104. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/retry/test_retry_streaming.py +0 -0
  105. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/retry/test_retry_unary.py +0 -0
  106. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_bidi.py +0 -0
  107. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_client_info.py +0 -0
  108. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_client_logging.py +0 -0
  109. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_client_options.py +0 -0
  110. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_datetime_helpers.py +0 -0
  111. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_exceptions.py +0 -0
  112. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_extended_operation.py +0 -0
  113. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_grpc_helpers.py +0 -0
  114. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_iam.py +0 -0
  115. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_operation.py +0 -0
  116. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_packaging.py +0 -0
  117. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_page_iterator.py +0 -0
  118. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_path_template.py +0 -0
  119. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_protobuf_helpers.py +0 -0
  120. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_rest_helpers.py +0 -0
  121. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_rest_streaming.py +0 -0
  122. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_timeout.py +0 -0
  123. {google_api_core-2.25.1 → google_api_core-2.25.2}/tests/unit/test_universe.py +0 -0
  124. {google_api_core-2.25.1 → google_api_core-2.25.2}/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.25.1
3
+ Version: 2.25.2
4
4
  Summary: Google API client core library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache 2.0
@@ -49,6 +49,9 @@ You can also pass a mapping object.
49
49
  """
50
50
 
51
51
  from typing import Callable, Mapping, Optional, Sequence, Tuple
52
+ import warnings
53
+
54
+ from google.api_core import general_helpers
52
55
 
53
56
 
54
57
  class ClientOptions(object):
@@ -67,8 +70,9 @@ class ClientOptions(object):
67
70
  and ``client_encrypted_cert_source`` are mutually exclusive.
68
71
  quota_project_id (Optional[str]): A project name that a client's
69
72
  quota belongs to.
70
- credentials_file (Optional[str]): A path to a file storing credentials.
71
- ``credentials_file` and ``api_key`` are mutually exclusive.
73
+ credentials_file (Optional[str]): Deprecated. A path to a file storing credentials.
74
+ ``credentials_file` and ``api_key`` are mutually exclusive. This argument will be
75
+ removed in the next major version of `google-api-core`.
72
76
 
73
77
  .. warning::
74
78
  Important: If you accept a credential configuration (credential JSON/File/Stream)
@@ -114,6 +118,9 @@ class ClientOptions(object):
114
118
  api_audience: Optional[str] = None,
115
119
  universe_domain: Optional[str] = None,
116
120
  ):
121
+ if credentials_file is not None:
122
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
123
+
117
124
  if client_cert_source and client_encrypted_cert_source:
118
125
  raise ValueError(
119
126
  "client_cert_source and client_encrypted_cert_source are mutually exclusive"
@@ -0,0 +1,52 @@
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
+ # This import for backward compatibility only.
16
+ from functools import wraps # noqa: F401 pragma: NO COVER
17
+
18
+ _CREDENTIALS_FILE_WARNING = """\
19
+ The `credentials_file` argument is deprecated because of a potential security risk.
20
+
21
+ The `google.auth.load_credentials_from_file` method does not validate the credential
22
+ configuration. The security risk occurs when a credential configuration is accepted
23
+ from a source that is not under your control and used without validation on your side.
24
+
25
+ If you know that you will be loading credential configurations of a
26
+ specific type, it is recommended to use a credential-type-specific
27
+ load method.
28
+
29
+ This will ensure that an unexpected credential type with potential for
30
+ malicious intent is not loaded unintentionally. You might still have to do
31
+ validation for certain credential types. Please follow the recommendations
32
+ for that method. For example, if you want to load only service accounts,
33
+ you can create the service account credentials explicitly:
34
+
35
+ ```
36
+ from google.cloud.vision_v1 import ImageAnnotatorClient
37
+ from google.oauth2 import service_account
38
+
39
+ credentials = service_account.Credentials.from_service_account_file(filename)
40
+ client = ImageAnnotatorClient(credentials=credentials)
41
+ ```
42
+
43
+ If you are loading your credential configuration from an untrusted source and have
44
+ not mitigated the risks (e.g. by validating the configuration yourself), make
45
+ these changes as soon as possible to prevent security risks to your environment.
46
+
47
+ Regardless of the method used, it is always your responsibility to validate
48
+ configurations received from external sources.
49
+
50
+ Refer to https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
51
+ for more details.
52
+ """
@@ -13,20 +13,19 @@
13
13
  # limitations under the License.
14
14
 
15
15
  """Helpers for :mod:`grpc`."""
16
- from typing import Generic, Iterator, Optional, TypeVar
17
-
18
16
  import collections
19
17
  import functools
18
+ from typing import Generic, Iterator, Optional, TypeVar
20
19
  import warnings
21
20
 
22
- import grpc
23
-
24
- from google.api_core import exceptions
25
21
  import google.auth
26
22
  import google.auth.credentials
27
23
  import google.auth.transport.grpc
28
24
  import google.auth.transport.requests
29
25
  import google.protobuf
26
+ import grpc
27
+
28
+ from google.api_core import exceptions, general_helpers
30
29
 
31
30
  PROTOBUF_VERSION = google.protobuf.__version__
32
31
 
@@ -213,9 +212,10 @@ def _create_composite_credentials(
213
212
  credentials (google.auth.credentials.Credentials): The credentials. If
214
213
  not specified, then this function will attempt to ascertain the
215
214
  credentials from the environment using :func:`google.auth.default`.
216
- credentials_file (str): A file with credentials that can be loaded with
215
+ credentials_file (str): Deprecated. A file with credentials that can be loaded with
217
216
  :func:`google.auth.load_credentials_from_file`. This argument is
218
- mutually exclusive with credentials.
217
+ mutually exclusive with credentials. This argument will be
218
+ removed in the next major version of `google-api-core`.
219
219
 
220
220
  .. warning::
221
221
  Important: If you accept a credential configuration (credential JSON/File/Stream)
@@ -245,6 +245,9 @@ def _create_composite_credentials(
245
245
  Raises:
246
246
  google.api_core.DuplicateCredentialArgs: If both a credentials object and credentials_file are passed.
247
247
  """
248
+ if credentials_file is not None:
249
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
250
+
248
251
  if credentials and credentials_file:
249
252
  raise exceptions.DuplicateCredentialArgs(
250
253
  "'credentials' and 'credentials_file' are mutually exclusive."
@@ -20,13 +20,14 @@ functions. This module is implementing the same surface with AsyncIO semantics.
20
20
 
21
21
  import asyncio
22
22
  import functools
23
+ import warnings
23
24
 
24
25
  from typing import AsyncGenerator, Generic, Iterator, Optional, TypeVar
25
26
 
26
27
  import grpc
27
28
  from grpc import aio
28
29
 
29
- from google.api_core import exceptions, grpc_helpers
30
+ from google.api_core import exceptions, general_helpers, grpc_helpers
30
31
 
31
32
  # denotes the proto response type for grpc calls
32
33
  P = TypeVar("P")
@@ -233,9 +234,10 @@ def create_channel(
233
234
  are passed to :func:`google.auth.default`.
234
235
  ssl_credentials (grpc.ChannelCredentials): Optional SSL channel
235
236
  credentials. This can be used to specify different certificates.
236
- credentials_file (str): A file with credentials that can be loaded with
237
+ credentials_file (str): Deprecated. A file with credentials that can be loaded with
237
238
  :func:`google.auth.load_credentials_from_file`. This argument is
238
- mutually exclusive with credentials.
239
+ mutually exclusive with credentials. This argument will be
240
+ removed in the next major version of `google-api-core`.
239
241
 
240
242
  .. warning::
241
243
  Important: If you accept a credential configuration (credential JSON/File/Stream)
@@ -280,6 +282,9 @@ def create_channel(
280
282
  ValueError: If `ssl_credentials` is set and `attempt_direct_path` is set to `True`.
281
283
  """
282
284
 
285
+ if credentials_file is not None:
286
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
287
+
283
288
  # If `ssl_credentials` is set and `attempt_direct_path` is set to `True`,
284
289
  # raise ValueError as this is not yet supported.
285
290
  # See https://github.com/googleapis/python-api-core/issues/590
@@ -16,12 +16,8 @@
16
16
  import abc
17
17
  import re
18
18
  from typing import Awaitable, Callable, Optional, Sequence, Union
19
+ import warnings
19
20
 
20
- import google.api_core # type: ignore
21
- from google.api_core import exceptions as core_exceptions # type: ignore
22
- from google.api_core import gapic_v1 # type: ignore
23
- from google.api_core import retry as retries # type: ignore
24
- from google.api_core import version
25
21
  import google.auth # type: ignore
26
22
  from google.auth import credentials as ga_credentials # type: ignore
27
23
  from google.longrunning import operations_pb2
@@ -30,6 +26,12 @@ import google.protobuf
30
26
  from google.protobuf import empty_pb2, json_format # type: ignore
31
27
  from grpc import Compression
32
28
 
29
+ import google.api_core # type: ignore
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
33
+ from google.api_core import retry as retries # type: ignore
34
+ from google.api_core import version
33
35
 
34
36
  PROTOBUF_VERSION = google.protobuf.__version__
35
37
 
@@ -69,9 +71,10 @@ class OperationsTransport(abc.ABC):
69
71
  credentials identify the application to the service; if none
70
72
  are specified, the client will attempt to ascertain the
71
73
  credentials from the environment.
72
- credentials_file (Optional[str]): A file with credentials that can
74
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
73
75
  be loaded with :func:`google.auth.load_credentials_from_file`.
74
- This argument is mutually exclusive with credentials.
76
+ This argument is mutually exclusive with credentials. This argument will be
77
+ removed in the next major version of `google-api-core`.
75
78
 
76
79
  .. warning::
77
80
  Important: If you accept a credential configuration (credential JSON/File/Stream)
@@ -98,6 +101,9 @@ class OperationsTransport(abc.ABC):
98
101
  "https", but for testing or local servers,
99
102
  "http" can be specified.
100
103
  """
104
+ if credentials_file is not None:
105
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
106
+
101
107
  maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
102
108
  if maybe_url_match is None:
103
109
  raise ValueError(
@@ -15,23 +15,26 @@
15
15
  #
16
16
 
17
17
  from typing import Callable, Dict, Optional, Sequence, Tuple, Union
18
+ import warnings
18
19
 
20
+ from google.auth import credentials as ga_credentials # type: ignore
21
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
22
+ 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
19
27
  from requests import __version__ as requests_version
20
28
 
21
29
  from google.api_core import exceptions as core_exceptions # type: ignore
22
30
  from google.api_core import gapic_v1 # type: ignore
31
+ from google.api_core import general_helpers
23
32
  from google.api_core import path_template # type: ignore
24
33
  from google.api_core import rest_helpers # type: ignore
25
34
  from google.api_core import retry as retries # type: ignore
26
- from google.auth import credentials as ga_credentials # type: ignore
27
- from google.auth.transport.requests import AuthorizedSession # type: ignore
28
- from google.longrunning import operations_pb2 # type: ignore
29
- from google.protobuf import empty_pb2 # type: ignore
30
- from google.protobuf import json_format # type: ignore
31
- import google.protobuf
32
35
 
33
- import grpc
34
- from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO, OperationsTransport
36
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
37
+ from .base import OperationsTransport
35
38
 
36
39
  PROTOBUF_VERSION = google.protobuf.__version__
37
40
 
@@ -91,9 +94,10 @@ class OperationsRestTransport(OperationsTransport):
91
94
  are specified, the client will attempt to ascertain the
92
95
  credentials from the environment.
93
96
 
94
- credentials_file (Optional[str]): A file with credentials that can
97
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
95
98
  be loaded with :func:`google.auth.load_credentials_from_file`.
96
- This argument is ignored if ``channel`` is provided.
99
+ This argument is ignored if ``channel`` is provided. This argument will be
100
+ removed in the next major version of `google-api-core`.
97
101
 
98
102
  .. warning::
99
103
  Important: If you accept a credential configuration (credential JSON/File/Stream)
@@ -101,9 +105,9 @@ class OperationsRestTransport(OperationsTransport):
101
105
  validate it before providing it to any Google API or client library. Providing an
102
106
  unvalidated credential configuration to Google APIs or libraries can compromise
103
107
  the security of your systems and data. For more information, refer to
104
- `Validate credential configurations from external sources`_.
108
+ `Validate credential configuration from external sources`_.
105
109
 
106
- .. _Validate credential configurations from external sources:
110
+ .. _Validate credential configuration from external sources:
107
111
 
108
112
  https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
109
113
  scopes (Optional(Sequence[str])): A list of scopes. This argument is
@@ -130,6 +134,9 @@ class OperationsRestTransport(OperationsTransport):
130
134
  "v1" by default.
131
135
 
132
136
  """
137
+ if credentials_file is not None:
138
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
139
+
133
140
  # Run the base constructor
134
141
  # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
135
142
  # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
@@ -16,6 +16,7 @@
16
16
 
17
17
  import json
18
18
  from typing import Any, Callable, Coroutine, Dict, Optional, Sequence, Tuple
19
+ import warnings
19
20
 
20
21
  from google.auth import __version__ as auth_version
21
22
 
@@ -29,6 +30,7 @@ except ImportError as e: # pragma: NO COVER
29
30
 
30
31
  from google.api_core import exceptions as core_exceptions # type: ignore
31
32
  from google.api_core import gapic_v1 # type: ignore
33
+ from google.api_core import general_helpers
32
34
  from google.api_core import path_template # type: ignore
33
35
  from google.api_core import rest_helpers # type: ignore
34
36
  from google.api_core import retry_async as retries_async # type: ignore
@@ -96,6 +98,22 @@ class AsyncOperationsRestTransport(OperationsTransport):
96
98
  credentials identify the application to the service; if none
97
99
  are specified, the client will attempt to ascertain the
98
100
  credentials from the environment.
101
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
102
+ be loaded with :func:`google.auth.load_credentials_from_file`.
103
+ This argument is ignored if ``channel`` is provided. This argument will be
104
+ removed in the next major version of `google-api-core`.
105
+
106
+ .. warning::
107
+ Important: If you accept a credential configuration (credential JSON/File/Stream)
108
+ from an external source for authentication to Google Cloud Platform, you must
109
+ validate it before providing it to any Google API or client library. Providing an
110
+ unvalidated credential configuration to Google APIs or libraries can compromise
111
+ the security of your systems and data. For more information, refer to
112
+ `Validate credential configurations from external sources`_.
113
+
114
+ .. _Validate credential configurations from external sources:
115
+
116
+ https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
99
117
  client_info (google.api_core.gapic_v1.client_info.ClientInfo):
100
118
  The client info used to send a user-agent string along with
101
119
  API requests. If ``None``, then default info will be used.
@@ -113,6 +131,9 @@ class AsyncOperationsRestTransport(OperationsTransport):
113
131
  "v1" by default.
114
132
 
115
133
  """
134
+ if credentials_file is not None:
135
+ warnings.warn(general_helpers._CREDENTIALS_FILE_WARNING, DeprecationWarning)
136
+
116
137
  unsupported_params = {
117
138
  # TODO(https://github.com/googleapis/python-api-core/issues/715): Add support for `credentials_file` to async REST transport.
118
139
  "google.api_core.client_options.ClientOptions.credentials_file": credentials_file,
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "2.25.1"
15
+ __version__ = "2.25.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-api-core
3
- Version: 2.25.1
3
+ Version: 2.25.2
4
4
  Summary: Google API client core library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache 2.0
@@ -256,7 +256,11 @@ async def test_wrap_method_with_overriding_timeout_as_a_number():
256
256
  result = await wrapped_method(timeout=22)
257
257
 
258
258
  assert result == 42
259
- method.assert_called_once_with(timeout=22, metadata=mock.ANY)
259
+
260
+ actual_timeout = method.call_args[1]["timeout"]
261
+ metadata = method.call_args[1]["metadata"]
262
+ assert metadata == mock.ANY
263
+ assert actual_timeout == pytest.approx(22, abs=0.01)
260
264
 
261
265
 
262
266
  @pytest.mark.asyncio
@@ -85,7 +85,7 @@ async def test_constructor():
85
85
 
86
86
 
87
87
  @pytest.mark.asyncio
88
- def test_metadata():
88
+ async def test_metadata():
89
89
  expected_metadata = struct_pb2.Struct()
90
90
  future, _, _ = make_operation_future(
91
91
  [make_operation_proto(metadata=expected_metadata)]
@@ -178,7 +178,7 @@ async def test_unexpected_result(unused_sleep):
178
178
 
179
179
 
180
180
  @pytest.mark.asyncio
181
- def test_from_gapic():
181
+ async def test_from_gapic():
182
182
  operation_proto = make_operation_proto(done=True)
183
183
  operations_client = mock.create_autospec(
184
184
  operations_v1.OperationsClient, instance=True
@@ -201,7 +201,11 @@ def test_wrap_method_with_overriding_timeout_as_a_number():
201
201
  result = wrapped_method(timeout=22)
202
202
 
203
203
  assert result == 42
204
- method.assert_called_once_with(timeout=22, metadata=mock.ANY)
204
+
205
+ actual_timeout = method.call_args[1]["timeout"]
206
+ metadata = method.call_args[1]["metadata"]
207
+ assert metadata == mock.ANY
208
+ assert actual_timeout == pytest.approx(22, abs=0.01)
205
209
 
206
210
 
207
211
  def test_wrap_method_with_call():
@@ -368,6 +368,22 @@ def test_operations_client_client_options(
368
368
  always_use_jwt_access=True,
369
369
  )
370
370
 
371
+ # Check the case credentials_file is provided
372
+ options = client_options.ClientOptions(credentials_file="credentials.json")
373
+ with mock.patch.object(transport_class, "__init__") as patched:
374
+ patched.return_value = None
375
+ client = client_class(client_options=options, transport=transport_name)
376
+ patched.assert_called_once_with(
377
+ credentials=None,
378
+ credentials_file="credentials.json",
379
+ host=client.DEFAULT_ENDPOINT,
380
+ scopes=None,
381
+ client_cert_source_for_mtls=None,
382
+ quota_project_id=None,
383
+ client_info=transports.base.DEFAULT_CLIENT_INFO,
384
+ always_use_jwt_access=True,
385
+ )
386
+
371
387
 
372
388
  # TODO: Add support for mtls in async REST
373
389
  @pytest.mark.parametrize(
@@ -544,8 +560,23 @@ def test_operations_client_client_options_credentials_file(
544
560
  )
545
561
 
546
562
 
547
- def test_list_operations_rest():
548
- client = _get_operations_client(is_async=False)
563
+ @pytest.mark.parametrize(
564
+ "credentials_file",
565
+ [None, "credentials.json"],
566
+ )
567
+ @mock.patch(
568
+ "google.auth.default",
569
+ autospec=True,
570
+ return_value=(mock.sentinel.credentials, mock.sentinel.project),
571
+ )
572
+ def test_list_operations_rest(google_auth_default, credentials_file):
573
+ sync_transport = transports.rest.OperationsRestTransport(
574
+ credentials_file=credentials_file,
575
+ http_options=HTTP_OPTIONS,
576
+ )
577
+
578
+ client = AbstractOperationsClient(transport=sync_transport)
579
+
549
580
  # Mock the http request call within the method and fake a response.
550
581
  with mock.patch.object(_get_session_type(is_async=False), "request") as req:
551
582
  # Designate an appropriate value for the returned response.
@@ -1,16 +0,0 @@
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
- # This import for backward compatibility only.
16
- from functools import wraps # noqa: F401 pragma: NO COVER