py2docfx 0.1.22.dev2259826__py3-none-any.whl → 0.1.22rc2268964__py3-none-any.whl
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.
- py2docfx/venv/basevenv/Lib/site-packages/certifi/__init__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +8 -9
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/imds.py +7 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/managed_identity.py +7 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/shared_cache.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/interactive.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_managed_identity_client.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +8 -9
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/imds.py +7 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/managed_identity.py +7 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/shared_cache.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/cachetools/__init__.py +96 -122
- py2docfx/venv/venv1/Lib/site-packages/cachetools/{_decorators.py → _cached.py} +106 -13
- py2docfx/venv/venv1/Lib/site-packages/cachetools/_cachedmethod.py +128 -0
- py2docfx/venv/venv1/Lib/site-packages/cachetools/func.py +5 -25
- py2docfx/venv/venv1/Lib/site-packages/certifi/__init__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/client_options.py +9 -2
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/general_helpers.py +36 -0
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/grpc_helpers.py +10 -7
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/grpc_helpers_async.py +8 -3
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/operations_v1/transports/base.py +13 -7
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/operations_v1/transports/rest.py +19 -12
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/operations_v1/transports/rest_asyncio.py +21 -0
- py2docfx/venv/venv1/Lib/site-packages/google/api_core/version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/auth/_default.py +66 -12
- py2docfx/venv/venv1/Lib/site-packages/google/auth/_default_async.py +16 -10
- py2docfx/venv/venv1/Lib/site-packages/google/auth/_helpers.py +41 -0
- py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/credentials.py +67 -6
- py2docfx/venv/venv1/Lib/site-packages/google/auth/credentials.py +161 -18
- py2docfx/venv/venv1/Lib/site-packages/google/auth/environment_vars.py +4 -0
- py2docfx/venv/venv1/Lib/site-packages/google/auth/external_account.py +33 -10
- py2docfx/venv/venv1/Lib/site-packages/google/auth/external_account_authorized_user.py +24 -1
- py2docfx/venv/venv1/Lib/site-packages/google/auth/identity_pool.py +25 -1
- py2docfx/venv/venv1/Lib/site-packages/google/auth/impersonated_credentials.py +57 -9
- py2docfx/venv/venv1/Lib/site-packages/google/auth/pluggable.py +25 -1
- py2docfx/venv/venv1/Lib/site-packages/google/auth/version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/oauth2/_client.py +117 -0
- py2docfx/venv/venv1/Lib/site-packages/google/oauth2/service_account.py +39 -4
- {py2docfx-0.1.22.dev2259826.dist-info → py2docfx-0.1.22rc2268964.dist-info}/METADATA +1 -1
- {py2docfx-0.1.22.dev2259826.dist-info → py2docfx-0.1.22rc2268964.dist-info}/RECORD +44 -43
- {py2docfx-0.1.22.dev2259826.dist-info → py2docfx-0.1.22rc2268964.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.22.dev2259826.dist-info → py2docfx-0.1.22rc2268964.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,53 @@
|
|
1
|
-
"""
|
1
|
+
"""Function decorator helpers."""
|
2
2
|
|
3
|
+
import functools
|
3
4
|
|
4
|
-
|
5
|
+
|
6
|
+
def _condition_info(func, cache, key, lock, cond, info):
|
7
|
+
hits = misses = 0
|
8
|
+
pending = set()
|
9
|
+
|
10
|
+
def wrapper(*args, **kwargs):
|
11
|
+
nonlocal hits, misses
|
12
|
+
k = key(*args, **kwargs)
|
13
|
+
with lock:
|
14
|
+
cond.wait_for(lambda: k not in pending)
|
15
|
+
try:
|
16
|
+
result = cache[k]
|
17
|
+
hits += 1
|
18
|
+
return result
|
19
|
+
except KeyError:
|
20
|
+
pending.add(k)
|
21
|
+
misses += 1
|
22
|
+
try:
|
23
|
+
v = func(*args, **kwargs)
|
24
|
+
with lock:
|
25
|
+
try:
|
26
|
+
cache[k] = v
|
27
|
+
except ValueError:
|
28
|
+
pass # value too large
|
29
|
+
return v
|
30
|
+
finally:
|
31
|
+
with lock:
|
32
|
+
pending.remove(k)
|
33
|
+
cond.notify_all()
|
34
|
+
|
35
|
+
def cache_clear():
|
36
|
+
nonlocal hits, misses
|
37
|
+
with lock:
|
38
|
+
cache.clear()
|
39
|
+
hits = misses = 0
|
40
|
+
|
41
|
+
def cache_info():
|
42
|
+
with lock:
|
43
|
+
return info(hits, misses)
|
44
|
+
|
45
|
+
wrapper.cache_clear = cache_clear
|
46
|
+
wrapper.cache_info = cache_info
|
47
|
+
return wrapper
|
48
|
+
|
49
|
+
|
50
|
+
def _locked_info(func, cache, key, lock, info):
|
5
51
|
hits = misses = 0
|
6
52
|
|
7
53
|
def wrapper(*args, **kwargs):
|
@@ -37,7 +83,7 @@ def _cached_locked_info(func, cache, key, lock, info):
|
|
37
83
|
return wrapper
|
38
84
|
|
39
85
|
|
40
|
-
def
|
86
|
+
def _unlocked_info(func, cache, key, info):
|
41
87
|
hits = misses = 0
|
42
88
|
|
43
89
|
def wrapper(*args, **kwargs):
|
@@ -83,7 +129,40 @@ def _uncached_info(func, info):
|
|
83
129
|
return wrapper
|
84
130
|
|
85
131
|
|
86
|
-
def
|
132
|
+
def _condition(func, cache, key, lock, cond):
|
133
|
+
pending = set()
|
134
|
+
|
135
|
+
def wrapper(*args, **kwargs):
|
136
|
+
k = key(*args, **kwargs)
|
137
|
+
with lock:
|
138
|
+
cond.wait_for(lambda: k not in pending)
|
139
|
+
try:
|
140
|
+
result = cache[k]
|
141
|
+
return result
|
142
|
+
except KeyError:
|
143
|
+
pending.add(k)
|
144
|
+
try:
|
145
|
+
v = func(*args, **kwargs)
|
146
|
+
with lock:
|
147
|
+
try:
|
148
|
+
cache[k] = v
|
149
|
+
except ValueError:
|
150
|
+
pass # value too large
|
151
|
+
return v
|
152
|
+
finally:
|
153
|
+
with lock:
|
154
|
+
pending.remove(k)
|
155
|
+
cond.notify_all()
|
156
|
+
|
157
|
+
def cache_clear():
|
158
|
+
with lock:
|
159
|
+
cache.clear()
|
160
|
+
|
161
|
+
wrapper.cache_clear = cache_clear
|
162
|
+
return wrapper
|
163
|
+
|
164
|
+
|
165
|
+
def _locked(func, cache, key, lock):
|
87
166
|
def wrapper(*args, **kwargs):
|
88
167
|
k = key(*args, **kwargs)
|
89
168
|
with lock:
|
@@ -107,7 +186,7 @@ def _cached_locked(func, cache, key, lock):
|
|
107
186
|
return wrapper
|
108
187
|
|
109
188
|
|
110
|
-
def
|
189
|
+
def _unlocked(func, cache, key):
|
111
190
|
def wrapper(*args, **kwargs):
|
112
191
|
k = key(*args, **kwargs)
|
113
192
|
try:
|
@@ -133,20 +212,34 @@ def _uncached(func):
|
|
133
212
|
return wrapper
|
134
213
|
|
135
214
|
|
136
|
-
def
|
215
|
+
def _wrapper(func, cache, key, lock=None, cond=None, info=None):
|
137
216
|
if info is not None:
|
138
217
|
if cache is None:
|
139
218
|
wrapper = _uncached_info(func, info)
|
140
|
-
elif lock is None:
|
141
|
-
wrapper =
|
219
|
+
elif cond is not None and lock is not None:
|
220
|
+
wrapper = _condition_info(func, cache, key, lock, cond, info)
|
221
|
+
elif cond is not None:
|
222
|
+
wrapper = _condition_info(func, cache, key, cond, cond, info)
|
223
|
+
elif lock is not None:
|
224
|
+
wrapper = _locked_info(func, cache, key, lock, info)
|
142
225
|
else:
|
143
|
-
wrapper =
|
226
|
+
wrapper = _unlocked_info(func, cache, key, info)
|
144
227
|
else:
|
145
228
|
if cache is None:
|
146
229
|
wrapper = _uncached(func)
|
147
|
-
elif lock is None:
|
148
|
-
wrapper =
|
230
|
+
elif cond is not None and lock is not None:
|
231
|
+
wrapper = _condition(func, cache, key, lock, cond)
|
232
|
+
elif cond is not None:
|
233
|
+
wrapper = _condition(func, cache, key, cond, cond)
|
234
|
+
elif lock is not None:
|
235
|
+
wrapper = _locked(func, cache, key, lock)
|
149
236
|
else:
|
150
|
-
wrapper =
|
237
|
+
wrapper = _unlocked(func, cache, key)
|
151
238
|
wrapper.cache_info = None
|
152
|
-
|
239
|
+
|
240
|
+
wrapper.cache = cache
|
241
|
+
wrapper.cache_key = key
|
242
|
+
wrapper.cache_lock = lock if lock is not None else cond
|
243
|
+
wrapper.cache_condition = cond
|
244
|
+
|
245
|
+
return functools.update_wrapper(wrapper, func)
|
@@ -0,0 +1,128 @@
|
|
1
|
+
"""Method decorator helpers."""
|
2
|
+
|
3
|
+
import functools
|
4
|
+
import weakref
|
5
|
+
|
6
|
+
|
7
|
+
def warn_cache_none():
|
8
|
+
from warnings import warn
|
9
|
+
|
10
|
+
warn(
|
11
|
+
"returning `None` from `cache(self)` is deprecated",
|
12
|
+
DeprecationWarning,
|
13
|
+
stacklevel=3,
|
14
|
+
)
|
15
|
+
|
16
|
+
|
17
|
+
def _condition(method, cache, key, lock, cond):
|
18
|
+
pending = weakref.WeakKeyDictionary()
|
19
|
+
|
20
|
+
def wrapper(self, *args, **kwargs):
|
21
|
+
c = cache(self)
|
22
|
+
if c is None:
|
23
|
+
warn_cache_none()
|
24
|
+
return method(self, *args, **kwargs)
|
25
|
+
k = key(self, *args, **kwargs)
|
26
|
+
with lock(self):
|
27
|
+
p = pending.setdefault(self, set())
|
28
|
+
cond(self).wait_for(lambda: k not in p)
|
29
|
+
try:
|
30
|
+
return c[k]
|
31
|
+
except KeyError:
|
32
|
+
p.add(k)
|
33
|
+
try:
|
34
|
+
v = method(self, *args, **kwargs)
|
35
|
+
with lock(self):
|
36
|
+
try:
|
37
|
+
c[k] = v
|
38
|
+
except ValueError:
|
39
|
+
pass # value too large
|
40
|
+
return v
|
41
|
+
finally:
|
42
|
+
with lock(self):
|
43
|
+
pending[self].remove(k)
|
44
|
+
cond(self).notify_all()
|
45
|
+
|
46
|
+
def cache_clear(self):
|
47
|
+
c = cache(self)
|
48
|
+
if c is not None:
|
49
|
+
with lock(self):
|
50
|
+
c.clear()
|
51
|
+
|
52
|
+
wrapper.cache_clear = cache_clear
|
53
|
+
return wrapper
|
54
|
+
|
55
|
+
|
56
|
+
def _locked(method, cache, key, lock):
|
57
|
+
def wrapper(self, *args, **kwargs):
|
58
|
+
c = cache(self)
|
59
|
+
if c is None:
|
60
|
+
warn_cache_none()
|
61
|
+
return method(self, *args, **kwargs)
|
62
|
+
k = key(self, *args, **kwargs)
|
63
|
+
with lock(self):
|
64
|
+
try:
|
65
|
+
return c[k]
|
66
|
+
except KeyError:
|
67
|
+
pass # key not found
|
68
|
+
v = method(self, *args, **kwargs)
|
69
|
+
# in case of a race, prefer the item already in the cache
|
70
|
+
with lock(self):
|
71
|
+
try:
|
72
|
+
return c.setdefault(k, v)
|
73
|
+
except ValueError:
|
74
|
+
return v # value too large
|
75
|
+
|
76
|
+
def cache_clear(self):
|
77
|
+
c = cache(self)
|
78
|
+
if c is not None:
|
79
|
+
with lock(self):
|
80
|
+
c.clear()
|
81
|
+
|
82
|
+
wrapper.cache_clear = cache_clear
|
83
|
+
return wrapper
|
84
|
+
|
85
|
+
|
86
|
+
def _unlocked(method, cache, key):
|
87
|
+
def wrapper(self, *args, **kwargs):
|
88
|
+
c = cache(self)
|
89
|
+
if c is None:
|
90
|
+
warn_cache_none()
|
91
|
+
return method(self, *args, **kwargs)
|
92
|
+
k = key(self, *args, **kwargs)
|
93
|
+
try:
|
94
|
+
return c[k]
|
95
|
+
except KeyError:
|
96
|
+
pass # key not found
|
97
|
+
v = method(self, *args, **kwargs)
|
98
|
+
try:
|
99
|
+
c[k] = v
|
100
|
+
except ValueError:
|
101
|
+
pass # value too large
|
102
|
+
return v
|
103
|
+
|
104
|
+
def cache_clear(self):
|
105
|
+
c = cache(self)
|
106
|
+
if c is not None:
|
107
|
+
c.clear()
|
108
|
+
|
109
|
+
wrapper.cache_clear = cache_clear
|
110
|
+
return wrapper
|
111
|
+
|
112
|
+
|
113
|
+
def _wrapper(method, cache, key, lock=None, cond=None):
|
114
|
+
if cond is not None and lock is not None:
|
115
|
+
wrapper = _condition(method, cache, key, lock, cond)
|
116
|
+
elif cond is not None:
|
117
|
+
wrapper = _condition(method, cache, key, cond, cond)
|
118
|
+
elif lock is not None:
|
119
|
+
wrapper = _locked(method, cache, key, lock)
|
120
|
+
else:
|
121
|
+
wrapper = _unlocked(method, cache, key)
|
122
|
+
|
123
|
+
wrapper.cache = cache
|
124
|
+
wrapper.cache_key = key
|
125
|
+
wrapper.cache_lock = lock if lock is not None else cond
|
126
|
+
wrapper.cache_condition = cond
|
127
|
+
|
128
|
+
return functools.update_wrapper(wrapper, method)
|
@@ -1,17 +1,14 @@
|
|
1
1
|
"""`functools.lru_cache` compatible memoizing function decorators."""
|
2
2
|
|
3
|
-
__all__ = ("fifo_cache", "lfu_cache", "lru_cache", "
|
3
|
+
__all__ = ("fifo_cache", "lfu_cache", "lru_cache", "rr_cache", "ttl_cache")
|
4
4
|
|
5
|
+
import functools
|
5
6
|
import math
|
6
7
|
import random
|
7
8
|
import time
|
9
|
+
from threading import Condition
|
8
10
|
|
9
|
-
|
10
|
-
from threading import RLock
|
11
|
-
except ImportError: # pragma: no cover
|
12
|
-
from dummy_threading import RLock
|
13
|
-
|
14
|
-
from . import FIFOCache, LFUCache, LRUCache, MRUCache, RRCache, TTLCache
|
11
|
+
from . import FIFOCache, LFUCache, LRUCache, RRCache, TTLCache
|
15
12
|
from . import cached
|
16
13
|
from . import keys
|
17
14
|
|
@@ -28,7 +25,7 @@ class _UnboundTTLCache(TTLCache):
|
|
28
25
|
def _cache(cache, maxsize, typed):
|
29
26
|
def decorator(func):
|
30
27
|
key = keys.typedkey if typed else keys.hashkey
|
31
|
-
wrapper = cached(cache=cache, key=key,
|
28
|
+
wrapper = cached(cache=cache, key=key, condition=Condition(), info=True)(func)
|
32
29
|
wrapper.cache_parameters = lambda: {"maxsize": maxsize, "typed": typed}
|
33
30
|
return wrapper
|
34
31
|
|
@@ -77,23 +74,6 @@ def lru_cache(maxsize=128, typed=False):
|
|
77
74
|
return _cache(LRUCache(maxsize), maxsize, typed)
|
78
75
|
|
79
76
|
|
80
|
-
def mru_cache(maxsize=128, typed=False):
|
81
|
-
"""Decorator to wrap a function with a memoizing callable that saves
|
82
|
-
up to `maxsize` results based on a Most Recently Used (MRU)
|
83
|
-
algorithm.
|
84
|
-
"""
|
85
|
-
from warnings import warn
|
86
|
-
|
87
|
-
warn("@mru_cache is deprecated", DeprecationWarning, stacklevel=2)
|
88
|
-
|
89
|
-
if maxsize is None:
|
90
|
-
return _cache({}, None, typed)
|
91
|
-
elif callable(maxsize):
|
92
|
-
return _cache(MRUCache(128), 128, typed)(maxsize)
|
93
|
-
else:
|
94
|
-
return _cache(MRUCache(maxsize), maxsize, typed)
|
95
|
-
|
96
|
-
|
97
77
|
def rr_cache(maxsize=128, choice=random.choice, typed=False):
|
98
78
|
"""Decorator to wrap a function with a memoizing callable that saves
|
99
79
|
up to `maxsize` results based on a Random Replacement (RR)
|
@@ -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"
|
@@ -14,3 +14,39 @@
|
|
14
14
|
|
15
15
|
# This import for backward compatibility only.
|
16
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
|
34
|
-
from .base import
|
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
|
108
|
+
`Validate credential configuration from external sources`_.
|
105
109
|
|
106
|
-
.. _Validate credential
|
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
|
py2docfx/venv/venv1/Lib/site-packages/google/api_core/operations_v1/transports/rest_asyncio.py
CHANGED
@@ -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,
|