tccli-intl-en 3.0.1262.1__py2.py3-none-any.whl → 3.0.1264.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.1264.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
  ],
@@ -407,7 +407,7 @@
407
407
  },
408
408
  {
409
409
  "disabled": false,
410
- "document": "Card Types Supported for Authentication: Currently supported types are as follows:\n1.HK (Default): Hong Kong (China) Identity Card\n2.ML: Malaysia Identity Card\n3.IndonesiaIDCard: Indonesia Identity Card\n4.PhilippinesVoteID: Philippines Voter ID\n5.PhilippinesDrivingLicense: Philippines Driving License\n6.PhilippinesTinID: Philippines Tin ID\n7.PhilippinesSSSID: Philippines SSS ID\n8.PhilippinesUMID: Philippines UMID\n9.MLIDPassport: Passports of Hong Kong, Macao, Taiwan Regions (China) and Foreign Countries\n10.ThailandIDCard: Thailand Identity Card\n11.MainlandIDCard: Mainland China Identity Card\n12.SingaporeIDCard: Singapore Identity Card\n13.HMTPermit: Exit-Entry Permit for Travel to and from Hong Kong, Macao and Taiwan (China)",
410
+ "document": "Specifies the identity document type used for authentication. valid values:. \n\nHK (default): hong kong (china) identity card.\n2. ML: malaysian identity card.\nIndonesian identity card.\n4. PhilippinesVoteID: specifies the voter card in the philippines.\n5. PhilippinesDrivingLicense: specifies the driving license in philippines.\n6. PhilippinesTinID: specifies the philippines tin id.\n7. PhilippinesSSSID: specifies the SSSID in the philippines.\n8. philippines UMID: specifies the philippines UMID.\n9. MLIDPassport: specifies the passport for hong kong (china), macao (china), and taiwan (china) as well as overseas passports.\nThailandIDCard: specifies the thai identity card.\nMainland id card.\n12. SingaporeIDCard: specifies the Singapore id card.\n13. HMTPermit: specifies the hong kong, macau and taiwan travel permit.",
411
411
  "example": "HK",
412
412
  "member": "string",
413
413
  "name": "IdCardType",
@@ -450,6 +450,15 @@
450
450
  "required": false,
451
451
  "type": "bool"
452
452
  },
453
+ {
454
+ "disabled": false,
455
+ "document": "Customize which alarm codes to block. If left blank, all alarm codes will be blocked by default.\nOptional alarm codes are: -9101 (occlusion or incomplete border), -9102 (photocopying), -9103 (screen capture by camera), -9104 (image editing/PS modification), -9107 (glare/reflection), -9108 (blurriness), -9901 (other alarms).",
456
+ "example": "[-9101]",
457
+ "member": "int64",
458
+ "name": "SelectedWarningCodes",
459
+ "required": false,
460
+ "type": "list"
461
+ },
453
462
  {
454
463
  "disabled": false,
455
464
  "document": "A passthrough field, which is returned together with the verification result and can contain up to 1,024 bits.",
@@ -461,7 +470,7 @@
461
470
  },
462
471
  {
463
472
  "disabled": false,
464
- "document": "ENHANCED: Enhanced Version, BASIC: Basic Version (Default)",
473
+ "document": "ENHANCED: enhanced.\nBASIC: basic version (default).",
465
474
  "example": "ENHANCED",
466
475
  "member": "string",
467
476
  "name": "SdkVersion",
@@ -485,7 +494,7 @@
485
494
  "members": [
486
495
  {
487
496
  "disabled": false,
488
- "document": "The token used to identify an SDK-based verification process. It is valid for 7,200s and can be used to get the verification result after the process is completed.",
497
+ "document": "A token that identifies an SDK verification process. the validity time is 10 minutes. after the process is complete, the token can be used to retrieve the verification result.",
489
498
  "example": "A561B769-C347-4724-A69A-6C3B3483E107",
490
499
  "member": "string",
491
500
  "name": "SdkToken",
@@ -21396,6 +21396,15 @@
21396
21396
  "required": false,
21397
21397
  "type": "string"
21398
21398
  },
21399
+ {
21400
+ "disabled": false,
21401
+ "document": "Output path, which can be a relative or an absolute path.\nThe path must end with `.{format}`. For details, please refer to the [Filename Variable](https://www.tencentcloud.comom/document/product/862/37039?from_cn_redirect=1).\n**Relative path example:**\n<Li>`Filename_{Variablename}.{format}`.</li>\n<Li>`Filename.{format}`.</li>\n\n**Absolute path example:**\n<Li>`/Path/Filename_{Variablename}.{format}`.</li>\n\nIf not filled in, default relative path: `{inputName}.{format}`.",
21402
+ "example": "{inputName}.{format}",
21403
+ "member": "string",
21404
+ "name": "OutputPath",
21405
+ "required": false,
21406
+ "type": "string"
21407
+ },
21399
21408
  {
21400
21409
  "disabled": false,
21401
21410
  "document": "Image processing parameter.",
@@ -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
+ }