tencentcloud-sdk-python 3.0.1362__py2.py3-none-any.whl → 3.0.1364__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.
- tencentcloud/__init__.py +1 -1
- tencentcloud/batch/v20170312/models.py +12 -18
- tencentcloud/cat/v20180409/cat_client.py +23 -0
- tencentcloud/cat/v20180409/models.py +199 -0
- tencentcloud/cbs/v20170312/models.py +26 -12
- tencentcloud/ccc/v20200210/ccc_client.py +23 -0
- tencentcloud/ccc/v20200210/errorcodes.py +3 -0
- tencentcloud/ccc/v20200210/models.py +162 -60
- tencentcloud/cdwch/v20200915/models.py +0 -12
- tencentcloud/cdwpg/v20201230/models.py +0 -12
- tencentcloud/cfw/v20190904/models.py +115 -12
- tencentcloud/chc/v20230418/models.py +15 -0
- tencentcloud/clb/v20180317/clb_client.py +1 -1
- tencentcloud/clb/v20180317/models.py +262 -366
- tencentcloud/cls/v20201016/models.py +35 -0
- tencentcloud/cme/v20191029/errorcodes.py +3 -0
- tencentcloud/common/abstract_client.py +29 -24
- tencentcloud/common/abstract_model.py +5 -1
- tencentcloud/common/common_client.py +14 -15
- tencentcloud/common/credential.py +68 -65
- tencentcloud/common/exception/tencent_cloud_sdk_exception.py +1 -1
- tencentcloud/common/profile/client_profile.py +32 -30
- tencentcloud/common/profile/http_profile.py +20 -12
- tencentcloud/common/retry.py +18 -0
- tencentcloud/cvm/v20170312/cvm_client.py +7 -1
- tencentcloud/cvm/v20170312/errorcodes.py +1 -1
- tencentcloud/cvm/v20170312/models.py +88 -68
- tencentcloud/cynosdb/v20190107/cynosdb_client.py +69 -0
- tencentcloud/cynosdb/v20190107/models.py +318 -0
- tencentcloud/dc/v20180410/models.py +2 -2
- tencentcloud/dlc/v20210125/models.py +0 -16
- tencentcloud/dts/v20211206/models.py +11 -7
- tencentcloud/es/v20250101/models.py +2 -6
- tencentcloud/ess/v20201111/models.py +31 -12
- tencentcloud/gwlb/v20240906/errorcodes.py +3 -0
- tencentcloud/gwlb/v20240906/gwlb_client.py +0 -1
- tencentcloud/gwlb/v20240906/models.py +4 -4
- tencentcloud/hunyuan/v20230901/models.py +2 -2
- tencentcloud/ioa/v20220601/ioa_client.py +46 -0
- tencentcloud/ioa/v20220601/models.py +538 -0
- tencentcloud/iotexplorer/v20190423/iotexplorer_client.py +3 -1
- tencentcloud/lcic/v20220817/models.py +30 -0
- tencentcloud/lke/v20231130/errorcodes.py +3 -0
- tencentcloud/lke/v20231130/lke_client.py +4 -2
- tencentcloud/lke/v20231130/models.py +167 -6
- tencentcloud/lkeap/v20240522/lkeap_client.py +2 -2
- tencentcloud/lkeap/v20240522/models.py +4 -4
- tencentcloud/monitor/v20180724/models.py +169 -0
- tencentcloud/monitor/v20180724/monitor_client.py +23 -0
- tencentcloud/mps/v20190612/models.py +20 -20
- tencentcloud/tcbr/v20220217/models.py +30 -0
- tencentcloud/teo/v20220901/errorcodes.py +3 -0
- tencentcloud/teo/v20220901/models.py +8 -112
- tencentcloud/tsf/v20180326/models.py +15 -0
- tencentcloud/tts/v20190823/models.py +15 -15
- tencentcloud/tts/v20190823/tts_client.py +4 -3
- tencentcloud/vpc/v20170312/models.py +710 -0
- tencentcloud/vpc/v20170312/vpc_client.py +116 -1
- tencentcloud/vrs/v20200824/models.py +17 -0
- tencentcloud/waf/v20180125/errorcodes.py +9 -0
- tencentcloud/waf/v20180125/models.py +3372 -240
- tencentcloud/waf/v20180125/waf_client.py +138 -0
- tencentcloud/wedata/v20210820/models.py +55 -0
- {tencentcloud_sdk_python-3.0.1362.dist-info → tencentcloud_sdk_python-3.0.1364.dist-info}/METADATA +1 -1
- {tencentcloud_sdk_python-3.0.1362.dist-info → tencentcloud_sdk_python-3.0.1364.dist-info}/RECORD +68 -68
- {tencentcloud_sdk_python-3.0.1362.dist-info → tencentcloud_sdk_python-3.0.1364.dist-info}/LICENSE +0 -0
- {tencentcloud_sdk_python-3.0.1362.dist-info → tencentcloud_sdk_python-3.0.1364.dist-info}/WHEEL +0 -0
- {tencentcloud_sdk_python-3.0.1362.dist-info → tencentcloud_sdk_python-3.0.1364.dist-info}/top_level.txt +0 -0
@@ -335,6 +335,8 @@ class AlarmInfo(AbstractModel):
|
|
335
335
|
:type GroupTriggerStatus: bool
|
336
336
|
:param _GroupTriggerCondition: 分组触发条件。
|
337
337
|
:type GroupTriggerCondition: list of str
|
338
|
+
:param _Tags: 告警策略绑定的标签信息。
|
339
|
+
:type Tags: list of Tag
|
338
340
|
:param _MonitorObjectType: 监控对象类型。0:执行语句共用监控对象;1:每个执行语句单独选择监控对象。
|
339
341
|
:type MonitorObjectType: int
|
340
342
|
:param _AlarmLevel: 告警级别。0:警告(Warn);1:提醒(Info);2:紧急 (Critical)。
|
@@ -361,6 +363,7 @@ Condition互斥。
|
|
361
363
|
self._Analysis = None
|
362
364
|
self._GroupTriggerStatus = None
|
363
365
|
self._GroupTriggerCondition = None
|
366
|
+
self._Tags = None
|
364
367
|
self._MonitorObjectType = None
|
365
368
|
self._AlarmLevel = None
|
366
369
|
self._Classifications = None
|
@@ -543,6 +546,17 @@ Condition互斥。
|
|
543
546
|
def GroupTriggerCondition(self, GroupTriggerCondition):
|
544
547
|
self._GroupTriggerCondition = GroupTriggerCondition
|
545
548
|
|
549
|
+
@property
|
550
|
+
def Tags(self):
|
551
|
+
"""告警策略绑定的标签信息。
|
552
|
+
:rtype: list of Tag
|
553
|
+
"""
|
554
|
+
return self._Tags
|
555
|
+
|
556
|
+
@Tags.setter
|
557
|
+
def Tags(self, Tags):
|
558
|
+
self._Tags = Tags
|
559
|
+
|
546
560
|
@property
|
547
561
|
def MonitorObjectType(self):
|
548
562
|
"""监控对象类型。0:执行语句共用监控对象;1:每个执行语句单独选择监控对象。
|
@@ -620,6 +634,12 @@ Condition互斥。
|
|
620
634
|
self._Analysis.append(obj)
|
621
635
|
self._GroupTriggerStatus = params.get("GroupTriggerStatus")
|
622
636
|
self._GroupTriggerCondition = params.get("GroupTriggerCondition")
|
637
|
+
if params.get("Tags") is not None:
|
638
|
+
self._Tags = []
|
639
|
+
for item in params.get("Tags"):
|
640
|
+
obj = Tag()
|
641
|
+
obj._deserialize(item)
|
642
|
+
self._Tags.append(obj)
|
623
643
|
self._MonitorObjectType = params.get("MonitorObjectType")
|
624
644
|
self._AlarmLevel = params.get("AlarmLevel")
|
625
645
|
if params.get("Classifications") is not None:
|
@@ -30072,11 +30092,14 @@ long及double类型字段需为空;
|
|
30072
30092
|
:type SqlFlag: bool
|
30073
30093
|
:param _ContainZH: 是否包含中文,long及double类型字段需为false
|
30074
30094
|
:type ContainZH: bool
|
30095
|
+
:param _Alias: 字段别名
|
30096
|
+
:type Alias: str
|
30075
30097
|
"""
|
30076
30098
|
self._Type = None
|
30077
30099
|
self._Tokenizer = None
|
30078
30100
|
self._SqlFlag = None
|
30079
30101
|
self._ContainZH = None
|
30102
|
+
self._Alias = None
|
30080
30103
|
|
30081
30104
|
@property
|
30082
30105
|
def Type(self):
|
@@ -30125,12 +30148,24 @@ long及double类型字段需为空;
|
|
30125
30148
|
def ContainZH(self, ContainZH):
|
30126
30149
|
self._ContainZH = ContainZH
|
30127
30150
|
|
30151
|
+
@property
|
30152
|
+
def Alias(self):
|
30153
|
+
"""字段别名
|
30154
|
+
:rtype: str
|
30155
|
+
"""
|
30156
|
+
return self._Alias
|
30157
|
+
|
30158
|
+
@Alias.setter
|
30159
|
+
def Alias(self, Alias):
|
30160
|
+
self._Alias = Alias
|
30161
|
+
|
30128
30162
|
|
30129
30163
|
def _deserialize(self, params):
|
30130
30164
|
self._Type = params.get("Type")
|
30131
30165
|
self._Tokenizer = params.get("Tokenizer")
|
30132
30166
|
self._SqlFlag = params.get("SqlFlag")
|
30133
30167
|
self._ContainZH = params.get("ContainZH")
|
30168
|
+
self._Alias = params.get("Alias")
|
30134
30169
|
memeber_set = set(params.keys())
|
30135
30170
|
for name, value in vars(self).items():
|
30136
30171
|
property_name = name[1:]
|
@@ -83,6 +83,9 @@ INVALIDPARAMETERVALUE_DEFINITION = 'InvalidParameterValue.Definition'
|
|
83
83
|
# 目标分类不存在。
|
84
84
|
INVALIDPARAMETERVALUE_DSTCLASSPATHNOTEXIST = 'InvalidParameterValue.DstClassPathNotExist'
|
85
85
|
|
86
|
+
# 结束时间参数不合法。
|
87
|
+
INVALIDPARAMETERVALUE_ENDTIME = 'InvalidParameterValue.EndTime'
|
88
|
+
|
86
89
|
# 导出目标不合法。
|
87
90
|
INVALIDPARAMETERVALUE_EXPORTDESTINATION = 'InvalidParameterValue.ExportDestination'
|
88
91
|
|
@@ -471,20 +471,19 @@ class AbstractClient(object):
|
|
471
471
|
return resp.content
|
472
472
|
|
473
473
|
def call_octet_stream(self, action, headers, body):
|
474
|
-
"""
|
475
|
-
Invoke API with application/ocet-stream content-type.
|
474
|
+
"""Invoke API with application/ocet-stream content-type.
|
476
475
|
|
477
476
|
Note:
|
478
477
|
1. only specific API can be invoked in such manner.
|
479
478
|
2. only TC3-HMAC-SHA256 signature method can be specified.
|
480
479
|
3. only POST request method can be specified
|
481
480
|
|
482
|
-
:type action: str
|
483
481
|
:param action: Specific API action name.
|
484
|
-
:type
|
482
|
+
:type action: str
|
485
483
|
:param headers: Header parameters for this API.
|
486
|
-
:type
|
484
|
+
:type headers: dict
|
487
485
|
:param body: Bytes of requested body
|
486
|
+
:type body: bytes
|
488
487
|
"""
|
489
488
|
if self.profile.signMethod != "TC3-HMAC-SHA256":
|
490
489
|
raise SDKError("ClientError", "Invalid signature method.")
|
@@ -505,17 +504,16 @@ class AbstractClient(object):
|
|
505
504
|
return json.loads(resp.content)
|
506
505
|
|
507
506
|
def call_json(self, action, params, headers=None, options=None):
|
508
|
-
"""
|
509
|
-
Call api with json object and return with json object.
|
507
|
+
"""Call api with json object and return with json object.
|
510
508
|
|
511
|
-
:type action: str
|
512
509
|
:param action: api name e.g. ``DescribeInstances``
|
510
|
+
:type action: str
|
511
|
+
:param params: Request parameters of this action
|
513
512
|
:type params: dict
|
514
|
-
:param
|
513
|
+
:param headers: Request headers, like {"X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca"}
|
515
514
|
:type headers: dict
|
516
|
-
:param
|
515
|
+
:param options: Request options, like {"SkipSign": False, "IsMultipart": False, "IsOctetStream": False, "BinaryParams": []}
|
517
516
|
:type options: dict
|
518
|
-
:param options: request options, like {"SkipSign": False, "IsMultipart": False, "IsOctetStream": False, "BinaryParams": []}
|
519
517
|
"""
|
520
518
|
|
521
519
|
def _call_once():
|
@@ -529,6 +527,17 @@ class AbstractClient(object):
|
|
529
527
|
return json.loads(retryer.send_request(_call_once).content)
|
530
528
|
|
531
529
|
def call_sse(self, action, params, headers=None, options=None):
|
530
|
+
"""Call api with json object and return with sse event.
|
531
|
+
|
532
|
+
:param action: api name e.g. ``ChatCompletions``
|
533
|
+
:type action: str
|
534
|
+
:param params: Request parameters of this action
|
535
|
+
:type params: dict
|
536
|
+
:param headers: Request headers, like {"X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca"}
|
537
|
+
:type headers: dict
|
538
|
+
:param options: Request options, like {"SkipSign": False, "IsMultipart": False, "IsOctetStream": False, "BinaryParams": []}
|
539
|
+
:type options: dict
|
540
|
+
"""
|
532
541
|
def _call_once():
|
533
542
|
resp = self._call(action, params, options, headers)
|
534
543
|
self._check_status(resp)
|
@@ -557,15 +566,14 @@ class AbstractClient(object):
|
|
557
566
|
return self._process_response_json(resp, resp_type)
|
558
567
|
|
559
568
|
def set_stream_logger(self, stream=None, level=logging.DEBUG, log_format=None):
|
560
|
-
"""
|
561
|
-
Add a stream handler
|
569
|
+
"""Add a stream handler
|
562
570
|
|
563
|
-
:type stream: IO[str]
|
564
571
|
:param stream: e.g. ``sys.stdout`` ``sys.stdin`` ``sys.stderr``
|
565
|
-
:type
|
572
|
+
:type stream: IO[str]
|
566
573
|
:param level: Logging level, e.g. ``logging.INFO``
|
567
|
-
:type
|
574
|
+
:type level: int
|
568
575
|
:param log_format: Log message format
|
576
|
+
:type log_format: str
|
569
577
|
"""
|
570
578
|
log = logging.getLogger(LOGGER_NAME)
|
571
579
|
log.setLevel(level)
|
@@ -578,15 +586,14 @@ class AbstractClient(object):
|
|
578
586
|
log.addHandler(sh)
|
579
587
|
|
580
588
|
def set_file_logger(self, file_path, level=logging.DEBUG, log_format=None):
|
581
|
-
"""
|
582
|
-
Add a file handler
|
589
|
+
"""Add a file handler
|
583
590
|
|
584
|
-
:type file_path: str
|
585
591
|
:param file_path: path of log file
|
586
|
-
:type
|
592
|
+
:type file_path: str
|
587
593
|
:param level: Logging level, e.g. ``logging.INFO``
|
588
|
-
:type
|
594
|
+
:type level: int
|
589
595
|
:param log_format: Log message format
|
596
|
+
:type log_format: str
|
590
597
|
"""
|
591
598
|
log = logging.getLogger(LOGGER_NAME)
|
592
599
|
log.setLevel(level)
|
@@ -600,9 +607,7 @@ class AbstractClient(object):
|
|
600
607
|
log.addHandler(fh)
|
601
608
|
|
602
609
|
def set_default_logger(self):
|
603
|
-
"""
|
604
|
-
Set default log handler
|
605
|
-
"""
|
610
|
+
"""Set default log handler"""
|
606
611
|
log = logging.getLogger(LOGGER_NAME)
|
607
612
|
log.handlers = []
|
608
613
|
logger.addHandler(EmptyHandler())
|
@@ -61,7 +61,11 @@ class AbstractModel(object):
|
|
61
61
|
return json.dumps(self._serialize(allow_none=True), *args, **kwargs)
|
62
62
|
|
63
63
|
def from_json_string(self, jsonStr):
|
64
|
-
"""Deserialize a JSON formatted str to a Python object
|
64
|
+
"""Deserialize a JSON formatted str to a Python object
|
65
|
+
|
66
|
+
:param jsonStr: JSON formatted string
|
67
|
+
:type jsonStr: str
|
68
|
+
"""
|
65
69
|
params = json.loads(jsonStr)
|
66
70
|
self._deserialize(params)
|
67
71
|
|
@@ -21,25 +21,24 @@ from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentClo
|
|
21
21
|
|
22
22
|
|
23
23
|
class CommonClient(AbstractClient):
|
24
|
-
"""
|
25
|
-
|
26
|
-
|
24
|
+
"""General client for all products.
|
25
|
+
|
26
|
+
With CommonClient, you only need to install the tencentcloud-sdk-python-common package to access APIs of all products.
|
27
|
+
See GitHub examples for usage details: https://github.com/TencentCloud/tencentcloud-sdk-python/tree/master/examples/common_client
|
27
28
|
|
29
|
+
:param service: Product name
|
30
|
+
:type service: str
|
31
|
+
:param version: Version of API
|
32
|
+
:type version: str
|
33
|
+
:param credential: Request credential
|
34
|
+
:type credential: tencentcloud.common.credential.Credential or tencentcloud.common.credential.STSAssumeRoleCredential or None
|
35
|
+
:param region: Request region
|
36
|
+
:type region: str
|
37
|
+
:param profile: Request SDK profile
|
38
|
+
:type profile: tencentcloud.common.profile.client_profile.ClientProfile
|
28
39
|
"""
|
29
40
|
|
30
41
|
def __init__(self, service, version, credential, region, profile=None):
|
31
|
-
"""
|
32
|
-
:param credential: 接口调用凭证
|
33
|
-
:type credential: tencentcloud.common.credential.Credential or tencentcloud.common.credential.STSAssumeRoleCredential or None
|
34
|
-
:param region: 接口调用地域
|
35
|
-
:type region: str
|
36
|
-
:param version: 接口版本
|
37
|
-
:type version: str
|
38
|
-
:param service: 接口产品
|
39
|
-
:type service: str
|
40
|
-
:param profile: 请求网络信息
|
41
|
-
:type profile: tencentcloud.common.profile.client_profile.ClientProfile
|
42
|
-
"""
|
43
42
|
if region is None or version is None or service is None:
|
44
43
|
raise TencentCloudSDKException("CommonClient Parameter Error, "
|
45
44
|
"credential region version service all required.")
|
@@ -35,20 +35,20 @@ from tencentcloud.common.profile.client_profile import ClientProfile
|
|
35
35
|
|
36
36
|
|
37
37
|
class Credential(object):
|
38
|
+
"""Tencent Cloud Credentials.
|
39
|
+
|
40
|
+
Access https://console.cloud.tencent.com/cam/capi to manage your credentials.
|
41
|
+
|
42
|
+
:param secret_id: The secret id of your credential.
|
43
|
+
:type secret_id: str
|
44
|
+
:param secret_key: The secret key of your credential.
|
45
|
+
:type secret_key: str
|
46
|
+
:param token: The federation token of your credential, if this field
|
47
|
+
is specified, secret_id and secret_key should be set
|
48
|
+
accordingly, see: https://cloud.tencent.com/document/product/598/13896
|
49
|
+
"""
|
50
|
+
|
38
51
|
def __init__(self, secret_id, secret_key, token=None):
|
39
|
-
"""Tencent Cloud Credentials.
|
40
|
-
|
41
|
-
Access https://console.cloud.tencent.com/cam/capi to manage your
|
42
|
-
credentials.
|
43
|
-
|
44
|
-
:param secret_id: The secret id of your credential.
|
45
|
-
:type secret_id: str
|
46
|
-
:param secret_key: The secret key of your credential.
|
47
|
-
:type secret_key: str
|
48
|
-
:param token: The federation token of your credential, if this field
|
49
|
-
is specified, secret_id and secret_key should be set
|
50
|
-
accordingly, see: https://cloud.tencent.com/document/product/598/13896
|
51
|
-
"""
|
52
52
|
if secret_id is None or secret_id.strip() == "":
|
53
53
|
raise TencentCloudSDKException("InvalidCredential", "secret id should not be none or empty")
|
54
54
|
if secret_id.strip() != secret_id:
|
@@ -73,6 +73,11 @@ class Credential(object):
|
|
73
73
|
|
74
74
|
|
75
75
|
class CVMRoleCredential(object):
|
76
|
+
"""Tencent Cloud Credential via CVM role
|
77
|
+
|
78
|
+
Automatically generates temporary credentials when binding a service role to instance.
|
79
|
+
See https://cloud.tencent.com/document/product/598/85616 for more information.
|
80
|
+
"""
|
76
81
|
_metadata_endpoint = "http://metadata.tencentyun.com/latest/meta-data/"
|
77
82
|
_role_endpoint = _metadata_endpoint + "cam/security-credentials/"
|
78
83
|
# In seconds.
|
@@ -156,9 +161,20 @@ class CVMRoleCredential(object):
|
|
156
161
|
|
157
162
|
|
158
163
|
class STSAssumeRoleCredential(object):
|
159
|
-
"""
|
160
|
-
|
161
|
-
|
164
|
+
"""Tencent Cloud Credential via STS service
|
165
|
+
|
166
|
+
Automatically generates temporary credentials for API calls.
|
167
|
+
|
168
|
+
:param secret_id: The secret id of your credential.
|
169
|
+
:type secret_id: str
|
170
|
+
:param secret_key: The secret key of your credential.
|
171
|
+
:type secret_key: str
|
172
|
+
:param role_arn: Resource descriptions of a role,see https://cloud.tencent.com/document/api/1312/48197
|
173
|
+
:type role_arn: str
|
174
|
+
:param role_session_name: User-defined temporary session name
|
175
|
+
:type role_session_name: str
|
176
|
+
:param duration_seconds: Specifies the validity period of credentials in seconds. Default value: 7200. Maximum value: 43200
|
177
|
+
:type duration_seconds: int
|
162
178
|
"""
|
163
179
|
_region = "ap-guangzhou"
|
164
180
|
_version = '2018-08-13'
|
@@ -167,17 +183,7 @@ class STSAssumeRoleCredential(object):
|
|
167
183
|
|
168
184
|
def __init__(self, secret_id, secret_key, role_arn, role_session_name, duration_seconds=7200, endpoint=None):
|
169
185
|
"""
|
170
|
-
|
171
|
-
:type secret_id: str
|
172
|
-
:param secret_key: 接口调用凭证key
|
173
|
-
:type secret_key: str
|
174
|
-
https://cloud.tencent.com/document/api/1312/48197
|
175
|
-
:param role_arn: 角色的资源描述,参考官网文档 https://cloud.tencent.com/document/api/1312/48197 中 RoleArn 参数的描述。
|
176
|
-
:type role_arn: str
|
177
|
-
:param role_session_name: 临时会话名称,由用户自定义名称
|
178
|
-
:type role_session_name: str
|
179
|
-
:param duration_seconds: 获取临时凭证的有效期,默认7200s
|
180
|
-
:type duration_seconds: int
|
186
|
+
|
181
187
|
"""
|
182
188
|
self._long_secret_id = secret_id
|
183
189
|
self._long_secret_key = secret_key
|
@@ -221,19 +227,6 @@ class STSAssumeRoleCredential(object):
|
|
221
227
|
return self._token
|
222
228
|
|
223
229
|
def _need_refresh(self):
|
224
|
-
"""
|
225
|
-
https://cloud.tencent.com/document/api/1312/48197
|
226
|
-
此函数自动使用初始secret_id和secret_key,自动调用上述链接中获取临时凭证的接口,并返回临时凭证
|
227
|
-
|
228
|
-
:param role_arn: 角色的资源描述,上述链接RoleArn参数中有详细获取方式
|
229
|
-
:type role_arn: str
|
230
|
-
:param role_session_name: 临时会话名称,由用户自定义名称
|
231
|
-
:type role_session_name: str
|
232
|
-
:param duration_seconds: 获取临时凭证的有效期,默认7200s
|
233
|
-
:type duration_seconds: int
|
234
|
-
|
235
|
-
"""
|
236
|
-
|
237
230
|
if None in [self._token, self._tmp_secret_key, self._tmp_secret_id] or self._expired_time < int(time.time()):
|
238
231
|
self.get_sts_tmp_role_arn()
|
239
232
|
|
@@ -260,18 +253,14 @@ class STSAssumeRoleCredential(object):
|
|
260
253
|
|
261
254
|
|
262
255
|
class EnvironmentVariableCredential(object):
|
256
|
+
"""Tencent Cloud EnvironmentVariableCredential.
|
263
257
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
credentials.
|
258
|
+
Acquire credential from environment variables.
|
259
|
+
Access https://console.cloud.tencent.com/cam/capi to manage your credentials.
|
260
|
+
Set secret id and secret key as `TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY `in environment variables.
|
261
|
+
"""
|
269
262
|
|
270
|
-
|
271
|
-
:type secret_id: str
|
272
|
-
:param secret_key: The secret key of your credential. get by environment variable TENCENTCLOUD_SECRET_KEY
|
273
|
-
:type secret_key: str
|
274
|
-
"""
|
263
|
+
def get_credential(self):
|
275
264
|
self.secret_id = os.environ.get('TENCENTCLOUD_SECRET_ID')
|
276
265
|
self.secret_key = os.environ.get('TENCENTCLOUD_SECRET_KEY')
|
277
266
|
|
@@ -283,23 +272,17 @@ class EnvironmentVariableCredential(object):
|
|
283
272
|
|
284
273
|
|
285
274
|
class ProfileCredential(object):
|
275
|
+
"""Tencent Cloud ProfileCredential.
|
276
|
+
|
277
|
+
Access https://console.cloud.tencent.com/cam/capi to manage your credentials.
|
278
|
+
default file position is "~/.tencentcloud/credentials" or "/etc/tencentcloud/credentials", it is ini format.
|
279
|
+
such as:
|
280
|
+
[default]
|
281
|
+
secret_id=""
|
282
|
+
secret_key=""
|
283
|
+
"""
|
286
284
|
|
287
285
|
def get_credential(self):
|
288
|
-
"""Tencent Cloud ProfileCredential.
|
289
|
-
|
290
|
-
Access https://console.cloud.tencent.com/cam/capi to manage your credentials.
|
291
|
-
|
292
|
-
default file position is "~/.tencentcloud/credentials" or "/etc/tencentcloud/credentials", it is ini format.
|
293
|
-
such as:
|
294
|
-
[default]
|
295
|
-
secret_id=""
|
296
|
-
secret_key=""
|
297
|
-
|
298
|
-
:param secret_id: The secret id of your credential.
|
299
|
-
:type secret_id: str
|
300
|
-
:param secret_key: The secret key of your credential.
|
301
|
-
:type secret_key: str
|
302
|
-
"""
|
303
286
|
home_path = os.environ.get('HOME') or os.environ.get('HOMEPATH')
|
304
287
|
if os.path.exists(home_path + "/.tencentcloud/credentials"):
|
305
288
|
file_path = home_path + "/.tencentcloud/credentials"
|
@@ -371,6 +354,7 @@ class DefaultCredentialProvider(object):
|
|
371
354
|
|
372
355
|
|
373
356
|
class DefaultTkeOIDCRoleArnProvider(object):
|
357
|
+
"""Acquire credential via TKE IdP automatically."""
|
374
358
|
def get_credential(self):
|
375
359
|
return self.get_credentials()
|
376
360
|
|
@@ -382,6 +366,25 @@ class DefaultTkeOIDCRoleArnProvider(object):
|
|
382
366
|
|
383
367
|
|
384
368
|
class OIDCRoleArnCredential(object):
|
369
|
+
"""TencentCloud OIDC Credential
|
370
|
+
|
371
|
+
OIDC is an authentication protocol built on OAuth 2.0. Tencent Cloud CAM supports OIDC role-based SSO.
|
372
|
+
See https://cloud.tencent.com/document/product/598/96013 for more information.
|
373
|
+
This will apply for an OIDC role credential automatically.
|
374
|
+
|
375
|
+
:param region: Region for AssumeRoleWithWebIdentity call. See https://cloud.tencent.com/document/product/1312/73070
|
376
|
+
:type region: str
|
377
|
+
:param provider_id: Identity provider name
|
378
|
+
:type provider_id: str
|
379
|
+
:param web_identity_token: OIDC token issued by the IdP
|
380
|
+
:type web_identity_token: str
|
381
|
+
:param role_arn: Role access description name
|
382
|
+
:type role_arn: str
|
383
|
+
:param role_session_name: Session name
|
384
|
+
:type role_session_name: str
|
385
|
+
:param duration_seconds: The validity period of the temporary credential in seconds. Default value: 7200s. Maximum value: 43200s.
|
386
|
+
:type duration_seconds: int
|
387
|
+
"""
|
385
388
|
_version = '2018-08-13'
|
386
389
|
_service = "sts"
|
387
390
|
_action = 'AssumeRoleWithWebIdentity'
|
@@ -18,25 +18,27 @@ from tencentcloud.common.profile.http_profile import HttpProfile
|
|
18
18
|
|
19
19
|
|
20
20
|
class ClientProfile(object):
|
21
|
+
"""SDK profile.
|
22
|
+
|
23
|
+
:param signMethod: The signature method, valid choice: HmacSHA1, HmacSHA256, TC3-HMAC-SHA256
|
24
|
+
:type signMethod: str
|
25
|
+
:param httpProfile: The http profile
|
26
|
+
:type httpProfile: :class:`HttpProfile`
|
27
|
+
:param language: Valid choice: en-US, zh-CN.
|
28
|
+
:type language: str
|
29
|
+
:param disable_region_breaker: Switch of region breaker.
|
30
|
+
:type disable_region_breaker: bool
|
31
|
+
:param region_breaker_profile: The region breaker profile.
|
32
|
+
:type region_breaker_profile: :class:`RegionBreakerProfile`
|
33
|
+
:param request_client: Custom request client.
|
34
|
+
:type request_client: str
|
35
|
+
:param retryer: Custom retry configuration.
|
36
|
+
:type retryer: :class:`tencentcloud.common.retry.StandardRetryer`
|
37
|
+
"""
|
21
38
|
unsignedPayload = False
|
22
39
|
|
23
40
|
def __init__(self, signMethod=None, httpProfile=None, language="zh-CN",
|
24
41
|
disable_region_breaker=True, region_breaker_profile=None, request_client=None, retryer=None):
|
25
|
-
"""SDK profile.
|
26
|
-
|
27
|
-
:param signMethod: The signature method, valid choice: HmacSHA1, HmacSHA256, TC3-HMAC-SHA256
|
28
|
-
:type signMethod: str
|
29
|
-
:param httpProfile: The http profile
|
30
|
-
:type httpProfile: :class:`HttpProfile`
|
31
|
-
:param language: Valid choice: en-US, zh-CN.
|
32
|
-
:type language: str
|
33
|
-
:param disable_region_breaker: Switch of region breaker.
|
34
|
-
:type disable_region_breaker: bool
|
35
|
-
:param region_breaker_profile: The region breaker profile.
|
36
|
-
:type region_breaker_profile: :class:`RegionBreakerProfile`
|
37
|
-
:param request_client: Custom request client.
|
38
|
-
:type request_client: str
|
39
|
-
"""
|
40
42
|
self.httpProfile = HttpProfile() if httpProfile is None else httpProfile
|
41
43
|
self.signMethod = "TC3-HMAC-SHA256" if signMethod is None else signMethod
|
42
44
|
valid_language = ["zh-CN", "en-US"]
|
@@ -59,6 +61,21 @@ class ClientProfile(object):
|
|
59
61
|
|
60
62
|
|
61
63
|
class RegionBreakerProfile(object):
|
64
|
+
"""RegionBreaker profile.
|
65
|
+
|
66
|
+
:param backup_endpoint: Backup region of endpoint, default ap-guangzhou.tencentcloudapi.com.
|
67
|
+
:type backup_endpoint: str
|
68
|
+
:param max_fail_num: Max failure to trigger breaker, default 5.
|
69
|
+
:type max_fail_num: int
|
70
|
+
:param max_fail_percent: Max failure percent to trigger breaker, default 0.75.
|
71
|
+
:type max_fail_percent: float
|
72
|
+
:param window_interval: Decides when to reset counter if the state is StateClosed, default 5 minutes.
|
73
|
+
:type window_interval: int
|
74
|
+
:param timeout: Decides when to turn StateOpen to StateHalfOpen, default 60 seconds.
|
75
|
+
:type timeout: int
|
76
|
+
:param max_requests: Decides when to turn StateHalfOpen to StateClosed, default 5 successful requests.
|
77
|
+
:type max_requests: int
|
78
|
+
"""
|
62
79
|
|
63
80
|
def __init__(self, backup_endpoint="ap-guangzhou.tencentcloudapi.com",
|
64
81
|
max_fail_num=5,
|
@@ -66,21 +83,6 @@ class RegionBreakerProfile(object):
|
|
66
83
|
window_interval=60 * 5,
|
67
84
|
timeout=60,
|
68
85
|
max_requests=5):
|
69
|
-
"""RegionBreaker profile.
|
70
|
-
|
71
|
-
:param backup_endpoint: Backup region of endpoint, default ap-guangzhou.tencentcloudapi.com.
|
72
|
-
:type backup_endpoint: str
|
73
|
-
:param max_fail_num: Max failure to trigger breaker, default 5.
|
74
|
-
:type max_fail_num: int
|
75
|
-
:param max_fail_percent: Max failure percent to trigger breaker, default 0.75.
|
76
|
-
:type max_fail_percent: float
|
77
|
-
:param window_interval: Decides when to reset counter if the state is StateClosed, default 5 minutes.
|
78
|
-
:type window_interval: int
|
79
|
-
:param timeout: Decides when to turn StateOpen to StateHalfOpen, default 1 minutes.
|
80
|
-
:type timeout: int
|
81
|
-
:param max_requests: Decides when to turn StateHalfOpen to StateClosed, default 5 successful requests.
|
82
|
-
:type timeout: int
|
83
|
-
"""
|
84
86
|
self.backup_endpoint = backup_endpoint
|
85
87
|
if not self.check_endpoint():
|
86
88
|
raise TencentCloudSDKException("ClientError", "the format of `backup_endpoint` must be tencentcloudapi.com "
|
@@ -14,22 +14,30 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
class HttpProfile(object):
|
17
|
+
"""HTTP profile.
|
18
|
+
|
19
|
+
:param protocol: Request schema, http or https, default is https.
|
20
|
+
:type protocol: str
|
21
|
+
:param endpoint: The domain to access, like: cvm.tencentcloudapi.com
|
22
|
+
:type endpoint: str
|
23
|
+
:param reqMethod: The http method, valid choice: GET, POST
|
24
|
+
:type reqMethod: str
|
25
|
+
:param reqTimeout: The http timeout in second.
|
26
|
+
:type reqTimeout: int
|
27
|
+
:param keepAlive: Whether set keep alive.
|
28
|
+
:type keepAlive: bool
|
29
|
+
:param proxy: Custom proxy server, like: http(s)://{user}:{password}@{ip}:{port}.
|
30
|
+
:type proxy: str
|
31
|
+
:param rootDomain: The root domain to access, like: tencentcloudapi.com.
|
32
|
+
:type rootDomain: str
|
33
|
+
:param certification: Custom certificate path (typically not required).
|
34
|
+
Set `False` to disable certificate verification.
|
35
|
+
:type certification: str or bool
|
36
|
+
"""
|
17
37
|
scheme = "https"
|
18
38
|
|
19
39
|
def __init__(self, protocol=None, endpoint=None, reqMethod="POST", reqTimeout=60,
|
20
40
|
keepAlive=False, proxy=None, rootDomain=None, certification=None):
|
21
|
-
"""HTTP profile.
|
22
|
-
:param protocol: http or https, default is https.
|
23
|
-
:type protocol: str
|
24
|
-
:param endpoint: The domain to access, like: cvm.tencentcloudapi.com
|
25
|
-
:type endpoint: str
|
26
|
-
:param reqMethod: the http method, valid choice: GET, POST
|
27
|
-
:type reqMethod: str
|
28
|
-
:param reqTimeout: The http timeout in second.
|
29
|
-
:type reqTimeout: int
|
30
|
-
:param rootDomain: The root domain to access, like: tencentcloudapi.com.
|
31
|
-
:type rootDomain: str
|
32
|
-
"""
|
33
41
|
self.endpoint = endpoint
|
34
42
|
self.reqTimeout = 60 if reqTimeout is None else reqTimeout
|
35
43
|
self.reqMethod = "POST" if reqMethod is None else reqMethod
|
tencentcloud/common/retry.py
CHANGED
@@ -5,11 +5,29 @@ from tencentcloud.common.exception import TencentCloudSDKException
|
|
5
5
|
|
6
6
|
|
7
7
|
class NoopRetryer(object):
|
8
|
+
"""configuration without retry
|
9
|
+
|
10
|
+
NoopRetryer is a retry policy that does nothing.
|
11
|
+
It is useful when you don't want to retry.
|
12
|
+
"""
|
13
|
+
|
8
14
|
def send_request(self, fn):
|
9
15
|
return fn()
|
10
16
|
|
11
17
|
|
12
18
|
class StandardRetryer(object):
|
19
|
+
"""Retry configuration
|
20
|
+
|
21
|
+
StandardRetryer is a retry policy that retries on network errors or frequency limitation.
|
22
|
+
:param max_attempts: Maximum number of attempts.
|
23
|
+
:type max_attempts: int
|
24
|
+
:param backoff_fn: A function that takes the number of attempts and returns the number of seconds to sleep before the next retry.
|
25
|
+
Default sleep time is 2^n seconds, n is the number of attempts.
|
26
|
+
:type backoff_fn: function
|
27
|
+
:param logger: A logger to log retry attempts. If not provided, no logging will be performed.
|
28
|
+
:type logger: logging.Logger
|
29
|
+
"""
|
30
|
+
|
13
31
|
def __init__(self, max_attempts=3, backoff_fn=None, logger=None):
|
14
32
|
self._max_attempts = max_attempts
|
15
33
|
self._backoff_fn = backoff_fn or self.backoff
|
@@ -53,6 +53,9 @@ class CvmClient(AbstractClient):
|
|
53
53
|
def AssociateInstancesKeyPairs(self, request):
|
54
54
|
"""本接口 (AssociateInstancesKeyPairs) 用于将密钥绑定到实例上。
|
55
55
|
|
56
|
+
* 仅支持对 `Linux` 操作系统实例进行绑定操作。
|
57
|
+
* 非强制关机场景下,仅支持对 [STOPPED](https://cloud.tencent.com/document/product/213/15753#InstanceStatus) 状态实例进行绑定操作。
|
58
|
+
* 强制关机场景下,先执行强制关机,再绑定密钥;如实例原状态为 [RUNNING](https://cloud.tencent.com/document/product/213/15753#InstanceStatus),绑定完成后实例会自动开机。
|
56
59
|
* 将密钥的公钥写入到实例的`SSH`配置当中,用户就可以通过该密钥的私钥来登录实例。
|
57
60
|
* 如果实例原来绑定过密钥,那么原来的密钥将失效。
|
58
61
|
* 如果实例原来是通过密码登录,绑定密钥后无法使用密码登录。
|
@@ -1268,7 +1271,9 @@ class CvmClient(AbstractClient):
|
|
1268
1271
|
def DisassociateInstancesKeyPairs(self, request):
|
1269
1272
|
"""本接口 (DisassociateInstancesKeyPairs) 用于解除实例的密钥绑定关系。
|
1270
1273
|
|
1271
|
-
*
|
1274
|
+
* 仅支持对 Linux 操作系统实例进行解绑操作。
|
1275
|
+
* 非强制关机场景下,仅支持对 [STOPPED](https://cloud.tencent.com/document/product/213/15753#InstanceStatus) 状态实例进行解绑操作。
|
1276
|
+
* 强制关机场景下,先执行强制关机,再解绑密钥;如实例原状态为 [RUNNING](https://cloud.tencent.com/document/product/213/15753#InstanceStatus),解绑完成后实例会自动开机。
|
1272
1277
|
* 解绑密钥后,实例可以通过原来设置的密码登录。
|
1273
1278
|
* 如果原来没有设置密码,解绑后将无法使用 `SSH` 登录。可以调用 [ResetInstancesPassword](https://cloud.tencent.com/document/api/213/15736) 接口来设置登录密码。
|
1274
1279
|
* 支持批量操作。每次请求批量实例的上限为100。如果批量实例存在不允许操作的实例,操作会以特定错误码返回。
|
@@ -2431,6 +2436,7 @@ class CvmClient(AbstractClient):
|
|
2431
2436
|
* 默认扩容方式为关机后扩容。
|
2432
2437
|
* 实例操作结果可以通过调用 [DescribeInstances](https://cloud.tencent.com/document/api/213/15728#.E7.A4.BA.E4.BE.8B3-.E6.9F.A5.E8.AF.A2.E5.AE.9E.E4.BE.8B.E7.9A.84.E6.9C.80.E6.96.B0.E6.93.8D.E4.BD.9C.E6.83.85.E5.86.B5) 接口查询,如果实例的最新操作状态(LatestOperationState)为“SUCCESS”,则代表操作成功。
|
2433
2438
|
* 如果是系统盘,目前只支持扩容,不支持缩容。
|
2439
|
+
* 如果是运行中的实例,必须指定ForceStop或ResizeOnline任意一个参数为true,否则操作失败。
|
2434
2440
|
|
2435
2441
|
:param request: Request instance for ResizeInstanceDisks.
|
2436
2442
|
:type request: :class:`tencentcloud.cvm.v20170312.models.ResizeInstanceDisksRequest`
|