This file is indexed.

/usr/share/perl5/VM/EC2/REST/relational_database_service.pm is in libvm-ec2-perl 1.28-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
package VM::EC2::REST::relational_database_service;

use strict;
use VM::EC2 '';   # important not to import anything!
package VM::EC2;  # add methods to VM::EC2

VM::EC2::Dispatch->register(
    AddSourceIdentifierToSubscription => 'fetch_one_result,EventSubscription,VM::EC2::DB::Event::Subscription',
    AuthorizeDBSecurityGroupIngress   => 'fetch_one_result,DBSecurityGroup,VM::EC2::DB::SecurityGroup',
    CopyDBSnapshot                    => 'fetch_one_result,DBSnapshot,VM::EC2::DB::Snapshot',
    CreateDBInstance                  => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    CreateDBInstanceReadReplica       => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    CreateDBParameterGroup            => 'fetch_one_result,DBParameterGroup,VM::EC2::DB::Parameter::Group',
    CreateDBSecurityGroup             => 'fetch_one_result,DBSecurityGroup,VM::EC2::DB::SecurityGroup',
    CreateDBSnapshot                  => 'fetch_one_result,DBSnapshot,VM::EC2::DB::Snapshot',
    CreateDBSubnetGroup               => 'fetch_one_result,DBSubnetGroup,VM::EC2::DB::Subnet::Group',
    CreateEventSubscription           => 'fetch_one_result,EventSubscription,VM::EC2::DB::Event::Subscription',
    CreateOptionGroup                 => 'fetch_one_result,OptionGroup,VM::EC2::DB::Option::Group',
    DescribeDBEngineVersions          => 'fetch_rds_objects,DBEngineVersion,VM::EC2::DB::Engine::Version',
    DescribeDBInstances               => 'fetch_rds_objects,DBInstance,VM::EC2::DB::Instance',
    DescribeDBParameterGroups         => 'fetch_rds_objects,DBParameterGroup,VM::EC2::DB::Parameter::Group',
    DescribeDBParameters              => 'fetch_rds_objects,Parameter,VM::EC2::DB::Parameter',
    DescribeDBSecurityGroups          => 'fetch_rds_objects,DBSecurityGroup,VM::EC2::DB::SecurityGroup',
    DescribeDBSnapshots               => 'fetch_rds_objects,DBSnapshot,VM::EC2::DB::Snapshot',
    DescribeDBSubnetGroups            => 'fetch_rds_objects,DBSubnetGroup,VM::EC2::DB::Subnet::Group',
    DescribeEngineDefaultParameters   => 'fetch_one_result,EngineDefaults,VM::EC2::DB::Engine::Defaults',
    DescribeEventCategories           => 'fetch_rds_objects,EventCategoriesMap,VM::EC2::DB::Event::Category',
    DescribeEventSubscriptions        => 'fetch_rds_objects,EventSubscription,VM::EC2::DB::Event::Subscription',
    DescribeEvents                    => 'fetch_rds_objects,Event,VM::EC2::DB::Event',
    DescribeOptionGroupOptions        => 'fetch_rds_objects,OptionGroupOption,VM::EC2::DB::Option::Group::Option',
    DescribeOptionGroups              => 'fetch_rds_objects,OptionGroup,VM::EC2::DB::Option::Group',
    DescribeOrderableDBInstanceOptions=> 'fetch_rds_objects,OrderableDBInstanceOption,VM::EC2::DB::Instance::OrderableOption',
    DescribeReservedDBInstances       => 'fetch_rds_objects,ReservedDBInstance,VM::EC2::DB::Reserved::Instance',
    DescribeReservedDBInstancesOfferings
                                      => 'fetch_rds_objects,ReservedDBInstancesOffering,VM::EC2::DB::Reserved::Instance::Offering',
    DownloadDBLogFilePortion          => 'fetch_one_result,DBLogFilePortion,VM::EC2::DB::LogFilePortion',
    ListTagsForResource               => sub {
                                             my @tag_list = shift->{ListTagsForResourceResult}{TagList}{Tag};
                                             my %tags;
                                             foreach (@tag_list) {
                                                 $tags{$_->{Key}} = $_->{Value}
                                             }
                                             return wantarray ? %tags : \%tags;
                                         },
    ModifyDBInstance                  => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    ModifyDBParameterGroup            => sub { return shift->{ModifyDBParameterGroupResult}{DBParameterGroupName} },
    ModifyDBSubnetGroup               => 'fetch_one_result,DBSubnetGroup,VM::EC2::DB::Subnet::Group',
    ModifyEventSubscription           => 'fetch_one_result,EventSubscription,VM::EC2::DB::Event::Subscription',
    ModifyOptionGroup                 => 'fetch_one_result,OptionGroup,VM::EC2::DB::Option::Group',
    PromoteReadReplica                => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    PurchaseReservedDBInstancesOffering
                                      => 'fetch_one_result,ReservedDBInstance,VM::EC2::DB::Reserved::Instance',
    RebootDBInstance                  => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    RemoveSourceIdentifierFromSubscription
                                      => 'fetch_one_result,EventSubscription,VM::EC2::DB::Event::Subscription',
    ResetDBParameterGroup             => sub { return shift->{ResetDBParameterGroupResult}{DBParameterGroupName} },
    RestoreDBInstanceFromDBSnapshot   => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    RestoreDBInstanceToPointInTime    => 'fetch_one_result,DBInstance,VM::EC2::DB::Instance',
    RevokeDBSecurityGroupIngress      => 'fetch_one_result,DBSecurityGroup,VM::EC2::DB::SecurityGroup',
    );

sub rds_call {
    my $self = shift;
    (my $endpoint = $self->{endpoint}) =~ s/ec2/rds/;
    local $self->{endpoint} = $endpoint;
    local $self->{version}  = '2013-09-09';
    $self->call(@_);
}

my $VEP = 'VM::EC2::ParmParser';

=head1 NAME VM::EC2::REST::relational_database_service - accessors for the AWS Relational Database Service

=head1 SYNOPSIS

use VM::EC2 ':rds';

=head1 METHODS

These methods give access and control over the AWS Relational Database Service.
RDS provides easy access to creating and managing an Oracle or MySQL database
in the AWS cloud.

Implemented:
AddSourceIdentifierToSubscription
AddTagsToResource
AuthorizeDBSecurityGroupIngress
CopyDBSnapshot
CreateDBInstance
CreateDBInstanceReadReplica
CreateDBParameterGroup
CreateDBSecurityGroup
CreateDBSnapshot
CreateDBSubnetGroup
CreateEventSubscription
CreateOptionGroup
DescribeDBEngineVersions
DescribeDBInstances
DescribeDBParameterGroups
DescribeDBParameters
DescribeDBSecurityGroups
DescribeDBSnapshots
DescribeDBSubnetGroups
DescribeEngineDefaultParameters
DescribeEventCategories
DescribeEventSubscriptions
DescribeEvents
DescribeOptionGroupOptions
DescribeOptionGroups
DescribeOrderableDBInstanceOptions
DescribeReservedDBInstances
DescribeReservedDBInstancesOfferings
DownloadDBLogFilePortion
ListTagsForResource
ModifyDBInstance
ModifyDBParameterGroup
ModifyDBSubnetGroup
ModifyEventSubscription
ModifyOptionGroup
PromoteReadReplica
PurchaseReservedDBInstancesOffering
RebootDBInstance
RemoveSourceIdentifierFromSubscription
RemoveTagsFromResource
ResetDBParameterGroup
RestoreDBInstanceFromDBSnapshot
RestoreDBInstanceToPointInTime
RevokeDBSecurityGroupIngress

Unimplemented:
 (none)

=head1 SEE ALSO

L<VM::EC2>

=cut

=head2 $ec2->add_source_identifier_to_subscription(%args)

Adds a source identifier to an existing RDS event notification subscription.

Required arguments:

 -source_identifier                    The identifier of the event source to be added.

 -subscription_name                    The name of the RDS event notification subscription you want
                                       to add a source identifier to.

Returns a L<VM::EC2::DB::Event::Subscription> object.

=cut

sub add_source_identifier_to_subscription {
    my $self = shift;
    my %args = @_;
    $args{-source_identifier} && $args{-subscription_name} or
        croak "add_source_identifier_to_subscription(): -source_identifier and -subscription_name arguments required";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => [qw(SourceIdentifier SubscriptionName)],
                                    });
    return $self->rds_call('AddSourceIdentifierToSubscription',@params);
}

=head2 $ec2->add_tags_to_resource(-resource_name => $name, -tags => \@tags)

Adds metadata tags to an Amazon RDS resource.  These tags can also be used with cost allocation
reporting to track costs associated with Amazon RDS resources, or used in a Condition statement in
an IAM policy for Amazon RDS.

Required arguments:

 -resource_name     The Amazon RDS resource the tags will be removed from.  This value is an Amazon
                    Resource Name (ARN).  For information about creating an ARN, see Constructing
                    an RDS Amazon Resource Name (ARN) at:
                    http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN

 -tags              hashref or arrayref of hashrefs containing tag Key/Value pairs

This method does not return a value but will raise an error if unsuccessful.

=cut

sub add_tags_to_resource {
    my $self = shift;
    my %args = @_;
    $args{-tags} && $args{-resource_name} or
        croak "add_tags_to_resource(): -tags and -resource_name arguments required";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => 'ResourceName',
                                        member_list_parm => 'Tags',
                                    });
    return $self->rds_call('AddTagsToResource',@params);
}

=head2 $sg = $ec2->authorize_db_security_group_ingress(%args)

Enables ingress to a DBSecurityGroup using one of two forms of authorization.  First, EC2 or VPC
security groups can be added to the DBSecurityGroup if the application using the database is running
on EC2 or VPC instances. Second, IP ranges are available if the application accessing your database
is running on the Internet.

Required arguments:

 -db_security_group_name               The name of the DB Security Group to add authorization to.

Optional arguments:

 -cidrip                               The IP range to authorize.

 -ec2_security_group_id                ID of the EC2 Security Group to authorize.  For VPC DB 
                                       security groups, EC2SecurityGroupId must be provided.

 -ec2_security_group_name              Name of the EC2 Security Group to authorize.

 -ec2_security_group_owner_id          AWS Account Number of the owner of the EC2 Security Group
                                       specified in the -ec2_security_group_name parameter.

Returns a L<VM::EC2::DB::SecurityGroup> object.

=cut

sub authorize_db_security_group_ingress {
    my $self = shift;
    my %args = @_;
    $args{-db_security_group_name} &&
        ($args{-cidrip} || $args{-ec2_security_group_id} || $args{-ec2_security_group_name}) or
        croak "authorize_db_security_group_ingress(): -db_security_group_name and one of -cidrip, -ec2_security_group_id, -ec2_security_group_name arguments required";
    ($args{-ec2_security_group_id} || $args{-ec2_security_group_name}) && $args{-ec2_security_group_owner_id} or
        croak "authorize_db_security_group_ingress(): -ec2_security_group_owner_id required when -ec2_security_group_id or -ec2_security_group_name arguments specified";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => [qw(CIDRIP DBSecurityGroupName
                                                           EC2SecurityGroupId EC2SecurityGroupName
                                                           EC2SecurityGroupOwnerId)],
                                    });
    return $self->rds_call('AuthorizeDBSecurityGroupIngress',@params);
}

