tencentcloud-sdk-python-common 3.0.1446__py2.py3-none-any.whl → 3.0.1447__py2.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.
Potentially problematic release.
This version of tencentcloud-sdk-python-common might be problematic. Click here for more details.
- tencentcloud/__init__.py +1 -1
- tencentcloud/common/abstract_client.py +14 -12
- tencentcloud/common/credential.py +61 -26
- {tencentcloud_sdk_python_common-3.0.1446.dist-info → tencentcloud_sdk_python_common-3.0.1447.dist-info}/METADATA +1 -1
- {tencentcloud_sdk_python_common-3.0.1446.dist-info → tencentcloud_sdk_python_common-3.0.1447.dist-info}/RECORD +7 -7
- {tencentcloud_sdk_python_common-3.0.1446.dist-info → tencentcloud_sdk_python_common-3.0.1447.dist-info}/WHEEL +0 -0
- {tencentcloud_sdk_python_common-3.0.1446.dist-info → tencentcloud_sdk_python_common-3.0.1447.dist-info}/top_level.txt +0 -0
tencentcloud/__init__.py
CHANGED
|
@@ -147,14 +147,16 @@ class AbstractClient(object):
|
|
|
147
147
|
params['Timestamp'] = int(time.time())
|
|
148
148
|
params['Version'] = self._apiVersion
|
|
149
149
|
|
|
150
|
+
cred_secret_id, cred_secret_key, cred_token = self.credential.get_credential_info()
|
|
151
|
+
|
|
150
152
|
if self.region:
|
|
151
153
|
params['Region'] = self.region
|
|
152
154
|
|
|
153
|
-
if
|
|
154
|
-
params['Token'] =
|
|
155
|
+
if cred_token:
|
|
156
|
+
params['Token'] = cred_token
|
|
155
157
|
|
|
156
|
-
if
|
|
157
|
-
params['SecretId'] =
|
|
158
|
+
if cred_secret_id:
|
|
159
|
+
params['SecretId'] = cred_secret_id
|
|
158
160
|
|
|
159
161
|
if self.profile.signMethod:
|
|
160
162
|
params['SignatureMethod'] = self.profile.signMethod
|
|
@@ -163,7 +165,7 @@ class AbstractClient(object):
|
|
|
163
165
|
params['Language'] = self.profile.language
|
|
164
166
|
|
|
165
167
|
signInParam = self._format_sign_string(params, options)
|
|
166
|
-
params['Signature'] = Sign.sign(str(
|
|
168
|
+
params['Signature'] = Sign.sign(str(cred_secret_key),
|
|
167
169
|
str(signInParam),
|
|
168
170
|
str(self.profile.signMethod))
|
|
169
171
|
|
|
@@ -189,6 +191,7 @@ class AbstractClient(object):
|
|
|
189
191
|
|
|
190
192
|
endpoint = self._get_endpoint(options=options)
|
|
191
193
|
timestamp = int(time.time())
|
|
194
|
+
cred_secret_id, cred_secret_key, cred_token = self.credential.get_credential_info()
|
|
192
195
|
req.header["Host"] = endpoint
|
|
193
196
|
req.header["X-TC-Action"] = action[0].upper() + action[1:]
|
|
194
197
|
req.header["X-TC-RequestClient"] = self.request_client
|
|
@@ -198,8 +201,8 @@ class AbstractClient(object):
|
|
|
198
201
|
req.header["X-TC-Content-SHA256"] = "UNSIGNED-PAYLOAD"
|
|
199
202
|
if self.region:
|
|
200
203
|
req.header['X-TC-Region'] = self.region
|
|
201
|
-
if
|
|
202
|
-
req.header['X-TC-Token'] =
|
|
204
|
+
if cred_token:
|
|
205
|
+
req.header['X-TC-Token'] = cred_token
|
|
203
206
|
if self.profile.language:
|
|
204
207
|
req.header['X-TC-Language'] = self.profile.language
|
|
205
208
|
|
|
@@ -215,13 +218,13 @@ class AbstractClient(object):
|
|
|
215
218
|
|
|
216
219
|
service = self._service
|
|
217
220
|
date = datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d')
|
|
218
|
-
signature = self._get_tc3_signature(params, req, date, service, options)
|
|
221
|
+
signature = self._get_tc3_signature(params, req, date, service, cred_secret_key, options)
|
|
219
222
|
|
|
220
223
|
auth = "TC3-HMAC-SHA256 Credential=%s/%s/%s/tc3_request, SignedHeaders=content-type;host, Signature=%s" % (
|
|
221
|
-
|
|
224
|
+
cred_secret_id, date, service, signature)
|
|
222
225
|
req.header["Authorization"] = auth
|
|
223
226
|
|
|
224
|
-
def _get_tc3_signature(self, params, req, date, service, options=None):
|
|
227
|
+
def _get_tc3_signature(self, params, req, date, service, secret_key, options=None):
|
|
225
228
|
options = options or {}
|
|
226
229
|
canonical_uri = req.uri
|
|
227
230
|
canonical_querystring = ""
|
|
@@ -258,8 +261,7 @@ class AbstractClient(object):
|
|
|
258
261
|
req.header["X-TC-Timestamp"],
|
|
259
262
|
credential_scope,
|
|
260
263
|
digest)
|
|
261
|
-
|
|
262
|
-
return Sign.sign_tc3(self.credential.secret_key, date, service, string2sign)
|
|
264
|
+
return Sign.sign_tc3(secret_key, date, service, string2sign)
|
|
263
265
|
|
|
264
266
|
def _build_req_without_signature(self, action, params, req, options=None):
|
|
265
267
|
content_type = self._default_content_type
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import json
|
|
17
17
|
import os
|
|
18
18
|
import time
|
|
19
|
+
import threading
|
|
19
20
|
|
|
20
21
|
try:
|
|
21
22
|
# py3
|
|
@@ -70,6 +71,9 @@ class Credential(object):
|
|
|
70
71
|
@property
|
|
71
72
|
def secretKey(self):
|
|
72
73
|
return self.secret_key
|
|
74
|
+
|
|
75
|
+
def get_credential_info(self):
|
|
76
|
+
return self.secret_id, self.secret_key, self.token
|
|
73
77
|
|
|
74
78
|
|
|
75
79
|
class CVMRoleCredential(object):
|
|
@@ -91,6 +95,7 @@ class CVMRoleCredential(object):
|
|
|
91
95
|
self._secret_key = None
|
|
92
96
|
self._token = None
|
|
93
97
|
self._expired_ts = 0
|
|
98
|
+
self._lock = threading.Lock()
|
|
94
99
|
|
|
95
100
|
@property
|
|
96
101
|
def secretId(self):
|
|
@@ -98,8 +103,9 @@ class CVMRoleCredential(object):
|
|
|
98
103
|
|
|
99
104
|
@property
|
|
100
105
|
def secret_id(self):
|
|
101
|
-
self.
|
|
102
|
-
|
|
106
|
+
with self._lock:
|
|
107
|
+
self.update_credential()
|
|
108
|
+
return self._secret_id
|
|
103
109
|
|
|
104
110
|
@property
|
|
105
111
|
def secretKey(self):
|
|
@@ -107,13 +113,15 @@ class CVMRoleCredential(object):
|
|
|
107
113
|
|
|
108
114
|
@property
|
|
109
115
|
def secret_key(self):
|
|
110
|
-
self.
|
|
111
|
-
|
|
116
|
+
with self._lock:
|
|
117
|
+
self.update_credential()
|
|
118
|
+
return self._secret_key
|
|
112
119
|
|
|
113
120
|
@property
|
|
114
121
|
def token(self):
|
|
115
|
-
self.
|
|
116
|
-
|
|
122
|
+
with self._lock:
|
|
123
|
+
self.update_credential()
|
|
124
|
+
return self._token
|
|
117
125
|
|
|
118
126
|
def get_role_name(self):
|
|
119
127
|
if self.role:
|
|
@@ -159,6 +167,11 @@ class CVMRoleCredential(object):
|
|
|
159
167
|
return None
|
|
160
168
|
return self
|
|
161
169
|
|
|
170
|
+
def get_credential_info(self):
|
|
171
|
+
with self._lock:
|
|
172
|
+
self.update_credential()
|
|
173
|
+
return self._secret_id, self._secret_key, self._token
|
|
174
|
+
|
|
162
175
|
|
|
163
176
|
class STSAssumeRoleCredential(object):
|
|
164
177
|
"""Tencent Cloud Credential via STS service
|
|
@@ -200,31 +213,42 @@ class STSAssumeRoleCredential(object):
|
|
|
200
213
|
self._tmp_credential = None
|
|
201
214
|
if endpoint:
|
|
202
215
|
self._endpoint = endpoint
|
|
216
|
+
self._lock = threading.Lock()
|
|
203
217
|
|
|
204
218
|
@property
|
|
205
219
|
def secretId(self):
|
|
206
|
-
self.
|
|
207
|
-
|
|
220
|
+
with self._lock:
|
|
221
|
+
self._need_refresh()
|
|
222
|
+
return self._tmp_secret_id
|
|
208
223
|
|
|
209
224
|
@property
|
|
210
225
|
def secretKey(self):
|
|
211
|
-
self.
|
|
212
|
-
|
|
226
|
+
with self._lock:
|
|
227
|
+
self._need_refresh()
|
|
228
|
+
return self._tmp_secret_key
|
|
213
229
|
|
|
214
230
|
@property
|
|
215
231
|
def secret_id(self):
|
|
216
|
-
self.
|
|
217
|
-
|
|
232
|
+
with self._lock:
|
|
233
|
+
self._need_refresh()
|
|
234
|
+
return self._tmp_secret_id
|
|
218
235
|
|
|
219
236
|
@property
|
|
220
237
|
def secret_key(self):
|
|
221
|
-
self.
|
|
222
|
-
|
|
238
|
+
with self._lock:
|
|
239
|
+
self._need_refresh()
|
|
240
|
+
return self._tmp_secret_key
|
|
223
241
|
|
|
224
242
|
@property
|
|
225
243
|
def token(self):
|
|
226
|
-
self.
|
|
227
|
-
|
|
244
|
+
with self._lock:
|
|
245
|
+
self._need_refresh()
|
|
246
|
+
return self._token
|
|
247
|
+
|
|
248
|
+
def get_credential_info(self):
|
|
249
|
+
with self._lock:
|
|
250
|
+
self._need_refresh()
|
|
251
|
+
return self._tmp_secret_id, self._tmp_secret_key, self._token
|
|
228
252
|
|
|
229
253
|
def _need_refresh(self):
|
|
230
254
|
if None in [self._token, self._tmp_secret_key, self._tmp_secret_id] or self._expired_time < int(time.time()):
|
|
@@ -405,31 +429,42 @@ class OIDCRoleArnCredential(object):
|
|
|
405
429
|
self._tmp_secret_key = None
|
|
406
430
|
self._expired_time = 0
|
|
407
431
|
self._is_tke = False
|
|
432
|
+
self._lock = threading.Lock()
|
|
408
433
|
|
|
409
434
|
@property
|
|
410
435
|
def secretId(self):
|
|
411
|
-
self.
|
|
412
|
-
|
|
436
|
+
with self._lock:
|
|
437
|
+
self._keep_fresh()
|
|
438
|
+
return self._tmp_secret_id
|
|
413
439
|
|
|
414
440
|
@property
|
|
415
441
|
def secretKey(self):
|
|
416
|
-
self.
|
|
417
|
-
|
|
442
|
+
with self._lock:
|
|
443
|
+
self._keep_fresh()
|
|
444
|
+
return self._tmp_secret_key
|
|
418
445
|
|
|
419
446
|
@property
|
|
420
447
|
def secret_id(self):
|
|
421
|
-
self.
|
|
422
|
-
|
|
448
|
+
with self._lock:
|
|
449
|
+
self._keep_fresh()
|
|
450
|
+
return self._tmp_secret_id
|
|
423
451
|
|
|
424
452
|
@property
|
|
425
453
|
def secret_key(self):
|
|
426
|
-
self.
|
|
427
|
-
|
|
454
|
+
with self._lock:
|
|
455
|
+
self._keep_fresh()
|
|
456
|
+
return self._tmp_secret_key
|
|
428
457
|
|
|
429
458
|
@property
|
|
430
459
|
def token(self):
|
|
431
|
-
self.
|
|
432
|
-
|
|
460
|
+
with self._lock:
|
|
461
|
+
self._keep_fresh()
|
|
462
|
+
return self._token
|
|
463
|
+
|
|
464
|
+
def get_credential_info(self):
|
|
465
|
+
with self._lock:
|
|
466
|
+
self._keep_fresh()
|
|
467
|
+
return self._tmp_secret_id, self._tmp_secret_key, self._token
|
|
433
468
|
|
|
434
469
|
@property
|
|
435
470
|
def endpoint(self):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
tencentcloud/__init__.py,sha256=
|
|
1
|
+
tencentcloud/__init__.py,sha256=Clabb3XxBDuEdLmg8E-OO3chnkbKm5mdLeZJzx_dS8c,631
|
|
2
2
|
tencentcloud/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
tencentcloud/common/abstract_client.py,sha256=
|
|
3
|
+
tencentcloud/common/abstract_client.py,sha256=hqnD1TruJPHxITCOgFrfZUovb27UWYbt71S-qJB3Bzw,25608
|
|
4
4
|
tencentcloud/common/abstract_model.py,sha256=LJ9BkK1Djh_gdx3Cy3trEOtJRGtrM-ikeqRzO1PgwiY,2418
|
|
5
5
|
tencentcloud/common/circuit_breaker.py,sha256=p_6ssklMRtR-YKNGcFLd3ClUvZPs8ZLnVkhjcOZA0DY,4301
|
|
6
6
|
tencentcloud/common/common_client.py,sha256=1Dr96VCEoJgDPmnurI46ko_cSROtRQbcHef_qeOKZco,2043
|
|
7
|
-
tencentcloud/common/credential.py,sha256=
|
|
7
|
+
tencentcloud/common/credential.py,sha256=hTZ0ROxdCkd4rCF0dplMg6lMrb3HK0euMNrhGD3WjiA,18254
|
|
8
8
|
tencentcloud/common/retry.py,sha256=4h6lG2KEVezhnfZt1BvSkftNupuu98g-n1g1EKu62IE,2323
|
|
9
9
|
tencentcloud/common/sign.py,sha256=Mm51G6huhhT91yayB-KKWCQFIuy59dFzdSwolNfSuwM,1568
|
|
10
10
|
tencentcloud/common/exception/__init__.py,sha256=xK4vqaAlCWY5pGTDaz21vzIO6izEBESCNDeBNvojqYo,735
|
|
@@ -15,7 +15,7 @@ tencentcloud/common/http/request.py,sha256=Qgo3BI4cbbEv1Y2EvlB8KQSh1brvPKRypSdfn
|
|
|
15
15
|
tencentcloud/common/profile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
tencentcloud/common/profile/client_profile.py,sha256=gvqlN4orPjQKA7kfZw0GMLuwXkKnSMgLo2S-6Mq3qh0,5221
|
|
17
17
|
tencentcloud/common/profile/http_profile.py,sha256=4or_nmNoy-Yd9MWpxxPhvbaeaAjx3ZYTNgTl6nt6ETU,2256
|
|
18
|
-
tencentcloud_sdk_python_common-3.0.
|
|
19
|
-
tencentcloud_sdk_python_common-3.0.
|
|
20
|
-
tencentcloud_sdk_python_common-3.0.
|
|
21
|
-
tencentcloud_sdk_python_common-3.0.
|
|
18
|
+
tencentcloud_sdk_python_common-3.0.1447.dist-info/METADATA,sha256=YpndmkNV6KYcUhPUiaBbRAfdFGMdi-rdaqGPyMJb0EA,1487
|
|
19
|
+
tencentcloud_sdk_python_common-3.0.1447.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
20
|
+
tencentcloud_sdk_python_common-3.0.1447.dist-info/top_level.txt,sha256=g-8OyzoqI6O6LiS85zkeNzhB-osEnRIPZMdyRd_0eL0,13
|
|
21
|
+
tencentcloud_sdk_python_common-3.0.1447.dist-info/RECORD,,
|
|
File without changes
|