tccli 3.0.1348.1__py2.py3-none-any.whl → 3.0.1349.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 +1 -1
- tccli/services/__init__.py +0 -76
- tccli/services/ai3d/v20250513/api.json +1 -1
- tccli/services/aiart/v20221229/api.json +3 -3
- tccli/services/autoscaling/v20180419/api.json +11 -0
- tccli/services/batch/v20170312/api.json +44 -0
- tccli/services/cdb/v20170320/api.json +8 -8
- tccli/services/cdb/v20170320/examples.json +1 -1
- tccli/services/cdn/v20180606/api.json +5 -5
- tccli/services/cdwdoris/v20211228/api.json +145 -7
- tccli/services/cfg/v20210820/api.json +20 -0
- tccli/services/cfs/v20190719/api.json +10 -10
- tccli/services/cfw/cfw_client.py +53 -0
- tccli/services/cfw/v20190904/api.json +272 -0
- tccli/services/cfw/v20190904/examples.json +8 -0
- tccli/services/csip/csip_client.py +833 -144
- tccli/services/csip/v20221121/api.json +3304 -1436
- tccli/services/csip/v20221121/examples.json +104 -0
- tccli/services/cvm/v20170312/api.json +1 -1
- tccli/services/cwp/v20180228/api.json +9 -0
- tccli/services/cwp/v20180228/examples.json +6 -0
- tccli/services/emr/v20190103/api.json +217 -2
- tccli/services/es/v20250101/api.json +22 -0
- tccli/services/ess/v20201111/api.json +10 -1
- tccli/services/essbasic/v20210526/api.json +3 -3
- tccli/services/gs/v20191118/api.json +38 -0
- tccli/services/igtm/igtm_client.py +159 -0
- tccli/services/igtm/v20231024/api.json +577 -0
- tccli/services/igtm/v20231024/examples.json +24 -0
- tccli/services/iotexplorer/v20190423/api.json +3 -3
- tccli/services/lcic/lcic_client.py +53 -0
- tccli/services/lcic/v20220817/api.json +53 -0
- tccli/services/lcic/v20220817/examples.json +8 -0
- tccli/services/live/v20180801/api.json +203 -1
- tccli/services/live/v20180801/examples.json +1 -1
- tccli/services/lke/v20231130/api.json +248 -2
- tccli/services/lke/v20231130/examples.json +1 -1
- tccli/services/lkeap/v20240522/api.json +1 -1
- tccli/services/mrs/v20200910/api.json +10 -0
- tccli/services/nlp/nlp_client.py +4 -322
- tccli/services/nlp/v20190408/api.json +0 -459
- tccli/services/nlp/v20190408/examples.json +0 -48
- tccli/services/ocr/v20181119/api.json +60 -5
- tccli/services/omics/v20221128/api.json +38 -0
- tccli/services/redis/v20180412/api.json +6 -6
- tccli/services/redis/v20180412/examples.json +1 -1
- tccli/services/ses/v20201002/api.json +100 -5
- tccli/services/tcb/v20180608/api.json +1 -1
- tccli/services/tcb/v20180608/examples.json +1 -1
- tccli/services/tdmq/v20200217/api.json +19 -0
- tccli/services/teo/teo_client.py +281 -16
- tccli/services/teo/v20220901/api.json +611 -6
- tccli/services/teo/v20220901/examples.json +48 -2
- tccli/services/tione/v20211111/api.json +16 -0
- tccli/services/tke/tke_client.py +57 -4
- tccli/services/tke/v20180525/api.json +24 -24
- tccli/services/tke/v20220501/api.json +52 -0
- tccli/services/tke/v20220501/examples.json +8 -0
- tccli/services/tmt/v20180321/api.json +4 -4
- tccli/services/tsf/v20180326/api.json +4 -4
- tccli/services/vclm/v20240523/api.json +3 -3
- tccli/services/vod/v20180717/api.json +5 -5
- tccli/services/vod/v20180717/examples.json +9 -9
- tccli/services/vpc/v20170312/api.json +1 -1
- tccli/services/vrs/v20200824/api.json +1 -1
- {tccli-3.0.1348.1.dist-info → tccli-3.0.1349.1.dist-info}/METADATA +2 -2
- {tccli-3.0.1348.1.dist-info → tccli-3.0.1349.1.dist-info}/RECORD +70 -172
- tccli/services/cis/__init__.py +0 -4
- tccli/services/cis/cis_client.py +0 -525
- tccli/services/cis/v20180408/api.json +0 -737
- tccli/services/cis/v20180408/examples.json +0 -93
- tccli/services/dataintegration/__init__.py +0 -4
- tccli/services/dataintegration/dataintegration_client.py +0 -207
- tccli/services/dataintegration/v20220613/api.json +0 -87
- tccli/services/dataintegration/v20220613/examples.json +0 -13
- tccli/services/dtf/__init__.py +0 -4
- tccli/services/dtf/dtf_client.py +0 -207
- tccli/services/dtf/v20200506/api.json +0 -274
- tccli/services/dtf/v20200506/examples.json +0 -13
- tccli/services/gpm/__init__.py +0 -4
- tccli/services/gpm/gpm_client.py +0 -1108
- tccli/services/gpm/v20200820/api.json +0 -1959
- tccli/services/gpm/v20200820/examples.json +0 -149
- tccli/services/gse/__init__.py +0 -4
- tccli/services/gse/gse_client.py +0 -4076
- tccli/services/gse/v20191112/api.json +0 -7095
- tccli/services/gse/v20191112/examples.json +0 -615
- tccli/services/iecp/__init__.py +0 -4
- tccli/services/iecp/iecp_client.py +0 -4500
- tccli/services/iecp/v20210914/api.json +0 -9770
- tccli/services/iecp/v20210914/examples.json +0 -691
- tccli/services/iir/__init__.py +0 -4
- tccli/services/iir/iir_client.py +0 -207
- tccli/services/iir/v20200417/api.json +0 -204
- tccli/services/iir/v20200417/examples.json +0 -13
- tccli/services/iottid/__init__.py +0 -4
- tccli/services/iottid/iottid_client.py +0 -631
- tccli/services/iottid/v20190411/api.json +0 -553
- tccli/services/iottid/v20190411/examples.json +0 -95
- tccli/services/mgobe/__init__.py +0 -4
- tccli/services/mgobe/mgobe_client.py +0 -530
- tccli/services/mgobe/v20190929/api.json +0 -52
- tccli/services/mgobe/v20190929/examples.json +0 -13
- tccli/services/mgobe/v20201014/api.json +0 -671
- tccli/services/mgobe/v20201014/examples.json +0 -61
- tccli/services/mvj/__init__.py +0 -4
- tccli/services/mvj/mvj_client.py +0 -207
- tccli/services/mvj/v20190926/api.json +0 -123
- tccli/services/mvj/v20190926/examples.json +0 -19
- tccli/services/pds/__init__.py +0 -4
- tccli/services/pds/pds_client.py +0 -260
- tccli/services/pds/v20210701/api.json +0 -193
- tccli/services/pds/v20210701/examples.json +0 -21
- tccli/services/smpn/__init__.py +0 -4
- tccli/services/smpn/smpn_client.py +0 -260
- tccli/services/smpn/v20190822/api.json +0 -191
- tccli/services/smpn/v20190822/examples.json +0 -21
- tccli/services/solar/__init__.py +0 -4
- tccli/services/solar/solar_client.py +0 -1055
- tccli/services/solar/v20181011/api.json +0 -1760
- tccli/services/solar/v20181011/examples.json +0 -125
- tccli/services/tan/__init__.py +0 -4
- tccli/services/tan/tan_client.py +0 -207
- tccli/services/tan/v20220420/api.json +0 -65
- tccli/services/tan/v20220420/examples.json +0 -19
- tccli/services/tav/__init__.py +0 -4
- tccli/services/tav/tav_client.py +0 -366
- tccli/services/tav/v20190118/api.json +0 -262
- tccli/services/tav/v20190118/examples.json +0 -37
- tccli/services/tbm/__init__.py +0 -4
- tccli/services/tbm/tbm_client.py +0 -631
- tccli/services/tbm/v20180129/api.json +0 -1037
- tccli/services/tbm/v20180129/examples.json +0 -77
- tccli/services/tcex/__init__.py +0 -4
- tccli/services/tcex/tcex_client.py +0 -260
- tccli/services/tcex/v20200727/api.json +0 -158
- tccli/services/tcex/v20200727/examples.json +0 -21
- tccli/services/tci/__init__.py +0 -4
- tccli/services/tci/tci_client.py +0 -2327
- tccli/services/tci/v20190318/api.json +0 -4958
- tccli/services/tci/v20190318/examples.json +0 -333
- tccli/services/tic/__init__.py +0 -4
- tccli/services/tic/tic_client.py +0 -843
- tccli/services/tic/v20201117/api.json +0 -1067
- tccli/services/tic/v20201117/examples.json +0 -121
- tccli/services/ticm/__init__.py +0 -4
- tccli/services/ticm/ticm_client.py +0 -313
- tccli/services/ticm/v20181127/api.json +0 -1391
- tccli/services/ticm/v20181127/examples.json +0 -53
- tccli/services/tics/__init__.py +0 -4
- tccli/services/tics/tics_client.py +0 -366
- tccli/services/tics/v20181115/api.json +0 -694
- tccli/services/tics/v20181115/examples.json +0 -37
- tccli/services/tiems/__init__.py +0 -4
- tccli/services/tiems/tiems_client.py +0 -1479
- tccli/services/tiems/v20190416/api.json +0 -3144
- tccli/services/tiems/v20190416/examples.json +0 -217
- tccli/services/trdp/__init__.py +0 -4
- tccli/services/trdp/trdp_client.py +0 -207
- tccli/services/trdp/v20220726/api.json +0 -843
- tccli/services/trdp/v20220726/examples.json +0 -13
- tccli/services/ump/__init__.py +0 -4
- tccli/services/ump/ump_client.py +0 -1055
- tccli/services/ump/v20200918/api.json +0 -2168
- tccli/services/ump/v20200918/examples.json +0 -141
- tccli/services/youmall/__init__.py +0 -4
- tccli/services/youmall/v20180228/api.json +0 -3572
- tccli/services/youmall/v20180228/examples.json +0 -313
- tccli/services/youmall/youmall_client.py +0 -1797
- {tccli-3.0.1348.1.dist-info → tccli-3.0.1349.1.dist-info}/WHEEL +0 -0
- {tccli-3.0.1348.1.dist-info → tccli-3.0.1349.1.dist-info}/entry_points.txt +0 -0
- {tccli-3.0.1348.1.dist-info → tccli-3.0.1349.1.dist-info}/license_files/LICENSE +0 -0
tccli/services/nlp/nlp_client.py
CHANGED
@@ -17,58 +17,6 @@ from tencentcloud.nlp.v20190408 import models as models_v20190408
|
|
17
17
|
from jmespath import search
|
18
18
|
import time
|
19
19
|
|
20
|
-
def doTextEmbellish(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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
47
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
48
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
49
|
-
model = models.TextEmbellishRequest()
|
50
|
-
model.from_json_string(json.dumps(args))
|
51
|
-
start_time = time.time()
|
52
|
-
while True:
|
53
|
-
rsp = client.TextEmbellish(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
20
|
def doClassifyContent(args, parsed_globals):
|
73
21
|
g_param = parse_global_arg(parsed_globals)
|
74
22
|
|
@@ -121,162 +69,6 @@ def doClassifyContent(args, parsed_globals):
|
|
121
69
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
122
70
|
|
123
71
|
|
124
|
-
def doSentenceCorrection(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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
151
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
152
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
153
|
-
model = models.SentenceCorrectionRequest()
|
154
|
-
model.from_json_string(json.dumps(args))
|
155
|
-
start_time = time.time()
|
156
|
-
while True:
|
157
|
-
rsp = client.SentenceCorrection(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 doComposePoetry(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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
203
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
204
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
205
|
-
model = models.ComposePoetryRequest()
|
206
|
-
model.from_json_string(json.dumps(args))
|
207
|
-
start_time = time.time()
|
208
|
-
while True:
|
209
|
-
rsp = client.ComposePoetry(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 doGenerateKeywordSentence(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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
255
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
256
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
257
|
-
model = models.GenerateKeywordSentenceRequest()
|
258
|
-
model.from_json_string(json.dumps(args))
|
259
|
-
start_time = time.time()
|
260
|
-
while True:
|
261
|
-
rsp = client.GenerateKeywordSentence(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
72
|
def doEvaluateSentenceSimilarity(args, parsed_globals):
|
281
73
|
g_param = parse_global_arg(parsed_globals)
|
282
74
|
|
@@ -329,111 +121,7 @@ def doEvaluateSentenceSimilarity(args, parsed_globals):
|
|
329
121
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
330
122
|
|
331
123
|
|
332
|
-
def
|
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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
359
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
360
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
361
|
-
model = models.RetrieveSimilarWordsRequest()
|
362
|
-
model.from_json_string(json.dumps(args))
|
363
|
-
start_time = time.time()
|
364
|
-
while True:
|
365
|
-
rsp = client.RetrieveSimilarWords(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 doTextWriting(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.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
411
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
412
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
413
|
-
model = models.TextWritingRequest()
|
414
|
-
model.from_json_string(json.dumps(args))
|
415
|
-
start_time = time.time()
|
416
|
-
while True:
|
417
|
-
rsp = client.TextWriting(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
|
-
def doEvaluateWordSimilarity(args, parsed_globals):
|
124
|
+
def doSentenceCorrection(args, parsed_globals):
|
437
125
|
g_param = parse_global_arg(parsed_globals)
|
438
126
|
|
439
127
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -462,11 +150,11 @@ def doEvaluateWordSimilarity(args, parsed_globals):
|
|
462
150
|
client = mod.NlpClient(cred, g_param[OptionsDefine.Region], profile)
|
463
151
|
client._sdkVersion += ("_CLI_" + __version__)
|
464
152
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
465
|
-
model = models.
|
153
|
+
model = models.SentenceCorrectionRequest()
|
466
154
|
model.from_json_string(json.dumps(args))
|
467
155
|
start_time = time.time()
|
468
156
|
while True:
|
469
|
-
rsp = client.
|
157
|
+
rsp = client.SentenceCorrection(model)
|
470
158
|
result = rsp.to_json_string()
|
471
159
|
try:
|
472
160
|
json_obj = json.loads(result)
|
@@ -652,15 +340,9 @@ MODELS_MAP = {
|
|
652
340
|
}
|
653
341
|
|
654
342
|
ACTION_MAP = {
|
655
|
-
"TextEmbellish": doTextEmbellish,
|
656
343
|
"ClassifyContent": doClassifyContent,
|
657
|
-
"SentenceCorrection": doSentenceCorrection,
|
658
|
-
"ComposePoetry": doComposePoetry,
|
659
|
-
"GenerateKeywordSentence": doGenerateKeywordSentence,
|
660
344
|
"EvaluateSentenceSimilarity": doEvaluateSentenceSimilarity,
|
661
|
-
"
|
662
|
-
"TextWriting": doTextWriting,
|
663
|
-
"EvaluateWordSimilarity": doEvaluateWordSimilarity,
|
345
|
+
"SentenceCorrection": doSentenceCorrection,
|
664
346
|
"ComposeCouplet": doComposeCouplet,
|
665
347
|
"AnalyzeSentiment": doAnalyzeSentiment,
|
666
348
|
"ParseWords": doParseWords,
|