tencentcloud-sdk-python-common 3.0.1398__py2.py3-none-any.whl → 3.0.1400__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 CHANGED
@@ -14,4 +14,4 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
- __version__ = '3.0.1398'
17
+ __version__ = '3.0.1400'
@@ -28,8 +28,10 @@ import logging.handlers
28
28
 
29
29
  try:
30
30
  from urllib.parse import urlencode
31
+ from urllib.parse import urlparse
31
32
  except ImportError:
32
33
  from urllib import urlencode
34
+ from urlparse import urlparse
33
35
 
34
36
  import tencentcloud
35
37
  from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
@@ -133,11 +135,11 @@ class AbstractClient(object):
133
135
  elif self.profile.signMethod == "TC3-HMAC-SHA256" or options.get("IsMultipart") is True:
134
136
  self._build_req_with_tc3_signature(action, params, req_inter, options)
135
137
  elif self.profile.signMethod in ("HmacSHA1", "HmacSHA256"):
136
- self._build_req_with_old_signature(action, params, req_inter)
138
+ self._build_req_with_old_signature(action, params, req_inter, options)
137
139
  else:
138
140
  raise TencentCloudSDKException("ClientError", "Invalid signature method.")
139
141
 
140
- def _build_req_with_old_signature(self, action, params, req):
142
+ def _build_req_with_old_signature(self, action, params, req, options):
141
143
  params = copy.deepcopy(self._fix_params(params))
142
144
  params['Action'] = action[0].upper() + action[1:]
143
145
  params['RequestClient'] = self.request_client
@@ -160,7 +162,7 @@ class AbstractClient(object):
160
162
  if self.profile.language:
161
163
  params['Language'] = self.profile.language
162
164
 
163
- signInParam = self._format_sign_string(params)
165
+ signInParam = self._format_sign_string(params, options)
164
166
  params['Signature'] = Sign.sign(str(self.credential.secret_key),
165
167
  str(signInParam),
166
168
  str(self.profile.signMethod))
@@ -185,7 +187,7 @@ class AbstractClient(object):
185
187
  raise SDKError("ClientError",
186
188
  "Invalid request method GET for multipart.")
187
189
 
188
- endpoint = self._get_endpoint()
190
+ endpoint = self._get_endpoint(options=options)
189
191
  timestamp = int(time.time())
190
192
  req.header["Host"] = endpoint
191
193
  req.header["X-TC-Action"] = action[0].upper() + action[1:]
@@ -276,7 +278,7 @@ class AbstractClient(object):
276
278
  raise SDKError("ClientError",
277
279
  "Invalid request method GET for multipart.")
278
280
 
279
- endpoint = self._get_endpoint()
281
+ endpoint = self._get_endpoint(options=options)
280
282
  timestamp = int(time.time())
281
283
  req.header["Host"] = endpoint
282
284
  req.header["X-TC-Action"] = action[0].upper() + action[1:]
@@ -333,20 +335,23 @@ class AbstractClient(object):
333
335
  logger.debug("GetResponse: %s", ResponsePrettyFormatter(resp_inter))
334
336
  raise TencentCloudSDKException("ServerNetworkError", resp_inter.content)
335
337
 
336
- def _format_sign_string(self, params):
338
+ def _format_sign_string(self, params, options=None):
337
339
  formatParam = {}
338
340
  for k in params:
339
341
  formatParam[k.replace('_', '.')] = params[k]
340
342
  strParam = '&'.join('%s=%s' % (k, formatParam[k]) for k in sorted(formatParam))
341
- msg = '%s%s%s?%s' % (self.profile.httpProfile.reqMethod, self._get_endpoint(), self._requestPath, strParam)
343
+ msg = '%s%s%s?%s' % (
344
+ self.profile.httpProfile.reqMethod, self._get_endpoint(options=options), self._requestPath, strParam)
342
345
  return msg
343
346
 
344
347
  def _get_service_domain(self):
345
348
  rootDomain = self.profile.httpProfile.rootDomain
346
349
  return self._service + "." + rootDomain
347
350
 
348
- def _get_endpoint(self):
351
+ def _get_endpoint(self, options=None):
349
352
  endpoint = self.profile.httpProfile.endpoint
353
+ if not endpoint and options:
354
+ endpoint = urlparse(options.get("Endpoint", "")).hostname
350
355
  if endpoint is None:
351
356
  endpoint = self._get_service_domain()
352
357
  return endpoint
@@ -420,7 +425,7 @@ class AbstractClient(object):
420
425
  headers["X-TC-TraceId"] = str(uuid.uuid4())
