tccli-intl-en 3.0.1262.1__py2.py3-none-any.whl → 3.0.1263.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.
tccli/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '3.0.1262.1'
1
+ __version__ = '3.0.1263.1'
@@ -289,6 +289,9 @@ SERVICE_VERSIONS = {
289
289
  "pts": [
290
290
  "2021-07-28"
291
291
  ],
292
+ "quota": [
293
+ "2024-12-04"
294
+ ],
292
295
  "rce": [
293
296
  "2020-11-03"
294
297
  ],
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from tccli.services.quota.quota_client import action_caller
4
+
@@ -0,0 +1,207 @@
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) 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.QuotaClient(cred, g_param[OptionsDefine.Region], profile)
47
+ client._sdkVersion += ("_CLI_" + __version__)
48
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
49
+ model = models.CreateAlarmRequest()
50
+ model.from_json_string(json.dumps(args))
51
+ start_time = time.time()
52
+ while True:
53
+ rsp = client.CreateAlarm(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
+ CLIENT_MAP = {
73
+ "v20241204": quota_client_v20241204,
74
+
75
+ }
76
+
77
+ MODELS_MAP = {
78
+ "v20241204": models_v20241204,
79
+
80
+ }
81
+
82
+ ACTION_MAP = {
83
+ "CreateAlarm": doCreateAlarm,
84
+
85
+ }
86
+
87
+ AVAILABLE_VERSION_LIST = [
88
+ "v20241204",
89
+
90
+ ]
91
+
92
+
93
+ def action_caller():
94
+ return ACTION_MAP
95
+
96
+
97
+ def parse_global_arg(parsed_globals):
98
+ g_param = parsed_globals
99
+ cvm_role_flag = True
100
+ for param in parsed_globals.keys():
101
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.RoleArn,
102
+ OptionsDefine.RoleSessionName]:
103
+ if parsed_globals[param] is not None:
104
+ cvm_role_flag = False
105
+ break
106
+ is_exist_profile = True
107
+ if not parsed_globals["profile"]:
108
+ is_exist_profile = False
109
+ g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
110
+
111
+ configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
112
+ is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
113
+ is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
114
+
115
+ conf = {}
116
+ cred = {}
117
+
118
+ if is_conf_exist:
119
+ conf = Utils.load_json_msg(conf_path)
120
+ if is_cred_exist:
121
+ cred = Utils.load_json_msg(cred_path)
122
+
123
+ if not (isinstance(conf, dict) and isinstance(cred, dict)):
124
+ raise ConfigurationError(
125
+ "file: %s or %s is not json format"
126
+ % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
127
+
128
+ if OptionsDefine.Token not in cred:
129
+ cred[OptionsDefine.Token] = None
130
+
131
+ if not is_exist_profile:
132
+ if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
133
+ cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
134
+ cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
135
+ cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
136
+ cvm_role_flag = False
137
+
138
+ if os.environ.get(OptionsDefine.ENV_REGION):
139
+ conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
140
+
141
+ if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
142
+ cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
143
+ cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
144
+ cvm_role_flag = False
145
+
146
+ if cvm_role_flag:
147
+ if "type" in cred and cred["type"] == "cvm-role":
148
+ g_param[OptionsDefine.UseCVMRole.replace('-', '_')] = True
149
+
150
+ for param in g_param.keys():
151
+ if g_param[param] is None:
152
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
153
+ if param in cred:
154
+ g_param[param] = cred[param]
155
+ elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
156
+ or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
157
+ raise ConfigurationError("%s is invalid" % param)
158
+ elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
159
+ if param in conf[OptionsDefine.SysParam]:
160
+ g_param[param] = conf[OptionsDefine.SysParam][param]
161
+ elif param != OptionsDefine.Language:
162
+ raise ConfigurationError("%s is invalid" % param)
163
+ elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
164
+ if param.replace('_', '-') in cred:
165
+ g_param[param] = cred[param.replace('_', '-')]
166
+
167
+ try:
168
+ if g_param[OptionsDefine.ServiceVersion]:
169
+ g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
170
+ else:
171
+ version = conf["quota"][OptionsDefine.Version]
172
+ g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
173
+
174
+ if g_param[OptionsDefine.Endpoint] is None:
175
+ g_param[OptionsDefine.Endpoint] = conf["quota"][OptionsDefine.Endpoint]
176
+ g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
177
+ except Exception as err:
178
+ raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
179
+
180
+ if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
181
+ raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
182
+
183
+ if g_param[OptionsDefine.Waiter]:
184
+ param = eval(g_param[OptionsDefine.Waiter])
185
+ if 'expr' not in param:
186
+ raise Exception('`expr` in `--waiter` must be defined')
187
+ if 'to' not in param:
188
+ raise Exception('`to` in `--waiter` must be defined')
189
+ if 'timeout' not in param:
190
+ if 'waiter' in conf and 'timeout' in conf['waiter']:
191
+ param['timeout'] = conf['waiter']['timeout']
192
+ else:
193
+ param['timeout'] = 180
194
+ if 'interval' not in param:
195
+ if 'waiter' in conf and 'interval' in conf['waiter']:
196
+ param['interval'] = conf['waiter']['interval']
197
+ else:
198
+ param['interval'] = 5
199
+ param['interval'] = min(param['interval'], param['timeout'])
200
+ g_param['OptionsDefine.WaiterInfo'] = param
201
+
202
+ if six.PY2:
203
+ for key, value in g_param.items():
204
+ if isinstance(value, six.text_type):
205
+ g_param[key] = value.encode('utf-8')
206
+ return g_param
207
+
@@ -0,0 +1,99 @@
1
+ {
2
+ "actions": {
3
+ "CreateAlarm": {
4
+ "document": "Add alarm rules",
5
+ "input": "CreateAlarmRequest",
6
+ "name": "Create Alarm Rule",
7
+ "output": "CreateAlarmResponse",
8
+ "status": "online"
9
+ }
10
+ },
11
+ "metadata": {
12
+ "apiVersion": "2024-12-04",
13
+ "serviceNameCN": "配额中心",
14
+ "serviceShortName": "quota"
15
+ },
16
+ "objects": {
17
+ "CreateAlarmRequest": {
18
+ "document": "CreateAlarm request structure.",
19
+ "members": [
20
+ {
21
+ "disabled": false,
22
+ "document": "Alarm rule name. specifies the name of the Alarm rule.",
23
+ "example": "监控告警",
24
+ "member": "string",
25
+ "name": "Name",
26
+ "required": true,
27
+ "type": "string"
28
+ },
29
+ {
30
+ "disabled": false,
31
+ "document": "Product ID.",
32
+ "example": "11",
33
+ "member": "int64",
34
+ "name": "ProductId",
35
+ "required": true,
36
+ "type": "int"
37
+ },
38
+ {
39
+ "disabled": false,
40
+ "document": "Quota ID.",
41
+ "example": "12",
42
+ "member": "int64",
43
+ "name": "QuotaId",
44
+ "required": true,
45
+ "type": "int"
46
+ },
47
+ {
48
+ "disabled": false,
49
+ "document": "Alert metrics 1: quota usage 2: quota usage rate 3: remaining quota 4: remaining quota rate.",
50
+ "example": "2",
51
+ "member": "int64",
52
+ "name": "Metrics",
53
+ "required": true,
54
+ "type": "int"
55
+ },
56
+ {
57
+ "disabled": false,
58
+ "document": "Specifies the Alarm threshold. value range: 0-100.",
59
+ "example": "50",
60
+ "member": "int64",
61
+ "name": "Threshold",
62
+ "required": true,
63
+ "type": "int"
64
+ },
65
+ {
66
+ "disabled": false,
67
+ "document": "Alarm frequency.",
68
+ "example": "2",
69
+ "member": "int64",
70
+ "name": "Frequency",
71
+ "required": true,
72
+ "type": "int"
73
+ },
74
+ {
75
+ "disabled": false,
76
+ "document": " Member UIN",
77
+ "example": "2342",
78
+ "member": "int64",
79
+ "name": "MemberUin",
80
+ "required": false,
81
+ "type": "int"
82
+ }
83
+ ],
84
+ "type": "object"
85
+ },
86
+ "CreateAlarmResponse": {
87
+ "document": "CreateAlarm response structure.",
88
+ "members": [
89
+ {
90
+ "document": "The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.",
91
+ "member": "string",
92
+ "name": "RequestId",
93
+ "type": "string"
94
+ }
95
+ ],
96
+ "type": "object"
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "actions": {
3
+ "CreateAlarm": [
4
+ {
5
+ "document": "",
6
+ "input": "POST / HTTP/1.1\nHost: quota.tencentcloudapi.com\nContent-Type: application/json\nX-TC-Action: CreateAlarm\n<Common request parameters>\n\n{\n \"Name\": \"Quota 2\",\n \"ProductId\": 2,\n \"QuotaId\": 3,\n \"Metrics\": 1,\n \"Threshold\": 1,\n \"Frequency\": 1\n}",
7
+ "output": "{\n \"Response\": {\n \"RequestId\": \"1c5d13bd-070e-4eb8-90c2-4a01dc1b2c54\"\n }\n}",
8
+ "title": "Creat Quota"
9
+ }
10
+ ]
11
+ }
12
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tccli-intl-en
3
- Version: 3.0.1262.1
3
+ Version: 3.0.1263.1
4
4
  Summary: Universal Command Line Environment for Tencent Cloud
5
5
  Home-page: https://github.com/TencentCloud/tencentcloud-cli-intl-en.git
6
6
  Author: Tencent Cloud
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.4
22
22
  Classifier: Programming Language :: Python :: 3.5
23
23
  Classifier: Programming Language :: Python :: 3.6
24
24
  License-File: LICENSE
25
- Requires-Dist: tencentcloud-sdk-python-intl-en (>=3.0.1262)
25
+ Requires-Dist: tencentcloud-sdk-python-intl-en (>=3.0.1263)
26
26
  Requires-Dist: jmespath (==0.10.0)
27
27
  Requires-Dist: six (==1.16.0)
28
28
 
@@ -1,4 +1,4 @@
1
- tccli/__init__.py,sha256=BKWyMzlMFgbySZT4oV5Y-4p9BPyTwklwx7Dt4qCi3Ng,28
1
+ tccli/__init__.py,sha256=D65a5cNaouXr0-CPzni5EWOpDVAYFk6wenhA0cZLUtY,28
2
2
  tccli/argparser.py,sha256=WtfpBhj2R6JHSzagy6w6Q4y3YVmyIC_yK80w3tqBPgU,5589
3
3
  tccli/argument.py,sha256=ZtVo3AySpzM-Hw6_hPdU27FjUsc8QPB2fIuLy7JSBAk,8091
4
4
  tccli/base_command.py,sha256=rFWNAwfS0GA6LLGNOM-iPI0RV81Jag5cZn536ZQN0pw,2859
@@ -49,7 +49,7 @@ tccli/plugins/sso/terminal.py,sha256=niX5xr6avR32NDIWGrXjuhJ-Y9OiBWW45RmxWxwXT6I
49
49
  tccli/plugins/sso/texts.py,sha256=N5bt3WXMk9oKWHFsuIG7jVVejdUi5Mzi8wsrhWX3t1s,2234
50
50
  tccli/plugins/test/__init__.py,sha256=ed14rjeb4-Sf_uttli4x3gRl27FT2-NHPtQxRcdwE3o,2712
51
51
  tccli/plugins/test/add.py,sha256=L8EcHizXbEb8NiH1C-Giu9RPHRxe9rxGBDziaaFa1LE,1016
52
- tccli/services/__init__.py,sha256=e8AISNMLt7aOYxAwsSQ6_PNTXH9v4AfBIzY5rtbR8r8,6306
52
+ tccli/services/__init__.py,sha256=KtR0PWILyIwQMEQamkfbIUeUUQkkDensHuS9yBUSBtI,6349
53
53
  tccli/services/advisor/__init__.py,sha256=94YMESuc98jtnMMx_zO-vxCDjIdVjLy_KTCcG7nvOVo,93
54
54
  tccli/services/advisor/advisor_client.py,sha256=P1Zc-T2sJfOiBwH7ynDirSEgm7pcPQK8fPkH8GFibMk,12366
55
55
  tccli/services/advisor/v20200721/api.json,sha256=WrgEe_7e5-wVC7N4iftxYIMkrwdDL8EmIQli8sMryGo,15295
@@ -410,6 +410,10 @@ tccli/services/pts/__init__.py,sha256=J0iwcjb1pfQr8JhxLeQ_n2JUhbIET_8hfW-6g-RrVl
410
410
  tccli/services/pts/pts_client.py,sha256=4yW8yLLg3aZ9ozcrJ9Hras8c8tQ_-HEiK4Dq7Si7it8,153992
411
411
  tccli/services/pts/v20210728/api.json,sha256=jMxT4d6OYwrAcOlxTtGTuoCK4F8bBS8_qZ6X6lFHJTU,250027
412
412
  tccli/services/pts/v20210728/examples.json,sha256=e33IuZ07ORwDgYUkhmhY3uIfZ-fUH05ff9Jzs4suKm0,90839
413
+ tccli/services/quota/__init__.py,sha256=AOKYvT89EKCoKMkMZLrU4cP8XILPg9KUGyTnc8vrwvI,89
414
+ tccli/services/quota/quota_client.py,sha256=VxplXK537GTQ1OYfSHGoypYymo_-iEavTZ8y95xGFyo,9189
415
+ tccli/services/quota/v20241204/api.json,sha256=NXNsvUug_F95XhlzD7NDG0AQft_V5Qpf3OLxEd398Tc,2760
416
+ tccli/services/quota/v20241204/examples.json,sha256=r1_QGqgtbIuE65A-oTIaj4ojH7JUvrV6hQrUsuJo-C0,541
413
417
  tccli/services/rce/__init__.py,sha256=hA0_efK_b48bYi70kHNZugvJchdDwQNHYJofWYNzyKo,85
414
418
  tccli/services/rce/rce_client.py,sha256=X0to7tDeJRzidLOYKi_qUk64BsNlZMzWmFN9ImXIhTE,9228
415
419
  tccli/services/rce/v20201103/api.json,sha256=sS510FJf3S198XvERTmlN8JnOX244IHy4gQnaghzui8,7026
@@ -582,9 +586,9 @@ tccli/services/yunjing/__init__.py,sha256=8HTKN8_ow1j67tspqAbBMQgeteXAagLvtb9WAf
582
586
  tccli/services/yunjing/yunjing_client.py,sha256=Vh5vFOLjDJ53q_RX9WADwLT610kGcUxwCmtny95k3js,226485
583
587
  tccli/services/yunjing/v20180228/api.json,sha256=zYojacZyPgPCi71CLBjuHsQR9mIxcZjCX5JwA9TYr1s,173428
584
588
  tccli/services/yunjing/v20180228/examples.json,sha256=j3GL3TtNTkZpNLlksz0nJNCVDxYGUqfRqOt94Y-P8OE,58723
585
- tccli_intl_en-3.0.1262.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
586
- tccli_intl_en-3.0.1262.1.dist-info/METADATA,sha256=aGydkzZg-fjVGD4ynVhqVKEcoXdM_wEwx0-z0TtgZbI,3092
587
- tccli_intl_en-3.0.1262.1.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
588
- tccli_intl_en-3.0.1262.1.dist-info/entry_points.txt,sha256=68P7ZjqXFm4zPWf5RsAVabzbECUWYFB2VyUnnv8XgMI,86
589
- tccli_intl_en-3.0.1262.1.dist-info/top_level.txt,sha256=gYFrQRE3IqZ_46Syp-vkVwwvNaYEtKcM4fE_C4Puomk,6
590
- tccli_intl_en-3.0.1262.1.dist-info/RECORD,,
589
+ tccli_intl_en-3.0.1263.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
590
+ tccli_intl_en-3.0.1263.1.dist-info/METADATA,sha256=G4wTj67_th4V8tVlma0ENVdtZ0o9I8Z4vN66N6dWg0s,3092
591
+ tccli_intl_en-3.0.1263.1.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
592
+ tccli_intl_en-3.0.1263.1.dist-info/entry_points.txt,sha256=68P7ZjqXFm4zPWf5RsAVabzbECUWYFB2VyUnnv8XgMI,86
593
+ tccli_intl_en-3.0.1263.1.dist-info/top_level.txt,sha256=gYFrQRE3IqZ_46Syp-vkVwwvNaYEtKcM4fE_C4Puomk,6
594
+ tccli_intl_en-3.0.1263.1.dist-info/RECORD,,