=head2 $snapshot = $ec2->copy_db_snapshot(-source_db_snapshot_identifier => $db_id, -target_db_snapshot_identifier => $snap_id)

Copies the specified DBSnapshot. The source DBSnapshot must be in the "available" state.

Required arguments:

 -source_db_snapshot_identifier        The identifier for the source DB snapshot.
                                       Constraints:
                                       * Must specify a valid system snapshot in
                                         the "available" state
                                       * If the source snapshot is in the same
                                         region as the copy, specify a valid DB
                                         snapshot identifier
                                       * If the source snapshot is in a different
                                         region than the copy, specify a valid DB
                                         snapshot ARN
                                         For more information, see:
                                         http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_CopySnapshot.html

 -target_db_snapshot_identifier        The identifier for the copied snapshot.
                                       Constraints:
                                       * Cannot be null, empty, or blank
                                       * Must contain from 1 to 255 alphanumeric
                                         characters or hyphens
                                       * First character must be a letter
                                       * Cannot end with a hyphen or contain two
                                         consecutive hyphens

 -source                               Alias for -source_db_snapshot_identifier

 -target                               Alias for -target_db_snapshot_identifier

Optional arguments:

 -tags                                 hashref or arrayref of hashrefs containing Key/Value pairs

Returns a L<VM::EC2::DB::Snapshot> object.

=cut

sub copy_db_snapshot {
    my $self = shift;
    my %args = @_;
    $args{-source_db_snapshot_identifier} ||= $args{-source};
    $args{-target_db_snapshot_identifier} ||= $args{-target};
    $args{-source_db_snapshot_identifier} && $args{-target_db_snapshot_identifier} or
        croak "authorize_db_security_group_ingress(): -db_security_group_name and one of -cidrip, -ec2_security_group_id, -ec2_security_group_name arguments required";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(SourceDBSnapshotIdentifier
                                                                TargetDBSnapshotIdentifier)],
                                        member_list_parm => 'Tags',
                                    });
    return $self->rds_call('CopyDBSnapshot',@params);
}

=head2 $instance = $ec2->create_db_instance(%args)

Creates a new DB instance.

Required arguments:

 -allocated_storage                    MySQL:
                                        * Must be an integer from 5 to 1024.
                                       Oracle:
                                        * Must be an integer from 10 to 1024.
                                       SQL Server:
                                        * Must be an integer from 200 to 1024
                                          (Standard Edition and Enterprise Edition)
                                          or from 30 to 1024 (Express Edition and
                                          Web Edition)

 -db_instance_class                    The compute and memory capacity of the DB Instance.
                                       db.t1.micro | db.m1.small | db.m1.medium | db.m1.large |
                                       db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge

 -db_instance_identifier               The DB Instance identifier. This parameter is stored as a
                                       lowercase string.
                                       Constraints:
                                        * Must contain from 1 to 63 alphanumeric characters or
                                          hyphens (1 to 15 for SQL Server).
                                        * First character must be a letter.
                                        * Cannot end with a hyphen or contain two consecutive
                                          hyphens.

 -engine                               The name of the database engine to be used for this
                                       instance.
                                       Valid values:  MySQL | oracle-se1 | oracle-se | oracle-ee |
                                        sqlserver-ee | sqlserver-se | sqlserver-ex | sqlserver-web

 -master_user_password                 The password for the master database user. Can be any
                                       printable ASCII character except "/", "\", or "@".
                                       Constraints:
                                        * MySQL:  Must contain from 8 to 41 alphanumeric characters.
                                        * Oracle: Must contain from 8 to 30 alphanumeric characters.
                                        * SQL Server: Must contain from 8 to 128 alphanumeric
                                          characters.

 -master_username                      The name of master user for the client DB Instance.

                                       Constraints:
                                         * First character must be a letter.
                                         * Cannot be a reserved word for the chosen database engine.
                                        MySQL:
                                         * Must be 1 to 16 alphanumeric characters.
                                        Oracle:
                                         * Must be 1 to 30 alphanumeric characters.
                                        SQL Server:
                                         * Must be 1 to 128 alphanumeric characters.

Optional arguments:

 -auto_minor_version_upgrade           Indicates that minor engine upgrades will be applied
                                       automatically to the DB Instance during the maintenance
                                       window.  (Boolean).  Default: true

 -availability_zone                    The EC2 Availability Zone that the database instance will
                                       be created in.
                                       Default: A random, system-chosen Availability Zone in the
                                                endpoint's region.

 -backup_retention_period              The number of days for which automated backups are retained.
                                       Setting this parameter to a positive number enables backups.
                                       Setting this parameter to 0 disables automated backups.
                                       Default: 1
                                       Constraints:
                                        * Must be a value from 0 to 8
                                        * Cannot be set to 0 if the DB Instance is a master instance
                                          with read replicas

 -character_set_name                   For supported engines, indicates that the DB Instance should
                                       be associated with the specified CharacterSet.

 -db_name                              The meaning of this parameter differs according to the
                                       database engine you use.

                                       MySQL:
                                         The name of the database to create when the DB Instance
                                         is created. If this parameter is not specified, no database
                                         is created in the DB Instance.

                                         Constraints:
                                         * Must contain 1 to 64 alphanumeric characters
                                         * Cannot be a reserved word

                                       Oracle:
                                         The Oracle System ID (SID) of the created DB Instance.

                                         Constraints:
                                         * Cannot be longer than 8 characters

                                       SQL Server:
                                         Not applicable. Must be null.

 -db_parameter_group_name              The name of the DB Parameter Group to associate with this
                                       DB instance. If this argument is omitted, the default
                                       DBParameterGroup for the specified engine will be used.

                                       Constraints:
                                       * Must be 1 to 255 alphanumeric characters
                                       * First character must be a letter.
                                       * Cannot end with a hyphen or contain two consecutive
                                         hyphens

 -db_security_groups                   An arrayref of DB Security Groups to associate with the
                                       instance

 -db_subnet_group_name                 A DB Subnet Group to associate with this DB Instance.
                                       If not specified, then it is a non-VPC DB instance.

 -engine_version                       The version number of the database engine to use.

 -iops                                 The amount of Provisioned IOPS initially allocated.
                                       Integer between 100-1000

 -license_model                        License model information for this DB Instance.
                                       Valid values: license-included |
                                                     bring-your-own-license |
                                                     general-public-license

 -multi_az                             Specifies if the DB Instance is a Multi-AZ deployment.
                                       You cannot set the -availability_zone argument if the
                                       -multi_az argument is set to true.

 -option_group_name                    Indicates that the DB Instance should be associated
                                       with the specified option group.

 -port                                 The port number on which the database accepts
                                       connections.

                                       MySQL:
                                        * Default: 3306, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1521, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1433, Valid values: 1150-65535 except
                                          1434 and 3389.

 -preferred_backup_window              The daily time range during which automated backups are
                                       created if automated backups are enabled using the
                                       -backup_retention_period argument.

                                       Default: Default: A 30-minute window selected at random
                                       from an 8-hour block of time per region. The following
                                       list shows the time blocks for each region from which
                                       the default backup windows are assigned.

                                       * US-East (Northern Virginia) Region: 03:00-11:00 UTC
                                       * US-West (N. California, Oregon) Region: 06:00-14:00 UTC
                                       * EU (Ireland) Region: 22:00-06:00 UTC
                                       * Asia Pacific (Singapore) Region: 14:00-22:00 UTC
                                       * Asia Pacific (Tokyo) Region: 17:00-03:00 UTC

                                       Constraints:
                                        * Must be in the format hh24:mi-hh24:mi
                                        * Times in Universal Time Coordinated (UTC).
                                        * Must not conflict with the preferred maintenance window.
                                        * Must be at least 30 minutes.

 -preferred_maintenance_window         The weekly time range (in UTC) during which system
                                       maintenance can occur.

                                       Format: ddd:hh24:mi-ddd:hh24:mi

                                       Default: A 30-minute window selected at random from an 8-hour
                                       block of time per region, occurring on a random day of the
                                       week. The following list shows the time blocks for each
                                       region from which the default maintenance windows are
                                       assigned.

                                       * US-East (Northern Virginia) Region: 03:00-11:00 UTC
                                       * US-West (N. California, Oregon) Region: 06:00-14:00 UTC
                                       * EU (Ireland) Region: 22:00-06:00 UTC
                                       * Asia Pacific (Singapore) Region: 14:00-22:00 UTC
                                       * Asia Pacific (Tokyo) Region: 17:00-03:00 UTC

                                       Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun
                                       Constraints: Minimum 30-minute window.

 -publicly_accessible                  Specifies the accessibility options for the DB instance. A
                                       value of true specifies an Internet-facing instance with a
                                       publicly resolvable DNS name, which resolves to a public IP
                                       address. A value of false specifies an internal instance with
                                       a DNS name that resolves to a private IP address.

                                       Default: The default behavior varies depending on whether a
                                       VPC has been requested or not. The following list shows the 
                                       default behavior in each case.
                                       * DefaultVPC:true
                                       * VPC:false

                                       If no DB subnet group has been specified as part of the
                                       request and the -publicly_accessible value has not been set,
                                       the DB instance will be publicly accessible. If a specific DB
                                       subnet group has been specified as part of the request and
                                       the PubliclyAccessible value has not been set, the DB
                                       instance will be private.

 -tags                                 hashref or arrayref of hashrefs containing Key/Value pairs

 -vpc_security_group_ids               A list of EC2 VPC Security Groups to associate with this
                                       DB Instance.

This method returns a L<VM::EC2::DB:Instance> object.

=cut


sub create_db_instance {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-allocated_storage} or
        croak "create_db_instance(): -allocated_storage required argument missing";
    $args{-db_instance_class} or
        croak "create_db_instance(): -db_instance_class required argument missing";
    $args{-db_instance_identifier} or
        croak "create_db_instance(): -db_instance_identifier required argument missing";
    $args{-engine} or
        croak "create_db_instance(): -engine required argument missing";
    $args{-master_user_password} or
        croak "create_db_instance(): -master_user_password required argument missing";
    $args{-master_username} or
        croak "create_db_instance(): -master_username required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(AutoMinorVersionUpgrade MultiAZ
                                                                PubliclyAccessible)],
                                        single_parm      => [qw(AllocatedStorage AvailabilityZone
                                                                BackupRetentionPeriod
                                                                CharacterSetName DBInstanceClass
                                                                DBInstanceIdentifier DBName
                                                                DBParameterGroupName
                                                                DBSubnetGroupName Engine
                                                                EngineVersion Iops LicenseModel
                                                                MasterUserPassword MasterUsername
                                                                OptionGroupName Port
                                                                PreferredBackupWindow
                                                                PreferredMaintenanceWindow)],
                                        member_list_parm => [qw(VpcSecurityGroupIds DBSecurityGroups
                                                                Tags)],
                                    });
    return $self->rds_call('CreateDBInstance',@params);
}

