Source file values.ml

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
(* generated by: awso-codegen generate-all --botocore-data vendor/botocore/botocore/data -o aws --runtime-dir lib/runtime/awso --cli-dir awso-cli *)
open Awso
open! Import
[@@@warning "-32"]
let service = Service.kms
let apiVersion = "2014-11-01"
let endpointPrefix = "kms"
let serviceFullName = "AWS Key Management Service"
let signatureVersion = "v4"
let protocol = "json"
let globalEndpoint = endpointPrefix ^ ".amazonaws.com"
let serviceAbbreviation = "KMS"
let targetPrefix = "TrentService"
let simple_to_json to_value x =
  Botodata.Json.value_to_json_scalar (to_value x)
let composed_to_json to_value x = Botodata.Json.value_to_json (to_value x)
let to_query to_value x = Client.Query.of_value (to_value x)
let structure_to_value_aux st ~f =
  let filter = function | (k, Some v) -> Some (k, v) | _ -> None in
  let pair k v = (k, v) in
  let defer_value (k, dv) = pair k dv in
  ((List.filter_map st ~f:filter) |> (List.map ~f:defer_value)) |>
    (fun x -> `Structure (f x))
let structure_to_value = structure_to_value_aux ~f:Fn.id
let structure_to_wrapped_value ~wrapper ~response =
  structure_to_value_aux
    ~f:(fun x -> [(wrapper, (`Structure x)); (response, (`Structure []))])
module ArnType =
  struct
    type nonrec t = string
    let context_ = "ArnType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:2048) >>=
             (fun () -> check_string_min i ~min:20));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"ArnType" j
    let to_json = simple_to_json to_value
  end
module RegionType =
  struct
    type nonrec t = string
    let context_ = "RegionType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:32) >>=
                  (fun () -> check_pattern i ~pattern:"^([a-z]+-){2,3}\\d+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"RegionType" j
    let to_json = simple_to_json to_value
  end
module EncryptionContextKey =
  struct
    type nonrec t = string
    let context_ = "EncryptionContextKey"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"EncryptionContextKey" j
    let to_json = simple_to_json to_value
  end
module EncryptionContextValue =
  struct
    type nonrec t = string
    let context_ = "EncryptionContextValue"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"EncryptionContextValue" j
    let to_json = simple_to_json to_value
  end
module MultiRegionKey =
  struct
    type nonrec t =
      {
      arn: ArnType.t option
        [@ocaml.doc
          "Displays the key ARN of a primary or replica key of a multi-Region key."];
      region: RegionType.t option
        [@ocaml.doc
          "Displays the Amazon Web Services Region of a primary or replica key in a multi-Region key."]}
    let make ?arn = fun ?region -> fun () -> { arn; region }
    let to_value x =
      structure_to_value
        [("Arn", (Option.map x.arn ~f:ArnType.to_value));
        ("Region", (Option.map x.region ~f:RegionType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let region =
        (Option.map ~f:RegionType.of_xml) (Xml.child xml_arg0 "Region") in
      let arn = (Option.map ~f:ArnType.of_xml) (Xml.child xml_arg0 "Arn") in
      make ?region ?arn ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let region = field_map json__ "Region" RegionType.of_json in
      let arn = field_map json__ "Arn" ArnType.of_json in
      make ?region ?arn ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Describes the primary or replica key in a multi-Region key."]
module EncryptionContextType =
  struct
    type nonrec t = (EncryptionContextKey.t * EncryptionContextValue.t) list
    let make i = i
    let of_header xs =
      make
        (List.filter_map xs
           ~f:(fun (k, v) ->
                 (Base.String.chop_prefix k ~prefix:"x-amz-meta-") |>
                   (Option.map
                      ~f:(fun chopped ->
                            ((EncryptionContextKey.of_string chopped),
                              (EncryptionContextValue.of_string v))))))
    let to_value xs =
      (xs |>
         (List.map
            ~f:(fun (x, y) ->
                  (EncryptionContextKey.to_value x) |>
                    (fun x ->
                       (EncryptionContextValue.to_value y) |>
                         (fun y -> (x, y))))))
        |> (fun x -> `Map x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for Map_shape objects" ()
    let of_xml _ =
      failwith "of_xml_converter_of_shape: Map_shape case not implemented"
    let of_json j =
      object_of_json ~key_of_string:EncryptionContextKey.of_string
        ~of_json:EncryptionContextValue.of_json j
    let to_json v = composed_to_json to_value v
  end
module GrantOperation =
  struct
    type nonrec t =
      | Decrypt 
      | Encrypt 
      | GenerateDataKey 
      | GenerateDataKeyWithoutPlaintext 
      | ReEncryptFrom 
      | ReEncryptTo 
      | Sign 
      | Verify 
      | GetPublicKey 
      | CreateGrant 
      | RetireGrant 
      | DescribeKey 
      | GenerateDataKeyPair 
      | GenerateDataKeyPairWithoutPlaintext 
      | GenerateMac 
      | VerifyMac 
      | DeriveSharedSecret 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | Decrypt -> "Decrypt"
      | Encrypt -> "Encrypt"
      | GenerateDataKey -> "GenerateDataKey"
      | GenerateDataKeyWithoutPlaintext -> "GenerateDataKeyWithoutPlaintext"
      | ReEncryptFrom -> "ReEncryptFrom"
      | ReEncryptTo -> "ReEncryptTo"
      | Sign -> "Sign"
      | Verify -> "Verify"
      | GetPublicKey -> "GetPublicKey"
      | CreateGrant -> "CreateGrant"
      | RetireGrant -> "RetireGrant"
      | DescribeKey -> "DescribeKey"
      | GenerateDataKeyPair -> "GenerateDataKeyPair"
      | GenerateDataKeyPairWithoutPlaintext ->
          "GenerateDataKeyPairWithoutPlaintext"
      | GenerateMac -> "GenerateMac"
      | VerifyMac -> "VerifyMac"
      | DeriveSharedSecret -> "DeriveSharedSecret"
      | Non_static_id s -> s
    let of_string =
      function
      | "Decrypt" -> Decrypt
      | "Encrypt" -> Encrypt
      | "GenerateDataKey" -> GenerateDataKey
      | "GenerateDataKeyWithoutPlaintext" -> GenerateDataKeyWithoutPlaintext
      | "ReEncryptFrom" -> ReEncryptFrom
      | "ReEncryptTo" -> ReEncryptTo
      | "Sign" -> Sign
      | "Verify" -> Verify
      | "GetPublicKey" -> GetPublicKey
      | "CreateGrant" -> CreateGrant
      | "RetireGrant" -> RetireGrant
      | "DescribeKey" -> DescribeKey
      | "GenerateDataKeyPair" -> GenerateDataKeyPair
      | "GenerateDataKeyPairWithoutPlaintext" ->
          GenerateDataKeyPairWithoutPlaintext
      | "GenerateMac" -> GenerateMac
      | "VerifyMac" -> VerifyMac
      | "DeriveSharedSecret" -> DeriveSharedSecret
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration GrantOperation" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"GrantOperation" j)
    let to_json = simple_to_json to_value
  end
module AccountIdType =
  struct
    type nonrec t = string
    let context_ = "AccountIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:12) >>=
             (fun () ->
                (check_string_max i ~max:12) >>=
                  (fun () -> check_pattern i ~pattern:"[0-9]{12}")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AccountIdType" j
    let to_json = simple_to_json to_value
  end
module XksProxyAuthenticationAccessKeyIdType =
  struct
    type nonrec t = string
    let context_ = "XksProxyAuthenticationAccessKeyIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:20) >>=
             (fun () ->
                (check_string_max i ~max:30) >>=
                  (fun () -> check_pattern i ~pattern:"^[A-Z2-7]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j =
      string_of_json ~kind:"XksProxyAuthenticationAccessKeyIdType" j
    let to_json = simple_to_json to_value
  end
module XksProxyConnectivityType =
  struct
    type nonrec t =
      | PUBLIC_ENDPOINT 
      | VPC_ENDPOINT_SERVICE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | PUBLIC_ENDPOINT -> "PUBLIC_ENDPOINT"
      | VPC_ENDPOINT_SERVICE -> "VPC_ENDPOINT_SERVICE"
      | Non_static_id s -> s
    let of_string =
      function
      | "PUBLIC_ENDPOINT" -> PUBLIC_ENDPOINT
      | "VPC_ENDPOINT_SERVICE" -> VPC_ENDPOINT_SERVICE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration XksProxyConnectivityType" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"XksProxyConnectivityType" j)
    let to_json = simple_to_json to_value
  end
module XksProxyUriEndpointType =
  struct
    type nonrec t = string
    let context_ = "XksProxyUriEndpointType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:10) >>=
             (fun () ->
                (check_string_max i ~max:128) >>=
                  (fun () ->
                     check_pattern i ~pattern:"^https://[a-zA-Z0-9.-]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"XksProxyUriEndpointType" j
    let to_json = simple_to_json to_value
  end
module XksProxyUriPathType =
  struct
    type nonrec t = string
    let context_ = "XksProxyUriPathType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:10) >>=
             (fun () ->
                (check_string_max i ~max:128) >>=
                  (fun () ->
                     check_pattern i
                       ~pattern:"^(/[a-zA-Z0-9\\/_-]+/kms/xks/v\\d{1,2})$|^(/kms/xks/v\\d{1,2})$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"XksProxyUriPathType" j
    let to_json = simple_to_json to_value
  end
module XksProxyVpcEndpointServiceNameType =
  struct
    type nonrec t = string
    let context_ = "XksProxyVpcEndpointServiceNameType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:20) >>=
             (fun () ->
                (check_string_max i ~max:64) >>=
                  (fun () ->
                     check_pattern i
                       ~pattern:"^(com|eu)\\.amazonaws\\.vpce\\.([a-z]+-){2,3}\\d+\\.vpce-svc-[0-9a-z]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j =
      string_of_json ~kind:"XksProxyVpcEndpointServiceNameType" j
    let to_json = simple_to_json to_value
  end
module TagKeyType =
  struct
    type nonrec t = string
    let context_ = "TagKeyType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:128) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"TagKeyType" j
    let to_json = simple_to_json to_value
  end
module TagValueType =
  struct
    type nonrec t = string
    let context_ = "TagValueType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:256) >>=
             (fun () -> check_string_min i ~min:0));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"TagValueType" j
    let to_json = simple_to_json to_value
  end
module EncryptionAlgorithmSpec =
  struct
    type nonrec t =
      | SYMMETRIC_DEFAULT 
      | RSAES_OAEP_SHA_1 
      | RSAES_OAEP_SHA_256 
      | SM2PKE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | SYMMETRIC_DEFAULT -> "SYMMETRIC_DEFAULT"
      | RSAES_OAEP_SHA_1 -> "RSAES_OAEP_SHA_1"
      | RSAES_OAEP_SHA_256 -> "RSAES_OAEP_SHA_256"
      | SM2PKE -> "SM2PKE"
      | Non_static_id s -> s
    let of_string =
      function
      | "SYMMETRIC_DEFAULT" -> SYMMETRIC_DEFAULT
      | "RSAES_OAEP_SHA_1" -> RSAES_OAEP_SHA_1
      | "RSAES_OAEP_SHA_256" -> RSAES_OAEP_SHA_256
      | "SM2PKE" -> SM2PKE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration EncryptionAlgorithmSpec" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"EncryptionAlgorithmSpec" j)
    let to_json = simple_to_json to_value
  end
module KeyAgreementAlgorithmSpec =
  struct
    type nonrec t =
      | ECDH 
      | Non_static_id of string 
    let make i = i
    let to_string = function | ECDH -> "ECDH" | Non_static_id s -> s
    let of_string = function | "ECDH" -> ECDH | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration KeyAgreementAlgorithmSpec" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"KeyAgreementAlgorithmSpec" j)
    let to_json = simple_to_json to_value
  end
module MacAlgorithmSpec =
  struct
    type nonrec t =
      | HMAC_SHA_224 
      | HMAC_SHA_256 
      | HMAC_SHA_384 
      | HMAC_SHA_512 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | HMAC_SHA_224 -> "HMAC_SHA_224"
      | HMAC_SHA_256 -> "HMAC_SHA_256"
      | HMAC_SHA_384 -> "HMAC_SHA_384"
      | HMAC_SHA_512 -> "HMAC_SHA_512"
      | Non_static_id s -> s
    let of_string =
      function
      | "HMAC_SHA_224" -> HMAC_SHA_224
      | "HMAC_SHA_256" -> HMAC_SHA_256
      | "HMAC_SHA_384" -> HMAC_SHA_384
      | "HMAC_SHA_512" -> HMAC_SHA_512
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration MacAlgorithmSpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"MacAlgorithmSpec" j)
    let to_json = simple_to_json to_value
  end
module MultiRegionKeyList =
  struct
    type nonrec t = MultiRegionKey.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:MultiRegionKey.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:MultiRegionKey.of_xml)
    let of_json j =
      list_of_json ~kind:"MultiRegionKeyList" ~of_json:MultiRegionKey.of_json
        j
    let to_json v = composed_to_json to_value v
  end
module MultiRegionKeyType =
  struct
    type nonrec t =
      | PRIMARY 
      | REPLICA 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | PRIMARY -> "PRIMARY"
      | REPLICA -> "REPLICA"
      | Non_static_id s -> s
    let of_string =
      function
      | "PRIMARY" -> PRIMARY
      | "REPLICA" -> REPLICA
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration MultiRegionKeyType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"MultiRegionKeyType" j)
    let to_json = simple_to_json to_value
  end
module SigningAlgorithmSpec =
  struct
    type nonrec t =
      | RSASSA_PSS_SHA_256 
      | RSASSA_PSS_SHA_384 
      | RSASSA_PSS_SHA_512 
      | RSASSA_PKCS1_V1_5_SHA_256 
      | RSASSA_PKCS1_V1_5_SHA_384 
      | RSASSA_PKCS1_V1_5_SHA_512 
      | ECDSA_SHA_256 
      | ECDSA_SHA_384 
      | ECDSA_SHA_512 
      | SM2DSA 
      | ML_DSA_SHAKE_256 
      | ED25519_SHA_512 
      | ED25519_PH_SHA_512 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSASSA_PSS_SHA_256 -> "RSASSA_PSS_SHA_256"
      | RSASSA_PSS_SHA_384 -> "RSASSA_PSS_SHA_384"
      | RSASSA_PSS_SHA_512 -> "RSASSA_PSS_SHA_512"
      | RSASSA_PKCS1_V1_5_SHA_256 -> "RSASSA_PKCS1_V1_5_SHA_256"
      | RSASSA_PKCS1_V1_5_SHA_384 -> "RSASSA_PKCS1_V1_5_SHA_384"
      | RSASSA_PKCS1_V1_5_SHA_512 -> "RSASSA_PKCS1_V1_5_SHA_512"
      | ECDSA_SHA_256 -> "ECDSA_SHA_256"
      | ECDSA_SHA_384 -> "ECDSA_SHA_384"
      | ECDSA_SHA_512 -> "ECDSA_SHA_512"
      | SM2DSA -> "SM2DSA"
      | ML_DSA_SHAKE_256 -> "ML_DSA_SHAKE_256"
      | ED25519_SHA_512 -> "ED25519_SHA_512"
      | ED25519_PH_SHA_512 -> "ED25519_PH_SHA_512"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSASSA_PSS_SHA_256" -> RSASSA_PSS_SHA_256
      | "RSASSA_PSS_SHA_384" -> RSASSA_PSS_SHA_384
      | "RSASSA_PSS_SHA_512" -> RSASSA_PSS_SHA_512
      | "RSASSA_PKCS1_V1_5_SHA_256" -> RSASSA_PKCS1_V1_5_SHA_256
      | "RSASSA_PKCS1_V1_5_SHA_384" -> RSASSA_PKCS1_V1_5_SHA_384
      | "RSASSA_PKCS1_V1_5_SHA_512" -> RSASSA_PKCS1_V1_5_SHA_512
      | "ECDSA_SHA_256" -> ECDSA_SHA_256
      | "ECDSA_SHA_384" -> ECDSA_SHA_384
      | "ECDSA_SHA_512" -> ECDSA_SHA_512
      | "SM2DSA" -> SM2DSA
      | "ML_DSA_SHAKE_256" -> ML_DSA_SHAKE_256
      | "ED25519_SHA_512" -> ED25519_SHA_512
      | "ED25519_PH_SHA_512" -> ED25519_PH_SHA_512
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration SigningAlgorithmSpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"SigningAlgorithmSpec" j)
    let to_json = simple_to_json to_value
  end
module XksKeyIdType =
  struct
    type nonrec t = string
    let context_ = "XksKeyIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:128) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-zA-Z0-9-_.]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"XksKeyIdType" j
    let to_json = simple_to_json to_value
  end
module KeyIdType =
  struct
    type nonrec t = string
    let context_ = "KeyIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:2048) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"KeyIdType" j
    let to_json = simple_to_json to_value
  end
module BackingKeyIdType =
  struct
    type nonrec t = string
    let context_ = "BackingKeyIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:64) >>=
             (fun () ->
                (check_string_max i ~max:64) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-f0-9]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"BackingKeyIdType" j
    let to_json = simple_to_json to_value
  end
module DateType =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Timestamp x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = string_of_xml ~kind:"a timestamp"
    let of_json = timestamp_of_json
    let to_json = simple_to_json to_value
  end
module ExpirationModelType =
  struct
    type nonrec t =
      | KEY_MATERIAL_EXPIRES 
      | KEY_MATERIAL_DOES_NOT_EXPIRE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | KEY_MATERIAL_EXPIRES -> "KEY_MATERIAL_EXPIRES"
      | KEY_MATERIAL_DOES_NOT_EXPIRE -> "KEY_MATERIAL_DOES_NOT_EXPIRE"
      | Non_static_id s -> s
    let of_string =
      function
      | "KEY_MATERIAL_EXPIRES" -> KEY_MATERIAL_EXPIRES
      | "KEY_MATERIAL_DOES_NOT_EXPIRE" -> KEY_MATERIAL_DOES_NOT_EXPIRE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration ExpirationModelType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"ExpirationModelType" j)
    let to_json = simple_to_json to_value
  end
module ImportState =
  struct
    type nonrec t =
      | IMPORTED 
      | PENDING_IMPORT 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | IMPORTED -> "IMPORTED"
      | PENDING_IMPORT -> "PENDING_IMPORT"
      | Non_static_id s -> s
    let of_string =
      function
      | "IMPORTED" -> IMPORTED
      | "PENDING_IMPORT" -> PENDING_IMPORT
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration ImportState" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"ImportState" j)
    let to_json = simple_to_json to_value
  end
module KeyMaterialDescriptionType =
  struct
    type nonrec t = string
    let context_ = "KeyMaterialDescriptionType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:0) >>=
             (fun () ->
                (check_string_max i ~max:256) >>=
                  (fun () ->
                     check_pattern i ~pattern:"^[a-zA-Z0-9:/_\\s.-]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"KeyMaterialDescriptionType" j
    let to_json = simple_to_json to_value
  end
module KeyMaterialState =
  struct
    type nonrec t =
      | NON_CURRENT 
      | CURRENT 
      | PENDING_ROTATION 
      | PENDING_MULTI_REGION_IMPORT_AND_ROTATION 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | NON_CURRENT -> "NON_CURRENT"
      | CURRENT -> "CURRENT"
      | PENDING_ROTATION -> "PENDING_ROTATION"
      | PENDING_MULTI_REGION_IMPORT_AND_ROTATION ->
          "PENDING_MULTI_REGION_IMPORT_AND_ROTATION"
      | Non_static_id s -> s
    let of_string =
      function
      | "NON_CURRENT" -> NON_CURRENT
      | "CURRENT" -> CURRENT
      | "PENDING_ROTATION" -> PENDING_ROTATION
      | "PENDING_MULTI_REGION_IMPORT_AND_ROTATION" ->
          PENDING_MULTI_REGION_IMPORT_AND_ROTATION
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration KeyMaterialState" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"KeyMaterialState" j)
    let to_json = simple_to_json to_value
  end
module RotationType =
  struct
    type nonrec t =
      | AUTOMATIC 
      | ON_DEMAND 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | AUTOMATIC -> "AUTOMATIC"
      | ON_DEMAND -> "ON_DEMAND"
      | Non_static_id s -> s
    let of_string =
      function
      | "AUTOMATIC" -> AUTOMATIC
      | "ON_DEMAND" -> ON_DEMAND
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration RotationType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"RotationType" j)
    let to_json = simple_to_json to_value
  end
module GrantConstraints =
  struct
    type nonrec t =
      {
      encryptionContextSubset: EncryptionContextType.t option
        [@ocaml.doc
          "A list of key-value pairs that must be included in the encryption context of the cryptographic operation request. The grant allows the cryptographic operation only when the encryption context in the request includes the key-value pairs specified in this constraint, although it can include additional key-value pairs."];
      encryptionContextEquals: EncryptionContextType.t option
        [@ocaml.doc
          "A list of key-value pairs that must match the encryption context in the cryptographic operation request. The grant allows the operation only when the encryption context in the request is the same as the encryption context specified in this constraint."]}
    let make ?encryptionContextSubset =
      fun ?encryptionContextEquals ->
        fun () -> { encryptionContextSubset; encryptionContextEquals }
    let to_value x =
      structure_to_value
        [("EncryptionContextSubset",
           (Option.map x.encryptionContextSubset
              ~f:EncryptionContextType.to_value));
        ("EncryptionContextEquals",
          (Option.map x.encryptionContextEquals
             ~f:EncryptionContextType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let encryptionContextEquals =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContextEquals") in
      let encryptionContextSubset =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContextSubset") in
      make ?encryptionContextEquals ?encryptionContextSubset ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let encryptionContextEquals =
        field_map json__ "EncryptionContextEquals"
          EncryptionContextType.of_json in
      let encryptionContextSubset =
        field_map json__ "EncryptionContextSubset"
          EncryptionContextType.of_json in
      make ?encryptionContextEquals ?encryptionContextSubset ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Use this structure to allow cryptographic operations in the grant only when the operation request includes the specified encryption context. KMS applies the grant constraints only to cryptographic operations that support an encryption context, that is, all cryptographic operations with a symmetric KMS key. Grant constraints are not applied to operations that do not support an encryption context, such as cryptographic operations with asymmetric KMS keys and management operations, such as DescribeKey or RetireGrant. In a cryptographic operation, the encryption context in the decryption operation must be an exact, case-sensitive match for the keys and values in the encryption context of the encryption operation. Only the order of the pairs can vary. However, in a grant constraint, the key in each key-value pair is not case sensitive, but the value is case sensitive. To avoid confusion, do not use multiple encryption context pairs that differ only by case. To require a fully case-sensitive encryption context, use the kms:EncryptionContext: and kms:EncryptionContextKeys conditions in an IAM or key policy. For details, see kms:EncryptionContext:context-key in the Key Management Service Developer Guide ."]
module GrantIdType =
  struct
    type nonrec t = string
    let context_ = "GrantIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:128) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"GrantIdType" j
    let to_json = simple_to_json to_value
  end
module GrantNameType =
  struct
    type nonrec t = string
    let context_ = "GrantNameType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:256) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-zA-Z0-9:/_-]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"GrantNameType" j
    let to_json = simple_to_json to_value
  end
module GrantOperationList =
  struct
    type nonrec t = GrantOperation.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:GrantOperation.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:GrantOperation.of_xml)
    let of_json j =
      list_of_json ~kind:"GrantOperationList" ~of_json:GrantOperation.of_json
        j
    let to_json v = composed_to_json to_value v
  end
module PrincipalIdType =
  struct
    type nonrec t = string
    let context_ = "PrincipalIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:256) >>=
                  (fun () -> check_pattern i ~pattern:"^[\\w+=,.@:/-]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"PrincipalIdType" j
    let to_json = simple_to_json to_value
  end
module AliasNameType =
  struct
    type nonrec t = string
    let context_ = "AliasNameType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:256) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-zA-Z0-9:/_-]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AliasNameType" j
    let to_json = simple_to_json to_value
  end
module CloudHsmClusterIdType =
  struct
    type nonrec t = string
    let context_ = "CloudHsmClusterIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:19) >>=
             (fun () ->
                (check_string_max i ~max:24) >>=
                  (fun () ->
                     check_pattern i ~pattern:"cluster-[2-7a-zA-Z]{11,16}")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"CloudHsmClusterIdType" j
    let to_json = simple_to_json to_value
  end
module ConnectionErrorCodeType =
  struct
    type nonrec t =
      | INVALID_CREDENTIALS 
      | CLUSTER_NOT_FOUND 
      | NETWORK_ERRORS 
      | INTERNAL_ERROR 
      | INSUFFICIENT_CLOUDHSM_HSMS 
      | USER_LOCKED_OUT 
      | USER_NOT_FOUND 
      | USER_LOGGED_IN 
      | SUBNET_NOT_FOUND 
      | INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET 
      | XKS_PROXY_ACCESS_DENIED 
      | XKS_PROXY_NOT_REACHABLE 
      | XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND 
      | XKS_PROXY_INVALID_RESPONSE 
      | XKS_PROXY_INVALID_CONFIGURATION 
      | XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION 
      | XKS_PROXY_TIMED_OUT 
      | XKS_PROXY_INVALID_TLS_CONFIGURATION 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | INVALID_CREDENTIALS -> "INVALID_CREDENTIALS"
      | CLUSTER_NOT_FOUND -> "CLUSTER_NOT_FOUND"
      | NETWORK_ERRORS -> "NETWORK_ERRORS"
      | INTERNAL_ERROR -> "INTERNAL_ERROR"
      | INSUFFICIENT_CLOUDHSM_HSMS -> "INSUFFICIENT_CLOUDHSM_HSMS"
      | USER_LOCKED_OUT -> "USER_LOCKED_OUT"
      | USER_NOT_FOUND -> "USER_NOT_FOUND"
      | USER_LOGGED_IN -> "USER_LOGGED_IN"
      | SUBNET_NOT_FOUND -> "SUBNET_NOT_FOUND"
      | INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET ->
          "INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET"
      | XKS_PROXY_ACCESS_DENIED -> "XKS_PROXY_ACCESS_DENIED"
      | XKS_PROXY_NOT_REACHABLE -> "XKS_PROXY_NOT_REACHABLE"
      | XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND ->
          "XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND"
      | XKS_PROXY_INVALID_RESPONSE -> "XKS_PROXY_INVALID_RESPONSE"
      | XKS_PROXY_INVALID_CONFIGURATION -> "XKS_PROXY_INVALID_CONFIGURATION"
      | XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION ->
          "XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION"
      | XKS_PROXY_TIMED_OUT -> "XKS_PROXY_TIMED_OUT"
      | XKS_PROXY_INVALID_TLS_CONFIGURATION ->
          "XKS_PROXY_INVALID_TLS_CONFIGURATION"
      | Non_static_id s -> s
    let of_string =
      function
      | "INVALID_CREDENTIALS" -> INVALID_CREDENTIALS
      | "CLUSTER_NOT_FOUND" -> CLUSTER_NOT_FOUND
      | "NETWORK_ERRORS" -> NETWORK_ERRORS
      | "INTERNAL_ERROR" -> INTERNAL_ERROR
      | "INSUFFICIENT_CLOUDHSM_HSMS" -> INSUFFICIENT_CLOUDHSM_HSMS
      | "USER_LOCKED_OUT" -> USER_LOCKED_OUT
      | "USER_NOT_FOUND" -> USER_NOT_FOUND
      | "USER_LOGGED_IN" -> USER_LOGGED_IN
      | "SUBNET_NOT_FOUND" -> SUBNET_NOT_FOUND
      | "INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET" ->
          INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET
      | "XKS_PROXY_ACCESS_DENIED" -> XKS_PROXY_ACCESS_DENIED
      | "XKS_PROXY_NOT_REACHABLE" -> XKS_PROXY_NOT_REACHABLE
      | "XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND" ->
          XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND
      | "XKS_PROXY_INVALID_RESPONSE" -> XKS_PROXY_INVALID_RESPONSE
      | "XKS_PROXY_INVALID_CONFIGURATION" -> XKS_PROXY_INVALID_CONFIGURATION
      | "XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION" ->
          XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION
      | "XKS_PROXY_TIMED_OUT" -> XKS_PROXY_TIMED_OUT
      | "XKS_PROXY_INVALID_TLS_CONFIGURATION" ->
          XKS_PROXY_INVALID_TLS_CONFIGURATION
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration ConnectionErrorCodeType" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"ConnectionErrorCodeType" j)
    let to_json = simple_to_json to_value
  end
module ConnectionStateType =
  struct
    type nonrec t =
      | CONNECTED 
      | CONNECTING 
      | FAILED 
      | DISCONNECTED 
      | DISCONNECTING 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | CONNECTED -> "CONNECTED"
      | CONNECTING -> "CONNECTING"
      | FAILED -> "FAILED"
      | DISCONNECTED -> "DISCONNECTED"
      | DISCONNECTING -> "DISCONNECTING"
      | Non_static_id s -> s
    let of_string =
      function
      | "CONNECTED" -> CONNECTED
      | "CONNECTING" -> CONNECTING
      | "FAILED" -> FAILED
      | "DISCONNECTED" -> DISCONNECTED
      | "DISCONNECTING" -> DISCONNECTING
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration ConnectionStateType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"ConnectionStateType" j)
    let to_json = simple_to_json to_value
  end
module CustomKeyStoreIdType =
  struct
    type nonrec t = string
    let context_ = "CustomKeyStoreIdType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:64) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"CustomKeyStoreIdType" j
    let to_json = simple_to_json to_value
  end
module CustomKeyStoreNameType =
  struct
    type nonrec t = string
    let context_ = "CustomKeyStoreNameType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:256) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"CustomKeyStoreNameType" j
    let to_json = simple_to_json to_value
  end
module CustomKeyStoreType =
  struct
    type nonrec t =
      | AWS_CLOUDHSM 
      | EXTERNAL_KEY_STORE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | AWS_CLOUDHSM -> "AWS_CLOUDHSM"
      | EXTERNAL_KEY_STORE -> "EXTERNAL_KEY_STORE"
      | Non_static_id s -> s
    let of_string =
      function
      | "AWS_CLOUDHSM" -> AWS_CLOUDHSM
      | "EXTERNAL_KEY_STORE" -> EXTERNAL_KEY_STORE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration CustomKeyStoreType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"CustomKeyStoreType" j)
    let to_json = simple_to_json to_value
  end
module TrustAnchorCertificateType =
  struct
    type nonrec t = string
    let context_ = "TrustAnchorCertificateType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:5000) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"TrustAnchorCertificateType" j
    let to_json = simple_to_json to_value
  end
module XksProxyConfigurationType =
  struct
    type nonrec t =
      {
      connectivity: XksProxyConnectivityType.t option
        [@ocaml.doc
          "Indicates whether the external key store proxy uses a public endpoint or an Amazon VPC endpoint service to communicate with KMS."];
      accessKeyId: XksProxyAuthenticationAccessKeyIdType.t option
        [@ocaml.doc
          "The part of the external key store proxy authentication credential that uniquely identifies the secret access key."];
      uriEndpoint: XksProxyUriEndpointType.t option
        [@ocaml.doc
          "The URI endpoint for the external key store proxy. If the external key store proxy has a public endpoint, it is displayed here. If the external key store proxy uses an Amazon VPC endpoint service name, this field displays the private DNS name associated with the VPC endpoint service."];
      uriPath: XksProxyUriPathType.t option
        [@ocaml.doc "The path to the external key store proxy APIs."];
      vpcEndpointServiceName: XksProxyVpcEndpointServiceNameType.t option
        [@ocaml.doc
          "The Amazon VPC endpoint service used to communicate with the external key store proxy. This field appears only when the external key store proxy uses an Amazon VPC endpoint service to communicate with KMS."];
      vpcEndpointServiceOwner: AccountIdType.t option
        [@ocaml.doc
          "The Amazon Web Services account ID that owns the Amazon VPC endpoint service used to communicate with the external key store proxy (XKS). This field appears only when the XKS uses an VPC endpoint service to communicate with KMS."]}
    let make ?connectivity =
      fun ?accessKeyId ->
        fun ?uriEndpoint ->
          fun ?uriPath ->
            fun ?vpcEndpointServiceName ->
              fun ?vpcEndpointServiceOwner ->
                fun () ->
                  {
                    connectivity;
                    accessKeyId;
                    uriEndpoint;
                    uriPath;
                    vpcEndpointServiceName;
                    vpcEndpointServiceOwner
                  }
    let to_value x =
      structure_to_value
        [("Connectivity",
           (Option.map x.connectivity ~f:XksProxyConnectivityType.to_value));
        ("AccessKeyId",
          (Option.map x.accessKeyId
             ~f:XksProxyAuthenticationAccessKeyIdType.to_value));
        ("UriEndpoint",
          (Option.map x.uriEndpoint ~f:XksProxyUriEndpointType.to_value));
        ("UriPath", (Option.map x.uriPath ~f:XksProxyUriPathType.to_value));
        ("VpcEndpointServiceName",
          (Option.map x.vpcEndpointServiceName
             ~f:XksProxyVpcEndpointServiceNameType.to_value));
        ("VpcEndpointServiceOwner",
          (Option.map x.vpcEndpointServiceOwner ~f:AccountIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let vpcEndpointServiceOwner =
        (Option.map ~f:AccountIdType.of_xml)
          (Xml.child xml_arg0 "VpcEndpointServiceOwner") in
      let vpcEndpointServiceName =
        (Option.map ~f:XksProxyVpcEndpointServiceNameType.of_xml)
          (Xml.child xml_arg0 "VpcEndpointServiceName") in
      let uriPath =
        (Option.map ~f:XksProxyUriPathType.of_xml)
          (Xml.child xml_arg0 "UriPath") in
      let uriEndpoint =
        (Option.map ~f:XksProxyUriEndpointType.of_xml)
          (Xml.child xml_arg0 "UriEndpoint") in
      let accessKeyId =
        (Option.map ~f:XksProxyAuthenticationAccessKeyIdType.of_xml)
          (Xml.child xml_arg0 "AccessKeyId") in
      let connectivity =
        (Option.map ~f:XksProxyConnectivityType.of_xml)
          (Xml.child xml_arg0 "Connectivity") in
      make ?vpcEndpointServiceOwner ?vpcEndpointServiceName ?uriPath
        ?uriEndpoint ?accessKeyId ?connectivity ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let vpcEndpointServiceOwner =
        field_map json__ "VpcEndpointServiceOwner" AccountIdType.of_json in
      let vpcEndpointServiceName =
        field_map json__ "VpcEndpointServiceName"
          XksProxyVpcEndpointServiceNameType.of_json in
      let uriPath = field_map json__ "UriPath" XksProxyUriPathType.of_json in
      let uriEndpoint =
        field_map json__ "UriEndpoint" XksProxyUriEndpointType.of_json in
      let accessKeyId =
        field_map json__ "AccessKeyId"
          XksProxyAuthenticationAccessKeyIdType.of_json in
      let connectivity =
        field_map json__ "Connectivity" XksProxyConnectivityType.of_json in
      make ?vpcEndpointServiceOwner ?vpcEndpointServiceName ?uriPath
        ?uriEndpoint ?accessKeyId ?connectivity ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Detailed information about the external key store proxy (XKS proxy). Your external key store proxy translates KMS requests into a format that your external key manager can understand. These fields appear in a DescribeCustomKeyStores response only when the CustomKeyStoreType is EXTERNAL_KEY_STORE."]
module ErrorMessageType =
  struct
    type nonrec t = string
    let context_ = "ErrorMessageType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"ErrorMessageType" j
    let to_json = simple_to_json to_value
  end
module GrantTokenType =
  struct
    type nonrec t = string
    let context_ = "GrantTokenType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:8192) >>=
             (fun () -> check_string_min i ~min:1));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"GrantTokenType" j
    let to_json = simple_to_json to_value
  end
module XksProxyAuthenticationRawSecretAccessKeyType =
  struct
    type nonrec t = string
    let context_ = "XksProxyAuthenticationRawSecretAccessKeyType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:43) >>=
             (fun () ->
                (check_string_max i ~max:64) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-zA-Z0-9\\/+=]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j =
      string_of_json ~kind:"XksProxyAuthenticationRawSecretAccessKeyType" j
    let to_json = simple_to_json to_value
  end
module Tag =
  struct
    type nonrec t =
      {
      tagKey: TagKeyType.t [@ocaml.doc "The key of the tag."];
      tagValue: TagValueType.t [@ocaml.doc "The value of the tag."]}
    let context_ = "Tag"
    let make ~tagKey = fun ~tagValue -> fun () -> { tagKey; tagValue }
    let to_value x =
      structure_to_value
        [("TagKey", (Some (TagKeyType.to_value x.tagKey)));
        ("TagValue", (Some (TagValueType.to_value x.tagValue)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let tagValue =
        TagValueType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "TagValue") in
      let tagKey =
        TagKeyType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "TagKey") in
      make ~tagValue ~tagKey ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let tagValue = field_map_exn json__ "TagValue" TagValueType.of_json in
      let tagKey = field_map_exn json__ "TagKey" TagKeyType.of_json in
      make ~tagValue ~tagKey ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "A key-value pair. A tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. For information about the rules that apply to tag keys and tag values, see User-Defined Tag Restrictions in the Amazon Web Services Billing and Cost Management User Guide."]
module AWSAccountIdType =
  struct
    type nonrec t = string
    let context_ = "AWSAccountIdType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"AWSAccountIdType" j
    let to_json = simple_to_json to_value
  end
module BooleanType =
  struct
    type nonrec t = bool
    let make i = i
    let of_string = Bool.of_string
    let to_value x = `Boolean x
    let to_query v = to_query to_value v
    let to_header x = Bool.to_string x
    let of_xml xml_arg0 =
      Bool.of_string (string_of_xml ~kind:"a boolean" xml_arg0)
    let of_json = bool_of_json
    let to_json = simple_to_json to_value
  end
module CustomerMasterKeySpec =
  struct
    type nonrec t =
      | RSA_2048 
      | RSA_3072 
      | RSA_4096 
      | ECC_NIST_P256 
      | ECC_NIST_P384 
      | ECC_NIST_P521 
      | ECC_SECG_P256K1 
      | SYMMETRIC_DEFAULT 
      | HMAC_224 
      | HMAC_256 
      | HMAC_384 
      | HMAC_512 
      | SM2 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSA_2048 -> "RSA_2048"
      | RSA_3072 -> "RSA_3072"
      | RSA_4096 -> "RSA_4096"
      | ECC_NIST_P256 -> "ECC_NIST_P256"
      | ECC_NIST_P384 -> "ECC_NIST_P384"
      | ECC_NIST_P521 -> "ECC_NIST_P521"
      | ECC_SECG_P256K1 -> "ECC_SECG_P256K1"
      | SYMMETRIC_DEFAULT -> "SYMMETRIC_DEFAULT"
      | HMAC_224 -> "HMAC_224"
      | HMAC_256 -> "HMAC_256"
      | HMAC_384 -> "HMAC_384"
      | HMAC_512 -> "HMAC_512"
      | SM2 -> "SM2"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSA_2048" -> RSA_2048
      | "RSA_3072" -> RSA_3072
      | "RSA_4096" -> RSA_4096
      | "ECC_NIST_P256" -> ECC_NIST_P256
      | "ECC_NIST_P384" -> ECC_NIST_P384
      | "ECC_NIST_P521" -> ECC_NIST_P521
      | "ECC_SECG_P256K1" -> ECC_SECG_P256K1
      | "SYMMETRIC_DEFAULT" -> SYMMETRIC_DEFAULT
      | "HMAC_224" -> HMAC_224
      | "HMAC_256" -> HMAC_256
      | "HMAC_384" -> HMAC_384
      | "HMAC_512" -> HMAC_512
      | "SM2" -> SM2
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration CustomerMasterKeySpec" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"CustomerMasterKeySpec" j)
    let to_json = simple_to_json to_value
  end
module DescriptionType =
  struct
    type nonrec t = string
    let context_ = "DescriptionType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:8192) >>=
             (fun () -> check_string_min i ~min:0));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"DescriptionType" j
    let to_json = simple_to_json to_value
  end
module EncryptionAlgorithmSpecList =
  struct
    type nonrec t = EncryptionAlgorithmSpec.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:EncryptionAlgorithmSpec.to_value)) |>
        (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:EncryptionAlgorithmSpec.of_xml)
    let of_json j =
      list_of_json ~kind:"EncryptionAlgorithmSpecList"
        ~of_json:EncryptionAlgorithmSpec.of_json j
    let to_json v = composed_to_json to_value v
  end
module KeyAgreementAlgorithmSpecList =
  struct
    type nonrec t = KeyAgreementAlgorithmSpec.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:KeyAgreementAlgorithmSpec.to_value)) |>
        (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:KeyAgreementAlgorithmSpec.of_xml)
    let of_json j =
      list_of_json ~kind:"KeyAgreementAlgorithmSpecList"
        ~of_json:KeyAgreementAlgorithmSpec.of_json j
    let to_json v = composed_to_json to_value v
  end
module KeyManagerType =
  struct
    type nonrec t =
      | AWS 
      | CUSTOMER 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function | AWS -> "AWS" | CUSTOMER -> "CUSTOMER" | Non_static_id s -> s
    let of_string =
      function | "AWS" -> AWS | "CUSTOMER" -> CUSTOMER | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration KeyManagerType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"KeyManagerType" j)
    let to_json = simple_to_json to_value
  end
module KeySpec =
  struct
    type nonrec t =
      | RSA_2048 
      | RSA_3072 
      | RSA_4096 
      | ECC_NIST_P256 
      | ECC_NIST_P384 
      | ECC_NIST_P521 
      | ECC_SECG_P256K1 
      | SYMMETRIC_DEFAULT 
      | HMAC_224 
      | HMAC_256 
      | HMAC_384 
      | HMAC_512 
      | SM2 
      | ML_DSA_44 
      | ML_DSA_65 
      | ML_DSA_87 
      | ECC_NIST_EDWARDS25519 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSA_2048 -> "RSA_2048"
      | RSA_3072 -> "RSA_3072"
      | RSA_4096 -> "RSA_4096"
      | ECC_NIST_P256 -> "ECC_NIST_P256"
      | ECC_NIST_P384 -> "ECC_NIST_P384"
      | ECC_NIST_P521 -> "ECC_NIST_P521"
      | ECC_SECG_P256K1 -> "ECC_SECG_P256K1"
      | SYMMETRIC_DEFAULT -> "SYMMETRIC_DEFAULT"
      | HMAC_224 -> "HMAC_224"
      | HMAC_256 -> "HMAC_256"
      | HMAC_384 -> "HMAC_384"
      | HMAC_512 -> "HMAC_512"
      | SM2 -> "SM2"
      | ML_DSA_44 -> "ML_DSA_44"
      | ML_DSA_65 -> "ML_DSA_65"
      | ML_DSA_87 -> "ML_DSA_87"
      | ECC_NIST_EDWARDS25519 -> "ECC_NIST_EDWARDS25519"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSA_2048" -> RSA_2048
      | "RSA_3072" -> RSA_3072
      | "RSA_4096" -> RSA_4096
      | "ECC_NIST_P256" -> ECC_NIST_P256
      | "ECC_NIST_P384" -> ECC_NIST_P384
      | "ECC_NIST_P521" -> ECC_NIST_P521
      | "ECC_SECG_P256K1" -> ECC_SECG_P256K1
      | "SYMMETRIC_DEFAULT" -> SYMMETRIC_DEFAULT
      | "HMAC_224" -> HMAC_224
      | "HMAC_256" -> HMAC_256
      | "HMAC_384" -> HMAC_384
      | "HMAC_512" -> HMAC_512
      | "SM2" -> SM2
      | "ML_DSA_44" -> ML_DSA_44
      | "ML_DSA_65" -> ML_DSA_65
      | "ML_DSA_87" -> ML_DSA_87
      | "ECC_NIST_EDWARDS25519" -> ECC_NIST_EDWARDS25519
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration KeySpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"KeySpec" j)
    let to_json = simple_to_json to_value
  end
module KeyState =
  struct
    type nonrec t =
      | Creating 
      | Enabled 
      | Disabled 
      | PendingDeletion 
      | PendingImport 
      | PendingReplicaDeletion 
      | Unavailable 
      | Updating 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | Creating -> "Creating"
      | Enabled -> "Enabled"
      | Disabled -> "Disabled"
      | PendingDeletion -> "PendingDeletion"
      | PendingImport -> "PendingImport"
      | PendingReplicaDeletion -> "PendingReplicaDeletion"
      | Unavailable -> "Unavailable"
      | Updating -> "Updating"
      | Non_static_id s -> s
    let of_string =
      function
      | "Creating" -> Creating
      | "Enabled" -> Enabled
      | "Disabled" -> Disabled
      | "PendingDeletion" -> PendingDeletion
      | "PendingImport" -> PendingImport
      | "PendingReplicaDeletion" -> PendingReplicaDeletion
      | "Unavailable" -> Unavailable
      | "Updating" -> Updating
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration KeyState" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"KeyState" j)
    let to_json = simple_to_json to_value
  end
module KeyUsageType =
  struct
    type nonrec t =
      | SIGN_VERIFY 
      | ENCRYPT_DECRYPT 
      | GENERATE_VERIFY_MAC 
      | KEY_AGREEMENT 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | SIGN_VERIFY -> "SIGN_VERIFY"
      | ENCRYPT_DECRYPT -> "ENCRYPT_DECRYPT"
      | GENERATE_VERIFY_MAC -> "GENERATE_VERIFY_MAC"
      | KEY_AGREEMENT -> "KEY_AGREEMENT"
      | Non_static_id s -> s
    let of_string =
      function
      | "SIGN_VERIFY" -> SIGN_VERIFY
      | "ENCRYPT_DECRYPT" -> ENCRYPT_DECRYPT
      | "GENERATE_VERIFY_MAC" -> GENERATE_VERIFY_MAC
      | "KEY_AGREEMENT" -> KEY_AGREEMENT
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration KeyUsageType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"KeyUsageType" j)
    let to_json = simple_to_json to_value
  end
module MacAlgorithmSpecList =
  struct
    type nonrec t = MacAlgorithmSpec.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:MacAlgorithmSpec.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:MacAlgorithmSpec.of_xml)
    let of_json j =
      list_of_json ~kind:"MacAlgorithmSpecList"
        ~of_json:MacAlgorithmSpec.of_json j
    let to_json v = composed_to_json to_value v
  end
module MultiRegionConfiguration =
  struct
    type nonrec t =
      {
      multiRegionKeyType: MultiRegionKeyType.t option
        [@ocaml.doc
          "Indicates whether the KMS key is a PRIMARY or REPLICA key."];
      primaryKey: MultiRegionKey.t option
        [@ocaml.doc
          "Displays the key ARN and Region of the primary key. This field includes the current KMS key if it is the primary key."];
      replicaKeys: MultiRegionKeyList.t option
        [@ocaml.doc
          "displays the key ARNs and Regions of all replica keys. This field includes the current KMS key if it is a replica key."]}
    let make ?multiRegionKeyType =
      fun ?primaryKey ->
        fun ?replicaKeys ->
          fun () -> { multiRegionKeyType; primaryKey; replicaKeys }
    let to_value x =
      structure_to_value
        [("MultiRegionKeyType",
           (Option.map x.multiRegionKeyType ~f:MultiRegionKeyType.to_value));
        ("PrimaryKey", (Option.map x.primaryKey ~f:MultiRegionKey.to_value));
        ("ReplicaKeys",
          (Option.map x.replicaKeys ~f:MultiRegionKeyList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let replicaKeys =
        (Option.map ~f:MultiRegionKeyList.of_xml)
          (Xml.child xml_arg0 "ReplicaKeys") in
      let primaryKey =
        (Option.map ~f:MultiRegionKey.of_xml)
          (Xml.child xml_arg0 "PrimaryKey") in
      let multiRegionKeyType =
        (Option.map ~f:MultiRegionKeyType.of_xml)
          (Xml.child xml_arg0 "MultiRegionKeyType") in
      make ?replicaKeys ?primaryKey ?multiRegionKeyType ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let replicaKeys =
        field_map json__ "ReplicaKeys" MultiRegionKeyList.of_json in
      let primaryKey = field_map json__ "PrimaryKey" MultiRegionKey.of_json in
      let multiRegionKeyType =
        field_map json__ "MultiRegionKeyType" MultiRegionKeyType.of_json in
      make ?replicaKeys ?primaryKey ?multiRegionKeyType ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Describes the configuration of this multi-Region key. This field appears only when the KMS key is a primary or replica of a multi-Region key. For more information about any listed KMS key, use the DescribeKey operation."]
module NullableBooleanType =
  struct
    type nonrec t = bool
    let make i = i
    let of_string = Bool.of_string
    let to_value x = `Boolean x
    let to_query v = to_query to_value v
    let to_header x = Bool.to_string x
    let of_xml xml_arg0 =
      Bool.of_string (string_of_xml ~kind:"a boolean" xml_arg0)
    let of_json = bool_of_json
    let to_json = simple_to_json to_value
  end
module OriginType =
  struct
    type nonrec t =
      | AWS_KMS 
      | EXTERNAL 
      | AWS_CLOUDHSM 
      | EXTERNAL_KEY_STORE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | AWS_KMS -> "AWS_KMS"
      | EXTERNAL -> "EXTERNAL"
      | AWS_CLOUDHSM -> "AWS_CLOUDHSM"
      | EXTERNAL_KEY_STORE -> "EXTERNAL_KEY_STORE"
      | Non_static_id s -> s
    let of_string =
      function
      | "AWS_KMS" -> AWS_KMS
      | "EXTERNAL" -> EXTERNAL
      | "AWS_CLOUDHSM" -> AWS_CLOUDHSM
      | "EXTERNAL_KEY_STORE" -> EXTERNAL_KEY_STORE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration OriginType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"OriginType" j)
    let to_json = simple_to_json to_value
  end
module PendingWindowInDaysType =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:365) >>= (fun () -> check_int_min i ~min:1));
        i
    let of_string = Int.of_string
    let to_value x = `Integer x
    let to_query v = to_query to_value v
    let to_header x = Int.to_string x
    let of_xml xml_arg0 =
      Int.of_string
        (string_of_xml ~kind:"an integer for PendingWindowInDaysType"
           xml_arg0)
    let of_json j = Int.of_float (float_of_json ~kind:"an integer" j)
    let to_json = simple_to_json to_value
  end
module SigningAlgorithmSpecList =
  struct
    type nonrec t = SigningAlgorithmSpec.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:SigningAlgorithmSpec.to_value)) |>
        (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:SigningAlgorithmSpec.of_xml)
    let of_json j =
      list_of_json ~kind:"SigningAlgorithmSpecList"
        ~of_json:SigningAlgorithmSpec.of_json j
    let to_json v = composed_to_json to_value v
  end
module XksKeyConfigurationType =
  struct
    type nonrec t =
      {
      id: XksKeyIdType.t option
        [@ocaml.doc
          "The ID of the external key in its external key manager. This is the ID that the external key store proxy uses to identify the external key."]}
    let make ?id = fun () -> { id }
    let to_value x =
      structure_to_value [("Id", (Option.map x.id ~f:XksKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let id = (Option.map ~f:XksKeyIdType.of_xml) (Xml.child xml_arg0 "Id") in
      make ?id ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let id = field_map json__ "Id" XksKeyIdType.of_json in make ?id ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Information about the external key that is associated with a KMS key in an external key store. This element appears in a CreateKey or DescribeKey response only for a KMS key in an external key store. The external key is a symmetric encryption key that is hosted by an external key manager outside of Amazon Web Services. When you use the KMS key in an external key store in a cryptographic operation, the cryptographic operation is performed in the external key manager using the specified external key. For more information, see External key in the Key Management Service Developer Guide."]
module DryRunModifierType =
  struct
    type nonrec t =
      | IGNORE_CIPHERTEXT 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | IGNORE_CIPHERTEXT -> "IGNORE_CIPHERTEXT"
      | Non_static_id s -> s
    let of_string =
      function
      | "IGNORE_CIPHERTEXT" -> IGNORE_CIPHERTEXT
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration DryRunModifierType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"DryRunModifierType" j)
    let to_json = simple_to_json to_value
  end
module KeyListEntry =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option [@ocaml.doc "Unique identifier of the key."];
      keyArn: ArnType.t option [@ocaml.doc "ARN of the key."]}
    let make ?keyId = fun ?keyArn -> fun () -> { keyId; keyArn }
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyArn", (Option.map x.keyArn ~f:ArnType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyArn =
        (Option.map ~f:ArnType.of_xml) (Xml.child xml_arg0 "KeyArn") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyArn ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyArn = field_map json__ "KeyArn" ArnType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyArn ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Contains information about each entry in the key list."]
module RotationsListEntry =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option [@ocaml.doc "Unique identifier of the key."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc "Unique identifier of the key material."];
      keyMaterialDescription: KeyMaterialDescriptionType.t option
        [@ocaml.doc
          "User-specified description of the key material. This field is only present for symmetric encryption KMS keys with EXTERNAL origin."];
      importState: ImportState.t option
        [@ocaml.doc
          "Indicates if the key material is currently imported into KMS. It has two possible values: IMPORTED or PENDING_IMPORT. This field is only present for symmetric encryption KMS keys with EXTERNAL origin."];
      keyMaterialState: KeyMaterialState.t option
        [@ocaml.doc
          "There are four possible values for this field: CURRENT, NON_CURRENT, PENDING_MULTI_REGION_IMPORT_AND_ROTATION and PENDING_ROTATION. KMS uses CURRENT key material for both encryption and decryption and NON_CURRENT key material only for decryption. PENDING_ROTATION identifies key material that has been imported for on-demand key rotation but the rotation hasn't completed. The key material state PENDING_MULTI_REGION_IMPORT_AND_ROTATION is unique to multi-region, symmetric encryption keys with imported key material. It indicates key material that has been imported into the primary Region key but not all of the replica Region keys. When this key material is imported in to all of the replica Region keys, the key material state will change to PENDING_ROTATION. Key material in PENDING_MULTI_REGION_IMPORT_AND_ROTATION or PENDING_ROTATION state is not permanently associated with the KMS key. You can delete this key material and import different key material in its place. The PENDING_MULTI_REGION_IMPORT_AND_ROTATION and PENDING_ROTATION values are only used in symmetric encryption keys with imported key material. The other values, CURRENT and NON_CURRENT, are used for all KMS keys that support automatic or on-demand key rotation."];
      expirationModel: ExpirationModelType.t option
        [@ocaml.doc
          "Indicates if the key material is configured to automatically expire. There are two possible values for this field: KEY_MATERIAL_EXPIRES and KEY_MATERIAL_DOES_NOT_EXPIRE. For any key material that expires, the expiration date and time is indicated in ValidTo. This field is only present for symmetric encryption KMS keys with EXTERNAL origin."];
      validTo: DateType.t option
        [@ocaml.doc
          "Date and time at which the key material expires. This field is only present for symmetric encryption KMS keys with EXTERNAL origin in rotation list entries with an ExpirationModel value of KEY_MATERIAL_EXPIRES."];
      rotationDate: DateType.t option
        [@ocaml.doc
          "Date and time that the key material rotation completed. Formatted as Unix time. This field is not present for the first key material or an imported key material in PENDING_ROTATION state."];
      rotationType: RotationType.t option
        [@ocaml.doc
          "Identifies whether the key material rotation was a scheduled automatic rotation or an on-demand rotation. This field is not present for the first key material or an imported key material in PENDING_ROTATION state."]}
    let make ?keyId =
      fun ?keyMaterialId ->
        fun ?keyMaterialDescription ->
          fun ?importState ->
            fun ?keyMaterialState ->
              fun ?expirationModel ->
                fun ?validTo ->
                  fun ?rotationDate ->
                    fun ?rotationType ->
                      fun () ->
                        {
                          keyId;
                          keyMaterialId;
                          keyMaterialDescription;
                          importState;
                          keyMaterialState;
                          expirationModel;
                          validTo;
                          rotationDate;
                          rotationType
                        }
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value));
        ("KeyMaterialDescription",
          (Option.map x.keyMaterialDescription
             ~f:KeyMaterialDescriptionType.to_value));
        ("ImportState", (Option.map x.importState ~f:ImportState.to_value));
        ("KeyMaterialState",
          (Option.map x.keyMaterialState ~f:KeyMaterialState.to_value));
        ("ExpirationModel",
          (Option.map x.expirationModel ~f:ExpirationModelType.to_value));
        ("ValidTo", (Option.map x.validTo ~f:DateType.to_value));
        ("RotationDate", (Option.map x.rotationDate ~f:DateType.to_value));
        ("RotationType",
          (Option.map x.rotationType ~f:RotationType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let rotationType =
        (Option.map ~f:RotationType.of_xml)
          (Xml.child xml_arg0 "RotationType") in
      let rotationDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "RotationDate") in
      let validTo =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "ValidTo") in
      let expirationModel =
        (Option.map ~f:ExpirationModelType.of_xml)
          (Xml.child xml_arg0 "ExpirationModel") in
      let keyMaterialState =
        (Option.map ~f:KeyMaterialState.of_xml)
          (Xml.child xml_arg0 "KeyMaterialState") in
      let importState =
        (Option.map ~f:ImportState.of_xml) (Xml.child xml_arg0 "ImportState") in
      let keyMaterialDescription =
        (Option.map ~f:KeyMaterialDescriptionType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialDescription") in
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?rotationType ?rotationDate ?validTo ?expirationModel
        ?keyMaterialState ?importState ?keyMaterialDescription ?keyMaterialId
        ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let rotationType = field_map json__ "RotationType" RotationType.of_json in
      let rotationDate = field_map json__ "RotationDate" DateType.of_json in
      let validTo = field_map json__ "ValidTo" DateType.of_json in
      let expirationModel =
        field_map json__ "ExpirationModel" ExpirationModelType.of_json in
      let keyMaterialState =
        field_map json__ "KeyMaterialState" KeyMaterialState.of_json in
      let importState = field_map json__ "ImportState" ImportState.of_json in
      let keyMaterialDescription =
        field_map json__ "KeyMaterialDescription"
          KeyMaterialDescriptionType.of_json in
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?rotationType ?rotationDate ?validTo ?expirationModel
        ?keyMaterialState ?importState ?keyMaterialDescription ?keyMaterialId
        ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Each entry contains information about one of the key materials associated with a KMS key."]
module PolicyNameType =
  struct
    type nonrec t = string
    let context_ = "PolicyNameType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:128) >>=
                  (fun () -> check_pattern i ~pattern:"[\\w]+")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"PolicyNameType" j
    let to_json = simple_to_json to_value
  end
module GrantListEntry =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The unique identifier for the KMS key to which the grant applies."];
      grantId: GrantIdType.t option
        [@ocaml.doc "The unique identifier for the grant."];
      name: GrantNameType.t option
        [@ocaml.doc
          "The friendly name that identifies the grant. If a name was provided in the CreateGrant request, that name is returned. Otherwise this value is null."];
      creationDate: DateType.t option
        [@ocaml.doc "The date and time when the grant was created."];
      granteePrincipal: PrincipalIdType.t option
        [@ocaml.doc
          "The identity that gets the permissions in the grant. The GranteePrincipal field in the ListGrants response usually contains the user or role designated as the grantee principal in the grant. However, when the grantee principal in the grant is an Amazon Web Services service, the GranteePrincipal field contains the service principal, which might represent several different grantee principals."];
      retiringPrincipal: PrincipalIdType.t option
        [@ocaml.doc "The principal that can retire the grant."];
      issuingAccount: PrincipalIdType.t option
        [@ocaml.doc
          "The Amazon Web Services account under which the grant was issued."];
      operations: GrantOperationList.t option
        [@ocaml.doc "The list of operations permitted by the grant."];
      constraints: GrantConstraints.t option
        [@ocaml.doc
          "A list of key-value pairs that must be present in the encryption context of certain subsequent operations that the grant allows."]}
    let make ?keyId =
      fun ?grantId ->
        fun ?name ->
          fun ?creationDate ->
            fun ?granteePrincipal ->
              fun ?retiringPrincipal ->
                fun ?issuingAccount ->
                  fun ?operations ->
                    fun ?constraints ->
                      fun () ->
                        {
                          keyId;
                          grantId;
                          name;
                          creationDate;
                          granteePrincipal;
                          retiringPrincipal;
                          issuingAccount;
                          operations;
                          constraints
                        }
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("GrantId", (Option.map x.grantId ~f:GrantIdType.to_value));
        ("Name", (Option.map x.name ~f:GrantNameType.to_value));
        ("CreationDate", (Option.map x.creationDate ~f:DateType.to_value));
        ("GranteePrincipal",
          (Option.map x.granteePrincipal ~f:PrincipalIdType.to_value));
        ("RetiringPrincipal",
          (Option.map x.retiringPrincipal ~f:PrincipalIdType.to_value));
        ("IssuingAccount",
          (Option.map x.issuingAccount ~f:PrincipalIdType.to_value));
        ("Operations",
          (Option.map x.operations ~f:GrantOperationList.to_value));
        ("Constraints",
          (Option.map x.constraints ~f:GrantConstraints.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let constraints =
        (Option.map ~f:GrantConstraints.of_xml)
          (Xml.child xml_arg0 "Constraints") in
      let operations =
        (Option.map ~f:GrantOperationList.of_xml)
          (Xml.child xml_arg0 "Operations") in
      let issuingAccount =
        (Option.map ~f:PrincipalIdType.of_xml)
          (Xml.child xml_arg0 "IssuingAccount") in
      let retiringPrincipal =
        (Option.map ~f:PrincipalIdType.of_xml)
          (Xml.child xml_arg0 "RetiringPrincipal") in
      let granteePrincipal =
        (Option.map ~f:PrincipalIdType.of_xml)
          (Xml.child xml_arg0 "GranteePrincipal") in
      let creationDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "CreationDate") in
      let name =
        (Option.map ~f:GrantNameType.of_xml) (Xml.child xml_arg0 "Name") in
      let grantId =
        (Option.map ~f:GrantIdType.of_xml) (Xml.child xml_arg0 "GrantId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?constraints ?operations ?issuingAccount ?retiringPrincipal
        ?granteePrincipal ?creationDate ?name ?grantId ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let constraints =
        field_map json__ "Constraints" GrantConstraints.of_json in
      let operations =
        field_map json__ "Operations" GrantOperationList.of_json in
      let issuingAccount =
        field_map json__ "IssuingAccount" PrincipalIdType.of_json in
      let retiringPrincipal =
        field_map json__ "RetiringPrincipal" PrincipalIdType.of_json in
      let granteePrincipal =
        field_map json__ "GranteePrincipal" PrincipalIdType.of_json in
      let creationDate = field_map json__ "CreationDate" DateType.of_json in
      let name = field_map json__ "Name" GrantNameType.of_json in
      let grantId = field_map json__ "GrantId" GrantIdType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?constraints ?operations ?issuingAccount ?retiringPrincipal
        ?granteePrincipal ?creationDate ?name ?grantId ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Contains information about a grant."]
module AliasListEntry =
  struct
    type nonrec t =
      {
      aliasName: AliasNameType.t option
        [@ocaml.doc
          "String that contains the alias. This value begins with alias/."];
      aliasArn: ArnType.t option
        [@ocaml.doc "String that contains the key ARN."];
      targetKeyId: KeyIdType.t option
        [@ocaml.doc
          "String that contains the key identifier of the KMS key associated with the alias."];
      creationDate: DateType.t option
        [@ocaml.doc
          "Date and time that the alias was most recently created in the account and Region. Formatted as Unix time."];
      lastUpdatedDate: DateType.t option
        [@ocaml.doc
          "Date and time that the alias was most recently associated with a KMS key in the account and Region. Formatted as Unix time."]}
    let make ?aliasName =
      fun ?aliasArn ->
        fun ?targetKeyId ->
          fun ?creationDate ->
            fun ?lastUpdatedDate ->
              fun () ->
                {
                  aliasName;
                  aliasArn;
                  targetKeyId;
                  creationDate;
                  lastUpdatedDate
                }
    let to_value x =
      structure_to_value
        [("AliasName", (Option.map x.aliasName ~f:AliasNameType.to_value));
        ("AliasArn", (Option.map x.aliasArn ~f:ArnType.to_value));
        ("TargetKeyId", (Option.map x.targetKeyId ~f:KeyIdType.to_value));
        ("CreationDate", (Option.map x.creationDate ~f:DateType.to_value));
        ("LastUpdatedDate",
          (Option.map x.lastUpdatedDate ~f:DateType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let lastUpdatedDate =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "LastUpdatedDate") in
      let creationDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "CreationDate") in
      let targetKeyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "TargetKeyId") in
      let aliasArn =
        (Option.map ~f:ArnType.of_xml) (Xml.child xml_arg0 "AliasArn") in
      let aliasName =
        (Option.map ~f:AliasNameType.of_xml) (Xml.child xml_arg0 "AliasName") in
      make ?lastUpdatedDate ?creationDate ?targetKeyId ?aliasArn ?aliasName
        ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let lastUpdatedDate =
        field_map json__ "LastUpdatedDate" DateType.of_json in
      let creationDate = field_map json__ "CreationDate" DateType.of_json in
      let targetKeyId = field_map json__ "TargetKeyId" KeyIdType.of_json in
      let aliasArn = field_map json__ "AliasArn" ArnType.of_json in
      let aliasName = field_map json__ "AliasName" AliasNameType.of_json in
      make ?lastUpdatedDate ?creationDate ?targetKeyId ?aliasArn ?aliasName
        ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc "Contains information about an alias."]
module CloudTrailEventIdType =
  struct
    type nonrec t = string
    let context_ = "CloudTrailEventIdType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"CloudTrailEventIdType" j
    let to_json = simple_to_json to_value
  end
module KeyLastUsageTrackingOperation =
  struct
    type nonrec t =
      | Decrypt 
      | DeriveSharedSecret 
      | Encrypt 
      | GenerateDataKey 
      | GenerateDataKeyPair 
      | GenerateDataKeyPairWithoutPlaintext 
      | GenerateDataKeyWithoutPlaintext 
      | GenerateMac 
      | ReEncrypt 
      | Sign 
      | Verify 
      | VerifyMac 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | Decrypt -> "Decrypt"
      | DeriveSharedSecret -> "DeriveSharedSecret"
      | Encrypt -> "Encrypt"
      | GenerateDataKey -> "GenerateDataKey"
      | GenerateDataKeyPair -> "GenerateDataKeyPair"
      | GenerateDataKeyPairWithoutPlaintext ->
          "GenerateDataKeyPairWithoutPlaintext"
      | GenerateDataKeyWithoutPlaintext -> "GenerateDataKeyWithoutPlaintext"
      | GenerateMac -> "GenerateMac"
      | ReEncrypt -> "ReEncrypt"
      | Sign -> "Sign"
      | Verify -> "Verify"
      | VerifyMac -> "VerifyMac"
      | Non_static_id s -> s
    let of_string =
      function
      | "Decrypt" -> Decrypt
      | "DeriveSharedSecret" -> DeriveSharedSecret
      | "Encrypt" -> Encrypt
      | "GenerateDataKey" -> GenerateDataKey
      | "GenerateDataKeyPair" -> GenerateDataKeyPair
      | "GenerateDataKeyPairWithoutPlaintext" ->
          GenerateDataKeyPairWithoutPlaintext
      | "GenerateDataKeyWithoutPlaintext" -> GenerateDataKeyWithoutPlaintext
      | "GenerateMac" -> GenerateMac
      | "ReEncrypt" -> ReEncrypt
      | "Sign" -> Sign
      | "Verify" -> Verify
      | "VerifyMac" -> VerifyMac
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration KeyLastUsageTrackingOperation"
           xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"KeyLastUsageTrackingOperation" j)
    let to_json = simple_to_json to_value
  end
module KmsRequestIdType =
  struct
    type nonrec t = string
    let context_ = "KmsRequestIdType"
    let make i = i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"KmsRequestIdType" j
    let to_json = simple_to_json to_value
  end
module AttestationDocumentType =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Blob x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml xml_arg0 = string_of_xml ~kind:"a blob" xml_arg0
    let of_json j = string_of_json ~kind:"a blob" j
    let to_json = simple_to_json to_value
  end
module KeyEncryptionMechanism =
  struct
    type nonrec t =
      | RSAES_OAEP_SHA_256 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSAES_OAEP_SHA_256 -> "RSAES_OAEP_SHA_256"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSAES_OAEP_SHA_256" -> RSAES_OAEP_SHA_256
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration KeyEncryptionMechanism" xml_arg0)
    let of_json j =
      of_string (string_of_json ~kind:"KeyEncryptionMechanism" j)
    let to_json = simple_to_json to_value
  end
module CustomKeyStoresListEntry =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc "A unique identifier for the custom key store."];
      customKeyStoreName: CustomKeyStoreNameType.t option
        [@ocaml.doc
          "The user-specified friendly name for the custom key store."];
      cloudHsmClusterId: CloudHsmClusterIdType.t option
        [@ocaml.doc
          "A unique identifier for the CloudHSM cluster that is associated with an CloudHSM key store. This field appears only when the CustomKeyStoreType is AWS_CLOUDHSM."];
      trustAnchorCertificate: TrustAnchorCertificateType.t option
        [@ocaml.doc
          "The trust anchor certificate of the CloudHSM cluster associated with an CloudHSM key store. When you initialize the cluster, you create this certificate and save it in the customerCA.crt file. This field appears only when the CustomKeyStoreType is AWS_CLOUDHSM."];
      connectionState: ConnectionStateType.t option
        [@ocaml.doc
          "Indicates whether the custom key store is connected to its backing key store. For an CloudHSM key store, the ConnectionState indicates whether it is connected to its CloudHSM cluster. For an external key store, the ConnectionState indicates whether it is connected to the external key store proxy that communicates with your external key manager. You can create and use KMS keys in your custom key stores only when its ConnectionState is CONNECTED. The ConnectionState value is DISCONNECTED only if the key store has never been connected or you use the DisconnectCustomKeyStore operation to disconnect it. If the value is CONNECTED but you are having trouble using the custom key store, make sure that the backing key store is reachable and active. For an CloudHSM key store, verify that its associated CloudHSM cluster is active and contains at least one active HSM. For an external key store, verify that the external key store proxy and external key manager are connected and enabled. A value of FAILED indicates that an attempt to connect was unsuccessful. The ConnectionErrorCode field in the response indicates the cause of the failure. For help resolving a connection failure, see Troubleshooting a custom key store in the Key Management Service Developer Guide."];
      connectionErrorCode: ConnectionErrorCodeType.t option
        [@ocaml.doc
          "Describes the connection error. This field appears in the response only when the ConnectionState is FAILED. Many failures can be resolved by updating the properties of the custom key store. To update a custom key store, disconnect it (DisconnectCustomKeyStore), correct the errors (UpdateCustomKeyStore), and try to connect again (ConnectCustomKeyStore). For additional help resolving these errors, see How to Fix a Connection Failure in Key Management Service Developer Guide. All custom key stores: INTERNAL_ERROR \226\128\148 KMS could not complete the request due to an internal error. Retry the request. For ConnectCustomKeyStore requests, disconnect the custom key store before trying to connect again. NETWORK_ERRORS \226\128\148 Network errors are preventing KMS from connecting the custom key store to its backing key store. CloudHSM key stores: CLUSTER_NOT_FOUND \226\128\148 KMS cannot find the CloudHSM cluster with the specified cluster ID. INSUFFICIENT_CLOUDHSM_HSMS \226\128\148 The associated CloudHSM cluster does not contain any active HSMs. To connect a custom key store to its CloudHSM cluster, the cluster must contain at least one active HSM. INSUFFICIENT_FREE_ADDRESSES_IN_SUBNET \226\128\148 At least one private subnet associated with the CloudHSM cluster doesn't have any available IP addresses. A CloudHSM key store connection requires one free IP address in each of the associated private subnets, although two are preferable. For details, see How to Fix a Connection Failure in the Key Management Service Developer Guide. INVALID_CREDENTIALS \226\128\148 The KeyStorePassword for the custom key store doesn't match the current password of the kmsuser crypto user in the CloudHSM cluster. Before you can connect your custom key store to its CloudHSM cluster, you must change the kmsuser account password and update the KeyStorePassword value for the custom key store. SUBNET_NOT_FOUND \226\128\148 A subnet in the CloudHSM cluster configuration was deleted. If KMS cannot find all of the subnets in the cluster configuration, attempts to connect the custom key store to the CloudHSM cluster fail. To fix this error, create a cluster from a recent backup and associate it with your custom key store. (This process creates a new cluster configuration with a VPC and private subnets.) For details, see How to Fix a Connection Failure in the Key Management Service Developer Guide. USER_LOCKED_OUT \226\128\148 The kmsuser CU account is locked out of the associated CloudHSM cluster due to too many failed password attempts. Before you can connect your custom key store to its CloudHSM cluster, you must change the kmsuser account password and update the key store password value for the custom key store. USER_LOGGED_IN \226\128\148 The kmsuser CU account is logged into the associated CloudHSM cluster. This prevents KMS from rotating the kmsuser account password and logging into the cluster. Before you can connect your custom key store to its CloudHSM cluster, you must log the kmsuser CU out of the cluster. If you changed the kmsuser password to log into the cluster, you must also and update the key store password value for the custom key store. For help, see How to Log Out and Reconnect in the Key Management Service Developer Guide. USER_NOT_FOUND \226\128\148 KMS cannot find a kmsuser CU account in the associated CloudHSM cluster. Before you can connect your custom key store to its CloudHSM cluster, you must create a kmsuser CU account in the cluster, and then update the key store password value for the custom key store. External key stores: INVALID_CREDENTIALS \226\128\148 One or both of the XksProxyAuthenticationCredential values is not valid on the specified external key store proxy. XKS_PROXY_ACCESS_DENIED \226\128\148 KMS requests are denied access to the external key store proxy. If the external key store proxy has authorization rules, verify that they permit KMS to communicate with the proxy on your behalf. XKS_PROXY_INVALID_CONFIGURATION \226\128\148 A configuration error is preventing the external key store from connecting to its proxy. Verify the value of the XksProxyUriPath. XKS_PROXY_INVALID_RESPONSE \226\128\148 KMS cannot interpret the response from the external key store proxy. If you see this connection error code repeatedly, notify your external key store proxy vendor. XKS_PROXY_INVALID_TLS_CONFIGURATION \226\128\148 KMS cannot connect to the external key store proxy because the TLS configuration is invalid. Verify that the XKS proxy supports TLS 1.2 or 1.3. Also, verify that the TLS certificate is not expired, and that it matches the hostname in the XksProxyUriEndpoint value, and that it is signed by a certificate authority included in the Trusted Certificate Authorities list. XKS_PROXY_NOT_REACHABLE \226\128\148 KMS can't communicate with your external key store proxy. Verify that the XksProxyUriEndpoint and XksProxyUriPath are correct. Use the tools for your external key store proxy to verify that the proxy is active and available on its network. Also, verify that your external key manager instances are operating properly. Connection attempts fail with this connection error code if the proxy reports that all external key manager instances are unavailable. XKS_PROXY_TIMED_OUT \226\128\148 KMS can connect to the external key store proxy, but the proxy does not respond to KMS in the time allotted. If you see this connection error code repeatedly, notify your external key store proxy vendor. XKS_VPC_ENDPOINT_SERVICE_INVALID_CONFIGURATION \226\128\148 The Amazon VPC endpoint service configuration doesn't conform to the requirements for an KMS external key store. The VPC endpoint service must be an endpoint service for interface endpoints in the caller's Amazon Web Services account. It must have a network load balancer (NLB) connected to at least two subnets, each in a different Availability Zone. The Allow principals list must include the KMS service principal for the Region, cks.kms.<region>.amazonaws.com, such as cks.kms.us-east-1.amazonaws.com. It must not require acceptance of connection requests. It must have a private DNS name. The private DNS name for an external key store with VPC_ENDPOINT_SERVICE connectivity must be unique in its Amazon Web Services Region. The domain of the private DNS name must have a verification status of verified. The TLS certificate specifies the private DNS hostname at which the endpoint is reachable. XKS_VPC_ENDPOINT_SERVICE_NOT_FOUND \226\128\148 KMS can't find the VPC endpoint service that it uses to communicate with the external key store proxy. Verify that the XksProxyVpcEndpointServiceName is correct and the KMS service principal has service consumer permissions on the Amazon VPC endpoint service."];
      creationDate: DateType.t option
        [@ocaml.doc
          "The date and time when the custom key store was created."];
      customKeyStoreType: CustomKeyStoreType.t option
        [@ocaml.doc
          "Indicates the type of the custom key store. AWS_CLOUDHSM indicates a custom key store backed by an CloudHSM cluster. EXTERNAL_KEY_STORE indicates a custom key store backed by an external key store proxy and external key manager outside of Amazon Web Services."];
      xksProxyConfiguration: XksProxyConfigurationType.t option
        [@ocaml.doc
          "Configuration settings for the external key store proxy (XKS proxy). The external key store proxy translates KMS requests into a format that your external key manager can understand. The proxy configuration includes connection information that KMS requires. This field appears only when the CustomKeyStoreType is EXTERNAL_KEY_STORE."]}
    let make ?customKeyStoreId =
      fun ?customKeyStoreName ->
        fun ?cloudHsmClusterId ->
          fun ?trustAnchorCertificate ->
            fun ?connectionState ->
              fun ?connectionErrorCode ->
                fun ?creationDate ->
                  fun ?customKeyStoreType ->
                    fun ?xksProxyConfiguration ->
                      fun () ->
                        {
                          customKeyStoreId;
                          customKeyStoreName;
                          cloudHsmClusterId;
                          trustAnchorCertificate;
                          connectionState;
                          connectionErrorCode;
                          creationDate;
                          customKeyStoreType;
                          xksProxyConfiguration
                        }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value));
        ("CustomKeyStoreName",
          (Option.map x.customKeyStoreName ~f:CustomKeyStoreNameType.to_value));
        ("CloudHsmClusterId",
          (Option.map x.cloudHsmClusterId ~f:CloudHsmClusterIdType.to_value));
        ("TrustAnchorCertificate",
          (Option.map x.trustAnchorCertificate
             ~f:TrustAnchorCertificateType.to_value));
        ("ConnectionState",
          (Option.map x.connectionState ~f:ConnectionStateType.to_value));
        ("ConnectionErrorCode",
          (Option.map x.connectionErrorCode
             ~f:ConnectionErrorCodeType.to_value));
        ("CreationDate", (Option.map x.creationDate ~f:DateType.to_value));
        ("CustomKeyStoreType",
          (Option.map x.customKeyStoreType ~f:CustomKeyStoreType.to_value));
        ("XksProxyConfiguration",
          (Option.map x.xksProxyConfiguration
             ~f:XksProxyConfigurationType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let xksProxyConfiguration =
        (Option.map ~f:XksProxyConfigurationType.of_xml)
          (Xml.child xml_arg0 "XksProxyConfiguration") in
      let customKeyStoreType =
        (Option.map ~f:CustomKeyStoreType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreType") in
      let creationDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "CreationDate") in
      let connectionErrorCode =
        (Option.map ~f:ConnectionErrorCodeType.of_xml)
          (Xml.child xml_arg0 "ConnectionErrorCode") in
      let connectionState =
        (Option.map ~f:ConnectionStateType.of_xml)
          (Xml.child xml_arg0 "ConnectionState") in
      let trustAnchorCertificate =
        (Option.map ~f:TrustAnchorCertificateType.of_xml)
          (Xml.child xml_arg0 "TrustAnchorCertificate") in
      let cloudHsmClusterId =
        (Option.map ~f:CloudHsmClusterIdType.of_xml)
          (Xml.child xml_arg0 "CloudHsmClusterId") in
      let customKeyStoreName =
        (Option.map ~f:CustomKeyStoreNameType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreName") in
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      make ?xksProxyConfiguration ?customKeyStoreType ?creationDate
        ?connectionErrorCode ?connectionState ?trustAnchorCertificate
        ?cloudHsmClusterId ?customKeyStoreName ?customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let xksProxyConfiguration =
        field_map json__ "XksProxyConfiguration"
          XksProxyConfigurationType.of_json in
      let customKeyStoreType =
        field_map json__ "CustomKeyStoreType" CustomKeyStoreType.of_json in
      let creationDate = field_map json__ "CreationDate" DateType.of_json in
      let connectionErrorCode =
        field_map json__ "ConnectionErrorCode"
          ConnectionErrorCodeType.of_json in
      let connectionState =
        field_map json__ "ConnectionState" ConnectionStateType.of_json in
      let trustAnchorCertificate =
        field_map json__ "TrustAnchorCertificate"
          TrustAnchorCertificateType.of_json in
      let cloudHsmClusterId =
        field_map json__ "CloudHsmClusterId" CloudHsmClusterIdType.of_json in
      let customKeyStoreName =
        field_map json__ "CustomKeyStoreName" CustomKeyStoreNameType.of_json in
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ?xksProxyConfiguration ?customKeyStoreType ?creationDate
        ?connectionErrorCode ?connectionState ?trustAnchorCertificate
        ?cloudHsmClusterId ?customKeyStoreName ?customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Contains information about each custom key store in the custom key store list."]
module DependencyTimeoutException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The system timed out while trying to fulfill the request. You can retry the request."]
module DisabledException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified KMS key is not enabled."]
module DryRunOperationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the DryRun parameter was specified."]
module InvalidGrantTokenException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified grant token is not valid."]
module InvalidKeyUsageException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected for one of the following reasons: The KeyUsage value of the KMS key is incompatible with the API operation. The encryption algorithm or signing algorithm specified for the operation is incompatible with the type of key material in the KMS key (KeySpec). For encrypting, decrypting, re-encrypting, and generating data keys, the KeyUsage must be ENCRYPT_DECRYPT. For signing and verifying messages, the KeyUsage must be SIGN_VERIFY. For generating and verifying message authentication codes (MACs), the KeyUsage must be GENERATE_VERIFY_MAC. For deriving key agreement secrets, the KeyUsage must be KEY_AGREEMENT. To find the KeyUsage of a KMS key, use the DescribeKey operation. To find the encryption or signing algorithms supported for a particular KMS key, use the DescribeKey operation."]
module KMSInternalException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because an internal exception occurred. The request can be retried."]
module KMSInvalidSignatureException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the signature verification failed. Signature verification fails when it cannot confirm that signature was produced by signing the specified message with the specified KMS key and signing algorithm."]
module KMSInvalidStateException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the state of the specified resource is not valid for this request. This exceptions means one of the following: The key state of the KMS key is not compatible with the operation. To find the key state, use the DescribeKey operation. For more information about which key states are compatible with each KMS operation, see Key states of KMS keys in the Key Management Service Developer Guide . For cryptographic operations on KMS keys in custom key stores, this exception represents a general failure with many possible causes. To identify the cause, see the error message that accompanies the exception."]
module KeyUnavailableException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified KMS key was not available. You can retry the request."]
module NotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified entity or resource could not be found."]
module CiphertextType =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Blob x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml xml_arg0 = string_of_xml ~kind:"a blob" xml_arg0
    let of_json j = string_of_json ~kind:"a blob" j
    let to_json = simple_to_json to_value
  end
module GrantTokenList =
  struct
    type nonrec t = GrantTokenType.t list
    let make i =
      let open Result in
        ok_or_failwith
          ((check_list_max i ~max:10) >>= (fun () -> check_list_min i ~min:0));
        i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:GrantTokenType.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:GrantTokenType.of_xml)
    let of_json j =
      list_of_json ~kind:"GrantTokenList" ~of_json:GrantTokenType.of_json j
    let to_json v = composed_to_json to_value v
  end
module MessageType =
  struct
    type nonrec t =
      | RAW 
      | DIGEST 
      | EXTERNAL_MU 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RAW -> "RAW"
      | DIGEST -> "DIGEST"
      | EXTERNAL_MU -> "EXTERNAL_MU"
      | Non_static_id s -> s
    let of_string =
      function
      | "RAW" -> RAW
      | "DIGEST" -> DIGEST
      | "EXTERNAL_MU" -> EXTERNAL_MU
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration MessageType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"MessageType" j)
    let to_json = simple_to_json to_value
  end
module PlaintextType =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Blob x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml xml_arg0 = string_of_xml ~kind:"a blob" xml_arg0
    let of_json j = string_of_json ~kind:"a blob" j
    let to_json = simple_to_json to_value
  end
module KMSInvalidMacException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the HMAC verification failed. HMAC verification fails when the HMAC computed by using the specified message, HMAC KMS key, and MAC algorithm does not match the HMAC specified in the request."]
module CloudHsmClusterInvalidConfigurationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the associated CloudHSM cluster did not meet the configuration requirements for an CloudHSM key store. The CloudHSM cluster must be configured with private subnets in at least two different Availability Zones in the Region. The security group for the cluster (cloudhsm-cluster-<cluster-id>-sg) must include inbound rules and outbound rules that allow TCP traffic on ports 2223-2225. The Source in the inbound rules and the Destination in the outbound rules must match the security group ID. These rules are set by default when you create the CloudHSM cluster. Do not delete or change them. To get information about a particular security group, use the DescribeSecurityGroups operation. The CloudHSM cluster must contain at least as many HSMs as the operation requires. To add HSMs, use the CloudHSM CreateHsm operation. For the CreateCustomKeyStore, UpdateCustomKeyStore, and CreateKey operations, the CloudHSM cluster must have at least two active HSMs, each in a different Availability Zone. For the ConnectCustomKeyStore operation, the CloudHSM must contain at least one active HSM. For information about the requirements for an CloudHSM cluster that is associated with an CloudHSM key store, see Assemble the Prerequisites in the Key Management Service Developer Guide. For information about creating a private subnet for an CloudHSM cluster, see Create a Private Subnet in the CloudHSM User Guide. For information about cluster security groups, see Configure a Default Security Group in the CloudHSM User Guide ."]
module CloudHsmClusterNotActiveException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the CloudHSM cluster associated with the CloudHSM key store is not active. Initialize and activate the cluster and try the command again. For detailed instructions, see Getting Started in the CloudHSM User Guide."]
module CloudHsmClusterNotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because KMS cannot find the CloudHSM cluster with the specified cluster ID. Retry the request with a different cluster ID."]
module CloudHsmClusterNotRelatedException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified CloudHSM cluster has a different cluster certificate than the original cluster. You cannot use the operation to specify an unrelated cluster for an CloudHSM key store. Specify an CloudHSM cluster that shares a backup history with the original cluster. This includes clusters that were created from a backup of the current cluster, and clusters that were created from the same backup that produced the current cluster. CloudHSM clusters that share a backup history have the same cluster certificate. To view the cluster certificate of an CloudHSM cluster, use the DescribeClusters operation."]
module CustomKeyStoreInvalidStateException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because of the ConnectionState of the custom key store. To get the ConnectionState of a custom key store, use the DescribeCustomKeyStores operation. This exception is thrown under the following conditions: You requested the ConnectCustomKeyStore operation on a custom key store with a ConnectionState of DISCONNECTING or FAILED. This operation is valid for all other ConnectionState values. To reconnect a custom key store in a FAILED state, disconnect it (DisconnectCustomKeyStore), then connect it (ConnectCustomKeyStore). You requested the CreateKey operation in a custom key store that is not connected. This operations is valid only when the custom key store ConnectionState is CONNECTED. You requested the DisconnectCustomKeyStore operation on a custom key store with a ConnectionState of DISCONNECTING or DISCONNECTED. This operation is valid for all other ConnectionState values. You requested the UpdateCustomKeyStore or DeleteCustomKeyStore operation on a custom key store that is not disconnected. UpdateCustomKeyStore can be called on a custom key store in the CONNECTED state only to update NewCustomKeyStoreName. For all other properties, the custom key store ConnectionState must be DISCONNECTED. You requested the GenerateRandom operation in an CloudHSM key store that is not connected. This operation is valid only when the CloudHSM key store ConnectionState is CONNECTED."]
module CustomKeyStoreNameInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified custom key store name is already assigned to another custom key store in the account. Try again with a custom key store name that is unique in the account."]
module CustomKeyStoreNotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because KMS cannot find a custom key store with the specified key store name or ID."]
module XksProxyIncorrectAuthenticationCredentialException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the proxy credentials failed to authenticate to the specified external key store proxy. The specified external key store proxy rejected a status request from KMS due to invalid credentials. This can indicate an error in the credentials or in the identification of the external key store proxy."]
module XksProxyInvalidConfigurationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the external key store proxy is not configured correctly. To identify the cause, see the error message that accompanies the exception."]
module XksProxyInvalidResponseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "KMS cannot interpret the response it received from the external key store proxy. The problem might be a poorly constructed response, but it could also be a transient network issue. If you see this error repeatedly, report it to the proxy vendor."]
module XksProxyUriEndpointInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the XksProxyUriEndpoint is already associated with another external key store in this Amazon Web Services Region. To identify the cause, see the error message that accompanies the exception."]
module XksProxyUriInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the concatenation of the XksProxyUriEndpoint and XksProxyUriPath is already associated with another external key store in this Amazon Web Services Region. Each external key store in a Region must use a unique external key store proxy API address."]
module XksProxyUriUnreachableException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "KMS was unable to reach the specified XksProxyUriPath. The path must be reachable before you create the external key store or update its settings. This exception is also thrown when the external key store proxy response to a GetHealthStatus request indicates that all external key manager instances are unavailable."]
module XksProxyVpcEndpointServiceInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified Amazon VPC endpoint service is already associated with another external key store in this Amazon Web Services Region. Each external key store in a Region must use a different Amazon VPC endpoint service."]
module XksProxyVpcEndpointServiceInvalidConfigurationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the Amazon VPC endpoint service configuration does not fulfill the requirements for an external key store. To identify the cause, see the error message that accompanies the exception and review the requirements for Amazon VPC endpoint service connectivity for an external key store."]
module XksProxyVpcEndpointServiceNotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because KMS could not find the specified VPC endpoint service. Use DescribeCustomKeyStores to verify the VPC endpoint service name for the external key store. Also, confirm that the Allow principals list for the VPC endpoint service includes the KMS service principal for the Region, such as cks.kms.us-east-1.amazonaws.com."]
module KeyStorePasswordType =
  struct
    type nonrec t = string
    let context_ = "KeyStorePasswordType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_max i ~max:32) >>=
             (fun () -> check_string_min i ~min:7));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"KeyStorePasswordType" j
    let to_json = simple_to_json to_value
  end
module XksProxyAuthenticationCredentialType =
  struct
    type nonrec t =
      {
      accessKeyId: XksProxyAuthenticationAccessKeyIdType.t
        [@ocaml.doc "A unique identifier for the raw secret access key."];
      rawSecretAccessKey: XksProxyAuthenticationRawSecretAccessKeyType.t
        [@ocaml.doc
          "A secret string of 43-64 characters. Valid characters are a-z, A-Z, 0-9, /, +, and =."]}
    let context_ = "XksProxyAuthenticationCredentialType"
    let make ~accessKeyId =
      fun ~rawSecretAccessKey ->
        fun () -> { accessKeyId; rawSecretAccessKey }
    let to_value x =
      structure_to_value
        [("AccessKeyId",
           (Some
              (XksProxyAuthenticationAccessKeyIdType.to_value x.accessKeyId)));
        ("RawSecretAccessKey",
          (Some
             (XksProxyAuthenticationRawSecretAccessKeyType.to_value
                x.rawSecretAccessKey)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let rawSecretAccessKey =
        XksProxyAuthenticationRawSecretAccessKeyType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "RawSecretAccessKey") in
      let accessKeyId =
        XksProxyAuthenticationAccessKeyIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "AccessKeyId") in
      make ~rawSecretAccessKey ~accessKeyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let rawSecretAccessKey =
        field_map_exn json__ "RawSecretAccessKey"
          XksProxyAuthenticationRawSecretAccessKeyType.of_json in
      let accessKeyId =
        field_map_exn json__ "AccessKeyId"
          XksProxyAuthenticationAccessKeyIdType.of_json in
      make ~rawSecretAccessKey ~accessKeyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "KMS uses the authentication credential to sign requests that it sends to the external key store proxy (XKS proxy) on your behalf. You establish these credentials on your external key store proxy and report them to KMS. The XksProxyAuthenticationCredential includes two required elements."]
module TagKeyList =
  struct
    type nonrec t = TagKeyType.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:TagKeyType.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:TagKeyType.of_xml)
    let of_json j =
      list_of_json ~kind:"TagKeyList" ~of_json:TagKeyType.of_json j
    let to_json v = composed_to_json to_value v
  end
module TagList =
  struct
    type nonrec t = Tag.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:Tag.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:Tag.of_xml)
    let of_json j = list_of_json ~kind:"TagList" ~of_json:Tag.of_json j
    let to_json v = composed_to_json to_value v
  end
module InvalidArnException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because a specified ARN, or an ARN in a key policy, is not valid."]
module ConflictException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because an automatic rotation of this key is currently in progress or scheduled to begin within the next 20 minutes."]
module LimitExceededException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because a length constraint or quota was exceeded. For more information, see Quotas in the Key Management Service Developer Guide."]
module UnsupportedOperationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation."]
module AlreadyExistsException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because it attempted to create a resource that already exists."]
module KeyMetadata =
  struct
    type nonrec t =
      {
      aWSAccountId: AWSAccountIdType.t option
        [@ocaml.doc
          "The twelve-digit account ID of the Amazon Web Services account that owns the KMS key."];
      keyId: KeyIdType.t option
        [@ocaml.doc "The globally unique identifier for the KMS key."];
      arn: ArnType.t option
        [@ocaml.doc
          "The Amazon Resource Name (ARN) of the KMS key. For examples, see Key Management Service (KMS) in the Example ARNs section of the Amazon Web Services General Reference."];
      creationDate: DateType.t option
        [@ocaml.doc "The date and time when the KMS key was created."];
      enabled: BooleanType.t option
        [@ocaml.doc
          "Specifies whether the KMS key is enabled. When KeyState is Enabled this value is true, otherwise it is false."];
      description: DescriptionType.t option
        [@ocaml.doc "The description of the KMS key."];
      keyUsage: KeyUsageType.t option
        [@ocaml.doc
          "The cryptographic operations for which you can use the KMS key."];
      keyState: KeyState.t option
        [@ocaml.doc
          "The current status of the KMS key. For more information about how key state affects the use of a KMS key, see Key states of KMS keys in the Key Management Service Developer Guide."];
      deletionDate: DateType.t option
        [@ocaml.doc
          "The date and time after which KMS deletes this KMS key. This value is present only when the KMS key is scheduled for deletion, that is, when its KeyState is PendingDeletion. When the primary key in a multi-Region key is scheduled for deletion but still has replica keys, its key state is PendingReplicaDeletion and the length of its waiting period is displayed in the PendingDeletionWindowInDays field."];
      validTo: DateType.t option
        [@ocaml.doc
          "The earliest time at which any imported key material permanently associated with this KMS key expires. When a key material expires, KMS deletes the key material and the KMS key becomes unusable. This value is present only for KMS keys whose Origin is EXTERNAL and the ExpirationModel is KEY_MATERIAL_EXPIRES, otherwise this value is omitted."];
      origin: OriginType.t option
        [@ocaml.doc
          "The source of the key material for the KMS key. When this value is AWS_KMS, KMS created the key material. When this value is EXTERNAL, the key material was imported or the KMS key doesn't have any key material. When this value is AWS_CLOUDHSM, the key material was created in the CloudHSM cluster associated with a custom key store."];
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc
          "A unique identifier for the custom key store that contains the KMS key. This field is present only when the KMS key is created in a custom key store."];
      cloudHsmClusterId: CloudHsmClusterIdType.t option
        [@ocaml.doc
          "The cluster ID of the CloudHSM cluster that contains the key material for the KMS key. When you create a KMS key in an CloudHSM custom key store, KMS creates the key material for the KMS key in the associated CloudHSM cluster. This field is present only when the KMS key is created in an CloudHSM key store."];
      expirationModel: ExpirationModelType.t option
        [@ocaml.doc
          "Specifies whether the KMS key's key material expires. This value is present only when Origin is EXTERNAL, otherwise this value is omitted."];
      keyManager: KeyManagerType.t option
        [@ocaml.doc
          "The manager of the KMS key. KMS keys in your Amazon Web Services account are either customer managed or Amazon Web Services managed. For more information about the difference, see KMS keys in the Key Management Service Developer Guide."];
      customerMasterKeySpec: CustomerMasterKeySpec.t option
        [@ocaml.doc
          "Instead, use the KeySpec field. The KeySpec and CustomerMasterKeySpec fields have the same value. We recommend that you use the KeySpec field in your code. However, to avoid breaking changes, KMS supports both fields."];
      keySpec: KeySpec.t option
        [@ocaml.doc "Describes the type of key material in the KMS key."];
      encryptionAlgorithms: EncryptionAlgorithmSpecList.t option
        [@ocaml.doc
          "The encryption algorithms that the KMS key supports. You cannot use the KMS key with other encryption algorithms within KMS. This value is present only when the KeyUsage of the KMS key is ENCRYPT_DECRYPT."];
      signingAlgorithms: SigningAlgorithmSpecList.t option
        [@ocaml.doc
          "The signing algorithms that the KMS key supports. You cannot use the KMS key with other signing algorithms within KMS. This field appears only when the KeyUsage of the KMS key is SIGN_VERIFY."];
      keyAgreementAlgorithms: KeyAgreementAlgorithmSpecList.t option
        [@ocaml.doc
          "The key agreement algorithm used to derive a shared secret."];
      multiRegion: NullableBooleanType.t option
        [@ocaml.doc
          "Indicates whether the KMS key is a multi-Region (True) or regional (False) key. This value is True for multi-Region primary and replica keys and False for regional KMS keys. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide."];
      multiRegionConfiguration: MultiRegionConfiguration.t option
        [@ocaml.doc
          "Lists the primary and replica keys in same multi-Region key. This field is present only when the value of the MultiRegion field is True. For more information about any listed KMS key, use the DescribeKey operation. MultiRegionKeyType indicates whether the KMS key is a PRIMARY or REPLICA key. PrimaryKey displays the key ARN and Region of the primary key. This field displays the current KMS key if it is the primary key. ReplicaKeys displays the key ARNs and Regions of all replica keys. This field includes the current KMS key if it is a replica key."];
      pendingDeletionWindowInDays: PendingWindowInDaysType.t option
        [@ocaml.doc
          "The waiting period before the primary key in a multi-Region key is deleted. This waiting period begins when the last of its replica keys is deleted. This value is present only when the KeyState of the KMS key is PendingReplicaDeletion. That indicates that the KMS key is the primary key in a multi-Region key, it is scheduled for deletion, and it still has existing replica keys. When a single-Region KMS key or a multi-Region replica key is scheduled for deletion, its deletion date is displayed in the DeletionDate field. However, when the primary key in a multi-Region key is scheduled for deletion, its waiting period doesn't begin until all of its replica keys are deleted. This value displays that waiting period. When the last replica key in the multi-Region key is deleted, the KeyState of the scheduled primary key changes from PendingReplicaDeletion to PendingDeletion and the deletion date appears in the DeletionDate field."];
      macAlgorithms: MacAlgorithmSpecList.t option
        [@ocaml.doc
          "The message authentication code (MAC) algorithm that the HMAC KMS key supports. This value is present only when the KeyUsage of the KMS key is GENERATE_VERIFY_MAC."];
      xksKeyConfiguration: XksKeyConfigurationType.t option
        [@ocaml.doc
          "Information about the external key that is associated with a KMS key in an external key store. For more information, see External key in the Key Management Service Developer Guide."];
      currentKeyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "Identifies the current key material. This value is present for symmetric encryption keys with AWS_KMS or EXTERNAL origin. These KMS keys support automatic or on-demand key rotation and can have multiple key materials associated with them. KMS uses the current key material for both encryption and decryption, and the non-current key material for decryption operations only."]}
    let make ?aWSAccountId =
      fun ?keyId ->
        fun ?arn ->
          fun ?creationDate ->
            fun ?enabled ->
              fun ?description ->
                fun ?keyUsage ->
                  fun ?keyState ->
                    fun ?deletionDate ->
                      fun ?validTo ->
                        fun ?origin ->
                          fun ?customKeyStoreId ->
                            fun ?cloudHsmClusterId ->
                              fun ?expirationModel ->
                                fun ?keyManager ->
                                  fun ?customerMasterKeySpec ->
                                    fun ?keySpec ->
                                      fun ?encryptionAlgorithms ->
                                        fun ?signingAlgorithms ->
                                          fun ?keyAgreementAlgorithms ->
                                            fun ?multiRegion ->
                                              fun ?multiRegionConfiguration
                                                ->
                                                fun
                                                  ?pendingDeletionWindowInDays
                                                  ->
                                                  fun ?macAlgorithms ->
                                                    fun ?xksKeyConfiguration
                                                      ->
                                                      fun
                                                        ?currentKeyMaterialId
                                                        ->
                                                        fun () ->
                                                          {
                                                            aWSAccountId;
                                                            keyId;
                                                            arn;
                                                            creationDate;
                                                            enabled;
                                                            description;
                                                            keyUsage;
                                                            keyState;
                                                            deletionDate;
                                                            validTo;
                                                            origin;
                                                            customKeyStoreId;
                                                            cloudHsmClusterId;
                                                            expirationModel;
                                                            keyManager;
                                                            customerMasterKeySpec;
                                                            keySpec;
                                                            encryptionAlgorithms;
                                                            signingAlgorithms;
                                                            keyAgreementAlgorithms;
                                                            multiRegion;
                                                            multiRegionConfiguration;
                                                            pendingDeletionWindowInDays;
                                                            macAlgorithms;
                                                            xksKeyConfiguration;
                                                            currentKeyMaterialId
                                                          }
    let to_value x =
      structure_to_value
        [("AWSAccountId",
           (Option.map x.aWSAccountId ~f:AWSAccountIdType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("Arn", (Option.map x.arn ~f:ArnType.to_value));
        ("CreationDate", (Option.map x.creationDate ~f:DateType.to_value));
        ("Enabled", (Option.map x.enabled ~f:BooleanType.to_value));
        ("Description",
          (Option.map x.description ~f:DescriptionType.to_value));
        ("KeyUsage", (Option.map x.keyUsage ~f:KeyUsageType.to_value));
        ("KeyState", (Option.map x.keyState ~f:KeyState.to_value));
        ("DeletionDate", (Option.map x.deletionDate ~f:DateType.to_value));
        ("ValidTo", (Option.map x.validTo ~f:DateType.to_value));
        ("Origin", (Option.map x.origin ~f:OriginType.to_value));
        ("CustomKeyStoreId",
          (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value));
        ("CloudHsmClusterId",
          (Option.map x.cloudHsmClusterId ~f:CloudHsmClusterIdType.to_value));
        ("ExpirationModel",
          (Option.map x.expirationModel ~f:ExpirationModelType.to_value));
        ("KeyManager", (Option.map x.keyManager ~f:KeyManagerType.to_value));
        ("CustomerMasterKeySpec",
          (Option.map x.customerMasterKeySpec
             ~f:CustomerMasterKeySpec.to_value));
        ("KeySpec", (Option.map x.keySpec ~f:KeySpec.to_value));
        ("EncryptionAlgorithms",
          (Option.map x.encryptionAlgorithms
             ~f:EncryptionAlgorithmSpecList.to_value));
        ("SigningAlgorithms",
          (Option.map x.signingAlgorithms
             ~f:SigningAlgorithmSpecList.to_value));
        ("KeyAgreementAlgorithms",
          (Option.map x.keyAgreementAlgorithms
             ~f:KeyAgreementAlgorithmSpecList.to_value));
        ("MultiRegion",
          (Option.map x.multiRegion ~f:NullableBooleanType.to_value));
        ("MultiRegionConfiguration",
          (Option.map x.multiRegionConfiguration
             ~f:MultiRegionConfiguration.to_value));
        ("PendingDeletionWindowInDays",
          (Option.map x.pendingDeletionWindowInDays
             ~f:PendingWindowInDaysType.to_value));
        ("MacAlgorithms",
          (Option.map x.macAlgorithms ~f:MacAlgorithmSpecList.to_value));
        ("XksKeyConfiguration",
          (Option.map x.xksKeyConfiguration
             ~f:XksKeyConfigurationType.to_value));
        ("CurrentKeyMaterialId",
          (Option.map x.currentKeyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let currentKeyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "CurrentKeyMaterialId") in
      let xksKeyConfiguration =
        (Option.map ~f:XksKeyConfigurationType.of_xml)
          (Xml.child xml_arg0 "XksKeyConfiguration") in
      let macAlgorithms =
        (Option.map ~f:MacAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "MacAlgorithms") in
      let pendingDeletionWindowInDays =
        (Option.map ~f:PendingWindowInDaysType.of_xml)
          (Xml.child xml_arg0 "PendingDeletionWindowInDays") in
      let multiRegionConfiguration =
        (Option.map ~f:MultiRegionConfiguration.of_xml)
          (Xml.child xml_arg0 "MultiRegionConfiguration") in
      let multiRegion =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "MultiRegion") in
      let keyAgreementAlgorithms =
        (Option.map ~f:KeyAgreementAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "KeyAgreementAlgorithms") in
      let signingAlgorithms =
        (Option.map ~f:SigningAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "SigningAlgorithms") in
      let encryptionAlgorithms =
        (Option.map ~f:EncryptionAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithms") in
      let keySpec =
        (Option.map ~f:KeySpec.of_xml) (Xml.child xml_arg0 "KeySpec") in
      let customerMasterKeySpec =
        (Option.map ~f:CustomerMasterKeySpec.of_xml)
          (Xml.child xml_arg0 "CustomerMasterKeySpec") in
      let keyManager =
        (Option.map ~f:KeyManagerType.of_xml)
          (Xml.child xml_arg0 "KeyManager") in
      let expirationModel =
        (Option.map ~f:ExpirationModelType.of_xml)
          (Xml.child xml_arg0 "ExpirationModel") in
      let cloudHsmClusterId =
        (Option.map ~f:CloudHsmClusterIdType.of_xml)
          (Xml.child xml_arg0 "CloudHsmClusterId") in
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      let origin =
        (Option.map ~f:OriginType.of_xml) (Xml.child xml_arg0 "Origin") in
      let validTo =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "ValidTo") in
      let deletionDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "DeletionDate") in
      let keyState =
        (Option.map ~f:KeyState.of_xml) (Xml.child xml_arg0 "KeyState") in
      let keyUsage =
        (Option.map ~f:KeyUsageType.of_xml) (Xml.child xml_arg0 "KeyUsage") in
      let description =
        (Option.map ~f:DescriptionType.of_xml)
          (Xml.child xml_arg0 "Description") in
      let enabled =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Enabled") in
      let creationDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "CreationDate") in
      let arn = (Option.map ~f:ArnType.of_xml) (Xml.child xml_arg0 "Arn") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let aWSAccountId =
        (Option.map ~f:AWSAccountIdType.of_xml)
          (Xml.child xml_arg0 "AWSAccountId") in
      make ?currentKeyMaterialId ?xksKeyConfiguration ?macAlgorithms
        ?pendingDeletionWindowInDays ?multiRegionConfiguration ?multiRegion
        ?keyAgreementAlgorithms ?signingAlgorithms ?encryptionAlgorithms
        ?keySpec ?customerMasterKeySpec ?keyManager ?expirationModel
        ?cloudHsmClusterId ?customKeyStoreId ?origin ?validTo ?deletionDate
        ?keyState ?keyUsage ?description ?enabled ?creationDate ?arn ?keyId
        ?aWSAccountId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let currentKeyMaterialId =
        field_map json__ "CurrentKeyMaterialId" BackingKeyIdType.of_json in
      let xksKeyConfiguration =
        field_map json__ "XksKeyConfiguration"
          XksKeyConfigurationType.of_json in
      let macAlgorithms =
        field_map json__ "MacAlgorithms" MacAlgorithmSpecList.of_json in
      let pendingDeletionWindowInDays =
        field_map json__ "PendingDeletionWindowInDays"
          PendingWindowInDaysType.of_json in
      let multiRegionConfiguration =
        field_map json__ "MultiRegionConfiguration"
          MultiRegionConfiguration.of_json in
      let multiRegion =
        field_map json__ "MultiRegion" NullableBooleanType.of_json in
      let keyAgreementAlgorithms =
        field_map json__ "KeyAgreementAlgorithms"
          KeyAgreementAlgorithmSpecList.of_json in
      let signingAlgorithms =
        field_map json__ "SigningAlgorithms" SigningAlgorithmSpecList.of_json in
      let encryptionAlgorithms =
        field_map json__ "EncryptionAlgorithms"
          EncryptionAlgorithmSpecList.of_json in
      let keySpec = field_map json__ "KeySpec" KeySpec.of_json in
      let customerMasterKeySpec =
        field_map json__ "CustomerMasterKeySpec"
          CustomerMasterKeySpec.of_json in
      let keyManager = field_map json__ "KeyManager" KeyManagerType.of_json in
      let expirationModel =
        field_map json__ "ExpirationModel" ExpirationModelType.of_json in
      let cloudHsmClusterId =
        field_map json__ "CloudHsmClusterId" CloudHsmClusterIdType.of_json in
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      let origin = field_map json__ "Origin" OriginType.of_json in
      let validTo = field_map json__ "ValidTo" DateType.of_json in
      let deletionDate = field_map json__ "DeletionDate" DateType.of_json in
      let keyState = field_map json__ "KeyState" KeyState.of_json in
      let keyUsage = field_map json__ "KeyUsage" KeyUsageType.of_json in
      let description =
        field_map json__ "Description" DescriptionType.of_json in
      let enabled = field_map json__ "Enabled" BooleanType.of_json in
      let creationDate = field_map json__ "CreationDate" DateType.of_json in
      let arn = field_map json__ "Arn" ArnType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let aWSAccountId =
        field_map json__ "AWSAccountId" AWSAccountIdType.of_json in
      make ?currentKeyMaterialId ?xksKeyConfiguration ?macAlgorithms
        ?pendingDeletionWindowInDays ?multiRegionConfiguration ?multiRegion
        ?keyAgreementAlgorithms ?signingAlgorithms ?encryptionAlgorithms
        ?keySpec ?customerMasterKeySpec ?keyManager ?expirationModel
        ?cloudHsmClusterId ?customKeyStoreId ?origin ?validTo ?deletionDate
        ?keyState ?keyUsage ?description ?enabled ?creationDate ?arn ?keyId
        ?aWSAccountId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Contains metadata about a KMS key. This data type is used as a response element for the CreateKey, DescribeKey, and ReplicateKey operations."]
module MalformedPolicyDocumentException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified policy is not syntactically or semantically correct."]
module PolicyType =
  struct
    type nonrec t = string
    let context_ = "PolicyType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:131072) >>=
                  (fun () ->
                     check_pattern i
                       ~pattern:"[\\u0009\\u000A\\u000D\\u0020-\\u00FF]+")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"PolicyType" j
    let to_json = simple_to_json to_value
  end
module TagException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because one or more tags are not valid."]
module IncorrectKeyException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified KMS key cannot decrypt the data. The KeyId in a Decrypt request and the SourceKeyId in a ReEncrypt request must identify the same KMS key that was used to encrypt the ciphertext."]
module InvalidCiphertextException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "From the Decrypt or ReEncrypt operation, the request was rejected because the specified ciphertext, or additional authenticated data incorporated into the ciphertext, such as the encryption context, is corrupted, missing, or otherwise invalid. From the ImportKeyMaterial operation, the request was rejected because KMS could not decrypt the encrypted (wrapped) key material."]
module DryRunModifierList =
  struct
    type nonrec t = DryRunModifierType.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:DryRunModifierType.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:DryRunModifierType.of_xml)
    let of_json j =
      list_of_json ~kind:"DryRunModifierList"
        ~of_json:DryRunModifierType.of_json j
    let to_json v = composed_to_json to_value v
  end
module LimitType =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:1000) >>= (fun () -> check_int_min i ~min:1));
        i
    let of_string = Int.of_string
    let to_value x = `Integer x
    let to_query v = to_query to_value v
    let to_header x = Int.to_string x
    let of_xml xml_arg0 =
      Int.of_string (string_of_xml ~kind:"an integer for LimitType" xml_arg0)
    let of_json j = Int.of_float (float_of_json ~kind:"an integer" j)
    let to_json = simple_to_json to_value
  end
module MarkerType =
  struct
    type nonrec t = string
    let context_ = "MarkerType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:1) >>=
             (fun () ->
                (check_string_max i ~max:1024) >>=
                  (fun () -> check_pattern i ~pattern:"[\\u0020-\\u00FF]*")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"MarkerType" j
    let to_json = simple_to_json to_value
  end
module InvalidMarkerException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the marker that specifies where pagination should next begin is not valid."]
module KeyList =
  struct
    type nonrec t = KeyListEntry.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:KeyListEntry.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:KeyListEntry.of_xml)
    let of_json j =
      list_of_json ~kind:"KeyList" ~of_json:KeyListEntry.of_json j
    let to_json v = composed_to_json to_value v
  end
module RotationsList =
  struct
    type nonrec t = RotationsListEntry.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:RotationsListEntry.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:RotationsListEntry.of_xml)
    let of_json j =
      list_of_json ~kind:"RotationsList" ~of_json:RotationsListEntry.of_json
        j
    let to_json v = composed_to_json to_value v
  end
module IncludeKeyMaterial =
  struct
    type nonrec t =
      | ALL_KEY_MATERIAL 
      | ROTATIONS_ONLY 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | ALL_KEY_MATERIAL -> "ALL_KEY_MATERIAL"
      | ROTATIONS_ONLY -> "ROTATIONS_ONLY"
      | Non_static_id s -> s
    let of_string =
      function
      | "ALL_KEY_MATERIAL" -> ALL_KEY_MATERIAL
      | "ROTATIONS_ONLY" -> ROTATIONS_ONLY
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string
        (string_of_xml ~kind:"enumeration IncludeKeyMaterial" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"IncludeKeyMaterial" j)
    let to_json = simple_to_json to_value
  end
module PolicyNameList =
  struct
    type nonrec t = PolicyNameType.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:PolicyNameType.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:PolicyNameType.of_xml)
    let of_json j =
      list_of_json ~kind:"PolicyNameList" ~of_json:PolicyNameType.of_json j
    let to_json v = composed_to_json to_value v
  end
module GrantList =
  struct
    type nonrec t = GrantListEntry.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:GrantListEntry.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:GrantListEntry.of_xml)
    let of_json j =
      list_of_json ~kind:"GrantList" ~of_json:GrantListEntry.of_json j
    let to_json v = composed_to_json to_value v
  end
module InvalidGrantIdException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified GrantId is not valid."]
module AliasList =
  struct
    type nonrec t = AliasListEntry.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:AliasListEntry.to_value)) |> (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:AliasListEntry.of_xml)
    let of_json j =
      list_of_json ~kind:"AliasList" ~of_json:AliasListEntry.of_json j
    let to_json v = composed_to_json to_value v
  end
module ExpiredImportTokenException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified import token is expired. Use GetParametersForImport to get a new import token and public key, use the new public key to encrypt the key material, and then try the request again."]
module IncorrectKeyMaterialException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the key material in the request is, expired, invalid, or does not meet expectations. For example, it is not the same key material that was previously imported or KMS expected new key material but the key material being imported is already associated with the KMS key."]
module InvalidImportTokenException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the provided import token is invalid or is associated with a different KMS key."]
module ImportType =
  struct
    type nonrec t =
      | NEW_KEY_MATERIAL 
      | EXISTING_KEY_MATERIAL 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | NEW_KEY_MATERIAL -> "NEW_KEY_MATERIAL"
      | EXISTING_KEY_MATERIAL -> "EXISTING_KEY_MATERIAL"
      | Non_static_id s -> s
    let of_string =
      function
      | "NEW_KEY_MATERIAL" -> NEW_KEY_MATERIAL
      | "EXISTING_KEY_MATERIAL" -> EXISTING_KEY_MATERIAL
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration ImportType" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"ImportType" j)
    let to_json = simple_to_json to_value
  end
module PublicKeyType =
  struct
    type nonrec t = string
    let make i = i
    let of_string x = x
    let to_value x = `Blob x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml xml_arg0 = string_of_xml ~kind:"a blob" xml_arg0
    let of_json j = string_of_json ~kind:"a blob" j
    let to_json = simple_to_json to_value
  end
module AlgorithmSpec =
  struct
    type nonrec t =
      | RSAES_PKCS1_V1_5 
      | RSAES_OAEP_SHA_1 
      | RSAES_OAEP_SHA_256 
      | RSA_AES_KEY_WRAP_SHA_1 
      | RSA_AES_KEY_WRAP_SHA_256 
      | SM2PKE 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSAES_PKCS1_V1_5 -> "RSAES_PKCS1_V1_5"
      | RSAES_OAEP_SHA_1 -> "RSAES_OAEP_SHA_1"
      | RSAES_OAEP_SHA_256 -> "RSAES_OAEP_SHA_256"
      | RSA_AES_KEY_WRAP_SHA_1 -> "RSA_AES_KEY_WRAP_SHA_1"
      | RSA_AES_KEY_WRAP_SHA_256 -> "RSA_AES_KEY_WRAP_SHA_256"
      | SM2PKE -> "SM2PKE"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSAES_PKCS1_V1_5" -> RSAES_PKCS1_V1_5
      | "RSAES_OAEP_SHA_1" -> RSAES_OAEP_SHA_1
      | "RSAES_OAEP_SHA_256" -> RSAES_OAEP_SHA_256
      | "RSA_AES_KEY_WRAP_SHA_1" -> RSA_AES_KEY_WRAP_SHA_1
      | "RSA_AES_KEY_WRAP_SHA_256" -> RSA_AES_KEY_WRAP_SHA_256
      | "SM2PKE" -> SM2PKE
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration AlgorithmSpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"AlgorithmSpec" j)
    let to_json = simple_to_json to_value
  end
module WrappingKeySpec =
  struct
    type nonrec t =
      | RSA_2048 
      | RSA_3072 
      | RSA_4096 
      | SM2 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSA_2048 -> "RSA_2048"
      | RSA_3072 -> "RSA_3072"
      | RSA_4096 -> "RSA_4096"
      | SM2 -> "SM2"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSA_2048" -> RSA_2048
      | "RSA_3072" -> RSA_3072
      | "RSA_4096" -> RSA_4096
      | "SM2" -> SM2
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration WrappingKeySpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"WrappingKeySpec" j)
    let to_json = simple_to_json to_value
  end
module RotationPeriodInDaysType =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:2560) >>=
             (fun () -> check_int_min i ~min:90));
        i
    let of_string = Int.of_string
    let to_value x = `Integer x
    let to_query v = to_query to_value v
    let to_header x = Int.to_string x
    let of_xml xml_arg0 =
      Int.of_string
        (string_of_xml ~kind:"an integer for RotationPeriodInDaysType"
           xml_arg0)
    let of_json j = Int.of_float (float_of_json ~kind:"an integer" j)
    let to_json = simple_to_json to_value
  end
module KeyLastUsageData =
  struct
    type nonrec t =
      {
      operation: KeyLastUsageTrackingOperation.t option
        [@ocaml.doc
          "The last successful cryptographic operation the KMS key was used for. Absent if the key has not been used since KMS began tracking."];
      timestamp: DateType.t option
        [@ocaml.doc
          "The date and time when the KMS key was most recently used for a successful cryptographic operation. Absent if the key has not been used since KMS began tracking."];
      cloudTrailEventId: CloudTrailEventIdType.t option
        [@ocaml.doc
          "The CloudTrail eventId associated with the last successful cryptographic operation. Absent if the key has not been used since KMS began tracking."];
      kmsRequestId: KmsRequestIdType.t option
        [@ocaml.doc
          "The KMS request ID associated with the last successful cryptographic operation. Absent if the key has not been used since KMS began tracking."]}
    let make ?operation =
      fun ?timestamp ->
        fun ?cloudTrailEventId ->
          fun ?kmsRequestId ->
            fun () ->
              { operation; timestamp; cloudTrailEventId; kmsRequestId }
    let to_value x =
      structure_to_value
        [("Operation",
           (Option.map x.operation ~f:KeyLastUsageTrackingOperation.to_value));
        ("Timestamp", (Option.map x.timestamp ~f:DateType.to_value));
        ("CloudTrailEventId",
          (Option.map x.cloudTrailEventId ~f:CloudTrailEventIdType.to_value));
        ("KmsRequestId",
          (Option.map x.kmsRequestId ~f:KmsRequestIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let kmsRequestId =
        (Option.map ~f:KmsRequestIdType.of_xml)
          (Xml.child xml_arg0 "KmsRequestId") in
      let cloudTrailEventId =
        (Option.map ~f:CloudTrailEventIdType.of_xml)
          (Xml.child xml_arg0 "CloudTrailEventId") in
      let timestamp =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "Timestamp") in
      let operation =
        (Option.map ~f:KeyLastUsageTrackingOperation.of_xml)
          (Xml.child xml_arg0 "Operation") in
      make ?kmsRequestId ?cloudTrailEventId ?timestamp ?operation ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let kmsRequestId =
        field_map json__ "KmsRequestId" KmsRequestIdType.of_json in
      let cloudTrailEventId =
        field_map json__ "CloudTrailEventId" CloudTrailEventIdType.of_json in
      let timestamp = field_map json__ "Timestamp" DateType.of_json in
      let operation =
        field_map json__ "Operation" KeyLastUsageTrackingOperation.of_json in
      make ?kmsRequestId ?cloudTrailEventId ?timestamp ?operation ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Contains usage information about the last time the KMS key was used for a successful cryptographic operation."]
module NumberOfBytesType =
  struct
    type nonrec t = int
    let make i =
      let open Result in
        ok_or_failwith
          ((check_int_max i ~max:1024) >>= (fun () -> check_int_min i ~min:1));
        i
    let of_string = Int.of_string
    let to_value x = `Integer x
    let to_query v = to_query to_value v
    let to_header x = Int.to_string x
    let of_xml xml_arg0 =
      Int.of_string
        (string_of_xml ~kind:"an integer for NumberOfBytesType" xml_arg0)
    let of_json j = Int.of_float (float_of_json ~kind:"an integer" j)
    let to_json = simple_to_json to_value
  end
module RecipientInfo =
  struct
    type nonrec t =
      {
      keyEncryptionAlgorithm: KeyEncryptionMechanism.t option
        [@ocaml.doc
          "The encryption algorithm that KMS should use with the public key for an Amazon Web Services Nitro Enclave or NitroTPM to encrypt plaintext values for the response. The only valid value is RSAES_OAEP_SHA_256."];
      attestationDocument: AttestationDocumentType.t option
        [@ocaml.doc
          "The attestation document for an Amazon Web Services Nitro Enclave or a NitroTPM. This document includes the enclave's public key."]}
    let make ?keyEncryptionAlgorithm =
      fun ?attestationDocument ->
        fun () -> { keyEncryptionAlgorithm; attestationDocument }
    let to_value x =
      structure_to_value
        [("KeyEncryptionAlgorithm",
           (Option.map x.keyEncryptionAlgorithm
              ~f:KeyEncryptionMechanism.to_value));
        ("AttestationDocument",
          (Option.map x.attestationDocument
             ~f:AttestationDocumentType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let attestationDocument =
        (Option.map ~f:AttestationDocumentType.of_xml)
          (Xml.child xml_arg0 "AttestationDocument") in
      let keyEncryptionAlgorithm =
        (Option.map ~f:KeyEncryptionMechanism.of_xml)
          (Xml.child xml_arg0 "KeyEncryptionAlgorithm") in
      make ?attestationDocument ?keyEncryptionAlgorithm ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let attestationDocument =
        field_map json__ "AttestationDocument"
          AttestationDocumentType.of_json in
      let keyEncryptionAlgorithm =
        field_map json__ "KeyEncryptionAlgorithm"
          KeyEncryptionMechanism.of_json in
      make ?attestationDocument ?keyEncryptionAlgorithm ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Contains information about the party that receives the response from the API operation. This data type is designed to support Amazon Web Services Nitro Enclaves and Amazon Web Services NitroTPM, which lets you create an attested environment in Amazon EC2. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."]
module DataKeySpec =
  struct
    type nonrec t =
      | AES_256 
      | AES_128 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | AES_256 -> "AES_256"
      | AES_128 -> "AES_128"
      | Non_static_id s -> s
    let of_string =
      function
      | "AES_256" -> AES_256
      | "AES_128" -> AES_128
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration DataKeySpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"DataKeySpec" j)
    let to_json = simple_to_json to_value
  end
module DataKeyPairSpec =
  struct
    type nonrec t =
      | RSA_2048 
      | RSA_3072 
      | RSA_4096 
      | ECC_NIST_P256 
      | ECC_NIST_P384 
      | ECC_NIST_P521 
      | ECC_SECG_P256K1 
      | SM2 
      | ECC_NIST_EDWARDS25519 
      | Non_static_id of string 
    let make i = i
    let to_string =
      function
      | RSA_2048 -> "RSA_2048"
      | RSA_3072 -> "RSA_3072"
      | RSA_4096 -> "RSA_4096"
      | ECC_NIST_P256 -> "ECC_NIST_P256"
      | ECC_NIST_P384 -> "ECC_NIST_P384"
      | ECC_NIST_P521 -> "ECC_NIST_P521"
      | ECC_SECG_P256K1 -> "ECC_SECG_P256K1"
      | SM2 -> "SM2"
      | ECC_NIST_EDWARDS25519 -> "ECC_NIST_EDWARDS25519"
      | Non_static_id s -> s
    let of_string =
      function
      | "RSA_2048" -> RSA_2048
      | "RSA_3072" -> RSA_3072
      | "RSA_4096" -> RSA_4096
      | "ECC_NIST_P256" -> ECC_NIST_P256
      | "ECC_NIST_P384" -> ECC_NIST_P384
      | "ECC_NIST_P521" -> ECC_NIST_P521
      | "ECC_SECG_P256K1" -> ECC_SECG_P256K1
      | "SM2" -> SM2
      | "ECC_NIST_EDWARDS25519" -> ECC_NIST_EDWARDS25519
      | x -> Non_static_id x
    let to_value x = `Enum (to_string x)
    let to_query v = to_query to_value v
    let to_header x = to_string x
    let of_xml xml_arg0 =
      of_string (string_of_xml ~kind:"enumeration DataKeyPairSpec" xml_arg0)
    let of_json j = of_string (string_of_json ~kind:"DataKeyPairSpec" j)
    let to_json = simple_to_json to_value
  end
module CustomKeyStoresList =
  struct
    type nonrec t = CustomKeyStoresListEntry.t list
    let make i = i
    let of_string _ =
      failwithf "of_string is not implemented for List_shape objects" ()
      [@@warning "-32"]
    let to_value xs =
      (xs |> (List.map ~f:CustomKeyStoresListEntry.to_value)) |>
        (fun x -> `List x)
    let to_query v = to_query to_value v
    let to_header _ =
      failwithf "to_header is not implemented for List_shape objects" ()
    let of_xml x =
      make
        (List.map
           ((Xml.all_children x) |>
              (List.filter
                 ~f:(function
                     | `Data s ->
                         (match Stdlib.String.trim s with
                          | "" -> false
                          | _ -> true)
                     | _ -> true))) ~f:CustomKeyStoresListEntry.of_xml)
    let of_json j =
      list_of_json ~kind:"CustomKeyStoresList"
        ~of_json:CustomKeyStoresListEntry.of_json j
    let to_json v = composed_to_json to_value v
  end
module BackingKeyIdResponseType =
  struct
    type nonrec t = string
    let context_ = "BackingKeyIdResponseType"
    let make i =
      let open Result in
        ok_or_failwith
          ((check_string_min i ~min:0) >>=
             (fun () ->
                (check_string_max i ~max:64) >>=
                  (fun () -> check_pattern i ~pattern:"^[a-f0-9]+$")));
        i
    let of_string x = x
    let to_value x = `String x
    let to_query v = to_query to_value v
    let to_header x = x
    let of_xml = Xml.string_data_exn ~context:context_
    let of_json j = string_of_json ~kind:"BackingKeyIdResponseType" j
    let to_json = simple_to_json to_value
  end
module CustomKeyStoreHasCMKsException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the custom key store contains KMS keys. After verifying that you do not need to use the KMS keys, use the ScheduleKeyDeletion operation to delete the KMS keys. After they are deleted, you can delete the custom key store."]
module XksKeyAlreadyInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the (XksKeyId) is already associated with another KMS key in this external key store. Each KMS key in an external key store must be associated with a different external key."]
module XksKeyInvalidConfigurationException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the external key specified by the XksKeyId parameter did not meet the configuration requirements for an external key store. The external key must be an AES-256 symmetric key that is enabled and performs encryption and decryption."]
module XksKeyNotFoundException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the external key store proxy could not find the external key. This exception is thrown when the value of the XksKeyId parameter doesn't identify a key in the external key manager associated with the external key proxy. Verify that the XksKeyId represents an existing key in the external key manager. Use the key identifier that the external key store proxy uses to identify the key. For details, see the documentation provided with your external key store proxy or key manager."]
module CloudHsmClusterInUseException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified CloudHSM cluster is already associated with an CloudHSM key store in the account, or it shares a backup history with an CloudHSM key store in the account. Each CloudHSM key store in the account must be associated with a different CloudHSM cluster. CloudHSM clusters that share a backup history have the same cluster certificate. To view the cluster certificate of an CloudHSM cluster, use the DescribeClusters operation."]
module IncorrectTrustAnchorException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the trust anchor certificate in the request to create an CloudHSM key store is not the trust anchor certificate for the specified CloudHSM cluster. When you initialize the CloudHSM cluster, you create the trust anchor certificate and save it in the customerCA.crt file."]
module VerifyResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the asymmetric KMS key that was used to verify the signature."];
      signatureValid: BooleanType.t option
        [@ocaml.doc
          "A Boolean value that indicates whether the signature was verified. A value of True indicates that the Signature was produced by signing the Message with the specified KeyID and SigningAlgorithm. If the signature is not verified, the Verify operation fails with a KMSInvalidSignatureException exception."];
      signingAlgorithm: SigningAlgorithmSpec.t option
        [@ocaml.doc
          "The signing algorithm that was used to verify the signature."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidSignatureException of KMSInvalidSignatureException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?signatureValid ->
        fun ?signingAlgorithm ->
          fun () -> { keyId; signatureValid; signingAlgorithm }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidSignatureException" ->
          `KMSInvalidSignatureException
            (KMSInvalidSignatureException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidSignatureException" ->
          `KMSInvalidSignatureException
            (KMSInvalidSignatureException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidSignatureException e ->
          `Assoc
            [("error", (`String "KMSInvalidSignatureException"));
            ("details", (KMSInvalidSignatureException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("SignatureValid",
          (Option.map x.signatureValid ~f:BooleanType.to_value));
        ("SigningAlgorithm",
          (Option.map x.signingAlgorithm ~f:SigningAlgorithmSpec.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let signingAlgorithm =
        (Option.map ~f:SigningAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "SigningAlgorithm") in
      let signatureValid =
        (Option.map ~f:BooleanType.of_xml)
          (Xml.child xml_arg0 "SignatureValid") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?signingAlgorithm ?signatureValid ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let signingAlgorithm =
        field_map json__ "SigningAlgorithm" SigningAlgorithmSpec.of_json in
      let signatureValid =
        field_map json__ "SignatureValid" BooleanType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?signingAlgorithm ?signatureValid ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Verifies a digital signature that was generated by the Sign operation. Verification confirms that an authorized user signed the message with the specified KMS key and signing algorithm, and the message hasn't changed since it was signed. If the signature is verified, the value of the SignatureValid field in the response is True. If the signature verification fails, the Verify operation fails with an KMSInvalidSignatureException exception. A digital signature is generated by using the private key in an asymmetric KMS key. The signature is verified by using the public key in the same asymmetric KMS key. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. To use the Verify operation, specify the same asymmetric KMS key, message, and signing algorithm that were used to produce the signature. The message type does not need to be the same as the one used for signing, but it must indicate whether the value of the Message parameter should be hashed as part of the verification process. You can also verify the digital signature by using the public key of the KMS key outside of KMS. Use the GetPublicKey operation to download the public key in the asymmetric KMS key and then use the public key to verify the signature outside of KMS. The advantage of using the Verify operation is that it is performed within KMS. As a result, it's easy to call, the operation is performed within the FIPS boundary, it is logged in CloudTrail, and you can use key policy and IAM policy to determine who is authorized to use the KMS key to verify signatures. To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses 1234567812345678 as the distinguishing ID. For more information, see Offline verification with SM2 key pairs. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Verify (key policy) Related operations: Sign Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module VerifyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the asymmetric KMS key that will be used to verify the signature. This must be the same KMS key that was used to generate the signature. If you specify a different KMS key, the signature verification fails. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      message: PlaintextType.t
        [@ocaml.doc
          "Specifies the message that was signed. You can submit a raw message of up to 4096 bytes, or a hash digest of the message. If you submit a digest, use the MessageType parameter with a value of DIGEST. If the message specified here is different from the message that was signed, the signature verification fails. A message and its hash digest are considered to be the same message."];
      messageType: MessageType.t option
        [@ocaml.doc
          "Tells KMS whether the value of the Message parameter should be hashed as part of the signing algorithm. Use RAW for unhashed messages; use DIGEST for message digests, which are already hashed; use EXTERNAL_MU for 64-byte representative \206\188 used in ML-DSA signing as defined in NIST FIPS 204 Section 6.2. When the value of MessageType is RAW, KMS uses the standard signing algorithm, which begins with a hash function. When the value is DIGEST, KMS skips the hashing step in the signing algorithm. When the value is EXTERNAL_MU KMS skips the concatenated hashing of the public key hash and the message done in the ML-DSA signing algorithm. Use the DIGEST or EXTERNAL_MU value only when the value of the Message parameter is a message digest. If you use the DIGEST value with an unhashed message, the security of the signing operation can be compromised. When using ECC_NIST_EDWARDS25519 KMS keys: ED25519_SHA_512 signing algorithm requires KMS MessageType:RAW ED25519_PH_SHA_512 signing algorithm requires KMS MessageType:DIGEST When you specify the ED25519_PH_SHA_512 signing algorithm with MessageType:DIGEST, KMS still performs the SHA-512 prehash described in Step 1 of Section 7.8.1 in FIPS 186-5. This means the input is hashed twice: once by you and once by KMS. When the value of MessageType is DIGEST, the length of the Message value must match the length of hashed messages for the specified signing algorithm. When the value of MessageType is EXTERNAL_MU the length of the Message value must be 64 bytes. You can submit a message digest and omit the MessageType or specify RAW so the digest is hashed again while signing. However, if the signed message is hashed once while signing, but twice while verifying, verification fails, even when the message hasn't changed. The hashing algorithm that Verify uses is based on the SigningAlgorithm value. Signing algorithms that end in SHA_256 use the SHA_256 hashing algorithm. Signing algorithms that end in SHA_384 use the SHA_384 hashing algorithm. Signing algorithms that end in SHA_512 use the SHA_512 hashing algorithm. Signing algorithms that end in SHAKE_256 use the SHAKE_256 hashing algorithm. SM2DSA uses the SM3 hashing algorithm. For details, see Offline verification with SM2 key pairs."];
      signature: CiphertextType.t
        [@ocaml.doc "The signature that the Sign operation generated."];
      signingAlgorithm: SigningAlgorithmSpec.t
        [@ocaml.doc
          "The signing algorithm that was used to sign the message. If you submit a different algorithm, the signature verification fails."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "VerifyRequest"
    let make ?messageType =
      fun ?grantTokens ->
        fun ?dryRun ->
          fun ~keyId ->
            fun ~message ->
              fun ~signature ->
                fun ~signingAlgorithm ->
                  fun () ->
                    {
                      messageType;
                      grantTokens;
                      dryRun;
                      keyId;
                      message;
                      signature;
                      signingAlgorithm
                    }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Message", (Some (PlaintextType.to_value x.message)));
        ("MessageType", (Option.map x.messageType ~f:MessageType.to_value));
        ("Signature", (Some (CiphertextType.to_value x.signature)));
        ("SigningAlgorithm",
          (Some (SigningAlgorithmSpec.to_value x.signingAlgorithm)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let signingAlgorithm =
        SigningAlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "SigningAlgorithm") in
      let signature =
        CiphertextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Signature") in
      let messageType =
        (Option.map ~f:MessageType.of_xml) (Xml.child xml_arg0 "MessageType") in
      let message =
        PlaintextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Message") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ?grantTokens ~signingAlgorithm ~signature ?messageType
        ~message ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let signingAlgorithm =
        field_map_exn json__ "SigningAlgorithm" SigningAlgorithmSpec.of_json in
      let signature = field_map_exn json__ "Signature" CiphertextType.of_json in
      let messageType = field_map json__ "MessageType" MessageType.of_json in
      let message = field_map_exn json__ "Message" PlaintextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ?grantTokens ~signingAlgorithm ~signature ?messageType
        ~message ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Verifies a digital signature that was generated by the Sign operation. Verification confirms that an authorized user signed the message with the specified KMS key and signing algorithm, and the message hasn't changed since it was signed. If the signature is verified, the value of the SignatureValid field in the response is True. If the signature verification fails, the Verify operation fails with an KMSInvalidSignatureException exception. A digital signature is generated by using the private key in an asymmetric KMS key. The signature is verified by using the public key in the same asymmetric KMS key. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. To use the Verify operation, specify the same asymmetric KMS key, message, and signing algorithm that were used to produce the signature. The message type does not need to be the same as the one used for signing, but it must indicate whether the value of the Message parameter should be hashed as part of the verification process. You can also verify the digital signature by using the public key of the KMS key outside of KMS. Use the GetPublicKey operation to download the public key in the asymmetric KMS key and then use the public key to verify the signature outside of KMS. The advantage of using the Verify operation is that it is performed within KMS. As a result, it's easy to call, the operation is performed within the FIPS boundary, it is logged in CloudTrail, and you can use key policy and IAM policy to determine who is authorized to use the KMS key to verify signatures. To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses 1234567812345678 as the distinguishing ID. For more information, see Offline verification with SM2 key pairs. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Verify (key policy) Related operations: Sign Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module VerifyMacResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc "The HMAC KMS key used in the verification."];
      macValid: BooleanType.t option
        [@ocaml.doc
          "A Boolean value that indicates whether the HMAC was verified. A value of True indicates that the HMAC (Mac) was generated with the specified Message, HMAC KMS key (KeyID) and MacAlgorithm.. If the HMAC is not verified, the VerifyMac operation fails with a KMSInvalidMacException exception. This exception indicates that one or more of the inputs changed since the HMAC was computed."];
      macAlgorithm: MacAlgorithmSpec.t option
        [@ocaml.doc "The MAC algorithm used in the verification."]}
    type nonrec error =
      [ `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidMacException of KMSInvalidMacException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?macValid ->
        fun ?macAlgorithm -> fun () -> { keyId; macValid; macAlgorithm }
    let error_of_json name json =
      match name with
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidMacException" ->
          `KMSInvalidMacException (KMSInvalidMacException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidMacException" ->
          `KMSInvalidMacException (KMSInvalidMacException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidMacException e ->
          `Assoc
            [("error", (`String "KMSInvalidMacException"));
            ("details", (KMSInvalidMacException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("MacValid", (Option.map x.macValid ~f:BooleanType.to_value));
        ("MacAlgorithm",
          (Option.map x.macAlgorithm ~f:MacAlgorithmSpec.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let macAlgorithm =
        (Option.map ~f:MacAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "MacAlgorithm") in
      let macValid =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "MacValid") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?macAlgorithm ?macValid ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let macAlgorithm =
        field_map json__ "MacAlgorithm" MacAlgorithmSpec.of_json in
      let macValid = field_map json__ "MacValid" BooleanType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?macAlgorithm ?macValid ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Verifies the hash-based message authentication code (HMAC) for a specified message, HMAC KMS key, and MAC algorithm. To verify the HMAC, VerifyMac computes an HMAC using the message, HMAC KMS key, and MAC algorithm that you specify, and compares the computed HMAC to the HMAC that you specify. If the HMACs are identical, the verification succeeds; otherwise, it fails. Verification indicates that the message hasn't changed since the HMAC was calculated, and the specified key was used to generate and verify the HMAC. HMAC KMS keys and the HMAC algorithms that KMS uses conform to industry standards defined in RFC 2104. This operation is part of KMS support for HMAC KMS keys. For details, see HMAC keys in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:VerifyMac (key policy) Related operations: GenerateMac Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module VerifyMacRequest =
  struct
    type nonrec t =
      {
      message: PlaintextType.t
        [@ocaml.doc
          "The message that will be used in the verification. Enter the same message that was used to generate the HMAC. GenerateMac and VerifyMac do not provide special handling for message digests. If you generated an HMAC for a hash digest of a message, you must verify the HMAC for the same hash digest."];
      keyId: KeyIdType.t
        [@ocaml.doc
          "The KMS key that will be used in the verification. Enter a key ID of the KMS key that was used to generate the HMAC. If you identify a different KMS key, the VerifyMac operation fails."];
      macAlgorithm: MacAlgorithmSpec.t
        [@ocaml.doc
          "The MAC algorithm that will be used in the verification. Enter the same MAC algorithm that was used to compute the HMAC. This algorithm must be supported by the HMAC KMS key identified by the KeyId parameter."];
      mac: CiphertextType.t
        [@ocaml.doc
          "The HMAC to verify. Enter the HMAC that was generated by the GenerateMac operation when you specified the same message, HMAC KMS key, and MAC algorithm as the values specified in this request."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "VerifyMacRequest"
    let make ?grantTokens =
      fun ?dryRun ->
        fun ~message ->
          fun ~keyId ->
            fun ~macAlgorithm ->
              fun ~mac ->
                fun () ->
                  { grantTokens; dryRun; message; keyId; macAlgorithm; mac }
    let to_value x =
      structure_to_value
        [("Message", (Some (PlaintextType.to_value x.message)));
        ("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("MacAlgorithm", (Some (MacAlgorithmSpec.to_value x.macAlgorithm)));
        ("Mac", (Some (CiphertextType.to_value x.mac)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let mac =
        CiphertextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Mac") in
      let macAlgorithm =
        MacAlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MacAlgorithm") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      let message =
        PlaintextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Message") in
      make ?dryRun ?grantTokens ~mac ~macAlgorithm ~keyId ~message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let mac = field_map_exn json__ "Mac" CiphertextType.of_json in
      let macAlgorithm =
        field_map_exn json__ "MacAlgorithm" MacAlgorithmSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      let message = field_map_exn json__ "Message" PlaintextType.of_json in
      make ?dryRun ?grantTokens ~mac ~macAlgorithm ~keyId ~message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Verifies the hash-based message authentication code (HMAC) for a specified message, HMAC KMS key, and MAC algorithm. To verify the HMAC, VerifyMac computes an HMAC using the message, HMAC KMS key, and MAC algorithm that you specify, and compares the computed HMAC to the HMAC that you specify. If the HMACs are identical, the verification succeeds; otherwise, it fails. Verification indicates that the message hasn't changed since the HMAC was calculated, and the specified key was used to generate and verify the HMAC. HMAC KMS keys and the HMAC algorithms that KMS uses conform to industry standards defined in RFC 2104. This operation is part of KMS support for HMAC KMS keys. For details, see HMAC keys in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:VerifyMac (key policy) Related operations: GenerateMac Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UpdatePrimaryRegionRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the current primary key. When the operation completes, this KMS key will be a replica key. Specify the key ID or key ARN of a multi-Region primary key. For example: Key ID: mrk-1234abcd12ab34cd56ef1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      primaryRegion: RegionType.t
        [@ocaml.doc
          "The Amazon Web Services Region of the new primary key. Enter the Region ID, such as us-east-1 or ap-southeast-2. There must be an existing replica key in this Region. When the operation completes, the multi-Region key in this Region will be the primary key."]}
    let context_ = "UpdatePrimaryRegionRequest"
    let make ~keyId =
      fun ~primaryRegion -> fun () -> { keyId; primaryRegion }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("PrimaryRegion", (Some (RegionType.to_value x.primaryRegion)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let primaryRegion =
        RegionType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "PrimaryRegion") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~primaryRegion ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let primaryRegion =
        field_map_exn json__ "PrimaryRegion" RegionType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~primaryRegion ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Changes the primary key of a multi-Region key. This operation changes the replica key in the specified Region to a primary key and changes the former primary key to a replica key. For example, suppose you have a primary key in us-east-1 and a replica key in eu-west-2. If you run UpdatePrimaryRegion with a PrimaryRegion value of eu-west-2, the primary key is now the key in eu-west-2, and the key in us-east-1 becomes a replica key. For details, see Change the primary key in a set of multi-Region keys in the Key Management Service Developer Guide. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. The primary key of a multi-Region key is the source for properties that are always shared by primary and replica keys, including the key material, key ID, key spec, key usage, key material origin, and automatic key rotation. It's the only key that can be replicated. You cannot delete the primary key until all replica keys are deleted. The key ID and primary Region that you specify uniquely identify the replica key that will become the primary key. The primary Region must already have a replica key. This operation does not create a KMS key in the specified Region. To find the replica keys, use the DescribeKey operation on the primary key or any replica key. To create a replica key, use the ReplicateKey operation. You can run this operation while using the affected multi-Region keys in cryptographic operations. This operation should not delay, interrupt, or cause failures in cryptographic operations. Even after this operation completes, the process of updating the primary Region might still be in progress for a few more seconds. Operations such as DescribeKey might display both the old and new primary keys as replicas. The old and new primary keys have a transient key state of Updating. The original key state is restored when the update is complete. While the key state is Updating, you can use the keys in cryptographic operations, but you cannot replicate the new primary key or perform certain management operations, such as enabling or disabling these keys. For details about the Updating key state, see Key states of KMS keys in the Key Management Service Developer Guide. This operation does not return any output. To verify that primary key is changed, use the DescribeKey operation. Cross-account use: No. You cannot use this operation in a different Amazon Web Services account. Required permissions: kms:UpdatePrimaryRegion on the current primary key (in the primary key's Region). Include this permission primary key's key policy. kms:UpdatePrimaryRegion on the current replica key (in the replica key's Region). Include this permission in the replica key's key policy. Related operations CreateKey ReplicateKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UpdateKeyDescriptionRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Updates the description of the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      description: DescriptionType.t
        [@ocaml.doc
          "New description for the KMS key. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output."]}
    let context_ = "UpdateKeyDescriptionRequest"
    let make ~keyId = fun ~description -> fun () -> { keyId; description }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Description", (Some (DescriptionType.to_value x.description)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let description =
        DescriptionType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Description") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~description ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let description =
        field_map_exn json__ "Description" DescriptionType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~description ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Updates the description of a KMS key. To see the description of a KMS key, use DescribeKey. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:UpdateKeyDescription (key policy) Related operations CreateKey DescribeKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UpdateCustomKeyStoreResponse =
  struct
    type nonrec t = unit
    type nonrec error =
      [
        `CloudHsmClusterInvalidConfigurationException of
          CloudHsmClusterInvalidConfigurationException.t 
      | `CloudHsmClusterNotActiveException of
          CloudHsmClusterNotActiveException.t 
      | `CloudHsmClusterNotFoundException of
          CloudHsmClusterNotFoundException.t 
      | `CloudHsmClusterNotRelatedException of
          CloudHsmClusterNotRelatedException.t 
      | `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNameInUseException of
          CustomKeyStoreNameInUseException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `XksProxyIncorrectAuthenticationCredentialException of
          XksProxyIncorrectAuthenticationCredentialException.t 
      | `XksProxyInvalidConfigurationException of
          XksProxyInvalidConfigurationException.t 
      | `XksProxyInvalidResponseException of
          XksProxyInvalidResponseException.t 
      | `XksProxyUriEndpointInUseException of
          XksProxyUriEndpointInUseException.t 
      | `XksProxyUriInUseException of XksProxyUriInUseException.t 
      | `XksProxyUriUnreachableException of XksProxyUriUnreachableException.t 
      | `XksProxyVpcEndpointServiceInUseException of
          XksProxyVpcEndpointServiceInUseException.t 
      | `XksProxyVpcEndpointServiceInvalidConfigurationException of
          XksProxyVpcEndpointServiceInvalidConfigurationException.t 
      | `XksProxyVpcEndpointServiceNotFoundException of
          XksProxyVpcEndpointServiceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make () = ()
    let error_of_json name json =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_json json)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_json json)
      | "CloudHsmClusterNotFoundException" ->
          `CloudHsmClusterNotFoundException
            (CloudHsmClusterNotFoundException.of_json json)
      | "CloudHsmClusterNotRelatedException" ->
          `CloudHsmClusterNotRelatedException
            (CloudHsmClusterNotRelatedException.of_json json)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNameInUseException" ->
          `CustomKeyStoreNameInUseException
            (CustomKeyStoreNameInUseException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "XksProxyIncorrectAuthenticationCredentialException" ->
          `XksProxyIncorrectAuthenticationCredentialException
            (XksProxyIncorrectAuthenticationCredentialException.of_json json)
      | "XksProxyInvalidConfigurationException" ->
          `XksProxyInvalidConfigurationException
            (XksProxyInvalidConfigurationException.of_json json)
      | "XksProxyInvalidResponseException" ->
          `XksProxyInvalidResponseException
            (XksProxyInvalidResponseException.of_json json)
      | "XksProxyUriEndpointInUseException" ->
          `XksProxyUriEndpointInUseException
            (XksProxyUriEndpointInUseException.of_json json)
      | "XksProxyUriInUseException" ->
          `XksProxyUriInUseException (XksProxyUriInUseException.of_json json)
      | "XksProxyUriUnreachableException" ->
          `XksProxyUriUnreachableException
            (XksProxyUriUnreachableException.of_json json)
      | "XksProxyVpcEndpointServiceInUseException" ->
          `XksProxyVpcEndpointServiceInUseException
            (XksProxyVpcEndpointServiceInUseException.of_json json)
      | "XksProxyVpcEndpointServiceInvalidConfigurationException" ->
          `XksProxyVpcEndpointServiceInvalidConfigurationException
            (XksProxyVpcEndpointServiceInvalidConfigurationException.of_json
               json)
      | "XksProxyVpcEndpointServiceNotFoundException" ->
          `XksProxyVpcEndpointServiceNotFoundException
            (XksProxyVpcEndpointServiceNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_xml xml)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_xml xml)
      | "CloudHsmClusterNotFoundException" ->
          `CloudHsmClusterNotFoundException
            (CloudHsmClusterNotFoundException.of_xml xml)
      | "CloudHsmClusterNotRelatedException" ->
          `CloudHsmClusterNotRelatedException
            (CloudHsmClusterNotRelatedException.of_xml xml)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNameInUseException" ->
          `CustomKeyStoreNameInUseException
            (CustomKeyStoreNameInUseException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "XksProxyIncorrectAuthenticationCredentialException" ->
          `XksProxyIncorrectAuthenticationCredentialException
            (XksProxyIncorrectAuthenticationCredentialException.of_xml xml)
      | "XksProxyInvalidConfigurationException" ->
          `XksProxyInvalidConfigurationException
            (XksProxyInvalidConfigurationException.of_xml xml)
      | "XksProxyInvalidResponseException" ->
          `XksProxyInvalidResponseException
            (XksProxyInvalidResponseException.of_xml xml)
      | "XksProxyUriEndpointInUseException" ->
          `XksProxyUriEndpointInUseException
            (XksProxyUriEndpointInUseException.of_xml xml)
      | "XksProxyUriInUseException" ->
          `XksProxyUriInUseException (XksProxyUriInUseException.of_xml xml)
      | "XksProxyUriUnreachableException" ->
          `XksProxyUriUnreachableException
            (XksProxyUriUnreachableException.of_xml xml)
      | "XksProxyVpcEndpointServiceInUseException" ->
          `XksProxyVpcEndpointServiceInUseException
            (XksProxyVpcEndpointServiceInUseException.of_xml xml)
      | "XksProxyVpcEndpointServiceInvalidConfigurationException" ->
          `XksProxyVpcEndpointServiceInvalidConfigurationException
            (XksProxyVpcEndpointServiceInvalidConfigurationException.of_xml
               xml)
      | "XksProxyVpcEndpointServiceNotFoundException" ->
          `XksProxyVpcEndpointServiceNotFoundException
            (XksProxyVpcEndpointServiceNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CloudHsmClusterInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String "CloudHsmClusterInvalidConfigurationException"));
            ("details",
              (CloudHsmClusterInvalidConfigurationException.to_json e))]
      | `CloudHsmClusterNotActiveException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotActiveException"));
            ("details", (CloudHsmClusterNotActiveException.to_json e))]
      | `CloudHsmClusterNotFoundException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotFoundException"));
            ("details", (CloudHsmClusterNotFoundException.to_json e))]
      | `CloudHsmClusterNotRelatedException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotRelatedException"));
            ("details", (CloudHsmClusterNotRelatedException.to_json e))]
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNameInUseException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNameInUseException"));
            ("details", (CustomKeyStoreNameInUseException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `XksProxyIncorrectAuthenticationCredentialException e ->
          `Assoc
            [("error",
               (`String "XksProxyIncorrectAuthenticationCredentialException"));
            ("details",
              (XksProxyIncorrectAuthenticationCredentialException.to_json e))]
      | `XksProxyInvalidConfigurationException e ->
          `Assoc
            [("error", (`String "XksProxyInvalidConfigurationException"));
            ("details", (XksProxyInvalidConfigurationException.to_json e))]
      | `XksProxyInvalidResponseException e ->
          `Assoc
            [("error", (`String "XksProxyInvalidResponseException"));
            ("details", (XksProxyInvalidResponseException.to_json e))]
      | `XksProxyUriEndpointInUseException e ->
          `Assoc
            [("error", (`String "XksProxyUriEndpointInUseException"));
            ("details", (XksProxyUriEndpointInUseException.to_json e))]
      | `XksProxyUriInUseException e ->
          `Assoc
            [("error", (`String "XksProxyUriInUseException"));
            ("details", (XksProxyUriInUseException.to_json e))]
      | `XksProxyUriUnreachableException e ->
          `Assoc
            [("error", (`String "XksProxyUriUnreachableException"));
            ("details", (XksProxyUriUnreachableException.to_json e))]
      | `XksProxyVpcEndpointServiceInUseException e ->
          `Assoc
            [("error", (`String "XksProxyVpcEndpointServiceInUseException"));
            ("details", (XksProxyVpcEndpointServiceInUseException.to_json e))]
      | `XksProxyVpcEndpointServiceInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String
                  "XksProxyVpcEndpointServiceInvalidConfigurationException"));
            ("details",
              (XksProxyVpcEndpointServiceInvalidConfigurationException.to_json
                 e))]
      | `XksProxyVpcEndpointServiceNotFoundException e ->
          `Assoc
            [("error",
               (`String "XksProxyVpcEndpointServiceNotFoundException"));
            ("details",
              (XksProxyVpcEndpointServiceNotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Changes the properties of a custom key store. You can use this operation to change the properties of an CloudHSM key store or an external key store. Use the required CustomKeyStoreId parameter to identify the custom key store. Use the remaining optional parameters to change its properties. This operation does not return any property values. To verify the updated property values, use the DescribeCustomKeyStores operation. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. When updating the properties of an external key store, verify that the updated settings connect your key store, via the external key store proxy, to the same external key manager as the previous settings, or to a backup or snapshot of the external key manager with the same cryptographic keys. If the updated connection settings fail, you can fix them and retry, although an extended delay might disrupt Amazon Web Services services. However, if KMS permanently loses its access to cryptographic keys, ciphertext encrypted under those keys is unrecoverable. For external key stores: Some external key managers provide a simpler method for updating an external key store. For details, see your external key manager documentation. When updating an external key store in the KMS console, you can upload a JSON-based proxy configuration file with the desired values. You cannot upload the proxy configuration file to the UpdateCustomKeyStore operation. However, you can use the file to help you determine the correct values for the UpdateCustomKeyStore parameters. For an CloudHSM key store, you can use this operation to change the custom key store friendly name (NewCustomKeyStoreName), to tell KMS about a change to the kmsuser crypto user password (KeyStorePassword), or to associate the custom key store with a different, but related, CloudHSM cluster (CloudHsmClusterId). To update most properties of an CloudHSM key store, the ConnectionState of the CloudHSM key store must be DISCONNECTED. However, you can update the CustomKeyStoreName of an AWS CloudHSM key store when it is in the CONNECTED or DISCONNECTED state. For an external key store, you can use this operation to change the custom key store friendly name (NewCustomKeyStoreName), or to tell KMS about a change to the external key store proxy authentication credentials (XksProxyAuthenticationCredential), connection method (XksProxyConnectivity), external proxy endpoint (XksProxyUriEndpoint) and path (XksProxyUriPath). For external key stores with an XksProxyConnectivity of VPC_ENDPOINT_SERVICE, you can also update the Amazon VPC endpoint service name (XksProxyVpcEndpointServiceName). To update most properties of an external key store, the ConnectionState of the external key store must be DISCONNECTED. However, you can update the CustomKeyStoreName, XksProxyAuthenticationCredential, and XksProxyUriPath of an external key store when it is in the CONNECTED or DISCONNECTED state. If your update requires a DISCONNECTED state, before using UpdateCustomKeyStore, use the DisconnectCustomKeyStore operation to disconnect the custom key store. After the UpdateCustomKeyStore operation completes, use the ConnectCustomKeyStore to reconnect the custom key store. To find the ConnectionState of the custom key store, use the DescribeCustomKeyStores operation. Before updating the custom key store, verify that the new values allow KMS to connect the custom key store to its backing key store. For example, before you change the XksProxyUriPath value, verify that the external key store proxy is reachable at the new path. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:UpdateCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UpdateCustomKeyStoreRequest =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t
        [@ocaml.doc
          "Identifies the custom key store that you want to update. Enter the ID of the custom key store. To find the ID of a custom key store, use the DescribeCustomKeyStores operation."];
      newCustomKeyStoreName: CustomKeyStoreNameType.t option
        [@ocaml.doc
          "Changes the friendly name of the custom key store to the value that you specify. The custom key store name must be unique in the Amazon Web Services account. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. To change this value, the custom key store can be connected or disconnected."];
      keyStorePassword: KeyStorePasswordType.t option
        [@ocaml.doc
          "Enter the current password of the kmsuser crypto user (CU) in the CloudHSM cluster that is associated with the custom key store. This parameter is valid only for custom key stores with a CustomKeyStoreType of AWS_CLOUDHSM. This parameter tells KMS the current password of the kmsuser crypto user (CU). It does not set or change the password of any users in the CloudHSM cluster. To change this value, the CloudHSM key store must be disconnected."];
      cloudHsmClusterId: CloudHsmClusterIdType.t option
        [@ocaml.doc
          "Associates the custom key store with a related CloudHSM cluster. This parameter is valid only for custom key stores with a CustomKeyStoreType of AWS_CLOUDHSM. Enter the cluster ID of the cluster that you used to create the custom key store or a cluster that shares a backup history and has the same cluster certificate as the original cluster. You cannot use this parameter to associate a custom key store with an unrelated cluster. In addition, the replacement cluster must fulfill the requirements for a cluster associated with a custom key store. To view the cluster certificate of a cluster, use the DescribeClusters operation. To change this value, the CloudHSM key store must be disconnected."];
      xksProxyUriEndpoint: XksProxyUriEndpointType.t option
        [@ocaml.doc
          "Changes the URI endpoint that KMS uses to connect to your external key store proxy (XKS proxy). This parameter is valid only for custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. For external key stores with an XksProxyConnectivity value of PUBLIC_ENDPOINT, the protocol must be HTTPS. For external key stores with an XksProxyConnectivity value of VPC_ENDPOINT_SERVICE, specify https:// followed by the private DNS name associated with the VPC endpoint service. Each external key store must use a different private DNS name. The combined XksProxyUriEndpoint and XksProxyUriPath values must be unique in the Amazon Web Services account and Region. To change this value, the external key store must be disconnected."];
      xksProxyUriPath: XksProxyUriPathType.t option
        [@ocaml.doc
          "Changes the base path to the proxy APIs for this external key store. To find this value, see the documentation for your external key manager and external key store proxy (XKS proxy). This parameter is valid only for custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. The value must start with / and must end with /kms/xks/v1, where v1 represents the version of the KMS external key store proxy API. You can include an optional prefix between the required elements such as /example/kms/xks/v1. The combined XksProxyUriEndpoint and XksProxyUriPath values must be unique in the Amazon Web Services account and Region. You can change this value when the external key store is connected or disconnected."];
      xksProxyVpcEndpointServiceName:
        XksProxyVpcEndpointServiceNameType.t option
        [@ocaml.doc
          "Changes the name that KMS uses to identify the Amazon VPC endpoint service for your external key store proxy (XKS proxy). This parameter is valid when the CustomKeyStoreType is EXTERNAL_KEY_STORE and the XksProxyConnectivity is VPC_ENDPOINT_SERVICE. To change this value, the external key store must be disconnected."];
      xksProxyVpcEndpointServiceOwner: AccountIdType.t option
        [@ocaml.doc
          "Changes the Amazon Web Services account ID that KMS uses to identify the Amazon VPC endpoint service for your external key store proxy (XKS proxy). This parameter is optional. If not specified, the current Amazon Web Services account ID for the VPC endpoint service will not be updated. To change this value, the external key store must be disconnected."];
      xksProxyAuthenticationCredential:
        XksProxyAuthenticationCredentialType.t option
        [@ocaml.doc
          "Changes the credentials that KMS uses to sign requests to the external key store proxy (XKS proxy). This parameter is valid only for custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. You must specify both the AccessKeyId and SecretAccessKey value in the authentication credential, even if you are only updating one value. This parameter doesn't establish or change your authentication credentials on the proxy. It just tells KMS the credential that you established with your external key store proxy. For example, if you rotate the credential on your external key store proxy, you can use this parameter to update the credential in KMS. You can change this value when the external key store is connected or disconnected."];
      xksProxyConnectivity: XksProxyConnectivityType.t option
        [@ocaml.doc
          "Changes the connectivity setting for the external key store. To indicate that the external key store proxy uses a Amazon VPC endpoint service to communicate with KMS, specify VPC_ENDPOINT_SERVICE. Otherwise, specify PUBLIC_ENDPOINT. If you change the XksProxyConnectivity to VPC_ENDPOINT_SERVICE, you must also change the XksProxyUriEndpoint and add an XksProxyVpcEndpointServiceName value. If you change the XksProxyConnectivity to PUBLIC_ENDPOINT, you must also change the XksProxyUriEndpoint and specify a null or empty string for the XksProxyVpcEndpointServiceName value. To change this value, the external key store must be disconnected."]}
    let context_ = "UpdateCustomKeyStoreRequest"
    let make ?newCustomKeyStoreName =
      fun ?keyStorePassword ->
        fun ?cloudHsmClusterId ->
          fun ?xksProxyUriEndpoint ->
            fun ?xksProxyUriPath ->
              fun ?xksProxyVpcEndpointServiceName ->
                fun ?xksProxyVpcEndpointServiceOwner ->
                  fun ?xksProxyAuthenticationCredential ->
                    fun ?xksProxyConnectivity ->
                      fun ~customKeyStoreId ->
                        fun () ->
                          {
                            newCustomKeyStoreName;
                            keyStorePassword;
                            cloudHsmClusterId;
                            xksProxyUriEndpoint;
                            xksProxyUriPath;
                            xksProxyVpcEndpointServiceName;
                            xksProxyVpcEndpointServiceOwner;
                            xksProxyAuthenticationCredential;
                            xksProxyConnectivity;
                            customKeyStoreId
                          }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Some (CustomKeyStoreIdType.to_value x.customKeyStoreId)));
        ("NewCustomKeyStoreName",
          (Option.map x.newCustomKeyStoreName
             ~f:CustomKeyStoreNameType.to_value));
        ("KeyStorePassword",
          (Option.map x.keyStorePassword ~f:KeyStorePasswordType.to_value));
        ("CloudHsmClusterId",
          (Option.map x.cloudHsmClusterId ~f:CloudHsmClusterIdType.to_value));
        ("XksProxyUriEndpoint",
          (Option.map x.xksProxyUriEndpoint
             ~f:XksProxyUriEndpointType.to_value));
        ("XksProxyUriPath",
          (Option.map x.xksProxyUriPath ~f:XksProxyUriPathType.to_value));
        ("XksProxyVpcEndpointServiceName",
          (Option.map x.xksProxyVpcEndpointServiceName
             ~f:XksProxyVpcEndpointServiceNameType.to_value));
        ("XksProxyVpcEndpointServiceOwner",
          (Option.map x.xksProxyVpcEndpointServiceOwner
             ~f:AccountIdType.to_value));
        ("XksProxyAuthenticationCredential",
          (Option.map x.xksProxyAuthenticationCredential
             ~f:XksProxyAuthenticationCredentialType.to_value));
        ("XksProxyConnectivity",
          (Option.map x.xksProxyConnectivity
             ~f:XksProxyConnectivityType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let xksProxyConnectivity =
        (Option.map ~f:XksProxyConnectivityType.of_xml)
          (Xml.child xml_arg0 "XksProxyConnectivity") in
      let xksProxyAuthenticationCredential =
        (Option.map ~f:XksProxyAuthenticationCredentialType.of_xml)
          (Xml.child xml_arg0 "XksProxyAuthenticationCredential") in
      let xksProxyVpcEndpointServiceOwner =
        (Option.map ~f:AccountIdType.of_xml)
          (Xml.child xml_arg0 "XksProxyVpcEndpointServiceOwner") in
      let xksProxyVpcEndpointServiceName =
        (Option.map ~f:XksProxyVpcEndpointServiceNameType.of_xml)
          (Xml.child xml_arg0 "XksProxyVpcEndpointServiceName") in
      let xksProxyUriPath =
        (Option.map ~f:XksProxyUriPathType.of_xml)
          (Xml.child xml_arg0 "XksProxyUriPath") in
      let xksProxyUriEndpoint =
        (Option.map ~f:XksProxyUriEndpointType.of_xml)
          (Xml.child xml_arg0 "XksProxyUriEndpoint") in
      let cloudHsmClusterId =
        (Option.map ~f:CloudHsmClusterIdType.of_xml)
          (Xml.child xml_arg0 "CloudHsmClusterId") in
      let keyStorePassword =
        (Option.map ~f:KeyStorePasswordType.of_xml)
          (Xml.child xml_arg0 "KeyStorePassword") in
      let newCustomKeyStoreName =
        (Option.map ~f:CustomKeyStoreNameType.of_xml)
          (Xml.child xml_arg0 "NewCustomKeyStoreName") in
      let customKeyStoreId =
        CustomKeyStoreIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "CustomKeyStoreId") in
      make ?xksProxyConnectivity ?xksProxyAuthenticationCredential
        ?xksProxyVpcEndpointServiceOwner ?xksProxyVpcEndpointServiceName
        ?xksProxyUriPath ?xksProxyUriEndpoint ?cloudHsmClusterId
        ?keyStorePassword ?newCustomKeyStoreName ~customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let xksProxyConnectivity =
        field_map json__ "XksProxyConnectivity"
          XksProxyConnectivityType.of_json in
      let xksProxyAuthenticationCredential =
        field_map json__ "XksProxyAuthenticationCredential"
          XksProxyAuthenticationCredentialType.of_json in
      let xksProxyVpcEndpointServiceOwner =
        field_map json__ "XksProxyVpcEndpointServiceOwner"
          AccountIdType.of_json in
      let xksProxyVpcEndpointServiceName =
        field_map json__ "XksProxyVpcEndpointServiceName"
          XksProxyVpcEndpointServiceNameType.of_json in
      let xksProxyUriPath =
        field_map json__ "XksProxyUriPath" XksProxyUriPathType.of_json in
      let xksProxyUriEndpoint =
        field_map json__ "XksProxyUriEndpoint"
          XksProxyUriEndpointType.of_json in
      let cloudHsmClusterId =
        field_map json__ "CloudHsmClusterId" CloudHsmClusterIdType.of_json in
      let keyStorePassword =
        field_map json__ "KeyStorePassword" KeyStorePasswordType.of_json in
      let newCustomKeyStoreName =
        field_map json__ "NewCustomKeyStoreName"
          CustomKeyStoreNameType.of_json in
      let customKeyStoreId =
        field_map_exn json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ?xksProxyConnectivity ?xksProxyAuthenticationCredential
        ?xksProxyVpcEndpointServiceOwner ?xksProxyVpcEndpointServiceName
        ?xksProxyUriPath ?xksProxyUriEndpoint ?cloudHsmClusterId
        ?keyStorePassword ?newCustomKeyStoreName ~customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Changes the properties of a custom key store. You can use this operation to change the properties of an CloudHSM key store or an external key store. Use the required CustomKeyStoreId parameter to identify the custom key store. Use the remaining optional parameters to change its properties. This operation does not return any property values. To verify the updated property values, use the DescribeCustomKeyStores operation. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. When updating the properties of an external key store, verify that the updated settings connect your key store, via the external key store proxy, to the same external key manager as the previous settings, or to a backup or snapshot of the external key manager with the same cryptographic keys. If the updated connection settings fail, you can fix them and retry, although an extended delay might disrupt Amazon Web Services services. However, if KMS permanently loses its access to cryptographic keys, ciphertext encrypted under those keys is unrecoverable. For external key stores: Some external key managers provide a simpler method for updating an external key store. For details, see your external key manager documentation. When updating an external key store in the KMS console, you can upload a JSON-based proxy configuration file with the desired values. You cannot upload the proxy configuration file to the UpdateCustomKeyStore operation. However, you can use the file to help you determine the correct values for the UpdateCustomKeyStore parameters. For an CloudHSM key store, you can use this operation to change the custom key store friendly name (NewCustomKeyStoreName), to tell KMS about a change to the kmsuser crypto user password (KeyStorePassword), or to associate the custom key store with a different, but related, CloudHSM cluster (CloudHsmClusterId). To update most properties of an CloudHSM key store, the ConnectionState of the CloudHSM key store must be DISCONNECTED. However, you can update the CustomKeyStoreName of an AWS CloudHSM key store when it is in the CONNECTED or DISCONNECTED state. For an external key store, you can use this operation to change the custom key store friendly name (NewCustomKeyStoreName), or to tell KMS about a change to the external key store proxy authentication credentials (XksProxyAuthenticationCredential), connection method (XksProxyConnectivity), external proxy endpoint (XksProxyUriEndpoint) and path (XksProxyUriPath). For external key stores with an XksProxyConnectivity of VPC_ENDPOINT_SERVICE, you can also update the Amazon VPC endpoint service name (XksProxyVpcEndpointServiceName). To update most properties of an external key store, the ConnectionState of the external key store must be DISCONNECTED. However, you can update the CustomKeyStoreName, XksProxyAuthenticationCredential, and XksProxyUriPath of an external key store when it is in the CONNECTED or DISCONNECTED state. If your update requires a DISCONNECTED state, before using UpdateCustomKeyStore, use the DisconnectCustomKeyStore operation to disconnect the custom key store. After the UpdateCustomKeyStore operation completes, use the ConnectCustomKeyStore to reconnect the custom key store. To find the ConnectionState of the custom key store, use the DescribeCustomKeyStores operation. Before updating the custom key store, verify that the new values allow KMS to connect the custom key store to its backing key store. For example, before you change the XksProxyUriPath value, verify that the external key store proxy is reachable at the new path. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:UpdateCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UpdateAliasRequest =
  struct
    type nonrec t =
      {
      aliasName: AliasNameType.t
        [@ocaml.doc
          "Identifies the alias that is changing its KMS key. This value must begin with alias/ followed by the alias name, such as alias/ExampleAlias. You cannot use UpdateAlias to change the alias name. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output."];
      targetKeyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the customer managed key to associate with the alias. You don't have permission to associate an alias with an Amazon Web Services managed key. The KMS key must be in the same Amazon Web Services account and Region as the alias. Also, the new target KMS key must be the same type as the current target KMS key (both symmetric or both asymmetric or both HMAC) and they must have the same key usage. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To verify that the alias is mapped to the correct KMS key, use ListAliases."]}
    let context_ = "UpdateAliasRequest"
    let make ~aliasName =
      fun ~targetKeyId -> fun () -> { aliasName; targetKeyId }
    let to_value x =
      structure_to_value
        [("AliasName", (Some (AliasNameType.to_value x.aliasName)));
        ("TargetKeyId", (Some (KeyIdType.to_value x.targetKeyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let targetKeyId =
        KeyIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "TargetKeyId") in
      let aliasName =
        AliasNameType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "AliasName") in
      make ~targetKeyId ~aliasName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let targetKeyId = field_map_exn json__ "TargetKeyId" KeyIdType.of_json in
      let aliasName = field_map_exn json__ "AliasName" AliasNameType.of_json in
      make ~targetKeyId ~aliasName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Associates an existing KMS alias with a different KMS key. Each alias is associated with only one KMS key at a time, although a KMS key can have multiple aliases. The alias and the KMS key must be in the same Amazon Web Services account and Region. Adding, deleting, or updating an alias can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. The current and new KMS key must be the same type (both symmetric or both asymmetric or both HMAC), and they must have the same key usage. This restriction prevents errors in code that uses aliases. If you must assign an alias to a different type of KMS key, use DeleteAlias to delete the old alias and CreateAlias to create a new alias. You cannot use UpdateAlias to change an alias name. To change an alias name, use DeleteAlias to delete the old alias and CreateAlias to create a new alias. Because an alias is not a property of a KMS key, you can create, update, and delete the aliases of a KMS key without affecting the KMS key. Also, aliases do not appear in the response from the DescribeKey operation. To get the aliases of all KMS keys in the account, use the ListAliases operation. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions kms:UpdateAlias on the alias (IAM policy). kms:UpdateAlias on the current KMS key (key policy). kms:UpdateAlias on the new KMS key (key policy). For details, see Controlling access to aliases in the Key Management Service Developer Guide. Related operations: CreateAlias DeleteAlias ListAliases Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module UntagResourceRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key from which you are removing tags. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      tagKeys: TagKeyList.t
        [@ocaml.doc
          "One or more tag keys. Specify only the tag keys, not the tag values."]}
    let context_ = "UntagResourceRequest"
    let make ~keyId = fun ~tagKeys -> fun () -> { keyId; tagKeys }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("TagKeys", (Some (TagKeyList.to_value x.tagKeys)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let tagKeys =
        TagKeyList.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "TagKeys") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~tagKeys ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let tagKeys = field_map_exn json__ "TagKeys" TagKeyList.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~tagKeys ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes tags from a customer managed key. To delete a tag, specify the tag key and the KMS key. Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. When it succeeds, the UntagResource operation doesn't return any output. Also, if the specified tag key isn't found on the KMS key, it doesn't throw an exception or return a response. To confirm that the operation worked, use the ListResourceTags operation. For information about using tags in KMS, see Tagging keys. For general information about tags, including the format and syntax, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:UntagResource (key policy) Related operations CreateKey ListResourceTags ReplicateKey TagResource Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module TagResourceRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies a customer managed key in the account and Region. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      tags: TagList.t
        [@ocaml.doc
          "One or more tags. Each tag consists of a tag key and a tag value. The tag value can be an empty (null) string. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. You cannot have more than one tag on a KMS key with the same tag key. If you specify an existing tag key with a different tag value, KMS replaces the current tag value with the specified one."]}
    let context_ = "TagResourceRequest"
    let make ~keyId = fun ~tags -> fun () -> { keyId; tags }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Tags", (Some (TagList.to_value x.tags)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let tags =
        TagList.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Tags") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~tags ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let tags = field_map_exn json__ "Tags" TagList.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~tags ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Adds or edits tags on a customer managed key. Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. Each tag consists of a tag key and a tag value, both of which are case-sensitive strings. The tag value can be an empty (null) string. To add a tag, specify a new tag key and a tag value. To edit a tag, specify an existing tag key and a new tag value. You can use this operation to tag a customer managed key, but you cannot tag an Amazon Web Services managed key, an Amazon Web Services owned key, a custom key store, or an alias. You can also add tags to a KMS key while creating it (CreateKey) or replicating it (ReplicateKey). For information about using tags in KMS, see Tagging keys. For general information about tags, including the format and syntax, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:TagResource (key policy) Related operations CreateKey ListResourceTags ReplicateKey UntagResource Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module SignResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the asymmetric KMS key that was used to sign the message."];
      signature: CiphertextType.t option
        [@ocaml.doc
          "The cryptographic signature that was generated for the message. When used with the supported RSA signing algorithms, the encoding of this value is defined by PKCS #1 in RFC 8017. When used with the ECDSA_SHA_256, ECDSA_SHA_384, or ECDSA_SHA_512 signing algorithms, this value is a DER-encoded object as defined by ANSI X9.62\226\128\1472005 and RFC 3279 Section 2.2.3. This is the most commonly used signature format and is appropriate for most uses. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      signingAlgorithm: SigningAlgorithmSpec.t option
        [@ocaml.doc
          "The signing algorithm that was used to sign the message."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?signature ->
        fun ?signingAlgorithm ->
          fun () -> { keyId; signature; signingAlgorithm }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("Signature", (Option.map x.signature ~f:CiphertextType.to_value));
        ("SigningAlgorithm",
          (Option.map x.signingAlgorithm ~f:SigningAlgorithmSpec.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let signingAlgorithm =
        (Option.map ~f:SigningAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "SigningAlgorithm") in
      let signature =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "Signature") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?signingAlgorithm ?signature ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let signingAlgorithm =
        field_map json__ "SigningAlgorithm" SigningAlgorithmSpec.of_json in
      let signature = field_map json__ "Signature" CiphertextType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?signingAlgorithm ?signature ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a digital signature for a message or message digest by using the private key in an asymmetric signing KMS key. To verify the signature, use the Verify operation, or use the public key in the same asymmetric KMS key outside of KMS. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. Digital signatures are generated and verified by using asymmetric key pair, such as an RSA, ECC, or ML-DSA pair that is represented by an asymmetric KMS key. The key owner (or an authorized user) uses their private key to sign a message. Anyone with the public key can verify that the message was signed with that particular private key and that the message hasn't changed since it was signed. To use the Sign operation, provide the following information: Use the KeyId parameter to identify an asymmetric KMS key with a KeyUsage value of SIGN_VERIFY. To get the KeyUsage value of a KMS key, use the DescribeKey operation. The caller must have kms:Sign permission on the KMS key. Use the Message parameter to specify the message or message digest to sign. You can submit messages of up to 4096 bytes. To sign a larger message, generate a hash digest of the message, and then provide the hash digest in the Message parameter. To indicate whether the message is a full message, a digest, or an ML-DSA EXTERNAL_MU, use the MessageType parameter. Choose a signing algorithm that is compatible with the KMS key. When signing a message, be sure to record the KMS key and the signing algorithm. This information is required to verify the signature. Best practices recommend that you limit the time during which any signature is effective. This deters an attack where the actor uses a signed message to establish validity repeatedly or long after the message is superseded. Signatures do not include a timestamp, but you can include a timestamp in the signed message to help you detect when its time to refresh the signature. To verify the signature that this operation generates, use the Verify operation. Or use the GetPublicKey operation to download the public key and then use the public key to verify the signature outside of KMS. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Sign (key policy) Related operations: Verify Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module SignRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies an asymmetric KMS key. KMS uses the private key in the asymmetric KMS key to sign the message. The KeyUsage type of the KMS key must be SIGN_VERIFY. To find the KeyUsage of a KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      message: PlaintextType.t
        [@ocaml.doc
          "Specifies the message or message digest to sign. Messages can be 0-4096 bytes. To sign a larger message, provide a message digest. If you provide a message digest, use the DIGEST value of MessageType to prevent the digest from being hashed again while signing."];
      messageType: MessageType.t option
        [@ocaml.doc
          "Tells KMS whether the value of the Message parameter should be hashed as part of the signing algorithm. Use RAW for unhashed messages; use DIGEST for message digests, which are already hashed; use EXTERNAL_MU for 64-byte representative \206\188 used in ML-DSA signing as defined in NIST FIPS 204 Section 6.2. When the value of MessageType is RAW, KMS uses the standard signing algorithm, which begins with a hash function. When the value is DIGEST, KMS skips the hashing step in the signing algorithm. When the value is EXTERNAL_MU KMS skips the concatenated hashing of the public key hash and the message done in the ML-DSA signing algorithm. Use the DIGEST or EXTERNAL_MU value only when the value of the Message parameter is a message digest. If you use the DIGEST value with an unhashed message, the security of the signing operation can be compromised. When using ECC_NIST_EDWARDS25519 KMS keys: ED25519_SHA_512 signing algorithm requires KMS MessageType:RAW ED25519_PH_SHA_512 signing algorithm requires KMS MessageType:DIGEST When you specify the ED25519_PH_SHA_512 signing algorithm with MessageType:DIGEST, KMS still performs the SHA-512 prehash described in Step 1 of Section 7.8.1 in FIPS 186-5. This means the input is hashed twice: once by you and once by KMS. When the value of MessageType is DIGEST, the length of the Message value must match the length of hashed messages for the specified signing algorithm. When the value of MessageType is EXTERNAL_MU the length of the Message value must be 64 bytes. You can submit a message digest and omit the MessageType or specify RAW so the digest is hashed again while signing. However, this can cause verification failures when verifying with a system that assumes a single hash. The hashing algorithm that Sign uses is based on the SigningAlgorithm value. Signing algorithms that end in SHA_256 use the SHA_256 hashing algorithm. Signing algorithms that end in SHA_384 use the SHA_384 hashing algorithm. Signing algorithms that end in SHA_512 use the SHA_512 hashing algorithm. Signing algorithms that end in SHAKE_256 use the SHAKE_256 hashing algorithm. SM2DSA uses the SM3 hashing algorithm. For details, see Offline verification with SM2 key pairs."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      signingAlgorithm: SigningAlgorithmSpec.t
        [@ocaml.doc
          "Specifies the signing algorithm to use when signing the message. Choose an algorithm that is compatible with the type and size of the specified asymmetric KMS key. When signing with RSA key pairs, RSASSA-PSS algorithms are preferred. We include RSASSA-PKCS1-v1_5 algorithms for compatibility with existing applications."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "SignRequest"
    let make ?messageType =
      fun ?grantTokens ->
        fun ?dryRun ->
          fun ~keyId ->
            fun ~message ->
              fun ~signingAlgorithm ->
                fun () ->
                  {
                    messageType;
                    grantTokens;
                    dryRun;
                    keyId;
                    message;
                    signingAlgorithm
                  }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Message", (Some (PlaintextType.to_value x.message)));
        ("MessageType", (Option.map x.messageType ~f:MessageType.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("SigningAlgorithm",
          (Some (SigningAlgorithmSpec.to_value x.signingAlgorithm)));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let signingAlgorithm =
        SigningAlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "SigningAlgorithm") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let messageType =
        (Option.map ~f:MessageType.of_xml) (Xml.child xml_arg0 "MessageType") in
      let message =
        PlaintextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Message") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ~signingAlgorithm ?grantTokens ?messageType ~message
        ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let signingAlgorithm =
        field_map_exn json__ "SigningAlgorithm" SigningAlgorithmSpec.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let messageType = field_map json__ "MessageType" MessageType.of_json in
      let message = field_map_exn json__ "Message" PlaintextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ~signingAlgorithm ?grantTokens ?messageType ~message
        ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a digital signature for a message or message digest by using the private key in an asymmetric signing KMS key. To verify the signature, use the Verify operation, or use the public key in the same asymmetric KMS key outside of KMS. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. Digital signatures are generated and verified by using asymmetric key pair, such as an RSA, ECC, or ML-DSA pair that is represented by an asymmetric KMS key. The key owner (or an authorized user) uses their private key to sign a message. Anyone with the public key can verify that the message was signed with that particular private key and that the message hasn't changed since it was signed. To use the Sign operation, provide the following information: Use the KeyId parameter to identify an asymmetric KMS key with a KeyUsage value of SIGN_VERIFY. To get the KeyUsage value of a KMS key, use the DescribeKey operation. The caller must have kms:Sign permission on the KMS key. Use the Message parameter to specify the message or message digest to sign. You can submit messages of up to 4096 bytes. To sign a larger message, generate a hash digest of the message, and then provide the hash digest in the Message parameter. To indicate whether the message is a full message, a digest, or an ML-DSA EXTERNAL_MU, use the MessageType parameter. Choose a signing algorithm that is compatible with the KMS key. When signing a message, be sure to record the KMS key and the signing algorithm. This information is required to verify the signature. Best practices recommend that you limit the time during which any signature is effective. This deters an attack where the actor uses a signed message to establish validity repeatedly or long after the message is superseded. Signatures do not include a timestamp, but you can include a timestamp in the signed message to help you detect when its time to refresh the signature. To verify the signature that this operation generates, use the Verify operation. Or use the GetPublicKey operation to download the public key and then use the public key to verify the signature outside of KMS. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Sign (key policy) Related operations: Verify Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ScheduleKeyDeletionResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key whose deletion is scheduled."];
      deletionDate: DateType.t option
        [@ocaml.doc
          "The date and time after which KMS deletes the KMS key. If the KMS key is a multi-Region primary key with replica keys, this field does not appear. The deletion date for the primary key isn't known until its last replica key is deleted."];
      keyState: KeyState.t option
        [@ocaml.doc
          "The current status of the KMS key. For more information about how key state affects the use of a KMS key, see Key states of KMS keys in the Key Management Service Developer Guide."];
      pendingWindowInDays: PendingWindowInDaysType.t option
        [@ocaml.doc
          "The waiting period before the KMS key is deleted. If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?deletionDate ->
        fun ?keyState ->
          fun ?pendingWindowInDays ->
            fun () -> { keyId; deletionDate; keyState; pendingWindowInDays }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("DeletionDate", (Option.map x.deletionDate ~f:DateType.to_value));
        ("KeyState", (Option.map x.keyState ~f:KeyState.to_value));
        ("PendingWindowInDays",
          (Option.map x.pendingWindowInDays
             ~f:PendingWindowInDaysType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let pendingWindowInDays =
        (Option.map ~f:PendingWindowInDaysType.of_xml)
          (Xml.child xml_arg0 "PendingWindowInDays") in
      let keyState =
        (Option.map ~f:KeyState.of_xml) (Xml.child xml_arg0 "KeyState") in
      let deletionDate =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "DeletionDate") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?pendingWindowInDays ?keyState ?deletionDate ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let pendingWindowInDays =
        field_map json__ "PendingWindowInDays"
          PendingWindowInDaysType.of_json in
      let keyState = field_map json__ "KeyState" KeyState.of_json in
      let deletionDate = field_map json__ "DeletionDate" DateType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?pendingWindowInDays ?keyState ?deletionDate ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Schedules the deletion of a KMS key. By default, KMS applies a waiting period of 30 days, but you can specify a waiting period of 7-30 days. When this operation is successful, the key state of the KMS key changes to PendingDeletion and the key can't be used in any cryptographic operations. It remains in this state for the duration of the waiting period. Before the waiting period ends, you can use CancelKeyDeletion to cancel the deletion of the KMS key. After the waiting period ends, KMS deletes the KMS key, its key material, and all KMS data associated with it, including all aliases that refer to it. Deleting a KMS key is a destructive and potentially dangerous operation. When a KMS key is deleted, all data that was encrypted under the KMS key is unrecoverable. (The only exception is a multi-Region replica key, or an asymmetric or HMAC KMS key with imported key material.) To prevent the use of a KMS key without deleting it, use DisableKey. You can schedule the deletion of a multi-Region primary key and its replica keys at any time. However, KMS will not delete a multi-Region primary key with existing replica keys. If you schedule the deletion of a primary key with replicas, its key state changes to PendingReplicaDeletion and it cannot be replicated or used in cryptographic operations. This status can continue indefinitely. When the last of its replicas keys is deleted (not just scheduled), the key state of the primary key changes to PendingDeletion and its waiting period (PendingWindowInDays) begins. For details, see Deleting multi-Region keys in the Key Management Service Developer Guide. When KMS deletes a KMS key from an CloudHSM key store, it makes a best effort to delete the associated key material from the associated CloudHSM cluster. However, you might need to manually delete the orphaned key material from the cluster and its backups. Deleting a KMS key from an external key store has no effect on the associated external key. However, for both types of custom key stores, deleting a KMS key is destructive and irreversible. You cannot decrypt ciphertext encrypted under the KMS key by using only its associated external key or CloudHSM key. Also, you cannot recreate a KMS key in an external key store by creating a new KMS key with the same key material. For more information about scheduling a KMS key for deletion, see Deleting KMS keys in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ScheduleKeyDeletion (key policy) Related operations CancelKeyDeletion DisableKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ScheduleKeyDeletionRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "The unique identifier of the KMS key to delete. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      pendingWindowInDays: PendingWindowInDaysType.t option
        [@ocaml.doc
          "The waiting period, specified in number of days. After the waiting period ends, KMS deletes the KMS key. If the KMS key is a multi-Region primary key with replica keys, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately. This value is optional. If you include a value, it must be between 7 and 30, inclusive. If you do not include a value, it defaults to 30. You can use the kms:ScheduleKeyDeletionPendingWindowInDays condition key to further constrain the values that principals can specify in the PendingWindowInDays parameter."]}
    let context_ = "ScheduleKeyDeletionRequest"
    let make ?pendingWindowInDays =
      fun ~keyId -> fun () -> { pendingWindowInDays; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("PendingWindowInDays",
          (Option.map x.pendingWindowInDays
             ~f:PendingWindowInDaysType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let pendingWindowInDays =
        (Option.map ~f:PendingWindowInDaysType.of_xml)
          (Xml.child xml_arg0 "PendingWindowInDays") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?pendingWindowInDays ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let pendingWindowInDays =
        field_map json__ "PendingWindowInDays"
          PendingWindowInDaysType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?pendingWindowInDays ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Schedules the deletion of a KMS key. By default, KMS applies a waiting period of 30 days, but you can specify a waiting period of 7-30 days. When this operation is successful, the key state of the KMS key changes to PendingDeletion and the key can't be used in any cryptographic operations. It remains in this state for the duration of the waiting period. Before the waiting period ends, you can use CancelKeyDeletion to cancel the deletion of the KMS key. After the waiting period ends, KMS deletes the KMS key, its key material, and all KMS data associated with it, including all aliases that refer to it. Deleting a KMS key is a destructive and potentially dangerous operation. When a KMS key is deleted, all data that was encrypted under the KMS key is unrecoverable. (The only exception is a multi-Region replica key, or an asymmetric or HMAC KMS key with imported key material.) To prevent the use of a KMS key without deleting it, use DisableKey. You can schedule the deletion of a multi-Region primary key and its replica keys at any time. However, KMS will not delete a multi-Region primary key with existing replica keys. If you schedule the deletion of a primary key with replicas, its key state changes to PendingReplicaDeletion and it cannot be replicated or used in cryptographic operations. This status can continue indefinitely. When the last of its replicas keys is deleted (not just scheduled), the key state of the primary key changes to PendingDeletion and its waiting period (PendingWindowInDays) begins. For details, see Deleting multi-Region keys in the Key Management Service Developer Guide. When KMS deletes a KMS key from an CloudHSM key store, it makes a best effort to delete the associated key material from the associated CloudHSM cluster. However, you might need to manually delete the orphaned key material from the cluster and its backups. Deleting a KMS key from an external key store has no effect on the associated external key. However, for both types of custom key stores, deleting a KMS key is destructive and irreversible. You cannot decrypt ciphertext encrypted under the KMS key by using only its associated external key or CloudHSM key. Also, you cannot recreate a KMS key in an external key store by creating a new KMS key with the same key material. For more information about scheduling a KMS key for deletion, see Deleting KMS keys in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ScheduleKeyDeletion (key policy) Related operations CancelKeyDeletion DisableKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module RotateKeyOnDemandResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "Identifies the symmetric encryption KMS key that you initiated on-demand rotation on."]}
    type nonrec error =
      [ `ConflictException of ConflictException.t 
      | `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId = fun () -> { keyId }
    let error_of_json name json =
      match name with
      | "ConflictException" ->
          `ConflictException (ConflictException.of_json json)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "ConflictException" ->
          `ConflictException (ConflictException.of_xml xml)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `ConflictException e ->
          `Assoc
            [("error", (`String "ConflictException"));
            ("details", (ConflictException.to_json e))]
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Immediately initiates rotation of the key material of the specified symmetric encryption KMS key. You can perform on-demand rotation of the key material in customer managed KMS keys, regardless of whether or not automatic key rotation is enabled. On-demand rotations do not change existing automatic rotation schedules. For example, consider a KMS key that has automatic key rotation enabled with a rotation period of 730 days. If the key is scheduled to automatically rotate on April 14, 2024, and you perform an on-demand rotation on April 10, 2024, the key will automatically rotate, as scheduled, on April 14, 2024 and every 730 days thereafter. You can perform on-demand key rotation a maximum of 25 times per KMS key. You can use the KMS console to view the number of remaining on-demand rotations available for a KMS key. You can use GetKeyRotationStatus to identify any in progress on-demand rotations. You can use ListKeyRotations to identify the date that completed on-demand rotations were performed. You can monitor rotation of the key material for your KMS keys in CloudTrail and Amazon CloudWatch. On-demand key rotation is supported only on symmetric encryption KMS keys. You cannot perform on-demand rotation of asymmetric KMS keys, HMAC KMS keys, or KMS keys in a custom key store. When you initiate on-demand key rotation on a symmetric encryption KMS key with imported key material, you must have already imported new key material and that key material's state should be PENDING_ROTATION. Use the ListKeyRotations operation to check the state of all key materials associated with a KMS key. To perform on-demand rotation of a set of related multi-Region keys, import new key material in the primary Region key, import the same key material in each replica Region key, and invoke the on-demand rotation on the primary Region key. You cannot initiate on-demand rotation of Amazon Web Services managed KMS keys. KMS always rotates the key material of Amazon Web Services managed keys every year. Rotation of Amazon Web Services owned KMS keys is managed by the Amazon Web Services service that owns the key. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:RotateKeyOnDemand (key policy) Related operations: EnableKeyRotation DisableKeyRotation GetKeyRotationStatus ImportKeyMaterial ListKeyRotations Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module RotateKeyOnDemandRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies a symmetric encryption KMS key. You cannot perform on-demand rotation of asymmetric KMS keys, HMAC KMS keys, multi-Region KMS keys with imported key material, or KMS keys in a custom key store. To perform on-demand rotation of a set of related multi-Region keys, invoke the on-demand rotation on the primary key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "RotateKeyOnDemandRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Immediately initiates rotation of the key material of the specified symmetric encryption KMS key. You can perform on-demand rotation of the key material in customer managed KMS keys, regardless of whether or not automatic key rotation is enabled. On-demand rotations do not change existing automatic rotation schedules. For example, consider a KMS key that has automatic key rotation enabled with a rotation period of 730 days. If the key is scheduled to automatically rotate on April 14, 2024, and you perform an on-demand rotation on April 10, 2024, the key will automatically rotate, as scheduled, on April 14, 2024 and every 730 days thereafter. You can perform on-demand key rotation a maximum of 25 times per KMS key. You can use the KMS console to view the number of remaining on-demand rotations available for a KMS key. You can use GetKeyRotationStatus to identify any in progress on-demand rotations. You can use ListKeyRotations to identify the date that completed on-demand rotations were performed. You can monitor rotation of the key material for your KMS keys in CloudTrail and Amazon CloudWatch. On-demand key rotation is supported only on symmetric encryption KMS keys. You cannot perform on-demand rotation of asymmetric KMS keys, HMAC KMS keys, or KMS keys in a custom key store. When you initiate on-demand key rotation on a symmetric encryption KMS key with imported key material, you must have already imported new key material and that key material's state should be PENDING_ROTATION. Use the ListKeyRotations operation to check the state of all key materials associated with a KMS key. To perform on-demand rotation of a set of related multi-Region keys, import new key material in the primary Region key, import the same key material in each replica Region key, and invoke the on-demand rotation on the primary Region key. You cannot initiate on-demand rotation of Amazon Web Services managed KMS keys. KMS always rotates the key material of Amazon Web Services managed keys every year. Rotation of Amazon Web Services owned KMS keys is managed by the Amazon Web Services service that owns the key. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:RotateKeyOnDemand (key policy) Related operations: EnableKeyRotation DisableKeyRotation GetKeyRotationStatus ImportKeyMaterial ListKeyRotations Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module RevokeGrantRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "A unique identifier for the KMS key associated with the grant. To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      grantId: GrantIdType.t
        [@ocaml.doc
          "Identifies the grant to revoke. To get the grant ID, use CreateGrant, ListGrants, or ListRetirableGrants."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "RevokeGrantRequest"
    let make ?dryRun =
      fun ~keyId -> fun ~grantId -> fun () -> { dryRun; keyId; grantId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("GrantId", (Some (GrantIdType.to_value x.grantId)));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantId =
        GrantIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "GrantId") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ~grantId ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantId = field_map_exn json__ "GrantId" GrantIdType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ~grantId ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes the specified grant. You revoke a grant to terminate the permissions that the grant allows. For more information, see Retiring and revoking grants in the Key Management Service Developer Guide . When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as eventual consistency. For details, see Eventual consistency in the Key Management Service Developer Guide . For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:RevokeGrant (key policy). Related operations: CreateGrant ListGrants ListRetirableGrants RetireGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module RetireGrantRequest =
  struct
    type nonrec t =
      {
      grantToken: GrantTokenType.t option
        [@ocaml.doc
          "Identifies the grant to be retired. You can use a grant token to identify a new grant even before it has achieved eventual consistency. Only the CreateGrant operation returns a grant token. For details, see Grant token and Eventual consistency in the Key Management Service Developer Guide."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The key ARN KMS key associated with the grant. To find the key ARN, use the ListKeys operation. For example: arn:aws:kms:us-east-2:444455556666:key/1234abcd-12ab-34cd-56ef-1234567890ab"];
      grantId: GrantIdType.t option
        [@ocaml.doc
          "Identifies the grant to retire. To get the grant ID, use CreateGrant, ListGrants, or ListRetirableGrants. Grant ID Example - 0123456789012345678901234567890123456789012345678901234567890123"];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let make ?grantToken =
      fun ?keyId ->
        fun ?grantId ->
          fun ?dryRun -> fun () -> { grantToken; keyId; grantId; dryRun }
    let to_value x =
      structure_to_value
        [("GrantToken", (Option.map x.grantToken ~f:GrantTokenType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("GrantId", (Option.map x.grantId ~f:GrantIdType.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantId =
        (Option.map ~f:GrantIdType.of_xml) (Xml.child xml_arg0 "GrantId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let grantToken =
        (Option.map ~f:GrantTokenType.of_xml)
          (Xml.child xml_arg0 "GrantToken") in
      make ?dryRun ?grantId ?keyId ?grantToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantId = field_map json__ "GrantId" GrantIdType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let grantToken = field_map json__ "GrantToken" GrantTokenType.of_json in
      make ?dryRun ?grantId ?keyId ?grantToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes a grant. Typically, you retire a grant when you no longer need its permissions. To identify the grant to retire, use a grant token, or both the grant ID and a key identifier (key ID or key ARN) of the KMS key. The CreateGrant operation returns both values. This operation can be called by the retiring principal for a grant, by the grantee principal if the grant allows the RetireGrant operation, and by the Amazon Web Services account in which the grant is created. It can also be called by principals to whom permission for retiring a grant is delegated. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. Cross-account use: Yes. You can retire a grant on a KMS key in a different Amazon Web Services account. Required permissions: Permission to retire a grant is determined primarily by the grant. For details, see Retiring and revoking grants in the Key Management Service Developer Guide. Related operations: CreateGrant ListGrants ListRetirableGrants RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ReplicateKeyResponse =
  struct
    type nonrec t =
      {
      replicaKeyMetadata: KeyMetadata.t option
        [@ocaml.doc
          "Displays details about the new replica key, including its Amazon Resource Name (key ARN) and Key states of KMS keys. It also includes the ARN and Amazon Web Services Region of its primary key and other replica keys."];
      replicaPolicy: PolicyType.t option
        [@ocaml.doc
          "The key policy of the new replica key. The value is a key policy document in JSON format."];
      replicaTags: TagList.t option
        [@ocaml.doc
          "The tags on the new replica key. The value is a list of tag key and tag value pairs."]}
    type nonrec error =
      [ `AlreadyExistsException of AlreadyExistsException.t 
      | `DisabledException of DisabledException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `MalformedPolicyDocumentException of
          MalformedPolicyDocumentException.t 
      | `NotFoundException of NotFoundException.t 
      | `TagException of TagException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?replicaKeyMetadata =
      fun ?replicaPolicy ->
        fun ?replicaTags ->
          fun () -> { replicaKeyMetadata; replicaPolicy; replicaTags }
    let error_of_json name json =
      match name with
      | "AlreadyExistsException" ->
          `AlreadyExistsException (AlreadyExistsException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "MalformedPolicyDocumentException" ->
          `MalformedPolicyDocumentException
            (MalformedPolicyDocumentException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "TagException" -> `TagException (TagException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "AlreadyExistsException" ->
          `AlreadyExistsException (AlreadyExistsException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "MalformedPolicyDocumentException" ->
          `MalformedPolicyDocumentException
            (MalformedPolicyDocumentException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "TagException" -> `TagException (TagException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `AlreadyExistsException e ->
          `Assoc
            [("error", (`String "AlreadyExistsException"));
            ("details", (AlreadyExistsException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `MalformedPolicyDocumentException e ->
          `Assoc
            [("error", (`String "MalformedPolicyDocumentException"));
            ("details", (MalformedPolicyDocumentException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `TagException e ->
          `Assoc
            [("error", (`String "TagException"));
            ("details", (TagException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("ReplicaKeyMetadata",
           (Option.map x.replicaKeyMetadata ~f:KeyMetadata.to_value));
        ("ReplicaPolicy",
          (Option.map x.replicaPolicy ~f:PolicyType.to_value));
        ("ReplicaTags", (Option.map x.replicaTags ~f:TagList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let replicaTags =
        (Option.map ~f:TagList.of_xml) (Xml.child xml_arg0 "ReplicaTags") in
      let replicaPolicy =
        (Option.map ~f:PolicyType.of_xml)
          (Xml.child xml_arg0 "ReplicaPolicy") in
      let replicaKeyMetadata =
        (Option.map ~f:KeyMetadata.of_xml)
          (Xml.child xml_arg0 "ReplicaKeyMetadata") in
      make ?replicaTags ?replicaPolicy ?replicaKeyMetadata ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let replicaTags = field_map json__ "ReplicaTags" TagList.of_json in
      let replicaPolicy = field_map json__ "ReplicaPolicy" PolicyType.of_json in
      let replicaKeyMetadata =
        field_map json__ "ReplicaKeyMetadata" KeyMetadata.of_json in
      make ?replicaTags ?replicaPolicy ?replicaKeyMetadata ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Replicates a multi-Region key into the specified Region. This operation creates a multi-Region replica key based on a multi-Region primary key in a different Region of the same Amazon Web Services partition. You can create multiple replicas of a primary key, but each must be in a different Region. To create a multi-Region primary key, use the CreateKey operation. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. A replica key is a fully-functional KMS key that can be used independently of its primary and peer replica keys. A primary key and its replica keys share properties that make them interoperable. They have the same key ID and key material. They also have the same key spec, key usage, key material origin, and automatic key rotation status. KMS automatically synchronizes these shared properties among related multi-Region keys. All other properties of a replica key can differ, including its key policy, tags, aliases, and key state. KMS pricing and quotas for KMS keys apply to each primary key and replica key. When this operation completes, the new replica key has a transient key state of Creating. This key state changes to Enabled (or PendingImport) after a few seconds when the process of creating the new replica key is complete. While the key state is Creating, you can manage key, but you cannot yet use it in cryptographic operations. If you are creating and using the replica key programmatically, retry on KMSInvalidStateException or call DescribeKey to check its KeyState value before using it. For details about the Creating key state, see Key states of KMS keys in the Key Management Service Developer Guide. You cannot create more than one replica of a primary key in any Region. If the Region already includes a replica of the key you're trying to replicate, ReplicateKey returns an AlreadyExistsException error. If the key state of the existing replica is PendingDeletion, you can cancel the scheduled key deletion (CancelKeyDeletion) or wait for the key to be deleted. The new replica key you create will have the same shared properties as the original replica key. The CloudTrail log of a ReplicateKey operation records a ReplicateKey operation in the primary key's Region and a CreateKey operation in the replica key's Region. If you replicate a multi-Region primary key with imported key material, the replica key is created with no key material. You must import the same key material that you imported into the primary key. To convert a replica key to a primary key, use the UpdatePrimaryRegion operation. ReplicateKey uses different default values for the KeyPolicy and Tags parameters than those used in the KMS console. For details, see the parameter descriptions. Cross-account use: No. You cannot use this operation to create a replica key in a different Amazon Web Services account. Required permissions: kms:ReplicateKey on the primary key (in the primary key's Region). Include this permission in the primary key's key policy. kms:CreateKey in an IAM policy in the replica Region. To use the Tags parameter, kms:TagResource in an IAM policy in the replica Region. Related operations CreateKey UpdatePrimaryRegion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ReplicateKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the multi-Region primary key that is being replicated. To determine whether a KMS key is a multi-Region primary key, use the DescribeKey operation to check the value of the MultiRegionKeyType property. Specify the key ID or key ARN of a multi-Region primary key. For example: Key ID: mrk-1234abcd12ab34cd56ef1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      replicaRegion: RegionType.t
        [@ocaml.doc
          "The Region ID of the Amazon Web Services Region for this replica key. Enter the Region ID, such as us-east-1 or ap-southeast-2. For a list of Amazon Web Services Regions in which KMS is supported, see KMS service endpoints in the Amazon Web Services General Reference. The replica must be in a different Amazon Web Services Region than its primary key and other replicas of that primary key, but in the same Amazon Web Services partition. KMS must be available in the replica Region. If the Region is not enabled by default, the Amazon Web Services account must be enabled in the Region. For information about Amazon Web Services partitions, see Amazon Resource Names (ARNs) in the Amazon Web Services General Reference. For information about enabling and disabling Regions, see Enabling a Region and Disabling a Region in the Amazon Web Services General Reference."];
      policy: PolicyType.t option
        [@ocaml.doc
          "The key policy to attach to the KMS key. This parameter is optional. If you do not provide a key policy, KMS attaches the default key policy to the KMS key. The key policy is not a shared property of multi-Region keys. You can specify the same key policy or a different key policy for each key in a set of related multi-Region keys. KMS does not synchronize this property. If you provide a key policy, it must meet the following criteria: The key policy must allow the calling principal to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the Key Management Service Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.) Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal, you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide. A key policy document can include only the following characters: Printable ASCII characters from the space character (\\u0020) through the end of the ASCII character range. Printable characters in the Basic Latin and Latin-1 Supplement character set (through \\u00FF). The tab (\\u0009), line feed (\\u000A), and carriage return (\\u000D) special characters For information about key policies, see Key policies in KMS in the Key Management Service Developer Guide. For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide ."];
      bypassPolicyLockoutSafetyCheck: BooleanType.t option
        [@ocaml.doc
          "Skips (\"bypasses\") the key policy lockout safety check. The default value is false. Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately. For more information, see Default key policy in the Key Management Service Developer Guide. Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key."];
      description: DescriptionType.t option
        [@ocaml.doc
          "A description of the KMS key. The default value is an empty string (no description). Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. The description is not a shared property of multi-Region keys. You can specify the same description or a different description for each key in a set of related multi-Region keys. KMS does not synchronize this property."];
      tags: TagList.t option
        [@ocaml.doc
          "Assigns one or more tags to the replica key. Use this parameter to tag the KMS key when it is created. To tag an existing KMS key, use the TagResource operation. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. To use this parameter, you must have kms:TagResource permission in an IAM policy. Tags are not a shared property of multi-Region keys. You can specify the same tags or different tags for each key in a set of related multi-Region keys. KMS does not synchronize this property. Each tag consists of a tag key and a tag value. Both the tag key and the tag value are required, but the tag value can be an empty (null) string. You cannot have more than one tag on a KMS key with the same tag key. If you specify an existing tag key with a different tag value, KMS replaces the current tag value with the specified one. When you add tags to an Amazon Web Services resource, Amazon Web Services generates a cost allocation report with usage and costs aggregated by tags. Tags can also be used to control access to a KMS key. For details, see Tags in KMS."]}
    let context_ = "ReplicateKeyRequest"
    let make ?policy =
      fun ?bypassPolicyLockoutSafetyCheck ->
        fun ?description ->
          fun ?tags ->
            fun ~keyId ->
              fun ~replicaRegion ->
                fun () ->
                  {
                    policy;
                    bypassPolicyLockoutSafetyCheck;
                    description;
                    tags;
                    keyId;
                    replicaRegion
                  }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("ReplicaRegion", (Some (RegionType.to_value x.replicaRegion)));
        ("Policy", (Option.map x.policy ~f:PolicyType.to_value));
        ("BypassPolicyLockoutSafetyCheck",
          (Option.map x.bypassPolicyLockoutSafetyCheck
             ~f:BooleanType.to_value));
        ("Description",
          (Option.map x.description ~f:DescriptionType.to_value));
        ("Tags", (Option.map x.tags ~f:TagList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let tags = (Option.map ~f:TagList.of_xml) (Xml.child xml_arg0 "Tags") in
      let description =
        (Option.map ~f:DescriptionType.of_xml)
          (Xml.child xml_arg0 "Description") in
      let bypassPolicyLockoutSafetyCheck =
        (Option.map ~f:BooleanType.of_xml)
          (Xml.child xml_arg0 "BypassPolicyLockoutSafetyCheck") in
      let policy =
        (Option.map ~f:PolicyType.of_xml) (Xml.child xml_arg0 "Policy") in
      let replicaRegion =
        RegionType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "ReplicaRegion") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?tags ?description ?bypassPolicyLockoutSafetyCheck ?policy
        ~replicaRegion ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let tags = field_map json__ "Tags" TagList.of_json in
      let description =
        field_map json__ "Description" DescriptionType.of_json in
      let bypassPolicyLockoutSafetyCheck =
        field_map json__ "BypassPolicyLockoutSafetyCheck" BooleanType.of_json in
      let policy = field_map json__ "Policy" PolicyType.of_json in
      let replicaRegion =
        field_map_exn json__ "ReplicaRegion" RegionType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?tags ?description ?bypassPolicyLockoutSafetyCheck ?policy
        ~replicaRegion ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Replicates a multi-Region key into the specified Region. This operation creates a multi-Region replica key based on a multi-Region primary key in a different Region of the same Amazon Web Services partition. You can create multiple replicas of a primary key, but each must be in a different Region. To create a multi-Region primary key, use the CreateKey operation. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. A replica key is a fully-functional KMS key that can be used independently of its primary and peer replica keys. A primary key and its replica keys share properties that make them interoperable. They have the same key ID and key material. They also have the same key spec, key usage, key material origin, and automatic key rotation status. KMS automatically synchronizes these shared properties among related multi-Region keys. All other properties of a replica key can differ, including its key policy, tags, aliases, and key state. KMS pricing and quotas for KMS keys apply to each primary key and replica key. When this operation completes, the new replica key has a transient key state of Creating. This key state changes to Enabled (or PendingImport) after a few seconds when the process of creating the new replica key is complete. While the key state is Creating, you can manage key, but you cannot yet use it in cryptographic operations. If you are creating and using the replica key programmatically, retry on KMSInvalidStateException or call DescribeKey to check its KeyState value before using it. For details about the Creating key state, see Key states of KMS keys in the Key Management Service Developer Guide. You cannot create more than one replica of a primary key in any Region. If the Region already includes a replica of the key you're trying to replicate, ReplicateKey returns an AlreadyExistsException error. If the key state of the existing replica is PendingDeletion, you can cancel the scheduled key deletion (CancelKeyDeletion) or wait for the key to be deleted. The new replica key you create will have the same shared properties as the original replica key. The CloudTrail log of a ReplicateKey operation records a ReplicateKey operation in the primary key's Region and a CreateKey operation in the replica key's Region. If you replicate a multi-Region primary key with imported key material, the replica key is created with no key material. You must import the same key material that you imported into the primary key. To convert a replica key to a primary key, use the UpdatePrimaryRegion operation. ReplicateKey uses different default values for the KeyPolicy and Tags parameters than those used in the KMS console. For details, see the parameter descriptions. Cross-account use: No. You cannot use this operation to create a replica key in a different Amazon Web Services account. Required permissions: kms:ReplicateKey on the primary key (in the primary key's Region). Include this permission in the primary key's key policy. kms:CreateKey in an IAM policy in the replica Region. To use the Tags parameter, kms:TagResource in an IAM policy in the replica Region. Related operations CreateKey UpdatePrimaryRegion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ReEncryptResponse =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The reencrypted data. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      sourceKeyId: KeyIdType.t option
        [@ocaml.doc
          "Unique identifier of the KMS key used to originally encrypt the data."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that was used to reencrypt the data."];
      sourceEncryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "The encryption algorithm that was used to decrypt the ciphertext before it was reencrypted."];
      destinationEncryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "The encryption algorithm that was used to reencrypt the data."];
      sourceKeyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to originally encrypt the data. This field is present only when the original encryption used a symmetric encryption KMS key."];
      destinationKeyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to reencrypt the data. This field is present only when data is reencrypted using a symmetric encryption KMS key."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `IncorrectKeyException of IncorrectKeyException.t 
      | `InvalidCiphertextException of InvalidCiphertextException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?ciphertextBlob =
      fun ?sourceKeyId ->
        fun ?keyId ->
          fun ?sourceEncryptionAlgorithm ->
            fun ?destinationEncryptionAlgorithm ->
              fun ?sourceKeyMaterialId ->
                fun ?destinationKeyMaterialId ->
                  fun () ->
                    {
                      ciphertextBlob;
                      sourceKeyId;
                      keyId;
                      sourceEncryptionAlgorithm;
                      destinationEncryptionAlgorithm;
                      sourceKeyMaterialId;
                      destinationKeyMaterialId
                    }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "IncorrectKeyException" ->
          `IncorrectKeyException (IncorrectKeyException.of_json json)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException
            (InvalidCiphertextException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "IncorrectKeyException" ->
          `IncorrectKeyException (IncorrectKeyException.of_xml xml)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException (InvalidCiphertextException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `IncorrectKeyException e ->
          `Assoc
            [("error", (`String "IncorrectKeyException"));
            ("details", (IncorrectKeyException.to_json e))]
      | `InvalidCiphertextException e ->
          `Assoc
            [("error", (`String "InvalidCiphertextException"));
            ("details", (InvalidCiphertextException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("SourceKeyId", (Option.map x.sourceKeyId ~f:KeyIdType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("SourceEncryptionAlgorithm",
          (Option.map x.sourceEncryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("DestinationEncryptionAlgorithm",
          (Option.map x.destinationEncryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("SourceKeyMaterialId",
          (Option.map x.sourceKeyMaterialId ~f:BackingKeyIdType.to_value));
        ("DestinationKeyMaterialId",
          (Option.map x.destinationKeyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let destinationKeyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "DestinationKeyMaterialId") in
      let sourceKeyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "SourceKeyMaterialId") in
      let destinationEncryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "DestinationEncryptionAlgorithm") in
      let sourceEncryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "SourceEncryptionAlgorithm") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let sourceKeyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "SourceKeyId") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?destinationKeyMaterialId ?sourceKeyMaterialId
        ?destinationEncryptionAlgorithm ?sourceEncryptionAlgorithm ?keyId
        ?sourceKeyId ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let destinationKeyMaterialId =
        field_map json__ "DestinationKeyMaterialId" BackingKeyIdType.of_json in
      let sourceKeyMaterialId =
        field_map json__ "SourceKeyMaterialId" BackingKeyIdType.of_json in
      let destinationEncryptionAlgorithm =
        field_map json__ "DestinationEncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let sourceEncryptionAlgorithm =
        field_map json__ "SourceEncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let sourceKeyId = field_map json__ "SourceKeyId" KeyIdType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?destinationKeyMaterialId ?sourceKeyMaterialId
        ?destinationEncryptionAlgorithm ?sourceEncryptionAlgorithm ?keyId
        ?sourceKeyId ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Decrypts ciphertext and then reencrypts it entirely within KMS. You can use this operation to change the KMS key under which data is encrypted, such as when you manually rotate a KMS key or change the KMS key that protects a ciphertext. You can also use it to reencrypt ciphertext under the same KMS key, such as to change the encryption context of a ciphertext. The ReEncrypt operation can decrypt ciphertext that was encrypted by using a KMS key in an KMS operation, such as Encrypt or GenerateDataKey. It can also decrypt ciphertext that was encrypted by using the public key of an asymmetric KMS key outside of KMS. However, it cannot decrypt ciphertext produced by other libraries, such as the Amazon Web Services Encryption SDK or Amazon S3 client-side encryption. These libraries return a ciphertext format that is incompatible with KMS. When you use the ReEncrypt operation, you need to provide information for the decrypt operation and the subsequent encrypt operation. If your ciphertext was encrypted under an asymmetric KMS key, you must use the SourceKeyId parameter to identify the KMS key that encrypted the ciphertext. You must also supply the encryption algorithm that was used. This information is required to decrypt the data. If your ciphertext was encrypted under a symmetric encryption KMS key, the SourceKeyId parameter is optional. KMS can get this information from metadata that it adds to the symmetric ciphertext blob. This feature adds durability to your implementation by ensuring that authorized users can decrypt ciphertext decades after it was encrypted, even if they've lost track of the key ID. However, specifying the source KMS key is always recommended as a best practice. When you use the SourceKeyId parameter to specify a KMS key, KMS uses only the KMS key you specify. If the ciphertext was encrypted under a different KMS key, the ReEncrypt operation fails. This practice ensures that you use the KMS key that you intend. To reencrypt the data, you must use the DestinationKeyId parameter to specify the KMS key that re-encrypts the data after it is decrypted. If the destination KMS key is an asymmetric KMS key, you must also provide the encryption algorithm. The algorithm that you choose must be compatible with the KMS key. When you use an asymmetric KMS key to encrypt or reencrypt data, be sure to record the KMS key and encryption algorithm that you choose. You will be required to provide the same KMS key and encryption algorithm when you decrypt the data. If the KMS key and algorithm do not match the values used to encrypt the data, the decrypt operation fails. You are not required to supply the key ID and encryption algorithm when you decrypt with symmetric encryption KMS keys because KMS stores this information in the ciphertext blob. KMS cannot store metadata in ciphertext generated with asymmetric keys. The standard format for asymmetric key ciphertext does not include configurable fields. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. The source KMS key and destination KMS key can be in different Amazon Web Services accounts. Either or both KMS keys can be in a different account than the caller. To specify a KMS key in a different account, use the key ARN or alias ARN. A short key ID is also acceptable for the source key when decrypting symmetric ciphertexts, though using a full key ARN is recommended to be more explicit about the intended KMS key. Required permissions: kms:ReEncryptFrom permission on the source KMS key (key policy) kms:ReEncryptTo permission on the destination KMS key (key policy) To permit reencryption from or to a KMS key, include the \"kms:ReEncrypt*\" permission in your key policy. This permission is automatically included in the key policy when you use the console to create a KMS key. But you must include it manually when you create a KMS key programmatically or when you use the PutKeyPolicy operation to set a key policy. Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ReEncryptRequest =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "Ciphertext of the data to reencrypt. This parameter is required in all cases except when DryRun is true and DryRunModifiers is set to IGNORE_CIPHERTEXT."];
      sourceEncryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context to use to decrypt the ciphertext. Enter the same encryption context that was used to encrypt the ciphertext. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      sourceKeyId: KeyIdType.t option
        [@ocaml.doc
          "Specifies the KMS key that KMS will use to decrypt the ciphertext before it is re-encrypted. Enter a key ID of the KMS key that was used to encrypt the ciphertext. If you identify a different KMS key, the ReEncrypt operation throws an IncorrectKeyException. This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key or when DryRun is true and DryRunModifiers is set to IGNORE_CIPHERTEXT. If you used a symmetric encryption KMS key, KMS can get the KMS key from metadata that it adds to the symmetric ciphertext blob. However, it is always recommended as a best practice. This practice ensures that you use the KMS key that you intend. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you should use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      destinationKeyId: KeyIdType.t
        [@ocaml.doc
          "A unique identifier for the KMS key that is used to reencrypt the data. Specify a symmetric encryption KMS key or an asymmetric KMS key with a KeyUsage value of ENCRYPT_DECRYPT. To find the KeyUsage value of a KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      destinationEncryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies that encryption context to use when the reencrypting the data. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. A destination encryption context is valid only when the destination KMS key is a symmetric encryption KMS key. The standard ciphertext format for asymmetric KMS keys does not include fields for metadata. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      sourceEncryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "Specifies the encryption algorithm that KMS will use to decrypt the ciphertext before it is reencrypted. The default value, SYMMETRIC_DEFAULT, represents the algorithm used for symmetric encryption KMS keys. Specify the same algorithm that was used to encrypt the ciphertext. If you specify a different algorithm, the decrypt attempt fails. This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key."];
      destinationEncryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "Specifies the encryption algorithm that KMS will use to reecrypt the data after it has decrypted it. The default value, SYMMETRIC_DEFAULT, represents the encryption algorithm used for symmetric encryption KMS keys. This parameter is required only when the destination KMS key is an asymmetric KMS key."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."];
      dryRunModifiers: DryRunModifierList.t option
        [@ocaml.doc
          "Specifies the modifiers to apply to the dry run operation. DryRunModifiers is an optional parameter that only applies when DryRun is set to true. When set to IGNORE_CIPHERTEXT, KMS performs only authorization validation without ciphertext validation. This allows you to test permissions without requiring a valid ciphertext blob. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "ReEncryptRequest"
    let make ?ciphertextBlob =
      fun ?sourceEncryptionContext ->
        fun ?sourceKeyId ->
          fun ?destinationEncryptionContext ->
            fun ?sourceEncryptionAlgorithm ->
              fun ?destinationEncryptionAlgorithm ->
                fun ?grantTokens ->
                  fun ?dryRun ->
                    fun ?dryRunModifiers ->
                      fun ~destinationKeyId ->
                        fun () ->
                          {
                            ciphertextBlob;
                            sourceEncryptionContext;
                            sourceKeyId;
                            destinationEncryptionContext;
                            sourceEncryptionAlgorithm;
                            destinationEncryptionAlgorithm;
                            grantTokens;
                            dryRun;
                            dryRunModifiers;
                            destinationKeyId
                          }
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("SourceEncryptionContext",
          (Option.map x.sourceEncryptionContext
             ~f:EncryptionContextType.to_value));
        ("SourceKeyId", (Option.map x.sourceKeyId ~f:KeyIdType.to_value));
        ("DestinationKeyId", (Some (KeyIdType.to_value x.destinationKeyId)));
        ("DestinationEncryptionContext",
          (Option.map x.destinationEncryptionContext
             ~f:EncryptionContextType.to_value));
        ("SourceEncryptionAlgorithm",
          (Option.map x.sourceEncryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("DestinationEncryptionAlgorithm",
          (Option.map x.destinationEncryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value));
        ("DryRunModifiers",
          (Option.map x.dryRunModifiers ~f:DryRunModifierList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRunModifiers =
        (Option.map ~f:DryRunModifierList.of_xml)
          (Xml.child xml_arg0 "DryRunModifiers") in
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let destinationEncryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "DestinationEncryptionAlgorithm") in
      let sourceEncryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "SourceEncryptionAlgorithm") in
      let destinationEncryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "DestinationEncryptionContext") in
      let destinationKeyId =
        KeyIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "DestinationKeyId") in
      let sourceKeyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "SourceKeyId") in
      let sourceEncryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "SourceEncryptionContext") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?dryRunModifiers ?dryRun ?grantTokens
        ?destinationEncryptionAlgorithm ?sourceEncryptionAlgorithm
        ?destinationEncryptionContext ~destinationKeyId ?sourceKeyId
        ?sourceEncryptionContext ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRunModifiers =
        field_map json__ "DryRunModifiers" DryRunModifierList.of_json in
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let destinationEncryptionAlgorithm =
        field_map json__ "DestinationEncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let sourceEncryptionAlgorithm =
        field_map json__ "SourceEncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let destinationEncryptionContext =
        field_map json__ "DestinationEncryptionContext"
          EncryptionContextType.of_json in
      let destinationKeyId =
        field_map_exn json__ "DestinationKeyId" KeyIdType.of_json in
      let sourceKeyId = field_map json__ "SourceKeyId" KeyIdType.of_json in
      let sourceEncryptionContext =
        field_map json__ "SourceEncryptionContext"
          EncryptionContextType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?dryRunModifiers ?dryRun ?grantTokens
        ?destinationEncryptionAlgorithm ?sourceEncryptionAlgorithm
        ?destinationEncryptionContext ~destinationKeyId ?sourceKeyId
        ?sourceEncryptionContext ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Decrypts ciphertext and then reencrypts it entirely within KMS. You can use this operation to change the KMS key under which data is encrypted, such as when you manually rotate a KMS key or change the KMS key that protects a ciphertext. You can also use it to reencrypt ciphertext under the same KMS key, such as to change the encryption context of a ciphertext. The ReEncrypt operation can decrypt ciphertext that was encrypted by using a KMS key in an KMS operation, such as Encrypt or GenerateDataKey. It can also decrypt ciphertext that was encrypted by using the public key of an asymmetric KMS key outside of KMS. However, it cannot decrypt ciphertext produced by other libraries, such as the Amazon Web Services Encryption SDK or Amazon S3 client-side encryption. These libraries return a ciphertext format that is incompatible with KMS. When you use the ReEncrypt operation, you need to provide information for the decrypt operation and the subsequent encrypt operation. If your ciphertext was encrypted under an asymmetric KMS key, you must use the SourceKeyId parameter to identify the KMS key that encrypted the ciphertext. You must also supply the encryption algorithm that was used. This information is required to decrypt the data. If your ciphertext was encrypted under a symmetric encryption KMS key, the SourceKeyId parameter is optional. KMS can get this information from metadata that it adds to the symmetric ciphertext blob. This feature adds durability to your implementation by ensuring that authorized users can decrypt ciphertext decades after it was encrypted, even if they've lost track of the key ID. However, specifying the source KMS key is always recommended as a best practice. When you use the SourceKeyId parameter to specify a KMS key, KMS uses only the KMS key you specify. If the ciphertext was encrypted under a different KMS key, the ReEncrypt operation fails. This practice ensures that you use the KMS key that you intend. To reencrypt the data, you must use the DestinationKeyId parameter to specify the KMS key that re-encrypts the data after it is decrypted. If the destination KMS key is an asymmetric KMS key, you must also provide the encryption algorithm. The algorithm that you choose must be compatible with the KMS key. When you use an asymmetric KMS key to encrypt or reencrypt data, be sure to record the KMS key and encryption algorithm that you choose. You will be required to provide the same KMS key and encryption algorithm when you decrypt the data. If the KMS key and algorithm do not match the values used to encrypt the data, the decrypt operation fails. You are not required to supply the key ID and encryption algorithm when you decrypt with symmetric encryption KMS keys because KMS stores this information in the ciphertext blob. KMS cannot store metadata in ciphertext generated with asymmetric keys. The standard format for asymmetric key ciphertext does not include configurable fields. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. The source KMS key and destination KMS key can be in different Amazon Web Services accounts. Either or both KMS keys can be in a different account than the caller. To specify a KMS key in a different account, use the key ARN or alias ARN. A short key ID is also acceptable for the source key when decrypting symmetric ciphertexts, though using a full key ARN is recommended to be more explicit about the intended KMS key. Required permissions: kms:ReEncryptFrom permission on the source KMS key (key policy) kms:ReEncryptTo permission on the destination KMS key (key policy) To permit reencryption from or to a KMS key, include the \"kms:ReEncrypt*\" permission in your key policy. This permission is automatically included in the key policy when you use the console to create a KMS key. But you must include it manually when you create a KMS key programmatically or when you use the PutKeyPolicy operation to set a key policy. Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module PutKeyPolicyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Sets the key policy on the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      policyName: PolicyNameType.t option
        [@ocaml.doc
          "The name of the key policy. If no policy name is specified, the default value is default. The only valid value is default."];
      policy: PolicyType.t
        [@ocaml.doc
          "The key policy to attach to the KMS key. The key policy must meet the following criteria: The key policy must allow the calling principal to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the Key Management Service Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.) Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal, you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide. If either of the required Resource or Action elements are missing from a key policy statement, the policy statement has no effect. When a key policy statement is missing one of these elements, the KMS console correctly reports an error, but the PutKeyPolicy API request succeeds, even though the policy statement is ineffective. For more information on required key policy elements, see Elements in a key policy in the Key Management Service Developer Guide. A key policy document can include only the following characters: Printable ASCII characters from the space character (\\u0020) through the end of the ASCII character range. Printable characters in the Basic Latin and Latin-1 Supplement character set (through \\u00FF). The tab (\\u0009), line feed (\\u000A), and carriage return (\\u000D) special characters If the key policy exceeds the length constraint, KMS returns a LimitExceededException. For information about key policies, see Key policies in KMS in the Key Management Service Developer Guide.For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide ."];
      bypassPolicyLockoutSafetyCheck: BooleanType.t option
        [@ocaml.doc
          "Skips (\"bypasses\") the key policy lockout safety check. The default value is false. Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately. For more information, see Default key policy in the Key Management Service Developer Guide. Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key."]}
    let context_ = "PutKeyPolicyRequest"
    let make ?policyName =
      fun ?bypassPolicyLockoutSafetyCheck ->
        fun ~keyId ->
          fun ~policy ->
            fun () ->
              { policyName; bypassPolicyLockoutSafetyCheck; keyId; policy }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("PolicyName", (Option.map x.policyName ~f:PolicyNameType.to_value));
        ("Policy", (Some (PolicyType.to_value x.policy)));
        ("BypassPolicyLockoutSafetyCheck",
          (Option.map x.bypassPolicyLockoutSafetyCheck
             ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let bypassPolicyLockoutSafetyCheck =
        (Option.map ~f:BooleanType.of_xml)
          (Xml.child xml_arg0 "BypassPolicyLockoutSafetyCheck") in
      let policy =
        PolicyType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "Policy") in
      let policyName =
        (Option.map ~f:PolicyNameType.of_xml)
          (Xml.child xml_arg0 "PolicyName") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?bypassPolicyLockoutSafetyCheck ~policy ?policyName ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let bypassPolicyLockoutSafetyCheck =
        field_map json__ "BypassPolicyLockoutSafetyCheck" BooleanType.of_json in
      let policy = field_map_exn json__ "Policy" PolicyType.of_json in
      let policyName = field_map json__ "PolicyName" PolicyNameType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?bypassPolicyLockoutSafetyCheck ~policy ?policyName ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Attaches a key policy to the specified KMS key. For more information about key policies, see Key Policies in the Key Management Service Developer Guide. For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide . For examples of adding a key policy in multiple programming languages, see Use PutKeyPolicy with an Amazon Web Services SDK or CLI in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:PutKeyPolicy (key policy) Related operations: GetKeyPolicy Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListRetirableGrantsRequest =
  struct
    type nonrec t =
      {
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."];
      retiringPrincipal: PrincipalIdType.t
        [@ocaml.doc
          "The retiring principal for which to list grants. Enter a principal in your Amazon Web Services account. To specify the retiring principal, use the Amazon Resource Name (ARN) of an Amazon Web Services principal. Valid principals include Amazon Web Services accounts, IAM users, IAM roles, federated users, and assumed role users. For help with the ARN syntax for a principal, see IAM ARNs in the Identity and Access Management User Guide ."]}
    let context_ = "ListRetirableGrantsRequest"
    let make ?limit =
      fun ?marker ->
        fun ~retiringPrincipal ->
          fun () -> { limit; marker; retiringPrincipal }
    let to_value x =
      structure_to_value
        [("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value));
        ("RetiringPrincipal",
          (Some (PrincipalIdType.to_value x.retiringPrincipal)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let retiringPrincipal =
        PrincipalIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "RetiringPrincipal") in
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      make ~retiringPrincipal ?marker ?limit ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let retiringPrincipal =
        field_map_exn json__ "RetiringPrincipal" PrincipalIdType.of_json in
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      make ~retiringPrincipal ?marker ?limit ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns information about all grants in the Amazon Web Services account and Region that have the specified retiring principal. You can specify any principal in your Amazon Web Services account. The grants that are returned include grants for KMS keys in your Amazon Web Services account and other Amazon Web Services accounts. You might use this operation to determine which grants you may retire. To retire a grant, use the RetireGrant operation. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. Cross-account use: You must specify a principal in your Amazon Web Services account. This operation returns a list of grants where the retiring principal specified in the ListRetirableGrants request is the same retiring principal on the grant. This can include grants on KMS keys owned by other Amazon Web Services accounts, but you do not need kms:ListRetirableGrants permission (or any other additional permission) in any Amazon Web Services account other than your own. Required permissions: kms:ListRetirableGrants (IAM policy) in your Amazon Web Services account. KMS authorizes ListRetirableGrants requests by evaluating the caller account's kms:ListRetirableGrants permissions. The authorized resource in ListRetirableGrants calls is the retiring principal specified in the request. KMS does not evaluate the caller's permissions to verify their access to any KMS keys or grants that might be returned by the ListRetirableGrants call. Related operations: CreateGrant ListGrants RetireGrant RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListResourceTagsResponse =
  struct
    type nonrec t =
      {
      tags: TagList.t option
        [@ocaml.doc
          "A list of tags. Each tag consists of a tag key and a tag value. Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request. Do not assume or infer any information from this value."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `InvalidArnException of InvalidArnException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?tags =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { tags; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Tags", (Option.map x.tags ~f:TagList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let tags = (Option.map ~f:TagList.of_xml) (Xml.child xml_arg0 "Tags") in
      make ?truncated ?nextMarker ?tags ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let tags = field_map json__ "Tags" TagList.of_json in
      make ?truncated ?nextMarker ?tags ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns all tags on the specified KMS key. For general information about tags, including the format and syntax, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference. For information about using tags in KMS, see Tags in KMS. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListResourceTags (key policy) Related operations: CreateKey ReplicateKey TagResource UntagResource Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListResourceTagsRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Gets tags on the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 50, inclusive. If you do not include a value, it defaults to 50."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received. Do not attempt to construct this value. Use only the value of NextMarker from the truncated response you just received."]}
    let context_ = "ListResourceTagsRequest"
    let make ?limit =
      fun ?marker -> fun ~keyId -> fun () -> { limit; marker; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?marker ?limit ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?marker ?limit ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns all tags on the specified KMS key. For general information about tags, including the format and syntax, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference. For information about using tags in KMS, see Tags in KMS. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListResourceTags (key policy) Related operations: CreateKey ReplicateKey TagResource UntagResource Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeysResponse =
  struct
    type nonrec t =
      {
      keys: KeyList.t option [@ocaml.doc "A list of KMS keys."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keys =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { keys; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Keys", (Option.map x.keys ~f:KeyList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let keys = (Option.map ~f:KeyList.of_xml) (Xml.child xml_arg0 "Keys") in
      make ?truncated ?nextMarker ?keys ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let keys = field_map json__ "Keys" KeyList.of_json in
      make ?truncated ?nextMarker ?keys ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of all KMS keys in the caller's Amazon Web Services account and Region. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeys (IAM policy) Related operations: CreateKey DescribeKey ListAliases ListResourceTags Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeysRequest =
  struct
    type nonrec t =
      {
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."]}
    let make ?limit = fun ?marker -> fun () -> { limit; marker }
    let to_value x =
      structure_to_value
        [("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      make ?marker ?limit ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      make ?marker ?limit ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of all KMS keys in the caller's Amazon Web Services account and Region. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeys (IAM policy) Related operations: CreateKey DescribeKey ListAliases ListResourceTags Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeyRotationsResponse =
  struct
    type nonrec t =
      {
      rotations: RotationsList.t option
        [@ocaml.doc
          "A list of completed key material rotations. When the optional input parameter IncludeKeyMaterial is specified with a value of ALL_KEY_MATERIAL, this list includes the first key material and any imported key material pending rotation."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `InvalidArnException of InvalidArnException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?rotations =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { rotations; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Rotations", (Option.map x.rotations ~f:RotationsList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let rotations =
        (Option.map ~f:RotationsList.of_xml) (Xml.child xml_arg0 "Rotations") in
      make ?truncated ?nextMarker ?rotations ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let rotations = field_map json__ "Rotations" RotationsList.of_json in
      make ?truncated ?nextMarker ?rotations ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns information about the key materials associated with the specified KMS key. You can use the optional IncludeKeyMaterial parameter to control which key materials are included in the response. You must specify the KMS key in all requests. You can refine the key rotations list by limiting the number of rotations returned. For detailed information about automatic and on-demand key rotations, see Rotate KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeyRotations (key policy) Related operations: EnableKeyRotation DeleteImportedKeyMaterial DisableKeyRotation GetKeyRotationStatus ImportKeyMaterial RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeyRotationsRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Gets the key rotations for the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      includeKeyMaterial: IncludeKeyMaterial.t option
        [@ocaml.doc
          "Use this optional parameter to control which key materials associated with this key are listed in the response. The default value of this parameter is ROTATIONS_ONLY. If you omit this parameter, KMS returns information on the key materials created by automatic or on-demand key rotation. When you specify a value of ALL_KEY_MATERIAL, KMS adds the first key material and any imported key material pending rotation to the response. This parameter can only be used with KMS keys that support automatic or on-demand key rotation."];
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."]}
    let context_ = "ListKeyRotationsRequest"
    let make ?includeKeyMaterial =
      fun ?limit ->
        fun ?marker ->
          fun ~keyId ->
            fun () -> { includeKeyMaterial; limit; marker; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("IncludeKeyMaterial",
          (Option.map x.includeKeyMaterial ~f:IncludeKeyMaterial.to_value));
        ("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      let includeKeyMaterial =
        (Option.map ~f:IncludeKeyMaterial.of_xml)
          (Xml.child xml_arg0 "IncludeKeyMaterial") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?marker ?limit ?includeKeyMaterial ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      let includeKeyMaterial =
        field_map json__ "IncludeKeyMaterial" IncludeKeyMaterial.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?marker ?limit ?includeKeyMaterial ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns information about the key materials associated with the specified KMS key. You can use the optional IncludeKeyMaterial parameter to control which key materials are included in the response. You must specify the KMS key in all requests. You can refine the key rotations list by limiting the number of rotations returned. For detailed information about automatic and on-demand key rotations, see Rotate KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeyRotations (key policy) Related operations: EnableKeyRotation DeleteImportedKeyMaterial DisableKeyRotation GetKeyRotationStatus ImportKeyMaterial RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeyPoliciesResponse =
  struct
    type nonrec t =
      {
      policyNames: PolicyNameList.t option
        [@ocaml.doc
          "A list of key policy names. The only valid value is default."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?policyNames =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { policyNames; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("PolicyNames",
           (Option.map x.policyNames ~f:PolicyNameList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let policyNames =
        (Option.map ~f:PolicyNameList.of_xml)
          (Xml.child xml_arg0 "PolicyNames") in
      make ?truncated ?nextMarker ?policyNames ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let policyNames = field_map json__ "PolicyNames" PolicyNameList.of_json in
      make ?truncated ?nextMarker ?policyNames ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets the names of the key policies that are attached to a KMS key. This operation is designed to get policy names that you can use in a GetKeyPolicy operation. However, the only valid policy name is default. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeyPolicies (key policy) Related operations: GetKeyPolicy PutKeyPolicy Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListKeyPoliciesRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Gets the names of key policies for the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100. Only one policy can be attached to a key."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."]}
    let context_ = "ListKeyPoliciesRequest"
    let make ?limit =
      fun ?marker -> fun ~keyId -> fun () -> { limit; marker; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?marker ?limit ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?marker ?limit ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets the names of the key policies that are attached to a KMS key. This operation is designed to get policy names that you can use in a GetKeyPolicy operation. However, the only valid policy name is default. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ListKeyPolicies (key policy) Related operations: GetKeyPolicy PutKeyPolicy Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListGrantsResponse =
  struct
    type nonrec t =
      {
      grants: GrantList.t option [@ocaml.doc "A list of grants."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `InvalidGrantIdException of InvalidGrantIdException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?grants =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { grants; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidGrantIdException" ->
          `InvalidGrantIdException (InvalidGrantIdException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidGrantIdException" ->
          `InvalidGrantIdException (InvalidGrantIdException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidGrantIdException e ->
          `Assoc
            [("error", (`String "InvalidGrantIdException"));
            ("details", (InvalidGrantIdException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Grants", (Option.map x.grants ~f:GrantList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let grants =
        (Option.map ~f:GrantList.of_xml) (Xml.child xml_arg0 "Grants") in
      make ?truncated ?nextMarker ?grants ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let grants = field_map json__ "Grants" GrantList.of_json in
      make ?truncated ?nextMarker ?grants ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of all grants for the specified KMS key. You must specify the KMS key in all requests. You can filter the grant list by grant ID or grantee principal. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. The GranteePrincipal field in the ListGrants response usually contains the user or role designated as the grantee principal in the grant. However, when the grantee principal in the grant is an Amazon Web Services service, the GranteePrincipal field contains the service principal, which might represent several different grantee principals. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:ListGrants (key policy) Related operations: CreateGrant ListRetirableGrants RetireGrant RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListGrantsRequest =
  struct
    type nonrec t =
      {
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."];
      keyId: KeyIdType.t
        [@ocaml.doc
          "Returns only grants for the specified KMS key. This parameter is required. Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      grantId: GrantIdType.t option
        [@ocaml.doc
          "Returns only the grant with the specified grant ID. The grant ID uniquely identifies the grant."];
      granteePrincipal: PrincipalIdType.t option
        [@ocaml.doc
          "Returns only grants where the specified principal is the grantee principal for the grant."]}
    let context_ = "ListGrantsRequest"
    let make ?limit =
      fun ?marker ->
        fun ?grantId ->
          fun ?granteePrincipal ->
            fun ~keyId ->
              fun () -> { limit; marker; grantId; granteePrincipal; keyId }
    let to_value x =
      structure_to_value
        [("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value));
        ("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("GrantId", (Option.map x.grantId ~f:GrantIdType.to_value));
        ("GranteePrincipal",
          (Option.map x.granteePrincipal ~f:PrincipalIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let granteePrincipal =
        (Option.map ~f:PrincipalIdType.of_xml)
          (Xml.child xml_arg0 "GranteePrincipal") in
      let grantId =
        (Option.map ~f:GrantIdType.of_xml) (Xml.child xml_arg0 "GrantId") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      make ?granteePrincipal ?grantId ~keyId ?marker ?limit ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let granteePrincipal =
        field_map json__ "GranteePrincipal" PrincipalIdType.of_json in
      let grantId = field_map json__ "GrantId" GrantIdType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      make ?granteePrincipal ?grantId ~keyId ?marker ?limit ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of all grants for the specified KMS key. You must specify the KMS key in all requests. You can filter the grant list by grant ID or grantee principal. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. The GranteePrincipal field in the ListGrants response usually contains the user or role designated as the grantee principal in the grant. However, when the grantee principal in the grant is an Amazon Web Services service, the GranteePrincipal field contains the service principal, which might represent several different grantee principals. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:ListGrants (key policy) Related operations: CreateGrant ListRetirableGrants RetireGrant RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListAliasesResponse =
  struct
    type nonrec t =
      {
      aliases: AliasList.t option [@ocaml.doc "A list of aliases."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?aliases =
      fun ?nextMarker ->
        fun ?truncated -> fun () -> { aliases; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Aliases", (Option.map x.aliases ~f:AliasList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let aliases =
        (Option.map ~f:AliasList.of_xml) (Xml.child xml_arg0 "Aliases") in
      make ?truncated ?nextMarker ?aliases ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let aliases = field_map json__ "Aliases" AliasList.of_json in
      make ?truncated ?nextMarker ?aliases ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of aliases in the caller's Amazon Web Services account and region. For more information about aliases, see CreateAlias. By default, the ListAliases operation returns all aliases in the account and region. To get only the aliases associated with a particular KMS key, use the KeyId parameter. The ListAliases response can include aliases that you created and associated with your customer managed keys, and aliases that Amazon Web Services created and associated with Amazon Web Services managed keys in your account. You can recognize Amazon Web Services aliases because their names have the format aws/<service-name>, such as aws/dynamodb. The response might also include aliases that have no TargetKeyId field. These are predefined aliases that Amazon Web Services has created but has not yet associated with a KMS key. Aliases that Amazon Web Services creates in your account, including predefined aliases, do not count against your KMS aliases quota. Cross-account use: No. ListAliases does not return aliases in other Amazon Web Services accounts. Required permissions: kms:ListAliases (IAM policy) For details, see Controlling access to aliases in the Key Management Service Developer Guide. Related operations: CreateAlias DeleteAlias UpdateAlias Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ListAliasesRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "Lists only aliases that are associated with the specified KMS key. Enter a KMS key in your Amazon Web Services account. This parameter is optional. If you omit it, ListAliases returns all aliases in the account and Region. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer. This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."]}
    let make ?keyId =
      fun ?limit -> fun ?marker -> fun () -> { keyId; limit; marker }
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?marker ?limit ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?marker ?limit ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a list of aliases in the caller's Amazon Web Services account and region. For more information about aliases, see CreateAlias. By default, the ListAliases operation returns all aliases in the account and region. To get only the aliases associated with a particular KMS key, use the KeyId parameter. The ListAliases response can include aliases that you created and associated with your customer managed keys, and aliases that Amazon Web Services created and associated with Amazon Web Services managed keys in your account. You can recognize Amazon Web Services aliases because their names have the format aws/<service-name>, such as aws/dynamodb. The response might also include aliases that have no TargetKeyId field. These are predefined aliases that Amazon Web Services has created but has not yet associated with a KMS key. Aliases that Amazon Web Services creates in your account, including predefined aliases, do not count against your KMS aliases quota. Cross-account use: No. ListAliases does not return aliases in other Amazon Web Services accounts. Required permissions: kms:ListAliases (IAM policy) For details, see Controlling access to aliases in the Key Management Service Developer Guide. Related operations: CreateAlias DeleteAlias UpdateAlias Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module InvalidAliasNameException =
  struct
    type nonrec t = {
      message: ErrorMessageType.t option }
    let make ?message = fun () -> { message }
    let to_value x =
      structure_to_value
        [("message", (Option.map x.message ~f:ErrorMessageType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let message =
        (Option.map ~f:ErrorMessageType.of_xml)
          (Xml.child xml_arg0 "message") in
      make ?message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let message = field_map json__ "message" ErrorMessageType.of_json in
      make ?message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "The request was rejected because the specified alias name is not valid."]
module ImportKeyMaterialResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key into which key material was imported."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc "Identifies the imported key material."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `ExpiredImportTokenException of ExpiredImportTokenException.t 
      | `IncorrectKeyMaterialException of IncorrectKeyMaterialException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `InvalidCiphertextException of InvalidCiphertextException.t 
      | `InvalidImportTokenException of InvalidImportTokenException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?keyMaterialId -> fun () -> { keyId; keyMaterialId }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "ExpiredImportTokenException" ->
          `ExpiredImportTokenException
            (ExpiredImportTokenException.of_json json)
      | "IncorrectKeyMaterialException" ->
          `IncorrectKeyMaterialException
            (IncorrectKeyMaterialException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException
            (InvalidCiphertextException.of_json json)
      | "InvalidImportTokenException" ->
          `InvalidImportTokenException
            (InvalidImportTokenException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "ExpiredImportTokenException" ->
          `ExpiredImportTokenException
            (ExpiredImportTokenException.of_xml xml)
      | "IncorrectKeyMaterialException" ->
          `IncorrectKeyMaterialException
            (IncorrectKeyMaterialException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException (InvalidCiphertextException.of_xml xml)
      | "InvalidImportTokenException" ->
          `InvalidImportTokenException
            (InvalidImportTokenException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `ExpiredImportTokenException e ->
          `Assoc
            [("error", (`String "ExpiredImportTokenException"));
            ("details", (ExpiredImportTokenException.to_json e))]
      | `IncorrectKeyMaterialException e ->
          `Assoc
            [("error", (`String "IncorrectKeyMaterialException"));
            ("details", (IncorrectKeyMaterialException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidCiphertextException e ->
          `Assoc
            [("error", (`String "InvalidCiphertextException"));
            ("details", (InvalidCiphertextException.to_json e))]
      | `InvalidImportTokenException e ->
          `Assoc
            [("error", (`String "InvalidImportTokenException"));
            ("details", (InvalidImportTokenException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyMaterialId ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyMaterialId ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Imports or reimports key material into an existing KMS key that was created without key material. You can also use this operation to set or update the expiration model and expiration date of the imported key material. By default, KMS creates KMS keys with key material that it generates. You can also generate and import your own key material. For more information about importing key material, see Importing key material. For asymmetric and HMAC keys, you cannot change the key material after the initial import. You can import multiple key materials into symmetric encryption keys and rotate the key material on demand using RotateKeyOnDemand. You can import new key materials into multi-Region symmetric encryption keys. To do so, you must import the new key material into the primary Region key. Then you can import the same key materials into the replica Region keys. You cannot directly import new key material into the replica Region keys. To import new key material for a multi-Region symmetric key, you\226\128\153ll need to complete the following: Call ImportKeyMaterial on the primary Region key with the ImportTypeset to NEW_KEY_MATERIAL. Call ImportKeyMaterial on the replica Region key with the ImportType set to EXISTING_KEY_MATERIAL using the same key material imported to the primary Region key. You must do this for every replica Region key before you can perform the RotateKeyOnDemand operation on the primary Region key. After you import key material, you can reimport the same key material into that KMS key or, if the key supports on-demand rotation, import new key material. You can use the ImportType parameter to indicate whether you are importing new key material or re-importing previously imported key material. You might reimport key material to replace key material that expired or key material that you deleted. You might also reimport key material to change the expiration model or expiration date of the key material. Each time you import key material into KMS, you can determine whether (ExpirationModel) and when (ValidTo) the key material expires. To change the expiration of your key material, you must import it again, either by calling ImportKeyMaterial or using the import features of the KMS console. Before you call ImportKeyMaterial, complete these steps: Create or identify a KMS key with EXTERNAL origin, which indicates that the KMS key is designed for imported key material. To create a new KMS key for imported key material, call the CreateKey operation with an Origin value of EXTERNAL. You can create a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, asymmetric key agreement key, or asymmetric signing KMS key. You can also import key material into a multi-Region key of any supported type. However, you can't import key material into a KMS key in a custom key store. Call the GetParametersForImport operation to get a public key and import token set for importing key material. Use the public key in the GetParametersForImport response to encrypt your key material. Then, in an ImportKeyMaterial request, you submit your encrypted key material and import token. When calling this operation, you must specify the following values: The key ID or key ARN of the KMS key to associate with the imported key material. Its Origin must be EXTERNAL and its KeyState must be PendingImport or Enabled. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account. To get the Origin and KeyState of a KMS key, call DescribeKey. The encrypted key material. The import token that GetParametersForImport returned. You must use a public key and token from the same GetParametersForImport response. Whether the key material expires (ExpirationModel) and, if so, when (ValidTo). For help with this choice, see Setting an expiration time in the Key Management Service Developer Guide. If you set an expiration date, KMS deletes the key material from the KMS key on the specified date, making the KMS key unusable. To use the KMS key in cryptographic operations again, you must reimport the same key material. However, you can delete and reimport the key material at any time, including before the key material expires. Each time you reimport, you can eliminate or reset the expiration time. When this operation is successful, the state of the KMS key changes to Enabled, and you can use the KMS key in cryptographic operations. For symmetric encryption keys, you will need to import all of the key materials associated with the KMS key to change its state to Enabled. Use the ListKeyRotations operation to list the ID and import state of each key material associated with a KMS key. If this operation fails, use the exception to help determine the problem. If the error is related to the key material, the import token, or wrapping key, use GetParametersForImport to get a new public key and import token for the KMS key and repeat the import procedure. For help, see Create a KMS key with imported key material in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ImportKeyMaterial (key policy) Related operations: DeleteImportedKeyMaterial GetParametersForImport ListKeyRotations RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ImportKeyMaterialRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "The identifier of the KMS key that will be associated with the imported key material. This must be the same KMS key specified in the KeyID parameter of the corresponding GetParametersForImport request. The Origin of the KMS key must be EXTERNAL and its KeyState must be PendingImport. The KMS key can be a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key, including a multi-Region key of any supported type. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      importToken: CiphertextType.t
        [@ocaml.doc
          "The import token that you received in the response to a previous GetParametersForImport request. It must be from the same response that contained the public key that you used to encrypt the key material."];
      encryptedKeyMaterial: CiphertextType.t
        [@ocaml.doc
          "The encrypted key material to import. The key material must be encrypted under the public wrapping key that GetParametersForImport returned, using the wrapping algorithm that you specified in the same GetParametersForImport request."];
      validTo: DateType.t option
        [@ocaml.doc
          "The date and time when the imported key material expires. This parameter is required when the value of the ExpirationModel parameter is KEY_MATERIAL_EXPIRES. Otherwise it is not valid. The value of this parameter must be a future date and time. The maximum value is 365 days from the request date. When the key material expires, KMS deletes the key material from the KMS key. Without its key material, the KMS key is unusable. To use the KMS key in cryptographic operations, you must reimport the same key material. You cannot change the ExpirationModel or ValidTo values for the current import after the request completes. To change either value, you must delete (DeleteImportedKeyMaterial) and reimport the key material."];
      expirationModel: ExpirationModelType.t option
        [@ocaml.doc
          "Specifies whether the key material expires. The default is KEY_MATERIAL_EXPIRES. For help with this choice, see Setting an expiration time in the Key Management Service Developer Guide. When the value of ExpirationModel is KEY_MATERIAL_EXPIRES, you must specify a value for the ValidTo parameter. When value is KEY_MATERIAL_DOES_NOT_EXPIRE, you must omit the ValidTo parameter. You cannot change the ExpirationModel or ValidTo values for the current import after the request completes. To change either value, you must reimport the key material."];
      importType: ImportType.t option
        [@ocaml.doc
          "Indicates whether the key material being imported is previously associated with this KMS key or not. This parameter is optional and only usable with symmetric encryption keys. If no key material has ever been imported into the KMS key, and this parameter is omitted, the parameter defaults to NEW_KEY_MATERIAL. After the first key material is imported, if this parameter is omitted then the parameter defaults to EXISTING_KEY_MATERIAL. For multi-Region keys, you must first import new key material into the primary Region key. You should use the NEW_KEY_MATERIAL import type when importing key material into the primary Region key. Then, you can import the same key material into the replica Region key. The import type for the replica Region key should be EXISTING_KEY_MATERIAL."];
      keyMaterialDescription: KeyMaterialDescriptionType.t option
        [@ocaml.doc
          "Description for the key material being imported. This parameter is optional and only usable with symmetric encryption keys. If you do not specify a key material description, KMS retains the value you specified when you last imported the same key material into this KMS key."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "Identifies the key material being imported. This parameter is optional and only usable with symmetric encryption keys. You cannot specify a key material ID with ImportType set to NEW_KEY_MATERIAL. Whenever you import key material into a symmetric encryption key, KMS assigns a unique identifier to the key material based on the KMS key ID and the imported key material. When you re-import key material with a specified key material ID, KMS: Computes the identifier for the key material Matches the computed identifier against the specified key material ID Verifies that the key material ID is already associated with the KMS key To get the list of key material IDs associated with a KMS key, use ListKeyRotations."]}
    let context_ = "ImportKeyMaterialRequest"
    let make ?validTo =
      fun ?expirationModel ->
        fun ?importType ->
          fun ?keyMaterialDescription ->
            fun ?keyMaterialId ->
              fun ~keyId ->
                fun ~importToken ->
                  fun ~encryptedKeyMaterial ->
                    fun () ->
                      {
                        validTo;
                        expirationModel;
                        importType;
                        keyMaterialDescription;
                        keyMaterialId;
                        keyId;
                        importToken;
                        encryptedKeyMaterial
                      }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("ImportToken", (Some (CiphertextType.to_value x.importToken)));
        ("EncryptedKeyMaterial",
          (Some (CiphertextType.to_value x.encryptedKeyMaterial)));
        ("ValidTo", (Option.map x.validTo ~f:DateType.to_value));
        ("ExpirationModel",
          (Option.map x.expirationModel ~f:ExpirationModelType.to_value));
        ("ImportType", (Option.map x.importType ~f:ImportType.to_value));
        ("KeyMaterialDescription",
          (Option.map x.keyMaterialDescription
             ~f:KeyMaterialDescriptionType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyMaterialDescription =
        (Option.map ~f:KeyMaterialDescriptionType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialDescription") in
      let importType =
        (Option.map ~f:ImportType.of_xml) (Xml.child xml_arg0 "ImportType") in
      let expirationModel =
        (Option.map ~f:ExpirationModelType.of_xml)
          (Xml.child xml_arg0 "ExpirationModel") in
      let validTo =
        (Option.map ~f:DateType.of_xml) (Xml.child xml_arg0 "ValidTo") in
      let encryptedKeyMaterial =
        CiphertextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "EncryptedKeyMaterial") in
      let importToken =
        CiphertextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "ImportToken") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?keyMaterialId ?keyMaterialDescription ?importType
        ?expirationModel ?validTo ~encryptedKeyMaterial ~importToken ~keyId
        ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyMaterialDescription =
        field_map json__ "KeyMaterialDescription"
          KeyMaterialDescriptionType.of_json in
      let importType = field_map json__ "ImportType" ImportType.of_json in
      let expirationModel =
        field_map json__ "ExpirationModel" ExpirationModelType.of_json in
      let validTo = field_map json__ "ValidTo" DateType.of_json in
      let encryptedKeyMaterial =
        field_map_exn json__ "EncryptedKeyMaterial" CiphertextType.of_json in
      let importToken =
        field_map_exn json__ "ImportToken" CiphertextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?keyMaterialId ?keyMaterialDescription ?importType
        ?expirationModel ?validTo ~encryptedKeyMaterial ~importToken ~keyId
        ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Imports or reimports key material into an existing KMS key that was created without key material. You can also use this operation to set or update the expiration model and expiration date of the imported key material. By default, KMS creates KMS keys with key material that it generates. You can also generate and import your own key material. For more information about importing key material, see Importing key material. For asymmetric and HMAC keys, you cannot change the key material after the initial import. You can import multiple key materials into symmetric encryption keys and rotate the key material on demand using RotateKeyOnDemand. You can import new key materials into multi-Region symmetric encryption keys. To do so, you must import the new key material into the primary Region key. Then you can import the same key materials into the replica Region keys. You cannot directly import new key material into the replica Region keys. To import new key material for a multi-Region symmetric key, you\226\128\153ll need to complete the following: Call ImportKeyMaterial on the primary Region key with the ImportTypeset to NEW_KEY_MATERIAL. Call ImportKeyMaterial on the replica Region key with the ImportType set to EXISTING_KEY_MATERIAL using the same key material imported to the primary Region key. You must do this for every replica Region key before you can perform the RotateKeyOnDemand operation on the primary Region key. After you import key material, you can reimport the same key material into that KMS key or, if the key supports on-demand rotation, import new key material. You can use the ImportType parameter to indicate whether you are importing new key material or re-importing previously imported key material. You might reimport key material to replace key material that expired or key material that you deleted. You might also reimport key material to change the expiration model or expiration date of the key material. Each time you import key material into KMS, you can determine whether (ExpirationModel) and when (ValidTo) the key material expires. To change the expiration of your key material, you must import it again, either by calling ImportKeyMaterial or using the import features of the KMS console. Before you call ImportKeyMaterial, complete these steps: Create or identify a KMS key with EXTERNAL origin, which indicates that the KMS key is designed for imported key material. To create a new KMS key for imported key material, call the CreateKey operation with an Origin value of EXTERNAL. You can create a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, asymmetric key agreement key, or asymmetric signing KMS key. You can also import key material into a multi-Region key of any supported type. However, you can't import key material into a KMS key in a custom key store. Call the GetParametersForImport operation to get a public key and import token set for importing key material. Use the public key in the GetParametersForImport response to encrypt your key material. Then, in an ImportKeyMaterial request, you submit your encrypted key material and import token. When calling this operation, you must specify the following values: The key ID or key ARN of the KMS key to associate with the imported key material. Its Origin must be EXTERNAL and its KeyState must be PendingImport or Enabled. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account. To get the Origin and KeyState of a KMS key, call DescribeKey. The encrypted key material. The import token that GetParametersForImport returned. You must use a public key and token from the same GetParametersForImport response. Whether the key material expires (ExpirationModel) and, if so, when (ValidTo). For help with this choice, see Setting an expiration time in the Key Management Service Developer Guide. If you set an expiration date, KMS deletes the key material from the KMS key on the specified date, making the KMS key unusable. To use the KMS key in cryptographic operations again, you must reimport the same key material. However, you can delete and reimport the key material at any time, including before the key material expires. Each time you reimport, you can eliminate or reset the expiration time. When this operation is successful, the state of the KMS key changes to Enabled, and you can use the KMS key in cryptographic operations. For symmetric encryption keys, you will need to import all of the key materials associated with the KMS key to change its state to Enabled. Use the ListKeyRotations operation to list the ID and import state of each key material associated with a KMS key. If this operation fails, use the exception to help determine the problem. If the error is related to the key material, the import token, or wrapping key, use GetParametersForImport to get a new public key and import token for the KMS key and repeat the import procedure. For help, see Create a KMS key with imported key material in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:ImportKeyMaterial (key policy) Related operations: DeleteImportedKeyMaterial GetParametersForImport ListKeyRotations RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetPublicKeyResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the asymmetric KMS key from which the public key was downloaded."];
      publicKey: PublicKeyType.t option
        [@ocaml.doc
          "The exported public key. The value is a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      customerMasterKeySpec: CustomerMasterKeySpec.t option
        [@ocaml.doc
          "Instead, use the KeySpec field in the GetPublicKey response. The KeySpec and CustomerMasterKeySpec fields have the same value. We recommend that you use the KeySpec field in your code. However, to avoid breaking changes, KMS supports both fields."];
      keySpec: KeySpec.t option
        [@ocaml.doc "The type of the of the public key that was downloaded."];
      keyUsage: KeyUsageType.t option
        [@ocaml.doc
          "The permitted use of the public key. Valid values for asymmetric key pairs are ENCRYPT_DECRYPT, SIGN_VERIFY, and KEY_AGREEMENT. This information is critical. For example, if a public key with SIGN_VERIFY key usage encrypts data outside of KMS, the ciphertext cannot be decrypted."];
      encryptionAlgorithms: EncryptionAlgorithmSpecList.t option
        [@ocaml.doc
          "The encryption algorithms that KMS supports for this key. This information is critical. If a public key encrypts data outside of KMS by using an unsupported encryption algorithm, the ciphertext cannot be decrypted. This field appears in the response only when the KeyUsage of the public key is ENCRYPT_DECRYPT."];
      signingAlgorithms: SigningAlgorithmSpecList.t option
        [@ocaml.doc
          "The signing algorithms that KMS supports for this key. This field appears in the response only when the KeyUsage of the public key is SIGN_VERIFY."];
      keyAgreementAlgorithms: KeyAgreementAlgorithmSpecList.t option
        [@ocaml.doc
          "The key agreement algorithm used to derive a shared secret. This field is present only when the KMS key has a KeyUsage value of KEY_AGREEMENT."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?publicKey ->
        fun ?customerMasterKeySpec ->
          fun ?keySpec ->
            fun ?keyUsage ->
              fun ?encryptionAlgorithms ->
                fun ?signingAlgorithms ->
                  fun ?keyAgreementAlgorithms ->
                    fun () ->
                      {
                        keyId;
                        publicKey;
                        customerMasterKeySpec;
                        keySpec;
                        keyUsage;
                        encryptionAlgorithms;
                        signingAlgorithms;
                        keyAgreementAlgorithms
                      }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("PublicKey", (Option.map x.publicKey ~f:PublicKeyType.to_value));
        ("CustomerMasterKeySpec",
          (Option.map x.customerMasterKeySpec
             ~f:CustomerMasterKeySpec.to_value));
        ("KeySpec", (Option.map x.keySpec ~f:KeySpec.to_value));
        ("KeyUsage", (Option.map x.keyUsage ~f:KeyUsageType.to_value));
        ("EncryptionAlgorithms",
          (Option.map x.encryptionAlgorithms
             ~f:EncryptionAlgorithmSpecList.to_value));
        ("SigningAlgorithms",
          (Option.map x.signingAlgorithms
             ~f:SigningAlgorithmSpecList.to_value));
        ("KeyAgreementAlgorithms",
          (Option.map x.keyAgreementAlgorithms
             ~f:KeyAgreementAlgorithmSpecList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyAgreementAlgorithms =
        (Option.map ~f:KeyAgreementAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "KeyAgreementAlgorithms") in
      let signingAlgorithms =
        (Option.map ~f:SigningAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "SigningAlgorithms") in
      let encryptionAlgorithms =
        (Option.map ~f:EncryptionAlgorithmSpecList.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithms") in
      let keyUsage =
        (Option.map ~f:KeyUsageType.of_xml) (Xml.child xml_arg0 "KeyUsage") in
      let keySpec =
        (Option.map ~f:KeySpec.of_xml) (Xml.child xml_arg0 "KeySpec") in
      let customerMasterKeySpec =
        (Option.map ~f:CustomerMasterKeySpec.of_xml)
          (Xml.child xml_arg0 "CustomerMasterKeySpec") in
      let publicKey =
        (Option.map ~f:PublicKeyType.of_xml) (Xml.child xml_arg0 "PublicKey") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyAgreementAlgorithms ?signingAlgorithms ?encryptionAlgorithms
        ?keyUsage ?keySpec ?customerMasterKeySpec ?publicKey ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyAgreementAlgorithms =
        field_map json__ "KeyAgreementAlgorithms"
          KeyAgreementAlgorithmSpecList.of_json in
      let signingAlgorithms =
        field_map json__ "SigningAlgorithms" SigningAlgorithmSpecList.of_json in
      let encryptionAlgorithms =
        field_map json__ "EncryptionAlgorithms"
          EncryptionAlgorithmSpecList.of_json in
      let keyUsage = field_map json__ "KeyUsage" KeyUsageType.of_json in
      let keySpec = field_map json__ "KeySpec" KeySpec.of_json in
      let customerMasterKeySpec =
        field_map json__ "CustomerMasterKeySpec"
          CustomerMasterKeySpec.of_json in
      let publicKey = field_map json__ "PublicKey" PublicKeyType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyAgreementAlgorithms ?signingAlgorithms ?encryptionAlgorithms
        ?keyUsage ?keySpec ?customerMasterKeySpec ?publicKey ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the public key of an asymmetric KMS key. Unlike the private key of a asymmetric KMS key, which never leaves KMS unencrypted, callers with kms:GetPublicKey permission can download the public key of an asymmetric KMS key. You can share the public key to allow others to encrypt messages and verify signatures outside of KMS. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. You do not need to download the public key. Instead, you can use the public key within KMS by calling the Encrypt, ReEncrypt, or Verify operations with the identifier of an asymmetric KMS key. When you use the public key within KMS, you benefit from the authentication, authorization, and logging that are part of every KMS operation. You also reduce of risk of encrypting data that cannot be decrypted. These features are not effective outside of KMS. To help you use the public key safely outside of KMS, GetPublicKey returns important information about the public key in the response, including: KeySpec: The type of key material in the public key, such as RSA_4096 or ECC_NIST_P521. KeyUsage: Whether the key is used for encryption, signing, or deriving a shared secret. EncryptionAlgorithms, KeyAgreementAlgorithms, or SigningAlgorithms: A list of the encryption algorithms, key agreement algorithms, or signing algorithms for the key. Although KMS cannot enforce these restrictions on external operations, it is crucial that you use this information to prevent the public key from being used improperly. For example, you can prevent a public signing key from being used encrypt data, or prevent a public key from being used with an encryption algorithm that is not supported by KMS. You can also avoid errors, such as using the wrong signing algorithm in a verification operation. To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses 1234567812345678 as the distinguishing ID. For more information, see Offline verification with SM2 key pairs. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GetPublicKey (key policy) Related operations: CreateKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetPublicKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the asymmetric KMS key that includes the public key. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."]}
    let context_ = "GetPublicKeyRequest"
    let make ?grantTokens = fun ~keyId -> fun () -> { grantTokens; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?grantTokens ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?grantTokens ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the public key of an asymmetric KMS key. Unlike the private key of a asymmetric KMS key, which never leaves KMS unencrypted, callers with kms:GetPublicKey permission can download the public key of an asymmetric KMS key. You can share the public key to allow others to encrypt messages and verify signatures outside of KMS. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. You do not need to download the public key. Instead, you can use the public key within KMS by calling the Encrypt, ReEncrypt, or Verify operations with the identifier of an asymmetric KMS key. When you use the public key within KMS, you benefit from the authentication, authorization, and logging that are part of every KMS operation. You also reduce of risk of encrypting data that cannot be decrypted. These features are not effective outside of KMS. To help you use the public key safely outside of KMS, GetPublicKey returns important information about the public key in the response, including: KeySpec: The type of key material in the public key, such as RSA_4096 or ECC_NIST_P521. KeyUsage: Whether the key is used for encryption, signing, or deriving a shared secret. EncryptionAlgorithms, KeyAgreementAlgorithms, or SigningAlgorithms: A list of the encryption algorithms, key agreement algorithms, or signing algorithms for the key. Although KMS cannot enforce these restrictions on external operations, it is crucial that you use this information to prevent the public key from being used improperly. For example, you can prevent a public signing key from being used encrypt data, or prevent a public key from being used with an encryption algorithm that is not supported by KMS. You can also avoid errors, such as using the wrong signing algorithm in a verification operation. To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses 1234567812345678 as the distinguishing ID. For more information, see Offline verification with SM2 key pairs. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GetPublicKey (key policy) Related operations: CreateKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetParametersForImportResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key to use in a subsequent ImportKeyMaterial request. This is the same KMS key specified in the GetParametersForImport request."];
      importToken: CiphertextType.t option
        [@ocaml.doc
          "The import token to send in a subsequent ImportKeyMaterial request."];
      publicKey: PlaintextType.t option
        [@ocaml.doc
          "The public key to use to encrypt the key material before importing it with ImportKeyMaterial."];
      parametersValidTo: DateType.t option
        [@ocaml.doc
          "The time at which the import token and public key are no longer valid. After this time, you cannot use them to make an ImportKeyMaterial request and you must send another GetParametersForImport request to get new ones."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?importToken ->
        fun ?publicKey ->
          fun ?parametersValidTo ->
            fun () -> { keyId; importToken; publicKey; parametersValidTo }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("ImportToken",
          (Option.map x.importToken ~f:CiphertextType.to_value));
        ("PublicKey", (Option.map x.publicKey ~f:PlaintextType.to_value));
        ("ParametersValidTo",
          (Option.map x.parametersValidTo ~f:DateType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let parametersValidTo =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "ParametersValidTo") in
      let publicKey =
        (Option.map ~f:PlaintextType.of_xml) (Xml.child xml_arg0 "PublicKey") in
      let importToken =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "ImportToken") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?parametersValidTo ?publicKey ?importToken ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let parametersValidTo =
        field_map json__ "ParametersValidTo" DateType.of_json in
      let publicKey = field_map json__ "PublicKey" PlaintextType.of_json in
      let importToken = field_map json__ "ImportToken" CiphertextType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?parametersValidTo ?publicKey ?importToken ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the public key and an import token you need to import or reimport key material for a KMS key. By default, KMS keys are created with key material that KMS generates. This operation supports Importing key material, an advanced feature that lets you generate and import the cryptographic key material for a KMS key. Before calling GetParametersForImport, use the CreateKey operation with an Origin value of EXTERNAL to create a KMS key with no key material. You can import key material for a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key. You can also import key material into a multi-Region key of any supported type. However, you can't import key material into a KMS key in a custom key store. You can also use GetParametersForImport to get a public key and import token to reimport the original key material into a KMS key whose key material expired or was deleted. GetParametersForImport returns the items that you need to import your key material. The public key (or \"wrapping key\") of an RSA key pair that KMS generates. You will use this public key to encrypt (\"wrap\") your key material while it's in transit to KMS. A import token that ensures that KMS can decrypt your key material and associate it with the correct KMS key. The public key and its import token are permanently linked and must be used together. Each public key and import token set is valid for 24 hours. The expiration date and time appear in the ParametersValidTo field in the GetParametersForImport response. You cannot use an expired public key or import token in an ImportKeyMaterial request. If your key and token expire, send another GetParametersForImport request. GetParametersForImport requires the following information: The key ID of the KMS key for which you are importing the key material. The key spec of the public key (\"wrapping key\") that you will use to encrypt your key material during import. The wrapping algorithm that you will use with the public key to encrypt your key material. You can use the same or a different public key spec and wrapping algorithm each time you import or reimport the same key material. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetParametersForImport (key policy) Related operations: ImportKeyMaterial DeleteImportedKeyMaterial Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetParametersForImportRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "The identifier of the KMS key that will be associated with the imported key material. The Origin of the KMS key must be EXTERNAL. All KMS key types are supported, including multi-Region keys. However, you cannot import key material into a KMS key in a custom key store. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      wrappingAlgorithm: AlgorithmSpec.t
        [@ocaml.doc
          "The algorithm you will use with the RSA public key (PublicKey) in the response to protect your key material during import. For more information, see Select a wrapping algorithm in the Key Management Service Developer Guide. For RSA_AES wrapping algorithms, you encrypt your key material with an AES key that you generate, then encrypt your AES key with the RSA public key from KMS. For RSAES wrapping algorithms, you encrypt your key material directly with the RSA public key from KMS. The wrapping algorithms that you can use depend on the type of key material that you are importing. To import an RSA private key, you must use an RSA_AES wrapping algorithm. RSA_AES_KEY_WRAP_SHA_256 \226\128\148 Supported for wrapping RSA and ECC key material. RSA_AES_KEY_WRAP_SHA_1 \226\128\148 Supported for wrapping RSA and ECC key material. RSAES_OAEP_SHA_256 \226\128\148 Supported for all types of key material, except RSA key material (private key). You cannot use the RSAES_OAEP_SHA_256 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material. RSAES_OAEP_SHA_1 \226\128\148 Supported for all types of key material, except RSA key material (private key). You cannot use the RSAES_OAEP_SHA_1 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material. RSAES_PKCS1_V1_5 (Deprecated) \226\128\148 As of October 10, 2023, KMS does not support the RSAES_PKCS1_V1_5 wrapping algorithm."];
      wrappingKeySpec: WrappingKeySpec.t
        [@ocaml.doc
          "The type of RSA public key to return in the response. You will use this wrapping key with the specified wrapping algorithm to protect your key material during import. Use the longest RSA wrapping key that is practical. You cannot use an RSA_2048 public key to directly wrap an ECC_NIST_P521 private key. Instead, use an RSA_AES wrapping algorithm or choose a longer RSA public key."]}
    let context_ = "GetParametersForImportRequest"
    let make ~keyId =
      fun ~wrappingAlgorithm ->
        fun ~wrappingKeySpec ->
          fun () -> { keyId; wrappingAlgorithm; wrappingKeySpec }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("WrappingAlgorithm",
          (Some (AlgorithmSpec.to_value x.wrappingAlgorithm)));
        ("WrappingKeySpec",
          (Some (WrappingKeySpec.to_value x.wrappingKeySpec)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let wrappingKeySpec =
        WrappingKeySpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "WrappingKeySpec") in
      let wrappingAlgorithm =
        AlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "WrappingAlgorithm") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~wrappingKeySpec ~wrappingAlgorithm ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let wrappingKeySpec =
        field_map_exn json__ "WrappingKeySpec" WrappingKeySpec.of_json in
      let wrappingAlgorithm =
        field_map_exn json__ "WrappingAlgorithm" AlgorithmSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~wrappingKeySpec ~wrappingAlgorithm ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns the public key and an import token you need to import or reimport key material for a KMS key. By default, KMS keys are created with key material that KMS generates. This operation supports Importing key material, an advanced feature that lets you generate and import the cryptographic key material for a KMS key. Before calling GetParametersForImport, use the CreateKey operation with an Origin value of EXTERNAL to create a KMS key with no key material. You can import key material for a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key. You can also import key material into a multi-Region key of any supported type. However, you can't import key material into a KMS key in a custom key store. You can also use GetParametersForImport to get a public key and import token to reimport the original key material into a KMS key whose key material expired or was deleted. GetParametersForImport returns the items that you need to import your key material. The public key (or \"wrapping key\") of an RSA key pair that KMS generates. You will use this public key to encrypt (\"wrap\") your key material while it's in transit to KMS. A import token that ensures that KMS can decrypt your key material and associate it with the correct KMS key. The public key and its import token are permanently linked and must be used together. Each public key and import token set is valid for 24 hours. The expiration date and time appear in the ParametersValidTo field in the GetParametersForImport response. You cannot use an expired public key or import token in an ImportKeyMaterial request. If your key and token expire, send another GetParametersForImport request. GetParametersForImport requires the following information: The key ID of the KMS key for which you are importing the key material. The key spec of the public key (\"wrapping key\") that you will use to encrypt your key material during import. The wrapping algorithm that you will use with the public key to encrypt your key material. You can use the same or a different public key spec and wrapping algorithm each time you import or reimport the same key material. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetParametersForImport (key policy) Related operations: ImportKeyMaterial DeleteImportedKeyMaterial Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyRotationStatusResponse =
  struct
    type nonrec t =
      {
      keyRotationEnabled: BooleanType.t option
        [@ocaml.doc
          "A Boolean value that specifies whether key rotation is enabled."];
      keyId: KeyIdType.t option
        [@ocaml.doc "Identifies the specified symmetric encryption KMS key."];
      rotationPeriodInDays: RotationPeriodInDaysType.t option
        [@ocaml.doc
          "The number of days between each automatic rotation. The default value is 365 days."];
      nextRotationDate: DateType.t option
        [@ocaml.doc
          "The next date that KMS will automatically rotate the key material."];
      onDemandRotationStartDate: DateType.t option
        [@ocaml.doc
          "Identifies the date and time that an in progress on-demand rotation was initiated. KMS uses a background process to perform rotations. As a result, there might be a slight delay between initiating on-demand key rotation and the rotation's completion. Once the on-demand rotation is complete, KMS removes this field from the response. You can use ListKeyRotations to view the details of the completed on-demand rotation."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyRotationEnabled =
      fun ?keyId ->
        fun ?rotationPeriodInDays ->
          fun ?nextRotationDate ->
            fun ?onDemandRotationStartDate ->
              fun () ->
                {
                  keyRotationEnabled;
                  keyId;
                  rotationPeriodInDays;
                  nextRotationDate;
                  onDemandRotationStartDate
                }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyRotationEnabled",
           (Option.map x.keyRotationEnabled ~f:BooleanType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("RotationPeriodInDays",
          (Option.map x.rotationPeriodInDays
             ~f:RotationPeriodInDaysType.to_value));
        ("NextRotationDate",
          (Option.map x.nextRotationDate ~f:DateType.to_value));
        ("OnDemandRotationStartDate",
          (Option.map x.onDemandRotationStartDate ~f:DateType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let onDemandRotationStartDate =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "OnDemandRotationStartDate") in
      let nextRotationDate =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "NextRotationDate") in
      let rotationPeriodInDays =
        (Option.map ~f:RotationPeriodInDaysType.of_xml)
          (Xml.child xml_arg0 "RotationPeriodInDays") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let keyRotationEnabled =
        (Option.map ~f:BooleanType.of_xml)
          (Xml.child xml_arg0 "KeyRotationEnabled") in
      make ?onDemandRotationStartDate ?nextRotationDate ?rotationPeriodInDays
        ?keyId ?keyRotationEnabled ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let onDemandRotationStartDate =
        field_map json__ "OnDemandRotationStartDate" DateType.of_json in
      let nextRotationDate =
        field_map json__ "NextRotationDate" DateType.of_json in
      let rotationPeriodInDays =
        field_map json__ "RotationPeriodInDays"
          RotationPeriodInDaysType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let keyRotationEnabled =
        field_map json__ "KeyRotationEnabled" BooleanType.of_json in
      make ?onDemandRotationStartDate ?nextRotationDate ?rotationPeriodInDays
        ?keyId ?keyRotationEnabled ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides detailed information about the rotation status for a KMS key, including whether automatic rotation of the key material is enabled for the specified KMS key, the rotation period, and the next scheduled rotation date. Automatic key rotation is supported only on symmetric encryption KMS keys. You cannot enable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key. You can enable (EnableKeyRotation) and disable automatic rotation (DisableKeyRotation) of the key material in customer managed KMS keys. Key material rotation of Amazon Web Services managed KMS keys is not configurable. KMS always rotates the key material in Amazon Web Services managed KMS keys every year. The key rotation status for Amazon Web Services managed KMS keys is always true. You can perform on-demand (RotateKeyOnDemand) rotation of the key material in customer managed KMS keys, regardless of whether or not automatic key rotation is enabled. You can use GetKeyRotationStatus to identify the date and time that an in progress on-demand rotation was initiated. You can use ListKeyRotations to view the details of completed rotations. In May 2022, KMS changed the rotation schedule for Amazon Web Services managed keys from every three years to every year. For details, see EnableKeyRotation. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Disabled: The key rotation status does not change when you disable a KMS key. However, while the KMS key is disabled, KMS does not rotate the key material. When you re-enable the KMS key, rotation resumes. If the key material in the re-enabled KMS key hasn't been rotated in one year, KMS rotates it immediately, and every year thereafter. If it's been less than a year since the key material in the re-enabled KMS key was rotated, the KMS key resumes its prior rotation schedule. Pending deletion: While a KMS key is pending deletion, its key rotation status is false and KMS does not rotate the key material. If you cancel the deletion, the original key rotation status returns to true. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:GetKeyRotationStatus (key policy) Related operations: DisableKeyRotation EnableKeyRotation ListKeyRotations RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyRotationStatusRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Gets the rotation status for the specified KMS key. Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "GetKeyRotationStatusRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides detailed information about the rotation status for a KMS key, including whether automatic rotation of the key material is enabled for the specified KMS key, the rotation period, and the next scheduled rotation date. Automatic key rotation is supported only on symmetric encryption KMS keys. You cannot enable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key. You can enable (EnableKeyRotation) and disable automatic rotation (DisableKeyRotation) of the key material in customer managed KMS keys. Key material rotation of Amazon Web Services managed KMS keys is not configurable. KMS always rotates the key material in Amazon Web Services managed KMS keys every year. The key rotation status for Amazon Web Services managed KMS keys is always true. You can perform on-demand (RotateKeyOnDemand) rotation of the key material in customer managed KMS keys, regardless of whether or not automatic key rotation is enabled. You can use GetKeyRotationStatus to identify the date and time that an in progress on-demand rotation was initiated. You can use ListKeyRotations to view the details of completed rotations. In May 2022, KMS changed the rotation schedule for Amazon Web Services managed keys from every three years to every year. For details, see EnableKeyRotation. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Disabled: The key rotation status does not change when you disable a KMS key. However, while the KMS key is disabled, KMS does not rotate the key material. When you re-enable the KMS key, rotation resumes. If the key material in the re-enabled KMS key hasn't been rotated in one year, KMS rotates it immediately, and every year thereafter. If it's been less than a year since the key material in the re-enabled KMS key was rotated, the KMS key resumes its prior rotation schedule. Pending deletion: While a KMS key is pending deletion, its key rotation status is false and KMS does not rotate the key material. If you cancel the deletion, the original key rotation status returns to true. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:GetKeyRotationStatus (key policy) Related operations: DisableKeyRotation EnableKeyRotation ListKeyRotations RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyPolicyResponse =
  struct
    type nonrec t =
      {
      policy: PolicyType.t option
        [@ocaml.doc "A key policy document in JSON format."];
      policyName: PolicyNameType.t option
        [@ocaml.doc
          "The name of the key policy. The only valid value is default."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?policy = fun ?policyName -> fun () -> { policy; policyName }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Policy", (Option.map x.policy ~f:PolicyType.to_value));
        ("PolicyName", (Option.map x.policyName ~f:PolicyNameType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let policyName =
        (Option.map ~f:PolicyNameType.of_xml)
          (Xml.child xml_arg0 "PolicyName") in
      let policy =
        (Option.map ~f:PolicyType.of_xml) (Xml.child xml_arg0 "Policy") in
      make ?policyName ?policy ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let policyName = field_map json__ "PolicyName" PolicyNameType.of_json in
      let policy = field_map json__ "Policy" PolicyType.of_json in
      make ?policyName ?policy ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a key policy attached to the specified KMS key. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetKeyPolicy (key policy) Related operations: PutKeyPolicy Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyPolicyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Gets the key policy for the specified KMS key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      policyName: PolicyNameType.t option
        [@ocaml.doc
          "Specifies the name of the key policy. If no policy name is specified, the default value is default. The only valid name is default. To get the names of key policies, use ListKeyPolicies."]}
    let context_ = "GetKeyPolicyRequest"
    let make ?policyName = fun ~keyId -> fun () -> { policyName; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("PolicyName", (Option.map x.policyName ~f:PolicyNameType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let policyName =
        (Option.map ~f:PolicyNameType.of_xml)
          (Xml.child xml_arg0 "PolicyName") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?policyName ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let policyName = field_map json__ "PolicyName" PolicyNameType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?policyName ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets a key policy attached to the specified KMS key. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetKeyPolicy (key policy) Related operations: PutKeyPolicy Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyLastUsageResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc "The globally unique identifier for the KMS key."];
      keyLastUsage: KeyLastUsageData.t option
        [@ocaml.doc
          "Contains usage information about the last time the KMS key was used for a successful cryptographic operation. If the key has not been used since tracking began, this response element is empty."];
      trackingStartDate: DateType.t option
        [@ocaml.doc
          "The date from which KMS began recording cryptographic activity for this key, or the date the KMS key was created, whichever is later."];
      keyCreationDate: DateType.t option
        [@ocaml.doc "The date and time when the KMS key was created."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?keyLastUsage ->
        fun ?trackingStartDate ->
          fun ?keyCreationDate ->
            fun () ->
              { keyId; keyLastUsage; trackingStartDate; keyCreationDate }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyLastUsage",
          (Option.map x.keyLastUsage ~f:KeyLastUsageData.to_value));
        ("TrackingStartDate",
          (Option.map x.trackingStartDate ~f:DateType.to_value));
        ("KeyCreationDate",
          (Option.map x.keyCreationDate ~f:DateType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyCreationDate =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "KeyCreationDate") in
      let trackingStartDate =
        (Option.map ~f:DateType.of_xml)
          (Xml.child xml_arg0 "TrackingStartDate") in
      let keyLastUsage =
        (Option.map ~f:KeyLastUsageData.of_xml)
          (Xml.child xml_arg0 "KeyLastUsage") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyCreationDate ?trackingStartDate ?keyLastUsage ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyCreationDate =
        field_map json__ "KeyCreationDate" DateType.of_json in
      let trackingStartDate =
        field_map json__ "TrackingStartDate" DateType.of_json in
      let keyLastUsage =
        field_map json__ "KeyLastUsage" KeyLastUsageData.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyCreationDate ?trackingStartDate ?keyLastUsage ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns usage information about the last successful cryptographic operation performed with a specified KMS key, including the operation type, timestamp, and associated CloudTrail event ID. The TrackingStartDate in the GetKeyLastUsage response indicates the date from which KMS began recording cryptographic activity for a given key. Use this value together with KeyCreationDate to understand the key's usage history: If the KeyLastUsage response element is present, the key has been used for a successful cryptographic operation since the TrackingStartDate. The response includes the operation type, timestamp, and associated CloudTrail event ID. If the KeyLastUsage response element is empty and KeyCreationDate is on or after TrackingStartDate, the key has not been used for a successful cryptographic operation since it was created. If the KeyLastUsage response element is empty and KeyCreationDate is before TrackingStartDate, there is no record of the key being used for a successful cryptographic operation since the TrackingStartDate. However, the key may have been used before tracking began. To determine whether the key was used before the TrackingStartDate, examine your past CloudTrail logs. For multi-Region KMS keys, primary and replica keys track last usage independently. Each key in a multi-Region key set maintains its own usage information. The ReEncrypt operation uses two keys: a source key for decryption and a destination key for encryption. Usage information is recorded for both keys independently, each with the CloudTrail event ID from the respective key owner's account. Do not use GetKeyLastUsage as the sole indicator when scheduling a key for deletion. Instead, first disable the key and monitor CloudTrail for DisabledException entries, as there could be infrequent workflows that are dependent on the key. By looking for this exception, you can identify potential dependencies and workload failures before they occur. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetKeyLastUsage (key policy) Related operations: DescribeKey DisableKey ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GetKeyLastUsageRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key to get usage information for. To specify a KMS key, use its key ID or key ARN. Alias names are not supported. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "GetKeyLastUsageRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns usage information about the last successful cryptographic operation performed with a specified KMS key, including the operation type, timestamp, and associated CloudTrail event ID. The TrackingStartDate in the GetKeyLastUsage response indicates the date from which KMS began recording cryptographic activity for a given key. Use this value together with KeyCreationDate to understand the key's usage history: If the KeyLastUsage response element is present, the key has been used for a successful cryptographic operation since the TrackingStartDate. The response includes the operation type, timestamp, and associated CloudTrail event ID. If the KeyLastUsage response element is empty and KeyCreationDate is on or after TrackingStartDate, the key has not been used for a successful cryptographic operation since it was created. If the KeyLastUsage response element is empty and KeyCreationDate is before TrackingStartDate, there is no record of the key being used for a successful cryptographic operation since the TrackingStartDate. However, the key may have been used before tracking began. To determine whether the key was used before the TrackingStartDate, examine your past CloudTrail logs. For multi-Region KMS keys, primary and replica keys track last usage independently. Each key in a multi-Region key set maintains its own usage information. The ReEncrypt operation uses two keys: a source key for decryption and a destination key for encryption. Usage information is recorded for both keys independently, each with the CloudTrail event ID from the respective key owner's account. Do not use GetKeyLastUsage as the sole indicator when scheduling a key for deletion. Instead, first disable the key and monitor CloudTrail for DisabledException entries, as there could be infrequent workflows that are dependent on the key. By looking for this exception, you can identify potential dependencies and workload failures before they occur. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:GetKeyLastUsage (key policy) Related operations: DescribeKey DisableKey ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateRandomResponse =
  struct
    type nonrec t =
      {
      plaintext: PlaintextType.t option
        [@ocaml.doc
          "The random byte string. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded. If the response includes the CiphertextForRecipient field, the Plaintext field is null or empty."];
      ciphertextForRecipient: CiphertextType.t option
        [@ocaml.doc
          "The plaintext random bytes encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment. This field is included in the response only when the Recipient parameter in the request includes a valid attestation document from an Amazon Web Services Nitro enclave or NitroTPM. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."]}
    type nonrec error =
      [
        `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `DependencyTimeoutException of DependencyTimeoutException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?plaintext =
      fun ?ciphertextForRecipient ->
        fun () -> { plaintext; ciphertextForRecipient }
    let error_of_json name json =
      match name with
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let of_header_and_body =
      ((fun (xs, pipe) ->
          make ?plaintext:(Some pipe) ?ciphertextForRecipient:(Some pipe) ())
      [@warning "-27"])
    let to_value x =
      structure_to_value
        [("Plaintext", (Option.map x.plaintext ~f:PlaintextType.to_value));
        ("CiphertextForRecipient",
          (Option.map x.ciphertextForRecipient ~f:CiphertextType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let ciphertextForRecipient =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextForRecipient") in
      let plaintext =
        (Option.map ~f:PlaintextType.of_xml) (Xml.child xml_arg0 "Plaintext") in
      make ?ciphertextForRecipient ?plaintext ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let ciphertextForRecipient =
        field_map json__ "CiphertextForRecipient" CiphertextType.of_json in
      let plaintext = field_map json__ "Plaintext" PlaintextType.of_json in
      make ?ciphertextForRecipient ?plaintext ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a random byte string that is cryptographically secure. You must use the NumberOfBytes parameter to specify the length of the random byte string. There is no default value for string length. By default, the random byte string is generated in KMS. To generate the byte string in the CloudHSM cluster associated with an CloudHSM key store, use the CustomKeyStoreId parameter. GenerateRandom also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateRandom for a Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. Instead of plaintext bytes, the response includes the plaintext bytes encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. For more information about entropy and random number generation, see Entropy and random number generation in the Key Management Service Developer Guide. Cross-account use: Not applicable. GenerateRandom does not use any account-specific resources, such as KMS keys. Required permissions: kms:GenerateRandom (IAM policy) Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateRandomRequest =
  struct
    type nonrec t =
      {
      numberOfBytes: NumberOfBytesType.t option
        [@ocaml.doc
          "The length of the random byte string. This parameter is required."];
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc
          "Generates the random byte string in the CloudHSM cluster that is associated with the specified CloudHSM key store. To find the ID of a custom key store, use the DescribeCustomKeyStores operation. External key store IDs are not valid for this parameter. If you specify the ID of an external key store, GenerateRandom throws an UnsupportedOperationException."];
      recipient: RecipientInfo.t option
        [@ocaml.doc
          "A signed attestation document from an Amazon Web Services Nitro enclave or NitroTPM, and the encryption algorithm to use with the public key in the attestation document. The only valid encryption algorithm is RSAES_OAEP_SHA_256. This parameter supports the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK for Amazon Web Services Nitro Enclaves. It supports any Amazon Web Services SDK for Amazon Web Services NitroTPM. When you use this parameter, instead of returning plaintext bytes, KMS encrypts the plaintext bytes under the public key in the attestation document, and returns the resulting ciphertext in the CiphertextForRecipient field in the response. This ciphertext can be decrypted only with the private key in the attested environment. The Plaintext field in the response is null or empty. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."]}
    let make ?numberOfBytes =
      fun ?customKeyStoreId ->
        fun ?recipient ->
          fun () -> { numberOfBytes; customKeyStoreId; recipient }
    let to_value x =
      structure_to_value
        [("NumberOfBytes",
           (Option.map x.numberOfBytes ~f:NumberOfBytesType.to_value));
        ("CustomKeyStoreId",
          (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value));
        ("Recipient", (Option.map x.recipient ~f:RecipientInfo.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let recipient =
        (Option.map ~f:RecipientInfo.of_xml) (Xml.child xml_arg0 "Recipient") in
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      let numberOfBytes =
        (Option.map ~f:NumberOfBytesType.of_xml)
          (Xml.child xml_arg0 "NumberOfBytes") in
      make ?recipient ?customKeyStoreId ?numberOfBytes ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let recipient = field_map json__ "Recipient" RecipientInfo.of_json in
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      let numberOfBytes =
        field_map json__ "NumberOfBytes" NumberOfBytesType.of_json in
      make ?recipient ?customKeyStoreId ?numberOfBytes ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a random byte string that is cryptographically secure. You must use the NumberOfBytes parameter to specify the length of the random byte string. There is no default value for string length. By default, the random byte string is generated in KMS. To generate the byte string in the CloudHSM cluster associated with an CloudHSM key store, use the CustomKeyStoreId parameter. GenerateRandom also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateRandom for a Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. Instead of plaintext bytes, the response includes the plaintext bytes encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. For more information about entropy and random number generation, see Entropy and random number generation in the Key Management Service Developer Guide. Cross-account use: Not applicable. GenerateRandom does not use any account-specific resources, such as KMS keys. Required permissions: kms:GenerateRandom (IAM policy) Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateMacResponse =
  struct
    type nonrec t =
      {
      mac: CiphertextType.t option
        [@ocaml.doc
          "The hash-based message authentication code (HMAC) that was generated for the specified message, HMAC KMS key, and MAC algorithm. This is the standard, raw HMAC defined in RFC 2104."];
      macAlgorithm: MacAlgorithmSpec.t option
        [@ocaml.doc "The MAC algorithm that was used to generate the HMAC."];
      keyId: KeyIdType.t option
        [@ocaml.doc "The HMAC KMS key used in the operation."]}
    type nonrec error =
      [ `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?mac =
      fun ?macAlgorithm ->
        fun ?keyId -> fun () -> { mac; macAlgorithm; keyId }
    let error_of_json name json =
      match name with
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("Mac", (Option.map x.mac ~f:CiphertextType.to_value));
        ("MacAlgorithm",
          (Option.map x.macAlgorithm ~f:MacAlgorithmSpec.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let macAlgorithm =
        (Option.map ~f:MacAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "MacAlgorithm") in
      let mac =
        (Option.map ~f:CiphertextType.of_xml) (Xml.child xml_arg0 "Mac") in
      make ?keyId ?macAlgorithm ?mac ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let macAlgorithm =
        field_map json__ "MacAlgorithm" MacAlgorithmSpec.of_json in
      let mac = field_map json__ "Mac" CiphertextType.of_json in
      make ?keyId ?macAlgorithm ?mac ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Generates a hash-based message authentication code (HMAC) for a message using an HMAC KMS key and a MAC algorithm that the key supports. HMAC KMS keys and the HMAC algorithms that KMS uses conform to industry standards defined in RFC 2104. You can use value that GenerateMac returns in the VerifyMac operation to demonstrate that the original message has not changed. Also, because a secret key is used to create the hash, you can verify that the party that generated the hash has the required secret key. You can also use the raw result to implement HMAC-based algorithms such as key derivation functions. This operation is part of KMS support for HMAC KMS keys. For details, see HMAC keys in KMS in the Key Management Service Developer Guide . Best practices recommend that you limit the time during which any signing mechanism, including an HMAC, is effective. This deters an attack where the actor uses a signed message to establish validity repeatedly or long after the message is superseded. HMAC tags do not include a timestamp, but you can include a timestamp in the token or message to help you detect when its time to refresh the HMAC. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateMac (key policy) Related operations: VerifyMac Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateMacRequest =
  struct
    type nonrec t =
      {
      message: PlaintextType.t
        [@ocaml.doc
          "The message to be hashed. Specify a message of up to 4,096 bytes. GenerateMac and VerifyMac do not provide special handling for message digests. If you generate an HMAC for a hash digest of a message, you must verify the HMAC of the same hash digest."];
      keyId: KeyIdType.t
        [@ocaml.doc
          "The HMAC KMS key to use in the operation. The MAC algorithm computes the HMAC for the message and the key as described in RFC 2104. To identify an HMAC KMS key, use the DescribeKey operation and see the KeySpec field in the response."];
      macAlgorithm: MacAlgorithmSpec.t
        [@ocaml.doc
          "The MAC algorithm used in the operation. The algorithm must be compatible with the HMAC KMS key that you specify. To find the MAC algorithms that your HMAC KMS key supports, use the DescribeKey operation and see the MacAlgorithms field in the DescribeKey response."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "GenerateMacRequest"
    let make ?grantTokens =
      fun ?dryRun ->
        fun ~message ->
          fun ~keyId ->
            fun ~macAlgorithm ->
              fun () -> { grantTokens; dryRun; message; keyId; macAlgorithm }
    let to_value x =
      structure_to_value
        [("Message", (Some (PlaintextType.to_value x.message)));
        ("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("MacAlgorithm", (Some (MacAlgorithmSpec.to_value x.macAlgorithm)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let macAlgorithm =
        MacAlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "MacAlgorithm") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      let message =
        PlaintextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Message") in
      make ?dryRun ?grantTokens ~macAlgorithm ~keyId ~message ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let macAlgorithm =
        field_map_exn json__ "MacAlgorithm" MacAlgorithmSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      let message = field_map_exn json__ "Message" PlaintextType.of_json in
      make ?dryRun ?grantTokens ~macAlgorithm ~keyId ~message ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Generates a hash-based message authentication code (HMAC) for a message using an HMAC KMS key and a MAC algorithm that the key supports. HMAC KMS keys and the HMAC algorithms that KMS uses conform to industry standards defined in RFC 2104. You can use value that GenerateMac returns in the VerifyMac operation to demonstrate that the original message has not changed. Also, because a secret key is used to create the hash, you can verify that the party that generated the hash has the required secret key. You can also use the raw result to implement HMAC-based algorithms such as key derivation functions. This operation is part of KMS support for HMAC KMS keys. For details, see HMAC keys in KMS in the Key Management Service Developer Guide . Best practices recommend that you limit the time during which any signing mechanism, including an HMAC, is effective. This deters an attack where the actor uses a signed message to establish validity repeatedly or long after the message is superseded. HMAC tags do not include a timestamp, but you can include a timestamp in the token or message to help you detect when its time to refresh the HMAC. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateMac (key policy) Related operations: VerifyMac Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyWithoutPlaintextResponse =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The encrypted data key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to encrypt the data key."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?ciphertextBlob =
      fun ?keyId ->
        fun ?keyMaterialId ->
          fun () -> { ciphertextBlob; keyId; keyMaterialId }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?keyMaterialId ?keyId ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?keyMaterialId ?keyId ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique symmetric data key for use outside of KMS. This operation returns a data key that is encrypted under a symmetric encryption KMS key that you specify. The bytes in the key are random; they are not related to the caller or to the KMS key. GenerateDataKeyWithoutPlaintext is identical to the GenerateDataKey operation except that it does not return a plaintext copy of the data key. This operation is useful for systems that need to encrypt data at some point, but not immediately. When you need to encrypt the data, you call the Decrypt operation on the encrypted copy of the key. It's also useful in distributed systems with different levels of trust. For example, you might store encrypted data in containers. One component of your system creates new containers and stores an encrypted data key with each container. Then, a different component puts the data into the containers. That component first decrypts the data key, uses the plaintext data key to encrypt data, puts the encrypted data into the container, and then destroys the plaintext data key. In this system, the component that creates the containers never sees the plaintext data key. To request an asymmetric data key pair, use the GenerateDataKeyPair or GenerateDataKeyPairWithoutPlaintext operations. To generate a data key, you must specify the symmetric encryption KMS key that is used to encrypt the data key. You cannot use an asymmetric KMS key or a key in a custom key store to generate a data key. To get the type of your KMS key, use the DescribeKey operation. You must also specify the length of the data key. Use either the KeySpec or NumberOfBytes parameters (but not both). For 128-bit and 256-bit data keys, use the KeySpec parameter. To generate an SM4 data key (China Regions only), specify a KeySpec value of AES_128 or NumberOfBytes value of 16. The symmetric encryption key used in China Regions to encrypt your data key is an SM4 encryption key. If the operation succeeds, you will find the encrypted copy of the data key in the CiphertextBlob field. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyWithoutPlaintext (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyPairWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyWithoutPlaintextRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Specifies the symmetric encryption KMS key that encrypts the data key. You cannot specify an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context that will be used when encrypting the data key. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      keySpec: DataKeySpec.t option
        [@ocaml.doc
          "The length of the data key. Use AES_128 to generate a 128-bit symmetric key, or AES_256 to generate a 256-bit symmetric key."];
      numberOfBytes: NumberOfBytesType.t option
        [@ocaml.doc
          "The length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). For common key lengths (128-bit and 256-bit symmetric keys), we recommend that you use the KeySpec field instead of this one."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "GenerateDataKeyWithoutPlaintextRequest"
    let make ?encryptionContext =
      fun ?keySpec ->
        fun ?numberOfBytes ->
          fun ?grantTokens ->
            fun ?dryRun ->
              fun ~keyId ->
                fun () ->
                  {
                    encryptionContext;
                    keySpec;
                    numberOfBytes;
                    grantTokens;
                    dryRun;
                    keyId
                  }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("EncryptionContext",
          (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("KeySpec", (Option.map x.keySpec ~f:DataKeySpec.to_value));
        ("NumberOfBytes",
          (Option.map x.numberOfBytes ~f:NumberOfBytesType.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let numberOfBytes =
        (Option.map ~f:NumberOfBytesType.of_xml)
          (Xml.child xml_arg0 "NumberOfBytes") in
      let keySpec =
        (Option.map ~f:DataKeySpec.of_xml) (Xml.child xml_arg0 "KeySpec") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ?grantTokens ?numberOfBytes ?keySpec ?encryptionContext
        ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let numberOfBytes =
        field_map json__ "NumberOfBytes" NumberOfBytesType.of_json in
      let keySpec = field_map json__ "KeySpec" DataKeySpec.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ?grantTokens ?numberOfBytes ?keySpec ?encryptionContext
        ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique symmetric data key for use outside of KMS. This operation returns a data key that is encrypted under a symmetric encryption KMS key that you specify. The bytes in the key are random; they are not related to the caller or to the KMS key. GenerateDataKeyWithoutPlaintext is identical to the GenerateDataKey operation except that it does not return a plaintext copy of the data key. This operation is useful for systems that need to encrypt data at some point, but not immediately. When you need to encrypt the data, you call the Decrypt operation on the encrypted copy of the key. It's also useful in distributed systems with different levels of trust. For example, you might store encrypted data in containers. One component of your system creates new containers and stores an encrypted data key with each container. Then, a different component puts the data into the containers. That component first decrypts the data key, uses the plaintext data key to encrypt data, puts the encrypted data into the container, and then destroys the plaintext data key. In this system, the component that creates the containers never sees the plaintext data key. To request an asymmetric data key pair, use the GenerateDataKeyPair or GenerateDataKeyPairWithoutPlaintext operations. To generate a data key, you must specify the symmetric encryption KMS key that is used to encrypt the data key. You cannot use an asymmetric KMS key or a key in a custom key store to generate a data key. To get the type of your KMS key, use the DescribeKey operation. You must also specify the length of the data key. Use either the KeySpec or NumberOfBytes parameters (but not both). For 128-bit and 256-bit data keys, use the KeySpec parameter. To generate an SM4 data key (China Regions only), specify a KeySpec value of AES_128 or NumberOfBytes value of 16. The symmetric encryption key used in China Regions to encrypt your data key is an SM4 encryption key. If the operation succeeds, you will find the encrypted copy of the data key in the CiphertextBlob field. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyWithoutPlaintext (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyPairWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyResponse =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The encrypted copy of the data key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      plaintext: PlaintextType.t option
        [@ocaml.doc
          "The plaintext data key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded. Use this data key to encrypt your data outside of KMS. Then, remove it from memory as soon as possible. If the response includes the CiphertextForRecipient field, the Plaintext field is null or empty."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key."];
      ciphertextForRecipient: CiphertextType.t option
        [@ocaml.doc
          "The plaintext data key encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment. This field is included in the response only when the Recipient parameter in the request includes a valid attestation document from an Amazon Web Services Nitro enclave or NitroTPM. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to encrypt the data key. This field is omitted if the request includes the Recipient parameter."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?ciphertextBlob =
      fun ?plaintext ->
        fun ?keyId ->
          fun ?ciphertextForRecipient ->
            fun ?keyMaterialId ->
              fun () ->
                {
                  ciphertextBlob;
                  plaintext;
                  keyId;
                  ciphertextForRecipient;
                  keyMaterialId
                }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("Plaintext", (Option.map x.plaintext ~f:PlaintextType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("CiphertextForRecipient",
          (Option.map x.ciphertextForRecipient ~f:CiphertextType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let ciphertextForRecipient =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextForRecipient") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let plaintext =
        (Option.map ~f:PlaintextType.of_xml) (Xml.child xml_arg0 "Plaintext") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?keyMaterialId ?ciphertextForRecipient ?keyId ?plaintext
        ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let ciphertextForRecipient =
        field_map json__ "CiphertextForRecipient" CiphertextType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let plaintext = field_map json__ "Plaintext" PlaintextType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?keyMaterialId ?ciphertextForRecipient ?keyId ?plaintext
        ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique symmetric data key for use outside of KMS. This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify. The bytes in the plaintext key are random; they are not related to the caller or the KMS key. You can use the plaintext key to encrypt your data outside of KMS and store the encrypted data key with the encrypted data. To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key. You cannot use an asymmetric KMS key to encrypt data keys. To get the type of your KMS key, use the DescribeKey operation. You must also specify the length of the data key. Use either the KeySpec or NumberOfBytes parameters (but not both). For 128-bit and 256-bit data keys, use the KeySpec parameter. To generate a 128-bit SM4 data key (China Regions only), specify a KeySpec value of AES_128 or a NumberOfBytes value of 16. The symmetric encryption key used in China Regions to encrypt your data key is an SM4 encryption key. To get only an encrypted copy of the data key, use GenerateDataKeyWithoutPlaintext. To generate an asymmetric data key pair, use the GenerateDataKeyPair or GenerateDataKeyPairWithoutPlaintext operation. To get a cryptographically secure random byte string, use GenerateRandom. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. GenerateDataKey also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateDataKey for an Amazon Web Services Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. GenerateDataKey returns a copy of the data key encrypted under the specified KMS key, as usual. But instead of a plaintext copy of the data key, the response includes a copy of the data key encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. How to use your data key We recommend that you use the following pattern to encrypt data locally in your application. You can write your own code or use a client-side encryption library, such as the Amazon Web Services Encryption SDK, the Amazon DynamoDB Encryption Client, or Amazon S3 client-side encryption to do these tasks for you. To encrypt data outside of KMS: Use the GenerateDataKey operation to get a data key. Use the plaintext data key (in the Plaintext field of the response) to encrypt your data outside of KMS. Then erase the plaintext data key from memory. Store the encrypted data key (in the CiphertextBlob field of the response) with the encrypted data. To decrypt data outside of KMS: Use the Decrypt operation to decrypt the encrypted data key. The operation returns a plaintext copy of the data key. Use the plaintext data key to decrypt data outside of KMS, then erase the plaintext data key from memory. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKey (key policy) Related operations: Decrypt Encrypt GenerateDataKeyPair GenerateDataKeyPairWithoutPlaintext GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Specifies the symmetric encryption KMS key that encrypts the data key. You cannot specify an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context that will be used when encrypting the data key. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      numberOfBytes: NumberOfBytesType.t option
        [@ocaml.doc
          "Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). For 128-bit (16-byte) and 256-bit (32-byte) data keys, use the KeySpec parameter. You must specify either the KeySpec or the NumberOfBytes parameter (but not both) in every GenerateDataKey request."];
      keySpec: DataKeySpec.t option
        [@ocaml.doc
          "Specifies the length of the data key. Use AES_128 to generate a 128-bit symmetric key, or AES_256 to generate a 256-bit symmetric key. You must specify either the KeySpec or the NumberOfBytes parameter (but not both) in every GenerateDataKey request."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      recipient: RecipientInfo.t option
        [@ocaml.doc
          "A signed attestation document from an Amazon Web Services Nitro enclave or NitroTPM, and the encryption algorithm to use with the public key in the attestation document. The only valid encryption algorithm is RSAES_OAEP_SHA_256. This parameter supports the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK for Amazon Web Services Nitro Enclaves. It supports any Amazon Web Services SDK for Amazon Web Services NitroTPM. When you use this parameter, instead of returning the plaintext data key, KMS encrypts the plaintext data key under the public key in the attestation document, and returns the resulting ciphertext in the CiphertextForRecipient field in the response. This ciphertext can be decrypted only with the private key in the enclave. The CiphertextBlob field in the response contains a copy of the data key encrypted under the KMS key specified by the KeyId parameter. The Plaintext field in the response is null or empty. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "GenerateDataKeyRequest"
    let make ?encryptionContext =
      fun ?numberOfBytes ->
        fun ?keySpec ->
          fun ?grantTokens ->
            fun ?recipient ->
              fun ?dryRun ->
                fun ~keyId ->
                  fun () ->
                    {
                      encryptionContext;
                      numberOfBytes;
                      keySpec;
                      grantTokens;
                      recipient;
                      dryRun;
                      keyId
                    }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("EncryptionContext",
          (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("NumberOfBytes",
          (Option.map x.numberOfBytes ~f:NumberOfBytesType.to_value));
        ("KeySpec", (Option.map x.keySpec ~f:DataKeySpec.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("Recipient", (Option.map x.recipient ~f:RecipientInfo.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let recipient =
        (Option.map ~f:RecipientInfo.of_xml) (Xml.child xml_arg0 "Recipient") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let keySpec =
        (Option.map ~f:DataKeySpec.of_xml) (Xml.child xml_arg0 "KeySpec") in
      let numberOfBytes =
        (Option.map ~f:NumberOfBytesType.of_xml)
          (Xml.child xml_arg0 "NumberOfBytes") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ?recipient ?grantTokens ?keySpec ?numberOfBytes
        ?encryptionContext ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let recipient = field_map json__ "Recipient" RecipientInfo.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let keySpec = field_map json__ "KeySpec" DataKeySpec.of_json in
      let numberOfBytes =
        field_map json__ "NumberOfBytes" NumberOfBytesType.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ?recipient ?grantTokens ?keySpec ?numberOfBytes
        ?encryptionContext ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique symmetric data key for use outside of KMS. This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify. The bytes in the plaintext key are random; they are not related to the caller or the KMS key. You can use the plaintext key to encrypt your data outside of KMS and store the encrypted data key with the encrypted data. To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key. You cannot use an asymmetric KMS key to encrypt data keys. To get the type of your KMS key, use the DescribeKey operation. You must also specify the length of the data key. Use either the KeySpec or NumberOfBytes parameters (but not both). For 128-bit and 256-bit data keys, use the KeySpec parameter. To generate a 128-bit SM4 data key (China Regions only), specify a KeySpec value of AES_128 or a NumberOfBytes value of 16. The symmetric encryption key used in China Regions to encrypt your data key is an SM4 encryption key. To get only an encrypted copy of the data key, use GenerateDataKeyWithoutPlaintext. To generate an asymmetric data key pair, use the GenerateDataKeyPair or GenerateDataKeyPairWithoutPlaintext operation. To get a cryptographically secure random byte string, use GenerateRandom. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. GenerateDataKey also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateDataKey for an Amazon Web Services Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. GenerateDataKey returns a copy of the data key encrypted under the specified KMS key, as usual. But instead of a plaintext copy of the data key, the response includes a copy of the data key encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. How to use your data key We recommend that you use the following pattern to encrypt data locally in your application. You can write your own code or use a client-side encryption library, such as the Amazon Web Services Encryption SDK, the Amazon DynamoDB Encryption Client, or Amazon S3 client-side encryption to do these tasks for you. To encrypt data outside of KMS: Use the GenerateDataKey operation to get a data key. Use the plaintext data key (in the Plaintext field of the response) to encrypt your data outside of KMS. Then erase the plaintext data key from memory. Store the encrypted data key (in the CiphertextBlob field of the response) with the encrypted data. To decrypt data outside of KMS: Use the Decrypt operation to decrypt the encrypted data key. The operation returns a plaintext copy of the data key. Use the plaintext data key to decrypt data outside of KMS, then erase the plaintext data key from memory. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKey (key policy) Related operations: Decrypt Encrypt GenerateDataKeyPair GenerateDataKeyPairWithoutPlaintext GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyPairWithoutPlaintextResponse =
  struct
    type nonrec t =
      {
      privateKeyCiphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The encrypted copy of the private key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      publicKey: PublicKeyType.t option
        [@ocaml.doc
          "The public key (in plaintext). When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that encrypted the private key."];
      keyPairSpec: DataKeyPairSpec.t option
        [@ocaml.doc "The type of data key pair that was generated."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to encrypt the private key."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?privateKeyCiphertextBlob =
      fun ?publicKey ->
        fun ?keyId ->
          fun ?keyPairSpec ->
            fun ?keyMaterialId ->
              fun () ->
                {
                  privateKeyCiphertextBlob;
                  publicKey;
                  keyId;
                  keyPairSpec;
                  keyMaterialId
                }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("PrivateKeyCiphertextBlob",
           (Option.map x.privateKeyCiphertextBlob ~f:CiphertextType.to_value));
        ("PublicKey", (Option.map x.publicKey ~f:PublicKeyType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyPairSpec",
          (Option.map x.keyPairSpec ~f:DataKeyPairSpec.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyPairSpec =
        (Option.map ~f:DataKeyPairSpec.of_xml)
          (Xml.child xml_arg0 "KeyPairSpec") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let publicKey =
        (Option.map ~f:PublicKeyType.of_xml) (Xml.child xml_arg0 "PublicKey") in
      let privateKeyCiphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "PrivateKeyCiphertextBlob") in
      make ?keyMaterialId ?keyPairSpec ?keyId ?publicKey
        ?privateKeyCiphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyPairSpec =
        field_map json__ "KeyPairSpec" DataKeyPairSpec.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let publicKey = field_map json__ "PublicKey" PublicKeyType.of_json in
      let privateKeyCiphertextBlob =
        field_map json__ "PrivateKeyCiphertextBlob" CiphertextType.of_json in
      make ?keyMaterialId ?keyPairSpec ?keyId ?publicKey
        ?privateKeyCiphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique asymmetric data key pair for use outside of KMS. This operation returns a plaintext public key and a copy of the private key that is encrypted under the symmetric encryption KMS key you specify. Unlike GenerateDataKeyPair, this operation does not return a plaintext private key. The bytes in the keys are random; they are not related to the caller or to the KMS key that is used to encrypt the private key. You can use the public key that GenerateDataKeyPairWithoutPlaintext returns to encrypt data or verify a signature outside of KMS. Then, store the encrypted private key with the data. When you are ready to decrypt data or sign a message, you can use the Decrypt operation to decrypt the encrypted private key. To generate a data key pair, you must specify a symmetric encryption KMS key to encrypt the private key in a data key pair. You cannot use an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. Use the KeyPairSpec parameter to choose an RSA or Elliptic Curve (ECC) data key pair. In China Regions, you can also choose an SM2 data key pair. KMS recommends that you use ECC key pairs for signing, and use RSA and SM2 key pairs for either encryption or signing, but not both. However, KMS cannot enforce any restrictions on the use of data key pairs outside of KMS. GenerateDataKeyPairWithoutPlaintext returns a unique data key pair for each request. The bytes in the key are not related to the caller or KMS key that is used to encrypt the private key. The public key is a DER-encoded X.509 SubjectPublicKeyInfo, as specified in RFC 5280. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyPairWithoutPlaintext (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyPairWithoutPlaintextRequest =
  struct
    type nonrec t =
      {
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context that will be used when encrypting the private key in the data key pair. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      keyId: KeyIdType.t
        [@ocaml.doc
          "Specifies the symmetric encryption KMS key that encrypts the private key in the data key pair. You cannot specify an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      keyPairSpec: DataKeyPairSpec.t
        [@ocaml.doc
          "Determines the type of data key pair that is generated. The KMS rule that restricts the use of asymmetric RSA and SM2 KMS keys to encrypt and decrypt or to sign and verify (but not both), the rule that permits you to use ECC KMS keys only to sign and verify, and the rule that permits you to use ML-DSA key pairs to sign and verify only are not effective on data key pairs, which are used outside of KMS. The SM2 key spec is only available in China Regions."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "GenerateDataKeyPairWithoutPlaintextRequest"
    let make ?encryptionContext =
      fun ?grantTokens ->
        fun ?dryRun ->
          fun ~keyId ->
            fun ~keyPairSpec ->
              fun () ->
                { encryptionContext; grantTokens; dryRun; keyId; keyPairSpec
                }
    let to_value x =
      structure_to_value
        [("EncryptionContext",
           (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("KeyPairSpec", (Some (DataKeyPairSpec.to_value x.keyPairSpec)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let keyPairSpec =
        DataKeyPairSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "KeyPairSpec") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      make ?dryRun ?grantTokens ~keyPairSpec ~keyId ?encryptionContext ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let keyPairSpec =
        field_map_exn json__ "KeyPairSpec" DataKeyPairSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      make ?dryRun ?grantTokens ~keyPairSpec ~keyId ?encryptionContext ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique asymmetric data key pair for use outside of KMS. This operation returns a plaintext public key and a copy of the private key that is encrypted under the symmetric encryption KMS key you specify. Unlike GenerateDataKeyPair, this operation does not return a plaintext private key. The bytes in the keys are random; they are not related to the caller or to the KMS key that is used to encrypt the private key. You can use the public key that GenerateDataKeyPairWithoutPlaintext returns to encrypt data or verify a signature outside of KMS. Then, store the encrypted private key with the data. When you are ready to decrypt data or sign a message, you can use the Decrypt operation to decrypt the encrypted private key. To generate a data key pair, you must specify a symmetric encryption KMS key to encrypt the private key in a data key pair. You cannot use an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. Use the KeyPairSpec parameter to choose an RSA or Elliptic Curve (ECC) data key pair. In China Regions, you can also choose an SM2 data key pair. KMS recommends that you use ECC key pairs for signing, and use RSA and SM2 key pairs for either encryption or signing, but not both. However, KMS cannot enforce any restrictions on the use of data key pairs outside of KMS. GenerateDataKeyPairWithoutPlaintext returns a unique data key pair for each request. The bytes in the key are not related to the caller or KMS key that is used to encrypt the private key. The public key is a DER-encoded X.509 SubjectPublicKeyInfo, as specified in RFC 5280. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyPairWithoutPlaintext (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyPairResponse =
  struct
    type nonrec t =
      {
      privateKeyCiphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The encrypted copy of the private key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      privateKeyPlaintext: PlaintextType.t option
        [@ocaml.doc
          "The plaintext copy of the private key. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded. If the response includes the CiphertextForRecipient field, the PrivateKeyPlaintext field is null or empty."];
      publicKey: PublicKeyType.t option
        [@ocaml.doc
          "The public key (in plaintext). When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that encrypted the private key."];
      keyPairSpec: DataKeyPairSpec.t option
        [@ocaml.doc "The type of data key pair that was generated."];
      ciphertextForRecipient: CiphertextType.t option
        [@ocaml.doc
          "The plaintext private data key encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment. This field is included in the response only when the Recipient parameter in the request includes a valid attestation document from an Amazon Web Services Nitro enclave or NitroTPM. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to encrypt the private key."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?privateKeyCiphertextBlob =
      fun ?privateKeyPlaintext ->
        fun ?publicKey ->
          fun ?keyId ->
            fun ?keyPairSpec ->
              fun ?ciphertextForRecipient ->
                fun ?keyMaterialId ->
                  fun () ->
                    {
                      privateKeyCiphertextBlob;
                      privateKeyPlaintext;
                      publicKey;
                      keyId;
                      keyPairSpec;
                      ciphertextForRecipient;
                      keyMaterialId
                    }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("PrivateKeyCiphertextBlob",
           (Option.map x.privateKeyCiphertextBlob ~f:CiphertextType.to_value));
        ("PrivateKeyPlaintext",
          (Option.map x.privateKeyPlaintext ~f:PlaintextType.to_value));
        ("PublicKey", (Option.map x.publicKey ~f:PublicKeyType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyPairSpec",
          (Option.map x.keyPairSpec ~f:DataKeyPairSpec.to_value));
        ("CiphertextForRecipient",
          (Option.map x.ciphertextForRecipient ~f:CiphertextType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let ciphertextForRecipient =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextForRecipient") in
      let keyPairSpec =
        (Option.map ~f:DataKeyPairSpec.of_xml)
          (Xml.child xml_arg0 "KeyPairSpec") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let publicKey =
        (Option.map ~f:PublicKeyType.of_xml) (Xml.child xml_arg0 "PublicKey") in
      let privateKeyPlaintext =
        (Option.map ~f:PlaintextType.of_xml)
          (Xml.child xml_arg0 "PrivateKeyPlaintext") in
      let privateKeyCiphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "PrivateKeyCiphertextBlob") in
      make ?keyMaterialId ?ciphertextForRecipient ?keyPairSpec ?keyId
        ?publicKey ?privateKeyPlaintext ?privateKeyCiphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let ciphertextForRecipient =
        field_map json__ "CiphertextForRecipient" CiphertextType.of_json in
      let keyPairSpec =
        field_map json__ "KeyPairSpec" DataKeyPairSpec.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let publicKey = field_map json__ "PublicKey" PublicKeyType.of_json in
      let privateKeyPlaintext =
        field_map json__ "PrivateKeyPlaintext" PlaintextType.of_json in
      let privateKeyCiphertextBlob =
        field_map json__ "PrivateKeyCiphertextBlob" CiphertextType.of_json in
      make ?keyMaterialId ?ciphertextForRecipient ?keyPairSpec ?keyId
        ?publicKey ?privateKeyPlaintext ?privateKeyCiphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique asymmetric data key pair for use outside of KMS. This operation returns a plaintext public key, a plaintext private key, and a copy of the private key that is encrypted under the symmetric encryption KMS key you specify. You can use the data key pair to perform asymmetric cryptography and implement digital signatures outside of KMS. The bytes in the keys are random; they are not related to the caller or to the KMS key that is used to encrypt the private key. You can use the public key that GenerateDataKeyPair returns to encrypt data or verify a signature outside of KMS. Then, store the encrypted private key with the data. When you are ready to decrypt data or sign a message, you can use the Decrypt operation to decrypt the encrypted private key. To generate a data key pair, you must specify a symmetric encryption KMS key to encrypt the private key in a data key pair. You cannot use an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. Use the KeyPairSpec parameter to choose an RSA or Elliptic Curve (ECC) data key pair. In China Regions, you can also choose an SM2 data key pair. KMS recommends that you use ECC key pairs for signing, and use RSA and SM2 key pairs for either encryption or signing, but not both. However, KMS cannot enforce any restrictions on the use of data key pairs outside of KMS. If you are using the data key pair to encrypt data, or for any operation where you don't immediately need a private key, consider using the GenerateDataKeyPairWithoutPlaintext operation. GenerateDataKeyPairWithoutPlaintext returns a plaintext public key and an encrypted private key, but omits the plaintext private key that you need only to decrypt ciphertext or sign a message. Later, when you need to decrypt the data or sign a message, use the Decrypt operation to decrypt the encrypted private key in the data key pair. GenerateDataKeyPair returns a unique data key pair for each request. The bytes in the keys are random; they are not related to the caller or the KMS key that is used to encrypt the private key. The public key is a DER-encoded X.509 SubjectPublicKeyInfo, as specified in RFC 5280. The private key is a DER-encoded PKCS8 PrivateKeyInfo, as specified in RFC 5958. GenerateDataKeyPair also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateDataKeyPair for an Amazon Web Services Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. GenerateDataKeyPair returns the public data key and a copy of the private data key encrypted under the specified KMS key, as usual. But instead of a plaintext copy of the private data key (PrivateKeyPlaintext), the response includes a copy of the private data key encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyPair (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPairWithoutPlaintext GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module GenerateDataKeyPairRequest =
  struct
    type nonrec t =
      {
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context that will be used when encrypting the private key in the data key pair. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      keyId: KeyIdType.t
        [@ocaml.doc
          "Specifies the symmetric encryption KMS key that encrypts the private key in the data key pair. You cannot specify an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      keyPairSpec: DataKeyPairSpec.t
        [@ocaml.doc
          "Determines the type of data key pair that is generated. The KMS rule that restricts the use of asymmetric RSA and SM2 KMS keys to encrypt and decrypt or to sign and verify (but not both), the rule that permits you to use ECC KMS keys only to sign and verify, and the rule that permits you to use ML-DSA key pairs to sign and verify only are not effective on data key pairs, which are used outside of KMS. The SM2 key spec is only available in China Regions."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      recipient: RecipientInfo.t option
        [@ocaml.doc
          "A signed attestation document from an Amazon Web Services Nitro enclave or NitroTPM, and the encryption algorithm to use with the public key in the attestation document. The only valid encryption algorithm is RSAES_OAEP_SHA_256. This parameter only supports attestation documents for Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM. To call GenerateDataKeyPair generate an attestation document use either Amazon Web Services Nitro Enclaves SDK for an Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM tools for Amazon Web Services NitroTPM. Then use the Recipient parameter from any Amazon Web Services SDK to provide the attestation document for the attested environment. When you use this parameter, instead of returning a plaintext copy of the private data key, KMS encrypts the plaintext private data key under the public key in the attestation document, and returns the resulting ciphertext in the CiphertextForRecipient field in the response. This ciphertext can be decrypted only with the private key in the attested environment. The CiphertextBlob field in the response contains a copy of the private data key encrypted under the KMS key specified by the KeyId parameter. The PrivateKeyPlaintext field in the response is null or empty. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "GenerateDataKeyPairRequest"
    let make ?encryptionContext =
      fun ?grantTokens ->
        fun ?recipient ->
          fun ?dryRun ->
            fun ~keyId ->
              fun ~keyPairSpec ->
                fun () ->
                  {
                    encryptionContext;
                    grantTokens;
                    recipient;
                    dryRun;
                    keyId;
                    keyPairSpec
                  }
    let to_value x =
      structure_to_value
        [("EncryptionContext",
           (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("KeyPairSpec", (Some (DataKeyPairSpec.to_value x.keyPairSpec)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("Recipient", (Option.map x.recipient ~f:RecipientInfo.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let recipient =
        (Option.map ~f:RecipientInfo.of_xml) (Xml.child xml_arg0 "Recipient") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let keyPairSpec =
        DataKeyPairSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "KeyPairSpec") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      make ?dryRun ?recipient ?grantTokens ~keyPairSpec ~keyId
        ?encryptionContext ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let recipient = field_map json__ "Recipient" RecipientInfo.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let keyPairSpec =
        field_map_exn json__ "KeyPairSpec" DataKeyPairSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      make ?dryRun ?recipient ?grantTokens ~keyPairSpec ~keyId
        ?encryptionContext ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Returns a unique asymmetric data key pair for use outside of KMS. This operation returns a plaintext public key, a plaintext private key, and a copy of the private key that is encrypted under the symmetric encryption KMS key you specify. You can use the data key pair to perform asymmetric cryptography and implement digital signatures outside of KMS. The bytes in the keys are random; they are not related to the caller or to the KMS key that is used to encrypt the private key. You can use the public key that GenerateDataKeyPair returns to encrypt data or verify a signature outside of KMS. Then, store the encrypted private key with the data. When you are ready to decrypt data or sign a message, you can use the Decrypt operation to decrypt the encrypted private key. To generate a data key pair, you must specify a symmetric encryption KMS key to encrypt the private key in a data key pair. You cannot use an asymmetric KMS key or a KMS key in a custom key store. To get the type and origin of your KMS key, use the DescribeKey operation. Use the KeyPairSpec parameter to choose an RSA or Elliptic Curve (ECC) data key pair. In China Regions, you can also choose an SM2 data key pair. KMS recommends that you use ECC key pairs for signing, and use RSA and SM2 key pairs for either encryption or signing, but not both. However, KMS cannot enforce any restrictions on the use of data key pairs outside of KMS. If you are using the data key pair to encrypt data, or for any operation where you don't immediately need a private key, consider using the GenerateDataKeyPairWithoutPlaintext operation. GenerateDataKeyPairWithoutPlaintext returns a plaintext public key and an encrypted private key, but omits the plaintext private key that you need only to decrypt ciphertext or sign a message. Later, when you need to decrypt the data or sign a message, use the Decrypt operation to decrypt the encrypted private key in the data key pair. GenerateDataKeyPair returns a unique data key pair for each request. The bytes in the keys are random; they are not related to the caller or the KMS key that is used to encrypt the private key. The public key is a DER-encoded X.509 SubjectPublicKeyInfo, as specified in RFC 5280. The private key is a DER-encoded PKCS8 PrivateKeyInfo, as specified in RFC 5958. GenerateDataKeyPair also supports Amazon Web Services Nitro Enclaves, which provide an isolated compute environment in Amazon EC2. To call GenerateDataKeyPair for an Amazon Web Services Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. GenerateDataKeyPair returns the public data key and a copy of the private data key encrypted under the specified KMS key, as usual. But instead of a plaintext copy of the private data key (PrivateKeyPlaintext), the response includes a copy of the private data key encrypted under the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. You can use an optional encryption context to add additional security to the encryption operation. If you specify an EncryptionContext, you must specify the same encryption context (a case-sensitive exact match) when decrypting the encrypted data key. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:GenerateDataKeyPair (key policy) Related operations: Decrypt Encrypt GenerateDataKey GenerateDataKeyPairWithoutPlaintext GenerateDataKeyWithoutPlaintext Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module EncryptResponse =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "The encrypted plaintext. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that was used to encrypt the plaintext."];
      encryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "The encryption algorithm that was used to encrypt the plaintext."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?ciphertextBlob =
      fun ?keyId ->
        fun ?encryptionAlgorithm ->
          fun () -> { ciphertextBlob; keyId; encryptionAlgorithm }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("EncryptionAlgorithm",
          (Option.map x.encryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let encryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithm") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?encryptionAlgorithm ?keyId ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let encryptionAlgorithm =
        field_map json__ "EncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?encryptionAlgorithm ?keyId ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Encrypts plaintext of up to 4,096 bytes using a KMS key. You can use a symmetric or asymmetric KMS key with a KeyUsage of ENCRYPT_DECRYPT. You can use this operation to encrypt small amounts of arbitrary data, such as a personal identifier or database password, or other sensitive information. You don't need to use the Encrypt operation to encrypt a data key. The GenerateDataKey and GenerateDataKeyPair operations return a plaintext data key and an encrypted copy of that data key. If you use a symmetric encryption KMS key, you can use an encryption context to add additional security to your encryption operation. If you specify an EncryptionContext when encrypting data, you must specify the same encryption context (a case-sensitive exact match) when decrypting the data. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. If you specify an asymmetric KMS key, you must also specify the encryption algorithm. The algorithm must be compatible with the KMS key spec. When you use an asymmetric KMS key to encrypt or reencrypt data, be sure to record the KMS key and encryption algorithm that you choose. You will be required to provide the same KMS key and encryption algorithm when you decrypt the data. If the KMS key and algorithm do not match the values used to encrypt the data, the decrypt operation fails. You are not required to supply the key ID and encryption algorithm when you decrypt with symmetric encryption KMS keys because KMS stores this information in the ciphertext blob. KMS cannot store metadata in ciphertext generated with asymmetric keys. The standard format for asymmetric key ciphertext does not include configurable fields. The maximum size of the data that you can encrypt varies with the type of KMS key and the encryption algorithm that you choose. Symmetric encryption KMS keys SYMMETRIC_DEFAULT: 4096 bytes RSA_2048 RSAES_OAEP_SHA_1: 214 bytes RSAES_OAEP_SHA_256: 190 bytes RSA_3072 RSAES_OAEP_SHA_1: 342 bytes RSAES_OAEP_SHA_256: 318 bytes RSA_4096 RSAES_OAEP_SHA_1: 470 bytes RSAES_OAEP_SHA_256: 446 bytes SM2PKE: 1024 bytes (China Regions only) The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Encrypt (key policy) Related operations: Decrypt GenerateDataKey GenerateDataKeyPair Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module EncryptRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key to use in the encryption operation. The KMS key must have a KeyUsage of ENCRYPT_DECRYPT. To find the KeyUsage of a KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      plaintext: PlaintextType.t [@ocaml.doc "Data to be encrypted."];
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context that will be used to encrypt the data. An encryption context is valid only for cryptographic operations with a symmetric encryption KMS key. The standard asymmetric encryption algorithms and HMAC algorithms that KMS uses do not support an encryption context. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      encryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "Specifies the encryption algorithm that KMS will use to encrypt the plaintext message. The algorithm must be compatible with the KMS key that you specify. This parameter is required only for asymmetric KMS keys. The default value, SYMMETRIC_DEFAULT, is the algorithm used for symmetric encryption KMS keys. If you are using an asymmetric KMS key, we recommend RSAES_OAEP_SHA_256. The SM2PKE algorithm is only available in China Regions."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "EncryptRequest"
    let make ?encryptionContext =
      fun ?grantTokens ->
        fun ?encryptionAlgorithm ->
          fun ?dryRun ->
            fun ~keyId ->
              fun ~plaintext ->
                fun () ->
                  {
                    encryptionContext;
                    grantTokens;
                    encryptionAlgorithm;
                    dryRun;
                    keyId;
                    plaintext
                  }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("Plaintext", (Some (PlaintextType.to_value x.plaintext)));
        ("EncryptionContext",
          (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("EncryptionAlgorithm",
          (Option.map x.encryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let encryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithm") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      let plaintext =
        PlaintextType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Plaintext") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ?encryptionAlgorithm ?grantTokens ?encryptionContext
        ~plaintext ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let encryptionAlgorithm =
        field_map json__ "EncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      let plaintext = field_map_exn json__ "Plaintext" PlaintextType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ?encryptionAlgorithm ?grantTokens ?encryptionContext
        ~plaintext ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Encrypts plaintext of up to 4,096 bytes using a KMS key. You can use a symmetric or asymmetric KMS key with a KeyUsage of ENCRYPT_DECRYPT. You can use this operation to encrypt small amounts of arbitrary data, such as a personal identifier or database password, or other sensitive information. You don't need to use the Encrypt operation to encrypt a data key. The GenerateDataKey and GenerateDataKeyPair operations return a plaintext data key and an encrypted copy of that data key. If you use a symmetric encryption KMS key, you can use an encryption context to add additional security to your encryption operation. If you specify an EncryptionContext when encrypting data, you must specify the same encryption context (a case-sensitive exact match) when decrypting the data. Otherwise, the request to decrypt fails with an InvalidCiphertextException. For more information, see Encryption Context in the Key Management Service Developer Guide. If you specify an asymmetric KMS key, you must also specify the encryption algorithm. The algorithm must be compatible with the KMS key spec. When you use an asymmetric KMS key to encrypt or reencrypt data, be sure to record the KMS key and encryption algorithm that you choose. You will be required to provide the same KMS key and encryption algorithm when you decrypt the data. If the KMS key and algorithm do not match the values used to encrypt the data, the decrypt operation fails. You are not required to supply the key ID and encryption algorithm when you decrypt with symmetric encryption KMS keys because KMS stores this information in the ciphertext blob. KMS cannot store metadata in ciphertext generated with asymmetric keys. The standard format for asymmetric key ciphertext does not include configurable fields. The maximum size of the data that you can encrypt varies with the type of KMS key and the encryption algorithm that you choose. Symmetric encryption KMS keys SYMMETRIC_DEFAULT: 4096 bytes RSA_2048 RSAES_OAEP_SHA_1: 214 bytes RSAES_OAEP_SHA_256: 190 bytes RSA_3072 RSAES_OAEP_SHA_1: 342 bytes RSAES_OAEP_SHA_256: 318 bytes RSA_4096 RSAES_OAEP_SHA_1: 470 bytes RSAES_OAEP_SHA_256: 446 bytes SM2PKE: 1024 bytes (China Regions only) The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:Encrypt (key policy) Related operations: Decrypt GenerateDataKey GenerateDataKeyPair Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module EnableKeyRotationRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies a symmetric encryption KMS key. You cannot enable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      rotationPeriodInDays: RotationPeriodInDaysType.t option
        [@ocaml.doc
          "Use this parameter to specify a custom period of time between each rotation date. If no value is specified, the default value is 365 days. The rotation period defines the number of days after you enable automatic key rotation that KMS will rotate your key material, and the number of days between each automatic rotation thereafter. You can use the kms:RotationPeriodInDays condition key to further constrain the values that principals can specify in the RotationPeriodInDays parameter."]}
    let context_ = "EnableKeyRotationRequest"
    let make ?rotationPeriodInDays =
      fun ~keyId -> fun () -> { rotationPeriodInDays; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("RotationPeriodInDays",
          (Option.map x.rotationPeriodInDays
             ~f:RotationPeriodInDaysType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let rotationPeriodInDays =
        (Option.map ~f:RotationPeriodInDaysType.of_xml)
          (Xml.child xml_arg0 "RotationPeriodInDays") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?rotationPeriodInDays ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let rotationPeriodInDays =
        field_map json__ "RotationPeriodInDays"
          RotationPeriodInDaysType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?rotationPeriodInDays ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Enables automatic rotation of the key material of the specified symmetric encryption KMS key. By default, when you enable automatic rotation of a customer managed KMS key, KMS rotates the key material of the KMS key one year (approximately 365 days) from the enable date and every year thereafter. You can use the optional RotationPeriodInDays parameter to specify a custom rotation period when you enable key rotation, or you can use RotationPeriodInDays to modify the rotation period of a key that you previously enabled automatic key rotation on. You can monitor rotation of the key material for your KMS keys in CloudTrail and Amazon CloudWatch. To disable rotation of the key material in a customer managed KMS key, use the DisableKeyRotation operation. You can use the GetKeyRotationStatus operation to identify any in progress rotations. You can use the ListKeyRotations operation to view the details of completed rotations. Automatic key rotation is supported only on symmetric encryption KMS keys. You cannot enable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key. You cannot enable or disable automatic rotation of Amazon Web Services managed KMS keys. KMS always rotates the key material of Amazon Web Services managed keys every year. Rotation of Amazon Web Services owned KMS keys is managed by the Amazon Web Services service that owns the key. In May 2022, KMS changed the rotation schedule for Amazon Web Services managed keys from every three years (approximately 1,095 days) to every year (approximately 365 days). New Amazon Web Services managed keys are automatically rotated one year after they are created, and approximately every year thereafter. Existing Amazon Web Services managed keys are automatically rotated one year after their most recent rotation, and every year thereafter. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:EnableKeyRotation (key policy) Related operations: DisableKeyRotation GetKeyRotationStatus ListKeyRotations RotateKeyOnDemand You can perform on-demand (RotateKeyOnDemand) rotation of the key material in customer managed KMS keys, regardless of whether or not automatic key rotation is enabled. Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module EnableKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key to enable. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "EnableKeyRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Sets the key state of a KMS key to enabled. This allows you to use the KMS key for cryptographic operations. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:EnableKey (key policy) Related operations: DisableKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DisconnectCustomKeyStoreResponse =
  struct
    type nonrec t = unit
    type nonrec error =
      [
        `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make () = ()
    let error_of_json name json =
      match name with
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Disconnects the custom key store from its backing key store. This operation disconnects an CloudHSM key store from its associated CloudHSM cluster or disconnects an external key store from the external key store proxy that communicates with your external key manager. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. While a custom key store is disconnected, you can manage the custom key store and its KMS keys, but you cannot create or use its KMS keys. You can reconnect the custom key store at any time. While a custom key store is disconnected, all attempts to create KMS keys in the custom key store or to use existing KMS keys in cryptographic operations will fail. This action can prevent users from storing and accessing sensitive data. When you disconnect a custom key store, its ConnectionState changes to Disconnected. To find the connection state of a custom key store, use the DescribeCustomKeyStores operation. To reconnect a custom key store, use the ConnectCustomKeyStore operation. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DisconnectCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DisconnectCustomKeyStoreRequest =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t
        [@ocaml.doc
          "Enter the ID of the custom key store you want to disconnect. To find the ID of a custom key store, use the DescribeCustomKeyStores operation."]}
    let context_ = "DisconnectCustomKeyStoreRequest"
    let make ~customKeyStoreId = fun () -> { customKeyStoreId }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Some (CustomKeyStoreIdType.to_value x.customKeyStoreId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let customKeyStoreId =
        CustomKeyStoreIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "CustomKeyStoreId") in
      make ~customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let customKeyStoreId =
        field_map_exn json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ~customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Disconnects the custom key store from its backing key store. This operation disconnects an CloudHSM key store from its associated CloudHSM cluster or disconnects an external key store from the external key store proxy that communicates with your external key manager. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. While a custom key store is disconnected, you can manage the custom key store and its KMS keys, but you cannot create or use its KMS keys. You can reconnect the custom key store at any time. While a custom key store is disconnected, all attempts to create KMS keys in the custom key store or to use existing KMS keys in cryptographic operations will fail. This action can prevent users from storing and accessing sensitive data. When you disconnect a custom key store, its ConnectionState changes to Disconnected. To find the connection state of a custom key store, use the DescribeCustomKeyStores operation. To reconnect a custom key store, use the ConnectCustomKeyStore operation. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DisconnectCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DisableKeyRotationRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies a symmetric encryption KMS key. You cannot enable or disable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "DisableKeyRotationRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Disables automatic rotation of the key material of the specified symmetric encryption KMS key. Automatic key rotation is supported only on symmetric encryption KMS keys. You cannot enable automatic rotation of asymmetric KMS keys, HMAC KMS keys, KMS keys with imported key material, or KMS keys in a custom key store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key. You can enable (EnableKeyRotation) and disable automatic rotation of the key material in customer managed KMS keys. Key material rotation of Amazon Web Services managed KMS keys is not configurable. KMS always rotates the key material for every year. Rotation of Amazon Web Services owned KMS keys varies. In May 2022, KMS changed the rotation schedule for Amazon Web Services managed keys from every three years to every year. For details, see EnableKeyRotation. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:DisableKeyRotation (key policy) Related operations: EnableKeyRotation GetKeyRotationStatus ListKeyRotations RotateKeyOnDemand Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DisableKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key to disable. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "DisableKeyRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Sets the state of a KMS key to disabled. This change temporarily prevents use of the KMS key for cryptographic operations. The KMS key that you use for this operation must be in a compatible key state. For more information about how key state affects the use of a KMS key, see Key states of KMS keys in the Key Management Service Developer Guide . Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:DisableKey (key policy) Related operations: EnableKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DescribeKeyResponse =
  struct
    type nonrec t =
      {
      keyMetadata: KeyMetadata.t option
        [@ocaml.doc "Metadata associated with the key."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyMetadata = fun () -> { keyMetadata }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyMetadata", (Option.map x.keyMetadata ~f:KeyMetadata.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMetadata =
        (Option.map ~f:KeyMetadata.of_xml) (Xml.child xml_arg0 "KeyMetadata") in
      make ?keyMetadata ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMetadata = field_map json__ "KeyMetadata" KeyMetadata.of_json in
      make ?keyMetadata ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides detailed information about a KMS key. You can run DescribeKey on a customer managed key or an Amazon Web Services managed key. This detailed information includes the key ARN, creation date (and deletion date, if applicable), the key state, and the origin and expiration date (if any) of the key material. It includes fields, like KeySpec, that help you distinguish different types of KMS keys. It also displays the key usage (encryption, signing, or generating and verifying MACs) and the algorithms that the KMS key supports. For multi-Region keys, DescribeKey displays the primary key and all related replica keys. For KMS keys in CloudHSM key stores, it includes information about the key store, such as the key store ID and the CloudHSM cluster ID. For KMS keys in external key stores, it includes the custom key store ID and the ID of the external key. DescribeKey does not return the following information: Aliases associated with the KMS key. To get this information, use ListAliases. Whether automatic key rotation is enabled on the KMS key. To get this information, use GetKeyRotationStatus. Also, some key states prevent a KMS key from being automatically rotated. For details, see How key rotation works in the Key Management Service Developer Guide. Tags on the KMS key. To get this information, use ListResourceTags. Key policies and grants on the KMS key. To get this information, use GetKeyPolicy and ListGrants. In general, DescribeKey is a non-mutating operation. It returns data about KMS keys, but doesn't change them. However, Amazon Web Services services use DescribeKey to create Amazon Web Services managed keys from a predefined Amazon Web Services alias with no key ID. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:DescribeKey (key policy) Related operations: GetKeyPolicy GetKeyRotationStatus ListAliases ListGrants ListKeys ListResourceTags ListRetirableGrants Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DescribeKeyRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Describes the specified KMS key. If you specify a predefined Amazon Web Services alias (an Amazon Web Services alias with no key ID), KMS associates the alias with an Amazon Web Services managed key and returns its KeyId and Arn in the response. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."]}
    let context_ = "DescribeKeyRequest"
    let make ?grantTokens = fun ~keyId -> fun () -> { grantTokens; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?grantTokens ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?grantTokens ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Provides detailed information about a KMS key. You can run DescribeKey on a customer managed key or an Amazon Web Services managed key. This detailed information includes the key ARN, creation date (and deletion date, if applicable), the key state, and the origin and expiration date (if any) of the key material. It includes fields, like KeySpec, that help you distinguish different types of KMS keys. It also displays the key usage (encryption, signing, or generating and verifying MACs) and the algorithms that the KMS key supports. For multi-Region keys, DescribeKey displays the primary key and all related replica keys. For KMS keys in CloudHSM key stores, it includes information about the key store, such as the key store ID and the CloudHSM cluster ID. For KMS keys in external key stores, it includes the custom key store ID and the ID of the external key. DescribeKey does not return the following information: Aliases associated with the KMS key. To get this information, use ListAliases. Whether automatic key rotation is enabled on the KMS key. To get this information, use GetKeyRotationStatus. Also, some key states prevent a KMS key from being automatically rotated. For details, see How key rotation works in the Key Management Service Developer Guide. Tags on the KMS key. To get this information, use ListResourceTags. Key policies and grants on the KMS key. To get this information, use GetKeyPolicy and ListGrants. In general, DescribeKey is a non-mutating operation. It returns data about KMS keys, but doesn't change them. However, Amazon Web Services services use DescribeKey to create Amazon Web Services managed keys from a predefined Amazon Web Services alias with no key ID. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:DescribeKey (key policy) Related operations: GetKeyPolicy GetKeyRotationStatus ListAliases ListGrants ListKeys ListResourceTags ListRetirableGrants Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DescribeCustomKeyStoresResponse =
  struct
    type nonrec t =
      {
      customKeyStores: CustomKeyStoresList.t option
        [@ocaml.doc "Contains metadata about each custom key store."];
      nextMarker: MarkerType.t option
        [@ocaml.doc
          "When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request."];
      truncated: BooleanType.t option
        [@ocaml.doc
          "A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request."]}
    type nonrec error =
      [
        `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `InvalidMarkerException of InvalidMarkerException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?customKeyStores =
      fun ?nextMarker ->
        fun ?truncated ->
          fun () -> { customKeyStores; nextMarker; truncated }
    let error_of_json name json =
      match name with
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "InvalidMarkerException" ->
          `InvalidMarkerException (InvalidMarkerException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `InvalidMarkerException e ->
          `Assoc
            [("error", (`String "InvalidMarkerException"));
            ("details", (InvalidMarkerException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CustomKeyStores",
           (Option.map x.customKeyStores ~f:CustomKeyStoresList.to_value));
        ("NextMarker", (Option.map x.nextMarker ~f:MarkerType.to_value));
        ("Truncated", (Option.map x.truncated ~f:BooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let truncated =
        (Option.map ~f:BooleanType.of_xml) (Xml.child xml_arg0 "Truncated") in
      let nextMarker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "NextMarker") in
      let customKeyStores =
        (Option.map ~f:CustomKeyStoresList.of_xml)
          (Xml.child xml_arg0 "CustomKeyStores") in
      make ?truncated ?nextMarker ?customKeyStores ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let truncated = field_map json__ "Truncated" BooleanType.of_json in
      let nextMarker = field_map json__ "NextMarker" MarkerType.of_json in
      let customKeyStores =
        field_map json__ "CustomKeyStores" CustomKeyStoresList.of_json in
      make ?truncated ?nextMarker ?customKeyStores ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets information about custom key stores in the account and Region. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. By default, this operation returns information about all custom key stores in the account and Region. To get only information about a particular custom key store, use either the CustomKeyStoreName or CustomKeyStoreId parameter (but not both). To determine whether the custom key store is connected to its CloudHSM cluster or external key store proxy, use the ConnectionState element in the response. If an attempt to connect the custom key store failed, the ConnectionState value is FAILED and the ConnectionErrorCode element in the response indicates the cause of the failure. For help interpreting the ConnectionErrorCode, see CustomKeyStoresListEntry. Custom key stores have a DISCONNECTED connection state if the key store has never been connected or you used the DisconnectCustomKeyStore operation to disconnect it. Otherwise, the connection state is CONNECTED. If your custom key store connection state is CONNECTED but you are having trouble using it, verify that the backing store is active and available. For an CloudHSM key store, verify that the associated CloudHSM cluster is active and contains the minimum number of HSMs required for the operation, if any. For an external key store, verify that the external key store proxy and its associated external key manager are reachable and enabled. For help repairing your CloudHSM key store, see the Troubleshooting CloudHSM key stores. For help repairing your external key store, see the Troubleshooting external key stores. Both topics are in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DescribeCustomKeyStores (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DescribeCustomKeyStoresRequest =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc
          "Gets only information about the specified custom key store. Enter the key store ID. By default, this operation gets information about all custom key stores in the account and Region. To limit the output to a particular custom key store, provide either the CustomKeyStoreId or CustomKeyStoreName parameter, but not both."];
      customKeyStoreName: CustomKeyStoreNameType.t option
        [@ocaml.doc
          "Gets only information about the specified custom key store. Enter the friendly name of the custom key store. By default, this operation gets information about all custom key stores in the account and Region. To limit the output to a particular custom key store, provide either the CustomKeyStoreId or CustomKeyStoreName parameter, but not both."];
      limit: LimitType.t option
        [@ocaml.doc
          "Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer."];
      marker: MarkerType.t option
        [@ocaml.doc
          "Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received."]}
    let make ?customKeyStoreId =
      fun ?customKeyStoreName ->
        fun ?limit ->
          fun ?marker ->
            fun () -> { customKeyStoreId; customKeyStoreName; limit; marker }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value));
        ("CustomKeyStoreName",
          (Option.map x.customKeyStoreName ~f:CustomKeyStoreNameType.to_value));
        ("Limit", (Option.map x.limit ~f:LimitType.to_value));
        ("Marker", (Option.map x.marker ~f:MarkerType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let marker =
        (Option.map ~f:MarkerType.of_xml) (Xml.child xml_arg0 "Marker") in
      let limit =
        (Option.map ~f:LimitType.of_xml) (Xml.child xml_arg0 "Limit") in
      let customKeyStoreName =
        (Option.map ~f:CustomKeyStoreNameType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreName") in
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      make ?marker ?limit ?customKeyStoreName ?customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let marker = field_map json__ "Marker" MarkerType.of_json in
      let limit = field_map json__ "Limit" LimitType.of_json in
      let customKeyStoreName =
        field_map json__ "CustomKeyStoreName" CustomKeyStoreNameType.of_json in
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ?marker ?limit ?customKeyStoreName ?customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Gets information about custom key stores in the account and Region. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. By default, this operation returns information about all custom key stores in the account and Region. To get only information about a particular custom key store, use either the CustomKeyStoreName or CustomKeyStoreId parameter (but not both). To determine whether the custom key store is connected to its CloudHSM cluster or external key store proxy, use the ConnectionState element in the response. If an attempt to connect the custom key store failed, the ConnectionState value is FAILED and the ConnectionErrorCode element in the response indicates the cause of the failure. For help interpreting the ConnectionErrorCode, see CustomKeyStoresListEntry. Custom key stores have a DISCONNECTED connection state if the key store has never been connected or you used the DisconnectCustomKeyStore operation to disconnect it. Otherwise, the connection state is CONNECTED. If your custom key store connection state is CONNECTED but you are having trouble using it, verify that the backing store is active and available. For an CloudHSM key store, verify that the associated CloudHSM cluster is active and contains the minimum number of HSMs required for the operation, if any. For an external key store, verify that the external key store proxy and its associated external key manager are reachable and enabled. For help repairing your CloudHSM key store, see the Troubleshooting CloudHSM key stores. For help repairing your external key store, see the Troubleshooting external key stores. Both topics are in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DescribeCustomKeyStores (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DeleteCustomKeyStore DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeriveSharedSecretResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "Identifies the KMS key used to derive the shared secret."];
      sharedSecret: PlaintextType.t option
        [@ocaml.doc
          "The raw secret derived from the specified key agreement algorithm, private key in the asymmetric KMS key, and your peer's public key. If the response includes the CiphertextForRecipient field, the SharedSecret field is null or empty."];
      ciphertextForRecipient: CiphertextType.t option
        [@ocaml.doc
          "The plaintext shared secret encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment. This field is included in the response only when the Recipient parameter in the request includes a valid attestation document from an Amazon Web Services Nitro enclave or NitroTPM. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      keyAgreementAlgorithm: KeyAgreementAlgorithmSpec.t option
        [@ocaml.doc
          "Identifies the key agreement algorithm used to derive the shared secret."];
      keyOrigin: OriginType.t option
        [@ocaml.doc
          "The source of the key material for the specified KMS key. When this value is AWS_KMS, KMS created the key material. When this value is EXTERNAL, the key material was imported or the KMS key doesn't have any key material. The only valid values for DeriveSharedSecret are AWS_KMS and EXTERNAL. DeriveSharedSecret does not support KMS keys with a KeyOrigin value of AWS_CLOUDHSM or EXTERNAL_KEY_STORE."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?sharedSecret ->
        fun ?ciphertextForRecipient ->
          fun ?keyAgreementAlgorithm ->
            fun ?keyOrigin ->
              fun () ->
                {
                  keyId;
                  sharedSecret;
                  ciphertextForRecipient;
                  keyAgreementAlgorithm;
                  keyOrigin
                }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("SharedSecret",
          (Option.map x.sharedSecret ~f:PlaintextType.to_value));
        ("CiphertextForRecipient",
          (Option.map x.ciphertextForRecipient ~f:CiphertextType.to_value));
        ("KeyAgreementAlgorithm",
          (Option.map x.keyAgreementAlgorithm
             ~f:KeyAgreementAlgorithmSpec.to_value));
        ("KeyOrigin", (Option.map x.keyOrigin ~f:OriginType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyOrigin =
        (Option.map ~f:OriginType.of_xml) (Xml.child xml_arg0 "KeyOrigin") in
      let keyAgreementAlgorithm =
        (Option.map ~f:KeyAgreementAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "KeyAgreementAlgorithm") in
      let ciphertextForRecipient =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextForRecipient") in
      let sharedSecret =
        (Option.map ~f:PlaintextType.of_xml)
          (Xml.child xml_arg0 "SharedSecret") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyOrigin ?keyAgreementAlgorithm ?ciphertextForRecipient
        ?sharedSecret ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyOrigin = field_map json__ "KeyOrigin" OriginType.of_json in
      let keyAgreementAlgorithm =
        field_map json__ "KeyAgreementAlgorithm"
          KeyAgreementAlgorithmSpec.of_json in
      let ciphertextForRecipient =
        field_map json__ "CiphertextForRecipient" CiphertextType.of_json in
      let sharedSecret =
        field_map json__ "SharedSecret" PlaintextType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyOrigin ?keyAgreementAlgorithm ?ciphertextForRecipient
        ?sharedSecret ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Derives a shared secret using a key agreement algorithm. You must use an asymmetric NIST-standard elliptic curve (ECC) or SM2 (China Regions only) KMS key pair with a KeyUsage value of KEY_AGREEMENT to call DeriveSharedSecret. DeriveSharedSecret uses the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive (ECDH) to establish a key agreement between two peers by deriving a shared secret from their elliptic curve public-private key pairs. You can use the raw shared secret that DeriveSharedSecret returns to derive a symmetric key that can encrypt and decrypt data that is sent between the two peers, or that can generate and verify HMACs. KMS recommends that you follow NIST recommendations for key derivation when using the raw shared secret to derive a symmetric key. The following workflow demonstrates how to establish key agreement over an insecure communication channel using DeriveSharedSecret. Alice calls CreateKey to create an asymmetric KMS key pair with a KeyUsage value of KEY_AGREEMENT. The asymmetric KMS key must use a NIST-standard elliptic curve (ECC) or SM2 (China Regions only) key spec. Bob creates an elliptic curve key pair. Bob can call CreateKey to create an asymmetric KMS key pair or generate a key pair outside of KMS. Bob's key pair must use the same NIST-standard elliptic curve (ECC) or SM2 (China Regions ony) curve as Alice. Alice and Bob exchange their public keys through an insecure communication channel (like the internet). Use GetPublicKey to download the public key of your asymmetric KMS key pair. KMS strongly recommends verifying that the public key you receive came from the expected party before using it to derive a shared secret. Alice calls DeriveSharedSecret. KMS uses the private key from the KMS key pair generated in Step 1, Bob's public key, and the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive to derive the shared secret. The private key in your KMS key pair never leaves KMS unencrypted. DeriveSharedSecret returns the raw shared secret. Bob uses the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive to calculate the same raw secret using his private key and Alice's public key. To derive a shared secret you must provide a key agreement algorithm, the private key of the caller's asymmetric NIST-standard elliptic curve or SM2 (China Regions only) KMS key pair, and the public key from your peer's NIST-standard elliptic curve or SM2 (China Regions only) key pair. The public key can be from another asymmetric KMS key pair or from a key pair generated outside of KMS, but both key pairs must be on the same elliptic curve. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:DeriveSharedSecret (key policy) Related operations: CreateKey GetPublicKey DescribeKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeriveSharedSecretRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies an asymmetric NIST-standard ECC or SM2 (China Regions only) KMS key. KMS uses the private key in the specified key pair to derive the shared secret. The key usage of the KMS key must be KEY_AGREEMENT. To find the KeyUsage of a KMS key, use the DescribeKey operation. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      keyAgreementAlgorithm: KeyAgreementAlgorithmSpec.t
        [@ocaml.doc
          "Specifies the key agreement algorithm used to derive the shared secret. The only valid value is ECDH."];
      publicKey: PublicKeyType.t
        [@ocaml.doc
          "Specifies the public key in your peer's NIST-standard elliptic curve (ECC) or SM2 (China Regions only) key pair. The public key must be a DER-encoded X.509 public key, also known as SubjectPublicKeyInfo (SPKI), as defined in RFC 5280. GetPublicKey returns the public key of an asymmetric KMS key pair in the required DER-encoded format. If you use Amazon Web Services CLI version 1, you must provide the DER-encoded X.509 public key in a file. Otherwise, the Amazon Web Services CLI Base64-encodes the public key a second time, resulting in a ValidationException. You can specify the public key as binary data in a file using fileb (fileb://<path-to-file>) or in-line using a Base64 encoded string."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."];
      recipient: RecipientInfo.t option
        [@ocaml.doc
          "A signed attestation document from an Amazon Web Services Nitro enclave or NitroTPM, and the encryption algorithm to use with the public key in the attestation document. The only valid encryption algorithm is RSAES_OAEP_SHA_256. This parameter only supports attestation documents for Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM. To call DeriveSharedSecret generate an attestation document use either Amazon Web Services Nitro Enclaves SDK for an Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM tools for Amazon Web Services NitroTPM. Then use the Recipient parameter from any Amazon Web Services SDK to provide the attestation document for the attested environment. When you use this parameter, instead of returning a plaintext copy of the shared secret, KMS encrypts the plaintext shared secret under the public key in the attestation document, and returns the resulting ciphertext in the CiphertextForRecipient field in the response. This ciphertext can be decrypted only with the private key in the attested environment. The CiphertextBlob field in the response contains the encrypted shared secret derived from the KMS key specified by the KeyId parameter and public key specified by the PublicKey parameter. The SharedSecret field in the response is null or empty. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."]}
    let context_ = "DeriveSharedSecretRequest"
    let make ?grantTokens =
      fun ?dryRun ->
        fun ?recipient ->
          fun ~keyId ->
            fun ~keyAgreementAlgorithm ->
              fun ~publicKey ->
                fun () ->
                  {
                    grantTokens;
                    dryRun;
                    recipient;
                    keyId;
                    keyAgreementAlgorithm;
                    publicKey
                  }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("KeyAgreementAlgorithm",
          (Some (KeyAgreementAlgorithmSpec.to_value x.keyAgreementAlgorithm)));
        ("PublicKey", (Some (PublicKeyType.to_value x.publicKey)));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value));
        ("Recipient", (Option.map x.recipient ~f:RecipientInfo.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let recipient =
        (Option.map ~f:RecipientInfo.of_xml) (Xml.child xml_arg0 "Recipient") in
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let publicKey =
        PublicKeyType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "PublicKey") in
      let keyAgreementAlgorithm =
        KeyAgreementAlgorithmSpec.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "KeyAgreementAlgorithm") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?recipient ?dryRun ?grantTokens ~publicKey ~keyAgreementAlgorithm
        ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let recipient = field_map json__ "Recipient" RecipientInfo.of_json in
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let publicKey = field_map_exn json__ "PublicKey" PublicKeyType.of_json in
      let keyAgreementAlgorithm =
        field_map_exn json__ "KeyAgreementAlgorithm"
          KeyAgreementAlgorithmSpec.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?recipient ?dryRun ?grantTokens ~publicKey ~keyAgreementAlgorithm
        ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Derives a shared secret using a key agreement algorithm. You must use an asymmetric NIST-standard elliptic curve (ECC) or SM2 (China Regions only) KMS key pair with a KeyUsage value of KEY_AGREEMENT to call DeriveSharedSecret. DeriveSharedSecret uses the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive (ECDH) to establish a key agreement between two peers by deriving a shared secret from their elliptic curve public-private key pairs. You can use the raw shared secret that DeriveSharedSecret returns to derive a symmetric key that can encrypt and decrypt data that is sent between the two peers, or that can generate and verify HMACs. KMS recommends that you follow NIST recommendations for key derivation when using the raw shared secret to derive a symmetric key. The following workflow demonstrates how to establish key agreement over an insecure communication channel using DeriveSharedSecret. Alice calls CreateKey to create an asymmetric KMS key pair with a KeyUsage value of KEY_AGREEMENT. The asymmetric KMS key must use a NIST-standard elliptic curve (ECC) or SM2 (China Regions only) key spec. Bob creates an elliptic curve key pair. Bob can call CreateKey to create an asymmetric KMS key pair or generate a key pair outside of KMS. Bob's key pair must use the same NIST-standard elliptic curve (ECC) or SM2 (China Regions ony) curve as Alice. Alice and Bob exchange their public keys through an insecure communication channel (like the internet). Use GetPublicKey to download the public key of your asymmetric KMS key pair. KMS strongly recommends verifying that the public key you receive came from the expected party before using it to derive a shared secret. Alice calls DeriveSharedSecret. KMS uses the private key from the KMS key pair generated in Step 1, Bob's public key, and the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive to derive the shared secret. The private key in your KMS key pair never leaves KMS unencrypted. DeriveSharedSecret returns the raw shared secret. Bob uses the Elliptic Curve Cryptography Cofactor Diffie-Hellman Primitive to calculate the same raw secret using his private key and Alice's public key. To derive a shared secret you must provide a key agreement algorithm, the private key of the caller's asymmetric NIST-standard elliptic curve or SM2 (China Regions only) KMS key pair, and the public key from your peer's NIST-standard elliptic curve or SM2 (China Regions only) key pair. The public key can be from another asymmetric KMS key pair or from a key pair generated outside of KMS, but both key pairs must be on the same elliptic curve. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter. Required permissions: kms:DeriveSharedSecret (key policy) Related operations: CreateKey GetPublicKey DescribeKey Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeleteImportedKeyMaterialResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key from which the key material was deleted."];
      keyMaterialId: BackingKeyIdResponseType.t option
        [@ocaml.doc "Identifies the deleted key material."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?keyMaterialId -> fun () -> { keyId; keyMaterialId }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdResponseType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdResponseType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyMaterialId ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdResponseType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyMaterialId ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes key material that was previously imported. This operation makes the specified KMS key temporarily unusable. To restore the usability of the KMS key, reimport the same key material. For more information about importing key material into KMS, see Importing Key Material in the Key Management Service Developer Guide. When the specified KMS key is in the PendingDeletion state, this operation does not change the KMS key's state. Otherwise, it changes the KMS key's state to PendingImport. Considerations for multi-Region symmetric encryption keys When you delete the key material of a primary Region key that is in PENDING_ROTATION or PENDING_MULTI_REGION_IMPORT_AND_ROTATIONstate, you'll also be deleting the key materials for the replica Region keys. If you delete any key material of a replica Region key, the primary Region key and other replica Region keys remain unchanged. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:DeleteImportedKeyMaterial (key policy) Related operations: GetParametersForImport ListKeyRotations ImportKeyMaterial Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeleteImportedKeyMaterialRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key from which you are deleting imported key material. The Origin of the KMS key must be EXTERNAL. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "Identifies the imported key material you are deleting. If no KeyMaterialId is specified, KMS deletes the current key material. To get the list of key material IDs associated with a KMS key, use ListKeyRotations."]}
    let context_ = "DeleteImportedKeyMaterialRequest"
    let make ?keyMaterialId =
      fun ~keyId -> fun () -> { keyMaterialId; keyId }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?keyMaterialId ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?keyMaterialId ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes key material that was previously imported. This operation makes the specified KMS key temporarily unusable. To restore the usability of the KMS key, reimport the same key material. For more information about importing key material into KMS, see Importing Key Material in the Key Management Service Developer Guide. When the specified KMS key is in the PendingDeletion state, this operation does not change the KMS key's state. Otherwise, it changes the KMS key's state to PendingImport. Considerations for multi-Region symmetric encryption keys When you delete the key material of a primary Region key that is in PENDING_ROTATION or PENDING_MULTI_REGION_IMPORT_AND_ROTATIONstate, you'll also be deleting the key materials for the replica Region keys. If you delete any key material of a replica Region key, the primary Region key and other replica Region keys remain unchanged. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:DeleteImportedKeyMaterial (key policy) Related operations: GetParametersForImport ListKeyRotations ImportKeyMaterial Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeleteCustomKeyStoreResponse =
  struct
    type nonrec t = unit
    type nonrec error =
      [ `CustomKeyStoreHasCMKsException of CustomKeyStoreHasCMKsException.t 
      | `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make () = ()
    let error_of_json name json =
      match name with
      | "CustomKeyStoreHasCMKsException" ->
          `CustomKeyStoreHasCMKsException
            (CustomKeyStoreHasCMKsException.of_json json)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CustomKeyStoreHasCMKsException" ->
          `CustomKeyStoreHasCMKsException
            (CustomKeyStoreHasCMKsException.of_xml xml)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CustomKeyStoreHasCMKsException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreHasCMKsException"));
            ("details", (CustomKeyStoreHasCMKsException.to_json e))]
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes a custom key store. This operation does not affect any backing elements of the custom key store. It does not delete the CloudHSM cluster that is associated with an CloudHSM key store, or affect any users or keys in the cluster. For an external key store, it does not affect the external key store proxy, external key manager, or any external keys. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. The custom key store that you delete cannot contain any KMS keys. Before deleting the key store, verify that you will never need to use any of the KMS keys in the key store for any cryptographic operations. Then, use ScheduleKeyDeletion to delete the KMS keys from the key store. After the required waiting period expires and all KMS keys are deleted from the custom key store, use DisconnectCustomKeyStore to disconnect the key store from KMS. Then, you can delete the custom key store. For keys in an CloudHSM key store, the ScheduleKeyDeletion operation makes a best effort to delete the key material from the associated cluster. However, you might need to manually delete the orphaned key material from the cluster and its backups. KMS never creates, manages, or deletes cryptographic keys in the external key manager associated with an external key store. You must manage them using your external key manager tools. Instead of deleting the custom key store, consider using the DisconnectCustomKeyStore operation to disconnect the custom key store from its backing key store. While the key store is disconnected, you cannot create or use the KMS keys in the key store. But, you do not need to delete KMS keys and you can reconnect a disconnected custom key store at any time. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DeleteCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeleteCustomKeyStoreRequest =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t
        [@ocaml.doc
          "Enter the ID of the custom key store you want to delete. To find the ID of a custom key store, use the DescribeCustomKeyStores operation."]}
    let context_ = "DeleteCustomKeyStoreRequest"
    let make ~customKeyStoreId = fun () -> { customKeyStoreId }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Some (CustomKeyStoreIdType.to_value x.customKeyStoreId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let customKeyStoreId =
        CustomKeyStoreIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "CustomKeyStoreId") in
      make ~customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let customKeyStoreId =
        field_map_exn json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ~customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes a custom key store. This operation does not affect any backing elements of the custom key store. It does not delete the CloudHSM cluster that is associated with an CloudHSM key store, or affect any users or keys in the cluster. For an external key store, it does not affect the external key store proxy, external key manager, or any external keys. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. The custom key store that you delete cannot contain any KMS keys. Before deleting the key store, verify that you will never need to use any of the KMS keys in the key store for any cryptographic operations. Then, use ScheduleKeyDeletion to delete the KMS keys from the key store. After the required waiting period expires and all KMS keys are deleted from the custom key store, use DisconnectCustomKeyStore to disconnect the key store from KMS. Then, you can delete the custom key store. For keys in an CloudHSM key store, the ScheduleKeyDeletion operation makes a best effort to delete the key material from the associated cluster. However, you might need to manually delete the orphaned key material from the cluster and its backups. KMS never creates, manages, or deletes cryptographic keys in the external key manager associated with an external key store. You must manage them using your external key manager tools. Instead of deleting the custom key store, consider using the DisconnectCustomKeyStore operation to disconnect the custom key store from its backing key store. While the key store is disconnected, you cannot create or use the KMS keys in the key store. But, you do not need to delete KMS keys and you can reconnect a disconnected custom key store at any time. If the operation succeeds, it returns a JSON object with no properties. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:DeleteCustomKeyStore (IAM policy) Related operations: ConnectCustomKeyStore CreateCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DeleteAliasRequest =
  struct
    type nonrec t =
      {
      aliasName: AliasNameType.t
        [@ocaml.doc
          "The alias to be deleted. The alias name must begin with alias/ followed by the alias name, such as alias/ExampleAlias."]}
    let context_ = "DeleteAliasRequest"
    let make ~aliasName = fun () -> { aliasName }
    let to_value x =
      structure_to_value
        [("AliasName", (Some (AliasNameType.to_value x.aliasName)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let aliasName =
        AliasNameType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "AliasName") in
      make ~aliasName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let aliasName = field_map_exn json__ "AliasName" AliasNameType.of_json in
      make ~aliasName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Deletes the specified alias. Adding, deleting, or updating an alias can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. Because an alias is not a property of a KMS key, you can delete and change the aliases of a KMS key without affecting the KMS key. Also, aliases do not appear in the response from the DescribeKey operation. To get the aliases of all KMS keys, use the ListAliases operation. Each KMS key can have multiple aliases. To change the alias of a KMS key, use DeleteAlias to delete the current alias and CreateAlias to create a new alias. To associate an existing alias with a different KMS key, call UpdateAlias. Cross-account use: No. You cannot perform this operation on an alias in a different Amazon Web Services account. Required permissions kms:DeleteAlias on the alias (IAM policy). kms:DeleteAlias on the KMS key (key policy). For details, see Controlling access to aliases in the Key Management Service Developer Guide. Related operations: CreateAlias ListAliases UpdateAlias Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DecryptResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key that was used to decrypt the ciphertext."];
      plaintext: PlaintextType.t option
        [@ocaml.doc
          "Decrypted plaintext data. When you use the HTTP API or the Amazon Web Services CLI, the value is Base64-encoded. Otherwise, it is not Base64-encoded. If the response includes the CiphertextForRecipient field, the Plaintext field is null or empty."];
      encryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "The encryption algorithm that was used to decrypt the ciphertext."];
      ciphertextForRecipient: CiphertextType.t option
        [@ocaml.doc
          "The plaintext data encrypted with the public key from the attestation document. This ciphertext can be decrypted only by using a private key from the attested environment. This field is included in the response only when the Recipient parameter in the request includes a valid attestation document from an Amazon Web Services Nitro enclave or NitroTPM. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      keyMaterialId: BackingKeyIdType.t option
        [@ocaml.doc
          "The identifier of the key material used to decrypt the ciphertext. This field is present only when the operation uses a symmetric encryption KMS key. This field is omitted if the request includes the Recipient parameter."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `IncorrectKeyException of IncorrectKeyException.t 
      | `InvalidCiphertextException of InvalidCiphertextException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `InvalidKeyUsageException of InvalidKeyUsageException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `KeyUnavailableException of KeyUnavailableException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId =
      fun ?plaintext ->
        fun ?encryptionAlgorithm ->
          fun ?ciphertextForRecipient ->
            fun ?keyMaterialId ->
              fun () ->
                {
                  keyId;
                  plaintext;
                  encryptionAlgorithm;
                  ciphertextForRecipient;
                  keyMaterialId
                }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "IncorrectKeyException" ->
          `IncorrectKeyException (IncorrectKeyException.of_json json)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException
            (InvalidCiphertextException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "IncorrectKeyException" ->
          `IncorrectKeyException (IncorrectKeyException.of_xml xml)
      | "InvalidCiphertextException" ->
          `InvalidCiphertextException (InvalidCiphertextException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "InvalidKeyUsageException" ->
          `InvalidKeyUsageException (InvalidKeyUsageException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "KeyUnavailableException" ->
          `KeyUnavailableException (KeyUnavailableException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `IncorrectKeyException e ->
          `Assoc
            [("error", (`String "IncorrectKeyException"));
            ("details", (IncorrectKeyException.to_json e))]
      | `InvalidCiphertextException e ->
          `Assoc
            [("error", (`String "InvalidCiphertextException"));
            ("details", (InvalidCiphertextException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `InvalidKeyUsageException e ->
          `Assoc
            [("error", (`String "InvalidKeyUsageException"));
            ("details", (InvalidKeyUsageException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `KeyUnavailableException e ->
          `Assoc
            [("error", (`String "KeyUnavailableException"));
            ("details", (KeyUnavailableException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("Plaintext", (Option.map x.plaintext ~f:PlaintextType.to_value));
        ("EncryptionAlgorithm",
          (Option.map x.encryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("CiphertextForRecipient",
          (Option.map x.ciphertextForRecipient ~f:CiphertextType.to_value));
        ("KeyMaterialId",
          (Option.map x.keyMaterialId ~f:BackingKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMaterialId =
        (Option.map ~f:BackingKeyIdType.of_xml)
          (Xml.child xml_arg0 "KeyMaterialId") in
      let ciphertextForRecipient =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextForRecipient") in
      let encryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithm") in
      let plaintext =
        (Option.map ~f:PlaintextType.of_xml) (Xml.child xml_arg0 "Plaintext") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyMaterialId ?ciphertextForRecipient ?encryptionAlgorithm
        ?plaintext ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMaterialId =
        field_map json__ "KeyMaterialId" BackingKeyIdType.of_json in
      let ciphertextForRecipient =
        field_map json__ "CiphertextForRecipient" CiphertextType.of_json in
      let encryptionAlgorithm =
        field_map json__ "EncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let plaintext = field_map json__ "Plaintext" PlaintextType.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyMaterialId ?ciphertextForRecipient ?encryptionAlgorithm
        ?plaintext ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Decrypts ciphertext that was encrypted by a KMS key using any of the following operations: Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyWithoutPlaintext GenerateDataKeyPairWithoutPlaintext You can use this operation to decrypt ciphertext that was encrypted under a symmetric encryption KMS key or an asymmetric encryption KMS key. When the KMS key is asymmetric, you must specify the KMS key and the encryption algorithm that was used to encrypt the ciphertext. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. The Decrypt operation also decrypts ciphertext that was encrypted outside of KMS by the public key in an KMS asymmetric KMS key. However, it cannot decrypt symmetric ciphertext produced by other libraries, such as the Amazon Web Services Encryption SDK or Amazon S3 client-side encryption. These libraries return a ciphertext format that is incompatible with KMS. If the ciphertext was encrypted under a symmetric encryption KMS key, the KeyId parameter is optional. KMS can get this information from metadata that it adds to the symmetric ciphertext blob. This feature adds durability to your implementation by ensuring that authorized users can decrypt ciphertext decades after it was encrypted, even if they've lost track of the key ID. However, specifying the KMS key is always recommended as a best practice. When you use the KeyId parameter to specify a KMS key, KMS only uses the KMS key you specify. If the ciphertext was encrypted under a different KMS key, the Decrypt operation fails. This practice ensures that you use the KMS key that you intend. Whenever possible, use key policies to give users permission to call the Decrypt operation on a particular KMS key, instead of using IAM policies. Otherwise, you might create an IAM policy that gives the user Decrypt permission on all KMS keys. This user could decrypt ciphertext that was encrypted by KMS keys in other accounts if the key policy for the cross-account KMS key permits it. If you must use an IAM policy for Decrypt permissions, limit the user to particular KMS keys or particular trusted accounts. For details, see Best practices for IAM policies in the Key Management Service Developer Guide. Decrypt also supports Amazon Web Services Nitro Enclaves and NitroTPM, which provide attested environments in Amazon EC2. To call Decrypt for a Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. Instead of the plaintext data, the response includes the plaintext data encrypted with the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To specify a KMS key in a different Amazon Web Services account, use the key ARN or alias ARN. A short key ID is also acceptable when decrypting symmetric ciphertexts, though using a full key ARN is recommended to be more explicit about the intended KMS key. Required permissions: kms:Decrypt (key policy) Related operations: Encrypt GenerateDataKey GenerateDataKeyPair ReEncrypt Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module DecryptRequest =
  struct
    type nonrec t =
      {
      ciphertextBlob: CiphertextType.t option
        [@ocaml.doc
          "Ciphertext to be decrypted. The blob includes metadata. This parameter is required in all cases except when DryRun is true and DryRunModifiers is set to IGNORE_CIPHERTEXT."];
      encryptionContext: EncryptionContextType.t option
        [@ocaml.doc
          "Specifies the encryption context to use when decrypting the data. An encryption context is valid only for cryptographic operations with a symmetric encryption KMS key. The standard asymmetric encryption algorithms and HMAC algorithms that KMS uses do not support an encryption context. An encryption context is a collection of non-secret key-value pairs that represent additional authenticated data. When you use an encryption context to encrypt data, you must specify the same (an exact case-sensitive match) encryption context to decrypt the data. An encryption context is supported only on operations with symmetric encryption KMS keys. On operations with symmetric encryption KMS keys, an encryption context is optional, but it is strongly recommended. For more information, see Encryption context in the Key Management Service Developer Guide."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      keyId: KeyIdType.t option
        [@ocaml.doc
          "Specifies the KMS key that KMS uses to decrypt the ciphertext. Enter a key ID of the KMS key that was used to encrypt the ciphertext. If you identify a different KMS key, the Decrypt operation throws an IncorrectKeyException. This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key or when DryRun is true and DryRunModifiers is set to IGNORE_CIPHERTEXT. If you used a symmetric encryption KMS key, KMS can get the KMS key from metadata that it adds to the symmetric ciphertext blob. However, it is always recommended as a best practice. This practice ensures that you use the KMS key that you intend. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with \"alias/\". To specify a KMS key in a different Amazon Web Services account, you should use the key ARN or alias ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab Alias name: alias/ExampleAlias Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey. To get the alias name and alias ARN, use ListAliases."];
      encryptionAlgorithm: EncryptionAlgorithmSpec.t option
        [@ocaml.doc
          "Specifies the encryption algorithm that will be used to decrypt the ciphertext. Specify the same algorithm that was used to encrypt the data. If you specify a different algorithm, the Decrypt operation fails. This parameter is required only when the ciphertext was encrypted under an asymmetric KMS key. The default value, SYMMETRIC_DEFAULT, represents the only supported algorithm that is valid for symmetric encryption KMS keys."];
      recipient: RecipientInfo.t option
        [@ocaml.doc
          "A signed attestation document from an Amazon Web Services Nitro enclave or NitroTPM, and the encryption algorithm to use with the public key in the attestation document. The only valid encryption algorithm is RSAES_OAEP_SHA_256. This parameter supports the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK for Amazon Web Services Nitro Enclaves. It supports any Amazon Web Services SDK for Amazon Web Services NitroTPM. When you use this parameter, instead of returning the plaintext data, KMS encrypts the plaintext data with the public key in the attestation document, and returns the resulting ciphertext in the CiphertextForRecipient field in the response. This ciphertext can be decrypted only with the private key in the attested environment. The Plaintext field in the response is null or empty. For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."];
      dryRunModifiers: DryRunModifierList.t option
        [@ocaml.doc
          "Specifies the modifiers to apply to the dry run operation. DryRunModifiers is an optional parameter that only applies when DryRun is set to true. When set to IGNORE_CIPHERTEXT, KMS performs only authorization validation without ciphertext validation. This allows you to test permissions without requiring a valid ciphertext blob. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let make ?ciphertextBlob =
      fun ?encryptionContext ->
        fun ?grantTokens ->
          fun ?keyId ->
            fun ?encryptionAlgorithm ->
              fun ?recipient ->
                fun ?dryRun ->
                  fun ?dryRunModifiers ->
                    fun () ->
                      {
                        ciphertextBlob;
                        encryptionContext;
                        grantTokens;
                        keyId;
                        encryptionAlgorithm;
                        recipient;
                        dryRun;
                        dryRunModifiers
                      }
    let to_value x =
      structure_to_value
        [("CiphertextBlob",
           (Option.map x.ciphertextBlob ~f:CiphertextType.to_value));
        ("EncryptionContext",
          (Option.map x.encryptionContext ~f:EncryptionContextType.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value));
        ("EncryptionAlgorithm",
          (Option.map x.encryptionAlgorithm
             ~f:EncryptionAlgorithmSpec.to_value));
        ("Recipient", (Option.map x.recipient ~f:RecipientInfo.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value));
        ("DryRunModifiers",
          (Option.map x.dryRunModifiers ~f:DryRunModifierList.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRunModifiers =
        (Option.map ~f:DryRunModifierList.of_xml)
          (Xml.child xml_arg0 "DryRunModifiers") in
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let recipient =
        (Option.map ~f:RecipientInfo.of_xml) (Xml.child xml_arg0 "Recipient") in
      let encryptionAlgorithm =
        (Option.map ~f:EncryptionAlgorithmSpec.of_xml)
          (Xml.child xml_arg0 "EncryptionAlgorithm") in
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let encryptionContext =
        (Option.map ~f:EncryptionContextType.of_xml)
          (Xml.child xml_arg0 "EncryptionContext") in
      let ciphertextBlob =
        (Option.map ~f:CiphertextType.of_xml)
          (Xml.child xml_arg0 "CiphertextBlob") in
      make ?dryRunModifiers ?dryRun ?recipient ?encryptionAlgorithm ?keyId
        ?grantTokens ?encryptionContext ?ciphertextBlob ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRunModifiers =
        field_map json__ "DryRunModifiers" DryRunModifierList.of_json in
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let recipient = field_map json__ "Recipient" RecipientInfo.of_json in
      let encryptionAlgorithm =
        field_map json__ "EncryptionAlgorithm"
          EncryptionAlgorithmSpec.of_json in
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let encryptionContext =
        field_map json__ "EncryptionContext" EncryptionContextType.of_json in
      let ciphertextBlob =
        field_map json__ "CiphertextBlob" CiphertextType.of_json in
      make ?dryRunModifiers ?dryRun ?recipient ?encryptionAlgorithm ?keyId
        ?grantTokens ?encryptionContext ?ciphertextBlob ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Decrypts ciphertext that was encrypted by a KMS key using any of the following operations: Encrypt GenerateDataKey GenerateDataKeyPair GenerateDataKeyWithoutPlaintext GenerateDataKeyPairWithoutPlaintext You can use this operation to decrypt ciphertext that was encrypted under a symmetric encryption KMS key or an asymmetric encryption KMS key. When the KMS key is asymmetric, you must specify the KMS key and the encryption algorithm that was used to encrypt the ciphertext. For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. The Decrypt operation also decrypts ciphertext that was encrypted outside of KMS by the public key in an KMS asymmetric KMS key. However, it cannot decrypt symmetric ciphertext produced by other libraries, such as the Amazon Web Services Encryption SDK or Amazon S3 client-side encryption. These libraries return a ciphertext format that is incompatible with KMS. If the ciphertext was encrypted under a symmetric encryption KMS key, the KeyId parameter is optional. KMS can get this information from metadata that it adds to the symmetric ciphertext blob. This feature adds durability to your implementation by ensuring that authorized users can decrypt ciphertext decades after it was encrypted, even if they've lost track of the key ID. However, specifying the KMS key is always recommended as a best practice. When you use the KeyId parameter to specify a KMS key, KMS only uses the KMS key you specify. If the ciphertext was encrypted under a different KMS key, the Decrypt operation fails. This practice ensures that you use the KMS key that you intend. Whenever possible, use key policies to give users permission to call the Decrypt operation on a particular KMS key, instead of using IAM policies. Otherwise, you might create an IAM policy that gives the user Decrypt permission on all KMS keys. This user could decrypt ciphertext that was encrypted by KMS keys in other accounts if the key policy for the cross-account KMS key permits it. If you must use an IAM policy for Decrypt permissions, limit the user to particular KMS keys or particular trusted accounts. For details, see Best practices for IAM policies in the Key Management Service Developer Guide. Decrypt also supports Amazon Web Services Nitro Enclaves and NitroTPM, which provide attested environments in Amazon EC2. To call Decrypt for a Nitro enclave or NitroTPM, use the Amazon Web Services Nitro Enclaves SDK or any Amazon Web Services SDK. Use the Recipient parameter to provide the attestation document for the attested environment. Instead of the plaintext data, the response includes the plaintext data encrypted with the public key from the attestation document (CiphertextForRecipient). For information about the interaction between KMS and Amazon Web Services Nitro Enclaves or Amazon Web Services NitroTPM, see Cryptographic attestation support in KMS in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To specify a KMS key in a different Amazon Web Services account, use the key ARN or alias ARN. A short key ID is also acceptable when decrypting symmetric ciphertexts, though using a full key ARN is recommended to be more explicit about the intended KMS key. Required permissions: kms:Decrypt (key policy) Related operations: Encrypt GenerateDataKey GenerateDataKeyPair ReEncrypt Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateKeyResponse =
  struct
    type nonrec t =
      {
      keyMetadata: KeyMetadata.t option
        [@ocaml.doc "Metadata associated with the KMS key."]}
    type nonrec error =
      [
        `CloudHsmClusterInvalidConfigurationException of
          CloudHsmClusterInvalidConfigurationException.t 
      | `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `MalformedPolicyDocumentException of
          MalformedPolicyDocumentException.t 
      | `TagException of TagException.t 
      | `UnsupportedOperationException of UnsupportedOperationException.t 
      | `XksKeyAlreadyInUseException of XksKeyAlreadyInUseException.t 
      | `XksKeyInvalidConfigurationException of
          XksKeyInvalidConfigurationException.t 
      | `XksKeyNotFoundException of XksKeyNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyMetadata = fun () -> { keyMetadata }
    let error_of_json name json =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_json json)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "MalformedPolicyDocumentException" ->
          `MalformedPolicyDocumentException
            (MalformedPolicyDocumentException.of_json json)
      | "TagException" -> `TagException (TagException.of_json json)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_json json)
      | "XksKeyAlreadyInUseException" ->
          `XksKeyAlreadyInUseException
            (XksKeyAlreadyInUseException.of_json json)
      | "XksKeyInvalidConfigurationException" ->
          `XksKeyInvalidConfigurationException
            (XksKeyInvalidConfigurationException.of_json json)
      | "XksKeyNotFoundException" ->
          `XksKeyNotFoundException (XksKeyNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_xml xml)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "MalformedPolicyDocumentException" ->
          `MalformedPolicyDocumentException
            (MalformedPolicyDocumentException.of_xml xml)
      | "TagException" -> `TagException (TagException.of_xml xml)
      | "UnsupportedOperationException" ->
          `UnsupportedOperationException
            (UnsupportedOperationException.of_xml xml)
      | "XksKeyAlreadyInUseException" ->
          `XksKeyAlreadyInUseException
            (XksKeyAlreadyInUseException.of_xml xml)
      | "XksKeyInvalidConfigurationException" ->
          `XksKeyInvalidConfigurationException
            (XksKeyInvalidConfigurationException.of_xml xml)
      | "XksKeyNotFoundException" ->
          `XksKeyNotFoundException (XksKeyNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CloudHsmClusterInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String "CloudHsmClusterInvalidConfigurationException"));
            ("details",
              (CloudHsmClusterInvalidConfigurationException.to_json e))]
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `MalformedPolicyDocumentException e ->
          `Assoc
            [("error", (`String "MalformedPolicyDocumentException"));
            ("details", (MalformedPolicyDocumentException.to_json e))]
      | `TagException e ->
          `Assoc
            [("error", (`String "TagException"));
            ("details", (TagException.to_json e))]
      | `UnsupportedOperationException e ->
          `Assoc
            [("error", (`String "UnsupportedOperationException"));
            ("details", (UnsupportedOperationException.to_json e))]
      | `XksKeyAlreadyInUseException e ->
          `Assoc
            [("error", (`String "XksKeyAlreadyInUseException"));
            ("details", (XksKeyAlreadyInUseException.to_json e))]
      | `XksKeyInvalidConfigurationException e ->
          `Assoc
            [("error", (`String "XksKeyInvalidConfigurationException"));
            ("details", (XksKeyInvalidConfigurationException.to_json e))]
      | `XksKeyNotFoundException e ->
          `Assoc
            [("error", (`String "XksKeyNotFoundException"));
            ("details", (XksKeyNotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyMetadata", (Option.map x.keyMetadata ~f:KeyMetadata.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyMetadata =
        (Option.map ~f:KeyMetadata.of_xml) (Xml.child xml_arg0 "KeyMetadata") in
      make ?keyMetadata ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyMetadata = field_map json__ "KeyMetadata" KeyMetadata.of_json in
      make ?keyMetadata ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a unique customer managed KMS key in your Amazon Web Services account and Region. You can use a KMS key in cryptographic operations, such as encryption and signing. Some Amazon Web Services services let you use KMS keys that you create and manage to protect your service resources. A KMS key is a logical representation of a cryptographic key. In addition to the key material used in cryptographic operations, a KMS key includes metadata, such as the key ID, key policy, creation date, description, and key state. Use the parameters of CreateKey to specify the type of KMS key, the source of its key material, its key policy, description, tags, and other properties. KMS has replaced the term customer master key (CMK) with Key Management Service key and KMS key. The concept has not changed. To prevent breaking changes, KMS is keeping some variations of this term. To create different types of KMS keys, use the following guidance: Symmetric encryption KMS key By default, CreateKey creates a symmetric encryption KMS key with key material that KMS generates. This is the basic and most widely used type of KMS key, and provides the best performance. To create a symmetric encryption KMS key, you don't need to specify any parameters. The default value for KeySpec, SYMMETRIC_DEFAULT, the default value for KeyUsage, ENCRYPT_DECRYPT, and the default value for Origin, AWS_KMS, create a symmetric encryption KMS key with KMS key material. If you need a key for basic encryption and decryption or you are creating a KMS key to protect your resources in an Amazon Web Services service, create a symmetric encryption KMS key. The key material in a symmetric encryption key never leaves KMS unencrypted. You can use a symmetric encryption KMS key to encrypt and decrypt data up to 4,096 bytes, but they are typically used to generate data keys and data keys pairs. For details, see GenerateDataKey and GenerateDataKeyPair. Asymmetric KMS keys To create an asymmetric KMS key, use the KeySpec parameter to specify the type of key material in the KMS key. Then, use the KeyUsage parameter to determine whether the KMS key will be used to encrypt and decrypt or sign and verify. You can't change these properties after the KMS key is created. Asymmetric KMS keys contain an RSA key pair, Elliptic Curve (ECC) key pair, ML-DSA key pair or an SM2 key pair (China Regions only). The private key in an asymmetric KMS key never leaves KMS unencrypted. However, you can use the GetPublicKey operation to download the public key so it can be used outside of KMS. Each KMS key can have only one key usage. KMS keys with RSA key pairs can be used to encrypt and decrypt data or sign and verify messages (but not both). KMS keys with NIST-standard ECC key pairs can be used to sign and verify messages or derive shared secrets (but not both). KMS keys with ECC_SECG_P256K1 can be used only to sign and verify messages. KMS keys with ML-DSA key pairs can be used to sign and verify messages. KMS keys with SM2 key pairs (China Regions only) can be used to either encrypt and decrypt data, sign and verify messages, or derive shared secrets (you must choose one key usage type). For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. HMAC KMS key To create an HMAC KMS key, set the KeySpec parameter to a key spec value for HMAC KMS keys. Then set the KeyUsage parameter to GENERATE_VERIFY_MAC. You must set the key usage even though GENERATE_VERIFY_MAC is the only valid key usage value for HMAC KMS keys. You can't change these properties after the KMS key is created. HMAC KMS keys are symmetric keys that never leave KMS unencrypted. You can use HMAC keys to generate (GenerateMac) and verify (VerifyMac) HMAC codes for messages up to 4096 bytes. Multi-Region primary keys To create a multi-Region primary key in the local Amazon Web Services Region, use the MultiRegion parameter with a value of True. To create a multi-Region replica key, that is, a KMS key with the same key ID and key material as a primary key, but in a different Amazon Web Services Region, use the ReplicateKey operation. To change a replica key to a primary key, and its primary key to a replica key, use the UpdatePrimaryRegion operation. You can create multi-Region KMS keys for all supported KMS key types: symmetric encryption KMS keys, HMAC KMS keys, asymmetric encryption KMS keys, and asymmetric signing KMS keys. You can also create multi-Region keys with imported key material. However, you can't create multi-Region keys in a custom key store. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. Imported key material To import your own key material into a KMS key, begin by creating a KMS key with no key material. To do this, use the Origin parameter of CreateKey with a value of EXTERNAL. Next, use GetParametersForImport operation to get a public key and import token. Use the wrapping public key to encrypt your key material. Then, use ImportKeyMaterial with your import token to import the key material. For step-by-step instructions, see Importing Key Material in the Key Management Service Developer Guide . You can import key material into KMS keys of all supported KMS key types: symmetric encryption KMS keys, HMAC KMS keys, asymmetric encryption KMS keys, and asymmetric signing KMS keys. You can also create multi-Region keys with imported key material. However, you can't import key material into a KMS key in a custom key store. To create a multi-Region primary key with imported key material, use the Origin parameter of CreateKey with a value of EXTERNAL and the MultiRegion parameter with a value of True. To create replicas of the multi-Region primary key, use the ReplicateKey operation. For instructions, see Importing key material step 1. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. Custom key store A custom key store lets you protect your Amazon Web Services resources using keys in a backing key store that you own and manage. When you request a cryptographic operation with a KMS key in a custom key store, the operation is performed in the backing key store using its cryptographic keys. KMS supports CloudHSM key stores backed by an CloudHSM cluster and external key stores backed by an external key manager outside of Amazon Web Services. When you create a KMS key in an CloudHSM key store, KMS generates an encryption key in the CloudHSM cluster and associates it with the KMS key. When you create a KMS key in an external key store, you specify an existing encryption key in the external key manager. Some external key managers provide a simpler method for creating a KMS key in an external key store. For details, see your external key manager documentation. Before you create a KMS key in a custom key store, the ConnectionState of the key store must be CONNECTED. To connect the custom key store, use the ConnectCustomKeyStore operation. To find the ConnectionState, use the DescribeCustomKeyStores operation. To create a KMS key in a custom key store, use the CustomKeyStoreId. Use the default KeySpec value, SYMMETRIC_DEFAULT, and the default KeyUsage value, ENCRYPT_DECRYPT to create a symmetric encryption key. No other key type is supported in a custom key store. To create a KMS key in an CloudHSM key store, use the Origin parameter with a value of AWS_CLOUDHSM. The CloudHSM cluster that is associated with the custom key store must have at least two active HSMs in different Availability Zones in the Amazon Web Services Region. To create a KMS key in an external key store, use the Origin parameter with a value of EXTERNAL_KEY_STORE and an XksKeyId parameter that identifies an existing external key. Some external key managers provide a simpler method for creating a KMS key in an external key store. For details, see your external key manager documentation. Cross-account use: No. You cannot use this operation to create a KMS key in a different Amazon Web Services account. Required permissions: kms:CreateKey (IAM policy). To use the Tags parameter, kms:TagResource (IAM policy). For examples and information about related permissions, see Allow a user to create KMS keys in the Key Management Service Developer Guide. Related operations: DescribeKey ListKeys ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateKeyRequest =
  struct
    type nonrec t =
      {
      policy: PolicyType.t option
        [@ocaml.doc
          "The key policy to attach to the KMS key. If you provide a key policy, it must meet the following criteria: The key policy must allow the calling principal to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the Key Management Service Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.) Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal, you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide. If either of the required Resource or Action elements are missing from a key policy statement, the policy statement has no effect. When a key policy statement is missing one of these elements, the KMS console correctly reports an error, but the CreateKey and PutKeyPolicy API requests succeed, even though the policy statement is ineffective. For more information on required key policy elements, see Elements in a key policy in the Key Management Service Developer Guide. If you do not provide a key policy, KMS attaches a default key policy to the KMS key. For more information, see Default key policy in the Key Management Service Developer Guide. If the key policy exceeds the length constraint, KMS returns a LimitExceededException. For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide ."];
      description: DescriptionType.t option
        [@ocaml.doc
          "A description of the KMS key. Use a description that helps you decide whether the KMS key is appropriate for a task. The default value is an empty string (no description). Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. To set or change the description after the key is created, use UpdateKeyDescription."];
      keyUsage: KeyUsageType.t option
        [@ocaml.doc
          "Determines the cryptographic operations for which you can use the KMS key. The default value is ENCRYPT_DECRYPT. This parameter is optional when you are creating a symmetric encryption KMS key; otherwise, it is required. You can't change the KeyUsage value after the KMS key is created. Each KMS key can have only one key usage. This follows key usage best practices according to NIST SP 800-57 Recommendations for Key Management, section 5.2, Key usage. Select only one valid value. For symmetric encryption KMS keys, omit the parameter or specify ENCRYPT_DECRYPT. For HMAC KMS keys (symmetric), specify GENERATE_VERIFY_MAC. For asymmetric KMS keys with RSA key pairs, specify ENCRYPT_DECRYPT or SIGN_VERIFY. For asymmetric KMS keys with NIST-standard elliptic curve key pairs, specify SIGN_VERIFY or KEY_AGREEMENT. For asymmetric KMS keys with ECC_SECG_P256K1 key pairs, specify SIGN_VERIFY. For asymmetric KMS keys with ML-DSA key pairs, specify SIGN_VERIFY. For asymmetric KMS keys with SM2 key pairs (China Regions only), specify ENCRYPT_DECRYPT, SIGN_VERIFY, or KEY_AGREEMENT."];
      customerMasterKeySpec: CustomerMasterKeySpec.t option
        [@ocaml.doc
          "Instead, use the KeySpec parameter. The KeySpec and CustomerMasterKeySpec parameters work the same way. Only the names differ. We recommend that you use KeySpec parameter in your code. However, to avoid breaking changes, KMS supports both parameters."];
      keySpec: KeySpec.t option
        [@ocaml.doc
          "Specifies the type of KMS key to create. The default value, SYMMETRIC_DEFAULT, creates a KMS key with a 256-bit AES-GCM key that is used for encryption and decryption, except in China Regions, where it creates a 128-bit symmetric key that uses SM4 encryption. For a detailed description of all supported key specs, see Key spec reference in the Key Management Service Developer Guide . The KeySpec determines whether the KMS key contains a symmetric key or an asymmetric key pair. It also determines the algorithms that the KMS key supports. You can't change the KeySpec after the KMS key is created. To further restrict the algorithms that can be used with the KMS key, use a condition key in its key policy or IAM policy. For more information, see kms:EncryptionAlgorithm, kms:MacAlgorithm, kms:KeyAgreementAlgorithm, or kms:SigningAlgorithm in the Key Management Service Developer Guide . Amazon Web Services services that are integrated with KMS use symmetric encryption KMS keys to protect your data. These services do not support asymmetric KMS keys or HMAC KMS keys. KMS supports the following key specs for KMS keys: Symmetric encryption key (default) SYMMETRIC_DEFAULT HMAC keys (symmetric) HMAC_224 HMAC_256 HMAC_384 HMAC_512 Asymmetric RSA key pairs (encryption and decryption -or- signing and verification) RSA_2048 RSA_3072 RSA_4096 Asymmetric NIST-standard elliptic curve key pairs (signing and verification -or- deriving shared secrets) ECC_NIST_P256 (secp256r1) ECC_NIST_P384 (secp384r1) ECC_NIST_P521 (secp521r1) ECC_NIST_EDWARDS25519 (ed25519) - signing and verification only Note: For ECC_NIST_EDWARDS25519 KMS keys, the ED25519_SHA_512 signing algorithm requires MessageType:RAW , while ED25519_PH_SHA_512 requires MessageType:DIGEST . These message types cannot be used interchangeably. Other asymmetric elliptic curve key pairs (signing and verification) ECC_SECG_P256K1 (secp256k1), commonly used for cryptocurrencies. Asymmetric ML-DSA key pairs (signing and verification) ML_DSA_44 ML_DSA_65 ML_DSA_87 SM2 key pairs (encryption and decryption -or- signing and verification -or- deriving shared secrets) SM2 (China Regions only)"];
      origin: OriginType.t option
        [@ocaml.doc
          "The source of the key material for the KMS key. You cannot change the origin after you create the KMS key. The default is AWS_KMS, which means that KMS creates the key material. To create a KMS key with no key material (for imported key material), set this value to EXTERNAL. For more information about importing key material into KMS, see Importing Key Material in the Key Management Service Developer Guide. The EXTERNAL origin value is valid only for symmetric KMS keys. To create a KMS key in an CloudHSM key store and create its key material in the associated CloudHSM cluster, set this value to AWS_CLOUDHSM. You must also use the CustomKeyStoreId parameter to identify the CloudHSM key store. The KeySpec value must be SYMMETRIC_DEFAULT. To create a KMS key in an external key store, set this value to EXTERNAL_KEY_STORE. You must also use the CustomKeyStoreId parameter to identify the external key store and the XksKeyId parameter to identify the associated external key. The KeySpec value must be SYMMETRIC_DEFAULT."];
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc
          "Creates the KMS key in the specified custom key store. The ConnectionState of the custom key store must be CONNECTED. To find the CustomKeyStoreID and ConnectionState use the DescribeCustomKeyStores operation. This parameter is valid only for symmetric encryption KMS keys in a single Region. You cannot create any other type of KMS key in a custom key store. When you create a KMS key in an CloudHSM key store, KMS generates a non-exportable 256-bit symmetric key in its associated CloudHSM cluster and associates it with the KMS key. When you create a KMS key in an external key store, you must use the XksKeyId parameter to specify an external key that serves as key material for the KMS key."];
      bypassPolicyLockoutSafetyCheck: BooleanType.t option
        [@ocaml.doc
          "Skips (\"bypasses\") the key policy lockout safety check. The default value is false. Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately. For more information, see Default key policy in the Key Management Service Developer Guide. Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key."];
      tags: TagList.t option
        [@ocaml.doc
          "Assigns one or more tags to the KMS key. Use this parameter to tag the KMS key when it is created. To tag an existing KMS key, use the TagResource operation. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. To use this parameter, you must have kms:TagResource permission in an IAM policy. Each tag consists of a tag key and a tag value. Both the tag key and the tag value are required, but the tag value can be an empty (null) string. You cannot have more than one tag on a KMS key with the same tag key. If you specify an existing tag key with a different tag value, KMS replaces the current tag value with the specified one. When you add tags to an Amazon Web Services resource, Amazon Web Services generates a cost allocation report with usage and costs aggregated by tags. Tags can also be used to control access to a KMS key. For details, see Tags in KMS."];
      multiRegion: NullableBooleanType.t option
        [@ocaml.doc
          "Creates a multi-Region primary key that you can replicate into other Amazon Web Services Regions. You cannot change this value after you create the KMS key. For a multi-Region key, set this parameter to True. For a single-Region KMS key, omit this parameter or set it to False. The default value is False. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. This value creates a primary key, not a replica. To create a replica key, use the ReplicateKey operation. You can create a symmetric or asymmetric multi-Region key, and you can create a multi-Region key with imported key material. However, you cannot create a multi-Region key in a custom key store."];
      xksKeyId: XksKeyIdType.t option
        [@ocaml.doc
          "Identifies the external key that serves as key material for the KMS key in an external key store. Specify the ID that the external key store proxy uses to refer to the external key. For help, see the documentation for your external key store proxy. This parameter is required for a KMS key with an Origin value of EXTERNAL_KEY_STORE. It is not valid for KMS keys with any other Origin value. The external key must be an existing 256-bit AES symmetric encryption key hosted outside of Amazon Web Services in an external key manager associated with the external key store specified by the CustomKeyStoreId parameter. This key must be enabled and configured to perform encryption and decryption. Each KMS key in an external key store must use a different external key. For details, see Requirements for a KMS key in an external key store in the Key Management Service Developer Guide. Each KMS key in an external key store is associated two backing keys. One is key material that KMS generates. The other is the external key specified by this parameter. When you use the KMS key in an external key store to encrypt data, the encryption operation is performed first by KMS using the KMS key material, and then by the external key manager using the specified external key, a process known as double encryption. For details, see Double encryption in the Key Management Service Developer Guide."]}
    let make ?policy =
      fun ?description ->
        fun ?keyUsage ->
          fun ?customerMasterKeySpec ->
            fun ?keySpec ->
              fun ?origin ->
                fun ?customKeyStoreId ->
                  fun ?bypassPolicyLockoutSafetyCheck ->
                    fun ?tags ->
                      fun ?multiRegion ->
                        fun ?xksKeyId ->
                          fun () ->
                            {
                              policy;
                              description;
                              keyUsage;
                              customerMasterKeySpec;
                              keySpec;
                              origin;
                              customKeyStoreId;
                              bypassPolicyLockoutSafetyCheck;
                              tags;
                              multiRegion;
                              xksKeyId
                            }
    let to_value x =
      structure_to_value
        [("Policy", (Option.map x.policy ~f:PolicyType.to_value));
        ("Description",
          (Option.map x.description ~f:DescriptionType.to_value));
        ("KeyUsage", (Option.map x.keyUsage ~f:KeyUsageType.to_value));
        ("CustomerMasterKeySpec",
          (Option.map x.customerMasterKeySpec
             ~f:CustomerMasterKeySpec.to_value));
        ("KeySpec", (Option.map x.keySpec ~f:KeySpec.to_value));
        ("Origin", (Option.map x.origin ~f:OriginType.to_value));
        ("CustomKeyStoreId",
          (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value));
        ("BypassPolicyLockoutSafetyCheck",
          (Option.map x.bypassPolicyLockoutSafetyCheck
             ~f:BooleanType.to_value));
        ("Tags", (Option.map x.tags ~f:TagList.to_value));
        ("MultiRegion",
          (Option.map x.multiRegion ~f:NullableBooleanType.to_value));
        ("XksKeyId", (Option.map x.xksKeyId ~f:XksKeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let xksKeyId =
        (Option.map ~f:XksKeyIdType.of_xml) (Xml.child xml_arg0 "XksKeyId") in
      let multiRegion =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "MultiRegion") in
      let tags = (Option.map ~f:TagList.of_xml) (Xml.child xml_arg0 "Tags") in
      let bypassPolicyLockoutSafetyCheck =
        (Option.map ~f:BooleanType.of_xml)
          (Xml.child xml_arg0 "BypassPolicyLockoutSafetyCheck") in
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      let origin =
        (Option.map ~f:OriginType.of_xml) (Xml.child xml_arg0 "Origin") in
      let keySpec =
        (Option.map ~f:KeySpec.of_xml) (Xml.child xml_arg0 "KeySpec") in
      let customerMasterKeySpec =
        (Option.map ~f:CustomerMasterKeySpec.of_xml)
          (Xml.child xml_arg0 "CustomerMasterKeySpec") in
      let keyUsage =
        (Option.map ~f:KeyUsageType.of_xml) (Xml.child xml_arg0 "KeyUsage") in
      let description =
        (Option.map ~f:DescriptionType.of_xml)
          (Xml.child xml_arg0 "Description") in
      let policy =
        (Option.map ~f:PolicyType.of_xml) (Xml.child xml_arg0 "Policy") in
      make ?xksKeyId ?multiRegion ?tags ?bypassPolicyLockoutSafetyCheck
        ?customKeyStoreId ?origin ?keySpec ?customerMasterKeySpec ?keyUsage
        ?description ?policy ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let xksKeyId = field_map json__ "XksKeyId" XksKeyIdType.of_json in
      let multiRegion =
        field_map json__ "MultiRegion" NullableBooleanType.of_json in
      let tags = field_map json__ "Tags" TagList.of_json in
      let bypassPolicyLockoutSafetyCheck =
        field_map json__ "BypassPolicyLockoutSafetyCheck" BooleanType.of_json in
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      let origin = field_map json__ "Origin" OriginType.of_json in
      let keySpec = field_map json__ "KeySpec" KeySpec.of_json in
      let customerMasterKeySpec =
        field_map json__ "CustomerMasterKeySpec"
          CustomerMasterKeySpec.of_json in
      let keyUsage = field_map json__ "KeyUsage" KeyUsageType.of_json in
      let description =
        field_map json__ "Description" DescriptionType.of_json in
      let policy = field_map json__ "Policy" PolicyType.of_json in
      make ?xksKeyId ?multiRegion ?tags ?bypassPolicyLockoutSafetyCheck
        ?customKeyStoreId ?origin ?keySpec ?customerMasterKeySpec ?keyUsage
        ?description ?policy ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a unique customer managed KMS key in your Amazon Web Services account and Region. You can use a KMS key in cryptographic operations, such as encryption and signing. Some Amazon Web Services services let you use KMS keys that you create and manage to protect your service resources. A KMS key is a logical representation of a cryptographic key. In addition to the key material used in cryptographic operations, a KMS key includes metadata, such as the key ID, key policy, creation date, description, and key state. Use the parameters of CreateKey to specify the type of KMS key, the source of its key material, its key policy, description, tags, and other properties. KMS has replaced the term customer master key (CMK) with Key Management Service key and KMS key. The concept has not changed. To prevent breaking changes, KMS is keeping some variations of this term. To create different types of KMS keys, use the following guidance: Symmetric encryption KMS key By default, CreateKey creates a symmetric encryption KMS key with key material that KMS generates. This is the basic and most widely used type of KMS key, and provides the best performance. To create a symmetric encryption KMS key, you don't need to specify any parameters. The default value for KeySpec, SYMMETRIC_DEFAULT, the default value for KeyUsage, ENCRYPT_DECRYPT, and the default value for Origin, AWS_KMS, create a symmetric encryption KMS key with KMS key material. If you need a key for basic encryption and decryption or you are creating a KMS key to protect your resources in an Amazon Web Services service, create a symmetric encryption KMS key. The key material in a symmetric encryption key never leaves KMS unencrypted. You can use a symmetric encryption KMS key to encrypt and decrypt data up to 4,096 bytes, but they are typically used to generate data keys and data keys pairs. For details, see GenerateDataKey and GenerateDataKeyPair. Asymmetric KMS keys To create an asymmetric KMS key, use the KeySpec parameter to specify the type of key material in the KMS key. Then, use the KeyUsage parameter to determine whether the KMS key will be used to encrypt and decrypt or sign and verify. You can't change these properties after the KMS key is created. Asymmetric KMS keys contain an RSA key pair, Elliptic Curve (ECC) key pair, ML-DSA key pair or an SM2 key pair (China Regions only). The private key in an asymmetric KMS key never leaves KMS unencrypted. However, you can use the GetPublicKey operation to download the public key so it can be used outside of KMS. Each KMS key can have only one key usage. KMS keys with RSA key pairs can be used to encrypt and decrypt data or sign and verify messages (but not both). KMS keys with NIST-standard ECC key pairs can be used to sign and verify messages or derive shared secrets (but not both). KMS keys with ECC_SECG_P256K1 can be used only to sign and verify messages. KMS keys with ML-DSA key pairs can be used to sign and verify messages. KMS keys with SM2 key pairs (China Regions only) can be used to either encrypt and decrypt data, sign and verify messages, or derive shared secrets (you must choose one key usage type). For information about asymmetric KMS keys, see Asymmetric KMS keys in the Key Management Service Developer Guide. HMAC KMS key To create an HMAC KMS key, set the KeySpec parameter to a key spec value for HMAC KMS keys. Then set the KeyUsage parameter to GENERATE_VERIFY_MAC. You must set the key usage even though GENERATE_VERIFY_MAC is the only valid key usage value for HMAC KMS keys. You can't change these properties after the KMS key is created. HMAC KMS keys are symmetric keys that never leave KMS unencrypted. You can use HMAC keys to generate (GenerateMac) and verify (VerifyMac) HMAC codes for messages up to 4096 bytes. Multi-Region primary keys To create a multi-Region primary key in the local Amazon Web Services Region, use the MultiRegion parameter with a value of True. To create a multi-Region replica key, that is, a KMS key with the same key ID and key material as a primary key, but in a different Amazon Web Services Region, use the ReplicateKey operation. To change a replica key to a primary key, and its primary key to a replica key, use the UpdatePrimaryRegion operation. You can create multi-Region KMS keys for all supported KMS key types: symmetric encryption KMS keys, HMAC KMS keys, asymmetric encryption KMS keys, and asymmetric signing KMS keys. You can also create multi-Region keys with imported key material. However, you can't create multi-Region keys in a custom key store. This operation supports multi-Region keys, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. Imported key material To import your own key material into a KMS key, begin by creating a KMS key with no key material. To do this, use the Origin parameter of CreateKey with a value of EXTERNAL. Next, use GetParametersForImport operation to get a public key and import token. Use the wrapping public key to encrypt your key material. Then, use ImportKeyMaterial with your import token to import the key material. For step-by-step instructions, see Importing Key Material in the Key Management Service Developer Guide . You can import key material into KMS keys of all supported KMS key types: symmetric encryption KMS keys, HMAC KMS keys, asymmetric encryption KMS keys, and asymmetric signing KMS keys. You can also create multi-Region keys with imported key material. However, you can't import key material into a KMS key in a custom key store. To create a multi-Region primary key with imported key material, use the Origin parameter of CreateKey with a value of EXTERNAL and the MultiRegion parameter with a value of True. To create replicas of the multi-Region primary key, use the ReplicateKey operation. For instructions, see Importing key material step 1. For more information about multi-Region keys, see Multi-Region keys in KMS in the Key Management Service Developer Guide. Custom key store A custom key store lets you protect your Amazon Web Services resources using keys in a backing key store that you own and manage. When you request a cryptographic operation with a KMS key in a custom key store, the operation is performed in the backing key store using its cryptographic keys. KMS supports CloudHSM key stores backed by an CloudHSM cluster and external key stores backed by an external key manager outside of Amazon Web Services. When you create a KMS key in an CloudHSM key store, KMS generates an encryption key in the CloudHSM cluster and associates it with the KMS key. When you create a KMS key in an external key store, you specify an existing encryption key in the external key manager. Some external key managers provide a simpler method for creating a KMS key in an external key store. For details, see your external key manager documentation. Before you create a KMS key in a custom key store, the ConnectionState of the key store must be CONNECTED. To connect the custom key store, use the ConnectCustomKeyStore operation. To find the ConnectionState, use the DescribeCustomKeyStores operation. To create a KMS key in a custom key store, use the CustomKeyStoreId. Use the default KeySpec value, SYMMETRIC_DEFAULT, and the default KeyUsage value, ENCRYPT_DECRYPT to create a symmetric encryption key. No other key type is supported in a custom key store. To create a KMS key in an CloudHSM key store, use the Origin parameter with a value of AWS_CLOUDHSM. The CloudHSM cluster that is associated with the custom key store must have at least two active HSMs in different Availability Zones in the Amazon Web Services Region. To create a KMS key in an external key store, use the Origin parameter with a value of EXTERNAL_KEY_STORE and an XksKeyId parameter that identifies an existing external key. Some external key managers provide a simpler method for creating a KMS key in an external key store. For details, see your external key manager documentation. Cross-account use: No. You cannot use this operation to create a KMS key in a different Amazon Web Services account. Required permissions: kms:CreateKey (IAM policy). To use the Tags parameter, kms:TagResource (IAM policy). For examples and information about related permissions, see Allow a user to create KMS keys in the Key Management Service Developer Guide. Related operations: DescribeKey ListKeys ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateGrantResponse =
  struct
    type nonrec t =
      {
      grantToken: GrantTokenType.t option
        [@ocaml.doc
          "The grant token. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      grantId: GrantIdType.t option
        [@ocaml.doc
          "The unique identifier for the grant. You can use the GrantId in a ListGrants, RetireGrant, or RevokeGrant operation."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `DisabledException of DisabledException.t 
      | `DryRunOperationException of DryRunOperationException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `InvalidGrantTokenException of InvalidGrantTokenException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?grantToken = fun ?grantId -> fun () -> { grantToken; grantId }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_json json)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException
            (InvalidGrantTokenException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "DisabledException" ->
          `DisabledException (DisabledException.of_xml xml)
      | "DryRunOperationException" ->
          `DryRunOperationException (DryRunOperationException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "InvalidGrantTokenException" ->
          `InvalidGrantTokenException (InvalidGrantTokenException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `DisabledException e ->
          `Assoc
            [("error", (`String "DisabledException"));
            ("details", (DisabledException.to_json e))]
      | `DryRunOperationException e ->
          `Assoc
            [("error", (`String "DryRunOperationException"));
            ("details", (DryRunOperationException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `InvalidGrantTokenException e ->
          `Assoc
            [("error", (`String "InvalidGrantTokenException"));
            ("details", (InvalidGrantTokenException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("GrantToken", (Option.map x.grantToken ~f:GrantTokenType.to_value));
        ("GrantId", (Option.map x.grantId ~f:GrantIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let grantId =
        (Option.map ~f:GrantIdType.of_xml) (Xml.child xml_arg0 "GrantId") in
      let grantToken =
        (Option.map ~f:GrantTokenType.of_xml)
          (Xml.child xml_arg0 "GrantToken") in
      make ?grantId ?grantToken ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let grantId = field_map json__ "GrantId" GrantIdType.of_json in
      let grantToken = field_map json__ "GrantToken" GrantTokenType.of_json in
      make ?grantId ?grantToken ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Adds a grant to a KMS key. A grant is a policy instrument that allows Amazon Web Services principals to use KMS keys in cryptographic operations. It also can allow them to view a KMS key (DescribeKey) and create and manage grants. When authorizing access to a KMS key, grants are considered along with key policies and IAM policies. Grants are often used for temporary permissions because you can create one, use its permissions, and delete it without changing your key policies or IAM policies. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. The CreateGrant operation returns a GrantToken and a GrantId. When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as eventual consistency. Once the grant has achieved eventual consistency, the grantee principal can use the permissions in the grant without identifying the grant. However, to use the permissions in the grant immediately, use the GrantToken that CreateGrant returns. For details, see Using a grant token in the Key Management Service Developer Guide . The CreateGrant operation also returns a GrantId. You can use the GrantId and a key identifier to identify the grant in the RetireGrant and RevokeGrant operations. To find the grant ID, use the ListGrants or ListRetirableGrants operations. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:CreateGrant (key policy) Related operations: ListGrants ListRetirableGrants RetireGrant RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateGrantRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key for the grant. The grant gives principals permission to use this KMS key. Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."];
      granteePrincipal: PrincipalIdType.t
        [@ocaml.doc
          "The identity that gets the permissions specified in the grant. To specify the grantee principal, use the Amazon Resource Name (ARN) of an Amazon Web Services principal. Valid principals include Amazon Web Services accounts, IAM users, IAM roles, federated users, and assumed role users. For help with the ARN syntax for a principal, see IAM ARNs in the Identity and Access Management User Guide ."];
      retiringPrincipal: PrincipalIdType.t option
        [@ocaml.doc
          "The principal that has permission to use the RetireGrant operation to retire the grant. To specify the principal, use the Amazon Resource Name (ARN) of an Amazon Web Services principal. Valid principals include Amazon Web Services accounts, IAM users, IAM roles, federated users, and assumed role users. For help with the ARN syntax for a principal, see IAM ARNs in the Identity and Access Management User Guide . The grant determines the retiring principal. Other principals might have permission to retire the grant or revoke the grant. For details, see RevokeGrant and Retiring and revoking grants in the Key Management Service Developer Guide."];
      operations: GrantOperationList.t
        [@ocaml.doc
          "A list of operations that the grant permits. This list must include only operations that are permitted in a grant. Also, the operation must be supported on the KMS key. For example, you cannot create a grant for a symmetric encryption KMS key that allows the Sign operation, or a grant for an asymmetric KMS key that allows the GenerateDataKey operation. If you try, KMS returns a ValidationError exception. For details, see Grant operations in the Key Management Service Developer Guide."];
      constraints: GrantConstraints.t option
        [@ocaml.doc
          "Specifies a grant constraint. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. KMS supports the EncryptionContextEquals and EncryptionContextSubset grant constraints, which allow the permissions in the grant only when the encryption context in the request matches (EncryptionContextEquals) or includes (EncryptionContextSubset) the encryption context specified in the constraint. The encryption context grant constraints are supported only on grant operations that include an EncryptionContext parameter, such as cryptographic operations on symmetric encryption KMS keys. Grants with grant constraints can include the DescribeKey and RetireGrant operations, but the constraint doesn't apply to these operations. If a grant with a grant constraint includes the CreateGrant operation, the constraint requires that any grants created with the CreateGrant permission have an equally strict or stricter encryption context constraint. You cannot use an encryption context grant constraint for cryptographic operations with asymmetric KMS keys or HMAC KMS keys. Operations with these keys don't support an encryption context. Each constraint value can include up to 8 encryption context pairs. The encryption context value in each constraint cannot exceed 384 characters. For information about grant constraints, see Using grant constraints in the Key Management Service Developer Guide. For more information about encryption context, see Encryption context in the Key Management Service Developer Guide ."];
      grantTokens: GrantTokenList.t option
        [@ocaml.doc
          "A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency. For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide."];
      name: GrantNameType.t option
        [@ocaml.doc
          "A friendly name for the grant. Use this value to prevent the unintended creation of duplicate grants when retrying this request. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. When this value is absent, all CreateGrant requests result in a new grant with a unique GrantId even if all the supplied parameters are identical. This can result in unintended duplicates when you retry the CreateGrant request. When this value is present, you can retry a CreateGrant request with identical parameters; if the grant already exists, the original GrantId is returned without creating a new grant. Note that the returned grant token is unique with every CreateGrant request, even when a duplicate GrantId is returned. All grant tokens for the same grant ID can be used interchangeably."];
      dryRun: NullableBooleanType.t option
        [@ocaml.doc
          "Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide."]}
    let context_ = "CreateGrantRequest"
    let make ?retiringPrincipal =
      fun ?constraints ->
        fun ?grantTokens ->
          fun ?name ->
            fun ?dryRun ->
              fun ~keyId ->
                fun ~granteePrincipal ->
                  fun ~operations ->
                    fun () ->
                      {
                        retiringPrincipal;
                        constraints;
                        grantTokens;
                        name;
                        dryRun;
                        keyId;
                        granteePrincipal;
                        operations
                      }
    let to_value x =
      structure_to_value
        [("KeyId", (Some (KeyIdType.to_value x.keyId)));
        ("GranteePrincipal",
          (Some (PrincipalIdType.to_value x.granteePrincipal)));
        ("RetiringPrincipal",
          (Option.map x.retiringPrincipal ~f:PrincipalIdType.to_value));
        ("Operations", (Some (GrantOperationList.to_value x.operations)));
        ("Constraints",
          (Option.map x.constraints ~f:GrantConstraints.to_value));
        ("GrantTokens",
          (Option.map x.grantTokens ~f:GrantTokenList.to_value));
        ("Name", (Option.map x.name ~f:GrantNameType.to_value));
        ("DryRun", (Option.map x.dryRun ~f:NullableBooleanType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let dryRun =
        (Option.map ~f:NullableBooleanType.of_xml)
          (Xml.child xml_arg0 "DryRun") in
      let name =
        (Option.map ~f:GrantNameType.of_xml) (Xml.child xml_arg0 "Name") in
      let grantTokens =
        (Option.map ~f:GrantTokenList.of_xml)
          (Xml.child xml_arg0 "GrantTokens") in
      let constraints =
        (Option.map ~f:GrantConstraints.of_xml)
          (Xml.child xml_arg0 "Constraints") in
      let operations =
        GrantOperationList.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "Operations") in
      let retiringPrincipal =
        (Option.map ~f:PrincipalIdType.of_xml)
          (Xml.child xml_arg0 "RetiringPrincipal") in
      let granteePrincipal =
        PrincipalIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "GranteePrincipal") in
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ?dryRun ?name ?grantTokens ?constraints ~operations
        ?retiringPrincipal ~granteePrincipal ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let dryRun = field_map json__ "DryRun" NullableBooleanType.of_json in
      let name = field_map json__ "Name" GrantNameType.of_json in
      let grantTokens = field_map json__ "GrantTokens" GrantTokenList.of_json in
      let constraints =
        field_map json__ "Constraints" GrantConstraints.of_json in
      let operations =
        field_map_exn json__ "Operations" GrantOperationList.of_json in
      let retiringPrincipal =
        field_map json__ "RetiringPrincipal" PrincipalIdType.of_json in
      let granteePrincipal =
        field_map_exn json__ "GranteePrincipal" PrincipalIdType.of_json in
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ?dryRun ?name ?grantTokens ?constraints ~operations
        ?retiringPrincipal ~granteePrincipal ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Adds a grant to a KMS key. A grant is a policy instrument that allows Amazon Web Services principals to use KMS keys in cryptographic operations. It also can allow them to view a KMS key (DescribeKey) and create and manage grants. When authorizing access to a KMS key, grants are considered along with key policies and IAM policies. Grants are often used for temporary permissions because you can create one, use its permissions, and delete it without changing your key policies or IAM policies. For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI. The CreateGrant operation returns a GrantToken and a GrantId. When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as eventual consistency. Once the grant has achieved eventual consistency, the grantee principal can use the permissions in the grant without identifying the grant. However, to use the permissions in the grant immediately, use the GrantToken that CreateGrant returns. For details, see Using a grant token in the Key Management Service Developer Guide . The CreateGrant operation also returns a GrantId. You can use the GrantId and a key identifier to identify the grant in the RetireGrant and RevokeGrant operations. To find the grant ID, use the ListGrants or ListRetirableGrants operations. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter. Required permissions: kms:CreateGrant (key policy) Related operations: ListGrants ListRetirableGrants RetireGrant RevokeGrant Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateCustomKeyStoreResponse =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t option
        [@ocaml.doc "A unique identifier for the new custom key store."]}
    type nonrec error =
      [ `CloudHsmClusterInUseException of CloudHsmClusterInUseException.t 
      | `CloudHsmClusterInvalidConfigurationException of
          CloudHsmClusterInvalidConfigurationException.t 
      | `CloudHsmClusterNotActiveException of
          CloudHsmClusterNotActiveException.t 
      | `CloudHsmClusterNotFoundException of
          CloudHsmClusterNotFoundException.t 
      | `CustomKeyStoreNameInUseException of
          CustomKeyStoreNameInUseException.t 
      | `IncorrectTrustAnchorException of IncorrectTrustAnchorException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `LimitExceededException of LimitExceededException.t 
      | `XksProxyIncorrectAuthenticationCredentialException of
          XksProxyIncorrectAuthenticationCredentialException.t 
      | `XksProxyInvalidConfigurationException of
          XksProxyInvalidConfigurationException.t 
      | `XksProxyInvalidResponseException of
          XksProxyInvalidResponseException.t 
      | `XksProxyUriEndpointInUseException of
          XksProxyUriEndpointInUseException.t 
      | `XksProxyUriInUseException of XksProxyUriInUseException.t 
      | `XksProxyUriUnreachableException of XksProxyUriUnreachableException.t 
      | `XksProxyVpcEndpointServiceInUseException of
          XksProxyVpcEndpointServiceInUseException.t 
      | `XksProxyVpcEndpointServiceInvalidConfigurationException of
          XksProxyVpcEndpointServiceInvalidConfigurationException.t 
      | `XksProxyVpcEndpointServiceNotFoundException of
          XksProxyVpcEndpointServiceNotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?customKeyStoreId = fun () -> { customKeyStoreId }
    let error_of_json name json =
      match name with
      | "CloudHsmClusterInUseException" ->
          `CloudHsmClusterInUseException
            (CloudHsmClusterInUseException.of_json json)
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_json json)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_json json)
      | "CloudHsmClusterNotFoundException" ->
          `CloudHsmClusterNotFoundException
            (CloudHsmClusterNotFoundException.of_json json)
      | "CustomKeyStoreNameInUseException" ->
          `CustomKeyStoreNameInUseException
            (CustomKeyStoreNameInUseException.of_json json)
      | "IncorrectTrustAnchorException" ->
          `IncorrectTrustAnchorException
            (IncorrectTrustAnchorException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_json json)
      | "XksProxyIncorrectAuthenticationCredentialException" ->
          `XksProxyIncorrectAuthenticationCredentialException
            (XksProxyIncorrectAuthenticationCredentialException.of_json json)
      | "XksProxyInvalidConfigurationException" ->
          `XksProxyInvalidConfigurationException
            (XksProxyInvalidConfigurationException.of_json json)
      | "XksProxyInvalidResponseException" ->
          `XksProxyInvalidResponseException
            (XksProxyInvalidResponseException.of_json json)
      | "XksProxyUriEndpointInUseException" ->
          `XksProxyUriEndpointInUseException
            (XksProxyUriEndpointInUseException.of_json json)
      | "XksProxyUriInUseException" ->
          `XksProxyUriInUseException (XksProxyUriInUseException.of_json json)
      | "XksProxyUriUnreachableException" ->
          `XksProxyUriUnreachableException
            (XksProxyUriUnreachableException.of_json json)
      | "XksProxyVpcEndpointServiceInUseException" ->
          `XksProxyVpcEndpointServiceInUseException
            (XksProxyVpcEndpointServiceInUseException.of_json json)
      | "XksProxyVpcEndpointServiceInvalidConfigurationException" ->
          `XksProxyVpcEndpointServiceInvalidConfigurationException
            (XksProxyVpcEndpointServiceInvalidConfigurationException.of_json
               json)
      | "XksProxyVpcEndpointServiceNotFoundException" ->
          `XksProxyVpcEndpointServiceNotFoundException
            (XksProxyVpcEndpointServiceNotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CloudHsmClusterInUseException" ->
          `CloudHsmClusterInUseException
            (CloudHsmClusterInUseException.of_xml xml)
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_xml xml)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_xml xml)
      | "CloudHsmClusterNotFoundException" ->
          `CloudHsmClusterNotFoundException
            (CloudHsmClusterNotFoundException.of_xml xml)
      | "CustomKeyStoreNameInUseException" ->
          `CustomKeyStoreNameInUseException
            (CustomKeyStoreNameInUseException.of_xml xml)
      | "IncorrectTrustAnchorException" ->
          `IncorrectTrustAnchorException
            (IncorrectTrustAnchorException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "LimitExceededException" ->
          `LimitExceededException (LimitExceededException.of_xml xml)
      | "XksProxyIncorrectAuthenticationCredentialException" ->
          `XksProxyIncorrectAuthenticationCredentialException
            (XksProxyIncorrectAuthenticationCredentialException.of_xml xml)
      | "XksProxyInvalidConfigurationException" ->
          `XksProxyInvalidConfigurationException
            (XksProxyInvalidConfigurationException.of_xml xml)
      | "XksProxyInvalidResponseException" ->
          `XksProxyInvalidResponseException
            (XksProxyInvalidResponseException.of_xml xml)
      | "XksProxyUriEndpointInUseException" ->
          `XksProxyUriEndpointInUseException
            (XksProxyUriEndpointInUseException.of_xml xml)
      | "XksProxyUriInUseException" ->
          `XksProxyUriInUseException (XksProxyUriInUseException.of_xml xml)
      | "XksProxyUriUnreachableException" ->
          `XksProxyUriUnreachableException
            (XksProxyUriUnreachableException.of_xml xml)
      | "XksProxyVpcEndpointServiceInUseException" ->
          `XksProxyVpcEndpointServiceInUseException
            (XksProxyVpcEndpointServiceInUseException.of_xml xml)
      | "XksProxyVpcEndpointServiceInvalidConfigurationException" ->
          `XksProxyVpcEndpointServiceInvalidConfigurationException
            (XksProxyVpcEndpointServiceInvalidConfigurationException.of_xml
               xml)
      | "XksProxyVpcEndpointServiceNotFoundException" ->
          `XksProxyVpcEndpointServiceNotFoundException
            (XksProxyVpcEndpointServiceNotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CloudHsmClusterInUseException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterInUseException"));
            ("details", (CloudHsmClusterInUseException.to_json e))]
      | `CloudHsmClusterInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String "CloudHsmClusterInvalidConfigurationException"));
            ("details",
              (CloudHsmClusterInvalidConfigurationException.to_json e))]
      | `CloudHsmClusterNotActiveException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotActiveException"));
            ("details", (CloudHsmClusterNotActiveException.to_json e))]
      | `CloudHsmClusterNotFoundException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotFoundException"));
            ("details", (CloudHsmClusterNotFoundException.to_json e))]
      | `CustomKeyStoreNameInUseException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNameInUseException"));
            ("details", (CustomKeyStoreNameInUseException.to_json e))]
      | `IncorrectTrustAnchorException e ->
          `Assoc
            [("error", (`String "IncorrectTrustAnchorException"));
            ("details", (IncorrectTrustAnchorException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `LimitExceededException e ->
          `Assoc
            [("error", (`String "LimitExceededException"));
            ("details", (LimitExceededException.to_json e))]
      | `XksProxyIncorrectAuthenticationCredentialException e ->
          `Assoc
            [("error",
               (`String "XksProxyIncorrectAuthenticationCredentialException"));
            ("details",
              (XksProxyIncorrectAuthenticationCredentialException.to_json e))]
      | `XksProxyInvalidConfigurationException e ->
          `Assoc
            [("error", (`String "XksProxyInvalidConfigurationException"));
            ("details", (XksProxyInvalidConfigurationException.to_json e))]
      | `XksProxyInvalidResponseException e ->
          `Assoc
            [("error", (`String "XksProxyInvalidResponseException"));
            ("details", (XksProxyInvalidResponseException.to_json e))]
      | `XksProxyUriEndpointInUseException e ->
          `Assoc
            [("error", (`String "XksProxyUriEndpointInUseException"));
            ("details", (XksProxyUriEndpointInUseException.to_json e))]
      | `XksProxyUriInUseException e ->
          `Assoc
            [("error", (`String "XksProxyUriInUseException"));
            ("details", (XksProxyUriInUseException.to_json e))]
      | `XksProxyUriUnreachableException e ->
          `Assoc
            [("error", (`String "XksProxyUriUnreachableException"));
            ("details", (XksProxyUriUnreachableException.to_json e))]
      | `XksProxyVpcEndpointServiceInUseException e ->
          `Assoc
            [("error", (`String "XksProxyVpcEndpointServiceInUseException"));
            ("details", (XksProxyVpcEndpointServiceInUseException.to_json e))]
      | `XksProxyVpcEndpointServiceInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String
                  "XksProxyVpcEndpointServiceInvalidConfigurationException"));
            ("details",
              (XksProxyVpcEndpointServiceInvalidConfigurationException.to_json
                 e))]
      | `XksProxyVpcEndpointServiceNotFoundException e ->
          `Assoc
            [("error",
               (`String "XksProxyVpcEndpointServiceNotFoundException"));
            ("details",
              (XksProxyVpcEndpointServiceNotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Option.map x.customKeyStoreId ~f:CustomKeyStoreIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let customKeyStoreId =
        (Option.map ~f:CustomKeyStoreIdType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreId") in
      make ?customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let customKeyStoreId =
        field_map json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ?customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a custom key store backed by a key store that you own and manage. When you use a KMS key in a custom key store for a cryptographic operation, the cryptographic operation is actually performed in your key store using your keys. KMS supports CloudHSM key stores backed by an CloudHSM cluster and external key stores backed by an external key store proxy and external key manager outside of Amazon Web Services. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. Before you create the custom key store, the required elements must be in place and operational. We recommend that you use the test tools that KMS provides to verify the configuration your external key store proxy. For details about the required elements and verification tests, see Assemble the prerequisites (for CloudHSM key stores) or Assemble the prerequisites (for external key stores) in the Key Management Service Developer Guide. To create a custom key store, use the following parameters. To create an CloudHSM key store, specify the CustomKeyStoreName, CloudHsmClusterId, KeyStorePassword, and TrustAnchorCertificate. The CustomKeyStoreType parameter is optional for CloudHSM key stores. If you include it, set it to the default value, AWS_CLOUDHSM. For help with failures, see Troubleshooting an CloudHSM key store in the Key Management Service Developer Guide. To create an external key store, specify the CustomKeyStoreName and a CustomKeyStoreType of EXTERNAL_KEY_STORE. Also, specify values for XksProxyConnectivity, XksProxyAuthenticationCredential, XksProxyUriEndpoint, and XksProxyUriPath. If your XksProxyConnectivity value is VPC_ENDPOINT_SERVICE, specify the XksProxyVpcEndpointServiceName parameter. For help with failures, see Troubleshooting an external key store in the Key Management Service Developer Guide. For external key stores: Some external key managers provide a simpler method for creating an external key store. For details, see your external key manager documentation. When creating an external key store in the KMS console, you can upload a JSON-based proxy configuration file with the desired values. You cannot use a proxy configuration with the CreateCustomKeyStore operation. However, you can use the values in the file to help you determine the correct values for the CreateCustomKeyStore parameters. When the operation completes successfully, it returns the ID of the new custom key store. Before you can use your new custom key store, you need to use the ConnectCustomKeyStore operation to connect a new CloudHSM key store to its CloudHSM cluster, or to connect a new external key store to the external key store proxy for your external key manager. Even if you are not going to use your custom key store immediately, you might want to connect it to verify that all settings are correct and then disconnect it until you are ready to use it. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:CreateCustomKeyStore (IAM policy). Related operations: ConnectCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateCustomKeyStoreRequest =
  struct
    type nonrec t =
      {
      customKeyStoreName: CustomKeyStoreNameType.t
        [@ocaml.doc
          "Specifies a friendly name for the custom key store. The name must be unique in your Amazon Web Services account and Region. This parameter is required for all custom key stores. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output."];
      cloudHsmClusterId: CloudHsmClusterIdType.t option
        [@ocaml.doc
          "Identifies the CloudHSM cluster for an CloudHSM key store. This parameter is required for custom key stores with CustomKeyStoreType of AWS_CLOUDHSM. Enter the cluster ID of any active CloudHSM cluster that is not already associated with a custom key store. To find the cluster ID, use the DescribeClusters operation."];
      trustAnchorCertificate: TrustAnchorCertificateType.t option
        [@ocaml.doc
          "Specifies the certificate for an CloudHSM key store. This parameter is required for custom key stores with a CustomKeyStoreType of AWS_CLOUDHSM. Enter the content of the trust anchor certificate for the CloudHSM cluster. This is the content of the customerCA.crt file that you created when you initialized the cluster."];
      keyStorePassword: KeyStorePasswordType.t option
        [@ocaml.doc
          "Specifies the kmsuser password for an CloudHSM key store. This parameter is required for custom key stores with a CustomKeyStoreType of AWS_CLOUDHSM. Enter the password of the kmsuser crypto user (CU) account in the specified CloudHSM cluster. KMS logs into the cluster as this user to manage key material on your behalf. The password must be a string of 7 to 32 characters. Its value is case sensitive. This parameter tells KMS the kmsuser account password; it does not change the password in the CloudHSM cluster."];
      customKeyStoreType: CustomKeyStoreType.t option
        [@ocaml.doc
          "Specifies the type of custom key store. The default value is AWS_CLOUDHSM. For a custom key store backed by an CloudHSM cluster, omit the parameter or enter AWS_CLOUDHSM. For a custom key store backed by an external key manager outside of Amazon Web Services, enter EXTERNAL_KEY_STORE. You cannot change this property after the key store is created."];
      xksProxyUriEndpoint: XksProxyUriEndpointType.t option
        [@ocaml.doc
          "Specifies the endpoint that KMS uses to send requests to the external key store proxy (XKS proxy). This parameter is required for custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. The protocol must be HTTPS. KMS communicates on port 443. Do not specify the port in the XksProxyUriEndpoint value. For external key stores with XksProxyConnectivity value of VPC_ENDPOINT_SERVICE, specify https:// followed by the private DNS name of the VPC endpoint service. For external key stores with PUBLIC_ENDPOINT connectivity, this endpoint must be reachable before you create the custom key store. KMS connects to the external key store proxy while creating the custom key store. For external key stores with VPC_ENDPOINT_SERVICE connectivity, KMS connects when you call the ConnectCustomKeyStore operation. The value of this parameter must begin with https://. The remainder can contain upper and lower case letters (A-Z and a-z), numbers (0-9), dots (.), and hyphens (-). Additional slashes (/ and \\) are not permitted. Uniqueness requirements: The combined XksProxyUriEndpoint and XksProxyUriPath values must be unique in the Amazon Web Services account and Region. An external key store with PUBLIC_ENDPOINT connectivity cannot use the same XksProxyUriEndpoint value as an external key store with VPC_ENDPOINT_SERVICE connectivity in this Amazon Web Services Region. Each external key store with VPC_ENDPOINT_SERVICE connectivity must have its own private DNS name. The XksProxyUriEndpoint value for external key stores with VPC_ENDPOINT_SERVICE connectivity (private DNS name) must be unique in the Amazon Web Services account and Region."];
      xksProxyUriPath: XksProxyUriPathType.t option
        [@ocaml.doc
          "Specifies the base path to the proxy APIs for this external key store. To find this value, see the documentation for your external key store proxy. This parameter is required for all custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. The value must start with / and must end with /kms/xks/v1 where v1 represents the version of the KMS external key store proxy API. This path can include an optional prefix between the required elements such as /prefix/kms/xks/v1. Uniqueness requirements: The combined XksProxyUriEndpoint and XksProxyUriPath values must be unique in the Amazon Web Services account and Region."];
      xksProxyVpcEndpointServiceName:
        XksProxyVpcEndpointServiceNameType.t option
        [@ocaml.doc
          "Specifies the name of the Amazon VPC endpoint service for interface endpoints that is used to communicate with your external key store proxy (XKS proxy). This parameter is required when the value of CustomKeyStoreType is EXTERNAL_KEY_STORE and the value of XksProxyConnectivity is VPC_ENDPOINT_SERVICE. The Amazon VPC endpoint service must fulfill all requirements for use with an external key store. Uniqueness requirements: External key stores with VPC_ENDPOINT_SERVICE connectivity can share an Amazon VPC, but each external key store must have its own VPC endpoint service and private DNS name."];
      xksProxyVpcEndpointServiceOwner: AccountIdType.t option
        [@ocaml.doc
          "Specifies the Amazon Web Services account ID that owns the Amazon VPC service endpoint for the interface that is used to communicate with your external key store proxy (XKS proxy). This parameter is optional. If not provided, the Amazon Web Services account ID calling the action will be used."];
      xksProxyAuthenticationCredential:
        XksProxyAuthenticationCredentialType.t option
        [@ocaml.doc
          "Specifies an authentication credential for the external key store proxy (XKS proxy). This parameter is required for all custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. The XksProxyAuthenticationCredential has two required elements: RawSecretAccessKey, a secret key, and AccessKeyId, a unique identifier for the RawSecretAccessKey. For character requirements, see XksProxyAuthenticationCredentialType. KMS uses this authentication credential to sign requests to the external key store proxy on your behalf. This credential is unrelated to Identity and Access Management (IAM) and Amazon Web Services credentials. This parameter doesn't set or change the authentication credentials on the XKS proxy. It just tells KMS the credential that you established on your external key store proxy. If you rotate your proxy authentication credential, use the UpdateCustomKeyStore operation to provide the new credential to KMS."];
      xksProxyConnectivity: XksProxyConnectivityType.t option
        [@ocaml.doc
          "Indicates how KMS communicates with the external key store proxy. This parameter is required for custom key stores with a CustomKeyStoreType of EXTERNAL_KEY_STORE. If the external key store proxy uses a public endpoint, specify PUBLIC_ENDPOINT. If the external key store proxy uses a Amazon VPC endpoint service for communication with KMS, specify VPC_ENDPOINT_SERVICE. For help making this choice, see Choosing a connectivity option in the Key Management Service Developer Guide. An Amazon VPC endpoint service keeps your communication with KMS in a private address space entirely within Amazon Web Services, but it requires more configuration, including establishing a Amazon VPC with multiple subnets, a VPC endpoint service, a network load balancer, and a verified private DNS name. A public endpoint is simpler to set up, but it might be slower and might not fulfill your security requirements. You might consider testing with a public endpoint, and then establishing a VPC endpoint service for production tasks. Note that this choice does not determine the location of the external key store proxy. Even if you choose a VPC endpoint service, the proxy can be hosted within the VPC or outside of Amazon Web Services such as in your corporate data center."]}
    let context_ = "CreateCustomKeyStoreRequest"
    let make ?cloudHsmClusterId =
      fun ?trustAnchorCertificate ->
        fun ?keyStorePassword ->
          fun ?customKeyStoreType ->
            fun ?xksProxyUriEndpoint ->
              fun ?xksProxyUriPath ->
                fun ?xksProxyVpcEndpointServiceName ->
                  fun ?xksProxyVpcEndpointServiceOwner ->
                    fun ?xksProxyAuthenticationCredential ->
                      fun ?xksProxyConnectivity ->
                        fun ~customKeyStoreName ->
                          fun () ->
                            {
                              cloudHsmClusterId;
                              trustAnchorCertificate;
                              keyStorePassword;
                              customKeyStoreType;
                              xksProxyUriEndpoint;
                              xksProxyUriPath;
                              xksProxyVpcEndpointServiceName;
                              xksProxyVpcEndpointServiceOwner;
                              xksProxyAuthenticationCredential;
                              xksProxyConnectivity;
                              customKeyStoreName
                            }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreName",
           (Some (CustomKeyStoreNameType.to_value x.customKeyStoreName)));
        ("CloudHsmClusterId",
          (Option.map x.cloudHsmClusterId ~f:CloudHsmClusterIdType.to_value));
        ("TrustAnchorCertificate",
          (Option.map x.trustAnchorCertificate
             ~f:TrustAnchorCertificateType.to_value));
        ("KeyStorePassword",
          (Option.map x.keyStorePassword ~f:KeyStorePasswordType.to_value));
        ("CustomKeyStoreType",
          (Option.map x.customKeyStoreType ~f:CustomKeyStoreType.to_value));
        ("XksProxyUriEndpoint",
          (Option.map x.xksProxyUriEndpoint
             ~f:XksProxyUriEndpointType.to_value));
        ("XksProxyUriPath",
          (Option.map x.xksProxyUriPath ~f:XksProxyUriPathType.to_value));
        ("XksProxyVpcEndpointServiceName",
          (Option.map x.xksProxyVpcEndpointServiceName
             ~f:XksProxyVpcEndpointServiceNameType.to_value));
        ("XksProxyVpcEndpointServiceOwner",
          (Option.map x.xksProxyVpcEndpointServiceOwner
             ~f:AccountIdType.to_value));
        ("XksProxyAuthenticationCredential",
          (Option.map x.xksProxyAuthenticationCredential
             ~f:XksProxyAuthenticationCredentialType.to_value));
        ("XksProxyConnectivity",
          (Option.map x.xksProxyConnectivity
             ~f:XksProxyConnectivityType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let xksProxyConnectivity =
        (Option.map ~f:XksProxyConnectivityType.of_xml)
          (Xml.child xml_arg0 "XksProxyConnectivity") in
      let xksProxyAuthenticationCredential =
        (Option.map ~f:XksProxyAuthenticationCredentialType.of_xml)
          (Xml.child xml_arg0 "XksProxyAuthenticationCredential") in
      let xksProxyVpcEndpointServiceOwner =
        (Option.map ~f:AccountIdType.of_xml)
          (Xml.child xml_arg0 "XksProxyVpcEndpointServiceOwner") in
      let xksProxyVpcEndpointServiceName =
        (Option.map ~f:XksProxyVpcEndpointServiceNameType.of_xml)
          (Xml.child xml_arg0 "XksProxyVpcEndpointServiceName") in
      let xksProxyUriPath =
        (Option.map ~f:XksProxyUriPathType.of_xml)
          (Xml.child xml_arg0 "XksProxyUriPath") in
      let xksProxyUriEndpoint =
        (Option.map ~f:XksProxyUriEndpointType.of_xml)
          (Xml.child xml_arg0 "XksProxyUriEndpoint") in
      let customKeyStoreType =
        (Option.map ~f:CustomKeyStoreType.of_xml)
          (Xml.child xml_arg0 "CustomKeyStoreType") in
      let keyStorePassword =
        (Option.map ~f:KeyStorePasswordType.of_xml)
          (Xml.child xml_arg0 "KeyStorePassword") in
      let trustAnchorCertificate =
        (Option.map ~f:TrustAnchorCertificateType.of_xml)
          (Xml.child xml_arg0 "TrustAnchorCertificate") in
      let cloudHsmClusterId =
        (Option.map ~f:CloudHsmClusterIdType.of_xml)
          (Xml.child xml_arg0 "CloudHsmClusterId") in
      let customKeyStoreName =
        CustomKeyStoreNameType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "CustomKeyStoreName") in
      make ?xksProxyConnectivity ?xksProxyAuthenticationCredential
        ?xksProxyVpcEndpointServiceOwner ?xksProxyVpcEndpointServiceName
        ?xksProxyUriPath ?xksProxyUriEndpoint ?customKeyStoreType
        ?keyStorePassword ?trustAnchorCertificate ?cloudHsmClusterId
        ~customKeyStoreName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let xksProxyConnectivity =
        field_map json__ "XksProxyConnectivity"
          XksProxyConnectivityType.of_json in
      let xksProxyAuthenticationCredential =
        field_map json__ "XksProxyAuthenticationCredential"
          XksProxyAuthenticationCredentialType.of_json in
      let xksProxyVpcEndpointServiceOwner =
        field_map json__ "XksProxyVpcEndpointServiceOwner"
          AccountIdType.of_json in
      let xksProxyVpcEndpointServiceName =
        field_map json__ "XksProxyVpcEndpointServiceName"
          XksProxyVpcEndpointServiceNameType.of_json in
      let xksProxyUriPath =
        field_map json__ "XksProxyUriPath" XksProxyUriPathType.of_json in
      let xksProxyUriEndpoint =
        field_map json__ "XksProxyUriEndpoint"
          XksProxyUriEndpointType.of_json in
      let customKeyStoreType =
        field_map json__ "CustomKeyStoreType" CustomKeyStoreType.of_json in
      let keyStorePassword =
        field_map json__ "KeyStorePassword" KeyStorePasswordType.of_json in
      let trustAnchorCertificate =
        field_map json__ "TrustAnchorCertificate"
          TrustAnchorCertificateType.of_json in
      let cloudHsmClusterId =
        field_map json__ "CloudHsmClusterId" CloudHsmClusterIdType.of_json in
      let customKeyStoreName =
        field_map_exn json__ "CustomKeyStoreName"
          CustomKeyStoreNameType.of_json in
      make ?xksProxyConnectivity ?xksProxyAuthenticationCredential
        ?xksProxyVpcEndpointServiceOwner ?xksProxyVpcEndpointServiceName
        ?xksProxyUriPath ?xksProxyUriEndpoint ?customKeyStoreType
        ?keyStorePassword ?trustAnchorCertificate ?cloudHsmClusterId
        ~customKeyStoreName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a custom key store backed by a key store that you own and manage. When you use a KMS key in a custom key store for a cryptographic operation, the cryptographic operation is actually performed in your key store using your keys. KMS supports CloudHSM key stores backed by an CloudHSM cluster and external key stores backed by an external key store proxy and external key manager outside of Amazon Web Services. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. Before you create the custom key store, the required elements must be in place and operational. We recommend that you use the test tools that KMS provides to verify the configuration your external key store proxy. For details about the required elements and verification tests, see Assemble the prerequisites (for CloudHSM key stores) or Assemble the prerequisites (for external key stores) in the Key Management Service Developer Guide. To create a custom key store, use the following parameters. To create an CloudHSM key store, specify the CustomKeyStoreName, CloudHsmClusterId, KeyStorePassword, and TrustAnchorCertificate. The CustomKeyStoreType parameter is optional for CloudHSM key stores. If you include it, set it to the default value, AWS_CLOUDHSM. For help with failures, see Troubleshooting an CloudHSM key store in the Key Management Service Developer Guide. To create an external key store, specify the CustomKeyStoreName and a CustomKeyStoreType of EXTERNAL_KEY_STORE. Also, specify values for XksProxyConnectivity, XksProxyAuthenticationCredential, XksProxyUriEndpoint, and XksProxyUriPath. If your XksProxyConnectivity value is VPC_ENDPOINT_SERVICE, specify the XksProxyVpcEndpointServiceName parameter. For help with failures, see Troubleshooting an external key store in the Key Management Service Developer Guide. For external key stores: Some external key managers provide a simpler method for creating an external key store. For details, see your external key manager documentation. When creating an external key store in the KMS console, you can upload a JSON-based proxy configuration file with the desired values. You cannot use a proxy configuration with the CreateCustomKeyStore operation. However, you can use the values in the file to help you determine the correct values for the CreateCustomKeyStore parameters. When the operation completes successfully, it returns the ID of the new custom key store. Before you can use your new custom key store, you need to use the ConnectCustomKeyStore operation to connect a new CloudHSM key store to its CloudHSM cluster, or to connect a new external key store to the external key store proxy for your external key manager. Even if you are not going to use your custom key store immediately, you might want to connect it to verify that all settings are correct and then disconnect it until you are ready to use it. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:CreateCustomKeyStore (IAM policy). Related operations: ConnectCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CreateAliasRequest =
  struct
    type nonrec t =
      {
      aliasName: AliasNameType.t
        [@ocaml.doc
          "Specifies the alias name. This value must begin with alias/ followed by a name, such as alias/ExampleAlias. Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output. The AliasName value must be string of 1-256 characters. It can contain only alphanumeric characters, forward slashes (/), underscores (_), and dashes (-). The alias name cannot begin with alias/aws/. The alias/aws/ prefix is reserved for Amazon Web Services managed keys."];
      targetKeyId: KeyIdType.t
        [@ocaml.doc
          "Associates the alias with the specified customer managed key. The KMS key must be in the same Amazon Web Services Region. A valid key ID is required. If you supply a null or empty string value, this operation returns an error. For help finding the key ID and ARN, see Find the key ID and key ARN in the Key Management Service Developer Guide . Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "CreateAliasRequest"
    let make ~aliasName =
      fun ~targetKeyId -> fun () -> { aliasName; targetKeyId }
    let to_value x =
      structure_to_value
        [("AliasName", (Some (AliasNameType.to_value x.aliasName)));
        ("TargetKeyId", (Some (KeyIdType.to_value x.targetKeyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let targetKeyId =
        KeyIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "TargetKeyId") in
      let aliasName =
        AliasNameType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "AliasName") in
      make ~targetKeyId ~aliasName ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let targetKeyId = field_map_exn json__ "TargetKeyId" KeyIdType.of_json in
      let aliasName = field_map_exn json__ "AliasName" AliasNameType.of_json in
      make ~targetKeyId ~aliasName ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Creates a friendly name for a KMS key. Adding, deleting, or updating an alias can allow or deny permission to the KMS key. For details, see ABAC for KMS in the Key Management Service Developer Guide. You can use an alias to identify a KMS key in the KMS console, in the DescribeKey operation and in cryptographic operations, such as Encrypt and GenerateDataKey. You can also change the KMS key that's associated with the alias (UpdateAlias) or delete the alias (DeleteAlias) at any time. These operations don't affect the underlying KMS key. You can associate the alias with any customer managed key in the same Amazon Web Services Region. Each alias is associated with only one KMS key at a time, but a KMS key can have multiple aliases. A valid KMS key is required. You can't create an alias without a KMS key. The alias must be unique in the account and Region, but you can have aliases with the same name in different Regions. For detailed information about aliases, see Aliases in KMS in the Key Management Service Developer Guide. This operation does not return a response. To get the alias that you created, use the ListAliases operation. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on an alias in a different Amazon Web Services account. Required permissions kms:CreateAlias on the alias (IAM policy). kms:CreateAlias on the KMS key (key policy). For details, see Controlling access to aliases in the Key Management Service Developer Guide. Related operations: DeleteAlias ListAliases UpdateAlias Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ConnectCustomKeyStoreResponse =
  struct
    type nonrec t = unit
    type nonrec error =
      [
        `CloudHsmClusterInvalidConfigurationException of
          CloudHsmClusterInvalidConfigurationException.t 
      | `CloudHsmClusterNotActiveException of
          CloudHsmClusterNotActiveException.t 
      | `CustomKeyStoreInvalidStateException of
          CustomKeyStoreInvalidStateException.t 
      | `CustomKeyStoreNotFoundException of CustomKeyStoreNotFoundException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make () = ()
    let error_of_json name json =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_json json)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_json json)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_json json)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "CloudHsmClusterInvalidConfigurationException" ->
          `CloudHsmClusterInvalidConfigurationException
            (CloudHsmClusterInvalidConfigurationException.of_xml xml)
      | "CloudHsmClusterNotActiveException" ->
          `CloudHsmClusterNotActiveException
            (CloudHsmClusterNotActiveException.of_xml xml)
      | "CustomKeyStoreInvalidStateException" ->
          `CustomKeyStoreInvalidStateException
            (CustomKeyStoreInvalidStateException.of_xml xml)
      | "CustomKeyStoreNotFoundException" ->
          `CustomKeyStoreNotFoundException
            (CustomKeyStoreNotFoundException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `CloudHsmClusterInvalidConfigurationException e ->
          `Assoc
            [("error",
               (`String "CloudHsmClusterInvalidConfigurationException"));
            ("details",
              (CloudHsmClusterInvalidConfigurationException.to_json e))]
      | `CloudHsmClusterNotActiveException e ->
          `Assoc
            [("error", (`String "CloudHsmClusterNotActiveException"));
            ("details", (CloudHsmClusterNotActiveException.to_json e))]
      | `CustomKeyStoreInvalidStateException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreInvalidStateException"));
            ("details", (CustomKeyStoreInvalidStateException.to_json e))]
      | `CustomKeyStoreNotFoundException e ->
          `Assoc
            [("error", (`String "CustomKeyStoreNotFoundException"));
            ("details", (CustomKeyStoreNotFoundException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let of_header_and_body = ((fun (xs, pipe) -> make ())[@warning "-27"])
    let to_value _ = `Structure []
    let to_query v = to_query to_value v
    let of_xml _ = make ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json _ = make ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Connects or reconnects a custom key store to its backing key store. For an CloudHSM key store, ConnectCustomKeyStore connects the key store to its associated CloudHSM cluster. For an external key store, ConnectCustomKeyStore connects the key store to the external key store proxy that communicates with your external key manager. The custom key store must be connected before you can create KMS keys in the key store or use the KMS keys it contains. You can disconnect and reconnect a custom key store at any time. The connection process for a custom key store can take an extended amount of time to complete. This operation starts the connection process, but it does not wait for it to complete. When it succeeds, this operation quickly returns an HTTP 200 response and a JSON object with no properties. However, this response does not indicate that the custom key store is connected. To get the connection state of the custom key store, use the DescribeCustomKeyStores operation. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. The ConnectCustomKeyStore operation might fail for various reasons. To find the reason, use the DescribeCustomKeyStores operation and see the ConnectionErrorCode in the response. For help interpreting the ConnectionErrorCode, see CustomKeyStoresListEntry. To fix the failure, use the DisconnectCustomKeyStore operation to disconnect the custom key store, correct the error, use the UpdateCustomKeyStore operation if necessary, and then use ConnectCustomKeyStore again. CloudHSM key store During the connection process for an CloudHSM key store, KMS finds the CloudHSM cluster that is associated with the custom key store, creates the connection infrastructure, connects to the cluster, logs into the CloudHSM client as the kmsuser CU, and rotates its password. To connect an CloudHSM key store, its associated CloudHSM cluster must have at least one active HSM. To get the number of active HSMs in a cluster, use the DescribeClusters operation. To add HSMs to the cluster, use the CreateHsm operation. Also, the kmsuser crypto user (CU) must not be logged into the cluster. This prevents KMS from using this account to log in. If you are having trouble connecting or disconnecting a CloudHSM key store, see Troubleshooting an CloudHSM key store in the Key Management Service Developer Guide. External key store When you connect an external key store that uses public endpoint connectivity, KMS tests its ability to communicate with your external key manager by sending a request via the external key store proxy. When you connect to an external key store that uses VPC endpoint service connectivity, KMS establishes the networking elements that it needs to communicate with your external key manager via the external key store proxy. This includes creating an interface endpoint to the VPC endpoint service and a private hosted zone for traffic between KMS and the VPC endpoint service. To connect an external key store, KMS must be able to connect to the external key store proxy, the external key store proxy must be able to communicate with your external key manager, and the external key manager must be available for cryptographic operations. If you are having trouble connecting or disconnecting an external key store, see Troubleshooting an external key store in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:ConnectCustomKeyStore (IAM policy) Related operations CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module ConnectCustomKeyStoreRequest =
  struct
    type nonrec t =
      {
      customKeyStoreId: CustomKeyStoreIdType.t
        [@ocaml.doc
          "Enter the key store ID of the custom key store that you want to connect. To find the ID of a custom key store, use the DescribeCustomKeyStores operation."]}
    let context_ = "ConnectCustomKeyStoreRequest"
    let make ~customKeyStoreId = fun () -> { customKeyStoreId }
    let to_value x =
      structure_to_value
        [("CustomKeyStoreId",
           (Some (CustomKeyStoreIdType.to_value x.customKeyStoreId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let customKeyStoreId =
        CustomKeyStoreIdType.of_xml
          (Xml.child_exn ~context:context_ xml_arg0 "CustomKeyStoreId") in
      make ~customKeyStoreId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let customKeyStoreId =
        field_map_exn json__ "CustomKeyStoreId" CustomKeyStoreIdType.of_json in
      make ~customKeyStoreId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Connects or reconnects a custom key store to its backing key store. For an CloudHSM key store, ConnectCustomKeyStore connects the key store to its associated CloudHSM cluster. For an external key store, ConnectCustomKeyStore connects the key store to the external key store proxy that communicates with your external key manager. The custom key store must be connected before you can create KMS keys in the key store or use the KMS keys it contains. You can disconnect and reconnect a custom key store at any time. The connection process for a custom key store can take an extended amount of time to complete. This operation starts the connection process, but it does not wait for it to complete. When it succeeds, this operation quickly returns an HTTP 200 response and a JSON object with no properties. However, this response does not indicate that the custom key store is connected. To get the connection state of the custom key store, use the DescribeCustomKeyStores operation. This operation is part of the custom key stores feature in KMS, which combines the convenience and extensive integration of KMS with the isolation and control of a key store that you own and manage. The ConnectCustomKeyStore operation might fail for various reasons. To find the reason, use the DescribeCustomKeyStores operation and see the ConnectionErrorCode in the response. For help interpreting the ConnectionErrorCode, see CustomKeyStoresListEntry. To fix the failure, use the DisconnectCustomKeyStore operation to disconnect the custom key store, correct the error, use the UpdateCustomKeyStore operation if necessary, and then use ConnectCustomKeyStore again. CloudHSM key store During the connection process for an CloudHSM key store, KMS finds the CloudHSM cluster that is associated with the custom key store, creates the connection infrastructure, connects to the cluster, logs into the CloudHSM client as the kmsuser CU, and rotates its password. To connect an CloudHSM key store, its associated CloudHSM cluster must have at least one active HSM. To get the number of active HSMs in a cluster, use the DescribeClusters operation. To add HSMs to the cluster, use the CreateHsm operation. Also, the kmsuser crypto user (CU) must not be logged into the cluster. This prevents KMS from using this account to log in. If you are having trouble connecting or disconnecting a CloudHSM key store, see Troubleshooting an CloudHSM key store in the Key Management Service Developer Guide. External key store When you connect an external key store that uses public endpoint connectivity, KMS tests its ability to communicate with your external key manager by sending a request via the external key store proxy. When you connect to an external key store that uses VPC endpoint service connectivity, KMS establishes the networking elements that it needs to communicate with your external key manager via the external key store proxy. This includes creating an interface endpoint to the VPC endpoint service and a private hosted zone for traffic between KMS and the VPC endpoint service. To connect an external key store, KMS must be able to connect to the external key store proxy, the external key store proxy must be able to communicate with your external key manager, and the external key manager must be available for cryptographic operations. If you are having trouble connecting or disconnecting an external key store, see Troubleshooting an external key store in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a custom key store in a different Amazon Web Services account. Required permissions: kms:ConnectCustomKeyStore (IAM policy) Related operations CreateCustomKeyStore DeleteCustomKeyStore DescribeCustomKeyStores DisconnectCustomKeyStore UpdateCustomKeyStore Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CancelKeyDeletionResponse =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t option
        [@ocaml.doc
          "The Amazon Resource Name (key ARN) of the KMS key whose deletion is canceled."]}
    type nonrec error =
      [ `DependencyTimeoutException of DependencyTimeoutException.t 
      | `InvalidArnException of InvalidArnException.t 
      | `KMSInternalException of KMSInternalException.t 
      | `KMSInvalidStateException of KMSInvalidStateException.t 
      | `NotFoundException of NotFoundException.t 
      | `Unknown_operation_error of (string * string option) ]
    let make ?keyId = fun () -> { keyId }
    let error_of_json name json =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException
            (DependencyTimeoutException.of_json json)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_json json)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_json json)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_json json)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_json json)
      | name ->
          `Unknown_operation_error
            (name, (Some (Yojson.Safe.to_string json)))
    let error_of_xml name xml =
      match name with
      | "DependencyTimeoutException" ->
          `DependencyTimeoutException (DependencyTimeoutException.of_xml xml)
      | "InvalidArnException" ->
          `InvalidArnException (InvalidArnException.of_xml xml)
      | "KMSInternalException" ->
          `KMSInternalException (KMSInternalException.of_xml xml)
      | "KMSInvalidStateException" ->
          `KMSInvalidStateException (KMSInvalidStateException.of_xml xml)
      | "NotFoundException" ->
          `NotFoundException (NotFoundException.of_xml xml)
      | name ->
          `Unknown_operation_error (name, (Some (Awso.Xml.to_string xml)))
    let error_to_json : error -> Yojson.Safe.t =
      function
      | `DependencyTimeoutException e ->
          `Assoc
            [("error", (`String "DependencyTimeoutException"));
            ("details", (DependencyTimeoutException.to_json e))]
      | `InvalidArnException e ->
          `Assoc
            [("error", (`String "InvalidArnException"));
            ("details", (InvalidArnException.to_json e))]
      | `KMSInternalException e ->
          `Assoc
            [("error", (`String "KMSInternalException"));
            ("details", (KMSInternalException.to_json e))]
      | `KMSInvalidStateException e ->
          `Assoc
            [("error", (`String "KMSInvalidStateException"));
            ("details", (KMSInvalidStateException.to_json e))]
      | `NotFoundException e ->
          `Assoc
            [("error", (`String "NotFoundException"));
            ("details", (NotFoundException.to_json e))]
      | `Unknown_operation_error (code, msg) ->
          `Assoc (("error", (`String code)) ::
            ((match msg with
              | None -> []
              | Some m -> [("message", (`String m))])))
    let to_value x =
      structure_to_value
        [("KeyId", (Option.map x.keyId ~f:KeyIdType.to_value))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        (Option.map ~f:KeyIdType.of_xml) (Xml.child xml_arg0 "KeyId") in
      make ?keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map json__ "KeyId" KeyIdType.of_json in
      make ?keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Cancels the deletion of a KMS key. When this operation succeeds, the key state of the KMS key is Disabled. To enable the KMS key, use EnableKey. For more information about scheduling and canceling deletion of a KMS key, see Deleting KMS keys in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:CancelKeyDeletion (key policy) Related operations: ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]
module CancelKeyDeletionRequest =
  struct
    type nonrec t =
      {
      keyId: KeyIdType.t
        [@ocaml.doc
          "Identifies the KMS key whose deletion is being canceled. Specify the key ID or key ARN of the KMS key. For example: Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey."]}
    let context_ = "CancelKeyDeletionRequest"
    let make ~keyId = fun () -> { keyId }
    let to_value x =
      structure_to_value [("KeyId", (Some (KeyIdType.to_value x.keyId)))]
    let to_query v = to_query to_value v
    let of_xml xml_arg0 =
      let keyId =
        KeyIdType.of_xml (Xml.child_exn ~context:context_ xml_arg0 "KeyId") in
      make ~keyId ()
    let of_string s = of_xml (Awso.Xml.parse_response s)[@@warning "-32"]
    let of_json json__ =
      let keyId = field_map_exn json__ "KeyId" KeyIdType.of_json in
      make ~keyId ()
    let to_json v = composed_to_json to_value v
  end[@@ocaml.doc
       "Cancels the deletion of a KMS key. When this operation succeeds, the key state of the KMS key is Disabled. To enable the KMS key, use EnableKey. For more information about scheduling and canceling deletion of a KMS key, see Deleting KMS keys in the Key Management Service Developer Guide. The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of KMS keys in the Key Management Service Developer Guide. Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account. Required permissions: kms:CancelKeyDeletion (key policy) Related operations: ScheduleKeyDeletion Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency."]