tccli 3.0.1353.1__py2.py3-none-any.whl → 3.0.1355.1__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.
Files changed (41) hide show
  1. tccli/__init__.py +1 -1
  2. tccli/services/__init__.py +3 -0
  3. tccli/services/aiart/aiart_client.py +70 -123
  4. tccli/services/aiart/v20221229/api.json +1 -99
  5. tccli/services/aiart/v20221229/examples.json +0 -8
  6. tccli/services/apm/v20210622/api.json +39 -1
  7. tccli/services/autoscaling/v20180419/api.json +45 -1
  8. tccli/services/cbs/v20170312/examples.json +3 -3
  9. tccli/services/ccc/v20200210/api.json +100 -0
  10. tccli/services/cdb/v20170320/api.json +64 -16
  11. tccli/services/cdb/v20170320/examples.json +1 -1
  12. tccli/services/cdwch/v20200915/api.json +85 -85
  13. tccli/services/cdwch/v20200915/examples.json +1 -1
  14. tccli/services/ctsdb/__init__.py +4 -0
  15. tccli/services/ctsdb/ctsdb_client.py +260 -0
  16. tccli/services/ctsdb/v20230202/api.json +679 -0
  17. tccli/services/ctsdb/v20230202/examples.json +21 -0
  18. tccli/services/dbbrain/v20210527/api.json +40 -0
  19. tccli/services/dlc/dlc_client.py +53 -0
  20. tccli/services/dlc/v20210125/api.json +44 -0
  21. tccli/services/dlc/v20210125/examples.json +8 -0
  22. tccli/services/essbasic/v20210526/api.json +46 -1
  23. tccli/services/gs/v20191118/api.json +32 -2
  24. tccli/services/hunyuan/v20230901/api.json +80 -0
  25. tccli/services/igtm/v20231024/api.json +152 -152
  26. tccli/services/igtm/v20231024/examples.json +27 -27
  27. tccli/services/lke/v20231130/api.json +1 -1
  28. tccli/services/securitylake/v20240117/api.json +2 -2
  29. tccli/services/ssl/v20191205/api.json +50 -0
  30. tccli/services/tcaplusdb/v20190823/api.json +2 -2
  31. tccli/services/teo/v20220901/api.json +55 -6
  32. tccli/services/teo/v20220901/examples.json +18 -0
  33. tccli/services/trtc/v20190722/api.json +1 -1
  34. tccli/services/tts/v20190823/api.json +3 -3
  35. tccli/services/vclm/v20240523/api.json +2 -2
  36. tccli/services/vod/v20180717/api.json +11 -2
  37. {tccli-3.0.1353.1.dist-info → tccli-3.0.1355.1.dist-info}/METADATA +3 -3
  38. {tccli-3.0.1353.1.dist-info → tccli-3.0.1355.1.dist-info}/RECORD +41 -37
  39. {tccli-3.0.1353.1.dist-info → tccli-3.0.1355.1.dist-info}/WHEEL +0 -0
  40. {tccli-3.0.1353.1.dist-info → tccli-3.0.1355.1.dist-info}/entry_points.txt +0 -0
  41. {tccli-3.0.1353.1.dist-info → tccli-3.0.1355.1.dist-info}/license_files/LICENSE +0 -0