=head2 $instance = $ec2->create_db_instance_read_replica(%args)

Creates a DB Instance that acts as a Read Replica of a source DB Instance.  All Read Replica DB
Instances are created as Single-AZ deployments with backups disabled. All other DB Instance
attributes (including DB Security Groups and DB Parameter Groups) are inherited from the source DB
Instance, except as specified below.
IMPORTANT:  The source DB Instance must have backup retention enabled.

Required arguments:

 -db_instance_identifier               The DB Instance identifier of the Read Replica. This is the
                                       unique key that identifies a DB Instance. This parameter is
                                       stored as a lowercase string.

 -source_db_instance_identifier        The identifier of the DB Instance that will act as the source
                                       for the Read Replica.  Each DB Instance can have up to five
                                       Read Replicas.  Constraints: Must be the identifier of an
                                       existing DB Instance that is not already a Read Replica DB
                                       Instance.

Optional arguments:

 -auto_minor_version_upgrade           Indicates that minor engine upgrades will be applied
                                       automatically to the Read Replica during the maintenance
                                       window.  (Boolean)

 -availability_zone                    The Amazon EC2 Availability Zone that the Read Replica will
                                       be created in.  Default: A random, system-chosen
                                       Availability Zone in the endpoint's region.

 -db_instance_class                    The compute and memory capacity of the Read
                                       Replica.
                                       Valid Values: db.m1.small | db.m1.medium |
                                       db.m1.large | db.m1.xlarge | db.m2.xlarge |
                                       db.m2.2xlarge | db.m2.4xlarge

 -iops                                 The amount of Provisioned IOPS to be initially allocated for
                                       the DB Instance.

 -option_group_name                    The option group the DB instance will be associated with. If
                                       omitted, the default Option Group for the engine specified
                                       will be used.

 -port                                 The port number that the DB Instance uses for connections.
                                       Default: Inherits from the source instance
                                       Valid Values: 1150-65535

 -publicly_accessible                  Specifies the accessibility options for the DB instance. A
                                       value of true specifies an Internet-facing instance with a
                                       publicly resolvable DNS name, which resolves to a public IP
                                       address. A value of false specifies an internal instance with
                                       a DNS name that resolves to a private IP address.

                                       Default: The default behavior varies depending on whether a
                                       VPC has been requested or not. The following list shows the 
                                       default behavior in each case.
                                       * DefaultVPC:true
                                       * VPC:false

                                       If no DB subnet group has been specified as part of the
                                       request and the -publicly_accessible value has not been set,
                                       the DB instance will be publicly accessible. If a specific DB
                                       subnet group has been specified as part of the request and
                                       the PubliclyAccessible value has not been set, the DB
                                       instance will be private.


Returns a L<VM::EC2::DB::Instance> object on success.

=cut

sub create_db_instance_read_replica {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-db_instance_identifier} or
        croak "create_db_instance_read_replica(): -db_instance_identifier required argument missing";
    $args{-source_db_instance_identifier} or
        croak "create_db_instance_read_replica(): -source_db_instance_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(AutoMinorVersionUpgrade MultiAZ
                                                                PubliclyAccessible)],
                                        single_parm      => [qw(AvailabilityZone DBInstanceClass
                                                                DBInstanceIdentifier Iops
                                                                OptionGroupName Port
                                                                SourceDBInstanceIdentifier)],
                                        member_list_parm => [qw(VpcSecurityGroupIds DBSecurityGroups
                                                                Tags)],
                                    });
    return $self->rds_call('CreateDBInstanceReadReplica',@params);
}

=head2 $group = $ec2->create_db_parameter_group(%args)

Creates a new DB Parameter Group.

A DB Parameter Group is initially created with the default parameters for the database engine used
by the DB Instance. To provide custom values for any of the parameters, you must modify the group
after creating it using modify_db_parameter_group(). Once you've created a DB Parameter Group, you
need to associate it with your DB Instance using modify_db_instance().  When you associate a new DB
Parameter Group with a running DB Instance, you need to reboot the DB Instance for the new DB
Parameter Group and associated settings to take effect.

Required arguments:

 -db_parameter_group_family            The DB Parameter Group Family name. A DB Parameter Group can
                                       be associated with one and only one DB Parameter Group
                                       Family, and can be applied only to a DB Instance running a
                                       database engine and engine version compatible with that DB
                                       Parameter Group Family.

 -db_parameter_group_name              The name of the DB Parameter Group.
                                       Constraints:
                                       * Must be 1 to 255 alphanumeric characters
                                       * First character must be a letter
                                       * Cannot end with a hyphen or contain two consecutive hyphens
                                       NOTE: This value is stored as a lower-case string.

 -description                          The description for the DB Parameter Group.

Returns a L<VM::EC2::DB::Parameter::Group> object.

=cut

sub create_db_parameter_group {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-db_parameter_group_family} or
        croak "create_db_parameter_group(): -db_parameter_group_family required argument missing";
    $args{-db_parameter_group_name} or
        croak "create_db_parameter_group(): -db_parameter_group_name required argument missing";
    $args{-description} or
        croak "create_db_parameter_group(): -description required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => [qw(DBParameterGroupFamily
                                                           DBParameterGroupName Description)],
                                    });
    return $self->rds_call('CreateDBParameterGroup',@params);
}

=head2 $group = $ec2->create_db_security_group(%args)

Creates a new DB Security Group. DB Security Groups control access to a DB Instance if not in a VPC.

Required arguments:

 -db_security_group_description        The description for the DB Security Group.

 -db_security_group_name               The name for the DB Security Group. This value is stored as a
                                       lowercase string.
                                       Constraints: Must contain no more than 255
                                       alphanumeric characters or hyphens.
                                       Must not be "Default".

 -name                                 Alias for -db_security_group_name

 -description                          Alias for -db_security_group_description

Returns a L<VM::EC2::DB::SecurityGroup> object.

=cut

sub create_db_security_group {
    my $self = shift;
    my %args = @_;
    $args{-db_security_group_name} ||= $args{-name} or
        croak "create_db_security_group(): -db_security_group_name required argument missing";
    $args{-db_security_group_description} ||= $args{-description} or
        croak "create_db_security_group(): -db_security_group_description required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => [qw(DBSecurityGroupDescription
                                                           DBSecurityGroupName)],
                                    });
    return $self->rds_call('CreateDBSecurityGroup',@params);
}

=head2 $dbsnap = $ec2->create_db_snapshot(-db_instance_identifier => $db_id, -db_snapshot_identifier => $snap_id)

Creates a DB snapshot. The source DB instance must be in "available" state.

Required arguments:

 -db_instance_identifier               The DB instance identifier. This is the unique key that
                                       identifies a DB instance. This parameter is not case
                                       sensitive.

                                       Constraints:
                                       * Must contain from 1 to 63 alphanumeric
                                         characters or hyphens
                                       * First character must be a letter
                                       * Cannot end with a hyphen or contain two
                                         consecutive hyphens

 -db_snapshot_identifier               The identifier for the DB snapshot.

                                       Constraints:
                                       * Cannot be null, empty, or blank
                                       * Must contain from 1 to 255 alphanumeric
                                         characters or hyphens
                                       * First character must be a letter
                                       * Cannot end with a hyphen or contain two
                                         consecutive hyphens

 -db_id                                Alias for -db_instance_identifier

 -snapshot_id                          Alias for -db_snapshot_identifier

Returns a L<VM::EC2::DB::Snapshot> object on success.

=cut

sub create_db_snapshot {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} ||= $args{-db_id} or
        croak "create_db_snapshot(): -db_instance_identifier required argument missing";
    $args{-db_snapshot_identifier} ||= $args{-snapshot_id} or
        croak "create_db_snapshot(): -db_snapshot_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm => [qw(DBInstanceIdentifier
                                                           DBSnapshotIdentifier)],
                                    });
    return $self->rds_call('CreateDBSnapshot',@params);
}

=head2 $subnet_group = $ec2->create_db_subnet_group(%args)

Creates a new DB subnet group. DB subnet groups must contain at least one subnet in at least two
availability zones in the region.

Required arguments:

 -db_subnet_group_description          The description for the DB subnet group.

 -db_subnet_group_name                 The name for the DB Subnet Group. This value is stored as a
                                       lowercase string.

                                       Constraints:
                                       * Must contain no more than 255 alphanumeric
                                         characters or hyphens.
                                       * Must not be "Default".

 -subnet_ids                           Arrayref of subnet IDs for the subnet group.

 -description                          Alias for -db_subnet_group_description

 -name                                 Alias -db_subnet_group_name

Returns a L<VM::EC2::DB::Subnet::Group> object on success.

=cut

sub create_db_subnet_group {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-db_subnet_group_name} ||= $args{-name} or
        croak "create_db_subnet_group(): -db_subnet_group_name required argument missing";
    $args{-db_subnet_group_description} ||= $args{-description} or
        croak "create_db_subnet_group(): -db_subnet_group_description required argument missing";
    $args{-subnet_ids} or croak "create_db_subnet_group(): -subnet_ids required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBInstanceIdentifier
                                                                DBSnapshotIdentifier)],
                                        member_list_parm => 'SubnetIds',
                                    });
    return $self->rds_call('CreateDBSubnetGroup',@params);
}

=head2 $event_sub = $ec2->create_event_subscription(%args)

Creates an RDS event notification subscription. This action requires a topic ARN
(Amazon Resource Name) created by either the RDS console, the SNS console, or
the SNS API. To obtain an ARN with SNS, you must create a topic in Amazon SNS
and subscribe to the topic. The ARN is displayed in the SNS console.

You can specify the type of source (SourceType) you want to be notified of,
provide a list of RDS sources (SourceIds) that triggers the events, and provide
a list of event categories (EventCategories) for events you want to be notified
of. For example, you can specify SourceType = db-instance, SourceIds =
mydbinstance1, mydbinstance2 and EventCategories = Availability, Backup.

If you specify both the SourceType and SourceIds, such as SourceType =
db-instance and SourceIdentifier = myDBInstance1, you will be notified of all
the db-instance events for the specified source. If you specify a SourceType but
do not specify a SourceIdentifier, you will receive notice of the events for
that source type for all your RDS sources. If you do not specify either the
SourceType nor the SourceIdentifier, you will be notified of events generated
from all RDS sources belonging to your customer account.

Required arguments:

 -sns_topic_arn        The Amazon Resource Name (ARN) of the SNS topic created
                       for event notification. The ARN is created by Amazon SNS
                       when you create a topic and subscribe to it.

 -subscription_name    The name of the subscription.

