tccli 3.0.1091.1__py2.py3-none-any.whl → 3.0.1092.1__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. tccli/__init__.py +1 -1
  2. tccli/examples/cdb/v20170320/CheckMigrateCluster.md +18 -0
  3. tccli/examples/cdb/v20170320/DescribeClusterInfo.md +59 -0
  4. tccli/examples/domain/v20180808/BidPreDomains.md +21 -0
  5. tccli/examples/domain/v20180808/DescribeReservedBidInfo.md +43 -0
  6. tccli/examples/domain/v20180808/DescribeReservedPreDomainInfo.md +31 -0
  7. tccli/examples/es/v20180416/UpdateInstance.md +27 -27
  8. tccli/examples/es/v20180416/UpdatePlugins.md +6 -6
  9. tccli/examples/ess/v20201111/CreateBatchOrganizationRegistrationTasks.md +146 -0
  10. tccli/examples/ess/v20201111/CreateOrganizationAuthUrl.md +18 -0
  11. tccli/examples/ess/v20201111/CreateOrganizationBatchSignUrl.md +28 -0
  12. tccli/examples/hunyuan/v20230901/ChatPro.md +69 -31
  13. tccli/examples/hunyuan/v20230901/ChatStd.md +40 -1
  14. tccli/examples/lke/v20231130/CheckAttributeLabelExist.md +24 -0
  15. tccli/examples/lke/v20231130/CheckAttributeLabelRefer.md +23 -0
  16. tccli/examples/lke/v20231130/CreateApp.md +24 -0
  17. tccli/examples/lke/v20231130/CreateAttributeLabel.md +24 -0
  18. tccli/examples/lke/v20231130/CreateCorp.md +24 -0
  19. tccli/examples/lke/v20231130/CreateQA.md +24 -0
  20. tccli/examples/lke/v20231130/CreateQACate.md +26 -0
  21. tccli/examples/lke/v20231130/CreateRejectedQuestion.md +22 -0
  22. tccli/examples/lke/v20231130/CreateRelease.md +21 -0
  23. tccli/examples/lke/v20231130/DeleteApp.md +21 -0
  24. tccli/examples/lke/v20231130/DeleteAttributeLabel.md +21 -0
  25. tccli/examples/lke/v20231130/DeleteDoc.md +21 -0
  26. tccli/examples/lke/v20231130/DeleteQA.md +21 -0
  27. tccli/examples/lke/v20231130/DeleteQACate.md +21 -0
  28. tccli/examples/lke/v20231130/DeleteRejectedQuestion.md +21 -0
  29. tccli/examples/lke/v20231130/DescribeApp.md +29 -0
  30. tccli/examples/lke/v20231130/DescribeAttributeLabel.md +28 -0
  31. tccli/examples/lke/v20231130/DescribeCorp.md +21 -0
  32. tccli/examples/lke/v20231130/DescribeDoc.md +44 -0
  33. tccli/examples/lke/v20231130/DescribeQA.md +42 -0
  34. tccli/examples/lke/v20231130/DescribeRefer.md +35 -0
  35. tccli/examples/lke/v20231130/DescribeRelease.md +25 -0
  36. tccli/examples/lke/v20231130/DescribeReleaseInfo.md +24 -0
  37. tccli/examples/lke/v20231130/DescribeRobotBizIDByAppKey.md +21 -0
  38. tccli/examples/lke/v20231130/DescribeStorageCredential.md +32 -0
  39. tccli/examples/lke/v20231130/DescribeUnsatisfiedReplyContext.md +121 -0
  40. tccli/examples/lke/v20231130/ExportAttributeLabel.md +21 -0
  41. tccli/examples/lke/v20231130/ExportQAList.md +21 -0
  42. tccli/examples/lke/v20231130/ExportUnsatisfiedReply.md +21 -0
  43. tccli/examples/lke/v20231130/GenerateQA.md +21 -0
  44. tccli/examples/lke/v20231130/GetAppKnowledgeCount.md +22 -0
  45. tccli/examples/lke/v20231130/GetAppSecret.md +24 -0
  46. tccli/examples/lke/v20231130/GetDocPreview.md +26 -0
  47. tccli/examples/lke/v20231130/GetEmbedding.md +29 -0
  48. tccli/examples/lke/v20231130/GetMsgRecord.md +51 -0
  49. tccli/examples/lke/v20231130/GetTaskStatus.md +0 -0
  50. tccli/examples/lke/v20231130/GetWsToken.md +44 -0
  51. tccli/examples/lke/v20231130/GroupQA.md +44 -0
  52. tccli/examples/lke/v20231130/IgnoreUnsatisfiedReply.md +21 -0
  53. tccli/examples/lke/v20231130/IsTransferIntent.md +22 -0
  54. tccli/examples/lke/v20231130/ListApp.md +36 -0
  55. tccli/examples/lke/v20231130/ListAppCategory.md +25 -0
  56. tccli/examples/lke/v20231130/ListAttributeLabel.md +33 -0
  57. tccli/examples/lke/v20231130/ListDoc.md +52 -0
  58. tccli/examples/lke/v20231130/ListModel.md +31 -0
  59. tccli/examples/lke/v20231130/ListQA.md +66 -0
  60. tccli/examples/lke/v20231130/ListQACate.md +41 -0
  61. tccli/examples/lke/v20231130/ListRejectedQuestion.md +52 -0
  62. tccli/examples/lke/v20231130/ListRejectedQuestionPreview.md +37 -0
  63. tccli/examples/lke/v20231130/ListRelease.md +36 -0
  64. tccli/examples/lke/v20231130/ListReleaseConfigPreview.md +129 -0
  65. tccli/examples/lke/v20231130/ListReleaseDocPreview.md +38 -0
  66. tccli/examples/lke/v20231130/ListReleaseQAPreview.md +107 -0
  67. tccli/examples/lke/v20231130/ListSelectDoc.md +27 -0
  68. tccli/examples/lke/v20231130/ListUnsatisfiedReply.md +24 -0
  69. tccli/examples/lke/v20231130/ModifyApp.md +25 -0
  70. tccli/examples/lke/v20231130/ModifyAttributeLabel.md +23 -0
  71. tccli/examples/lke/v20231130/ModifyDoc.md +25 -0
  72. tccli/examples/lke/v20231130/ModifyDocAttrRange.md +25 -0
  73. tccli/examples/lke/v20231130/ModifyQA.md +24 -0
  74. tccli/examples/lke/v20231130/ModifyQAAttrRange.md +25 -0
  75. tccli/examples/lke/v20231130/ModifyQACate.md +22 -0
  76. tccli/examples/lke/v20231130/ModifyRejectedQuestion.md +22 -0
  77. tccli/examples/lke/v20231130/ParseDoc.md +25 -0
  78. tccli/examples/lke/v20231130/QueryParseDocResult.md +24 -0
  79. tccli/examples/lke/v20231130/QueryRewrite.md +25 -0
  80. tccli/examples/lke/v20231130/RateMsgRecord.md +22 -0
  81. tccli/examples/lke/v20231130/ResetSession.md +20 -0
  82. tccli/examples/lke/v20231130/RetryDocAudit.md +21 -0
  83. tccli/examples/lke/v20231130/RetryDocParse.md +21 -0
  84. tccli/examples/lke/v20231130/RetryRelease.md +21 -0
  85. tccli/examples/lke/v20231130/SaveDoc.md +34 -0
  86. tccli/examples/lke/v20231130/StopDocParse.md +21 -0
  87. tccli/examples/lke/v20231130/UploadAttributeLabel.md +27 -0
  88. tccli/examples/lke/v20231130/VerifyQA.md +27 -0
  89. tccli/examples/mna/v20210119/GetFlowPackages.md +3 -1
  90. tccli/examples/mna/v20210119/GetFlowStatistic.md +42 -0
  91. tccli/examples/ocr/v20181119/GeneralBasicOCR.md +0 -1
  92. tccli/examples/sqlserver/v20180328/DescribeRestoreTimeRange.md +23 -0
  93. tccli/services/__init__.py +3 -0
  94. tccli/services/aiart/v20221229/api.json +6 -6
  95. tccli/services/antiddos/v20200309/api.json +10 -0
  96. tccli/services/cdb/cdb_client.py +106 -0
  97. tccli/services/cdb/v20170320/api.json +255 -0
  98. tccli/services/cdb/v20170320/examples.json +16 -0
  99. tccli/services/cdn/v20180606/api.json +4 -4
  100. tccli/services/ckafka/v20190819/api.json +29 -24
  101. tccli/services/domain/domain_client.py +114 -8
  102. tccli/services/domain/v20180808/api.json +174 -1
  103. tccli/services/domain/v20180808/examples.json +22 -0
  104. tccli/services/es/v20180416/api.json +12 -12
  105. tccli/services/es/v20180416/examples.json +21 -21
  106. tccli/services/ess/ess_client.py +149 -43
  107. tccli/services/ess/v20201111/api.json +214 -4
  108. tccli/services/ess/v20201111/examples.json +34 -0
  109. tccli/services/essbasic/v20210526/api.json +2 -2
  110. tccli/services/faceid/v20180301/api.json +10 -1
  111. tccli/services/hunyuan/v20230901/api.json +67 -21
  112. tccli/services/hunyuan/v20230901/examples.json +17 -5
  113. tccli/services/iai/v20180301/api.json +19 -19
  114. tccli/services/lke/__init__.py +4 -0
  115. tccli/services/lke/lke_client.py +4117 -0
  116. tccli/services/lke/v20231130/api.json +9010 -0
  117. tccli/services/lke/v20231130/examples.json +617 -0
  118. tccli/services/mna/v20210119/api.json +249 -29
  119. tccli/services/mna/v20210119/examples.json +7 -1
  120. tccli/services/monitor/v20180724/api.json +30 -10
  121. tccli/services/ocr/v20181119/api.json +5 -0
  122. tccli/services/ocr/v20181119/examples.json +1 -1
  123. tccli/services/redis/v20180412/api.json +1 -1
  124. tccli/services/scf/v20180416/api.json +18 -9
  125. tccli/services/sms/v20210111/api.json +1 -1
  126. tccli/services/sqlserver/sqlserver_client.py +110 -57
  127. tccli/services/sqlserver/v20180328/api.json +63 -0
  128. tccli/services/sqlserver/v20180328/examples.json +8 -0
  129. tccli/services/tione/v20211111/api.json +25 -1
  130. tccli/services/trtc/v20190722/api.json +46 -4
  131. tccli/services/wedata/v20210820/api.json +295 -1437
  132. tccli/services/wedata/v20210820/examples.json +0 -88
  133. tccli/services/wedata/wedata_client.py +33 -616
  134. {tccli-3.0.1091.1.dist-info → tccli-3.0.1092.1.dist-info}/METADATA +2 -2
  135. {tccli-3.0.1091.1.dist-info → tccli-3.0.1092.1.dist-info}/RECORD +138 -52
  136. {tccli-3.0.1091.1.dist-info → tccli-3.0.1092.1.dist-info}/WHEEL +0 -0
  137. {tccli-3.0.1091.1.dist-info → tccli-3.0.1092.1.dist-info}/entry_points.txt +0 -0
  138. {tccli-3.0.1091.1.dist-info → tccli-3.0.1092.1.dist-info}/license_files/LICENSE +0 -0
