tccli 3.0.966.1__py2.py3-none-any.whl → 3.0.968.1__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. tccli/__init__.py +1 -1
  2. tccli/examples/bi/v20220105/ModifyUserRole.md +53 -0
  3. tccli/examples/cdwpg/v20201230/CreateInstanceByApi.md +40 -0
  4. tccli/examples/cdwpg/v20201230/DestroyInstanceByApi.md +22 -0
  5. tccli/examples/csip/v20221121/DescribeDbAssets.md +258 -65
  6. tccli/examples/dbbrain/v20210527/DescribeIndexRecommendAggregationSlowLogs.md +34 -0
  7. tccli/examples/dbbrain/v20210527/DescribeIndexRecommendInfo.md +57 -0
  8. tccli/examples/dbbrain/v20210527/DescribeRedisProcessList.md +46 -0
  9. tccli/examples/ess/v20201111/CreateDocument.md +1 -1
  10. tccli/examples/ess/v20201111/DescribeFileUrls.md +30 -0
  11. tccli/examples/ess/v20201111/UploadFiles.md +46 -14
  12. tccli/examples/sms/v20210111/AddSmsSign.md +4 -4
  13. tccli/examples/sms/v20210111/AddSmsTemplate.md +1 -1
  14. tccli/examples/sms/v20210111/DescribeSmsSignList.md +2 -2
  15. tccli/examples/sms/v20210111/DescribeSmsTemplateList.md +2 -2
  16. tccli/examples/sms/v20210111/ModifySmsSign.md +4 -4
  17. tccli/examples/sms/v20210111/ModifySmsTemplate.md +1 -1
  18. tccli/examples/sms/v20210111/PullSmsReplyStatus.md +3 -3
  19. tccli/examples/sms/v20210111/PullSmsReplyStatusByPhoneNumber.md +2 -2
  20. tccli/examples/sms/v20210111/PullSmsSendStatus.md +1 -1
  21. tccli/examples/sms/v20210111/SendSms.md +3 -3
  22. tccli/examples/tat/v20201028/DescribeInvocationTasks.md +12 -6
  23. tccli/examples/teo/v20220901/VerifyOwnership.md +66 -0
  24. tccli/examples/trtc/v20190722/DescribeTRTCMarketQualityData.md +2 -2
  25. tccli/examples/trtc/v20190722/DescribeTRTCMarketScaleData.md +27 -45
  26. tccli/examples/trtc/v20190722/DescribeTRTCRealTimeQualityData.md +202 -6
  27. tccli/examples/trtc/v20190722/DescribeTRTCRealTimeScaleData.md +214 -7
  28. tccli/examples/tse/v20201207/CreateCloudNativeAPIGatewayCanaryRule.md +2 -2
  29. tccli/examples/tse/v20201207/DeleteCloudNativeAPIGatewayCanaryRule.md +3 -3
  30. tccli/examples/tse/v20201207/DescribeCloudNativeAPIGatewayCanaryRules.md +10 -10
  31. tccli/examples/tse/v20201207/DescribeNacosReplicas.md +13 -10
  32. tccli/examples/tse/v20201207/DescribeNacosServerInterfaces.md +4 -4
  33. tccli/examples/tse/v20201207/DescribeZookeeperReplicas.md +12 -10
  34. tccli/examples/tse/v20201207/ModifyCloudNativeAPIGatewayCanaryRule.md +5 -5
  35. tccli/examples/vpc/v20170312/DescribeVpcPeeringConnections.md +29 -1
  36. tccli/services/__init__.py +3 -0
  37. tccli/services/asr/v20190614/api.json +1 -1
  38. tccli/services/bi/bi_client.py +53 -0
  39. tccli/services/bi/v20220105/api.json +109 -0
  40. tccli/services/bi/v20220105/examples.json +14 -0
  41. tccli/services/cdwpg/__init__.py +4 -0
  42. tccli/services/cdwpg/cdwpg_client.py +247 -0
  43. tccli/services/cdwpg/v20201230/api.json +354 -0
  44. tccli/services/cdwpg/v20201230/examples.json +21 -0
  45. tccli/services/clb/v20180317/api.json +4 -4
  46. tccli/services/csip/v20221121/api.json +66 -26
  47. tccli/services/csip/v20221121/examples.json +4 -4
  48. tccli/services/dbbrain/dbbrain_client.py +171 -12
  49. tccli/services/dbbrain/v20210527/api.json +614 -0
  50. tccli/services/dbbrain/v20210527/examples.json +24 -0
  51. tccli/services/ess/v20201111/api.json +158 -28
  52. tccli/services/ess/v20201111/examples.json +20 -8
  53. tccli/services/essbasic/v20210526/api.json +140 -2
  54. tccli/services/lcic/v20220817/api.json +7 -7
  55. tccli/services/lighthouse/v20200324/api.json +3 -3
  56. tccli/services/mps/v20190612/api.json +2 -1
  57. tccli/services/ocr/v20181119/api.json +1 -1
  58. tccli/services/sms/v20210111/api.json +84 -81
  59. tccli/services/sms/v20210111/examples.json +11 -11
  60. tccli/services/tat/v20201028/api.json +9 -9
  61. tccli/services/tat/v20201028/examples.json +1 -1
  62. tccli/services/teo/teo_client.py +65 -12
  63. tccli/services/teo/v20220901/api.json +169 -1
  64. tccli/services/teo/v20220901/examples.json +20 -0
  65. tccli/services/tmt/v20180321/api.json +5 -2
  66. tccli/services/trtc/v20190722/api.json +1 -1
  67. tccli/services/trtc/v20190722/examples.json +8 -8
  68. tccli/services/tse/v20201207/api.json +7 -6
  69. tccli/services/tse/v20201207/examples.json +13 -13
  70. tccli/services/vod/v20180717/api.json +18 -5
  71. tccli/services/vpc/v20170312/api.json +206 -0
  72. tccli/services/vpc/v20170312/examples.json +1 -1
  73. tccli/services/waf/v20180125/api.json +22 -0
  74. {tccli-3.0.966.1.dist-info → tccli-3.0.968.1.dist-info}/METADATA +2 -2
  75. {tccli-3.0.966.1.dist-info → tccli-3.0.968.1.dist-info}/RECORD +78 -67
  76. {tccli-3.0.966.1.dist-info → tccli-3.0.968.1.dist-info}/WHEEL +0 -0
  77. {tccli-3.0.966.1.dist-info → tccli-3.0.968.1.dist-info}/entry_points.txt +0 -0
  78. {tccli-3.0.966.1.dist-info → tccli-3.0.968.1.dist-info}/license_files/LICENSE +0 -0