Optional arguments:

 -enabled              Boolean; set to true to activate the subscription, set to
                       false to create the subscription but not active it.

 -event_categories     An arrayref of event categories for a -source_type that
                       you want to subscribe to.  You can see a list of the
                       categories for a given -source_type in the Events topic
                       in the Amazon RDS User Guide or by using the
                       describe_event_categories() call.  
 -source_ids           An arrayref of identifiers of the event sources for which
                       events will be returned.  If not specified, then all
                       sources are included in the response. An identifier must
                       begin with a letter and must contain only ASCII letters,
                       digits, and hyphens; it cannot end with a hyphen or
                       contain two consecutive hyphens.

 -source_type          The type of source that will be generating the events.
                       For example, if you want to be notified of events
                       generated by a DB instance, you would set this parameter
                       to db-instance. if this value is not specified, all
                       events are returned.

                       Valid values: db-instance | db-parameter-group |
                                     db-security-group | db-snapshot

 -name                 Alias for -subscription_name

Returns a L<VM::EC2::DB::Event::Subscription> object on success.

=cut

sub create_event_subscription {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-subscription_name} ||= $args{-name} or
        croak "create_event_subscription(): -subscription_name required argument missing";
    $args{-sns_topic_arn} or croak "create_event_subscription(): -sns_topic_arn required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'Enabled',
                                        single_parm      => [qw(SnsTopicArn SourceType
                                                                SubscriptionName)],
                                        member_list_parm => [qw(EventCategories SourceIds)],
                                    });
    return $self->rds_call('CreateEventSubscription',@params);
}

=head2 $option_grp = $ec2->create_option_group(%args)

Creates a new Option Group. You can create up to 20 option groups.

Required arguments:

 -engine_name                     Specifies the name of the engine that this
                                  option group should be associated with.

 -major_engine_version            Specifies the major version of the engine
                                  that this option group should be associated
                                  with.

 -option_group_description        The description of the option group.

 -option_group_name               Specifies the name of the option group to be
                                  created.

                                  Constraints:
                                  * Must be 1 to 255 alphanumeric characters or
                                    hyphens
                                  * First character must be a letter
                                  * Cannot end with a hyphen or contain two
                                    consecutive hyphens

 -name                            Alias for -option_group_name

 -description                     Alias for -option_group_description

Returns a L<VM::EC2::DB::Option::Group> object on success.

=cut

sub create_option_group {
    my $self = shift;
    my %args = @_;
    $args{-option_group_name} ||= $args{-name} or
        croak "create_option_group(): -option_group_name required argument missing";
    $args{-option_group_description} ||= $args{-description} or
        croak "create_option_group(): -option_group_description required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(EngineName MajorEngineVersion
                                                                OptionGroupDescription
                                                                OptionGroupName)],
                                    });
    return $self->rds_call('CreateOptionGroup',@params);
}

=head2 @versions = $ec2->describe_db_engine_versions(%args)

All arguments are optional.

 -db_parameter_group_family       The specific DB Parameter Group family to
                                  return details for.

 -family                          Alias for -db_parameter_group_family

 -default_only                    Return only the default version of the
                                  specified engine or engine and major
                                  version combination (boolean).

 -engine                          Database engine to return.

 -engine_version                  Database engine version to return.

 -list_supported_character_sets   List supported charsets (boolean)

 -marker                          An optional pagination token provided by a previous
                                  request.  If specified, the response includes only
                                  records after the marker, up to the value specified by
                                  -max_records.

 -max_records                     The maximum number of records to include in the
                                  response.  If more records than the max exist,
                                  a marker token is included in the response.

Returns an array of L<VM::EC2::DB::Engine::Version> objects.

=cut

sub describe_db_engine_versions {
    my $self = shift;
    my %args = @_;
    $args{-db_parameter_group_family} ||= $args{-family};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(DefaultOnly
                                                                ListSupportedCharacterSets)],
                                        single_parm      => [qw(DBParameterGroupFamily Engine
                                                                EngineVersion Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBEngineVersions',@params);
}

=head2 @db_instances = $ec2->describe_db_instances(-db_instance_identifier => $id, -marker => $marker, -max_records => $integer)

All arguments are optional.

 -db_instance_identifier    The user-supplied instance identifier. If this
                            parameter is specified, only information for the
                            specific DB Instance is returned.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

 -db_instance_id            alias for -db_instance_identifier

Returns an array of L<VM::EC2::DB::Instance> objects if any exist.

=cut

sub describe_db_instances {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} ||= $args{-db_instance_id};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBInstanceIdentifier
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBInstances',@params);
}

=head2 @groups = $ec2->describe_db_parameter_groups(-db_parameter_group_name => $name, -marker => $marker, -max_records => $integer)

All arguments are optional.

 -db_parameter_group_name   The name of the DB parameter group to describe.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

 -group_name                alias for -db_subnet_group_name

Returns an array of L<VM::EC2::DB::Parameter::Group> objects if any exist.

=cut

sub describe_db_parameter_groups {
    my $self = shift;
    my %args = @_;
    $args{-db_parameter_group_name} ||= $args{-group_name};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBParameterGroupName
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBParameterGroups',@params);
}

=head2 @params = $ec2->describe_db_parameters(-db_parameter_group_name => $name, -source => $source, -marker => $marker, -max_records => $integer)

Required arguments:

 -db_parameter_group_name   The name of the DB parameter group.

Optional arguments:

 -source                    The parameter types to return.
                            Valid values: user | system | engine-default
                            Default is all parameter types.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

Returns an array of L<VM::EC2::DB::Parameter> objects.

=cut

sub describe_db_parameters {
    my $self = shift;
    my %args = @_;
    $args{-db_parameter_group_name} ||= $args{-group_name} or
        croak "describe_db_parameters(): -db_parameter_group_name argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBParameterGroupName Source
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBParameters',@params);
}

=head2 @groups = $ec2->describe_db_security_groups(-db_security_group_name => $name, -marker => $marker, -max_records => $integer)

All arguments are optional.

 -db_security_group_name    The name of the DB security group.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

 -group_name                alias for -db_security_group_name

Returns an array of L<VM::EC2::DB::SecurityGroup> objects if any exist.

=cut

sub describe_db_security_groups {
    my $self = shift;
    my %args = @_;
    $args{-db_security_group_name} ||= $args{-group_name};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBSecurityGroupName
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBSecurityGroups',@params);
}

=head2 @snapshots = $ec2->describe_db_snapshots(%args)

All arguments are optional.

 -db_instance_identifier    A DB Instance Identifier to retrieve the list of DB
                            snapshots for. Cannot be used in conjunction with
                            -db_snapshot_identifier.
                            This parameter is not case sensitive.

 -db_snapshot_identifier    A specific DB Snapshot Identifier to describe.
                            Cannot be used in conjunction with .
                            This value is stored as a lowercase string.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

 -snapshot_type             An optional snapshot type for which snapshots will
                            be returned. If not specified, the returned results
                            will include snapshots of all types.

 -db_instance_id            Alias for -db_instance_identifier

 -db_snapshot_id            Alias for -db_snapshot_identifier

Returns an array of L<VM::EC2:DB::Snapshot> objects if any exist.

=cut

sub describe_db_snapshots {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} ||= $args{-db_instance_id};
    $args{-db_snapshot_identifier} ||= $args{-db_snapshot_id};
    $args{-db_instance_identifier} && $args{-db_snapshot_identifier} and
        croak "describe_db_snapshots(): Specify only one of -db_instance_identifier or -db_snapshot_identifier";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBInstanceIdentifier
                                                                DBSnapshotIdentifier
                                                                SnapshotType Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBSnapshots',@params);
}

=head2 @groups = $ec2->describe_db_subnet_groups(-db_subnet_group_name => $name, -marker => $marker, -max_records => $integer)

All arguments are optional.

 -db_subnet_group_name      The name of the DB Subnet Group to describe.

 -marker                    An optional pagination token provided by a previous
                            request.  If specified, the response includes only
                            records after the marker, up to the value specified by
                            -max_records.

 -max_records               The maximum number of records to include in the
                            response.  If more records than the max exist,
                            a marker token is included in the response.

 -group_name                alias for -db_subnet_group_name

Returns an array of L<VM::EC2::DB::Subnet::Group> objects if any exist.

=cut

sub describe_db_subnet_groups {
    my $self = shift;
    my %args = @_;
    $args{-db_subnet_group_name} ||= $args{-group_name};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBSubnetGroupName
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeDBSubnetGroups',@params);
}

=head2 @params = $ec2->describe_engine_default_parameters(%args)

Required arguments:

 -db_parameter_group_family    The name of the DB Parameter Group Family.

 -family                       Alias for -db_parameter_group_family

Returns an array of L<VM::EC2::DB::Parameter> objects.

=cut

sub describe_engine_default_parameters {
    my $self = shift;
    my %args = @_;
    $args{-db_parameter_group_family} ||= $args{-family} or
        croak "describe_engine_default_parameters(): missing argument -db_parameter_group_family";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBParameterGroupFamily
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeEngineDefaultParameters',@params);
}

=head2 @categories = $ec2->describe_event_categories(-source_type => $type)

Optional argument:

 -source_type         The type of source that will be generating the events.
                      Valid values: db-instance | db-parameter-group |
                       db-security-group | db-snapshot

Returns an array of L<VM::EC2::DB::Event::Category> objects

=cut

sub describe_event_categories {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(SourceType
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeEventCategories',@params);
}

=head2 @subs = $ec2->describe_event_subscriptions(-subscription_name => $name)

Optional argument:

 -subscription_name       The name of the RDS event notification subscription.

Returns an array of L<VM::EC2::DB::Event::Subscription> object.

=cut

sub describe_event_subscriptions {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(SubscriptionName
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeEventSubscriptions',@params);
}

=head2 @events = $ec2->describe_events(%args)

All arguments are optional but some conditions apply.

 -duration                The number of minutes to retrieve events for.

 -end_time                The end of the time interval for which to retrieve
                          events, specified in ISO 8601 format.
                          For more information on ISO 8601, visit:
                          http://en.wikipedia.org/wiki/ISO_8601

 -event_categories        A string or arrayref of event categories that trigger
                          notifications for a event notification subscription.

 -source_identifier       The identifier of the event source for which events
                          will be returned. If not specified, then all sources
                          are included in the response.

 -source_type             The event source to retrieve events for. If no value
                          is specified, all events are returned.
                          REQUIRED if -source_identifier is provided.

                          If 'DBInstance', then a DBInstanceIdentifier must be
                          supplied in -source_identifier.

                          If 'DBSecurityGroup', a DBSecurityGroupName must be
                          supplied in -source_identifier.

                          If 'DBParameterGroup', a DBParameterGroupName must be
                          supplied in -source_identifier.

                          If 'DBSnapshot', a DBSnapshotIdentifier must be
                          supplied in -source_identifier.

 -start_time              The beginning of the time interval to retrieve events
                          for, specified in ISO 8601 format.
                          For more information on ISO 8601, visit:
                          http://en.wikipedia.org/wiki/ISO_8601

Returns an array of L<VM::EC2::DB::Event> objects.

=cut

sub describe_events {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(Duration EndTime SourceIdentifier SourceType StartTime
                                                                Marker MaxRecords)],
                                        member_list_parm => 'EventCategories',
                                    });
    return $self->rds_call('DescribeEvents',@params);
}

=head2 @options = $ec2->describe_option_group_options(-engine_name => $name, -major_engine_version => $version)