@@ -0,0 +1,4117 @@
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.lke.v20231130 import lke_client as lke_client_v20231130
15
+ from tencentcloud.lke.v20231130 import models as models_v20231130
16
+
17
+ from jmespath import search
18
+ import time
19
+
20
+ def doGetWsToken(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
47
+ client._sdkVersion += ("_CLI_" + __version__)
48
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
49
+ model = models.GetWsTokenRequest()
50
+ model.from_json_string(json.dumps(args))
51
+ start_time = time.time()
52
+ while True:
53
+ rsp = client.GetWsToken(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 doModifyQA(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
99
+ client._sdkVersion += ("_CLI_" + __version__)
100
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
101
+ model = models.ModifyQARequest()
102
+ model.from_json_string(json.dumps(args))
103
+ start_time = time.time()
104
+ while True:
105
+ rsp = client.ModifyQA(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 doListUnsatisfiedReply(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
151
+ client._sdkVersion += ("_CLI_" + __version__)
152
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
153
+ model = models.ListUnsatisfiedReplyRequest()
154
+ model.from_json_string(json.dumps(args))
155
+ start_time = time.time()
156
+ while True:
157
+ rsp = client.ListUnsatisfiedReply(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 doDeleteAttributeLabel(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
203
+ client._sdkVersion += ("_CLI_" + __version__)
204
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
205
+ model = models.DeleteAttributeLabelRequest()
206
+ model.from_json_string(json.dumps(args))
207
+ start_time = time.time()
208
+ while True:
209
+ rsp = client.DeleteAttributeLabel(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 doSaveDoc(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
255
+ client._sdkVersion += ("_CLI_" + __version__)
256
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
257
+ model = models.SaveDocRequest()
258
+ model.from_json_string(json.dumps(args))
259
+ start_time = time.time()
260
+ while True:
261
+ rsp = client.SaveDoc(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 doCreateRejectedQuestion(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
307
+ client._sdkVersion += ("_CLI_" + __version__)
308
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
309
+ model = models.CreateRejectedQuestionRequest()
310
+ model.from_json_string(json.dumps(args))
311
+ start_time = time.time()
312
+ while True:
313
+ rsp = client.CreateRejectedQuestion(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 doCheckAttributeLabelExist(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
359
+ client._sdkVersion += ("_CLI_" + __version__)
360
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
361
+ model = models.CheckAttributeLabelExistRequest()
362
+ model.from_json_string(json.dumps(args))
363
+ start_time = time.time()
364
+ while True:
365
+ rsp = client.CheckAttributeLabelExist(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 doModifyQAAttrRange(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.LkeClient(cred, g_param[OptionsDefine.Region], profile)
411
+ client._sdkVersion += ("_CLI_" + __version__)
412
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
413
+ model = models.ModifyQAAttrRangeRequest()
414
+ model.from_json_string(json.dumps(args))
415
+ start_time = time.time()
416
+ while True:
417
+ rsp = client.ModifyQAAttrRange(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 doDescribeDoc(args, parsed_globals):
437
+ g_param = parse_global_arg(parsed_globals)
438
+
439
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
440
+ cred = credential.CVMRoleCredential()
441
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
442
+ cred = credential.STSAssumeRoleCredential(
443
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
444
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
445
+ )
446
+ 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):
447
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
448
+ else:
449
+ cred = credential.Credential(
450
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
451
+ )
452
+ http_profile = HttpProfile(
453
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
454
+ reqMethod="POST",
455
+ endpoint=g_param[OptionsDefine.Endpoint],
456
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
457
+ )
458
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
459
+ if g_param[OptionsDefine.Language]:
460
+ profile.language = g_param[OptionsDefine.Language]
461
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
462
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
463
+ client._sdkVersion += ("_CLI_" + __version__)
464
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
465
+ model = models.DescribeDocRequest()
466
+ model.from_json_string(json.dumps(args))
467
+ start_time = time.time()
468
+ while True:
469
+ rsp = client.DescribeDoc(model)
470
+ result = rsp.to_json_string()
471
+ try:
472
+ json_obj = json.loads(result)
473
+ except TypeError as e:
474
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
475
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
476
+ break
477
+ cur_time = time.time()
478
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
479
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
480
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
481
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
482
+ else:
483
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
484
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
485
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
486
+
487
+
488
+ def doDeleteRejectedQuestion(args, parsed_globals):
489
+ g_param = parse_global_arg(parsed_globals)
490
+
491
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
492
+ cred = credential.CVMRoleCredential()
493
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
494
+ cred = credential.STSAssumeRoleCredential(
495
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
496
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
497
+ )
498
+ 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):
499
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
500
+ else:
501
+ cred = credential.Credential(
502
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
503
+ )
504
+ http_profile = HttpProfile(
505
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
506
+ reqMethod="POST",
507
+ endpoint=g_param[OptionsDefine.Endpoint],
508
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
509
+ )
510
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
511
+ if g_param[OptionsDefine.Language]:
512
+ profile.language = g_param[OptionsDefine.Language]
513
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
514
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
515
+ client._sdkVersion += ("_CLI_" + __version__)
516
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
517
+ model = models.DeleteRejectedQuestionRequest()
518
+ model.from_json_string(json.dumps(args))
519
+ start_time = time.time()
520
+ while True:
521
+ rsp = client.DeleteRejectedQuestion(model)
522
+ result = rsp.to_json_string()
523
+ try:
524
+ json_obj = json.loads(result)
525
+ except TypeError as e:
526
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
527
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
528
+ break
529
+ cur_time = time.time()
530
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
531
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
532
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
533
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
534
+ else:
535
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
536
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
537
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
538
+
539
+
540
+ def doListSelectDoc(args, parsed_globals):
541
+ g_param = parse_global_arg(parsed_globals)
542
+
543
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
544
+ cred = credential.CVMRoleCredential()
545
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
546
+ cred = credential.STSAssumeRoleCredential(
547
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
548
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
549
+ )
550
+ 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):
551
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
552
+ else:
553
+ cred = credential.Credential(
554
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
555
+ )
556
+ http_profile = HttpProfile(
557
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
558
+ reqMethod="POST",
559
+ endpoint=g_param[OptionsDefine.Endpoint],
560
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
561
+ )
562
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
563
+ if g_param[OptionsDefine.Language]:
564
+ profile.language = g_param[OptionsDefine.Language]
565
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
566
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
567
+ client._sdkVersion += ("_CLI_" + __version__)
568
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
569
+ model = models.ListSelectDocRequest()
570
+ model.from_json_string(json.dumps(args))
571
+ start_time = time.time()
572
+ while True:
573
+ rsp = client.ListSelectDoc(model)
574
+ result = rsp.to_json_string()
575
+ try:
576
+ json_obj = json.loads(result)
577
+ except TypeError as e:
578
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
579
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
580
+ break
581
+ cur_time = time.time()
582
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
583
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
584
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
585
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
586
+ else:
587
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
588
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
589
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
590
+
591
+
592
+ def doQueryRewrite(args, parsed_globals):
593
+ g_param = parse_global_arg(parsed_globals)
594
+
595
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
596
+ cred = credential.CVMRoleCredential()
597
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
598
+ cred = credential.STSAssumeRoleCredential(
599
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
600
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
601
+ )
602
+ 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):
603
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
604
+ else:
605
+ cred = credential.Credential(
606
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
607
+ )
608
+ http_profile = HttpProfile(
609
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
610
+ reqMethod="POST",
611
+ endpoint=g_param[OptionsDefine.Endpoint],
612
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
613
+ )
614
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
615
+ if g_param[OptionsDefine.Language]:
616
+ profile.language = g_param[OptionsDefine.Language]
617
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
618
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
619
+ client._sdkVersion += ("_CLI_" + __version__)
620
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
621
+ model = models.QueryRewriteRequest()
622
+ model.from_json_string(json.dumps(args))
623
+ start_time = time.time()
624
+ while True:
625
+ rsp = client.QueryRewrite(model)
626
+ result = rsp.to_json_string()
627
+ try:
628
+ json_obj = json.loads(result)
629
+ except TypeError as e:
630
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
631
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
632
+ break
633
+ cur_time = time.time()
634
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
635
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
636
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
637
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
638
+ else:
639
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
640
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
641
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
642
+
643
+
644
+ def doDescribeUnsatisfiedReplyContext(args, parsed_globals):
645
+ g_param = parse_global_arg(parsed_globals)
646
+
647
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
648
+ cred = credential.CVMRoleCredential()
649
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
650
+ cred = credential.STSAssumeRoleCredential(
651
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
652
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
653
+ )
654
+ 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):
655
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
656
+ else:
657
+ cred = credential.Credential(
658
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
659
+ )
660
+ http_profile = HttpProfile(
661
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
662
+ reqMethod="POST",
663
+ endpoint=g_param[OptionsDefine.Endpoint],
664
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
665
+ )
666
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
667
+ if g_param[OptionsDefine.Language]:
668
+ profile.language = g_param[OptionsDefine.Language]
669
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
670
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
671
+ client._sdkVersion += ("_CLI_" + __version__)
672
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
673
+ model = models.DescribeUnsatisfiedReplyContextRequest()
674
+ model.from_json_string(json.dumps(args))
675
+ start_time = time.time()
676
+ while True:
677
+ rsp = client.DescribeUnsatisfiedReplyContext(model)
678
+ result = rsp.to_json_string()
679
+ try:
680
+ json_obj = json.loads(result)
681
+ except TypeError as e:
682
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
683
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
684
+ break
685
+ cur_time = time.time()
686
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
687
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
688
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
689
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
690
+ else:
691
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
692
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
693
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
694
+
695
+
696
+ def doModifyDocAttrRange(args, parsed_globals):
697
+ g_param = parse_global_arg(parsed_globals)
698
+
699
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
700
+ cred = credential.CVMRoleCredential()
701
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
702
+ cred = credential.STSAssumeRoleCredential(
703
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
704
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
705
+ )
706
+ 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):
707
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
708
+ else:
709
+ cred = credential.Credential(
710
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
711
+ )
712
+ http_profile = HttpProfile(
713
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
714
+ reqMethod="POST",
715
+ endpoint=g_param[OptionsDefine.Endpoint],
716
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
717
+ )
718
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
719
+ if g_param[OptionsDefine.Language]:
720
+ profile.language = g_param[OptionsDefine.Language]
721
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
722
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
723
+ client._sdkVersion += ("_CLI_" + __version__)
724
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
725
+ model = models.ModifyDocAttrRangeRequest()
726
+ model.from_json_string(json.dumps(args))
727
+ start_time = time.time()
728
+ while True:
729
+ rsp = client.ModifyDocAttrRange(model)
730
+ result = rsp.to_json_string()
731
+ try:
732
+ json_obj = json.loads(result)
733
+ except TypeError as e:
734
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
735
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
736
+ break
737
+ cur_time = time.time()
738
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
739
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
740
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
741
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
742
+ else:
743
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
744
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
745
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
746
+
747
+
748
+ def doListQA(args, parsed_globals):
749
+ g_param = parse_global_arg(parsed_globals)
750
+
751
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
752
+ cred = credential.CVMRoleCredential()
753
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
754
+ cred = credential.STSAssumeRoleCredential(
755
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
756
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
757
+ )
758
+ 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):
759
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
760
+ else:
761
+ cred = credential.Credential(
762
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
763
+ )
764
+ http_profile = HttpProfile(
765
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
766
+ reqMethod="POST",
767
+ endpoint=g_param[OptionsDefine.Endpoint],
768
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
769
+ )
770
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
771
+ if g_param[OptionsDefine.Language]:
772
+ profile.language = g_param[OptionsDefine.Language]
773
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
774
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
775
+ client._sdkVersion += ("_CLI_" + __version__)
776
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
777
+ model = models.ListQARequest()
778
+ model.from_json_string(json.dumps(args))
779
+ start_time = time.time()
780
+ while True:
781
+ rsp = client.ListQA(model)
782
+ result = rsp.to_json_string()
783
+ try:
784
+ json_obj = json.loads(result)
785
+ except TypeError as e:
786
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
787
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
788
+ break
789
+ cur_time = time.time()
790
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
791
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
792
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
793
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
794
+ else:
795
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
796
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
797
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
798
+
799
+
800
+ def doDeleteDoc(args, parsed_globals):
801
+ g_param = parse_global_arg(parsed_globals)
802
+
803
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
804
+ cred = credential.CVMRoleCredential()
805
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
806
+ cred = credential.STSAssumeRoleCredential(
807
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
808
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
809
+ )
810
+ 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):
811
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
812
+ else:
813
+ cred = credential.Credential(
814
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
815
+ )
816
+ http_profile = HttpProfile(
817
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
818
+ reqMethod="POST",
819
+ endpoint=g_param[OptionsDefine.Endpoint],
820
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
821
+ )
822
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
823
+ if g_param[OptionsDefine.Language]:
824
+ profile.language = g_param[OptionsDefine.Language]
825
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
826
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
827
+ client._sdkVersion += ("_CLI_" + __version__)
828
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
829
+ model = models.DeleteDocRequest()
830
+ model.from_json_string(json.dumps(args))
831
+ start_time = time.time()
832
+ while True:
833
+ rsp = client.DeleteDoc(model)
834
+ result = rsp.to_json_string()
835
+ try:
836
+ json_obj = json.loads(result)
837
+ except TypeError as e:
838
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
839
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
840
+ break
841
+ cur_time = time.time()
842
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
843
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
844
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
845
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
846
+ else:
847
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
848
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
849
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
850
+
851
+
852
+ def doCreateRelease(args, parsed_globals):
853
+ g_param = parse_global_arg(parsed_globals)
854
+
855
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
856
+ cred = credential.CVMRoleCredential()
857
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
858
+ cred = credential.STSAssumeRoleCredential(
859
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
860
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
861
+ )
862
+ 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):
863
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
864
+ else:
865
+ cred = credential.Credential(
866
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
867
+ )
868
+ http_profile = HttpProfile(
869
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
870
+ reqMethod="POST",
871
+ endpoint=g_param[OptionsDefine.Endpoint],
872
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
873
+ )
874
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
875
+ if g_param[OptionsDefine.Language]:
876
+ profile.language = g_param[OptionsDefine.Language]
877
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
878
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
879
+ client._sdkVersion += ("_CLI_" + __version__)
880
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
881
+ model = models.CreateReleaseRequest()
882
+ model.from_json_string(json.dumps(args))
883
+ start_time = time.time()
884
+ while True:
885
+ rsp = client.CreateRelease(model)
886
+ result = rsp.to_json_string()
887
+ try:
888
+ json_obj = json.loads(result)
889
+ except TypeError as e:
890
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
891
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
892
+ break
893
+ cur_time = time.time()
894
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
895
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
896
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
897
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
898
+ else:
899
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
900
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
901
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
902
+
903
+
904
+ def doGetEmbedding(args, parsed_globals):
905
+ g_param = parse_global_arg(parsed_globals)
906
+
907
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
908
+ cred = credential.CVMRoleCredential()
909
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
910
+ cred = credential.STSAssumeRoleCredential(
911
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
912
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
913
+ )
914
+ 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):
915
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
916
+ else:
917
+ cred = credential.Credential(
918
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
919
+ )
920
+ http_profile = HttpProfile(
921
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
922
+ reqMethod="POST",
923
+ endpoint=g_param[OptionsDefine.Endpoint],
924
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
925
+ )
926
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
927
+ if g_param[OptionsDefine.Language]:
928
+ profile.language = g_param[OptionsDefine.Language]
929
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
930
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
931
+ client._sdkVersion += ("_CLI_" + __version__)
932
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
933
+ model = models.GetEmbeddingRequest()
934
+ model.from_json_string(json.dumps(args))
935
+ start_time = time.time()
936
+ while True:
937
+ rsp = client.GetEmbedding(model)
938
+ result = rsp.to_json_string()
939
+ try:
940
+ json_obj = json.loads(result)
941
+ except TypeError as e:
942
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
943
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
944
+ break
945
+ cur_time = time.time()
946
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
947
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
948
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
949
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
950
+ else:
951
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
952
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
953
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
954
+
955
+
956
+ def doGetAppSecret(args, parsed_globals):
957
+ g_param = parse_global_arg(parsed_globals)
958
+
959
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
960
+ cred = credential.CVMRoleCredential()
961
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
962
+ cred = credential.STSAssumeRoleCredential(
963
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
964
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
965
+ )
966
+ 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):
967
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
968
+ else:
969
+ cred = credential.Credential(
970
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
971
+ )
972
+ http_profile = HttpProfile(
973
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
974
+ reqMethod="POST",
975
+ endpoint=g_param[OptionsDefine.Endpoint],
976
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
977
+ )
978
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
979
+ if g_param[OptionsDefine.Language]:
980
+ profile.language = g_param[OptionsDefine.Language]
981
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
982
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
983
+ client._sdkVersion += ("_CLI_" + __version__)
984
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
985
+ model = models.GetAppSecretRequest()
986
+ model.from_json_string(json.dumps(args))
987
+ start_time = time.time()
988
+ while True:
989
+ rsp = client.GetAppSecret(model)
990
+ result = rsp.to_json_string()
991
+ try:
992
+ json_obj = json.loads(result)
993
+ except TypeError as e:
994
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
995
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
996
+ break
997
+ cur_time = time.time()
998
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
999
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1000
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1001
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1002
+ else:
1003
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1004
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1005
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1006
+
1007
+
1008
+ def doModifyAttributeLabel(args, parsed_globals):
1009
+ g_param = parse_global_arg(parsed_globals)
1010
+
1011
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1012
+ cred = credential.CVMRoleCredential()
1013
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1014
+ cred = credential.STSAssumeRoleCredential(
1015
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1016
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1017
+ )
1018
+ 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):
1019
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1020
+ else:
1021
+ cred = credential.Credential(
1022
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1023
+ )
1024
+ http_profile = HttpProfile(
1025
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1026
+ reqMethod="POST",
1027
+ endpoint=g_param[OptionsDefine.Endpoint],
1028
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1029
+ )
1030
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1031
+ if g_param[OptionsDefine.Language]:
1032
+ profile.language = g_param[OptionsDefine.Language]
1033
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1034
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1035
+ client._sdkVersion += ("_CLI_" + __version__)
1036
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1037
+ model = models.ModifyAttributeLabelRequest()
1038
+ model.from_json_string(json.dumps(args))
1039
+ start_time = time.time()
1040
+ while True:
1041
+ rsp = client.ModifyAttributeLabel(model)
1042
+ result = rsp.to_json_string()
1043
+ try:
1044
+ json_obj = json.loads(result)
1045
+ except TypeError as e:
1046
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1047
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1048
+ break
1049
+ cur_time = time.time()
1050
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1051
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1052
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1053
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1054
+ else:
1055
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1056
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1057
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1058
+
1059
+
1060
+ def doRateMsgRecord(args, parsed_globals):
1061
+ g_param = parse_global_arg(parsed_globals)
1062
+
1063
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1064
+ cred = credential.CVMRoleCredential()
1065
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1066
+ cred = credential.STSAssumeRoleCredential(
1067
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1068
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1069
+ )
1070
+ 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):
1071
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1072
+ else:
1073
+ cred = credential.Credential(
1074
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1075
+ )
1076
+ http_profile = HttpProfile(
1077
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1078
+ reqMethod="POST",
1079
+ endpoint=g_param[OptionsDefine.Endpoint],
1080
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1081
+ )
1082
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1083
+ if g_param[OptionsDefine.Language]:
1084
+ profile.language = g_param[OptionsDefine.Language]
1085
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1086
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1087
+ client._sdkVersion += ("_CLI_" + __version__)
1088
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1089
+ model = models.RateMsgRecordRequest()
1090
+ model.from_json_string(json.dumps(args))
1091
+ start_time = time.time()
1092
+ while True:
1093
+ rsp = client.RateMsgRecord(model)
1094
+ result = rsp.to_json_string()
1095
+ try:
1096
+ json_obj = json.loads(result)
1097
+ except TypeError as e:
1098
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1099
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1100
+ break
1101
+ cur_time = time.time()
1102
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1103
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1104
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1105
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1106
+ else:
1107
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1108
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1109
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1110
+
1111
+
1112
+ def doDescribeStorageCredential(args, parsed_globals):
1113
+ g_param = parse_global_arg(parsed_globals)
1114
+
1115
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1116
+ cred = credential.CVMRoleCredential()
1117
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1118
+ cred = credential.STSAssumeRoleCredential(
1119
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1120
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1121
+ )
1122
+ 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):
1123
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1124
+ else:
1125
+ cred = credential.Credential(
1126
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1127
+ )
1128
+ http_profile = HttpProfile(
1129
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1130
+ reqMethod="POST",
1131
+ endpoint=g_param[OptionsDefine.Endpoint],
1132
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1133
+ )
1134
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1135
+ if g_param[OptionsDefine.Language]:
1136
+ profile.language = g_param[OptionsDefine.Language]
1137
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1138
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1139
+ client._sdkVersion += ("_CLI_" + __version__)
1140
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1141
+ model = models.DescribeStorageCredentialRequest()
1142
+ model.from_json_string(json.dumps(args))
1143
+ start_time = time.time()
1144
+ while True:
1145
+ rsp = client.DescribeStorageCredential(model)
1146
+ result = rsp.to_json_string()
1147
+ try:
1148
+ json_obj = json.loads(result)
1149
+ except TypeError as e:
1150
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1151
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1152
+ break
1153
+ cur_time = time.time()
1154
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1155
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1156
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1157
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1158
+ else:
1159
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1160
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1161
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1162
+
1163
+
1164
+ def doDeleteQA(args, parsed_globals):
1165
+ g_param = parse_global_arg(parsed_globals)
1166
+
1167
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1168
+ cred = credential.CVMRoleCredential()
1169
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1170
+ cred = credential.STSAssumeRoleCredential(
1171
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1172
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1173
+ )
1174
+ 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):
1175
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1176
+ else:
1177
+ cred = credential.Credential(
1178
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1179
+ )
1180
+ http_profile = HttpProfile(
1181
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1182
+ reqMethod="POST",
1183
+ endpoint=g_param[OptionsDefine.Endpoint],
1184
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1185
+ )
1186
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1187
+ if g_param[OptionsDefine.Language]:
1188
+ profile.language = g_param[OptionsDefine.Language]
1189
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1190
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1191
+ client._sdkVersion += ("_CLI_" + __version__)
1192
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1193
+ model = models.DeleteQARequest()
1194
+ model.from_json_string(json.dumps(args))
1195
+ start_time = time.time()
1196
+ while True:
1197
+ rsp = client.DeleteQA(model)
1198
+ result = rsp.to_json_string()
1199
+ try:
1200
+ json_obj = json.loads(result)
1201
+ except TypeError as e:
1202
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1203
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1204
+ break
1205
+ cur_time = time.time()
1206
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1207
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1208
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1209
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1210
+ else:
1211
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1212
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1213
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1214
+
1215
+
1216
+ def doDescribeRobotBizIDByAppKey(args, parsed_globals):
1217
+ g_param = parse_global_arg(parsed_globals)
1218
+
1219
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1220
+ cred = credential.CVMRoleCredential()
1221
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1222
+ cred = credential.STSAssumeRoleCredential(
1223
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1224
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1225
+ )
1226
+ 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):
1227
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1228
+ else:
1229
+ cred = credential.Credential(
1230
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1231
+ )
1232
+ http_profile = HttpProfile(
1233
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1234
+ reqMethod="POST",
1235
+ endpoint=g_param[OptionsDefine.Endpoint],
1236
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1237
+ )
1238
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1239
+ if g_param[OptionsDefine.Language]:
1240
+ profile.language = g_param[OptionsDefine.Language]
1241
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1242
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1243
+ client._sdkVersion += ("_CLI_" + __version__)
1244
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1245
+ model = models.DescribeRobotBizIDByAppKeyRequest()
1246
+ model.from_json_string(json.dumps(args))
1247
+ start_time = time.time()
1248
+ while True:
1249
+ rsp = client.DescribeRobotBizIDByAppKey(model)
1250
+ result = rsp.to_json_string()
1251
+ try:
1252
+ json_obj = json.loads(result)
1253
+ except TypeError as e:
1254
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1255
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1256
+ break
1257
+ cur_time = time.time()
1258
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1259
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1260
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1261
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1262
+ else:
1263
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1264
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1265
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1266
+
1267
+
1268
+ def doListReleaseQAPreview(args, parsed_globals):
1269
+ g_param = parse_global_arg(parsed_globals)
1270
+
1271
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1272
+ cred = credential.CVMRoleCredential()
1273
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1274
+ cred = credential.STSAssumeRoleCredential(
1275
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1276
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1277
+ )
1278
+ 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):
1279
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1280
+ else:
1281
+ cred = credential.Credential(
1282
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1283
+ )
1284
+ http_profile = HttpProfile(
1285
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1286
+ reqMethod="POST",
1287
+ endpoint=g_param[OptionsDefine.Endpoint],
1288
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1289
+ )
1290
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1291
+ if g_param[OptionsDefine.Language]:
1292
+ profile.language = g_param[OptionsDefine.Language]
1293
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1294
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1295
+ client._sdkVersion += ("_CLI_" + __version__)
1296
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1297
+ model = models.ListReleaseQAPreviewRequest()
1298
+ model.from_json_string(json.dumps(args))
1299
+ start_time = time.time()
1300
+ while True:
1301
+ rsp = client.ListReleaseQAPreview(model)
1302
+ result = rsp.to_json_string()
1303
+ try:
1304
+ json_obj = json.loads(result)
1305
+ except TypeError as e:
1306
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1307
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1308
+ break
1309
+ cur_time = time.time()
1310
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1311
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1312
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1313
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1314
+ else:
1315
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1316
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1317
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1318
+
1319
+
1320
+ def doExportQAList(args, parsed_globals):
1321
+ g_param = parse_global_arg(parsed_globals)
1322
+
1323
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1324
+ cred = credential.CVMRoleCredential()
1325
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1326
+ cred = credential.STSAssumeRoleCredential(
1327
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1328
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1329
+ )
1330
+ 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):
1331
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1332
+ else:
1333
+ cred = credential.Credential(
1334
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1335
+ )
1336
+ http_profile = HttpProfile(
1337
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1338
+ reqMethod="POST",
1339
+ endpoint=g_param[OptionsDefine.Endpoint],
1340
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1341
+ )
1342
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1343
+ if g_param[OptionsDefine.Language]:
1344
+ profile.language = g_param[OptionsDefine.Language]
1345
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1346
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1347
+ client._sdkVersion += ("_CLI_" + __version__)
1348
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1349
+ model = models.ExportQAListRequest()
1350
+ model.from_json_string(json.dumps(args))
1351
+ start_time = time.time()
1352
+ while True:
1353
+ rsp = client.ExportQAList(model)
1354
+ result = rsp.to_json_string()
1355
+ try:
1356
+ json_obj = json.loads(result)
1357
+ except TypeError as e:
1358
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1359
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1360
+ break
1361
+ cur_time = time.time()
1362
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1363
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1364
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1365
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1366
+ else:
1367
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1368
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1369
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1370
+
1371
+
1372
+ def doModifyQACate(args, parsed_globals):
1373
+ g_param = parse_global_arg(parsed_globals)
1374
+
1375
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1376
+ cred = credential.CVMRoleCredential()
1377
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1378
+ cred = credential.STSAssumeRoleCredential(
1379
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1380
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1381
+ )
1382
+ 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):
1383
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1384
+ else:
1385
+ cred = credential.Credential(
1386
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1387
+ )
1388
+ http_profile = HttpProfile(
1389
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1390
+ reqMethod="POST",
1391
+ endpoint=g_param[OptionsDefine.Endpoint],
1392
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1393
+ )
1394
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1395
+ if g_param[OptionsDefine.Language]:
1396
+ profile.language = g_param[OptionsDefine.Language]
1397
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1398
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1399
+ client._sdkVersion += ("_CLI_" + __version__)
1400
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1401
+ model = models.ModifyQACateRequest()
1402
+ model.from_json_string(json.dumps(args))
1403
+ start_time = time.time()
1404
+ while True:
1405
+ rsp = client.ModifyQACate(model)
1406
+ result = rsp.to_json_string()
1407
+ try:
1408
+ json_obj = json.loads(result)
1409
+ except TypeError as e:
1410
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1411
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1412
+ break
1413
+ cur_time = time.time()
1414
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1415
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1416
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1417
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1418
+ else:
1419
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1420
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1421
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1422
+
1423
+
1424
+ def doDeleteApp(args, parsed_globals):
1425
+ g_param = parse_global_arg(parsed_globals)
1426
+
1427
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1428
+ cred = credential.CVMRoleCredential()
1429
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1430
+ cred = credential.STSAssumeRoleCredential(
1431
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1432
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1433
+ )
1434
+ 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):
1435
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1436
+ else:
1437
+ cred = credential.Credential(
1438
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1439
+ )
1440
+ http_profile = HttpProfile(
1441
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1442
+ reqMethod="POST",
1443
+ endpoint=g_param[OptionsDefine.Endpoint],
1444
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1445
+ )
1446
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1447
+ if g_param[OptionsDefine.Language]:
1448
+ profile.language = g_param[OptionsDefine.Language]
1449
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1450
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1451
+ client._sdkVersion += ("_CLI_" + __version__)
1452
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1453
+ model = models.DeleteAppRequest()
1454
+ model.from_json_string(json.dumps(args))
1455
+ start_time = time.time()
1456
+ while True:
1457
+ rsp = client.DeleteApp(model)
1458
+ result = rsp.to_json_string()
1459
+ try:
1460
+ json_obj = json.loads(result)
1461
+ except TypeError as e:
1462
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1463
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1464
+ break
1465
+ cur_time = time.time()
1466
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1467
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1468
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1469
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1470
+ else:
1471
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1472
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1473
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1474
+
1475
+
1476
+ def doModifyApp(args, parsed_globals):
1477
+ g_param = parse_global_arg(parsed_globals)
1478
+
1479
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1480
+ cred = credential.CVMRoleCredential()
1481
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1482
+ cred = credential.STSAssumeRoleCredential(
1483
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1484
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1485
+ )
1486
+ 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):
1487
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1488
+ else:
1489
+ cred = credential.Credential(
1490
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1491
+ )
1492
+ http_profile = HttpProfile(
1493
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1494
+ reqMethod="POST",
1495
+ endpoint=g_param[OptionsDefine.Endpoint],
1496
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1497
+ )
1498
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1499
+ if g_param[OptionsDefine.Language]:
1500
+ profile.language = g_param[OptionsDefine.Language]
1501
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1502
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1503
+ client._sdkVersion += ("_CLI_" + __version__)
1504
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1505
+ model = models.ModifyAppRequest()
1506
+ model.from_json_string(json.dumps(args))
1507
+ start_time = time.time()
1508
+ while True:
1509
+ rsp = client.ModifyApp(model)
1510
+ result = rsp.to_json_string()
1511
+ try:
1512
+ json_obj = json.loads(result)
1513
+ except TypeError as e:
1514
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1515
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1516
+ break
1517
+ cur_time = time.time()
1518
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1519
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1520
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1521
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1522
+ else:
1523
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1524
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1525
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1526
+
1527
+
1528
+ def doIgnoreUnsatisfiedReply(args, parsed_globals):
1529
+ g_param = parse_global_arg(parsed_globals)
1530
+
1531
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1532
+ cred = credential.CVMRoleCredential()
1533
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1534
+ cred = credential.STSAssumeRoleCredential(
1535
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1536
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1537
+ )
1538
+ 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):
1539
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1540
+ else:
1541
+ cred = credential.Credential(
1542
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1543
+ )
1544
+ http_profile = HttpProfile(
1545
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1546
+ reqMethod="POST",
1547
+ endpoint=g_param[OptionsDefine.Endpoint],
1548
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1549
+ )
1550
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1551
+ if g_param[OptionsDefine.Language]:
1552
+ profile.language = g_param[OptionsDefine.Language]
1553
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1554
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1555
+ client._sdkVersion += ("_CLI_" + __version__)
1556
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1557
+ model = models.IgnoreUnsatisfiedReplyRequest()
1558
+ model.from_json_string(json.dumps(args))
1559
+ start_time = time.time()
1560
+ while True:
1561
+ rsp = client.IgnoreUnsatisfiedReply(model)
1562
+ result = rsp.to_json_string()
1563
+ try:
1564
+ json_obj = json.loads(result)
1565
+ except TypeError as e:
1566
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1567
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1568
+ break
1569
+ cur_time = time.time()
1570
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1571
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1572
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1573
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1574
+ else:
1575
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1576
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1577
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1578
+
1579
+
1580
+ def doCheckAttributeLabelRefer(args, parsed_globals):
1581
+ g_param = parse_global_arg(parsed_globals)
1582
+
1583
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1584
+ cred = credential.CVMRoleCredential()
1585
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1586
+ cred = credential.STSAssumeRoleCredential(
1587
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1588
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1589
+ )
1590
+ 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):
1591
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1592
+ else:
1593
+ cred = credential.Credential(
1594
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1595
+ )
1596
+ http_profile = HttpProfile(
1597
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1598
+ reqMethod="POST",
1599
+ endpoint=g_param[OptionsDefine.Endpoint],
1600
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1601
+ )
1602
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1603
+ if g_param[OptionsDefine.Language]:
1604
+ profile.language = g_param[OptionsDefine.Language]
1605
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1606
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1607
+ client._sdkVersion += ("_CLI_" + __version__)
1608
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1609
+ model = models.CheckAttributeLabelReferRequest()
1610
+ model.from_json_string(json.dumps(args))
1611
+ start_time = time.time()
1612
+ while True:
1613
+ rsp = client.CheckAttributeLabelRefer(model)
1614
+ result = rsp.to_json_string()
1615
+ try:
1616
+ json_obj = json.loads(result)
1617
+ except TypeError as e:
1618
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1619
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1620
+ break
1621
+ cur_time = time.time()
1622
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1623
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1624
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1625
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1626
+ else:
1627
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1628
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1629
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1630
+
1631
+
1632
+ def doDescribeCorp(args, parsed_globals):
1633
+ g_param = parse_global_arg(parsed_globals)
1634
+
1635
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1636
+ cred = credential.CVMRoleCredential()
1637
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1638
+ cred = credential.STSAssumeRoleCredential(
1639
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1640
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1641
+ )
1642
+ 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):
1643
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1644
+ else:
1645
+ cred = credential.Credential(
1646
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1647
+ )
1648
+ http_profile = HttpProfile(
1649
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1650
+ reqMethod="POST",
1651
+ endpoint=g_param[OptionsDefine.Endpoint],
1652
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1653
+ )
1654
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1655
+ if g_param[OptionsDefine.Language]:
1656
+ profile.language = g_param[OptionsDefine.Language]
1657
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1658
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1659
+ client._sdkVersion += ("_CLI_" + __version__)
1660
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1661
+ model = models.DescribeCorpRequest()
1662
+ model.from_json_string(json.dumps(args))
1663
+ start_time = time.time()
1664
+ while True:
1665
+ rsp = client.DescribeCorp(model)
1666
+ result = rsp.to_json_string()
1667
+ try:
1668
+ json_obj = json.loads(result)
1669
+ except TypeError as e:
1670
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1671
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1672
+ break
1673
+ cur_time = time.time()
1674
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1675
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1676
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1677
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1678
+ else:
1679
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1680
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1681
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1682
+
1683
+
1684
+ def doCreateAttributeLabel(args, parsed_globals):
1685
+ g_param = parse_global_arg(parsed_globals)
1686
+
1687
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1688
+ cred = credential.CVMRoleCredential()
1689
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1690
+ cred = credential.STSAssumeRoleCredential(
1691
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1692
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1693
+ )
1694
+ 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):
1695
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1696
+ else:
1697
+ cred = credential.Credential(
1698
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1699
+ )
1700
+ http_profile = HttpProfile(
1701
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1702
+ reqMethod="POST",
1703
+ endpoint=g_param[OptionsDefine.Endpoint],
1704
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1705
+ )
1706
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1707
+ if g_param[OptionsDefine.Language]:
1708
+ profile.language = g_param[OptionsDefine.Language]
1709
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1710
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1711
+ client._sdkVersion += ("_CLI_" + __version__)
1712
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1713
+ model = models.CreateAttributeLabelRequest()
1714
+ model.from_json_string(json.dumps(args))
1715
+ start_time = time.time()
1716
+ while True:
1717
+ rsp = client.CreateAttributeLabel(model)
1718
+ result = rsp.to_json_string()
1719
+ try:
1720
+ json_obj = json.loads(result)
1721
+ except TypeError as e:
1722
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1723
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1724
+ break
1725
+ cur_time = time.time()
1726
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1727
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1728
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1729
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1730
+ else:
1731
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1732
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1733
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1734
+
1735
+
1736
+ def doRetryDocAudit(args, parsed_globals):
1737
+ g_param = parse_global_arg(parsed_globals)
1738
+
1739
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1740
+ cred = credential.CVMRoleCredential()
1741
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1742
+ cred = credential.STSAssumeRoleCredential(
1743
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1744
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1745
+ )
1746
+ 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):
1747
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1748
+ else:
1749
+ cred = credential.Credential(
1750
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1751
+ )
1752
+ http_profile = HttpProfile(
1753
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1754
+ reqMethod="POST",
1755
+ endpoint=g_param[OptionsDefine.Endpoint],
1756
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1757
+ )
1758
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1759
+ if g_param[OptionsDefine.Language]:
1760
+ profile.language = g_param[OptionsDefine.Language]
1761
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1762
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1763
+ client._sdkVersion += ("_CLI_" + __version__)
1764
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1765
+ model = models.RetryDocAuditRequest()
1766
+ model.from_json_string(json.dumps(args))
1767
+ start_time = time.time()
1768
+ while True:
1769
+ rsp = client.RetryDocAudit(model)
1770
+ result = rsp.to_json_string()
1771
+ try:
1772
+ json_obj = json.loads(result)
1773
+ except TypeError as e:
1774
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1775
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1776
+ break
1777
+ cur_time = time.time()
1778
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1779
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1780
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1781
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1782
+ else:
1783
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1784
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1785
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1786
+
1787
+
1788
+ def doUploadAttributeLabel(args, parsed_globals):
1789
+ g_param = parse_global_arg(parsed_globals)
1790
+
1791
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1792
+ cred = credential.CVMRoleCredential()
1793
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1794
+ cred = credential.STSAssumeRoleCredential(
1795
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1796
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1797
+ )
1798
+ 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):
1799
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1800
+ else:
1801
+ cred = credential.Credential(
1802
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1803
+ )
1804
+ http_profile = HttpProfile(
1805
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1806
+ reqMethod="POST",
1807
+ endpoint=g_param[OptionsDefine.Endpoint],
1808
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1809
+ )
1810
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1811
+ if g_param[OptionsDefine.Language]:
1812
+ profile.language = g_param[OptionsDefine.Language]
1813
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1814
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1815
+ client._sdkVersion += ("_CLI_" + __version__)
1816
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1817
+ model = models.UploadAttributeLabelRequest()
1818
+ model.from_json_string(json.dumps(args))
1819
+ start_time = time.time()
1820
+ while True:
1821
+ rsp = client.UploadAttributeLabel(model)
1822
+ result = rsp.to_json_string()
1823
+ try:
1824
+ json_obj = json.loads(result)
1825
+ except TypeError as e:
1826
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1827
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1828
+ break
1829
+ cur_time = time.time()
1830
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1831
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1832
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1833
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1834
+ else:
1835
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1836
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1837
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1838
+
1839
+
1840
+ def doListApp(args, parsed_globals):
1841
+ g_param = parse_global_arg(parsed_globals)
1842
+
1843
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1844
+ cred = credential.CVMRoleCredential()
1845
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1846
+ cred = credential.STSAssumeRoleCredential(
1847
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1848
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1849
+ )
1850
+ 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):
1851
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1852
+ else:
1853
+ cred = credential.Credential(
1854
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1855
+ )
1856
+ http_profile = HttpProfile(
1857
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1858
+ reqMethod="POST",
1859
+ endpoint=g_param[OptionsDefine.Endpoint],
1860
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1861
+ )
1862
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1863
+ if g_param[OptionsDefine.Language]:
1864
+ profile.language = g_param[OptionsDefine.Language]
1865
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1866
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1867
+ client._sdkVersion += ("_CLI_" + __version__)
1868
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1869
+ model = models.ListAppRequest()
1870
+ model.from_json_string(json.dumps(args))
1871
+ start_time = time.time()
1872
+ while True:
1873
+ rsp = client.ListApp(model)
1874
+ result = rsp.to_json_string()
1875
+ try:
1876
+ json_obj = json.loads(result)
1877
+ except TypeError as e:
1878
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1879
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1880
+ break
1881
+ cur_time = time.time()
1882
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1883
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1884
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1885
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1886
+ else:
1887
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1888
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1889
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1890
+
1891
+
1892
+ def doGetDocPreview(args, parsed_globals):
1893
+ g_param = parse_global_arg(parsed_globals)
1894
+
1895
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1896
+ cred = credential.CVMRoleCredential()
1897
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1898
+ cred = credential.STSAssumeRoleCredential(
1899
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1900
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1901
+ )
1902
+ 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):
1903
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1904
+ else:
1905
+ cred = credential.Credential(
1906
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1907
+ )
1908
+ http_profile = HttpProfile(
1909
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1910
+ reqMethod="POST",
1911
+ endpoint=g_param[OptionsDefine.Endpoint],
1912
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1913
+ )
1914
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1915
+ if g_param[OptionsDefine.Language]:
1916
+ profile.language = g_param[OptionsDefine.Language]
1917
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1918
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1919
+ client._sdkVersion += ("_CLI_" + __version__)
1920
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1921
+ model = models.GetDocPreviewRequest()
1922
+ model.from_json_string(json.dumps(args))
1923
+ start_time = time.time()
1924
+ while True:
1925
+ rsp = client.GetDocPreview(model)
1926
+ result = rsp.to_json_string()
1927
+ try:
1928
+ json_obj = json.loads(result)
1929
+ except TypeError as e:
1930
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1931
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1932
+ break
1933
+ cur_time = time.time()
1934
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1935
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1936
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1937
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1938
+ else:
1939
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1940
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1941
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1942
+
1943
+
1944
+ def doListReleaseDocPreview(args, parsed_globals):
1945
+ g_param = parse_global_arg(parsed_globals)
1946
+
1947
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
1948
+ cred = credential.CVMRoleCredential()
1949
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
1950
+ cred = credential.STSAssumeRoleCredential(
1951
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
1952
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
1953
+ )
1954
+ 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):
1955
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
1956
+ else:
1957
+ cred = credential.Credential(
1958
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
1959
+ )
1960
+ http_profile = HttpProfile(
1961
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
1962
+ reqMethod="POST",
1963
+ endpoint=g_param[OptionsDefine.Endpoint],
1964
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
1965
+ )
1966
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
1967
+ if g_param[OptionsDefine.Language]:
1968
+ profile.language = g_param[OptionsDefine.Language]
1969
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
1970
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
1971
+ client._sdkVersion += ("_CLI_" + __version__)
1972
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
1973
+ model = models.ListReleaseDocPreviewRequest()
1974
+ model.from_json_string(json.dumps(args))
1975
+ start_time = time.time()
1976
+ while True:
1977
+ rsp = client.ListReleaseDocPreview(model)
1978
+ result = rsp.to_json_string()
1979
+ try:
1980
+ json_obj = json.loads(result)
1981
+ except TypeError as e:
1982
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
1983
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
1984
+ break
1985
+ cur_time = time.time()
1986
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
1987
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
1988
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
1989
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
1990
+ else:
1991
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
1992
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
1993
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
1994
+
1995
+
1996
+ def doModifyRejectedQuestion(args, parsed_globals):
1997
+ g_param = parse_global_arg(parsed_globals)
1998
+
1999
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2000
+ cred = credential.CVMRoleCredential()
2001
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2002
+ cred = credential.STSAssumeRoleCredential(
2003
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2004
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2005
+ )
2006
+ 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):
2007
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2008
+ else:
2009
+ cred = credential.Credential(
2010
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2011
+ )
2012
+ http_profile = HttpProfile(
2013
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2014
+ reqMethod="POST",
2015
+ endpoint=g_param[OptionsDefine.Endpoint],
2016
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2017
+ )
2018
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2019
+ if g_param[OptionsDefine.Language]:
2020
+ profile.language = g_param[OptionsDefine.Language]
2021
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2022
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2023
+ client._sdkVersion += ("_CLI_" + __version__)
2024
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2025
+ model = models.ModifyRejectedQuestionRequest()
2026
+ model.from_json_string(json.dumps(args))
2027
+ start_time = time.time()
2028
+ while True:
2029
+ rsp = client.ModifyRejectedQuestion(model)
2030
+ result = rsp.to_json_string()
2031
+ try:
2032
+ json_obj = json.loads(result)
2033
+ except TypeError as e:
2034
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2035
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2036
+ break
2037
+ cur_time = time.time()
2038
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2039
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2040
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2041
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2042
+ else:
2043
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2044
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2045
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2046
+
2047
+
2048
+ def doDescribeAttributeLabel(args, parsed_globals):
2049
+ g_param = parse_global_arg(parsed_globals)
2050
+
2051
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2052
+ cred = credential.CVMRoleCredential()
2053
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2054
+ cred = credential.STSAssumeRoleCredential(
2055
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2056
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2057
+ )
2058
+ 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):
2059
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2060
+ else:
2061
+ cred = credential.Credential(
2062
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2063
+ )
2064
+ http_profile = HttpProfile(
2065
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2066
+ reqMethod="POST",
2067
+ endpoint=g_param[OptionsDefine.Endpoint],
2068
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2069
+ )
2070
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2071
+ if g_param[OptionsDefine.Language]:
2072
+ profile.language = g_param[OptionsDefine.Language]
2073
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2074
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2075
+ client._sdkVersion += ("_CLI_" + __version__)
2076
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2077
+ model = models.DescribeAttributeLabelRequest()
2078
+ model.from_json_string(json.dumps(args))
2079
+ start_time = time.time()
2080
+ while True:
2081
+ rsp = client.DescribeAttributeLabel(model)
2082
+ result = rsp.to_json_string()
2083
+ try:
2084
+ json_obj = json.loads(result)
2085
+ except TypeError as e:
2086
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2087
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2088
+ break
2089
+ cur_time = time.time()
2090
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2091
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2092
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2093
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2094
+ else:
2095
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2096
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2097
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2098
+
2099
+
2100
+ def doDescribeRelease(args, parsed_globals):
2101
+ g_param = parse_global_arg(parsed_globals)
2102
+
2103
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2104
+ cred = credential.CVMRoleCredential()
2105
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2106
+ cred = credential.STSAssumeRoleCredential(
2107
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2108
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2109
+ )
2110
+ 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):
2111
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2112
+ else:
2113
+ cred = credential.Credential(
2114
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2115
+ )
2116
+ http_profile = HttpProfile(
2117
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2118
+ reqMethod="POST",
2119
+ endpoint=g_param[OptionsDefine.Endpoint],
2120
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2121
+ )
2122
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2123
+ if g_param[OptionsDefine.Language]:
2124
+ profile.language = g_param[OptionsDefine.Language]
2125
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2126
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2127
+ client._sdkVersion += ("_CLI_" + __version__)
2128
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2129
+ model = models.DescribeReleaseRequest()
2130
+ model.from_json_string(json.dumps(args))
2131
+ start_time = time.time()
2132
+ while True:
2133
+ rsp = client.DescribeRelease(model)
2134
+ result = rsp.to_json_string()
2135
+ try:
2136
+ json_obj = json.loads(result)
2137
+ except TypeError as e:
2138
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2139
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2140
+ break
2141
+ cur_time = time.time()
2142
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2143
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2144
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2145
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2146
+ else:
2147
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2148
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2149
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2150
+
2151
+
2152
+ def doDescribeApp(args, parsed_globals):
2153
+ g_param = parse_global_arg(parsed_globals)
2154
+
2155
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2156
+ cred = credential.CVMRoleCredential()
2157
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2158
+ cred = credential.STSAssumeRoleCredential(
2159
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2160
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2161
+ )
2162
+ 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):
2163
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2164
+ else:
2165
+ cred = credential.Credential(
2166
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2167
+ )
2168
+ http_profile = HttpProfile(
2169
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2170
+ reqMethod="POST",
2171
+ endpoint=g_param[OptionsDefine.Endpoint],
2172
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2173
+ )
2174
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2175
+ if g_param[OptionsDefine.Language]:
2176
+ profile.language = g_param[OptionsDefine.Language]
2177
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2178
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2179
+ client._sdkVersion += ("_CLI_" + __version__)
2180
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2181
+ model = models.DescribeAppRequest()
2182
+ model.from_json_string(json.dumps(args))
2183
+ start_time = time.time()
2184
+ while True:
2185
+ rsp = client.DescribeApp(model)
2186
+ result = rsp.to_json_string()
2187
+ try:
2188
+ json_obj = json.loads(result)
2189
+ except TypeError as e:
2190
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2191
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2192
+ break
2193
+ cur_time = time.time()
2194
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2195
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2196
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2197
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2198
+ else:
2199
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2200
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2201
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2202
+
2203
+
2204
+ def doRetryDocParse(args, parsed_globals):
2205
+ g_param = parse_global_arg(parsed_globals)
2206
+
2207
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2208
+ cred = credential.CVMRoleCredential()
2209
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2210
+ cred = credential.STSAssumeRoleCredential(
2211
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2212
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2213
+ )
2214
+ 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):
2215
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2216
+ else:
2217
+ cred = credential.Credential(
2218
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2219
+ )
2220
+ http_profile = HttpProfile(
2221
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2222
+ reqMethod="POST",
2223
+ endpoint=g_param[OptionsDefine.Endpoint],
2224
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2225
+ )
2226
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2227
+ if g_param[OptionsDefine.Language]:
2228
+ profile.language = g_param[OptionsDefine.Language]
2229
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2230
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2231
+ client._sdkVersion += ("_CLI_" + __version__)
2232
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2233
+ model = models.RetryDocParseRequest()
2234
+ model.from_json_string(json.dumps(args))
2235
+ start_time = time.time()
2236
+ while True:
2237
+ rsp = client.RetryDocParse(model)
2238
+ result = rsp.to_json_string()
2239
+ try:
2240
+ json_obj = json.loads(result)
2241
+ except TypeError as e:
2242
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2243
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2244
+ break
2245
+ cur_time = time.time()
2246
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2247
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2248
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2249
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2250
+ else:
2251
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2252
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2253
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2254
+
2255
+
2256
+ def doCreateCorp(args, parsed_globals):
2257
+ g_param = parse_global_arg(parsed_globals)
2258
+
2259
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2260
+ cred = credential.CVMRoleCredential()
2261
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2262
+ cred = credential.STSAssumeRoleCredential(
2263
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2264
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2265
+ )
2266
+ 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):
2267
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2268
+ else:
2269
+ cred = credential.Credential(
2270
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2271
+ )
2272
+ http_profile = HttpProfile(
2273
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2274
+ reqMethod="POST",
2275
+ endpoint=g_param[OptionsDefine.Endpoint],
2276
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2277
+ )
2278
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2279
+ if g_param[OptionsDefine.Language]:
2280
+ profile.language = g_param[OptionsDefine.Language]
2281
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2282
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2283
+ client._sdkVersion += ("_CLI_" + __version__)
2284
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2285
+ model = models.CreateCorpRequest()
2286
+ model.from_json_string(json.dumps(args))
2287
+ start_time = time.time()
2288
+ while True:
2289
+ rsp = client.CreateCorp(model)
2290
+ result = rsp.to_json_string()
2291
+ try:
2292
+ json_obj = json.loads(result)
2293
+ except TypeError as e:
2294
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2295
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2296
+ break
2297
+ cur_time = time.time()
2298
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2299
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2300
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2301
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2302
+ else:
2303
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2304
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2305
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2306
+
2307
+
2308
+ def doCreateQA(args, parsed_globals):
2309
+ g_param = parse_global_arg(parsed_globals)
2310
+
2311
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2312
+ cred = credential.CVMRoleCredential()
2313
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2314
+ cred = credential.STSAssumeRoleCredential(
2315
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2316
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2317
+ )
2318
+ 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):
2319
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2320
+ else:
2321
+ cred = credential.Credential(
2322
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2323
+ )
2324
+ http_profile = HttpProfile(
2325
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2326
+ reqMethod="POST",
2327
+ endpoint=g_param[OptionsDefine.Endpoint],
2328
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2329
+ )
2330
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2331
+ if g_param[OptionsDefine.Language]:
2332
+ profile.language = g_param[OptionsDefine.Language]
2333
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2334
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2335
+ client._sdkVersion += ("_CLI_" + __version__)
2336
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2337
+ model = models.CreateQARequest()
2338
+ model.from_json_string(json.dumps(args))
2339
+ start_time = time.time()
2340
+ while True:
2341
+ rsp = client.CreateQA(model)
2342
+ result = rsp.to_json_string()
2343
+ try:
2344
+ json_obj = json.loads(result)
2345
+ except TypeError as e:
2346
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2347
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2348
+ break
2349
+ cur_time = time.time()
2350
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2351
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2352
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2353
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2354
+ else:
2355
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2356
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2357
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2358
+
2359
+
2360
+ def doExportUnsatisfiedReply(args, parsed_globals):
2361
+ g_param = parse_global_arg(parsed_globals)
2362
+
2363
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2364
+ cred = credential.CVMRoleCredential()
2365
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2366
+ cred = credential.STSAssumeRoleCredential(
2367
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2368
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2369
+ )
2370
+ 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):
2371
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2372
+ else:
2373
+ cred = credential.Credential(
2374
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2375
+ )
2376
+ http_profile = HttpProfile(
2377
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2378
+ reqMethod="POST",
2379
+ endpoint=g_param[OptionsDefine.Endpoint],
2380
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2381
+ )
2382
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2383
+ if g_param[OptionsDefine.Language]:
2384
+ profile.language = g_param[OptionsDefine.Language]
2385
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2386
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2387
+ client._sdkVersion += ("_CLI_" + __version__)
2388
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2389
+ model = models.ExportUnsatisfiedReplyRequest()
2390
+ model.from_json_string(json.dumps(args))
2391
+ start_time = time.time()
2392
+ while True:
2393
+ rsp = client.ExportUnsatisfiedReply(model)
2394
+ result = rsp.to_json_string()
2395
+ try:
2396
+ json_obj = json.loads(result)
2397
+ except TypeError as e:
2398
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2399
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2400
+ break
2401
+ cur_time = time.time()
2402
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2403
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2404
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2405
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2406
+ else:
2407
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2408
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2409
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2410
+
2411
+
2412
+ def doResetSession(args, parsed_globals):
2413
+ g_param = parse_global_arg(parsed_globals)
2414
+
2415
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2416
+ cred = credential.CVMRoleCredential()
2417
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2418
+ cred = credential.STSAssumeRoleCredential(
2419
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2420
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2421
+ )
2422
+ 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):
2423
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2424
+ else:
2425
+ cred = credential.Credential(
2426
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2427
+ )
2428
+ http_profile = HttpProfile(
2429
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2430
+ reqMethod="POST",
2431
+ endpoint=g_param[OptionsDefine.Endpoint],
2432
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2433
+ )
2434
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2435
+ if g_param[OptionsDefine.Language]:
2436
+ profile.language = g_param[OptionsDefine.Language]
2437
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2438
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2439
+ client._sdkVersion += ("_CLI_" + __version__)
2440
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2441
+ model = models.ResetSessionRequest()
2442
+ model.from_json_string(json.dumps(args))
2443
+ start_time = time.time()
2444
+ while True:
2445
+ rsp = client.ResetSession(model)
2446
+ result = rsp.to_json_string()
2447
+ try:
2448
+ json_obj = json.loads(result)
2449
+ except TypeError as e:
2450
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2451
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2452
+ break
2453
+ cur_time = time.time()
2454
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2455
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2456
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2457
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2458
+ else:
2459
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2460
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2461
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2462
+
2463
+
2464
+ def doListQACate(args, parsed_globals):
2465
+ g_param = parse_global_arg(parsed_globals)
2466
+
2467
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2468
+ cred = credential.CVMRoleCredential()
2469
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2470
+ cred = credential.STSAssumeRoleCredential(
2471
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2472
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2473
+ )
2474
+ 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):
2475
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2476
+ else:
2477
+ cred = credential.Credential(
2478
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2479
+ )
2480
+ http_profile = HttpProfile(
2481
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2482
+ reqMethod="POST",
2483
+ endpoint=g_param[OptionsDefine.Endpoint],
2484
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2485
+ )
2486
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2487
+ if g_param[OptionsDefine.Language]:
2488
+ profile.language = g_param[OptionsDefine.Language]
2489
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2490
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2491
+ client._sdkVersion += ("_CLI_" + __version__)
2492
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2493
+ model = models.ListQACateRequest()
2494
+ model.from_json_string(json.dumps(args))
2495
+ start_time = time.time()
2496
+ while True:
2497
+ rsp = client.ListQACate(model)
2498
+ result = rsp.to_json_string()
2499
+ try:
2500
+ json_obj = json.loads(result)
2501
+ except TypeError as e:
2502
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2503
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2504
+ break
2505
+ cur_time = time.time()
2506
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2507
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2508
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2509
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2510
+ else:
2511
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2512
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2513
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2514
+
2515
+
2516
+ def doGetAppKnowledgeCount(args, parsed_globals):
2517
+ g_param = parse_global_arg(parsed_globals)
2518
+
2519
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2520
+ cred = credential.CVMRoleCredential()
2521
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2522
+ cred = credential.STSAssumeRoleCredential(
2523
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2524
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2525
+ )
2526
+ 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):
2527
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2528
+ else:
2529
+ cred = credential.Credential(
2530
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2531
+ )
2532
+ http_profile = HttpProfile(
2533
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2534
+ reqMethod="POST",
2535
+ endpoint=g_param[OptionsDefine.Endpoint],
2536
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2537
+ )
2538
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2539
+ if g_param[OptionsDefine.Language]:
2540
+ profile.language = g_param[OptionsDefine.Language]
2541
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2542
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2543
+ client._sdkVersion += ("_CLI_" + __version__)
2544
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2545
+ model = models.GetAppKnowledgeCountRequest()
2546
+ model.from_json_string(json.dumps(args))
2547
+ start_time = time.time()
2548
+ while True:
2549
+ rsp = client.GetAppKnowledgeCount(model)
2550
+ result = rsp.to_json_string()
2551
+ try:
2552
+ json_obj = json.loads(result)
2553
+ except TypeError as e:
2554
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2555
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2556
+ break
2557
+ cur_time = time.time()
2558
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2559
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2560
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2561
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2562
+ else:
2563
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2564
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2565
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2566
+
2567
+
2568
+ def doGenerateQA(args, parsed_globals):
2569
+ g_param = parse_global_arg(parsed_globals)
2570
+
2571
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2572
+ cred = credential.CVMRoleCredential()
2573
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2574
+ cred = credential.STSAssumeRoleCredential(
2575
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2576
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2577
+ )
2578
+ 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):
2579
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2580
+ else:
2581
+ cred = credential.Credential(
2582
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2583
+ )
2584
+ http_profile = HttpProfile(
2585
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2586
+ reqMethod="POST",
2587
+ endpoint=g_param[OptionsDefine.Endpoint],
2588
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2589
+ )
2590
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2591
+ if g_param[OptionsDefine.Language]:
2592
+ profile.language = g_param[OptionsDefine.Language]
2593
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2594
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2595
+ client._sdkVersion += ("_CLI_" + __version__)
2596
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2597
+ model = models.GenerateQARequest()
2598
+ model.from_json_string(json.dumps(args))
2599
+ start_time = time.time()
2600
+ while True:
2601
+ rsp = client.GenerateQA(model)
2602
+ result = rsp.to_json_string()
2603
+ try:
2604
+ json_obj = json.loads(result)
2605
+ except TypeError as e:
2606
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2607
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2608
+ break
2609
+ cur_time = time.time()
2610
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2611
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2612
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2613
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2614
+ else:
2615
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2616
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2617
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2618
+
2619
+
2620
+ def doListAppCategory(args, parsed_globals):
2621
+ g_param = parse_global_arg(parsed_globals)
2622
+
2623
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2624
+ cred = credential.CVMRoleCredential()
2625
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2626
+ cred = credential.STSAssumeRoleCredential(
2627
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2628
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2629
+ )
2630
+ 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):
2631
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2632
+ else:
2633
+ cred = credential.Credential(
2634
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2635
+ )
2636
+ http_profile = HttpProfile(
2637
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2638
+ reqMethod="POST",
2639
+ endpoint=g_param[OptionsDefine.Endpoint],
2640
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2641
+ )
2642
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2643
+ if g_param[OptionsDefine.Language]:
2644
+ profile.language = g_param[OptionsDefine.Language]
2645
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2646
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2647
+ client._sdkVersion += ("_CLI_" + __version__)
2648
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2649
+ model = models.ListAppCategoryRequest()
2650
+ model.from_json_string(json.dumps(args))
2651
+ start_time = time.time()
2652
+ while True:
2653
+ rsp = client.ListAppCategory(model)
2654
+ result = rsp.to_json_string()
2655
+ try:
2656
+ json_obj = json.loads(result)
2657
+ except TypeError as e:
2658
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2659
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2660
+ break
2661
+ cur_time = time.time()
2662
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2663
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2664
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2665
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2666
+ else:
2667
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2668
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2669
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2670
+
2671
+
2672
+ def doDescribeQA(args, parsed_globals):
2673
+ g_param = parse_global_arg(parsed_globals)
2674
+
2675
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2676
+ cred = credential.CVMRoleCredential()
2677
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2678
+ cred = credential.STSAssumeRoleCredential(
2679
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2680
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2681
+ )
2682
+ 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):
2683
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2684
+ else:
2685
+ cred = credential.Credential(
2686
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2687
+ )
2688
+ http_profile = HttpProfile(
2689
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2690
+ reqMethod="POST",
2691
+ endpoint=g_param[OptionsDefine.Endpoint],
2692
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2693
+ )
2694
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2695
+ if g_param[OptionsDefine.Language]:
2696
+ profile.language = g_param[OptionsDefine.Language]
2697
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2698
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2699
+ client._sdkVersion += ("_CLI_" + __version__)
2700
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2701
+ model = models.DescribeQARequest()
2702
+ model.from_json_string(json.dumps(args))
2703
+ start_time = time.time()
2704
+ while True:
2705
+ rsp = client.DescribeQA(model)
2706
+ result = rsp.to_json_string()
2707
+ try:
2708
+ json_obj = json.loads(result)
2709
+ except TypeError as e:
2710
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2711
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2712
+ break
2713
+ cur_time = time.time()
2714
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2715
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2716
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2717
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2718
+ else:
2719
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2720
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2721
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2722
+
2723
+
2724
+ def doCreateApp(args, parsed_globals):
2725
+ g_param = parse_global_arg(parsed_globals)
2726
+
2727
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2728
+ cred = credential.CVMRoleCredential()
2729
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2730
+ cred = credential.STSAssumeRoleCredential(
2731
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2732
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2733
+ )
2734
+ 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):
2735
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2736
+ else:
2737
+ cred = credential.Credential(
2738
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2739
+ )
2740
+ http_profile = HttpProfile(
2741
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2742
+ reqMethod="POST",
2743
+ endpoint=g_param[OptionsDefine.Endpoint],
2744
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2745
+ )
2746
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2747
+ if g_param[OptionsDefine.Language]:
2748
+ profile.language = g_param[OptionsDefine.Language]
2749
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2750
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2751
+ client._sdkVersion += ("_CLI_" + __version__)
2752
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2753
+ model = models.CreateAppRequest()
2754
+ model.from_json_string(json.dumps(args))
2755
+ start_time = time.time()
2756
+ while True:
2757
+ rsp = client.CreateApp(model)
2758
+ result = rsp.to_json_string()
2759
+ try:
2760
+ json_obj = json.loads(result)
2761
+ except TypeError as e:
2762
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2763
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2764
+ break
2765
+ cur_time = time.time()
2766
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2767
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2768
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2769
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2770
+ else:
2771
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2772
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2773
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2774
+
2775
+
2776
+ def doIsTransferIntent(args, parsed_globals):
2777
+ g_param = parse_global_arg(parsed_globals)
2778
+
2779
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2780
+ cred = credential.CVMRoleCredential()
2781
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2782
+ cred = credential.STSAssumeRoleCredential(
2783
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2784
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2785
+ )
2786
+ 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):
2787
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2788
+ else:
2789
+ cred = credential.Credential(
2790
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2791
+ )
2792
+ http_profile = HttpProfile(
2793
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2794
+ reqMethod="POST",
2795
+ endpoint=g_param[OptionsDefine.Endpoint],
2796
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2797
+ )
2798
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2799
+ if g_param[OptionsDefine.Language]:
2800
+ profile.language = g_param[OptionsDefine.Language]
2801
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2802
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2803
+ client._sdkVersion += ("_CLI_" + __version__)
2804
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2805
+ model = models.IsTransferIntentRequest()
2806
+ model.from_json_string(json.dumps(args))
2807
+ start_time = time.time()
2808
+ while True:
2809
+ rsp = client.IsTransferIntent(model)
2810
+ result = rsp.to_json_string()
2811
+ try:
2812
+ json_obj = json.loads(result)
2813
+ except TypeError as e:
2814
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2815
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2816
+ break
2817
+ cur_time = time.time()
2818
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2819
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2820
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2821
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2822
+ else:
2823
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2824
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2825
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2826
+
2827
+
2828
+ def doListRejectedQuestionPreview(args, parsed_globals):
2829
+ g_param = parse_global_arg(parsed_globals)
2830
+
2831
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2832
+ cred = credential.CVMRoleCredential()
2833
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2834
+ cred = credential.STSAssumeRoleCredential(
2835
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2836
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2837
+ )
2838
+ 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):
2839
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2840
+ else:
2841
+ cred = credential.Credential(
2842
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2843
+ )
2844
+ http_profile = HttpProfile(
2845
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2846
+ reqMethod="POST",
2847
+ endpoint=g_param[OptionsDefine.Endpoint],
2848
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2849
+ )
2850
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2851
+ if g_param[OptionsDefine.Language]:
2852
+ profile.language = g_param[OptionsDefine.Language]
2853
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2854
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2855
+ client._sdkVersion += ("_CLI_" + __version__)
2856
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2857
+ model = models.ListRejectedQuestionPreviewRequest()
2858
+ model.from_json_string(json.dumps(args))
2859
+ start_time = time.time()
2860
+ while True:
2861
+ rsp = client.ListRejectedQuestionPreview(model)
2862
+ result = rsp.to_json_string()
2863
+ try:
2864
+ json_obj = json.loads(result)
2865
+ except TypeError as e:
2866
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2867
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2868
+ break
2869
+ cur_time = time.time()
2870
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2871
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2872
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2873
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2874
+ else:
2875
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2876
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2877
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2878
+
2879
+
2880
+ def doGetMsgRecord(args, parsed_globals):
2881
+ g_param = parse_global_arg(parsed_globals)
2882
+
2883
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2884
+ cred = credential.CVMRoleCredential()
2885
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2886
+ cred = credential.STSAssumeRoleCredential(
2887
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2888
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2889
+ )
2890
+ 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):
2891
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2892
+ else:
2893
+ cred = credential.Credential(
2894
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2895
+ )
2896
+ http_profile = HttpProfile(
2897
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2898
+ reqMethod="POST",
2899
+ endpoint=g_param[OptionsDefine.Endpoint],
2900
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2901
+ )
2902
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2903
+ if g_param[OptionsDefine.Language]:
2904
+ profile.language = g_param[OptionsDefine.Language]
2905
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2906
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2907
+ client._sdkVersion += ("_CLI_" + __version__)
2908
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2909
+ model = models.GetMsgRecordRequest()
2910
+ model.from_json_string(json.dumps(args))
2911
+ start_time = time.time()
2912
+ while True:
2913
+ rsp = client.GetMsgRecord(model)
2914
+ result = rsp.to_json_string()
2915
+ try:
2916
+ json_obj = json.loads(result)
2917
+ except TypeError as e:
2918
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2919
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2920
+ break
2921
+ cur_time = time.time()
2922
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2923
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2924
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2925
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2926
+ else:
2927
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2928
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2929
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2930
+
2931
+
2932
+ def doModifyDoc(args, parsed_globals):
2933
+ g_param = parse_global_arg(parsed_globals)
2934
+
2935
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2936
+ cred = credential.CVMRoleCredential()
2937
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2938
+ cred = credential.STSAssumeRoleCredential(
2939
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2940
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2941
+ )
2942
+ 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):
2943
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2944
+ else:
2945
+ cred = credential.Credential(
2946
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2947
+ )
2948
+ http_profile = HttpProfile(
2949
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
2950
+ reqMethod="POST",
2951
+ endpoint=g_param[OptionsDefine.Endpoint],
2952
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
2953
+ )
2954
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
2955
+ if g_param[OptionsDefine.Language]:
2956
+ profile.language = g_param[OptionsDefine.Language]
2957
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
2958
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
2959
+ client._sdkVersion += ("_CLI_" + __version__)
2960
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
2961
+ model = models.ModifyDocRequest()
2962
+ model.from_json_string(json.dumps(args))
2963
+ start_time = time.time()
2964
+ while True:
2965
+ rsp = client.ModifyDoc(model)
2966
+ result = rsp.to_json_string()
2967
+ try:
2968
+ json_obj = json.loads(result)
2969
+ except TypeError as e:
2970
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
2971
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
2972
+ break
2973
+ cur_time = time.time()
2974
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
2975
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
2976
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
2977
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
2978
+ else:
2979
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
2980
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
2981
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
2982
+
2983
+
2984
+ def doDescribeReleaseInfo(args, parsed_globals):
2985
+ g_param = parse_global_arg(parsed_globals)
2986
+
2987
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
2988
+ cred = credential.CVMRoleCredential()
2989
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
2990
+ cred = credential.STSAssumeRoleCredential(
2991
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
2992
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
2993
+ )
2994
+ 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):
2995
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
2996
+ else:
2997
+ cred = credential.Credential(
2998
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
2999
+ )
3000
+ http_profile = HttpProfile(
3001
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3002
+ reqMethod="POST",
3003
+ endpoint=g_param[OptionsDefine.Endpoint],
3004
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3005
+ )
3006
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3007
+ if g_param[OptionsDefine.Language]:
3008
+ profile.language = g_param[OptionsDefine.Language]
3009
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3010
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3011
+ client._sdkVersion += ("_CLI_" + __version__)
3012
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3013
+ model = models.DescribeReleaseInfoRequest()
3014
+ model.from_json_string(json.dumps(args))
3015
+ start_time = time.time()
3016
+ while True:
3017
+ rsp = client.DescribeReleaseInfo(model)
3018
+ result = rsp.to_json_string()
3019
+ try:
3020
+ json_obj = json.loads(result)
3021
+ except TypeError as e:
3022
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3023
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3024
+ break
3025
+ cur_time = time.time()
3026
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3027
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3028
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3029
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3030
+ else:
3031
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3032
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3033
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3034
+
3035
+
3036
+ def doListRelease(args, parsed_globals):
3037
+ g_param = parse_global_arg(parsed_globals)
3038
+
3039
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3040
+ cred = credential.CVMRoleCredential()
3041
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3042
+ cred = credential.STSAssumeRoleCredential(
3043
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3044
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3045
+ )
3046
+ 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):
3047
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3048
+ else:
3049
+ cred = credential.Credential(
3050
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3051
+ )
3052
+ http_profile = HttpProfile(
3053
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3054
+ reqMethod="POST",
3055
+ endpoint=g_param[OptionsDefine.Endpoint],
3056
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3057
+ )
3058
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3059
+ if g_param[OptionsDefine.Language]:
3060
+ profile.language = g_param[OptionsDefine.Language]
3061
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3062
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3063
+ client._sdkVersion += ("_CLI_" + __version__)
3064
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3065
+ model = models.ListReleaseRequest()
3066
+ model.from_json_string(json.dumps(args))
3067
+ start_time = time.time()
3068
+ while True:
3069
+ rsp = client.ListRelease(model)
3070
+ result = rsp.to_json_string()
3071
+ try:
3072
+ json_obj = json.loads(result)
3073
+ except TypeError as e:
3074
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3075
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3076
+ break
3077
+ cur_time = time.time()
3078
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3079
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3080
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3081
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3082
+ else:
3083
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3084
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3085
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3086
+
3087
+
3088
+ def doListModel(args, parsed_globals):
3089
+ g_param = parse_global_arg(parsed_globals)
3090
+
3091
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3092
+ cred = credential.CVMRoleCredential()
3093
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3094
+ cred = credential.STSAssumeRoleCredential(
3095
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3096
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3097
+ )
3098
+ 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):
3099
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3100
+ else:
3101
+ cred = credential.Credential(
3102
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3103
+ )
3104
+ http_profile = HttpProfile(
3105
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3106
+ reqMethod="POST",
3107
+ endpoint=g_param[OptionsDefine.Endpoint],
3108
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3109
+ )
3110
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3111
+ if g_param[OptionsDefine.Language]:
3112
+ profile.language = g_param[OptionsDefine.Language]
3113
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3114
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3115
+ client._sdkVersion += ("_CLI_" + __version__)
3116
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3117
+ model = models.ListModelRequest()
3118
+ model.from_json_string(json.dumps(args))
3119
+ start_time = time.time()
3120
+ while True:
3121
+ rsp = client.ListModel(model)
3122
+ result = rsp.to_json_string()
3123
+ try:
3124
+ json_obj = json.loads(result)
3125
+ except TypeError as e:
3126
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3127
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3128
+ break
3129
+ cur_time = time.time()
3130
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3131
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3132
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3133
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3134
+ else:
3135
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3136
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3137
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3138
+
3139
+
3140
+ def doGroupQA(args, parsed_globals):
3141
+ g_param = parse_global_arg(parsed_globals)
3142
+
3143
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3144
+ cred = credential.CVMRoleCredential()
3145
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3146
+ cred = credential.STSAssumeRoleCredential(
3147
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3148
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3149
+ )
3150
+ 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):
3151
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3152
+ else:
3153
+ cred = credential.Credential(
3154
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3155
+ )
3156
+ http_profile = HttpProfile(
3157
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3158
+ reqMethod="POST",
3159
+ endpoint=g_param[OptionsDefine.Endpoint],
3160
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3161
+ )
3162
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3163
+ if g_param[OptionsDefine.Language]:
3164
+ profile.language = g_param[OptionsDefine.Language]
3165
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3166
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3167
+ client._sdkVersion += ("_CLI_" + __version__)
3168
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3169
+ model = models.GroupQARequest()
3170
+ model.from_json_string(json.dumps(args))
3171
+ start_time = time.time()
3172
+ while True:
3173
+ rsp = client.GroupQA(model)
3174
+ result = rsp.to_json_string()
3175
+ try:
3176
+ json_obj = json.loads(result)
3177
+ except TypeError as e:
3178
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3179
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3180
+ break
3181
+ cur_time = time.time()
3182
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3183
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3184
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3185
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3186
+ else:
3187
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3188
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3189
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3190
+
3191
+
3192
+ def doListAttributeLabel(args, parsed_globals):
3193
+ g_param = parse_global_arg(parsed_globals)
3194
+
3195
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3196
+ cred = credential.CVMRoleCredential()
3197
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3198
+ cred = credential.STSAssumeRoleCredential(
3199
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3200
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3201
+ )
3202
+ 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):
3203
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3204
+ else:
3205
+ cred = credential.Credential(
3206
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3207
+ )
3208
+ http_profile = HttpProfile(
3209
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3210
+ reqMethod="POST",
3211
+ endpoint=g_param[OptionsDefine.Endpoint],
3212
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3213
+ )
3214
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3215
+ if g_param[OptionsDefine.Language]:
3216
+ profile.language = g_param[OptionsDefine.Language]
3217
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3218
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3219
+ client._sdkVersion += ("_CLI_" + __version__)
3220
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3221
+ model = models.ListAttributeLabelRequest()
3222
+ model.from_json_string(json.dumps(args))
3223
+ start_time = time.time()
3224
+ while True:
3225
+ rsp = client.ListAttributeLabel(model)
3226
+ result = rsp.to_json_string()
3227
+ try:
3228
+ json_obj = json.loads(result)
3229
+ except TypeError as e:
3230
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3231
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3232
+ break
3233
+ cur_time = time.time()
3234
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3235
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3236
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3237
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3238
+ else:
3239
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3240
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3241
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3242
+
3243
+
3244
+ def doListRejectedQuestion(args, parsed_globals):
3245
+ g_param = parse_global_arg(parsed_globals)
3246
+
3247
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3248
+ cred = credential.CVMRoleCredential()
3249
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3250
+ cred = credential.STSAssumeRoleCredential(
3251
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3252
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3253
+ )
3254
+ 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):
3255
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3256
+ else:
3257
+ cred = credential.Credential(
3258
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3259
+ )
3260
+ http_profile = HttpProfile(
3261
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3262
+ reqMethod="POST",
3263
+ endpoint=g_param[OptionsDefine.Endpoint],
3264
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3265
+ )
3266
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3267
+ if g_param[OptionsDefine.Language]:
3268
+ profile.language = g_param[OptionsDefine.Language]
3269
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3270
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3271
+ client._sdkVersion += ("_CLI_" + __version__)
3272
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3273
+ model = models.ListRejectedQuestionRequest()
3274
+ model.from_json_string(json.dumps(args))
3275
+ start_time = time.time()
3276
+ while True:
3277
+ rsp = client.ListRejectedQuestion(model)
3278
+ result = rsp.to_json_string()
3279
+ try:
3280
+ json_obj = json.loads(result)
3281
+ except TypeError as e:
3282
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3283
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3284
+ break
3285
+ cur_time = time.time()
3286
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3287
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3288
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3289
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3290
+ else:
3291
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3292
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3293
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3294
+
3295
+
3296
+ def doListReleaseConfigPreview(args, parsed_globals):
3297
+ g_param = parse_global_arg(parsed_globals)
3298
+
3299
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3300
+ cred = credential.CVMRoleCredential()
3301
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3302
+ cred = credential.STSAssumeRoleCredential(
3303
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3304
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3305
+ )
3306
+ 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):
3307
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3308
+ else:
3309
+ cred = credential.Credential(
3310
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3311
+ )
3312
+ http_profile = HttpProfile(
3313
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3314
+ reqMethod="POST",
3315
+ endpoint=g_param[OptionsDefine.Endpoint],
3316
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3317
+ )
3318
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3319
+ if g_param[OptionsDefine.Language]:
3320
+ profile.language = g_param[OptionsDefine.Language]
3321
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3322
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3323
+ client._sdkVersion += ("_CLI_" + __version__)
3324
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3325
+ model = models.ListReleaseConfigPreviewRequest()
3326
+ model.from_json_string(json.dumps(args))
3327
+ start_time = time.time()
3328
+ while True:
3329
+ rsp = client.ListReleaseConfigPreview(model)
3330
+ result = rsp.to_json_string()
3331
+ try:
3332
+ json_obj = json.loads(result)
3333
+ except TypeError as e:
3334
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3335
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3336
+ break
3337
+ cur_time = time.time()
3338
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3339
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3340
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3341
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3342
+ else:
3343
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3344
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3345
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3346
+
3347
+
3348
+ def doGetTaskStatus(args, parsed_globals):
3349
+ g_param = parse_global_arg(parsed_globals)
3350
+
3351
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3352
+ cred = credential.CVMRoleCredential()
3353
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3354
+ cred = credential.STSAssumeRoleCredential(
3355
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3356
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3357
+ )
3358
+ 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):
3359
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3360
+ else:
3361
+ cred = credential.Credential(
3362
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3363
+ )
3364
+ http_profile = HttpProfile(
3365
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3366
+ reqMethod="POST",
3367
+ endpoint=g_param[OptionsDefine.Endpoint],
3368
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3369
+ )
3370
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3371
+ if g_param[OptionsDefine.Language]:
3372
+ profile.language = g_param[OptionsDefine.Language]
3373
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3374
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3375
+ client._sdkVersion += ("_CLI_" + __version__)
3376
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3377
+ model = models.GetTaskStatusRequest()
3378
+ model.from_json_string(json.dumps(args))
3379
+ start_time = time.time()
3380
+ while True:
3381
+ rsp = client.GetTaskStatus(model)
3382
+ result = rsp.to_json_string()
3383
+ try:
3384
+ json_obj = json.loads(result)
3385
+ except TypeError as e:
3386
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3387
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3388
+ break
3389
+ cur_time = time.time()
3390
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3391
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3392
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3393
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3394
+ else:
3395
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3396
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3397
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3398
+
3399
+
3400
+ def doDescribeRefer(args, parsed_globals):
3401
+ g_param = parse_global_arg(parsed_globals)
3402
+
3403
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3404
+ cred = credential.CVMRoleCredential()
3405
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3406
+ cred = credential.STSAssumeRoleCredential(
3407
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3408
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3409
+ )
3410
+ 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):
3411
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3412
+ else:
3413
+ cred = credential.Credential(
3414
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3415
+ )
3416
+ http_profile = HttpProfile(
3417
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3418
+ reqMethod="POST",
3419
+ endpoint=g_param[OptionsDefine.Endpoint],
3420
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3421
+ )
3422
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3423
+ if g_param[OptionsDefine.Language]:
3424
+ profile.language = g_param[OptionsDefine.Language]
3425
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3426
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3427
+ client._sdkVersion += ("_CLI_" + __version__)
3428
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3429
+ model = models.DescribeReferRequest()
3430
+ model.from_json_string(json.dumps(args))
3431
+ start_time = time.time()
3432
+ while True:
3433
+ rsp = client.DescribeRefer(model)
3434
+ result = rsp.to_json_string()
3435
+ try:
3436
+ json_obj = json.loads(result)
3437
+ except TypeError as e:
3438
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3439
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3440
+ break
3441
+ cur_time = time.time()
3442
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3443
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3444
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3445
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3446
+ else:
3447
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3448
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3449
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3450
+
3451
+
3452
+ def doDeleteQACate(args, parsed_globals):
3453
+ g_param = parse_global_arg(parsed_globals)
3454
+
3455
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3456
+ cred = credential.CVMRoleCredential()
3457
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3458
+ cred = credential.STSAssumeRoleCredential(
3459
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3460
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3461
+ )
3462
+ 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):
3463
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3464
+ else:
3465
+ cred = credential.Credential(
3466
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3467
+ )
3468
+ http_profile = HttpProfile(
3469
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3470
+ reqMethod="POST",
3471
+ endpoint=g_param[OptionsDefine.Endpoint],
3472
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3473
+ )
3474
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3475
+ if g_param[OptionsDefine.Language]:
3476
+ profile.language = g_param[OptionsDefine.Language]
3477
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3478
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3479
+ client._sdkVersion += ("_CLI_" + __version__)
3480
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3481
+ model = models.DeleteQACateRequest()
3482
+ model.from_json_string(json.dumps(args))
3483
+ start_time = time.time()
3484
+ while True:
3485
+ rsp = client.DeleteQACate(model)
3486
+ result = rsp.to_json_string()
3487
+ try:
3488
+ json_obj = json.loads(result)
3489
+ except TypeError as e:
3490
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3491
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3492
+ break
3493
+ cur_time = time.time()
3494
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3495
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3496
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3497
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3498
+ else:
3499
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3500
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3501
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3502
+
3503
+
3504
+ def doCreateQACate(args, parsed_globals):
3505
+ g_param = parse_global_arg(parsed_globals)
3506
+
3507
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3508
+ cred = credential.CVMRoleCredential()
3509
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3510
+ cred = credential.STSAssumeRoleCredential(
3511
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3512
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3513
+ )
3514
+ 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):
3515
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3516
+ else:
3517
+ cred = credential.Credential(
3518
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3519
+ )
3520
+ http_profile = HttpProfile(
3521
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3522
+ reqMethod="POST",
3523
+ endpoint=g_param[OptionsDefine.Endpoint],
3524
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3525
+ )
3526
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3527
+ if g_param[OptionsDefine.Language]:
3528
+ profile.language = g_param[OptionsDefine.Language]
3529
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3530
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3531
+ client._sdkVersion += ("_CLI_" + __version__)
3532
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3533
+ model = models.CreateQACateRequest()
3534
+ model.from_json_string(json.dumps(args))
3535
+ start_time = time.time()
3536
+ while True:
3537
+ rsp = client.CreateQACate(model)
3538
+ result = rsp.to_json_string()
3539
+ try:
3540
+ json_obj = json.loads(result)
3541
+ except TypeError as e:
3542
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3543
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3544
+ break
3545
+ cur_time = time.time()
3546
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3547
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3548
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3549
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3550
+ else:
3551
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3552
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3553
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3554
+
3555
+
3556
+ def doRetryRelease(args, parsed_globals):
3557
+ g_param = parse_global_arg(parsed_globals)
3558
+
3559
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3560
+ cred = credential.CVMRoleCredential()
3561
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3562
+ cred = credential.STSAssumeRoleCredential(
3563
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3564
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3565
+ )
3566
+ 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):
3567
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3568
+ else:
3569
+ cred = credential.Credential(
3570
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3571
+ )
3572
+ http_profile = HttpProfile(
3573
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3574
+ reqMethod="POST",
3575
+ endpoint=g_param[OptionsDefine.Endpoint],
3576
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3577
+ )
3578
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3579
+ if g_param[OptionsDefine.Language]:
3580
+ profile.language = g_param[OptionsDefine.Language]
3581
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3582
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3583
+ client._sdkVersion += ("_CLI_" + __version__)
3584
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3585
+ model = models.RetryReleaseRequest()
3586
+ model.from_json_string(json.dumps(args))
3587
+ start_time = time.time()
3588
+ while True:
3589
+ rsp = client.RetryRelease(model)
3590
+ result = rsp.to_json_string()
3591
+ try:
3592
+ json_obj = json.loads(result)
3593
+ except TypeError as e:
3594
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3595
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3596
+ break
3597
+ cur_time = time.time()
3598
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3599
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3600
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3601
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3602
+ else:
3603
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3604
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3605
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3606
+
3607
+
3608
+ def doQueryParseDocResult(args, parsed_globals):
3609
+ g_param = parse_global_arg(parsed_globals)
3610
+
3611
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3612
+ cred = credential.CVMRoleCredential()
3613
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3614
+ cred = credential.STSAssumeRoleCredential(
3615
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3616
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3617
+ )
3618
+ 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):
3619
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3620
+ else:
3621
+ cred = credential.Credential(
3622
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3623
+ )
3624
+ http_profile = HttpProfile(
3625
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3626
+ reqMethod="POST",
3627
+ endpoint=g_param[OptionsDefine.Endpoint],
3628
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3629
+ )
3630
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3631
+ if g_param[OptionsDefine.Language]:
3632
+ profile.language = g_param[OptionsDefine.Language]
3633
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3634
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3635
+ client._sdkVersion += ("_CLI_" + __version__)
3636
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3637
+ model = models.QueryParseDocResultRequest()
3638
+ model.from_json_string(json.dumps(args))
3639
+ start_time = time.time()
3640
+ while True:
3641
+ rsp = client.QueryParseDocResult(model)
3642
+ result = rsp.to_json_string()
3643
+ try:
3644
+ json_obj = json.loads(result)
3645
+ except TypeError as e:
3646
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3647
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3648
+ break
3649
+ cur_time = time.time()
3650
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3651
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3652
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3653
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3654
+ else:
3655
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3656
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3657
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3658
+
3659
+
3660
+ def doStopDocParse(args, parsed_globals):
3661
+ g_param = parse_global_arg(parsed_globals)
3662
+
3663
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3664
+ cred = credential.CVMRoleCredential()
3665
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3666
+ cred = credential.STSAssumeRoleCredential(
3667
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3668
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3669
+ )
3670
+ 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):
3671
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3672
+ else:
3673
+ cred = credential.Credential(
3674
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3675
+ )
3676
+ http_profile = HttpProfile(
3677
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3678
+ reqMethod="POST",
3679
+ endpoint=g_param[OptionsDefine.Endpoint],
3680
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3681
+ )
3682
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3683
+ if g_param[OptionsDefine.Language]:
3684
+ profile.language = g_param[OptionsDefine.Language]
3685
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3686
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3687
+ client._sdkVersion += ("_CLI_" + __version__)
3688
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3689
+ model = models.StopDocParseRequest()
3690
+ model.from_json_string(json.dumps(args))
3691
+ start_time = time.time()
3692
+ while True:
3693
+ rsp = client.StopDocParse(model)
3694
+ result = rsp.to_json_string()
3695
+ try:
3696
+ json_obj = json.loads(result)
3697
+ except TypeError as e:
3698
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3699
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3700
+ break
3701
+ cur_time = time.time()
3702
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3703
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3704
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3705
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3706
+ else:
3707
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3708
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3709
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3710
+
3711
+
3712
+ def doExportAttributeLabel(args, parsed_globals):
3713
+ g_param = parse_global_arg(parsed_globals)
3714
+
3715
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3716
+ cred = credential.CVMRoleCredential()
3717
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3718
+ cred = credential.STSAssumeRoleCredential(
3719
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3720
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3721
+ )
3722
+ 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):
3723
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3724
+ else:
3725
+ cred = credential.Credential(
3726
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3727
+ )
3728
+ http_profile = HttpProfile(
3729
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3730
+ reqMethod="POST",
3731
+ endpoint=g_param[OptionsDefine.Endpoint],
3732
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3733
+ )
3734
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3735
+ if g_param[OptionsDefine.Language]:
3736
+ profile.language = g_param[OptionsDefine.Language]
3737
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3738
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3739
+ client._sdkVersion += ("_CLI_" + __version__)
3740
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3741
+ model = models.ExportAttributeLabelRequest()
3742
+ model.from_json_string(json.dumps(args))
3743
+ start_time = time.time()
3744
+ while True:
3745
+ rsp = client.ExportAttributeLabel(model)
3746
+ result = rsp.to_json_string()
3747
+ try:
3748
+ json_obj = json.loads(result)
3749
+ except TypeError as e:
3750
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3751
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3752
+ break
3753
+ cur_time = time.time()
3754
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3755
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3756
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3757
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3758
+ else:
3759
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3760
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3761
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3762
+
3763
+
3764
+ def doVerifyQA(args, parsed_globals):
3765
+ g_param = parse_global_arg(parsed_globals)
3766
+
3767
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3768
+ cred = credential.CVMRoleCredential()
3769
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3770
+ cred = credential.STSAssumeRoleCredential(
3771
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3772
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3773
+ )
3774
+ 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):
3775
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3776
+ else:
3777
+ cred = credential.Credential(
3778
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3779
+ )
3780
+ http_profile = HttpProfile(
3781
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3782
+ reqMethod="POST",
3783
+ endpoint=g_param[OptionsDefine.Endpoint],
3784
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3785
+ )
3786
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3787
+ if g_param[OptionsDefine.Language]:
3788
+ profile.language = g_param[OptionsDefine.Language]
3789
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3790
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3791
+ client._sdkVersion += ("_CLI_" + __version__)
3792
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3793
+ model = models.VerifyQARequest()
3794
+ model.from_json_string(json.dumps(args))
3795
+ start_time = time.time()
3796
+ while True:
3797
+ rsp = client.VerifyQA(model)
3798
+ result = rsp.to_json_string()
3799
+ try:
3800
+ json_obj = json.loads(result)
3801
+ except TypeError as e:
3802
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3803
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3804
+ break
3805
+ cur_time = time.time()
3806
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3807
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3808
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3809
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3810
+ else:
3811
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3812
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3813
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3814
+
3815
+
3816
+ def doParseDoc(args, parsed_globals):
3817
+ g_param = parse_global_arg(parsed_globals)
3818
+
3819
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3820
+ cred = credential.CVMRoleCredential()
3821
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3822
+ cred = credential.STSAssumeRoleCredential(
3823
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3824
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3825
+ )
3826
+ 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):
3827
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3828
+ else:
3829
+ cred = credential.Credential(
3830
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3831
+ )
3832
+ http_profile = HttpProfile(
3833
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3834
+ reqMethod="POST",
3835
+ endpoint=g_param[OptionsDefine.Endpoint],
3836
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3837
+ )
3838
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3839
+ if g_param[OptionsDefine.Language]:
3840
+ profile.language = g_param[OptionsDefine.Language]
3841
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3842
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3843
+ client._sdkVersion += ("_CLI_" + __version__)
3844
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3845
+ model = models.ParseDocRequest()
3846
+ model.from_json_string(json.dumps(args))
3847
+ start_time = time.time()
3848
+ while True:
3849
+ rsp = client.ParseDoc(model)
3850
+ result = rsp.to_json_string()
3851
+ try:
3852
+ json_obj = json.loads(result)
3853
+ except TypeError as e:
3854
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3855
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3856
+ break
3857
+ cur_time = time.time()
3858
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3859
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3860
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3861
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3862
+ else:
3863
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3864
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3865
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3866
+
3867
+
3868
+ def doListDoc(args, parsed_globals):
3869
+ g_param = parse_global_arg(parsed_globals)
3870
+
3871
+ if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
3872
+ cred = credential.CVMRoleCredential()
3873
+ elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
3874
+ cred = credential.STSAssumeRoleCredential(
3875
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
3876
+ g_param[OptionsDefine.RoleSessionName.replace('-', '_')], endpoint=g_param["sts_cred_endpoint"]
3877
+ )
3878
+ 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):
3879
+ cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
3880
+ else:
3881
+ cred = credential.Credential(
3882
+ g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
3883
+ )
3884
+ http_profile = HttpProfile(
3885
+ reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
3886
+ reqMethod="POST",
3887
+ endpoint=g_param[OptionsDefine.Endpoint],
3888
+ proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
3889
+ )
3890
+ profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
3891
+ if g_param[OptionsDefine.Language]:
3892
+ profile.language = g_param[OptionsDefine.Language]
3893
+ mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
3894
+ client = mod.LkeClient(cred, g_param[OptionsDefine.Region], profile)
3895
+ client._sdkVersion += ("_CLI_" + __version__)
3896
+ models = MODELS_MAP[g_param[OptionsDefine.Version]]
3897
+ model = models.ListDocRequest()
3898
+ model.from_json_string(json.dumps(args))
3899
+ start_time = time.time()
3900
+ while True:
3901
+ rsp = client.ListDoc(model)
3902
+ result = rsp.to_json_string()
3903
+ try:
3904
+ json_obj = json.loads(result)
3905
+ except TypeError as e:
3906
+ json_obj = json.loads(result.decode('utf-8')) # python3.3
3907
+ if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
3908
+ break
3909
+ cur_time = time.time()
3910
+ if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
3911
+ raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
3912
+ (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
3913
+ search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
3914
+ else:
3915
+ print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
3916
+ time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
3917
+ FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
3918
+
3919
+
3920
+ CLIENT_MAP = {
3921
+ "v20231130": lke_client_v20231130,
3922
+
3923
+ }
3924
+
3925
+ MODELS_MAP = {
3926
+ "v20231130": models_v20231130,
3927
+
3928
+ }
3929
+
3930
+ ACTION_MAP = {
3931
+ "GetWsToken": doGetWsToken,
3932
+ "ModifyQA": doModifyQA,
3933
+ "ListUnsatisfiedReply": doListUnsatisfiedReply,
3934
+ "DeleteAttributeLabel": doDeleteAttributeLabel,
3935
+ "SaveDoc": doSaveDoc,
3936
+ "CreateRejectedQuestion": doCreateRejectedQuestion,
3937
+ "CheckAttributeLabelExist": doCheckAttributeLabelExist,
3938
+ "ModifyQAAttrRange": doModifyQAAttrRange,
3939
+ "DescribeDoc": doDescribeDoc,
3940
+ "DeleteRejectedQuestion": doDeleteRejectedQuestion,
3941
+ "ListSelectDoc": doListSelectDoc,
3942
+ "QueryRewrite": doQueryRewrite,
3943
+ "DescribeUnsatisfiedReplyContext": doDescribeUnsatisfiedReplyContext,
3944
+ "ModifyDocAttrRange": doModifyDocAttrRange,
3945
+ "ListQA": doListQA,
3946
+ "DeleteDoc": doDeleteDoc,
3947
+ "CreateRelease": doCreateRelease,
3948
+ "GetEmbedding": doGetEmbedding,
3949
+ "GetAppSecret": doGetAppSecret,
3950
+ "ModifyAttributeLabel": doModifyAttributeLabel,
3951
+ "RateMsgRecord": doRateMsgRecord,
3952
+ "DescribeStorageCredential": doDescribeStorageCredential,
3953
+ "DeleteQA": doDeleteQA,
3954
+ "DescribeRobotBizIDByAppKey": doDescribeRobotBizIDByAppKey,
3955
+ "ListReleaseQAPreview": doListReleaseQAPreview,
3956
+ "ExportQAList": doExportQAList,
3957
+ "ModifyQACate": doModifyQACate,
3958
+ "DeleteApp": doDeleteApp,
3959
+ "ModifyApp": doModifyApp,
3960
+ "IgnoreUnsatisfiedReply": doIgnoreUnsatisfiedReply,
3961
+ "CheckAttributeLabelRefer": doCheckAttributeLabelRefer,
3962
+ "DescribeCorp": doDescribeCorp,
3963
+ "CreateAttributeLabel": doCreateAttributeLabel,
3964
+ "RetryDocAudit": doRetryDocAudit,
3965
+ "UploadAttributeLabel": doUploadAttributeLabel,
3966
+ "ListApp": doListApp,
3967
+ "GetDocPreview": doGetDocPreview,
3968
+ "ListReleaseDocPreview": doListReleaseDocPreview,
3969
+ "ModifyRejectedQuestion": doModifyRejectedQuestion,
3970
+ "DescribeAttributeLabel": doDescribeAttributeLabel,
3971
+ "DescribeRelease": doDescribeRelease,
3972
+ "DescribeApp": doDescribeApp,
3973
+ "RetryDocParse": doRetryDocParse,
3974
+ "CreateCorp": doCreateCorp,
3975
+ "CreateQA": doCreateQA,
3976
+ "ExportUnsatisfiedReply": doExportUnsatisfiedReply,
3977
+ "ResetSession": doResetSession,
3978
+ "ListQACate": doListQACate,
3979
+ "GetAppKnowledgeCount": doGetAppKnowledgeCount,
3980
+ "GenerateQA": doGenerateQA,
3981
+ "ListAppCategory": doListAppCategory,
3982
+ "DescribeQA": doDescribeQA,
3983
+ "CreateApp": doCreateApp,
3984
+ "IsTransferIntent": doIsTransferIntent,
3985
+ "ListRejectedQuestionPreview": doListRejectedQuestionPreview,
3986
+ "GetMsgRecord": doGetMsgRecord,
3987
+ "ModifyDoc": doModifyDoc,
3988
+ "DescribeReleaseInfo": doDescribeReleaseInfo,
3989
+ "ListRelease": doListRelease,
3990
+ "ListModel": doListModel,
3991
+ "GroupQA": doGroupQA,
3992
+ "ListAttributeLabel": doListAttributeLabel,
3993
+ "ListRejectedQuestion": doListRejectedQuestion,
3994
+ "ListReleaseConfigPreview": doListReleaseConfigPreview,
3995
+ "GetTaskStatus": doGetTaskStatus,
3996
+ "DescribeRefer": doDescribeRefer,
3997
+ "DeleteQACate": doDeleteQACate,
3998
+ "CreateQACate": doCreateQACate,
3999
+ "RetryRelease": doRetryRelease,
4000
+ "QueryParseDocResult": doQueryParseDocResult,
4001
+ "StopDocParse": doStopDocParse,
4002
+ "ExportAttributeLabel": doExportAttributeLabel,
4003
+ "VerifyQA": doVerifyQA,
4004
+ "ParseDoc": doParseDoc,
4005
+ "ListDoc": doListDoc,
4006
+
4007
+ }
4008
+
4009
+ AVAILABLE_VERSION_LIST = [
4010
+ "v20231130",
4011
+
4012
+ ]
4013
+
4014
+
4015
+ def action_caller():
4016
+ return ACTION_MAP
4017
+
4018
+
4019
+ def parse_global_arg(parsed_globals):
4020
+ g_param = parsed_globals
4021
+
4022
+ is_exist_profile = True
4023
+ if not parsed_globals["profile"]:
4024
+ is_exist_profile = False
4025
+ g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
4026
+
4027
+ configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
4028
+ is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
4029
+ is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
4030
+
4031
+ conf = {}
4032
+ cred = {}
4033
+
4034
+ if is_conf_exist:
4035
+ conf = Utils.load_json_msg(conf_path)
4036
+ if is_cred_exist:
4037
+ cred = Utils.load_json_msg(cred_path)
4038
+
4039
+ if not (isinstance(conf, dict) and isinstance(cred, dict)):
4040
+ raise ConfigurationError(
4041
+ "file: %s or %s is not json format"
4042
+ % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
4043
+
4044
+ if OptionsDefine.Token not in cred:
4045
+ cred[OptionsDefine.Token] = None
4046
+
4047
+ if not is_exist_profile:
4048
+ if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
4049
+ cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
4050
+ cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
4051
+ cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
4052
+
4053
+ if os.environ.get(OptionsDefine.ENV_REGION):
4054
+ conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
4055
+
4056
+ if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
4057
+ cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
4058
+ cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
4059
+
4060
+ for param in g_param.keys():
4061
+ if g_param[param] is None:
4062
+ if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
4063
+ if param in cred:
4064
+ g_param[param] = cred[param]
4065
+ elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
4066
+ or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
4067
+ raise ConfigurationError("%s is invalid" % param)
4068
+ elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
4069
+ if param in conf[OptionsDefine.SysParam]:
4070
+ g_param[param] = conf[OptionsDefine.SysParam][param]
4071
+ elif param != OptionsDefine.Language:
4072
+ raise ConfigurationError("%s is invalid" % param)
4073
+ elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
4074
+ if param.replace('_', '-') in cred:
4075
+ g_param[param] = cred[param.replace('_', '-')]
4076
+
4077
+ try:
4078
+ if g_param[OptionsDefine.ServiceVersion]:
4079
+ g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
4080
+ else:
4081
+ version = conf["lke"][OptionsDefine.Version]
4082
+ g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
4083
+
4084
+ if g_param[OptionsDefine.Endpoint] is None:
4085
+ g_param[OptionsDefine.Endpoint] = conf["lke"][OptionsDefine.Endpoint]
4086
+ g_param["sts_cred_endpoint"] = conf.get("sts", {}).get("endpoint")
4087
+ except Exception as err:
4088
+ raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
4089
+
4090
+ if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
4091
+ raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
4092
+
4093
+ if g_param[OptionsDefine.Waiter]:
4094
+ param = eval(g_param[OptionsDefine.Waiter])
4095
+ if 'expr' not in param:
4096
+ raise Exception('`expr` in `--waiter` must be defined')
4097
+ if 'to' not in param:
4098
+ raise Exception('`to` in `--waiter` must be defined')
4099
+ if 'timeout' not in param:
4100
+ if 'waiter' in conf and 'timeout' in conf['waiter']:
4101
+ param['timeout'] = conf['waiter']['timeout']
4102
+ else:
4103
+ param['timeout'] = 180
4104
+ if 'interval' not in param:
4105
+ if 'waiter' in conf and 'interval' in conf['waiter']:
4106
+ param['interval'] = conf['waiter']['interval']
4107
+ else:
4108
+ param['interval'] = 5
4109
+ param['interval'] = min(param['interval'], param['timeout'])
4110
+ g_param['OptionsDefine.WaiterInfo'] = param
4111
+
4112
+ if six.PY2:
4113
+ for key, value in g_param.items():
4114
+ if isinstance(value, six.text_type):
4115
+ g_param[key] = value.encode('utf-8')
4116
+ return g_param
4117
+