@@ -13,7 +13,35 @@ Output:
13
13
  ```
14
14
  {
15
15
  "Response": {
16
- "RequestId": "c9f0e94c-3e0c-4d39-8155-fcf5ba13ec96"
16
+ "TotalCount": 0,
17
+ "PeerConnectionSet": [
18
+ {
19
+ "SourceVpcId": "abc",
20
+ "PeerVpcId": "abc",
21
+ "PeeringConnectionId": "abc",
22
+ "PeeringConnectionName": "abc",
23
+ "State": "abc",
24
+ "IsNgw": true,
25
+ "Bandwidth": 0,
26
+ "SourceRegion": "abc",
27
+ "DestinationRegion": "abc",
28
+ "CreateTime": "abc",
29
+ "AppId": 0,
30
+ "PeerAppId": 0,
31
+ "ChargeType": "abc",
32
+ "SourceUin": 0,
33
+ "DestinationUin": 0,
34
+ "TagSet": [
35
+ {
36
+ "Key": "abc",
37
+ "Value": "abc"
38
+ }
39
+ ],
40
+ "QosLevel": "abc",
41
+ "Type": "abc"
42
+ }
43
+ ],
44
+ "RequestId": "abc"
17
45
  }
18
46
  }
19
47
  ```
@@ -152,6 +152,9 @@ SERVICE_VERSIONS = {
152
152
  "cdwch": [
153
153
  "2020-09-15"
154
154
  ],
155
+ "cdwpg": [
156
+ "2020-12-30"
157
+ ],
155
158
  "cfg": [
156
159
  "2021-08-20"
157
160
  ],
@@ -530,7 +530,7 @@
530
530
  },