Describes all available options for a particular database engine.

Required arguments:

 -engine_name                 Database engine to describe options for.

Optional arguments:

 -major_engine_version        If specified, filters the results to include only
                              options for the specified major engine version.

Returns an array of L<VM::EC2::DB::Option::Group::Option> objects.

=cut

sub describe_option_group_options {
    my $self = shift;
    my %args = @_;
    $args{-engine_name} or
        croak "describe_option_group_options(): Required argument -engine_name missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(EngineName MajorEngineVersion
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeOptionGroupOptions',@params);
}

=head2 @groups = $ec2->describe_option_groups(-engine_name => $name, -major_engine_version => $version, -option_group_name => $og_name)

Describes the available option groups.

All arguments are optional.

 -engine_name                 Database engine to describe options for.

 -major_engine_version        If specified, filters the results to include only
                              options for the specified major engine version.

 -option_group_name           The name of the option group to describe. Cannot
                              be supplied together with -engine_name or
                              -major_engine_version.

Returns an array of L<VM::EC2::DB::Option::Group> objects.

=cut

sub describe_option_groups {
    my $self = shift;
    my %args = @_;
    $args{-engine_name} && $args{-option_group_name} and
        croak "describe_option_groups(): Cannot specify -engine_name and -option_group_name together";
    $args{-major_engine_version} && $args{-option_group_name} and
        croak "describe_option_groups(): Cannot specify -major_engine_version and -option_group_name together";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(EngineName MajorEngineVersion
                                                                OptionGroupName
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeOptionGroups',@params);
}

=head2 @options = $ec2->describe_orderable_db_instance_options(%args)

Describe the different RDS instances that can be launched.

Required arguments:

 -engine                 The name of the engine to retrieve DB Instance options
                         for.

Optional arguments:

 -db_instance_class      The DB Instance class (size) filter value.

 -engine_version         The engine version filter value.

 -license_model          The license model filter value.

 -vpc                    The VPC filter value. (boolean)

Returns an array of L<VM::EC2::DB::Instance::OrderableOption> objects.

=cut

sub describe_orderable_db_instance_options {
    my $self = shift;
    my %args = @_;
    $args{-engine} or
        croak "describe_orderable_db_instance_options(): Required argument -engine missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'Vpc',
                                        single_parm      => [qw(Engine DBInstanceClass
                                                                EngineVersion LicenseModel
                                                                Marker MaxRecords)],
                                    });
   return $self->rds_call('DescribeOrderableDBInstanceOptions',@params);
}

=head2 @instances = $ec2->describe_reserved_db_instances(%args)

Returns information about reserved DB Instances for the account, or about a
specific reserved DB Instance.

All arguments are optional:

 -db_instance_class                     The DB Instance class (size) filter.

 -duration                              The duration filter value, specified in
                                        years or seconds.
                                        Valid values: 1 | 3 | 31536000 | 94608000

 -multi_az                              The Multi-AZ filter value. (boolean)

 -offering_type                         The offering type filter value.
                                        Valid Values: "Light Utilization" |
                                         "Medium Utilization" |
                                         "Heavy Utilization"

 -product_description                   The product description filter value.

 -reserved_db_instance_id               The reserved DB Instance identifier filter value.

 -reserved_db_instances_offering_id     The offering identifier filter value.

Returns an array of L<VM::EC2::DB::Reserved::Instance> objects.

=cut

sub describe_reserved_db_instances {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'MultiAZ',
                                        single_parm      => [qw(DBInstanceClass Duration
                                                                OfferingType ProductDescription
                                                                ReservedDBInstanceId
                                                                ReservedDBInstancesOfferingId
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeReservedDBInstances',@params);
}

=head2 @offerings = $ec2->describe_reserved_db_instances_offerings(%args)

Lists available reserved DB Instance offerings.

All arguments are optional:

 -db_instance_class                     The DB Instance class (size) filter.

 -duration                              The duration filter value, specified in
                                        years or seconds.
                                        Valid values: 1 | 3 | 31536000 | 94608000

 -multi_az                              The Multi-AZ filter value. (boolean)

 -offering_type                         The offering type filter value.
                                        Valid Values: "Light Utilization" |
                                         "Medium Utilization" |
                                         "Heavy Utilization"

 -product_description                   The product description filter value.

 -reserved_db_instance_id               The reserved DB Instance identifier filter value.

 -reserved_db_instances_offering_id     The offering identifier filter value.

Returns an array of L<VM::EC2::DB::Reserved::Instance> objects.

=cut

sub describe_reserved_db_instances_offerings {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'MultiAZ',
                                        single_parm      => [qw(DBInstanceClass Duration
                                                                OfferingType ProductDescription
                                                                ReservedDBInstanceId
                                                                ReservedDBInstancesOfferingId
                                                                Marker MaxRecords)],
                                    });
    return $self->rds_call('DescribeReservedDBInstancesOfferings',@params);
}

=head2 $log = $ec2->download_db_log_file_portion(%args)

Downloads the last line of the specified log file.

All arguments are optional:

 -db_instance_identifier                The DB Instance class (size) filter.

 -log_file_name                         The name of the log file to be downloaded.

 -marker                                The pagination token provided in the previous
                                        request. If this parameter is specified the
                                        response includes only records beyond the marker,
                                        up to MaxRecords.

 -number_of_lines                       The number of lines remaining to be downloaded.

Returns a L<VM::EC2::DB::LogFilePortion> object.

=cut

sub download_db_log_file_portion {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBInstanceIdentifier LogFileName
                                                                Marker NumberOfLines)],
                                    });
    return $self->rds_call('DownloadDBLogFilePortion',@params);
}

=head2 %tags = $ec2->list_tags_for_resource(-resource_name => $name)

Lists all tags on a DB Instance or Snapshot.

Arguments:

 -resource_name         The name of the resource to list tags for.

Returns a hash or hashref of tags.

=cut

sub list_tags_for_resource {
    my $self = shift;
    my %args = @_;
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => 'ResourceName',
                                    });
    return $self->rds_call('ListTagsForResource',@params);
}

=head2 $db_instance = $ec2->modify_db_instance(%args)

Modify settings for a DB Instance. You can change one or more database configuration
parameters by specifying these parameters and the new values in the request.

Required arguments:

 -db_instance_identifier               The DB Instance identifier.

Optional arguments:

 -allocated_storage                    The new storage capacity of the RDS instance. Changing this
                                       parameter does not result in an outage and the change is
                                       applied during the next maintenance window unless the
                                       -apply_immediately parameter is set to true for this request.
                                       MySQL:
                                        * Must be an integer from 5 to 1024.
                                        * Value supplied must be at least 10% greater than the
                                          current value. Values that are not at least 10% greater
                                          than the existing value are rounded up so that they are
                                          10% greater than the current value.
                                       Oracle:
                                        * Must be an integer from 10 to 1024.
                                        * Value supplied must be at least 10% greater than the
                                          current value. Values that are not at least 10% greater
                                          than the existing value are rounded up so that they are
                                          10% greater than the current value.
                                       SQL Server:
                                        * CANNOT BE MODIFIED

 -allow_major_version_upgrade          Indicates that major version upgrades are allowed. Changing
                                       this parameter does not result in an outage and the change is
                                       asynchronously applied as soon as possible.

                                       Constraints: This parameter must be set to true when
                                       specifying a value for the -engine_version argument that is
                                       a different major version than the DB Instance's current
                                       version.

 -apply_immediately                    Specifies whether or not the modifications in this request
                                       and any pending modifications are asynchronously applied as
                                       soon as possible, regardless of the
                                       -preferred_maintenance_window setting for the DB Instance.

                                       If this parameter is passed as false, changes to the DB
                                       Instance are applied on the next reboot_db_instance() call,
                                       the next maintenance reboot, or the next failure reboot,
                                       whichever occurs first. See each parameter to determine when
                                       a change is applied.  Default is false.

 -auto_minor_version_upgrade           Indicates that minor engine upgrades will be applied
                                       automatically to the DB Instance during the maintenance
                                       window.  Changing this parameter does not result in an outage
                                       except in the following case and the change is asynchronously
                                       applied as soon as possible. An outage will result if this
                                       parameter is set to true during the maintenance window, and a
                                       newer minor version is available, and RDS has enabled auto
                                       patching for that engine version.  (Boolean)

 -backup_retention_period              The number of days for which automated backups are retained.
                                       Setting this parameter to a positive number enables backups.
                                       Setting this parameter to 0 disables automated backups.
                                       Default: Existing setting
                                       Constraints:
                                        * Must be a value from 0 to 8
                                        * Cannot be set to 0 if the DB Instance is a master instance
                                          with read replicas

 -db_instance_class                    The new compute and memory capacity of the DB Instance.
                                       To determine the available classes, use the
                                       describe_orderable_db_instance_options() call.

                                       Passing a value for this parameter causes an outage during
                                       the change and is applied during the next maintenance window,
                                       unless the -apply_immediately argument is specified as true
                                       for this request.

                                       Valid values:
                                       db.t1.micro | db.m1.small | db.m1.medium | db.m1.large |
                                       db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge

 -db_parameter_group_name              The name of the DB Parameter Group to apply to this DB Instance.
                                       Changing this parameter does not result in an outage and the
                                       change is applied during the next maintenance window unless the
                                       -apply_immediately argument is set to true for this request.

                                       Default: Existing setting.

                                       Constraints:
                                       * Must be 1 to 255 alphanumeric characters
                                       * First character must be a letter.
                                       * Cannot end with a hyphen or contain two consecutive
                                         hyphens

 -db_security_groups                   An arrayref of DB Security Groups to authorize on this DB
                                       Instance.  Changing this parameter does not result in an outage
                                       and the change is asynchronously applied as soon as possible.

 -engine_version                       The version number of the database engine to upgrade to.
                                       Changing this parameter results in an outage and the change is
                                       applied during the next maintenance window unless the
                                       -apply_immediately parameter is set to true for this request.

                                       For major version upgrades, if a nondefault DB Parameter Group is
                                       currently in use, a new DB Parameter Group in the DB Parameter
                                       Group Family for the new engine version must be specified. The
                                       new DB Parameter Group can be the default for that DB Parameter
                                       Group Family.

 -iops                                 The new Provisioned IOPS (I/O operations per second) value for
                                       the RDS instance. Changing this parameter does not result in an
                                       outage and the change is applied during the next maintenance
                                       window unless the -apply_immediately argument is set to true for
                                       this request.

                                       Default: Existing setting.

                                       Constraints:
                                       * Value supplied must be at least 10% greater than the current
                                         value. Values that are not at least 10% greater than the
                                         existing value are rounded up so that they are 10% greater than
                                         the current value.

 -master_user_password                 The new password for the master database user. Can be any
                                       printable ASCII character except "/", "\", or "@".

                                       Changing this parameter does not result in an outage and the
                                       change is asynchronously applied as soon as possible. Between the
                                       time of the request and the completion of the request, the
                                       MasterUserPassword element exists in the PendingModifiedValues
                                       element of the operation response.

                                       Constraints:
                                        * MySQL:  Must contain from 8 to 41 alphanumeric characters.
                                        * Oracle: Must contain from 8 to 30 alphanumeric characters.
                                        * SQL Server: Must contain from 8 to 128 alphanumeric
                                          characters.

 -multi_az                             Specifies if the DB Instance is a Multi-AZ deployment.
                                       Changing this parameter does not result in an outage and the
                                       change is applied during the next maintenance window unless
                                       the -apply_immediately argument is set to true for this request.
                                       (Boolean)

                                       Constraints:
                                       * Cannot be specified if the DB Instance is a read replica.

 -new_db_instance_identifier           The new DB Instance identifier for the DB Instance when renaming
                                       a DB Instance. This value is stored as a lowercase string.

                                       Constraints:
                                        * Must contain from 1 to 63 alphanumeric characters or
                                          hyphens (1 to 15 for SQL Server).
                                        * First character must be a letter.
                                        * Cannot end with a hyphen or contain two consecutive
                                          hyphens.

 -option_group_name                    Indicates that the DB Instance should be associated
                                       with the specified option group.  Changing this parameter does
                                       not result in an outage except in the following case and the
                                       change is applied during the next maintenance window unless the
                                       -apply_immediately argument is set to true for this request. If
                                       the parameter change results in an option group that enables OEM,
                                       this change can cause a brief (sub-second) period during which
                                       new connections are rejected but existing connections are not
                                       interrupted.

                                       Note that persistent options, such as the TDE_SQLServer option for
                                       Microsoft SQL Server, cannot be removed from an option group while
                                       DB instances are associated with the option group. Permanent options,
                                       such as the TDE option for Oracle Advanced Security TDE, cannot be
                                       removed from an option group, and that option group cannot be removed
                                       from a DB instance once it is associated with a DB instance.

 -preferred_backup_window              The daily time range during which automated backups are
                                       created if automated backups are enabled using the
                                       -backup_retention_period argument.

                                       Default: Default: A 30-minute window selected at random
                                       from an 8-hour block of time per region. The following
                                       list shows the time blocks for each region from which
                                       the default backup windows are assigned.

                                       * US-East (Northern Virginia) Region: 03:00-11:00 UTC
                                       * US-West (N. California, Oregon) Region: 06:00-14:00 UTC
                                       * EU (Ireland) Region: 22:00-06:00 UTC
                                       * Asia Pacific (Singapore) Region: 14:00-22:00 UTC
                                       * Asia Pacific (Tokyo) Region: 17:00-03:00 UTC

                                       Constraints:
                                        * Must be in the format hh24:mi-hh24:mi
                                        * Times in Universal Time Coordinated (UTC).
                                        * Must not conflict with the preferred maintenance window.
                                        * Must be at least 30 minutes.

 -preferred_maintenance_window         The weekly time range (in UTC) during which system
                                       maintenance can occur.

                                       Format: ddd:hh24:mi-ddd:hh24:mi

                                       Default: A 30-minute window selected at random from an 8-hour
                                       block of time per region, occurring on a random day of the
                                       week. The following list shows the time blocks for each
                                       region from which the default maintenance windows are
                                       assigned.

                                       * US-East (Northern Virginia) Region: 03:00-11:00 UTC
                                       * US-West (N. California, Oregon) Region: 06:00-14:00 UTC
                                       * EU (Ireland) Region: 22:00-06:00 UTC
                                       * Asia Pacific (Singapore) Region: 14:00-22:00 UTC
                                       * Asia Pacific (Tokyo) Region: 17:00-03:00 UTC

                                       Valid Days: Mon, Tue, Wed, Thu, Fri, Sat, Sun
                                       Constraints: Minimum 30-minute window.

 -vpc_security_group_ids               A list of EC2 VPC Security Groups to associate with this
                                       DB Instance.  This change is asynchronously applied as soon
                                       as possible.