@@ -0,0 +1,260 @@
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import sys
4
+ import six
5
+ import json
6
+ import tccli.options_define as OptionsDefine
7
+ import tccli.format_output as FormatOutput
8
+ from tccli import __version__
9
+ from tccli.utils import Utils
10
+ from tccli.exceptions import ConfigurationError, ClientError, ParamError
11
+ from tencentcloud.common import credential
12
+ from tencentcloud.common.profile.http_profile import HttpProfile
13
+ from tencentcloud.common.profile.client_profile import ClientProfile
14
+ from tencentcloud.ctsdb.v20230202 import ctsdb_client as ctsdb_client_v20230202
15
+ from tencentcloud.ctsdb.v20230202 import models as models_v20230202
16
+
17
+ from jmespath import search
18
+ import time
19
+
20
+ def doDescribeClusters(args, parsed_globals):
21
+ g_param = parse_global_arg(parsed_globals)
22
+
23
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
24
+ cred = credential.CVMRoleCredential()
25
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
26
+ cred = credential.STSAssumeRoleCredential(
27
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
28
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
29
+ )
30
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
31
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
32
+ else:
33
+ cred = credential.Credential(
34
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
35
+ )
36
+ http_profile = HttpProfile(
37
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
38
+ reqMethod="POST",
39
+ endpoint=g_param[OptionsDefine.Endpoint],
40
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
41
+ )
42
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
43
+ if g_param[OptionsDefine.Language]:
44
+ profile.language = g_param[OptionsDefine.Language]
45
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
46
+ client = mod.CtsdbClient(cred, g_param[OptionsDefine.Region], profile)
47
+ client._sdkVersion += ("_CLI_" + __version__)
48
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
49
+ model = models.DescribeClustersRequest()
50
+ model.from_json_string(json.dumps(args))
51
+ start_time = time.time()
52
+ while True:
53
+ rsp = client.DescribeClusters(model)
54
+ result = rsp.to_json_string()
55
+ try:
56
+ json_obj = json.loads(result)
57
+ except TypeError as e:
58
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
59
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
60
+ break
61
+ cur_time = time.time()
62
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
63
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
64
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
65
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
66
+ else:
67
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
68
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
69
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
70
+
71
+
72
+ def doDescribeDatabases(args, parsed_globals):
73
+ g_param = parse_global_arg(parsed_globals)
74
+
75
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
76
+ cred = credential.CVMRoleCredential()
77
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
78
+ cred = credential.STSAssumeRoleCredential(
79
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
80
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
81
+ )
82
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
83
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
84
+ else:
85
+ cred = credential.Credential(
86
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
87
+ )
88
+ http_profile = HttpProfile(
89
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
90
+ reqMethod="POST",
91
+ endpoint=g_param[OptionsDefine.Endpoint],
92
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
93
+ )
94
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
95
+ if g_param[OptionsDefine.Language]:
96
+ profile.language = g_param[OptionsDefine.Language]
97
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
98
+ client = mod.CtsdbClient(cred, g_param[OptionsDefine.Region], profile)
99
+ client._sdkVersion += ("_CLI_" + __version__)
100
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
101
+ model = models.DescribeDatabasesRequest()
102
+ model.from_json_string(json.dumps(args))
103
+ start_time = time.time()
104
+ while True:
105
+ rsp = client.DescribeDatabases(model)
106
+ result = rsp.to_json_string()
107
+ try:
108
+ json_obj = json.loads(result)
109
+ except TypeError as e:
110
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
111
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
112
+ break
113
+ cur_time = time.time()
114
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
115
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
116
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
117
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
118
+ else:
119
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
120
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
121
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
122
+
123
+
124
+ CLIENT_MAP = {
125
+ "v20230202": ctsdb_client_v20230202,
126
+
127
+ }
128
+
129
+ MODELS_MAP = {
130
+ "v20230202": models_v20230202,
131
+
132
+ }
133
+
134
+ ACTION_MAP = {
135
+ "DescribeClusters": doDescribeClusters,
136
+ "DescribeDatabases": doDescribeDatabases,
137
+
138
+ }
139
+
140
+ AVAILABLE_VERSION_LIST = [
141
+ "v20230202",
142
+
143
+ ]
144
+
145
+
146
+ def action_caller():
147
+ return ACTION_MAP
148
+
149
+
150
+ def parse_global_arg(parsed_globals):
151
+ g_param = parsed_globals
152
+ cvm_role_flag = True
153
+ for param in parsed_globals.keys():
154
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.RoleArn,
155
+ OptionsDefine.RoleSessionName]:
156
+ if parsed_globals[param] is not None:
157
+ cvm_role_flag = False
158
+ break
159
+ is_exist_profile = True
160
+ if not parsed_globals["profile"]:
161
+ is_exist_profile = False
162
+ g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
163
+
164
+ configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
165
+ is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
166
+ is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
167
+
168
+ conf = {}
169
+ cred = {}
170
+
171
+ if is_conf_exist:
172
+ conf = Utils.load_json_msg(conf_path)
173
+ if is_cred_exist:
174
+ cred = Utils.load_json_msg(cred_path)
175
+
176
+ if not (isinstance(conf, dict) and isinstance(cred, dict)):
177
+ raise ConfigurationError(
178
+ "file: %s or %s is not json format"
179
+ % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
180
+
181
+ if OptionsDefine.Token not in cred:
182
+ cred[OptionsDefine.Token] = None
183
+
184
+ if not is_exist_profile:
185
+ if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
186
+ cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
187
+ cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
188
+ cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
189
+ cvm_role_flag = False
190
+
191
+ if os.environ.get(OptionsDefine.ENV_REGION):
192
+ conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
193
+
194
+ if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
195
+ cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
196
+ cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
197
+ cvm_role_flag = False
198
+
199
+ if cvm_role_flag:
200
+ if "type" in cred and cred["type"] == "cvm-role":
201
+ g_param[OptionsDefine.UseCVMRole.replace('-', '_')] = True
202
+
203
+ for param in g_param.keys():
204
+ if g_param[param] is None:
205
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
206
+ if param in cred:
207
+ g_param[param] = cred[param]
208
+ elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
209
+ or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
210
+ raise ConfigurationError("%s is invalid" % param)
211
+ elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
212
+ if param in conf[OptionsDefine.SysParam]:
213
+ g_param[param] = conf[OptionsDefine.SysParam][param]
214
+ elif param != OptionsDefine.Language:
215
+ raise ConfigurationError("%s is invalid" % param)
216
+ elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
217
+ if param.replace('_', '-') in cred:
218
+ g_param[param] = cred[param.replace('_', '-')]
219
+
220
+ try:
221
+ if g_param[OptionsDefine.ServiceVersion]:
222
+ g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
223
+ else:
224
+ version = conf["ctsdb"][OptionsDefine.Version]
225
+ g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
226
+
227
+ if g_param[OptionsDefine.Endpoint] is None:
228
+ g_param[OptionsDefine.Endpoint] = conf["ctsdb"][OptionsDefine.Endpoint]
229
+ g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
230
+ except Exception as err:
231
+ raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
232
+
233
+ if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
234
+ raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
235
+
236
+ if g_param[OptionsDefine.Waiter]:
237
+ param = eval(g_param[OptionsDefine.Waiter])
238
+ if 'expr' not in param:
239
+ raise Exception('`expr` in `--waiter` must be defined')
240
+ if 'to' not in param:
241
+ raise Exception('`to` in `--waiter` must be defined')
242
+ if 'timeout' not in param:
243
+ if 'waiter' in conf and 'timeout' in conf['waiter']:
244
+ param['timeout'] = conf['waiter']['timeout']
245
+ else:
246
+ param['timeout'] = 180
247
+ if 'interval' not in param:
248
+ if 'waiter' in conf and 'interval' in conf['waiter']:
249
+ param['interval'] = conf['waiter']['interval']
250
+ else:
251
+ param['interval'] = 5
252
+ param['interval'] = min(param['interval'], param['timeout'])
253
+ g_param['OptionsDefine.WaiterInfo'] = param
254
+
255
+ if six.PY2:
256
+ for key, value in g_param.items():
257
+ if isinstance(value, six.text_type):
258
+ g_param[key] = value.encode('utf-8')
259
+ return g_param
260
+