531
531
  {
532
532
  "disabled": false,
533
- "document": "识别结果返回样式\n0:基础识别结果(仅包含有效人声时间戳,无词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail));\n1:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值,**不含标点**);\n2:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点);\n3:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点),且识别结果按标点符号分段,**适用字幕场景**;\n4:**【增值付费功能】**基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点),且识别结果按nlp语义分段,**适用会议、庭审记录转写等场景**,仅支持8k_zh/16k_zh引擎\n\n注意:如果传入参数值4,需确保账号已购买[语义分段资源包](https://cloud.tencent.com/document/product/1093/35686#97ae4aa0-29a0-4066-9f07-ccaf8856a16b),或账号开启后付费;**若当前账号已开启后付费功能,并传入参数值4,将[自动计费](https://cloud.tencent.com/document/product/1093/35686#d912167d-ffd5-41a9-8b1c-2e89845a6852))**",
533
+ "document": "识别结果返回样式\n0:基础识别结果(仅包含有效人声时间戳,无词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail));\n1:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值,**不含标点**);\n2:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点);\n3:基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点),且识别结果按标点符号分段,**适用字幕场景**;\n4:**【增值付费功能】**基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点),且识别结果按nlp语义分段,**适用会议、庭审记录转写等场景**,仅支持8k_zh/16k_zh引擎\n5:**【增值付费功能】**基础识别结果之上,增加词粒度的[详细识别结果](https://cloud.tencent.com/document/api/1093/37824#SentenceDetail)(包含词级别时间戳、语速值和标点),并输出口语转书面语转写结果,该结果去除语气词、重复词、精简冗余表达,并修正发言人口误,实现口语转书面语的效果,**适用于线上、线下会议直接总结为书面会议纪要的场景**,仅支持8k_zh/16k_zh引擎\n\n注意:\n如果传入参数值4,需确保账号已购买[语义分段资源包](https://cloud.tencent.com/document/product/1093/35686#97ae4aa0-29a0-4066-9f07-ccaf8856a16b),或账号开启后付费;**若当前账号已开启后付费功能,并传入参数值4,将[自动计费](https://cloud.tencent.com/document/product/1093/35686#d912167d-ffd5-41a9-8b1c-2e89845a6852)**\n如果传入参数值5,需确保账号已购买[口语转书面语资源包](https://cloud.tencent.com/document/product/1093/35686#97ae4aa0-29a0-4066-9f07-ccaf8856a16b),或账号开启后付费;**若当前账号已开启后付费功能,并传入参数值5,将自动计费[自动计费](https://cloud.tencent.com/document/product/1093/35686#d912167d-ffd5-41a9-8b1c-2e89845a6852)**",
534
534
  "example": "0",
535
535
  "member": "uint64",
536
536
  "name": "ResTextFormat",
@@ -225,6 +225,58 @@ def doCreateUserRoleProject(args, parsed_globals):
225
225
  FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
226
226
 
227
227
 
228
+ def doModifyUserRole(args, parsed_globals):
229
+ g_param = parse_global_arg(parsed_globals)
230
+
231
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
232
+ cred = credential.CVMRoleCredential()
233
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
234
+ cred = credential.STSAssumeRoleCredential(
235
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
236
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')]
237
+ )
238
+ 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):
239
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
240
+ else:
241
+ cred = credential.Credential(
242
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
243
+ )
244
+ http_profile = HttpProfile(
245
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
246
+ reqMethod="POST",
247
+ endpoint=g_param[OptionsDefine.Endpoint],
248
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
249
+ )
250
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
251
+ if g_param[OptionsDefine.Language]:
252
+ profile.language = g_param[OptionsDefine.Language]
253
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
254
+ client = mod.BiClient(cred, g_param[OptionsDefine.Region], profile)
255
+ client._sdkVersion += ("_CLI_" + __version__)
256
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
257
+ model = models.ModifyUserRoleRequest()
258
+ model.from_json_string(json.dumps(args))
259
+ start_time = time.time()
260
+ while True:
261
+ rsp = client.ModifyUserRole(model)
262
+ result = rsp.to_json_string()
263
+ try:
264
+ json_obj = json.loads(result)
265
+ except TypeError as e:
266
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
267
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
268
+ break
269
+ cur_time = time.time()
270
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
271
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
272
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
273
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
274
+ else:
275
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
276
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
277
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
278
+
279
+
228
280
  def doDeleteUserRoleProject(args, parsed_globals):