This method returns a L<VM::EC2::DB:Instance> object.

=cut

sub modify_db_instance {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} or
        croak "modify_db_instance(): -db_instance_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(AutoMinorVersionUpgrade MultiAZ
                                                                PubliclyAccessible)],
                                        single_parm      => [qw(AllocatedStorage AvailabilityZone
                                                                BackupRetentionPeriod
                                                                CharacterSetName DBInstanceClass
                                                                DBInstanceIdentifier DBName
                                                                DBParameterGroupName
                                                                DBSubnetGroupName Engine
                                                                EngineVersion Iops LicenseModel
                                                                MasterUserPassword MasterUsername
                                                                OptionGroupName Port
                                                                PreferredBackupWindow
                                                                PreferredMaintenanceWindow)],
                                        member_list_parm => [qw(VpcSecurityGroupIds
                                                                DBSecurityGroups)],
                                    });
    return $self->rds_call('CreateDBInstance',@params);
}

=head2 $group_name = $ec2->modify_db_parameter_group(-db_parameter_group_name => $group, -parameters => \@parms)

Modifies the parameters of a DB Parameter Group.

Note: The immediate method can be used only for dynamic parameters; the pending-reboot method
can be used with MySQL and Oracle DB Instances for either dynamic or static parameters. For 
Microsoft SQL Server DB Instances, the pending-reboot method can be used only for static 
parameters.

Required arguments:

 -db_parameter_group_name             The name of the DB Parameter Group.
                                      Constraints:
                                      * Must be the name of an existing DB Parameter Group
                                      * Must be 1 to 255 alphanumeric characters
                                      * First character must be a letter
                                      * Cannot end with a hyphen or contain two consecutive hyphens

 -parameters                          An arrayref of hashes containing parameter names, values,
                                      and the apply method for the parameter update. At least one
                                      parameter name, value, and apply method must be supplied;
                                      subsequent arguments are optional. A maximum of 20 parameters
                                      may be modified in a single request.

                                      The hash keys must be: ParameterName, ParameterValue, ApplyMethod

                                      ie:
                                      [ { ParameterName => 'db_block_checking',
                                          ParameterValue => 'FULL',
                                          ApplyMethod => 'immediate' } ]

 -name                                Alias for -db_parameter_group_name

Returns the DB Parameter Group name on success.

=cut

sub modify_db_parameter_group {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-db_parameter_group_name} ||= $args{-name} or
        croak "modify_db_parameter_group(): -db_parameter_group_name required argument missing";
    $args{-parameters} or
        croak "modify_db_parameter_group(): -parameters required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => 'DBParameterGroupName',
                                        member_hash_parm => 'Parameters',
                                    });
    return $self->rds_call('ModifyDBParameterGroup',@params);
}

=head2 $subnet_group = $ec2->modify_db_subnet_group(%args)

Modifies an existing DB subnet group. DB subnet groups must contain at least one subnet in at 
least two AZs in the region.

Required arguments:

 -db_subnet_group_name                The name for the DB Subnet Group.

 -subnet_ids                          An arrayref of EC2 Subnet IDs for the DB Subnet Group.

Optional arguments:

 -db_subnet_group_description         The description for the DB Subnet Group.

Returns L<VM::EC2::DB::Subnet::Group> object on success.

=cut

sub modify_db_subnet_group {
    my $self = shift;
    my %args = @_;
    $args{-db_subnet_group_name} or
        croak "modify_db_subnet_group(): -db_subnet_group_name required argument missing";
    $args{-subnet_ids} or
        croak "modify_db_subnet_group(): -subnet_ids required argument missing";
    ref $args{-subnet_ids} eq 'ARRAY' or
        croak "modify_db_subnet_group(): -subnet_ids must be an arrayref";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBSubnetGroupName
                                                                DBSubnetGroupDescription)],
                                        member_list_parm => 'SubnetIds',
                                    });
    return $self->rds_call('ModifyDBSubnetGroup',@params);
}

=head2 $event_sub = $ec2->modify_event_subscription(%args)

Modifies an existing RDS event notification subscription. Note that you cannot modify the source 
identifiers using this call; to change source identifiers for a subscription, use the 
add_source_identifier_to_subscription() and remove_source_identifier_from_subscription() calls.

Required arguments:

 -subscription_name                   The name of the RDS event notification subscription.

Optional arguments:

 -enabled                             Boolean value; set to true to activate the subscription.

 -event_categories                    An arrayref of event categories for a -source_type to
                                      subscribe to.  A list of the categories for a given
                                      -source_type can be seen in the Events topic in the Amazon
                                      RDS User Guide or by using the describe_event_categories()
                                      call.

 -sns_topic_arn                       The Amazon Resource Name (ARN) of the SNS topic created for 
                                      event notification. The ARN is created by Amazon SNS when 
                                      a topic is created and subscribed to.

 -source_type                         The type of source that will be generating the events.
                                      For example, to be notified of events generated by a DB
                                      instance, set this parameter to db-instance. if this value is
                                      not specified, all events are returned.

                                      Valid values: db-instance | db-parameter-group | 
                                                    db-security-group | db-snapshot

Returns a L<VM::EC2::DB::Event::Subscription> object on success.

=cut

sub modify_event_subscription {
    my $self = shift;
    my %args = @_;
    $args{-subscription_name} or
        croak "modify_event_subscription(): -subscription_name required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'Enabled',
                                        single_parm      => [qw(SnsTopicArn SourceType
                                                                SubscriptionName)],
                                        member_list_parm => 'EventCategories',
                                    });
    return $self->rds_call('ModifyEventSubscription',@params);
 }

=head2 $option_group = $ec2->modify_option_group(%args)

Modifies an existing Option Group.

Required arguments:

 -option_group_name                   The name of the option group to be modified.

Optional arguments:

 -apply_immediately                   Indicates whether the changes should be applied immediately,
                                      or during the next maintenance window for each instance
                                      associated with the Option Group. (Boolean)

 -options_to_include                  An arrayref of hashes containing OptionName and other available
                                      options.

                                      Available options are: DBSecurityGroupMemberships, OptionName,
                                      OptionSettings, Port, VpcSecurityGroupMemberships

                                      OptionName and Port must be provided as scalars.
                                      DBSecurityGroupMemberships, VpcSecurityGroupMemberships must
                                      be provided as arrayrefs.
                                      OptionSettings must be a hashref of Name => Value pairs.

                                      ie:
                                         [ { OptionName => 'OEM',
                                             DBSecurityGroupMemberships => [ 'mygroup' ],
                                             Port => 1158 },
                                           { OptionName => 'NATIVE_NETWORK_ENCRYPTION',
                                             OptionSettings => {
                                                 'SQLNET.ENCRYPTION_SERVER' => 'REQUIRED',
                                                 'SQLNET.CRYPTO_CHECKSUM_SERVER' => 'REQUIRED' } } ]


 -options_to_remove                   A string or arrayref containing the containing the option(s) to
                                      remove.

                                      ie:
                                         [ 'OEM', 'NATIVE_NETWORK_ENCRYPTION' ]
                                      or
                                         'OEM'

Returns a L<VM::EC2::DB::Option::Group> object on success.

=cut

