tccli 3.0.1236.1__py2.py3-none-any.whl → 3.0.1238.1__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- tccli/__init__.py +1 -1
- tccli/services/__init__.py +3 -0
- tccli/services/aca/__init__.py +4 -0
- tccli/services/aca/aca_client.py +578 -0
- tccli/services/aca/v20210323/api.json +3715 -0
- tccli/services/aca/v20210323/examples.json +69 -0
- tccli/services/aiart/v20221229/api.json +18 -9
- tccli/services/aiart/v20221229/examples.json +2 -2
- tccli/services/apm/v20210622/api.json +25 -22
- tccli/services/apm/v20210622/examples.json +16 -22
- tccli/services/ba/v20200720/api.json +3 -2
- tccli/services/batch/v20170312/api.json +641 -566
- tccli/services/batch/v20170312/examples.json +7 -7
- tccli/services/bi/v20220105/api.json +9 -0
- tccli/services/billing/v20180709/api.json +2 -2
- tccli/services/bpaas/v20181217/examples.json +1 -1
- tccli/services/cam/v20190116/api.json +116 -99
- tccli/services/cam/v20190116/examples.json +11 -11
- tccli/services/ccc/v20200210/api.json +40 -1
- tccli/services/ccc/v20200210/examples.json +1 -1
- tccli/services/cdb/cdb_client.py +53 -0
- tccli/services/cdb/v20170320/api.json +257 -207
- tccli/services/cdb/v20170320/examples.json +18 -10
- tccli/services/cdwch/v20200915/api.json +6 -6
- tccli/services/cdwdoris/v20211228/api.json +16 -5
- tccli/services/cdwdoris/v20211228/examples.json +1 -1
- tccli/services/cfg/v20210820/api.json +29 -13
- tccli/services/cfg/v20210820/examples.json +1 -1
- tccli/services/cfs/v20190719/api.json +84 -84
- tccli/services/cfs/v20190719/examples.json +6 -6
- tccli/services/chdfs/v20201112/api.json +18 -17
- tccli/services/chdfs/v20201112/examples.json +2 -2
- tccli/services/clb/v20180317/api.json +184 -162
- tccli/services/cloudapp/v20220530/api.json +11 -1
- tccli/services/cloudapp/v20220530/examples.json +3 -3
- tccli/services/cloudaudit/v20190319/api.json +64 -53
- tccli/services/cloudaudit/v20190319/examples.json +5 -5
- tccli/services/cls/v20201016/api.json +21 -21
- tccli/services/cls/v20201016/examples.json +1 -1
- tccli/services/config/v20220802/api.json +2 -0
- tccli/services/config/v20220802/examples.json +2 -2
- tccli/services/cvm/v20170312/api.json +5 -5
- tccli/services/cynosdb/cynosdb_client.py +53 -0
- tccli/services/cynosdb/v20190107/api.json +110 -0
- tccli/services/cynosdb/v20190107/examples.json +8 -0
- tccli/services/dcdb/v20180411/api.json +390 -387
- tccli/services/dcdb/v20180411/examples.json +14 -14
- tccli/services/dlc/v20210125/api.json +162 -7
- tccli/services/dlc/v20210125/examples.json +1 -1
- tccli/services/domain/v20180808/api.json +55 -54
- tccli/services/domain/v20180808/examples.json +38 -32
- tccli/services/dsgc/v20190723/api.json +1796 -1623
- tccli/services/dsgc/v20190723/examples.json +217 -211
- tccli/services/dts/v20180330/api.json +143 -106
- tccli/services/dts/v20211206/api.json +57 -46
- tccli/services/dts/v20211206/examples.json +1 -1
- tccli/services/ecm/v20190719/api.json +6 -6
- tccli/services/emr/v20190103/api.json +80 -20
- tccli/services/ess/ess_client.py +118 -12
- tccli/services/ess/v20201111/api.json +320 -37
- tccli/services/ess/v20201111/examples.json +19 -3
- tccli/services/essbasic/essbasic_client.py +167 -8
- tccli/services/essbasic/v20210526/api.json +528 -55
- tccli/services/essbasic/v20210526/examples.json +46 -16
- tccli/services/facefusion/v20220927/api.json +12 -1
- tccli/services/fmu/v20191213/api.json +8 -8
- tccli/services/gaap/v20180529/api.json +200 -209
- tccli/services/gwlb/v20240906/api.json +16 -16
- tccli/services/gwlb/v20240906/examples.json +2 -2
- tccli/services/hai/v20230812/api.json +1 -1
- tccli/services/hunyuan/v20230901/api.json +6 -6
- tccli/services/iss/v20230517/api.json +11 -11
- tccli/services/iss/v20230517/examples.json +31 -31
- tccli/services/keewidb/v20220308/api.json +92 -82
- tccli/services/keewidb/v20220308/examples.json +5 -5
- tccli/services/lcic/v20220817/api.json +3 -3
- tccli/services/lcic/v20220817/examples.json +2 -2
- tccli/services/lighthouse/v20200324/api.json +18 -18
- tccli/services/lighthouse/v20200324/examples.json +6 -6
- tccli/services/live/v20180801/api.json +32 -14
- tccli/services/lke/v20231130/examples.json +1 -1
- tccli/services/mariadb/v20170312/api.json +285 -263
- tccli/services/mariadb/v20170312/examples.json +12 -12
- tccli/services/mongodb/v20180408/api.json +52 -40
- tccli/services/mongodb/v20180408/examples.json +4 -4
- tccli/services/mongodb/v20190725/api.json +119 -109
- tccli/services/mongodb/v20190725/examples.json +5 -5
- tccli/services/monitor/monitor_client.py +106 -0
- tccli/services/monitor/v20180724/api.json +222 -0
- tccli/services/monitor/v20180724/examples.json +17 -1
- tccli/services/mps/mps_client.py +228 -16
- tccli/services/mps/v20190612/api.json +385 -23
- tccli/services/mps/v20190612/examples.json +32 -0
- tccli/services/mqtt/v20240516/api.json +1 -1
- tccli/services/mqtt/v20240516/examples.json +1 -1
- tccli/services/msp/v20180319/api.json +2 -2
- tccli/services/ocr/v20181119/api.json +11 -1
- tccli/services/omics/v20221128/api.json +14 -2
- tccli/services/organization/v20210331/api.json +45 -18
- tccli/services/privatedns/v20201028/api.json +90 -81
- tccli/services/privatedns/v20201028/examples.json +18 -18
- tccli/services/pts/v20210728/api.json +8 -0
- tccli/services/redis/redis_client.py +106 -0
- tccli/services/redis/v20180412/api.json +178 -16
- tccli/services/redis/v20180412/examples.json +16 -0
- tccli/services/region/v20220627/api.json +5 -3
- tccli/services/region/v20220627/examples.json +1 -1
- tccli/services/ssl/v20191205/api.json +6 -4
- tccli/services/ssl/v20191205/examples.json +1 -1
- tccli/services/sts/v20180813/examples.json +1 -1
- tccli/services/tag/v20180813/api.json +4 -5
- tccli/services/tcb/v20180608/api.json +36 -16
- tccli/services/tdid/v20210519/api.json +30 -38
- tccli/services/tdid/v20210519/examples.json +5 -5
- tccli/services/tdmq/tdmq_client.py +53 -0
- tccli/services/tdmq/v20200217/api.json +64 -1
- tccli/services/tdmq/v20200217/examples.json +9 -1
- tccli/services/teo/teo_client.py +485 -8
- tccli/services/teo/v20220901/api.json +837 -39
- tccli/services/teo/v20220901/examples.json +108 -0
- tccli/services/thpc/v20211109/api.json +32 -34
- tccli/services/thpc/v20220401/api.json +31 -33
- tccli/services/thpc/v20230321/api.json +55 -57
- tccli/services/thpc/v20230321/examples.json +1 -1
- tccli/services/tiia/v20190529/api.json +307 -293
- tccli/services/tiia/v20190529/examples.json +41 -41
- tccli/services/tione/v20211111/api.json +4 -4
- tccli/services/tione/v20211111/examples.json +2 -2
- tccli/services/tke/v20180525/api.json +1 -1
- tccli/services/trocket/trocket_client.py +53 -0
- tccli/services/trocket/v20230308/api.json +119 -3
- tccli/services/trocket/v20230308/examples.json +14 -0
- tccli/services/tse/v20201207/api.json +188 -120
- tccli/services/tse/v20201207/examples.json +30 -30
- tccli/services/tsf/v20180326/api.json +826 -745
- tccli/services/tsf/v20180326/examples.json +99 -111
- tccli/services/vclm/v20240523/api.json +1 -1
- tccli/services/vdb/v20230616/api.json +80 -80
- tccli/services/vdb/v20230616/examples.json +1 -1
- tccli/services/vpc/v20170312/api.json +64 -44
- tccli/services/vpc/v20170312/examples.json +6 -6
- tccli/services/vrs/v20200824/api.json +3 -2
- tccli/services/wedata/v20210820/api.json +550 -40
- tccli/services/wedata/v20210820/examples.json +10 -4
- {tccli-3.0.1236.1.dist-info → tccli-3.0.1238.1.dist-info}/METADATA +2 -2
- {tccli-3.0.1236.1.dist-info → tccli-3.0.1238.1.dist-info}/RECORD +149 -145
- {tccli-3.0.1236.1.dist-info → tccli-3.0.1238.1.dist-info}/WHEEL +0 -0
- {tccli-3.0.1236.1.dist-info → tccli-3.0.1238.1.dist-info}/entry_points.txt +0 -0
- {tccli-3.0.1236.1.dist-info → tccli-3.0.1238.1.dist-info}/license_files/LICENSE +0 -0
tccli/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '3.0.
|
1
|
+
__version__ = '3.0.1238.1'
|
tccli/services/__init__.py
CHANGED
@@ -0,0 +1,578 @@
|
|
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.aca.v20210323 import aca_client as aca_client_v20210323
|
15
|
+
from tencentcloud.aca.v20210323 import models as models_v20210323
|
16
|
+
|
17
|
+
from jmespath import search
|
18
|
+
import time
|
19
|
+
|
20
|
+
def doLoginHisTool(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.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
47
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
48
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
49
|
+
model = models.LoginHisToolRequest()
|
50
|
+
model.from_json_string(json.dumps(args))
|
51
|
+
start_time = time.time()
|
52
|
+
while True:
|
53
|
+
rsp = client.LoginHisTool(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 doGetDrugIndications(args, parsed_globals):
|
73
|
+
g_param = parse_global_arg(parsed_globals)
|
74
|
+
|
75
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
76
|
+
cred = credential.CVMRoleCredential()
|
77
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
78
|
+
cred = credential.STSAssumeRoleCredential(
|
79
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
80
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
81
|
+
)
|
82
|
+
elif os.getenv(OptionsDefine.ENV_TKE_REGION) and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID) and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE) and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
|
83
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
84
|
+
else:
|
85
|
+
cred = credential.Credential(
|
86
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
87
|
+
)
|
88
|
+
http_profile = HttpProfile(
|
89
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
90
|
+
reqMethod="POST",
|
91
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
92
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
93
|
+
)
|
94
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
95
|
+
if g_param[OptionsDefine.Language]:
|
96
|
+
profile.language = g_param[OptionsDefine.Language]
|
97
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
98
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
99
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
100
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
101
|
+
model = models.GetDrugIndicationsRequest()
|
102
|
+
model.from_json_string(json.dumps(args))
|
103
|
+
start_time = time.time()
|
104
|
+
while True:
|
105
|
+
rsp = client.GetDrugIndications(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
|
+
def doLoginOutHisTool(args, parsed_globals):
|
125
|
+
g_param = parse_global_arg(parsed_globals)
|
126
|
+
|
127
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
128
|
+
cred = credential.CVMRoleCredential()
|
129
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
130
|
+
cred = credential.STSAssumeRoleCredential(
|
131
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
132
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
133
|
+
)
|
134
|
+
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):
|
135
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
136
|
+
else:
|
137
|
+
cred = credential.Credential(
|
138
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
139
|
+
)
|
140
|
+
http_profile = HttpProfile(
|
141
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
142
|
+
reqMethod="POST",
|
143
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
144
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
145
|
+
)
|
146
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
147
|
+
if g_param[OptionsDefine.Language]:
|
148
|
+
profile.language = g_param[OptionsDefine.Language]
|
149
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
150
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
151
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
152
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
153
|
+
model = models.LoginOutHisToolRequest()
|
154
|
+
model.from_json_string(json.dumps(args))
|
155
|
+
start_time = time.time()
|
156
|
+
while True:
|
157
|
+
rsp = client.LoginOutHisTool(model)
|
158
|
+
result = rsp.to_json_string()
|
159
|
+
try:
|
160
|
+
json_obj = json.loads(result)
|
161
|
+
except TypeError as e:
|
162
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
163
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
164
|
+
break
|
165
|
+
cur_time = time.time()
|
166
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
167
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
168
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
169
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
170
|
+
else:
|
171
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
172
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
173
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
174
|
+
|
175
|
+
|
176
|
+
def doSmartPredict(args, parsed_globals):
|
177
|
+
g_param = parse_global_arg(parsed_globals)
|
178
|
+
|
179
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
180
|
+
cred = credential.CVMRoleCredential()
|
181
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
182
|
+
cred = credential.STSAssumeRoleCredential(
|
183
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
184
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
185
|
+
)
|
186
|
+
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):
|
187
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
188
|
+
else:
|
189
|
+
cred = credential.Credential(
|
190
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
191
|
+
)
|
192
|
+
http_profile = HttpProfile(
|
193
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
194
|
+
reqMethod="POST",
|
195
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
196
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
197
|
+
)
|
198
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
199
|
+
if g_param[OptionsDefine.Language]:
|
200
|
+
profile.language = g_param[OptionsDefine.Language]
|
201
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
202
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
203
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
204
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
205
|
+
model = models.SmartPredictRequest()
|
206
|
+
model.from_json_string(json.dumps(args))
|
207
|
+
start_time = time.time()
|
208
|
+
while True:
|
209
|
+
rsp = client.SmartPredict(model)
|
210
|
+
result = rsp.to_json_string()
|
211
|
+
try:
|
212
|
+
json_obj = json.loads(result)
|
213
|
+
except TypeError as e:
|
214
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
215
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
216
|
+
break
|
217
|
+
cur_time = time.time()
|
218
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
219
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
220
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
221
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
222
|
+
else:
|
223
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
224
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
225
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
226
|
+
|
227
|
+
|
228
|
+
def doSmartDrugInfo(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('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
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.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
255
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
256
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
257
|
+
model = models.SmartDrugInfoRequest()
|
258
|
+
model.from_json_string(json.dumps(args))
|
259
|
+
start_time = time.time()
|
260
|
+
while True:
|
261
|
+
rsp = client.SmartDrugInfo(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
|
+
|
280
|
+
def doSyncDepartment(args, parsed_globals):
|
281
|
+
g_param = parse_global_arg(parsed_globals)
|
282
|
+
|
283
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
284
|
+
cred = credential.CVMRoleCredential()
|
285
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
286
|
+
cred = credential.STSAssumeRoleCredential(
|
287
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
288
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
289
|
+
)
|
290
|
+
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):
|
291
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
292
|
+
else:
|
293
|
+
cred = credential.Credential(
|
294
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
295
|
+
)
|
296
|
+
http_profile = HttpProfile(
|
297
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
298
|
+
reqMethod="POST",
|
299
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
300
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
301
|
+
)
|
302
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
303
|
+
if g_param[OptionsDefine.Language]:
|
304
|
+
profile.language = g_param[OptionsDefine.Language]
|
305
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
306
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
307
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
308
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
309
|
+
model = models.SyncDepartmentRequest()
|
310
|
+
model.from_json_string(json.dumps(args))
|
311
|
+
start_time = time.time()
|
312
|
+
while True:
|
313
|
+
rsp = client.SyncDepartment(model)
|
314
|
+
result = rsp.to_json_string()
|
315
|
+
try:
|
316
|
+
json_obj = json.loads(result)
|
317
|
+
except TypeError as e:
|
318
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
319
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
320
|
+
break
|
321
|
+
cur_time = time.time()
|
322
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
323
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
324
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
325
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
326
|
+
else:
|
327
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
328
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
329
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
330
|
+
|
331
|
+
|
332
|
+
def doSyncStandardDict(args, parsed_globals):
|
333
|
+
g_param = parse_global_arg(parsed_globals)
|
334
|
+
|
335
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
336
|
+
cred = credential.CVMRoleCredential()
|
337
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
338
|
+
cred = credential.STSAssumeRoleCredential(
|
339
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
340
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
341
|
+
)
|
342
|
+
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):
|
343
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
344
|
+
else:
|
345
|
+
cred = credential.Credential(
|
346
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
347
|
+
)
|
348
|
+
http_profile = HttpProfile(
|
349
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
350
|
+
reqMethod="POST",
|
351
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
352
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
353
|
+
)
|
354
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
355
|
+
if g_param[OptionsDefine.Language]:
|
356
|
+
profile.language = g_param[OptionsDefine.Language]
|
357
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
358
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
359
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
360
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
361
|
+
model = models.SyncStandardDictRequest()
|
362
|
+
model.from_json_string(json.dumps(args))
|
363
|
+
start_time = time.time()
|
364
|
+
while True:
|
365
|
+
rsp = client.SyncStandardDict(model)
|
366
|
+
result = rsp.to_json_string()
|
367
|
+
try:
|
368
|
+
json_obj = json.loads(result)
|
369
|
+
except TypeError as e:
|
370
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
371
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
372
|
+
break
|
373
|
+
cur_time = time.time()
|
374
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
375
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
376
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
377
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
378
|
+
else:
|
379
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
380
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
381
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
382
|
+
|
383
|
+
|
384
|
+
def doUploadDrugs(args, parsed_globals):
|
385
|
+
g_param = parse_global_arg(parsed_globals)
|
386
|
+
|
387
|
+
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
388
|
+
cred = credential.CVMRoleCredential()
|
389
|
+
elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
|
390
|
+
cred = credential.STSAssumeRoleCredential(
|
391
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
|
392
|
+
g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
|
393
|
+
)
|
394
|
+
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):
|
395
|
+
cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
|
396
|
+
else:
|
397
|
+
cred = credential.Credential(
|
398
|
+
g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
|
399
|
+
)
|
400
|
+
http_profile = HttpProfile(
|
401
|
+
reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
|
402
|
+
reqMethod="POST",
|
403
|
+
endpoint=g_param[OptionsDefine.Endpoint],
|
404
|
+
proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
|
405
|
+
)
|
406
|
+
profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
|
407
|
+
if g_param[OptionsDefine.Language]:
|
408
|
+
profile.language = g_param[OptionsDefine.Language]
|
409
|
+
mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
|
410
|
+
client = mod.AcaClient(cred, g_param[OptionsDefine.Region], profile)
|
411
|
+
client._sdkVersion += ("_CLI_" + __version__)
|
412
|
+
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
413
|
+
model = models.UploadDrugsRequest()
|
414
|
+
model.from_json_string(json.dumps(args))
|
415
|
+
start_time = time.time()
|
416
|
+
while True:
|
417
|
+
rsp = client.UploadDrugs(model)
|
418
|
+
result = rsp.to_json_string()
|
419
|
+
try:
|
420
|
+
json_obj = json.loads(result)
|
421
|
+
except TypeError as e:
|
422
|
+
json_obj = json.loads(result.decode('utf-8')) # python3.3
|
423
|
+
if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
|
424
|
+
break
|
425
|
+
cur_time = time.time()
|
426
|
+
if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
|
427
|
+
raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
|
428
|
+
(g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
|
429
|
+
search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
|
430
|
+
else:
|
431
|
+
print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
|
432
|
+
time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
|
433
|
+
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
434
|
+
|
435
|
+
|
436
|
+
CLIENT_MAP = {
|
437
|
+
"v20210323": aca_client_v20210323,
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
MODELS_MAP = {
|
442
|
+
"v20210323": models_v20210323,
|
443
|
+
|
444
|
+
}
|
445
|
+
|
446
|
+
ACTION_MAP = {
|
447
|
+
"LoginHisTool": doLoginHisTool,
|
448
|
+
"GetDrugIndications": doGetDrugIndications,
|
449
|
+
"LoginOutHisTool": doLoginOutHisTool,
|
450
|
+
"SmartPredict": doSmartPredict,
|
451
|
+
"SmartDrugInfo": doSmartDrugInfo,
|
452
|
+
"SyncDepartment": doSyncDepartment,
|
453
|
+
"SyncStandardDict": doSyncStandardDict,
|
454
|
+
"UploadDrugs": doUploadDrugs,
|
455
|
+
|
456
|
+
}
|
457
|
+
|
458
|
+
AVAILABLE_VERSION_LIST = [
|
459
|
+
"v20210323",
|
460
|
+
|
461
|
+
]
|
462
|
+
|
463
|
+
|
464
|
+
def action_caller():
|
465
|
+
return ACTION_MAP
|
466
|
+
|
467
|
+
|
468
|
+
def parse_global_arg(parsed_globals):
|
469
|
+
g_param = parsed_globals
|
470
|
+
cvm_role_flag = True
|
471
|
+
for param in parsed_globals.keys():
|
472
|
+
if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.RoleArn,
|
473
|
+
OptionsDefine.RoleSessionName]:
|
474
|
+
if parsed_globals[param] is not None:
|
475
|
+
cvm_role_flag = False
|
476
|
+
break
|
477
|
+
is_exist_profile = True
|
478
|
+
if not parsed_globals["profile"]:
|
479
|
+
is_exist_profile = False
|
480
|
+
g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
|
481
|
+
|
482
|
+
configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
|
483
|
+
is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
|
484
|
+
is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
|
485
|
+
|
486
|
+
conf = {}
|
487
|
+
cred = {}
|
488
|
+
|
489
|
+
if is_conf_exist:
|
490
|
+
conf = Utils.load_json_msg(conf_path)
|
491
|
+
if is_cred_exist:
|
492
|
+
cred = Utils.load_json_msg(cred_path)
|
493
|
+
|
494
|
+
if not (isinstance(conf, dict) and isinstance(cred, dict)):
|
495
|
+
raise ConfigurationError(
|
496
|
+
"file: %s or %s is not json format"
|
497
|
+
% (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
|
498
|
+
|
499
|
+
if OptionsDefine.Token not in cred:
|
500
|
+
cred[OptionsDefine.Token] = None
|
501
|
+
|
502
|
+
if not is_exist_profile:
|
503
|
+
if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
|
504
|
+
cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
|
505
|
+
cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
|
506
|
+
cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
|
507
|
+
cvm_role_flag = False
|
508
|
+
|
509
|
+
if os.environ.get(OptionsDefine.ENV_REGION):
|
510
|
+
conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
|
511
|
+
|
512
|
+
if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
|
513
|
+
cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
|
514
|
+
cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
|
515
|
+
cvm_role_flag = False
|
516
|
+
|
517
|
+
if cvm_role_flag:
|
518
|
+
if "type" in cred and cred["type"] == "cvm-role":
|
519
|
+
g_param[OptionsDefine.UseCVMRole.replace('-', '_')] = True
|
520
|
+
|
521
|
+
for param in g_param.keys():
|
522
|
+
if g_param[param] is None:
|
523
|
+
if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
|
524
|
+
if param in cred:
|
525
|
+
g_param[param] = cred[param]
|
526
|
+
elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
|
527
|
+
or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
|
528
|
+
raise ConfigurationError("%s is invalid" % param)
|
529
|
+
elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
|
530
|
+
if param in conf[OptionsDefine.SysParam]:
|
531
|
+
g_param[param] = conf[OptionsDefine.SysParam][param]
|
532
|
+
elif param != OptionsDefine.Language:
|
533
|
+
raise ConfigurationError("%s is invalid" % param)
|
534
|
+
elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
|
535
|
+
if param.replace('_', '-') in cred:
|
536
|
+
g_param[param] = cred[param.replace('_', '-')]
|
537
|
+
|
538
|
+
try:
|
539
|
+
if g_param[OptionsDefine.ServiceVersion]:
|
540
|
+
g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
|
541
|
+
else:
|
542
|
+
version = conf["aca"][OptionsDefine.Version]
|
543
|
+
g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
|
544
|
+
|
545
|
+
if g_param[OptionsDefine.Endpoint] is None:
|
546
|
+
g_param[OptionsDefine.Endpoint] = conf["aca"][OptionsDefine.Endpoint]
|
547
|
+
g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
|
548
|
+
except Exception as err:
|
549
|
+
raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
|
550
|
+
|
551
|
+
if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
|
552
|
+
raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
|
553
|
+
|
554
|
+
if g_param[OptionsDefine.Waiter]:
|
555
|
+
param = eval(g_param[OptionsDefine.Waiter])
|
556
|
+
if 'expr' not in param:
|
557
|
+
raise Exception('`expr` in `--waiter` must be defined')
|
558
|
+
if 'to' not in param:
|
559
|
+
raise Exception('`to` in `--waiter` must be defined')
|
560
|
+
if 'timeout' not in param:
|
561
|
+
if 'waiter' in conf and 'timeout' in conf['waiter']:
|
562
|
+
param['timeout'] = conf['waiter']['timeout']
|
563
|
+
else:
|
564
|
+
param['timeout'] = 180
|
565
|
+
if 'interval' not in param:
|
566
|
+
if 'waiter' in conf and 'interval' in conf['waiter']:
|
567
|
+
param['interval'] = conf['waiter']['interval']
|
568
|
+
else:
|
569
|
+
param['interval'] = 5
|
570
|
+
param['interval'] = min(param['interval'], param['timeout'])
|
571
|
+
g_param['OptionsDefine.WaiterInfo'] = param
|
572
|
+
|
573
|
+
if six.PY2:
|
574
|
+
for key, value in g_param.items():
|
575
|
+
if isinstance(value, six.text_type):
|
576
|
+
g_param[key] = value.encode('utf-8')
|
577
|
+
return g_param
|
578
|
+
|