229
281
  g_param = parse_global_arg(parsed_globals)
230
282
 
@@ -1072,6 +1124,7 @@ ACTION_MAP = {
1072
1124
  "DescribeDatasourceList": doDescribeDatasourceList,
1073
1125
  "CreateDatasource": doCreateDatasource,
1074
1126
  "CreateUserRoleProject": doCreateUserRoleProject,
1127
+ "ModifyUserRole": doModifyUserRole,
1075
1128
  "DeleteUserRoleProject": doDeleteUserRoleProject,
1076
1129
  "CreateEmbedToken": doCreateEmbedToken,
1077
1130
  "DescribeProjectInfo": doDescribeProjectInfo,
@@ -133,6 +133,13 @@
133
133
  "output": "ModifyProjectResponse",
134
134
  "status": "online"
135
135
  },
136
+ "ModifyUserRole": {
137
+ "document": "修改用户角色信息",
138
+ "input": "ModifyUserRoleRequest",
139
+ "name": "修改用户角色信息",
140
+ "output": "ModifyUserRoleResponse",
141
+ "status": "online"
142
+ },
136
143
  "ModifyUserRoleProject": {
137
144
  "document": "项目-修改用户角色信息",
138
145
  "input": "ModifyUserRoleProjectRequest",
@@ -3228,6 +3235,108 @@
3228
3235
  ],
3229
3236
  "type": "object"
3230
3237
  },
3238
+ "ModifyUserRoleRequest": {
3239
+ "document": "ModifyUserRole请求参数结构体",
3240
+ "members": [
3241
+ {
3242
+ "disabled": false,
3243
+ "document": "用户ID",
3244
+ "example": "无",
3245
+ "member": "string",
3246
+ "name": "UserId",
3247
+ "required": false,
3248
+ "type": "string"
3249
+ },
3250
+ {
3251
+ "disabled": false,
3252
+ "document": "角色ID 列表",
3253
+ "example": "无",
3254
+ "member": "int64",
3255
+ "name": "RoleIdList",
3256
+ "required": false,
3257
+ "type": "list"
3258
+ },
3259
+ {
3260
+ "disabled": false,
3261
+ "document": "邮箱",
3262
+ "example": "无",
3263
+ "member": "string",
3264
+ "name": "Email",
3265
+ "required": false,
3266
+ "type": "string"
3267
+ },
3268
+ {
3269
+ "disabled": false,
3270
+ "document": "用户名",
3271
+ "example": "无",
3272
+ "member": "string",
3273
+ "name": "UserName",
3274
+ "required": false,
3275
+ "type": "string"
3276
+ },
3277
+ {
3278
+ "disabled": false,
3279
+ "document": "手机号",
3280
+ "example": "无",
3281
+ "member": "string",
3282
+ "name": "PhoneNumber",
3283
+ "required": false,
3284
+ "type": "string"
3285
+ },
3286
+ {
3287
+ "disabled": false,
3288
+ "document": "手机区号",
3289
+ "example": "无",
3290
+ "member": "string",
3291
+ "name": "AreaCode",
3292
+ "required": false,
3293
+ "type": "string"
3294
+ }
3295
+ ],
3296
+ "type": "object"
3297
+ },
3298
+ "ModifyUserRoleResponse": {
3299
+ "document": "ModifyUserRole返回参数结构体",
3300
+ "members": [
3301
+ {
3302
+ "disabled": false,
3303
+ "document": "扩展\n注意:此字段可能返回 null,表示取不到有效值。",
3304
+ "example": "无",
3305
+ "member": "string",
3306
+ "name": "Extra",
3307
+ "output_required": true,
3308
+ "type": "string",
3309
+ "value_allowed_null": true
3310
+ },
3311
+ {
3312
+ "disabled": false,
3313
+ "document": "消息\n注意:此字段可能返回 null,表示取不到有效值。",
3314
+ "example": "无",
3315
+ "member": "string",
3316
+ "name": "Msg",
3317
+ "output_required": true,
3318
+ "type": "string",
3319
+ "value_allowed_null": true
3320
+ },
3321
+ {
3322
+ "disabled": false,
3323
+ "document": "数据\n注意:此字段可能返回 null,表示取不到有效值。",
3324
+ "example": "无",
3325
+ "member": "string",
3326
+ "name": "Data",
3327
+ "output_required": true,
3328
+ "type": "string",
3329
+ "value_allowed_null": true
3330
+ },
3331
+ {
3332
+ "document": "唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。",
3333
+ "member": "string",
3334
+ "name": "RequestId",
3335
+ "type": "string"
3336
+ }
3337
+ ],
3338
+ "type": "object"
3339
+ },
3231
3340
  "PermissionComponent": {
3232
3341
  "document": "商业版本权限单元",
3233
3342
  "members": [
@@ -176,6 +176,20 @@
176
176
  "title": "修改项目"
177
177
  }
178
178
  ],
