tccli 3.0.1042.1__py2.py3-none-any.whl → 3.0.1043.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tccli/__init__.py +1 -1
- tccli/examples/tdid/v20210519/CheckNewPurchase.md +18 -0
- tccli/examples/tdid/v20210519/CreateTDidByHost.md +25 -0
- tccli/examples/tdid/v20210519/CreateTDidByPubKey.md +28 -0
- tccli/examples/tdid/v20210519/DeactivateTDid.md +52 -0
- tccli/examples/tdid/v20210519/GetCredentialState.md +33 -0
- tccli/examples/tdid/v20210519/GetTDidDocument.md +22 -0
- tccli/examples/tdid/v20210519/IssueCredential.md +25 -0
- tccli/examples/tdid/v20210519/UpdateCredentialState.md +57 -0
- tccli/examples/tdid/v20210519/VerifyCredentials.md +24 -0
- tccli/services/tdid/tdid_client.py +36 -248
- tccli/services/tdid/v20210519/api.json +346 -712
- tccli/services/tdid/v20210519/examples.json +44 -76
- {tccli-3.0.1042.1.dist-info → tccli-3.0.1043.1.dist-info}/METADATA +2 -2
- {tccli-3.0.1042.1.dist-info → tccli-3.0.1043.1.dist-info}/RECORD +18 -9
- {tccli-3.0.1042.1.dist-info → tccli-3.0.1043.1.dist-info}/WHEEL +0 -0
- {tccli-3.0.1042.1.dist-info → tccli-3.0.1043.1.dist-info}/entry_points.txt +0 -0
- {tccli-3.0.1042.1.dist-info → tccli-3.0.1043.1.dist-info}/license_files/LICENSE +0 -0
@@ -17,7 +17,7 @@ from tencentcloud.tdid.v20210519 import models as models_v20210519
|
|
17
17
|
from jmespath import search
|
18
18
|
import time
|
19
19
|
|
20
|
-
def
|
20
|
+
def doVerifyCredentials(args, parsed_globals):
|
21
21
|
g_param = parse_global_arg(parsed_globals)
|
22
22
|
|
23
23
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -46,11 +46,11 @@ def doCheckChain(args, parsed_globals):
|
|
46
46
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
47
47
|
client._sdkVersion += ("_CLI_" + __version__)
|
48
48
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
49
|
-
model = models.
|
49
|
+
model = models.VerifyCredentialsRequest()
|
50
50
|
model.from_json_string(json.dumps(args))
|
51
51
|
start_time = time.time()
|
52
52
|
while True:
|
53
|
-
rsp = client.
|
53
|
+
rsp = client.VerifyCredentials(model)
|
54
54
|
result = rsp.to_json_string()
|
55
55
|
try:
|
56
56
|
json_obj = json.loads(result)
|
@@ -69,7 +69,7 @@ def doCheckChain(args, parsed_globals):
|
|
69
69
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
70
70
|
|
71
71
|
|
72
|
-
def
|
72
|
+
def doCreateTDidByHost(args, parsed_globals):
|
73
73
|
g_param = parse_global_arg(parsed_globals)
|
74
74
|
|
75
75
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -98,11 +98,11 @@ def doGetCptInfo(args, parsed_globals):
|
|
98
98
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
99
99
|
client._sdkVersion += ("_CLI_" + __version__)
|
100
100
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
101
|
-
model = models.
|
101
|
+
model = models.CreateTDidByHostRequest()
|
102
102
|
model.from_json_string(json.dumps(args))
|
103
103
|
start_time = time.time()
|
104
104
|
while True:
|
105
|
-
rsp = client.
|
105
|
+
rsp = client.CreateTDidByHost(model)
|
106
106
|
result = rsp.to_json_string()
|
107
107
|
try:
|
108
108
|
json_obj = json.loads(result)
|
@@ -121,7 +121,7 @@ def doGetCptInfo(args, parsed_globals):
|
|
121
121
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
122
122
|
|
123
123
|
|
124
|
-
def
|
124
|
+
def doCreateTDidByPubKey(args, parsed_globals):
|
125
125
|
g_param = parse_global_arg(parsed_globals)
|
126
126
|
|
127
127
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -150,11 +150,11 @@ def doGetDidDocument(args, parsed_globals):
|
|
150
150
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
151
151
|
client._sdkVersion += ("_CLI_" + __version__)
|
152
152
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
153
|
-
model = models.
|
153
|
+
model = models.CreateTDidByPubKeyRequest()
|
154
154
|
model.from_json_string(json.dumps(args))
|
155
155
|
start_time = time.time()
|
156
156
|
while True:
|
157
|
-
rsp = client.
|
157
|
+
rsp = client.CreateTDidByPubKey(model)
|
158
158
|
result = rsp.to_json_string()
|
159
159
|
try:
|
160
160
|
json_obj = json.loads(result)
|
@@ -173,7 +173,7 @@ def doGetDidDocument(args, parsed_globals):
|
|
173
173
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
174
174
|
|
175
175
|
|
176
|
-
def
|
176
|
+
def doGetTDidDocument(args, parsed_globals):
|
177
177
|
g_param = parse_global_arg(parsed_globals)
|
178
178
|
|
179
179
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -202,11 +202,11 @@ def doCreateSelectiveCredential(args, parsed_globals):
|
|
202
202
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
203
203
|
client._sdkVersion += ("_CLI_" + __version__)
|
204
204
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
205
|
-
model = models.
|
205
|
+
model = models.GetTDidDocumentRequest()
|
206
206
|
model.from_json_string(json.dumps(args))
|
207
207
|
start_time = time.time()
|
208
208
|
while True:
|
209
|
-
rsp = client.
|
209
|
+
rsp = client.GetTDidDocument(model)
|
210
210
|
result = rsp.to_json_string()
|
211
211
|
try:
|
212
212
|
json_obj = json.loads(result)
|
@@ -225,7 +225,7 @@ def doCreateSelectiveCredential(args, parsed_globals):
|
|
225
225
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
226
226
|
|
227
227
|
|
228
|
-
def
|
228
|
+
def doUpdateCredentialState(args, parsed_globals):
|
229
229
|
g_param = parse_global_arg(parsed_globals)
|
230
230
|
|
231
231
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -254,11 +254,11 @@ def doCreateCredential(args, parsed_globals):
|
|
254
254
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
255
255
|
client._sdkVersion += ("_CLI_" + __version__)
|
256
256
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
257
|
-
model = models.
|
257
|
+
model = models.UpdateCredentialStateRequest()
|
258
258
|
model.from_json_string(json.dumps(args))
|
259
259
|
start_time = time.time()
|
260
260
|
while True:
|
261
|
-
rsp = client.
|
261
|
+
rsp = client.UpdateCredentialState(model)
|
262
262
|
result = rsp.to_json_string()
|
263
263
|
try:
|
264
264
|
json_obj = json.loads(result)
|
@@ -277,7 +277,7 @@ def doCreateCredential(args, parsed_globals):
|
|
277
277
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
278
278
|
|
279
279
|
|
280
|
-
def
|
280
|
+
def doDeactivateTDid(args, parsed_globals):
|
281
281
|
g_param = parse_global_arg(parsed_globals)
|
282
282
|
|
283
283
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -306,11 +306,11 @@ def doCreateTDidByPublicKey(args, parsed_globals):
|
|
306
306
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
307
307
|
client._sdkVersion += ("_CLI_" + __version__)
|
308
308
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
309
|
-
model = models.
|
309
|
+
model = models.DeactivateTDidRequest()
|
310
310
|
model.from_json_string(json.dumps(args))
|
311
311
|
start_time = time.time()
|
312
312
|
while True:
|
313
|
-
rsp = client.
|
313
|
+
rsp = client.DeactivateTDid(model)
|
314
314
|
result = rsp.to_json_string()
|
315
315
|
try:
|
316
316
|
json_obj = json.loads(result)
|
@@ -329,7 +329,7 @@ def doCreateTDidByPublicKey(args, parsed_globals):
|
|
329
329
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
330
330
|
|
331
331
|
|
332
|
-
def
|
332
|
+
def doGetCredentialState(args, parsed_globals):
|
333
333
|
g_param = parse_global_arg(parsed_globals)
|
334
334
|
|
335
335
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -358,11 +358,11 @@ def doGetCredentialStatus(args, parsed_globals):
|
|
358
358
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
359
359
|
client._sdkVersion += ("_CLI_" + __version__)
|
360
360
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
361
|
-
model = models.
|
361
|
+
model = models.GetCredentialStateRequest()
|
362
362
|
model.from_json_string(json.dumps(args))
|
363
363
|
start_time = time.time()
|
364
364
|
while True:
|
365
|
-
rsp = client.
|
365
|
+
rsp = client.GetCredentialState(model)
|
366
366
|
result = rsp.to_json_string()
|
367
367
|
try:
|
368
368
|
json_obj = json.loads(result)
|
@@ -381,7 +381,7 @@ def doGetCredentialStatus(args, parsed_globals):
|
|
381
381
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
382
382
|
|
383
383
|
|
384
|
-
def
|
384
|
+
def doIssueCredential(args, parsed_globals):
|
385
385
|
g_param = parse_global_arg(parsed_globals)
|
386
386
|
|
387
387
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -410,11 +410,11 @@ def doCreateTDidByPrivateKey(args, parsed_globals):
|
|
410
410
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
411
411
|
client._sdkVersion += ("_CLI_" + __version__)
|
412
412
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
413
|
-
model = models.
|
413
|
+
model = models.IssueCredentialRequest()
|
414
414
|
model.from_json_string(json.dumps(args))
|
415
415
|
start_time = time.time()
|
416
416
|
while True:
|
417
|
-
rsp = client.
|
417
|
+
rsp = client.IssueCredential(model)
|
418
418
|
result = rsp.to_json_string()
|
419
419
|
try:
|
420
420
|
json_obj = json.loads(result)
|
@@ -433,7 +433,7 @@ def doCreateTDidByPrivateKey(args, parsed_globals):
|
|
433
433
|
FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
|
434
434
|
|
435
435
|
|
436
|
-
def
|
436
|
+
def doCheckNewPurchase(args, parsed_globals):
|
437
437
|
g_param = parse_global_arg(parsed_globals)
|
438
438
|
|
439
439
|
if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
|
@@ -462,219 +462,11 @@ def doCreateTDid(args, parsed_globals):
|
|
462
462
|
client = mod.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
463
463
|
client._sdkVersion += ("_CLI_" + __version__)
|
464
464
|
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
465
|
-
model = models.
|
465
|
+
model = models.CheckNewPurchaseRequest()
|
466
466
|
model.from_json_string(json.dumps(args))
|
467
467
|
start_time = time.time()
|
468
468
|
while True:
|
469
|
-
rsp = client.
|
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 doRegisterCpt(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.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
515
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
516
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
517
|
-
model = models.RegisterCptRequest()
|
518
|
-
model.from_json_string(json.dumps(args))
|
519
|
-
start_time = time.time()
|
520
|
-
while True:
|
521
|
-
rsp = client.RegisterCpt(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 doVerifyCredential(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.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
567
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
568
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
569
|
-
model = models.VerifyCredentialRequest()
|
570
|
-
model.from_json_string(json.dumps(args))
|
571
|
-
start_time = time.time()
|
572
|
-
while True:
|
573
|
-
rsp = client.VerifyCredential(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 doGetAuthorityIssuer(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.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
619
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
620
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
621
|
-
model = models.GetAuthorityIssuerRequest()
|
622
|
-
model.from_json_string(json.dumps(args))
|
623
|
-
start_time = time.time()
|
624
|
-
while True:
|
625
|
-
rsp = client.GetAuthorityIssuer(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 doSetCredentialStatus(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.TdidClient(cred, g_param[OptionsDefine.Region], profile)
|
671
|
-
client._sdkVersion += ("_CLI_" + __version__)
|
672
|
-
models = MODELS_MAP[g_param[OptionsDefine.Version]]
|
673
|
-
model = models.SetCredentialStatusRequest()
|
674
|
-
model.from_json_string(json.dumps(args))
|
675
|
-
start_time = time.time()
|
676
|
-
while True:
|
677
|
-
rsp = client.SetCredentialStatus(model)
|
469
|
+
rsp = client.CheckNewPurchase(model)
|
678
470
|
result = rsp.to_json_string()
|
679
471
|
try:
|
680
472
|
json_obj = json.loads(result)
|
@@ -704,19 +496,15 @@ MODELS_MAP = {
|
|
704
496
|
}
|
705
497
|
|
706
498
|
ACTION_MAP = {
|
707
|
-
"
|
708
|
-
"
|
709
|
-
"
|
710
|
-
"
|
711
|
-
"
|
712
|
-
"
|
713
|
-
"
|
714
|
-
"
|
715
|
-
"
|
716
|
-
"RegisterCpt": doRegisterCpt,
|
717
|
-
"VerifyCredential": doVerifyCredential,
|
718
|
-
"GetAuthorityIssuer": doGetAuthorityIssuer,
|
719
|
-
"SetCredentialStatus": doSetCredentialStatus,
|
499
|
+
"VerifyCredentials": doVerifyCredentials,
|
500
|
+
"CreateTDidByHost": doCreateTDidByHost,
|
501
|
+
"CreateTDidByPubKey": doCreateTDidByPubKey,
|
502
|
+
"GetTDidDocument": doGetTDidDocument,
|
503
|
+
"UpdateCredentialState": doUpdateCredentialState,
|
504
|
+
"DeactivateTDid": doDeactivateTDid,
|
505
|
+
"GetCredentialState": doGetCredentialState,
|
506
|
+
"IssueCredential": doIssueCredential,
|
507
|
+
"CheckNewPurchase": doCheckNewPurchase,
|
720
508
|
|
721
509
|
}
|
722
510
|
|