tencentcloud-sdk-python-common 3.0.1111__tar.gz → 3.0.1125__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 (25) hide show
  1. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/PKG-INFO +1 -1
  2. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/__init__.py +1 -1
  3. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/abstract_client.py +13 -3
  4. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/profile/client_profile.py +12 -1
  5. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud_sdk_python_common.egg-info/PKG-INFO +1 -1
  6. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/README.rst +0 -0
  7. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/setup.cfg +0 -0
  8. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/setup.py +0 -0
  9. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/__init__.py +0 -0
  10. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/abstract_model.py +0 -0
  11. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/circuit_breaker.py +0 -0
  12. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/common_client.py +0 -0
  13. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/credential.py +0 -0
  14. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/exception/__init__.py +0 -0
  15. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/exception/tencent_cloud_sdk_exception.py +0 -0
  16. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/http/__init__.py +0 -0
  17. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/http/pre_conn.py +0 -0
  18. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/http/request.py +0 -0
  19. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/profile/__init__.py +0 -0
  20. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/profile/http_profile.py +0 -0
  21. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud/common/sign.py +0 -0
  22. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud_sdk_python_common.egg-info/SOURCES.txt +0 -0
  23. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud_sdk_python_common.egg-info/dependency_links.txt +0 -0
  24. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud_sdk_python_common.egg-info/requires.txt +0 -0
  25. {tencentcloud-sdk-python-common-3.0.1111 → tencentcloud-sdk-python-common-3.0.1125}/tencentcloud_sdk_python_common.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: tencentcloud-sdk-python-common
3
- Version: 3.0.1111
3
+ Version: 3.0.1125
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
@@ -14,4 +14,4 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
- __version__ = '3.0.1111'
17
+ __version__ = '3.0.1125'
@@ -86,6 +86,10 @@ class AbstractClient(object):
86
86
  if self.profile.region_breaker_profile is None:
87
87
  self.profile.region_breaker_profile = RegionBreakerProfile()
88
88
  self.circuit_breaker = CircuitBreaker(self.profile.region_breaker_profile)
89
+ if self.profile.request_client:
90
+ self.request_client = self._sdkVersion + "; " + self.profile.request_client
91
+ else:
92
+ self.request_client = self._sdkVersion
89
93
 
90
94
  def _fix_params(self, params):
91
95
  if not isinstance(params, (dict,)):
@@ -135,7 +139,7 @@ class AbstractClient(object):
135
139
  def _build_req_with_old_signature(self, action, params, req):
136
140
  params = copy.deepcopy(self._fix_params(params))
137
141
  params['Action'] = action[0].upper() + action[1:]
138
- params['RequestClient'] = self._sdkVersion
142
+ params['RequestClient'] = self.request_client
139
143
  params['Nonce'] = random.randint(1, sys.maxsize)
140
144
  params['Timestamp'] = int(time.time())
141
145
  params['Version'] = self._apiVersion
@@ -184,7 +188,7 @@ class AbstractClient(object):
184
188
  timestamp = int(time.time())
185
189
  req.header["Host"] = endpoint
186
190
  req.header["X-TC-Action"] = action[0].upper() + action[1:]
187
- req.header["X-TC-RequestClient"] = self._sdkVersion
191
+ req.header["X-TC-RequestClient"] = self.request_client
188
192
  req.header["X-TC-Timestamp"] = str(timestamp)
189
193
  req.header["X-TC-Version"] = self._apiVersion
190
194
  if self.profile.unsignedPayload is True:
@@ -275,7 +279,7 @@ class AbstractClient(object):
275
279
  timestamp = int(time.time())
276
280
  req.header["Host"] = endpoint
277
281
  req.header["X-TC-Action"] = action[0].upper() + action[1:]
278
- req.header["X-TC-RequestClient"] = self._sdkVersion
282
+ req.header["X-TC-RequestClient"] = self.request_client
279
283
  req.header["X-TC-Timestamp"] = str(timestamp)
280
284
  req.header["X-TC-Version"] = self._apiVersion
281
285
  if self.profile.unsignedPayload is True:
@@ -397,6 +401,12 @@ class AbstractClient(object):
397
401
  e[key] = int(val)
398
402
 
399
403
  def _call(self, action, params, options=None, headers=None):
404
+ if headers is None:
405
+ headers = {}
406
+ if not isinstance(headers, dict):
407
+ raise TencentCloudSDKException("ClientError", "headers must be a dict.")
408
+ if "x-tc-traceid" not in {k.lower() for k in headers.keys()}:
409
+ headers["X-TC-TraceId"] = str(uuid.uuid4())
400
410
  if not self.profile.disable_region_breaker:
401
411
  return self._call_with_region_breaker(action, params, options, headers)
402
412
  req = RequestInternal(self._get_endpoint(),
@@ -11,6 +11,8 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+ import re
15
+ import warnings
14
16
  from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
15
17
  from tencentcloud.common.profile.http_profile import HttpProfile
16
18
 
@@ -19,7 +21,7 @@ class ClientProfile(object):
19
21
  unsignedPayload = False
20
22
 
21
23
  def __init__(self, signMethod=None, httpProfile=None, language="zh-CN",
22
- disable_region_breaker=True, region_breaker_profile=None):
24
+ disable_region_breaker=True, region_breaker_profile=None, request_client=None):
23
25
  """SDK profile.
24
26
 
25
27
  :param signMethod: The signature method, valid choice: HmacSHA1, HmacSHA256, TC3-HMAC-SHA256
@@ -32,6 +34,8 @@ class ClientProfile(object):
32
34
  :type disable_region_breaker: bool
33
35
  :param region_breaker_profile: The region breaker profile.
34
36
  :type region_breaker_profile: :class:`RegionBreakerProfile`
37
+ :param request_client: Custom request client.
38
+ :type request_client: str
35
39
  """
36
40
  self.httpProfile = HttpProfile() if httpProfile is None else httpProfile
37
41
  self.signMethod = "TC3-HMAC-SHA256" if signMethod is None else signMethod
@@ -43,6 +47,13 @@ class ClientProfile(object):
43
47
  self.region_breaker_profile = region_breaker_profile
44
48
  if not self.disable_region_breaker and self.region_breaker_profile is None:
45
49
  self.region_breaker_profile = RegionBreakerProfile()
50
+ self.request_client = None
51
+ if isinstance(request_client, str) and re.match("^[0-9a-zA-Z-_,;.]+$", request_client):
52
+ if len(request_client) > 128:
53
+ warnings.warn("the length of RequestClient should be with in 128 characters, it will be truncated")
54
+ self.request_client = request_client[:128]
55
+ elif request_client is not None:
56
+ warnings.warn("RequestClient not match the regexp: ^[0-9a-zA-Z-_,;.]+$, ignored")
46
57
 
47
58
 
48
59
  class RegionBreakerProfile(object):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: tencentcloud-sdk-python-common
3
- Version: 3.0.1111
3
+ Version: 3.0.1125
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