179
+ "ModifyUserRole": [
180
+ {
181
+ "document": "",
182
+ "input": "POST / HTTP/1.1\nHost: bi.tencentcloudapi.com\nContent-Type: application/json\nX-TC-Action: ModifyUserRole\n<公共请求参数>\n\n{\n \"RoleIdList\": [\n \"100090\"\n ],\n \"UserId\": \"joshshzho\",\n \"Email\": \"abc@qq.com\"\n}",
183
+ "output": "{\n \"Response\": {\n \"RequestId\": \"933660c5-a247-4068-a852-c3eaf0e93684\",\n \"Extra\": \"\",\n \"Data\": null,\n \"Msg\": \"success\"\n }\n}",
184
+ "title": "修改用户角色信息"
185
+ },
186
+ {
187
+ "document": "",
188
+ "input": "POST / HTTP/1.1\nHost: bi.tencentcloudapi.com\nContent-Type: application/json\nX-TC-Action: ModifyUserRole\n<公共请求参数>\n\n{\n \"UserName\": \"tommyho\",\n \"AreaCode\": \"086\",\n \"UserId\": \"tommyho\",\n \"PhoneNumber\": \"123456\",\n \"RoleIdList\": [\n \"100099\"\n ],\n \"Email\": \"123@qq.com\"\n}",
189
+ "output": "{\n \"Response\": {\n \"Msg\": \"success\",\n \"RequestId\": \"6b573965-cda5-4c95-a66a-fd1bd6d77c5c\",\n \"Extra\": \"\",\n \"Data\": null\n }\n}",
190
+ "title": "demo"
191
+ }
192
+ ],
179
193
  "ModifyUserRoleProject": [
180
194
  {
181
195
  "document": "",
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from tccli.services.cdwpg.cdwpg_client import action_caller
4
+
@@ -0,0 +1,247 @@
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.cdwpg.v20201230 import cdwpg_client as cdwpg_client_v20201230
15
+ from tencentcloud.cdwpg.v20201230 import models as models_v20201230
16
+
17
+ from jmespath import search
18
+ import time
19
+
20
+ def doDestroyInstanceByApi(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('-', '_')]
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.CdwpgClient(cred, g_param[OptionsDefine.Region], profile)
47
+ client._sdkVersion += ("_CLI_" + __version__)
48
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
49
+ model = models.DestroyInstanceByApiRequest()
50
+ model.from_json_string(json.dumps(args))
51
+ start_time = time.time()
52
+ while True:
53
+ rsp = client.DestroyInstanceByApi(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 doCreateInstanceByApi(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('-', '_')]
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.CdwpgClient(cred, g_param[OptionsDefine.Region], profile)
99
+ client._sdkVersion += ("_CLI_" + __version__)
100
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
101
+ model = models.CreateInstanceByApiRequest()
102
+ model.from_json_string(json.dumps(args))
103
+ start_time = time.time()
104
+ while True:
105
+ rsp = client.CreateInstanceByApi(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
+ "v20201230": cdwpg_client_v20201230,
126
+
127
+ }
128
+
129
+ MODELS_MAP = {
130
+ "v20201230": models_v20201230,
131
+
132
+ }
133
+
134
+ ACTION_MAP = {
135
+ "DestroyInstanceByApi": doDestroyInstanceByApi,
136
+ "CreateInstanceByApi": doCreateInstanceByApi,
137
+
138
+ }
139
+
140
+ AVAILABLE_VERSION_LIST = [
141
+ "v20201230",
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
+
153
+ is_exist_profile = True
154
+ if not parsed_globals["profile"]:
155
+ is_exist_profile = False
156
+ g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
157
+
158
+ configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
159
+ is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
160
+ is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
161
+
162
+ conf = {}
163
+ cred = {}
164
+
165
+ if is_conf_exist:
166
+ conf = Utils.load_json_msg(conf_path)
167
+ if is_cred_exist:
168
+ cred = Utils.load_json_msg(cred_path)
169
+
170
+ if not (isinstance(conf, dict) and isinstance(cred, dict)):
171
+ raise ConfigurationError(
172
+ "file: %s or %s is not json format"
173
+ % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
174
+
175
+ if OptionsDefine.Token not in cred:
176
+ cred[OptionsDefine.Token] = None
177
+
178
+ if not is_exist_profile:
179
+ if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
180
+ cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
181
+ cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
182
+ cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
183
+
184
+ if os.environ.get(OptionsDefine.ENV_REGION):
185
+ conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
186
+
187
+ if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
188
+ cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
189
+ cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
190
+
191
+ for param in g_param.keys():
192
+ if g_param[param] is None:
193
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
194
+ if param in cred:
195
+ g_param[param] = cred[param]
196
+ elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
197
+ or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
198
+ raise ConfigurationError("%s is invalid" % param)
199
+ elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
200
+ if param in conf[OptionsDefine.SysParam]:
201
+ g_param[param] = conf[OptionsDefine.SysParam][param]
202
+ elif param != OptionsDefine.Language:
203
+ raise ConfigurationError("%s is invalid" % param)
204
+ elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
205
+ if param.replace('_', '-') in cred:
206
+ g_param[param] = cred[param.replace('_', '-')]
207
+
208
+ try:
209
+ if g_param[OptionsDefine.ServiceVersion]:
210
+ g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
211
+ else:
212
+ version = conf["cdwpg"][OptionsDefine.Version]
213
+ g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
214
+
215
+ if g_param[OptionsDefine.Endpoint] is None:
216
+ g_param[OptionsDefine.Endpoint] = conf["cdwpg"][OptionsDefine.Endpoint]
217
+ except Exception as err:
218
+ raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
219
+
220
+ if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
221
+ raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
222
+
223
+ if g_param[OptionsDefine.Waiter]:
224
+ param = eval(g_param[OptionsDefine.Waiter])
225
+ if 'expr' not in param:
226
+ raise Exception('`expr` in `--waiter` must be defined')
227
+ if 'to' not in param:
228
+ raise Exception('`to` in `--waiter` must be defined')
229
+ if 'timeout' not in param:
230
+ if 'waiter' in conf and 'timeout' in conf['waiter']:
231
+ param['timeout'] = conf['waiter']['timeout']
232
+ else:
233
+ param['timeout'] = 180
234
+ if 'interval' not in param:
235
+ if 'waiter' in conf and 'interval' in conf['waiter']:
236
+ param['interval'] = conf['waiter']['interval']
237
+ else:
238
+ param['interval'] = 5
239
+ param['interval'] = min(param['interval'], param['timeout'])
240
+ g_param['OptionsDefine.WaiterInfo'] = param
241
+
242
+ if six.PY2:
243
+ for key, value in g_param.items():
244
+ if isinstance(value, six.text_type):
245
+ g_param[key] = value.encode('utf-8')
246
+ return g_param
247
+