sub modify_option_group {
    my $self = shift;
    my %args = @_;
    my @params;
    $args{-option_group_name} or
        croak "modify_option_group(): -option_group_name required argument missing";
    ($args{-options_to_include} || $args{-options_to_remove}) or
        croak "modify_option_group(): -options_to_include or -options_to_remove argument required";

    # -options_to_include is a convoluted combination of parameter types
    # The DBSecurityGroupMemberships, VpcSecurityGroupMemberships options use
    # parameters in the style:
    #   OptionsToInclude.member.1.DBSecurityGroupMemberships.member.1=value1
    #   OptionsToInclude.member.1.DBSecurityGroupMemberships.member.2=value2
    #
    # The OptionSettings option use parameters in the style:
    #   OptionsToInclude.member.1.OptionSettings.member.1.Name=SQLNET.ENCRYPTION_SERVER
    #   OptionsToInclude.member.1.OptionSettings.member.1.Value=REQUIRED
    #
    # The following code is to generate the parameters from perl objects
    #
    if (my $options = $args{-options_to_include}) {
        croak "modify_option_group(): -options_to_include must be hashref or arrayref"
            unless ref $options;
        my @options = ref $options eq 'HASH' ? ($options) : @$options;
        foreach my $option (@options) {
            next unless ref $option eq 'HASH';
            foreach my $option_cfg (keys %$option) {
                if (ref $option->{$option_cfg}) {
                    my %p;
                    # this is for DBSecurityGroupMemberships, VpcSecurityGroupMemberships
                    if (ref $option->{$option_cfg} eq 'ARRAY') {
                        # create hashref compatible with member_list_parm()
                        my $hash_ref = { "-$option_cfg" => $option->{$option_cfg} };
                        %p = $self->member_list_parm($option_cfg,$hash_ref);
                    }
                    # this is for OptionSettings
                    else {
                        my $array_ref;
                        foreach my $name (keys %{$option->{$option_cfg}}) {
                            push @$array_ref, {
                                Name => $name,
                                Value => $option->{$option_cfg}->{$name}
                            };
                        }
                        %p = $self->member_hash_parms($option_cfg,{ "-$option_cfg" => $array_ref });
                    }
                    $option->{$_} = $p{$_} foreach keys %p;
                    delete $option->{$option_cfg};
                }
            }
        }
    }
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'ApplyImmediately',
                                        single_parm      => 'OptionGroupName',
                                        member_list_parm => 'OptionsToRemove',
                                        member_hash_parm => 'OptionsToInclude',
                                    });
    return $self->rds_call('ModifyOptionGroup',@params);
}

=head2 $db_instance = $ec2->promote_read_replica(%args)

Promotes a Read Replica DB Instance to a standalone DB Instance.

Required arguments:

 -db_instance_identifier              The DB Instance identifier. This value is stored as a
                                      lowercase string.

                                      Constraints:
                                      * Must be the identifier for an existing Read Replica DB
                                        Instance
                                      * Must contain from 1 to 63 alphanumeric characters or
                                        hyphens
                                      * First character must be a letter
                                      * Cannot end with a hyphen or contain two consecutive hyphens

Optional arguments:

 -backup_retention_period             The daily time range during which automated backups are
                                      created if automated backups are enabled.

 -preferred_backup_window             The daily time range during which automated backups are
                                      created if automated backups are enabled using the
                                      -backup_retention_period argument.

                                      Default: Default: A 30-minute window selected at random
                                      from an 8-hour block of time per region. The following
                                      list shows the time blocks for each region from which
                                      the default backup windows are assigned.

                                      * US-East (Northern Virginia) Region: 03:00-11:00 UTC
                                      * US-West (N. California, Oregon) Region: 06:00-14:00 UTC
                                      * EU (Ireland) Region: 22:00-06:00 UTC
                                      * Asia Pacific (Singapore) Region: 14:00-22:00 UTC
                                      * Asia Pacific (Tokyo) Region: 17:00-03:00 UTC

                                      Constraints:
                                       * Must be in the format hh24:mi-hh24:mi
                                       * Times in Universal Time Coordinated (UTC).
                                       * Must not conflict with the preferred maintenance window.
                                       * Must be at least 30 minutes.


Returns a L<VM::EC2::DB::Instance> object on success.

=cut

sub promote_read_replica {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} or
        croak "promote_read_replica(): -db_instance_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(BackupRetentionPeriod
                                                                DBInstanceIdentifier
                                                                PreferredBackupWindow)],
                                    });
    return $self->rds_call('PromoteReadReplica',@params);
}

=head2 $reserved_db = $ec2->purchase_reserved_db_instances_offering(%args)

Purchases a reserved DB Instance offering.

Required arguments:

 -reserved_db_instances_offering_id   The ID of the Reserved DB Instance offering to purchase.
                                      ie: 438012d3-4052-4cc7-b2e3-8d3372e0e706

Optional arguments:

 -db_instance_count                   The number of instances to reserve.  Default: 1

 -reserved_db_instance_id             Customer-specified identifier to track this reservation.
                                      ie: myreservationID

Returns a L<VM::EC2::DB::Reserved::Instance> object on success.

=cut

sub purchase_reserved_db_instances_offering {
    my $self = shift;
    my %args = @_;
    $args{-reserved_db_instances_offering_id} or
        croak "purchase_reserved_db_instances_offering(): -reserved_db_instances_offering_id required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(DBInstanceCount
                                                                ReservedDBInstanceId
                                                                ReservedDBInstancesOfferingId)],
                                    });
    return $self->rds_call('PurchaseReservedDBInstancesOffering',@params);
}

=head2 $db_instance = $ec2->reboot_db_instance(-db_instance_identifier => $id, -force_failover => $boolean)

Reboots a previously provisioned RDS instance. This API results in the application of modified
DBParameterGroup parameters with ApplyStatus of pending-reboot to the RDS instance. This action
is taken as soon as possible, and results in a momentary outage to the RDS instance during which
the RDS instance status is set to rebooting. If the RDS instance is configured for MultiAZ, it is
possible that the reboot will be conducted through a failover. A DBInstance event is created when
the reboot is completed.

Required arguments:

 -db_instance_identifier              The DB Instance identifier. 

Optional arguments:

 -force_failover                      When true, the reboot will be conducted through a MultiAZ
                                      failover.

                                      Constraints:
                                      * You cannot specify true if the instance is not configured
                                        for MultiAZ.

Returns a L<VM::EC2::DB::Instance> object on success.

=cut

sub reboot_db_instance {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} or
        croak "reboot_db_instance(): -db_instance_identifier required argument missing";
    $args{-DBInstanceIdentifier} = $args{-db_instance_identifier};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm => 'ForceFailover',
                                        single_parm  => 'DBInstanceIdentifier',
                                    });
    return $self->rds_call('RebootDBInstance',@params);
}

=head2 $event_sub = $ec2->remove_source_identifier_from_subscription(-source_identifier => $id, -subscription_name => $name)

Removes a source identifier from an existing RDS event notification subscription.

Required arguments:

 -source_identifier                   The source identifier to be removed from the subscription,
                                      such as the DB instance identifier for a DB instance or the
                                      name of a security group.

 -subscription_name                   The name of the RDS event notification subscription to remove
                                      a source identifier from.

Returns a L<VM::EC2::DB::Event::Subscription> object on success.

=cut

sub remove_source_identifier_from_subscription {
    my $self = shift;
    my %args = @_;
    $args{-instance_identifier} or
        croak "remove_source_identifier_from_subscription(): -instance_identifier required argument missing";
    $args{-subscription_name} or
        croak "remove_source_identifier_from_subscription(): -subscription_name required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm  => [qw(SourceIdentifier SubscriptionName)],
                                    });
    return $self->rds_call('RemoveSourceIdentifierFromSubscription',@params);
}

=head2 $ec2->remove_tags_from_resource(-resource_name => $name, -tags => \@tags)

Remove metadata tags from a resource.

Required arguments:

 -resource_name     The Amazon RDS resource the tags will be removed from.  This value is an Amazon
                    Resource Name (ARN).  For information about creating an ARN, see Constructing
                    an RDS Amazon Resource Name (ARN) at:
                    http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN

 -tags              hashref or arrayref of hashrefs containing tag Key/Value pairs

This method does not return a value but will raise an error if unsuccessful.

=cut

sub remove_tags_from_resource {
    my $self = shift;
    my %args = @_;
    $args{-tags} && $args{-resource_name} or
        croak "remove_tags_from_resource(): -tags and -resource_name arguments required";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => 'ResourceName',
                                        member_list_parm => 'Tags',
                                    });
    return $self->rds_call('RemoveTagsFromResource',@params);
}

=head2 $name = $ec2->reset_db_parameter_group(%args)

Modifies the parameters of a DB parameter group to the engine/system default value.  To reset
specific parameters, submit a hashref of the following: ParameterName and ApplyMethod.
To reset the entire DB parameter group, set the -reset_all_parameters argument to true.
When resetting the entire group, dynamic parameters are updated immediately and static 
parameters are set to pending-reboot to take effect on the next DB instance restart or
after issuing a reboot_db_instance().

Required arguments:

 -db_parameter_group_name             The name of the DB Parameter Group. 
                                      Constraints:
                                      * Must be the name of an existing DB Parameter Group
                                      * Must be 1 to 255 alphanumeric characters
                                      * First character must be a letter
                                      * Cannot end with a hyphen or contain two consecutive hyphens

Conditional arguments:

 -parameters                          An arrayref of hashes containing parameter names and the apply 
                                      method for the parameter update. 

                                      The hash keys must be: ParameterName and ApplyMethod
                                      ie:
                                         [ { ParameterName => 'max_user_connections',
                                             ApplyMethod => 'pending-reboot' },
                                           { ParameterName => 'max_allowed_packet',
                                             ApplyMethod => 'immediate' } ]

 -reset_all_parameters                Reset all parameters in the DB parameter group to default
                                      values.  Boolean, default is true.

Returns the name of the DB parameter group.

=cut

sub reset_db_parameter_group {
    my $self = shift;
    my %args = @_;
    $args{-db_parameter_group_name} or
        croak "reset_db_parameter_group(): -db_parameter_group_name argument required";
    $args{-DBParameterGroupName} = $args{-db_parameter_group_name};
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => 'ResetAllParameters',
                                        single_parm      => 'DBParameterGroupName',
                                        member_hash_parm => 'Parameters',
                                    });
    return $self->rds_call('ResetDBParameterGroup',@params);
}

=head2 $db_instance = $ec2->restore_db_instance_from_db_snapshot(%args)

Creates a new DB instance from a DB snapshot.  The target database is created from the source
database restore point with the same configuration as the original source database, except that
the new RDS instance is created in the default security group.

Required arguments:

 -db_instance_identifier               The DB Instance identifier. 
                                       Constraints:
                                        * Must contain from 1 to 63 alphanumeric characters or
                                          hyphens (1 to 15 for SQL Server).
                                        * First character must be a letter.
                                        * Cannot end with a hyphen or contain two consecutive
                                          hyphens.

 -db_snapshot_identifier               The identifier for the DB snapshot.

                                       Constraints:
                                       * Must contain 1 to 255 alphanumeric characters or hyphens
                                       * First character must be a letter
                                       * Cannot end with a hyphen or contain two consecutive hyphens