421
426
  if not self.profile.disable_region_breaker:
422
427
  return self._call_with_region_breaker(action, params, options, headers)
423
- req = RequestInternal(self._get_endpoint(),
428
+ req = RequestInternal(self._get_endpoint(options=options),
424
429
  self.profile.httpProfile.reqMethod,
425
430
  self._requestPath,
426
431
  header=headers)
@@ -444,7 +449,7 @@ class AbstractClient(object):
444
449
  return retryer.send_request(_call_once).content
445
450
 
446
451
  def _call_with_region_breaker(self, action, params, options=None, headers=None):
447
- endpoint = self._get_endpoint()
452
+ endpoint = self._get_endpoint(options=options)
448
453
  generation, need_break = self.circuit_breaker.before_requests()
449
454
  if need_break:
450
455
  endpoint = self._service + "." + self.profile.region_breaker_profile.backup_endpoint
@@ -470,7 +475,7 @@ class AbstractClient(object):
470
475
  self._check_error(resp)
471
476
  return resp.content
472
477
 
473
- def call_octet_stream(self, action, headers, body):
478
+ def call_octet_stream(self, action, headers, body, options=None):
474
479
  """Invoke API with application/ocet-stream content-type.
475
480
 
476
481
  Note:
@@ -490,12 +495,14 @@ class AbstractClient(object):
490
495
  if self.profile.httpProfile.reqMethod != "POST":
491
496
  raise SDKError("ClientError", "Invalid request method.")
492
497
 
493
- req = RequestInternal(self._get_endpoint(),
498
+ if not options:
499
+ options = {}
500
+ req = RequestInternal(self._get_endpoint(options=options),
494
501
  self.profile.httpProfile.reqMethod,
495
502
  self._requestPath,
496
503
  header=headers)
497
504
  req.data = body
498
- options = {"IsOctetStream": True}
505
+ options["IsOctetStream"] = True
499
506
  self._build_req_inter(action, None, req, options)
500
507
 
501
508
  resp = self.request.send_request(req)
@@ -538,6 +545,7 @@ class AbstractClient(object):
538
545
  :param options: Request options, like {"SkipSign": False, "IsMultipart": False, "IsOctetStream": False, "BinaryParams": []}
539
546
  :type options: dict
540
547
  """
548
+
541
549
  def _call_once():
542
550
  resp = self._call(action, params, options, headers)
543
551
  self._check_status(resp)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tencentcloud-sdk-python-common
3
- Version: 3.0.1398
3
+ Version: 3.0.1400
4
4
  Summary: Tencent Cloud Common SDK for Python
5
5
  Home-page: https://github.com/TencentCloud/tencentcloud-sdk-python
6
6
  Author: Tencent Cloud
@@ -1,6 +1,6 @@
1
- tencentcloud/__init__.py,sha256=pKr6brC7YUjBkrxyLokSpN1rFqXikExgD0hq20xAUMo,631
1
+ tencentcloud/__init__.py,sha256=LqN0ndPTZccT-h8Q0XbdH8NKLR8KJkRmVGYMq-hMrQI,631
2
2
  tencentcloud/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- tencentcloud/common/abstract_client.py,sha256=W-kuyBPX23VbUV3sNpqhVMEivSg_Un7IRI_yk9IFCpQ,25100
3
+ tencentcloud/common/abstract_client.py,sha256=xJM9-JThhLv5_pnnqMie_RqZkSjnn_mVkaiy9phVLT0,25499
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
@@ -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.1398.dist-info/METADATA,sha256=-e46E7_rxsCmV0__zbiC0YawsFgYm_cFO1RgQYZA28U,1487
19
- tencentcloud_sdk_python_common-3.0.1398.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
20
- tencentcloud_sdk_python_common-3.0.1398.dist-info/top_level.txt,sha256=g-8OyzoqI6O6LiS85zkeNzhB-osEnRIPZMdyRd_0eL0,13
21
- tencentcloud_sdk_python_common-3.0.1398.dist-info/RECORD,,
18
+ tencentcloud_sdk_python_common-3.0.1400.dist-info/METADATA,sha256=ndMwDZHabJ947940mk5Fpc32glRVGNIQT5MYYECiDs4,1487
19
+ tencentcloud_sdk_python_common-3.0.1400.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
20
+ tencentcloud_sdk_python_common-3.0.1400.dist-info/top_level.txt,sha256=g-8OyzoqI6O6LiS85zkeNzhB-osEnRIPZMdyRd_0eL0,13
21
+ tencentcloud_sdk_python_common-3.0.1400.dist-info/RECORD,,