-
Notifications
You must be signed in to change notification settings - Fork 5
/
kms_client.py
1247 lines (1031 loc) · 51.1 KB
/
kms_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf8 -*-
# Copyright (c) 2017-2021 THL A29 Limited, a Tencent company. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.common.abstract_client import AbstractClient
from tencentcloud.kms.v20190118 import models
class KmsClient(AbstractClient):
_apiVersion = '2019-01-18'
_endpoint = 'kms.tencentcloudapi.com'
_service = 'kms'
def ArchiveKey(self, request):
"""This API is used to archive keys. The archived keys can only be used for decryption but not encryption.
:param request: Request instance for ArchiveKey.
:type request: :class:`tencentcloud.kms.v20190118.models.ArchiveKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.ArchiveKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ArchiveKey", params, headers=headers)
response = json.loads(body)
model = models.ArchiveKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def AsymmetricRsaDecrypt(self, request):
"""This API is used to decrypt data with the specified private key that is encrypted with RSA asymmetric cryptographic algorithm. The ciphertext must be encrypted with the corresponding public key. The asymmetric key must be in `Enabled` state for decryption.
:param request: Request instance for AsymmetricRsaDecrypt.
:type request: :class:`tencentcloud.kms.v20190118.models.AsymmetricRsaDecryptRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.AsymmetricRsaDecryptResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("AsymmetricRsaDecrypt", params, headers=headers)
response = json.loads(body)
model = models.AsymmetricRsaDecryptResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def AsymmetricSm2Decrypt(self, request):
"""This API is used to decrypt data with the specified private key that is encrypted with SM2 asymmetric cryptographic algorithm. The ciphertext must be encrypted with the corresponding public key. The asymmetric key must be in `Enabled` state for decryption. The length of the ciphertext passed in cannot exceed 256 bytes.
:param request: Request instance for AsymmetricSm2Decrypt.
:type request: :class:`tencentcloud.kms.v20190118.models.AsymmetricSm2DecryptRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.AsymmetricSm2DecryptResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("AsymmetricSm2Decrypt", params, headers=headers)
response = json.loads(body)
model = models.AsymmetricSm2DecryptResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BindCloudResource(self, request):
"""This API is used to bind a key with a Tencent Cloud resource. If the key has been set to be expired automatically, the setting will be canceled to ensure that the key will not be invalid automatically. If the key and the resource has already been bound, the call will still be successful.
:param request: Request instance for BindCloudResource.
:type request: :class:`tencentcloud.kms.v20190118.models.BindCloudResourceRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.BindCloudResourceResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BindCloudResource", params, headers=headers)
response = json.loads(body)
model = models.BindCloudResourceResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CancelKeyArchive(self, request):
"""This API is used to unarchive keys. If a key is unarchived, its status will be `Enabled`.
:param request: Request instance for CancelKeyArchive.
:type request: :class:`tencentcloud.kms.v20190118.models.CancelKeyArchiveRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.CancelKeyArchiveResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CancelKeyArchive", params, headers=headers)
response = json.loads(body)
model = models.CancelKeyArchiveResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CancelKeyDeletion(self, request):
"""Cancel the scheduled deletion of CMK
:param request: Request instance for CancelKeyDeletion.
:type request: :class:`tencentcloud.kms.v20190118.models.CancelKeyDeletionRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.CancelKeyDeletionResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CancelKeyDeletion", params, headers=headers)
response = json.loads(body)
model = models.CancelKeyDeletionResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateKey(self, request):
"""Create a master key CMK (Custom Master Key) for user management data keys
:param request: Request instance for CreateKey.
:type request: :class:`tencentcloud.kms.v20190118.models.CreateKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.CreateKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateKey", params, headers=headers)
response = json.loads(body)
model = models.CreateKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateWhiteBoxKey(self, request):
"""This API is used to create a white-box key. Up to 50 ones can be created.
:param request: Request instance for CreateWhiteBoxKey.
:type request: :class:`tencentcloud.kms.v20190118.models.CreateWhiteBoxKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.CreateWhiteBoxKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateWhiteBoxKey", params, headers=headers)
response = json.loads(body)
model = models.CreateWhiteBoxKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def Decrypt(self, request):
"""This API is used to decrypt the ciphertext and obtain the plaintext data.
:param request: Request instance for Decrypt.
:type request: :class:`tencentcloud.kms.v20190118.models.DecryptRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DecryptResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("Decrypt", params, headers=headers)
response = json.loads(body)
model = models.DecryptResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DeleteImportedKeyMaterial(self, request):
"""This API is used to delete the imported key material. It is only valid for EXTERNAL CMKs. Specifically, it puts a CMK into `PendingImport` status instead of deleting the CMK, so that the CMK can be used again after key material is reimported. To delete the CMK completely, please call the `ScheduleKeyDeletion` API.
:param request: Request instance for DeleteImportedKeyMaterial.
:type request: :class:`tencentcloud.kms.v20190118.models.DeleteImportedKeyMaterialRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DeleteImportedKeyMaterialResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DeleteImportedKeyMaterial", params, headers=headers)
response = json.loads(body)
model = models.DeleteImportedKeyMaterialResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DeleteWhiteBoxKey(self, request):
"""This API is used to delete a white-box key. Note: only disabled white-box keys can be deleted.
:param request: Request instance for DeleteWhiteBoxKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DeleteWhiteBoxKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DeleteWhiteBoxKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DeleteWhiteBoxKey", params, headers=headers)
response = json.loads(body)
model = models.DeleteWhiteBoxKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeKey(self, request):
"""This API is used to get the attribute details of the CMK with a specified `KeyId`.
:param request: Request instance for DescribeKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeKey", params, headers=headers)
response = json.loads(body)
model = models.DescribeKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeKeys(self, request):
"""This API is used to get the attribute information of CMKs in batches.
:param request: Request instance for DescribeKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeKeys", params, headers=headers)
response = json.loads(body)
model = models.DescribeKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeWhiteBoxDecryptKey(self, request):
"""This API is used to get a white-box decryption key.
:param request: Request instance for DescribeWhiteBoxDecryptKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxDecryptKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxDecryptKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeWhiteBoxDecryptKey", params, headers=headers)
response = json.loads(body)
model = models.DescribeWhiteBoxDecryptKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeWhiteBoxDeviceFingerprints(self, request):
"""This API is used to get the device fingerprint list of a specified key.
:param request: Request instance for DescribeWhiteBoxDeviceFingerprints.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxDeviceFingerprintsRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxDeviceFingerprintsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeWhiteBoxDeviceFingerprints", params, headers=headers)
response = json.loads(body)
model = models.DescribeWhiteBoxDeviceFingerprintsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeWhiteBoxKey(self, request):
"""This API is used to display white-box key information.
:param request: Request instance for DescribeWhiteBoxKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeWhiteBoxKey", params, headers=headers)
response = json.loads(body)
model = models.DescribeWhiteBoxKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeWhiteBoxKeyDetails(self, request):
"""This API is used to get the white-box key list.
:param request: Request instance for DescribeWhiteBoxKeyDetails.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxKeyDetailsRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxKeyDetailsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeWhiteBoxKeyDetails", params, headers=headers)
response = json.loads(body)
model = models.DescribeWhiteBoxKeyDetailsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeWhiteBoxServiceStatus(self, request):
"""This API is used to get the white-box key service status.
:param request: Request instance for DescribeWhiteBoxServiceStatus.
:type request: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxServiceStatusRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DescribeWhiteBoxServiceStatusResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeWhiteBoxServiceStatus", params, headers=headers)
response = json.loads(body)
model = models.DescribeWhiteBoxServiceStatusResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DisableKey(self, request):
"""This API is used to disable a master key. The disabled key cannot be used for encryption and decryption operations.
:param request: Request instance for DisableKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DisableKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DisableKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DisableKey", params, headers=headers)
response = json.loads(body)
model = models.DisableKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DisableKeyRotation(self, request):
"""Disabled key rotation for the specified CMK.
:param request: Request instance for DisableKeyRotation.
:type request: :class:`tencentcloud.kms.v20190118.models.DisableKeyRotationRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DisableKeyRotationResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DisableKeyRotation", params, headers=headers)
response = json.loads(body)
model = models.DisableKeyRotationResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DisableKeys(self, request):
"""This API is used to batch prohibit the use of CMK.
:param request: Request instance for DisableKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.DisableKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DisableKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DisableKeys", params, headers=headers)
response = json.loads(body)
model = models.DisableKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DisableWhiteBoxKey(self, request):
"""This API is used to disable a white-box key.
:param request: Request instance for DisableWhiteBoxKey.
:type request: :class:`tencentcloud.kms.v20190118.models.DisableWhiteBoxKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DisableWhiteBoxKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DisableWhiteBoxKey", params, headers=headers)
response = json.loads(body)
model = models.DisableWhiteBoxKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DisableWhiteBoxKeys(self, request):
"""This API is used to disable white-box keys in batches.
:param request: Request instance for DisableWhiteBoxKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.DisableWhiteBoxKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.DisableWhiteBoxKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DisableWhiteBoxKeys", params, headers=headers)
response = json.loads(body)
model = models.DisableWhiteBoxKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnableKey(self, request):
"""Enable a specified CMK.
:param request: Request instance for EnableKey.
:type request: :class:`tencentcloud.kms.v20190118.models.EnableKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EnableKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnableKey", params, headers=headers)
response = json.loads(body)
model = models.EnableKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnableKeyRotation(self, request):
"""Turn on the key rotation function for the specified CMK.
:param request: Request instance for EnableKeyRotation.
:type request: :class:`tencentcloud.kms.v20190118.models.EnableKeyRotationRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EnableKeyRotationResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnableKeyRotation", params, headers=headers)
response = json.loads(body)
model = models.EnableKeyRotationResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnableKeys(self, request):
"""This API is used to enable CMK in batches.
:param request: Request instance for EnableKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.EnableKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EnableKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnableKeys", params, headers=headers)
response = json.loads(body)
model = models.EnableKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnableWhiteBoxKey(self, request):
"""This API is used to enable a white-box key.
:param request: Request instance for EnableWhiteBoxKey.
:type request: :class:`tencentcloud.kms.v20190118.models.EnableWhiteBoxKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EnableWhiteBoxKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnableWhiteBoxKey", params, headers=headers)
response = json.loads(body)
model = models.EnableWhiteBoxKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnableWhiteBoxKeys(self, request):
"""This API is used to enable white-box keys in batches.
:param request: Request instance for EnableWhiteBoxKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.EnableWhiteBoxKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EnableWhiteBoxKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnableWhiteBoxKeys", params, headers=headers)
response = json.loads(body)
model = models.EnableWhiteBoxKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def Encrypt(self, request):
"""This API is used to encrypt any data up to 4KB. It can be used to encrypt database passwords, RSA Key, or other small sensitive information. For application data encryption, use the DataKey generated by GenerateDataKey to perform local data encryption and decryption operations
:param request: Request instance for Encrypt.
:type request: :class:`tencentcloud.kms.v20190118.models.EncryptRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EncryptResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("Encrypt", params, headers=headers)
response = json.loads(body)
model = models.EncryptResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EncryptByWhiteBox(self, request):
"""This API is used to encrypt data with a white-box key.
:param request: Request instance for EncryptByWhiteBox.
:type request: :class:`tencentcloud.kms.v20190118.models.EncryptByWhiteBoxRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.EncryptByWhiteBoxResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EncryptByWhiteBox", params, headers=headers)
response = json.loads(body)
model = models.EncryptByWhiteBoxResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GenerateDataKey(self, request):
"""This API generates a data key, which you can use to encrypt local data.
:param request: Request instance for GenerateDataKey.
:type request: :class:`tencentcloud.kms.v20190118.models.GenerateDataKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GenerateDataKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GenerateDataKey", params, headers=headers)
response = json.loads(body)
model = models.GenerateDataKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GenerateRandom(self, request):
"""This API is used to generate a random number.
:param request: Request instance for GenerateRandom.
:type request: :class:`tencentcloud.kms.v20190118.models.GenerateRandomRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GenerateRandomResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GenerateRandom", params, headers=headers)
response = json.loads(body)
model = models.GenerateRandomResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetKeyRotationStatus(self, request):
"""Query whether the specified CMK has the key rotation function.
:param request: Request instance for GetKeyRotationStatus.
:type request: :class:`tencentcloud.kms.v20190118.models.GetKeyRotationStatusRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GetKeyRotationStatusResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetKeyRotationStatus", params, headers=headers)
response = json.loads(body)
model = models.GetKeyRotationStatusResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetParametersForImport(self, request):
"""This API is used to obtain the parameters of the material to be imported into a CMK. The returned `Token` is used as one of the parameters to execute `ImportKeyMaterial`, and the returned `PublicKey` is used to encrypt the key material. The `Token` and `PublicKey` are valid for 24 hours. If they are expired, you will need to call the API again to get a new `Token` and `PublicKey`.
:param request: Request instance for GetParametersForImport.
:type request: :class:`tencentcloud.kms.v20190118.models.GetParametersForImportRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GetParametersForImportResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetParametersForImport", params, headers=headers)
response = json.loads(body)
model = models.GetParametersForImportResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetPublicKey(self, request):
"""This API is used to get the public key of an asymmetric KMS key (which must be enabled). With the public key, you can encrypt messages and verify signatures.
:param request: Request instance for GetPublicKey.
:type request: :class:`tencentcloud.kms.v20190118.models.GetPublicKeyRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GetPublicKeyResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetPublicKey", params, headers=headers)
response = json.loads(body)
model = models.GetPublicKeyResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetRegions(self, request):
"""This API is used to return all regions support KMS service.
:param request: Request instance for GetRegions.
:type request: :class:`tencentcloud.kms.v20190118.models.GetRegionsRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GetRegionsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetRegions", params, headers=headers)
response = json.loads(body)
model = models.GetRegionsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetServiceStatus(self, request):
"""Used to query whether the user has activated the KMS service.
:param request: Request instance for GetServiceStatus.
:type request: :class:`tencentcloud.kms.v20190118.models.GetServiceStatusRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.GetServiceStatusResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetServiceStatus", params, headers=headers)
response = json.loads(body)
model = models.GetServiceStatusResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ImportKeyMaterial(self, request):
"""This API is used to import key material into an EXTERNAL CMK. The key obtained through the `GetParametersForImport` API is used to encrypt the key material. You can only reimport the same key material into the specified CMK and set a new expiration time. After the CMK key material is imported, it cannot be replaced. After the key material is expired or deleted, the CMK will remain unavailable until the same key material is reimported. CMKs are independent, which means that the same key material can be imported into different CMKs, but data encrypted by one CMK cannot be decrypted by another one.
Key material can only be imported into CMKs in `Enabled` and `PendingImport` status.
:param request: Request instance for ImportKeyMaterial.
:type request: :class:`tencentcloud.kms.v20190118.models.ImportKeyMaterialRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.ImportKeyMaterialResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ImportKeyMaterial", params, headers=headers)
response = json.loads(body)
model = models.ImportKeyMaterialResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ListAlgorithms(self, request):
"""This API is used to list the encryption methods supported in the current region.
:param request: Request instance for ListAlgorithms.
:type request: :class:`tencentcloud.kms.v20190118.models.ListAlgorithmsRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.ListAlgorithmsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ListAlgorithms", params, headers=headers)
response = json.loads(body)
model = models.ListAlgorithmsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ListKeyDetail(self, request):
"""Get the master key list details according to the specified Offset and Limit.
:param request: Request instance for ListKeyDetail.
:type request: :class:`tencentcloud.kms.v20190118.models.ListKeyDetailRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.ListKeyDetailResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ListKeyDetail", params, headers=headers)
response = json.loads(body)
model = models.ListKeyDetailResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ListKeys(self, request):
"""This API is used to list the KeyIds of CMKs in `Enabled`, `Disabled`, and `PendingImport` status under the account.
:param request: Request instance for ListKeys.
:type request: :class:`tencentcloud.kms.v20190118.models.ListKeysRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.ListKeysResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ListKeys", params, headers=headers)
response = json.loads(body)
model = models.ListKeysResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def OverwriteWhiteBoxDeviceFingerprints(self, request):
"""This API is used to overwrite the device fingerprint information of a specified key.
:param request: Request instance for OverwriteWhiteBoxDeviceFingerprints.
:type request: :class:`tencentcloud.kms.v20190118.models.OverwriteWhiteBoxDeviceFingerprintsRequest`
:rtype: :class:`tencentcloud.kms.v20190118.models.OverwriteWhiteBoxDeviceFingerprintsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("OverwriteWhiteBoxDeviceFingerprints", params, headers=headers)
response = json.loads(body)
model = models.OverwriteWhiteBoxDeviceFingerprintsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def PostQuantumCryptoDecrypt(self, request):
"""u200dThis API u200dis used to decrypt ciphertext using post-quantum cryptography (PQC) algorithm, and return the plaintext.
:param request: Request instance for PostQuantumCryptoDecrypt.
:type request: :class:`tencentcloud.kms.v20190118.models.PostQuantumCryptoDecryptRequest`