Optional arguments:

 -auto_minor_version_upgrade           Indicates that minor engine upgrades will be applied
                                       automatically to the DB Instance during the maintenance
                                       window.  (Boolean).  Default: true

 -availability_zone                    The EC2 Availability Zone that the database instance will
                                       be created in.
                                       Default: A random, system-chosen Availability Zone in the
                                                endpoint's region.
                                       Constraint:  Cannot specify if -multi_az is true

 -db_instance_class                    The compute and memory capacity of the DB Instance.
                                       db.t1.micro | db.m1.small | db.m1.medium | db.m1.large |
                                       db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge

 -db_name                              The database name for the restored DB instance.
                                       NOTE: Does not apply to MySQL engine.

 -db_subnet_group_name                 A DB Subnet Group to associate with this DB Instance.
                                       If not specified, then it is a non-VPC DB instance.

 -engine                               The name of the database engine to be used for this
                                       instance.
                                       Default is that of source.
                                       Valid values:  MySQL | oracle-se1 | oracle-se | oracle-ee |
                                        sqlserver-ee | sqlserver-se | sqlserver-ex | sqlserver-web

 -iops                                 The amount of Provisioned IOPS initially allocated.
                                       Must be an integer greater than 1000

 -license_model                        License model information for this DB Instance.
                                       Valid values: license-included |
                                                     bring-your-own-license |
                                                     general-public-license

 -multi_az                             Specifies if the DB Instance is a Multi-AZ deployment.
                                       You cannot set the -availability_zone argument if the
                                       -multi_az argument is set to true.

 -option_group_name                    Indicates that the DB Instance should be associated
                                       with the specified option group.

 -port                                 The port number on which the database accepts
                                       connections.

                                       MySQL:
                                        * Default: 3306, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1521, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1433, Valid values: 1150-65535 except
                                          1434 and 3389.

 -publicly_accessible                  Specifies the accessibility options for the DB instance. A
                                       value of true specifies an Internet-facing instance with a
                                       publicly resolvable DNS name, which resolves to a public IP
                                       address. A value of false specifies an internal instance with
                                       a DNS name that resolves to a private IP address.

                                       Default: The default behavior varies depending on whether a
                                       VPC has been requested or not. The following list shows the 
                                       default behavior in each case.
                                       * DefaultVPC:true
                                       * VPC:false

                                       If no DB subnet group has been specified as part of the
                                       request and the -publicly_accessible value has not been set,
                                       the DB instance will be publicly accessible. If a specific DB
                                       subnet group has been specified as part of the request and
                                       the PubliclyAccessible value has not been set, the DB
                                       instance will be private.

 -tags                                 hashref or arrayref of hashrefs containing Key/Value pairs

=cut

sub restore_db_instance_from_db_snapshot {
    my $self = shift;
    my %args = @_;
    $args{-db_instance_identifier} or 
        croak "restore_db_instance_from_db_snapshot(): -db_instance_identifier required argument missing";
    $args{-db_snapshot_identifier} or 
        croak "restore_db_instance_from_db_snapshot(): -db_snapshot_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(AutoMinorVersionUpgrade MultiAZ
                                                                PubliclyAccessible)],
                                        single_parm      => [qw(AvailabilityZone DBInstanceClass
                                                                DBInstanceIdentifier
                                                                DBName DBSnapshotIdentifier
                                                                DBSubnetGroupName Engine
                                                                Iops LicenseModel OptionGroupName
                                                                Port)],
                                        member_list_parm => 'Tags',
                                    });
    return $self->rds_call('RestoreDBInstanceFromDBSnapshot',@params);
}

=head2 $db_instance = $ec2->restore_db_instance_to_point_in_time(%args)

Restores a DB instance to an arbitrary point-in-time. Users can restore to any point in time before
the latestRestorableTime for up to backupRetentionPeriod days. The target database is created from
the source database with the same configuration as the original database except that the DB instance
is created with the default DB security group.

Required arguments:

 -source_db_instance_identifier      The identifier of the source DB instance from which to restore.
                                     Constraints: Must be the identifier of an existing DB Instance 

 -target_db_instance_identifier      The name of the new database instance to be created.
                                     Constraints:
                                     * Must contain from 1 to 63 alphanumeric characters or hyphens
                                     * First character must be a letter
                                     * Cannot end with a hyphen or contain two consecutive hyphens

Optional arguments:

 -auto_minor_version_upgrade           Indicates that minor engine upgrades will be applied
                                       automatically to the DB Instance during the maintenance
                                       window.  (Boolean).  Default: true

 -availability_zone                    The EC2 Availability Zone that the database instance will
                                       be created in.
                                       Default: A random, system-chosen Availability Zone in the
                                                endpoint's region.
                                       Constraint:  Cannot specify if -multi_az is true

 -db_instance_class                    The compute and memory capacity of the DB Instance.
                                       db.t1.micro | db.m1.small | db.m1.medium | db.m1.large |
                                       db.m1.xlarge | db.m2.xlarge |db.m2.2xlarge | db.m2.4xlarge

 -db_name                              The database name for the restored DB instance.
                                       NOTE: Does not apply to MySQL engine.

 -db_subnet_group_name                 A DB Subnet Group to associate with this DB Instance.
                                       If not specified, then it is a non-VPC DB instance.

 -engine                               The name of the database engine to be used for this
                                       instance.
                                       Default is that of source.
                                       Valid values:  MySQL | oracle-se1 | oracle-se | oracle-ee |
                                        sqlserver-ee | sqlserver-se | sqlserver-ex | sqlserver-web

 -iops                                 The amount of Provisioned IOPS initially allocated.
                                       Must be an integer greater than 1000

 -license_model                        License model information for this DB Instance.
                                       Valid values: license-included |
                                                     bring-your-own-license |
                                                     general-public-license

 -multi_az                             Specifies if the DB Instance is a Multi-AZ deployment.
                                       You cannot set the -availability_zone argument if the
                                       -multi_az argument is set to true.

 -option_group_name                    Indicates that the DB Instance should be associated
                                       with the specified option group.

 -port                                 The port number on which the database accepts
                                       connections.

                                       MySQL:
                                        * Default: 3306, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1521, Valid values: 1150-65535
                                       Oracle:
                                        * Default: 1433, Valid values: 1150-65535 except
                                          1434 and 3389.

 -publicly_accessible                  Specifies the accessibility options for the DB instance. A
                                       value of true specifies an Internet-facing instance with a
                                       publicly resolvable DNS name, which resolves to a public IP
                                       address. A value of false specifies an internal instance with
                                       a DNS name that resolves to a private IP address.

                                       Default: The default behavior varies depending on whether a
                                       VPC has been requested or not. The following list shows the 
                                       default behavior in each case.
                                       * DefaultVPC:true
                                       * VPC:false

                                       If no DB subnet group has been specified as part of the
                                       request and the -publicly_accessible value has not been set,
                                       the DB instance will be publicly accessible. If a specific DB
                                       subnet group has been specified as part of the request and
                                       the PubliclyAccessible value has not been set, the DB
                                       instance will be private.

 -restore_time                         The date and time to restore from.
                                       Valid Values: Value must be a UTC time
                                       Constraints:
                                       * Must be prior the latest restorable time for the DB
                                         instance
                                       * Cannot be specified if -use_latest_restorable_time
                                         parameter is true
                                       Example: 2009-09-07T23:45:00Z

 -tags                                 hashref or arrayref of hashrefs containing Key/Value pairs

 -use_latest_restorable_time           Specifies if the DB instance is restored from the latest
                                       backup time.
                                       Boolean, default is false.
                                       Constraints: Cannot be specified if -restore_time parameter
                                       is provided.

=cut

sub restore_db_instance_to_point_in_time {
    my $self = shift;
    my %args = @_;
    $args{-source_db_instance_identifier} or 
        croak "restore_db_instance_to_point_in_time(): -source_db_instance_identifier required argument missing";
    $args{-target_db_instance_identifier} or 
        croak "restore_db_instance_to_point_in_time(): -target_db_instance_identifier required argument missing";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        boolean_parm     => [qw(AutoMinorVersionUpgrade MultiAZ
                                                                PubliclyAccessible
                                                                UseLatestRestorableTime)],
                                        single_parm      => [qw(AvailabilityZone DBInstanceClass
                                                                DBName DBSubnetGroupName Engine
                                                                Iops OptionGroupName Port
                                                                RestoreTime
                                                                SourceDBInstanceIdentifier
                                                                TargetDBInstanceIdentifier)],
                                        member_list_parm => 'Tags',
                                    });
    return $self->rds_call('RestoreDBInstanceToPointInTime',@params);
}

=head2 $sg = $ec2->revoke_db_security_group_ingress(%args)

Revokes ingress from a DBSecurityGroup for previously authorized IP ranges or EC2 or VPC Security
Groups.

Required arguments:

 -db_security_group_name          The name of the DB Security Group to revoke authorization from.

Optional arguments:

 -cidrip                          The IP range to revoke.  Must be a valid CIDR range.
                                  Security group parameters cannot be specified if -cidrip is
                                  specified.

 -ec2_security_group_id           ID of the EC2 Security Group to revoke access from.
                                  For VPC DB security groups, this must be provided.

 -ec2_security_group_name         Name of the EC2 Security Group to revoke access from.

 -ec2_security_group_owner_id     AWS Account Number of the owner of the EC2 Security Group
                                  specified in the -ec2_security_group_name parameter.

Returns a L<VM::EC2::DB::SecurityGroup> object.

=cut

sub revoke_db_security_group_ingress {
    my $self = shift;
    my %args = @_;
    $args{-db_security_group_name} &&
        ($args{-cidrip} || $args{-ec2_security_group_id} || $args{-ec2_security_group_name}) or
        croak "revoke_db_security_group_ingress(): -db_security_group_name and one of -cidrip, -ec2_security_group_id, -ec2_security_group_name arguments required";
    ($args{-ec2_security_group_id} || $args{-ec2_security_group_name}) &&
     $args{-ec2_security_group_owner_id} or
        croak "revoke_db_security_group_ingress(): -ec2_security_group_owner_id required when -ec2_security_group_id or -ec2_security_group_name arguments specified";
    my @params = $VEP->format_parms(\%args,
                                    {
                                        single_parm      => [qw(CIDRIP DBSecurityGroupName
                                                                EC2SecurityGroupId
                                                                EC2SecurityGroupName
                                                                EC2SecurityGroupOwnerId)],
                                    });
    return $self->rds_call('RevokeDBSecurityGroupIngress',@params);
}

=head1 AUTHOR

Lance Kinley E<lt>lkinley@loyaltymethods.com<gt>.

Copyright (c) 2013 Loyalty Methods, Inc.

This package and its accompanying libraries is free software; you can
redistribute it and/or modify it under the terms of the GPL (either
version 1, or at your option, any later version) or the Artistic
License 2.0.  Refer to LICENSE for the full license text. In addition,
please see DISCLAIMER.txt for disclaimers of warranty.

=cut

1;