tccli-intl-en 3.0.1258.1__py2.py3-none-any.whl → 3.0.1283.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 (197) hide show
  1. tccli/__init__.py +1 -1
  2. tccli/argument.py +1 -1
  3. tccli/services/__init__.py +14 -1
  4. tccli/services/advisor/advisor_client.py +10 -4
  5. tccli/services/aiart/aiart_client.py +5 -2
  6. tccli/services/ams/ams_client.py +20 -8
  7. tccli/services/antiddos/antiddos_client.py +350 -140
  8. tccli/services/apigateway/apigateway_client.py +465 -186
  9. tccli/services/apm/apm_client.py +835 -68
  10. tccli/services/apm/v20210622/api.json +3936 -1145
  11. tccli/services/apm/v20210622/examples.json +133 -23
  12. tccli/services/asr/asr_client.py +10 -4
  13. tccli/services/autoscaling/autoscaling_client.py +290 -116
  14. tccli/services/autoscaling/v20180419/api.json +1 -1
  15. tccli/services/batch/batch_client.py +140 -56
  16. tccli/services/bi/bi_client.py +120 -48
  17. tccli/services/billing/billing_client.py +210 -84
  18. tccli/services/cam/cam_client.py +405 -162
  19. tccli/services/captcha/captcha_client.py +5 -2
  20. tccli/services/car/car_client.py +165 -66
  21. tccli/services/cbs/cbs_client.py +190 -76
  22. tccli/services/ccc/ccc_client.py +515 -146
  23. tccli/services/ccc/v20200210/api.json +511 -27
  24. tccli/services/ccc/v20200210/examples.json +24 -0
  25. tccli/services/cdb/cdb_client.py +665 -266
  26. tccli/services/cdc/cdc_client.py +100 -40
  27. tccli/services/cdn/cdn_client.py +220 -88
  28. tccli/services/cdwdoris/cdwdoris_client.py +385 -154
  29. tccli/services/cdwpg/cdwpg_client.py +120 -48
  30. tccli/services/cdz/__init__.py +4 -0
  31. tccli/services/cdz/cdz_client.py +210 -0
  32. tccli/services/cdz/v20221123/api.json +233 -0
  33. tccli/services/cdz/v20221123/examples.json +12 -0
  34. tccli/services/cfg/cfg_client.py +80 -32
  35. tccli/services/cfs/cfs_client.py +195 -78
  36. tccli/services/cfw/cfw_client.py +330 -132
  37. tccli/services/chdfs/chdfs_client.py +145 -58
  38. tccli/services/ciam/ciam_client.py +80 -32
  39. tccli/services/ckafka/ckafka_client.py +629 -131
  40. tccli/services/ckafka/v20190819/api.json +2749 -1470
  41. tccli/services/ckafka/v20190819/examples.json +209 -155
  42. tccli/services/clb/clb_client.py +415 -166
  43. tccli/services/clb/v20180317/api.json +29 -14
  44. tccli/services/cloudaudit/cloudaudit_client.py +90 -36
  45. tccli/services/cls/cls_client.py +434 -173
  46. tccli/services/cmq/cmq_client.py +10 -4
  47. tccli/services/config/config_client.py +30 -12
  48. tccli/services/controlcenter/controlcenter_client.py +5 -2
  49. tccli/services/csip/csip_client.py +170 -68
  50. tccli/services/ctsdb/ctsdb_client.py +10 -4
  51. tccli/services/cvm/cvm_client.py +572 -214
  52. tccli/services/cvm/v20170312/api.json +371 -133
  53. tccli/services/cvm/v20170312/examples.json +123 -101
  54. tccli/services/cwp/cwp_client.py +2325 -930
  55. tccli/services/cynosdb/cynosdb_client.py +1887 -577
  56. tccli/services/cynosdb/v20190107/api.json +11763 -7697
  57. tccli/services/cynosdb/v20190107/examples.json +132 -4
  58. tccli/services/dataintegration/dataintegration_client.py +5 -2
  59. tccli/services/dayu/dayu_client.py +515 -206
  60. tccli/services/dbbrain/dbbrain_client.py +210 -84
  61. tccli/services/dc/dc_client.py +90 -36
  62. tccli/services/dcdb/dcdb_client.py +310 -124
  63. tccli/services/dlc/dlc_client.py +859 -214
  64. tccli/services/dlc/v20210125/api.json +637 -13
  65. tccli/services/dlc/v20210125/examples.json +48 -0
  66. tccli/services/dms/dms_client.py +10 -4
  67. tccli/services/dnspod/dnspod_client.py +302 -76
  68. tccli/services/dnspod/v20210323/api.json +153 -0
  69. tccli/services/dnspod/v20210323/examples.json +16 -0
  70. tccli/services/domain/domain_client.py +120 -48
  71. tccli/services/dts/dts_client.py +415 -166
  72. tccli/services/eb/eb_client.py +130 -52
  73. tccli/services/ecdn/ecdn_client.py +75 -30
  74. tccli/services/ecm/ecm_client.py +620 -248
  75. tccli/services/eiam/eiam_client.py +200 -80
  76. tccli/services/emr/emr_client.py +385 -154
  77. tccli/services/es/es_client.py +105 -42
  78. tccli/services/facefusion/facefusion_client.py +15 -6
  79. tccli/services/faceid/faceid_client.py +95 -38
  80. tccli/services/faceid/v20180301/api.json +16 -7
  81. tccli/services/faceid/v20180301/examples.json +2 -2
  82. tccli/services/gaap/gaap_client.py +440 -176
  83. tccli/services/gme/gme_client.py +50 -20
  84. tccli/services/gpm/gpm_client.py +90 -36
  85. tccli/services/gse/gse_client.py +110 -44
  86. tccli/services/gwlb/gwlb_client.py +90 -36
  87. tccli/services/iai/iai_client.py +145 -58
  88. tccli/services/iap/iap_client.py +30 -12
  89. tccli/services/ims/ims_client.py +5 -2
  90. tccli/services/intlpartnersmgt/intlpartnersmgt_client.py +210 -84
  91. tccli/services/iotcloud/iotcloud_client.py +100 -40
  92. tccli/services/ip/ip_client.py +30 -12
  93. tccli/services/kms/kms_client.py +340 -136
  94. tccli/services/lcic/lcic_client.py +265 -106
  95. tccli/services/lighthouse/lighthouse_client.py +370 -148
  96. tccli/services/live/live_client.py +600 -240
  97. tccli/services/lke/lke_client.py +450 -180
  98. tccli/services/lkeap/lkeap_client.py +142 -12
  99. tccli/services/lkeap/v20240522/api.json +263 -0
  100. tccli/services/lkeap/v20240522/examples.json +35 -1
  101. tccli/services/mariadb/mariadb_client.py +250 -100
  102. tccli/services/mdc/mdc_client.py +90 -36
  103. tccli/services/mdl/mdl_client.py +165 -66
  104. tccli/services/mdl/v20200326/api.json +186 -12
  105. tccli/services/mdl/v20200326/examples.json +16 -16
  106. tccli/services/mdp/mdp_client.py +416 -124
  107. tccli/services/mdp/v20200527/api.json +146 -14
  108. tccli/services/mdp/v20200527/examples.json +95 -79
  109. tccli/services/message/__init__.py +4 -0
  110. tccli/services/message/message_client.py +210 -0
  111. tccli/services/message/v20181225/api.json +72 -0
  112. tccli/services/message/v20181225/examples.json +13 -0
  113. tccli/services/mongodb/mongodb_client.py +369 -58
  114. tccli/services/mongodb/v20190725/api.json +811 -226
  115. tccli/services/mongodb/v20190725/examples.json +54 -22
  116. tccli/services/monitor/monitor_client.py +1008 -296
  117. tccli/services/monitor/v20180724/api.json +657 -8
  118. tccli/services/monitor/v20180724/examples.json +152 -4
  119. tccli/services/mps/mps_client.py +684 -184
  120. tccli/services/mps/v20190612/api.json +2719 -375
  121. tccli/services/mps/v20190612/examples.json +63 -13
  122. tccli/services/msp/msp_client.py +35 -14
  123. tccli/services/ocr/ocr_client.py +246 -76
  124. tccli/services/ocr/v20181119/api.json +83 -4
  125. tccli/services/ocr/v20181119/examples.json +8 -0
  126. tccli/services/omics/omics_client.py +100 -40
  127. tccli/services/organization/organization_client.py +580 -232
  128. tccli/services/postgres/postgres_client.py +455 -182
  129. tccli/services/privatedns/privatedns_client.py +155 -62
  130. tccli/services/pts/pts_client.py +240 -96
  131. tccli/services/quota/__init__.py +4 -0
  132. tccli/services/quota/quota_client.py +434 -0
  133. tccli/services/quota/v20241204/api.json +548 -0
  134. tccli/services/quota/v20241204/examples.json +51 -0
  135. tccli/services/rce/rce_client.py +5 -2
  136. tccli/services/redis/redis_client.py +545 -218
  137. tccli/services/redis/v20180412/api.json +225 -113
  138. tccli/services/redis/v20180412/examples.json +19 -19
  139. tccli/services/region/region_client.py +15 -6
  140. tccli/services/rum/rum_client.py +300 -120
  141. tccli/services/scf/scf_client.py +210 -84
  142. tccli/services/ses/ses_client.py +145 -58
  143. tccli/services/sms/sms_client.py +90 -36
  144. tccli/services/sqlserver/sqlserver_client.py +695 -278
  145. tccli/services/ssl/ssl_client.py +190 -76
  146. tccli/services/ssm/ssm_client.py +120 -48
  147. tccli/services/sts/sts_client.py +25 -10
  148. tccli/services/tag/tag_client.py +150 -60
  149. tccli/services/tat/tat_client.py +95 -38
  150. tccli/services/tbaas/tbaas_client.py +20 -8
  151. tccli/services/tcaplusdb/tcaplusdb_client.py +260 -104
  152. tccli/services/tcaplusdb/v20190823/api.json +836 -760
  153. tccli/services/tcaplusdb/v20190823/examples.json +3 -3
  154. tccli/services/tchd/tchd_client.py +5 -2
  155. tccli/services/tcmpp/tcmpp_client.py +520 -208
  156. tccli/services/tcr/tcr_client.py +380 -152
  157. tccli/services/tcsas/tcsas_client.py +295 -118
  158. tccli/services/tcsas/v20250106/api.json +101 -61
  159. tccli/services/tcsas/v20250106/examples.json +2 -2
  160. tccli/services/tcss/tcss_client.py +1650 -660
  161. tccli/services/tdid/tdid_client.py +240 -96
  162. tccli/services/tdmq/tdmq_client.py +470 -188
  163. tccli/services/tem/tem_client.py +280 -112
  164. tccli/services/teo/teo_client.py +1365 -483
  165. tccli/services/teo/v20220901/api.json +361 -46
  166. tccli/services/teo/v20220901/examples.json +24 -0
  167. tccli/services/tione/__init__.py +4 -0
  168. tccli/services/tione/tione_client.py +210 -0
  169. tccli/services/tione/v20211111/api.json +3074 -0
  170. tccli/services/tione/v20211111/examples.json +12 -0
  171. tccli/services/tiw/tiw_client.py +255 -102
  172. tccli/services/tke/tke_client.py +690 -276
  173. tccli/services/tms/tms_client.py +5 -2
  174. tccli/services/tmt/tmt_client.py +5 -2
  175. tccli/services/trabbit/trabbit_client.py +145 -58
  176. tccli/services/trro/trro_client.py +95 -38
  177. tccli/services/trtc/trtc_client.py +255 -102
  178. tccli/services/trtc/v20190722/api.json +120 -16
  179. tccli/services/trtc/v20190722/examples.json +7 -7
  180. tccli/services/tts/tts_client.py +5 -2
  181. tccli/services/vclm/vclm_client.py +10 -4
  182. tccli/services/vm/vm_client.py +20 -8
  183. tccli/services/vod/vod_client.py +895 -358
  184. tccli/services/vpc/v20170312/api.json +970 -75
  185. tccli/services/vpc/v20170312/examples.json +106 -10
  186. tccli/services/vpc/vpc_client.py +2159 -644
  187. tccli/services/waf/waf_client.py +535 -214
  188. tccli/services/wedata/v20250806/api.json +13644 -0
  189. tccli/services/wedata/v20250806/examples.json +621 -0
  190. tccli/services/wedata/wedata_client.py +6067 -1263
  191. tccli/services/yunjing/yunjing_client.py +355 -142
  192. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/METADATA +4 -7
  193. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/RECORD +197 -179
  194. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/WHEEL +1 -1
  195. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/entry_points.txt +0 -1
  196. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/LICENSE +0 -0
  197. {tccli_intl_en-3.0.1258.1.dist-info → tccli_intl_en-3.0.1283.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from tccli.services.quota.quota_client import action_caller
4
+
@@ -0,0 +1,434 @@
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.quota.v20241204 import quota_client as quota_client_v20241204
15
+ from tencentcloud.quota.v20241204 import models as models_v20241204
16
+
17
+ from jmespath import search
18
+ import time
19
+
20
+ def doCreateAlarm(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) \
31
+ and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) \
32
+ and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) \
33
+ and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
34
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
35
+ else:
36
+ cred = credential.Credential(
37
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
38
+ )
39
+ http_profile = HttpProfile(
40
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
41
+ reqMethod="POST",
42
+ endpoint=g_param[OptionsDefine.Endpoint],
43
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
44
+ )
45
+ profile = ClientProfile(httpProfile=http_profile, signMethod="TC3-HMAC-SHA256")
46
+ if g_param[OptionsDefine.Language]:
47
+ profile.language = g_param[OptionsDefine.Language]
48
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
49
+ client = mod.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
50
+ client._sdkVersion += ("_CLI_" + __version__)
51
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
52
+ model = models.CreateAlarmRequest()
53
+ model.from_json_string(json.dumps(args))
54
+ start_time = time.time()
55
+ while True:
56
+ rsp = client.CreateAlarm(model)
57
+ result = rsp.to_json_string()
58
+ try:
59
+ json_obj = json.loads(result)
60
+ except TypeError as e:
61
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
62
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
63
+ break
64
+ cur_time = time.time()
65
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
66
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
67
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
68
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
69
+ else:
70
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
71
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
72
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
73
+
74
+
75
+ def doUpdateAlarm(args, parsed_globals):
76
+ g_param = parse_global_arg(parsed_globals)
77
+
78
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
79
+ cred = credential.CVMRoleCredential()
80
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
81
+ cred = credential.STSAssumeRoleCredential(
82
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
83
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
84
+ )
85
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) \
86
+ and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) \
87
+ and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) \
88
+ and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
89
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
90
+ else:
91
+ cred = credential.Credential(
92
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
93
+ )
94
+ http_profile = HttpProfile(
95
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
96
+ reqMethod="POST",
97
+ endpoint=g_param[OptionsDefine.Endpoint],
98
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
99
+ )
100
+ profile = ClientProfile(httpProfile=http_profile, signMethod="TC3-HMAC-SHA256")
101
+ if g_param[OptionsDefine.Language]:
102
+ profile.language = g_param[OptionsDefine.Language]
103
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
104
+ client = mod.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
105
+ client._sdkVersion += ("_CLI_" + __version__)
106
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
107
+ model = models.UpdateAlarmRequest()
108
+ model.from_json_string(json.dumps(args))
109
+ start_time = time.time()
110
+ while True:
111
+ rsp = client.UpdateAlarm(model)
112
+ result = rsp.to_json_string()
113
+ try:
114
+ json_obj = json.loads(result)
115
+ except TypeError as e:
116
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
117
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
118
+ break
119
+ cur_time = time.time()
120
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
121
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
122
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
123
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
124
+ else:
125
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
126
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
127
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
128
+
129
+
130
+ def doDeleteAlarm(args, parsed_globals):
131
+ g_param = parse_global_arg(parsed_globals)
132
+
133
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
134
+ cred = credential.CVMRoleCredential()
135
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
136
+ cred = credential.STSAssumeRoleCredential(
137
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
138
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
139
+ )
140
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) \
141
+ and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) \
142
+ and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) \
143
+ and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
144
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
145
+ else:
146
+ cred = credential.Credential(
147
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
148
+ )
149
+ http_profile = HttpProfile(
150
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
151
+ reqMethod="POST",
152
+ endpoint=g_param[OptionsDefine.Endpoint],
153
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
154
+ )
155
+ profile = ClientProfile(httpProfile=http_profile, signMethod="TC3-HMAC-SHA256")
156
+ if g_param[OptionsDefine.Language]:
157
+ profile.language = g_param[OptionsDefine.Language]
158
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
159
+ client = mod.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
160
+ client._sdkVersion += ("_CLI_" + __version__)
161
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
162
+ model = models.DeleteAlarmRequest()
163
+ model.from_json_string(json.dumps(args))
164
+ start_time = time.time()
165
+ while True:
166
+ rsp = client.DeleteAlarm(model)
167
+ result = rsp.to_json_string()
168
+ try:
169
+ json_obj = json.loads(result)
170
+ except TypeError as e:
171
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
172
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
173
+ break
174
+ cur_time = time.time()
175
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
176
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
177
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
178
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
179
+ else:
180
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
181
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
182
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
183
+
184
+
185
+ def doDescribeAlarms(args, parsed_globals):
186
+ g_param = parse_global_arg(parsed_globals)
187
+
188
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
189
+ cred = credential.CVMRoleCredential()
190
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
191
+ cred = credential.STSAssumeRoleCredential(
192
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
193
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
194
+ )
195
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) \
196
+ and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) \
197
+ and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) \
198
+ and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
199
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
200
+ else:
201
+ cred = credential.Credential(
202
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
203
+ )
204
+ http_profile = HttpProfile(
205
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
206
+ reqMethod="POST",
207
+ endpoint=g_param[OptionsDefine.Endpoint],
208
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
209
+ )
210
+ profile = ClientProfile(httpProfile=http_profile, signMethod="TC3-HMAC-SHA256")
211
+ if g_param[OptionsDefine.Language]:
212
+ profile.language = g_param[OptionsDefine.Language]
213
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
214
+ client = mod.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
215
+ client._sdkVersion += ("_CLI_" + __version__)
216
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
217
+ model = models.DescribeAlarmsRequest()
218
+ model.from_json_string(json.dumps(args))
219
+ start_time = time.time()
220
+ while True:
221
+ rsp = client.DescribeAlarms(model)
222
+ result = rsp.to_json_string()
223
+ try:
224
+ json_obj = json.loads(result)
225
+ except TypeError as e:
226
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
227
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
228
+ break
229
+ cur_time = time.time()
230
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
231
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
232
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
233
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
234
+ else:
235
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
236
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
237
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
238
+
239
+
240
+ def doEnableAlarm(args, parsed_globals):
241
+ g_param = parse_global_arg(parsed_globals)
242
+
243
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
244
+ cred = credential.CVMRoleCredential()
245
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
246
+ cred = credential.STSAssumeRoleCredential(
247
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
248
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
249
+ )
250
+ elif os.getenv(OptionsDefine.ENV_TKE_REGION) \
251
+ and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) \
252
+ and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) \
253
+ and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
254
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
255
+ else:
256
+ cred = credential.Credential(
257
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
258
+ )
259
+ http_profile = HttpProfile(
260
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
261
+ reqMethod="POST",
262
+ endpoint=g_param[OptionsDefine.Endpoint],
263
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
264
+ )
265
+ profile = ClientProfile(httpProfile=http_profile, signMethod="TC3-HMAC-SHA256")
266
+ if g_param[OptionsDefine.Language]:
267
+ profile.language = g_param[OptionsDefine.Language]
268
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
269
+ client = mod.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
270
+ client._sdkVersion += ("_CLI_" + __version__)
271
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
272
+ model = models.EnableAlarmRequest()
273
+ model.from_json_string(json.dumps(args))
274
+ start_time = time.time()
275
+ while True:
276
+ rsp = client.EnableAlarm(model)
277
+ result = rsp.to_json_string()
278
+ try:
279
+ json_obj = json.loads(result)
280
+ except TypeError as e:
281
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
282
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
283
+ break
284
+ cur_time = time.time()
285
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
286
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
287
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
288
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
289
+ else:
290
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
291
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
292
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
293
+
294
+
295
+ CLIENT_MAP = {
296
+ "v20241204": quota_client_v20241204,
297
+
298
+ }
299
+
300
+ MODELS_MAP = {
301
+ "v20241204": models_v20241204,
302
+
303
+ }
304
+
305
+ ACTION_MAP = {
306
+ "CreateAlarm": doCreateAlarm,
307
+ "UpdateAlarm": doUpdateAlarm,
308
+ "DeleteAlarm": doDeleteAlarm,
309
+ "DescribeAlarms": doDescribeAlarms,
310
+ "EnableAlarm": doEnableAlarm,
311
+
312
+ }
313
+
314
+ AVAILABLE_VERSION_LIST = [
315
+ "v20241204",
316
+
317
+ ]
318
+
319
+
320
+ def action_caller():
321
+ return ACTION_MAP
322
+
323
+
324
+ def parse_global_arg(parsed_globals):
325
+ g_param = parsed_globals
326
+ cvm_role_flag = True
327
+ for param in parsed_globals.keys():
328
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.RoleArn,
329
+ OptionsDefine.RoleSessionName]:
330
+ if parsed_globals[param] is not None:
331
+ cvm_role_flag = False
332
+ break
333
+ is_exist_profile = True
334
+ if not parsed_globals["profile"]:
335
+ is_exist_profile = False
336
+ g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
337
+
338
+ configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
339
+ is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
340
+ is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
341
+
342
+ conf = {}
343
+ cred = {}
344
+
345
+ if is_conf_exist:
346
+ conf = Utils.load_json_msg(conf_path)
347
+ if is_cred_exist:
348
+ cred = Utils.load_json_msg(cred_path)
349
+
350
+ if not (isinstance(conf, dict) and isinstance(cred, dict)):
351
+ raise ConfigurationError(
352
+ "file: %s or %s is not json format"
353
+ % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
354
+
355
+ if OptionsDefine.Token not in cred:
356
+ cred[OptionsDefine.Token] = None
357
+
358
+ if not is_exist_profile:
359
+ if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
360
+ cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
361
+ cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
362
+ cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
363
+ cvm_role_flag = False
364
+
365
+ if os.environ.get(OptionsDefine.ENV_REGION):
366
+ conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
367
+
368
+ if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
369
+ cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
370
+ cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
371
+ cvm_role_flag = False
372
+
373
+ if cvm_role_flag:
374
+ if "type" in cred and cred["type"] == "cvm-role":
375
+ g_param[OptionsDefine.UseCVMRole.replace('-', '_')] = True
376
+
377
+ for param in g_param.keys():
378
+ if g_param[param] is None:
379
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
380
+ if param in cred:
381
+ g_param[param] = cred[param]
382
+ elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
383
+ or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
384
+ raise ConfigurationError("%s is invalid" % param)
385
+ elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
386
+ if param in conf[OptionsDefine.SysParam]:
387
+ g_param[param] = conf[OptionsDefine.SysParam][param]
388
+ elif param != OptionsDefine.Language:
389
+ raise ConfigurationError("%s is invalid" % param)
390
+ elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
391
+ if param.replace('_', '-') in cred:
392
+ g_param[param] = cred[param.replace('_', '-')]
393
+
394
+ try:
395
+ if g_param[OptionsDefine.ServiceVersion]:
396
+ g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
397
+ else:
398
+ version = conf["quota"][OptionsDefine.Version]
399
+ g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
400
+
401
+ if g_param[OptionsDefine.Endpoint] is None:
402
+ g_param[OptionsDefine.Endpoint] = conf["quota"][OptionsDefine.Endpoint]
403
+ g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
404
+ except Exception as err:
405
+ raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
406
+
407
+ if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
408
+ raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
409
+
410
+ if g_param[OptionsDefine.Waiter]:
411
+ param = eval(g_param[OptionsDefine.Waiter])
412
+ if 'expr' not in param:
413
+ raise Exception('`expr` in `--waiter` must be defined')
414
+ if 'to' not in param:
415
+ raise Exception('`to` in `--waiter` must be defined')
416
+ if 'timeout' not in param:
417
+ if 'waiter' in conf and 'timeout' in conf['waiter']:
418
+ param['timeout'] = conf['waiter']['timeout']
419
+ else:
420
+ param['timeout'] = 180
421
+ if 'interval' not in param:
422
+ if 'waiter' in conf and 'interval' in conf['waiter']:
423
+ param['interval'] = conf['waiter']['interval']
424
+ else:
425
+ param['interval'] = 5
426
+ param['interval'] = min(param['interval'], param['timeout'])
427
+ g_param['OptionsDefine.WaiterInfo'] = param
428
+
429
+ if six.PY2:
430
+ for key, value in g_param.items():
431
+ if isinstance(value, six.text_type):
432
+ g_param[key] = value.encode('utf-8')
433
+ return g_param
434
+