text:
"""
    house_sales_data()

Returns a dictionary `D` with the Sacramento house sales data
used in section 2.3 and chapter 13.
The 6 items in the dictionary are vectors of length 774, with data for
774 house sales.

* `D["price"]`:    selling price in 1000 dollars
* `D["area"]`:     area in 1000 square feet
* `D["beds"]`:     number of bedrooms
* `D["baths"]`:    number of bathrooms
* `D["condo"]`:    1 if a condo, 0 otherwise
* `D["location"]`: an integer between 1 and 4 indicating the location.
"""
function house_sales_data()
# 774 House sales in Sacramento area.
# Column 1: region (1--4) based on 5-digit ZIP code (see Table 13.4.)
# Column 2: number of bedrooms.
# Column 3: number of bathrooms.
# Column 4: house area in square feet.
# Column 5: 1 if a condo, 0 otherwise.
# Column 6: selling price in dollars.

X = [ 2   2   2    941   1     94905;
      2   3   2   1146   0     98937;
      2   3   2    909   0    100309;
      3   3   2   1289   0    106250;
      3   3   1   1020   0    107502;
      2   2   2   1022   0    108750;
      2   2   2   1134   1    110700;
      2   2   1    844   0    113263;
      2   2   1    795   1    116250;
      2   2   1    588   0    120000;
      2   3   2   1356   0    121630;
      2   3   2   1118   0    122000;
      3   4   2   1329   0    122682;
      2   4   2   1240   0    123000;
      2   3   2   1601   0    124100;
      2   3   2    901   0    125000;
      2   3   2   1088   0    126640;
      3   3   1    963   0    127281;
      3   3   2   1119   0    129000;
      2   4   2   1380   0    131200;
      3   3   2   1248   0    132000;
      3   2   2   1039   1    133000;
      2   3   2   1152   0    134555;
      2   3   2   1380   0    136500;
      2   3   2   1116   0    138750;
      3   2   2   1039   1    141000;
      3   3   2   1418   0    146250;
      2   3   2   1082   0    147308;
      3   4   2   1472   0    148750;
      3   4   2   1146   0    149593;
      2   1   1    760   1    150000;
      2   2   2   1304   1    152000;
      3   3   2   1207   0    154000;
      3   3   2   1056   0    156896;
      2   2   2   1043   0    161250;
      2   4   2   1587   0    161500;
      2   4   1   1120   0    164000;
      3   4   2   1580   0    165000;
      3   4   1   1955   0    166357;
      2   4   2   1656   0    166357;
      3   3   2   1477   0    168000;
      3   3   2   1188   0    170000;
      3   4   2   1590   0    173000;
      3   3   2   1463   0    174250;
      3   4   2   1714   0    174313;
      3   3   2   1185   0    178480;
      3   3   2   1406   0    178760;
      3   3   2   1172   0    181000;
      2   3   1   1152   0    181872;
      3   4   3   1851   0    182587;
      2   3   2   1215   0    182716;
      3   3   2   1130   0    182750;
      2   4   2   1603   0    183200;
      3   3   1   1479   0    188741;
      3   3   2   1420   0    189000;
      3   3   2   1280   0    192067;
      3   3   2   1586   0    194000;
      2   3   2   1362   0    194818;
      3   3   2   1266   0    198000;
      3   4   2   1715   0    199500;
      4   3   2   1820   0    200000;
      2   3   1    936   0    200000;
      2   3   2   1511   0    208000;
      3   4   2   1590   0    212864;
      3   4   2   1596   0    221000;
      2   2   2   1341   0    221000;
      3   5   3   2136   0    223058;
      3   4   2   1616   0    227887;
      3   3   2   1478   0    231477;
      2   3   2   1287   0    234697;
      2   4   2   1277   0    235000;
      2   4   2   1448   0    236000;
      3   4   3   2235   0    236685;
      2   3   2   2093   0    237800;
      2   3   2   1193   0    240122;
      3   3   2   2163   0    242638;
      3   3   2   1269   0    244000;
      3   3   1    958   0    244960;
      3   5   3   2508   0    245918;
      2   3   2   1305   0    250000;
      3   4   2   1591   0    250000;
      2   2   2   1326   1    250134;
      3   3   2   1843   0    254200;
      2   4   2   1921   0    254200;
      3   5   3   2790   0    258000;
      2   3   2   1541   0    260000;
      3   3   1   1018   0    260014;
      2   3   2   1672   1    265000;
      3   3   1    975   0    271742;
      3   4   3   2372   0    273750;
      3   3   2   1446   0    275086;
      3   4   3   3009   0    280987;
      3   4   2   2056   0    285000;
      3   4   2   1993   0    287417;
      3   3   2   1857   0    291000;
      1   2   1   1126   0    292024;
      3   5   3   2494   0    297000;
      3   3   2   1843   0    298000;
      2   2   2   1520   0    299000;
      2   5   3   2800   0    304037;
      3   4   2   2309   0    311000;
      2   5   3   2367   0    315537;
      2   5   4   3516   0    320000;
      3   4   3   1914   0    328360;
      2   2   1   1690   0    334150;
      3   3   3   2725   0    335750;
      3   4   3   2354   0    335750;
      4   3   2   2185   0    344250;
      3   4   2   1801   0    346210;
      3   3   3   1961   0    347029;
      3   4   2   3134   0    347650;
      3   4   3   1915   0    351300;
      2   4   3   2734   0    370500;
      3   3   2   2110   0    372000;
      3   5   3   3164   0    375000;
      2   5   3   3599   0    381300;
      3   4   2   2054   0    381942;
      2   4   2   1830   0    387731;
      1   3   3   1627   0    391000;
      3   4   3   3440   0    394470;
      4   3   2   2846   0    395000;
      3   4   3   2359   0    400186;
      3   3   3   2052   0    415000;
      3   5   3   3433   0    425000;
      2   5   3   3615   0    430000;
      4   5   3   2687   0    460000;
      3   4   3   2724   0    461000;
      3   4   3   3440   0    489332;
      3   5   4   3508   0    510000;
      4   4   2   2462   0    539000;
      2   3   3   2325   0    660000;
      2   2   1    795   1     69000;
      1   4   2   1099   0     70000;
      3   2   1    840   1     71000;
      2   2   1    800   0     78000;
      3   2   1    746   0     78400;
      3   3   1   1067   0     80000;
      2   4   2   1316   0     89000;
      2   3   1   1337   0     90000;
      3   2   1    868   0     90000;
      3   3   1    924   0     92000;
      3   2   1    610   0     93675;
      2   2   1   1220   0     98000;
      3   1   1    722   1     98000;
      2   3   1   1643   0     99000;
      3   1   1    722   1    100000;
      3   3   1   1080   0    106716;
      3   3   1   1039   0    111000;
      2   3   1   1051   0    111000;
      2   2   2    967   0    114800;
      2   3   1   1098   0    120108;
      3   3   1   1050   0    123225;
      2   3   2   1110   0    123750;
      2   3   1    888   0    125000;
      3   3   2   1120   0    125000;
      2   3   2   1080   0    126000;
      2   3   1    957   0    129000;
      2   2   1    952   0    134000;
      2   3   2   1211   0    135000;
      2   3   2   1264   0    135500;
      2   3   1   1080   0    140000;
      3   3   2   1266   0    140000;
      2   2   2    994   1    142500;
      2   3   2   1202   0    143500;
      3   2   1    722   0    145000;
      3   4   2   1448   0    145000;
      3   3   2   1188   0    145000;
      2   4   2   1183   0    146000;
      3   3   1   1320   0    148500;
      3   3   2   1117   0    149000;
      3   3   2   1364   0    150000;
      3   4   2   1310   0    150000;
      3   2   2   1006   0    152000;
      2   3   2   1104   0    156000;
      2   2   1    810   0    156000;
      3   2   2   1123   0    156000;
      2   2   1    904   0    157788;
      2   3   2   1156   0    161653;
      3   2   1   1321   0    161829;
      2   3   2   1392   0    165000;
      3   3   2   1439   0    168000;
      2   3   2   1159   0    169000;
      2   3   2   1671   0    175000;
      3   3   2   1740   0    176250;
      3   3   2   1265   0    179000;
      2   2   2   1007   0    180000;
      3   3   2   1716   0    180400;
      3   4   2   1685   0    182000;
      2   4   2   1829   0    184500;
      3   3   2   1555   0    185000;
      2   4   2   1120   0    189000;
      2   3   2   1137   0    194000;
      3   3   1   1174   0    195000;
      2   3   2   1393   0    200000;
      3   3   2   1289   0    205000;
      2   4   2   1799   0    205000;
      3   4   3   1953   0    205000;
      3   2   1    723   0    207000;
      2   4   2   1578   0    215000;
      2   3   2   1317   0    215000;
      3   3   1   1360   0    222381;
      2   3   2   1522   0    225000;
      2   4   2   1751   0    225000;
      3   3   2   1465   0    225000;
      3   4   2   1605   0    228000;
      2   4   2   1475   0    229665;
      4   3   1   1216   0    230000;
      2   2   2   1315   0    230000;
      3   3   2   1567   0    230000;
      2   3   2   1776   0    234000;
      2   3   2   2187   0    235000;
      3   3   1   1291   0    236250;
      2   3   2   1503   0    245000;
      3   4   3   2491   0    245000;
      1   2   1   1269   0    245000;
      2   3   2   1176   0    250000;
      2   4   2   1456   0    250000;
      4   3   2   1498   0    250000;
      2   3   2   1574   0    255000;
      3   3   2   2170   0    257729;
      3   4   2   1595   0    260000;
      2   3   2   1567   0    261000;
      3   4   2   1253   0    264469;
      2   4   3   1768   0    265000;
      2   4   3   2030   0    270000;
      2   3   2   1531   0    270000;
      3   4   3   1653   0    275000;
      3   4   2   2056   0    275000;
      3   4   3   2494   0    280000;
      2   3   2   1450   0    286013;
      2   4   2   2169   0    292000;
      4   3   2   1440   0    292000;
      2   3   2   1527   0    293993;
      4   3   2   1401   0    294000;
      2   3   2   1411   0    296769;
      2   3   1   1284   0    300000;
      3   4   3   2307   0    300000;
      2   4   2   1910   0    300500;
      2   3   2   1981   0    305000;
      3   4   2   2205   0    319789;
      4   2   2   1449   0    330000;
      4   3   2   1258   0    330000;
      3   3   2   2575   0    331000;
      3   2   1    539   0    334000;
      2   4   3   2208   0    336000;
      1   3   1   1108   0    339000;
      4   4   2   1595   0    339000;
      3   4   2   2159   0    345000;
      4   3   2   1838   0    356000;
      3   4   2   1900   0    361745;
      1   4   2   1718   0    361948;
      3   5   3   3389   0    370000;
      3   5   4   3260   0    385000;
      4   3   2   2016   0    399000;
      4   4   2   2607   0    402000;
      3   4   3   2724   0    406026;
      3   5   4   3746   0    420000;
      2   4   2   3192   0    425000;
      1   2   1   1247   0    445000;
      4   4   2   2581   0    450000;
      2   3   1   2068   0    460000;
      3   4   3   3992   0    460000;
      2   4   4   3397   0    465000;
      2   5   3   3881   0    471750;
      2   2   2   1598   0    484000;
      3   4   3   3070   0    495000;
      3   5   3   3984   0    572500;
      2   4   2   2222   0    582000;
      4   4   3   3838   0    613401;
      2   5   5   2846   0    680000;
      1   5   2   2484   0    699000;
      2   3   1    970   0     61500;
      1   2   1    623   0     62050;
      3   2   1    932   0     65000;
      2   2   1    796   0     65000;
      3   2   1    834   0     68000;
      3   2   1    834   0     68000;
      2   2   1    924   1     77000;
      2   2   1    795   1     82732;
      2   3   1   1250   0     84000;
      3   2   1    984   0     84675;
      3   3   1   1013   0     85000;
      3   3   1   1012   0     90000;
      3   2   1    795   1     90000;
      2   2   2    918   0     91000;
      2   3   1   1082   0     95000;
      2   2   1    964   0     97500;
      3   1   1    625   1    100000;
      2   2   1    888   0    101000;
      2   4   2   1120   0    102750;
      2   3   1   1331   0    112500;
      2   3   1   1014   0    113000;
      3   4   2   1448   0    114000;
      2   3   1    966   0    114000;
      3   2   1    779   0    114750;
      2   2   2    836   1    115000;
      4   2   2   1100   1    115000;
      3   3   1   1174   0    116100;
      2   3   2   1207   0    119250;
      3   2   1    804   0    120000;
      2   2   2    958   1    120000;
      3   3   2   1366   0    120108;
      3   2   2    901   0    121500;
      2   3   1    696   0    121725;
      3   3   2   1080   0    122000;
      3   3   2   1104   0    123000;
      2   2   1    972   0    125000;
      2   4   2   1390   0    125573;
      2   4   2   1354   0    126714;
      3   2   1    795   1    126960;
      4   2   1    780   1    127000;
      3   4   2   1587   0    127500;
      2   3   2   1209   0    130000;
      3   2   1   1139   0    133105;
      2   2   2   1690   0    136500;
      2   3   2   1245   1    139500;
      2   3   2   1416   0    140000;
      3   3   2   1300   0    140800;
      3   3   2   1120   0    145000;
      3   4   2   1590   0    147000;
      3   3   2   1407   0    149600;
      3   5   2   1516   0    150000;
      3   3   2   1646   0    150000;
      3   3   2   1676   0    155000;
      2   3   2   1370   0    155435;
      2   3   2   1370   0    155500;
      2   4   2   1351   0    158000;
      2   3   2   1152   0    158000;
      3   3   2   1452   0    160000;
      4   2   1    990   0    160000;
      2   2   2   1162   0    164000;
      2   3   2   1182   0    164000;
      3   2   2   1112   0    165000;
      3   3   2   1100   0    167000;
      2   4   2   1280   0    167293;
      2   4   2   1280   0    167293;
      3   3   1   1039   0    168000;
      2   3   2   1159   0    170000;
      2   4   2   1917   0    170000;
      2   3   2   1520   0    170000;
      3   3   2   1204   0    174000;
      2   3   2   1120   0    178000;
      3   3   2   1436   0    180000;
      3   3   2   1451   0    180000;
      3   4   2   1638   0    180000;
      2   2   2   1000   1    182000;
      4   3   1   1152   0    188325;
      4   3   2   1154   0    191500;
      2   3   2   1353   0    192000;
      2   3   2   1329   0    192700;
      3   3   1   1356   0    195000;
      2   3   2   1505   0    197654;
      2   3   1   1009   0    198000;
      3   3   2   1144   0    200345;
      2   2   1    930   0    203000;
      2   4   2   1766   0    207000;
      3   4   3   1940   0    208000;
      3   4   2   1776   0    210000;
      2   3   1   1258   0    212000;
      3   4   2   1872   0    213675;
      3   2   2   1112   0    213697;
      2   4   2   1856   0    215000;
      1   4   3   1939   0    215000;
      4   3   1    998   0    215100;
      4   3   2   1758   0    217500;
      2   3   2   2142   0    218000;
      3   2   1    950   0    220000;
      3   4   3   1739   0    221000;
      3   3   2   1516   0    222900;
      2   3   1    988   0    223139;
      3   4   2   1555   0    225500;
      3   3   2   1212   0    228327;
      2   4   2   1871   0    230000;
      3   3   2   1302   0    230000;
      2   2   1    756   1    230522;
      2   4   3   2026   0    231200;
      3   3   2   1375   0    232000;
      2   2   2   1250   1    232500;
      3   3   1   1058   0    233641;
      2   3   2   1187   0    234000;
      3   2   2   1324   0    234500;
      3   4   3   1936   0    235000;
      4   3   2   1427   0    236073;
      2   3   2   1678   1    238000;
      3   4   2   1798   0    238861;
      2   4   3   2652   0    239700;
      3   4   2   1816   0    240000;
      2   5   3   3076   0    240000;
      3   4   2   1844   0    241000;
      3   3   2   1306   0    245000;
      2   4   3   2447   0    246000;
      3   4   2   1176   0    247234;
      2   4   2   1182   0    247480;
      2   3   1   1160   0    249862;
      2   3   2   1424   0    251000;
      2   4   2   1574   0    252155;
      2   3   2   1830   0    254172;
      3   4   2   1724   0    258000;
      4   2   2   1255   1    260000;
      2   4   3   2175   0    261000;
      2   4   2   1904   0    261000;
      4   4   2   1808   0    262500;
      2   4   2   2711   0    266000;
      2   3   1   1713   0    266000;
      3   3   2   1457   0    270000;
      3   4   3   2724   0    274425;
      3   3   2   1468   0    275336;
      2   4   3   2550   0    277980;
      3   4   2   1928   0    280000;
      1   3   3   1922   0    284686;
      2   3   2   1343   0    284893;
      4   3   2   1510   0    285000;
      2   4   2   1559   0    285000;
      3   5   3   2992   0    295000;
      3   4   2   2109   0    296000;
      2   4   2   1524   0    296056;
      3   3   2   1248   0    297359;
      3   4   2   1876   0    299940;
      2   4   3   1851   0    305000;
      2   4   2   2218   0    311328;
      3   3   2   1394   0    313138;
      3   3   2   1410   0    316630;
      3   5   3   3468   0    320000;
      2   5   3   2346   0    320000;
      2   5   3   2347   0    325000;
      2   4   2   1659   0    328578;
      3   3   3   2442   0    331000;
      2   4   2   2155   0    340000;
      3   3   2   1810   0    345746;
      3   4   2   2789   0    351000;
      3   4   2   1606   0    353767;
      2   4   2   2166   0    356035;
      2   4   2   1871   0    360552;
      2   3   2   1800   0    362305;
      1   3   1   1683   0    365000;
      4   2   2   1596   0    370000;
      3   3   2   1179   0    378000;
      1   3   1   1639   0    388000;
      2   5   3   3281   0    395100;
      1   3   2   1697   0    400000;
      2   4   3   2085   0    408431;
      4   4   3   1939   0    423000;
      1   2   3   1788   0    427500;
      4   3   2   1691   0    430922;
      3   4   2   2002   0    445000;
      3   4   4   4303   0    450000;
      2   5   3   4246   0    452000;
      4   3   2   2274   0    470000;
      2   4   4   3056   0    475000;
      3   3   3   2503   0    484500;
      4   3   2   1905   0    500000;
      4   3   2   1320   0    506688;
      2   4   2   3037   0    528000;
      3   5   2   3741   0    579093;
      4   4   3   2660   0    636000;
      2   4   3   3357   0    668365;
      4   5   3   2896   0    676200;
      3   5   3   3788   0    691659;
      3   2   1    838   0     55422;
      2   2   1    904   0     63000;
      2   2   1   1032   0     65000;
      2   2   1    904   0     65000;
      1   2   1   1080   0     65000;
      3   2   2    990   0     66500;
      2   2   1    900   0     71000;
      3   2   1    861   0     75000;
      3   2   1    906   1     77000;
      2   2   1   1011   0     85000;
      3   3   2   1089   0     95625;
      2   2   1    832   0     96140;
      3   2   1    800   1    104250;
      2   4   2   1292   0    105000;
      3   2   1    810   0    108000;
      2   4   2   1064   0    109000;
      2   2   1    911   0    115000;
      2   1   1    846   1    115000;
      2   3   2   1320   0    115500;
      2   3   2   1410   0    115620;
      2   3   2   1115   0    116000;
      3   3   2   1169   0    122000;
      3   3   2   1164   0    122500;
      3   4   2   1341   0    123000;
      2   3   2   1219   0    124000;
      2   4   2   1127   0    124000;
      2   3   2   1272   0    124413;
      3   4   2   1253   0    125000;
      3   3   2   1120   0    130000;
      2   2   2   1118   0    131750;
      2   4   3   1890   0    137721;
      2   3   2   1260   0    137760;
      3   3   2   1400   0    138000;
      2   3   1   1264   0    140000;
      3   3   1   1060   0    145000;
      3   2   2   1132   0    145000;
      3   3   2   1466   0    150000;
      2   3   2   1092   0    150000;
      3   4   2   1628   0    151000;
      2   3   2    960   0    155000;
      2   3   2   1075   0    155800;
      3   3   2   1428   0    156142;
      3   4   2   1358   0    158000;
      2   3   2   1410   0    160000;
      2   3   2   1711   0    161500;
      3   4   2   1483   0    161600;
      3   3   2   1140   0    162000;
      3   4   2   1549   0    165000;
      3   3   2   1410   0    165000;
      3   3   2   1240   0    167293;
      2   5   2   1712   0    168000;
      3   4   2   1580   0    168000;
      2   3   2   1669   0    168750;
      3   3   1   1029   0    168750;
      2   3   1   1103   0    170000;
      3   3   2   2161   0    170250;
      3   3   2   1650   0    173000;
      3   3   2   1200   0    176095;
      2   3   2   1170   0    176250;
      2   3   2   1199   0    178000;
      3   4   2   1695   0    179000;
      2   3   2   1157   0    180000;
      2   3   2   1410   0    180000;
      4   3   2   1174   0    180000;
      3   3   2   1593   0    181000;
      2   3   2   1093   0    182000;
      4   3   2   1770   0    182587;
      3   4   2   1436   0    185074;
      3   3   2   1124   0    185833;
      3   4   2   1139   0    186785;
      3   3   2   1638   0    187000;
      2   3   2   1328   0    188335;
      3   3   2   1273   0    190000;
      2   3   1   1082   0    190000;
      2   4   2   1578   0    190000;
      4   2   1    796   0    190000;
      3   3   2   1386   0    191250;
      2   3   2   1452   0    193000;
      3   3   2   1513   0    193500;
      2   4   2   1578   0    195000;
      2   4   3   1736   0    195000;
      2   3   1   1473   0    195000;
      3   3   1   1150   0    198000;
      2   3   2   1127   0    199900;
      2   3   1   1144   0    200000;
      2   3   1    972   0    201000;
      3   4   2   2306   0    204918;
      2   3   2   1479   0    205000;
      2   3   2   1430   0    205878;
      3   4   2   1800   0    207000;
      2   4   2   1953   0    207744;
      2   3   2   1120   0    209000;
      2   3   2   1232   0    210000;
      2   1   1    984   1    210944;
      3   4   2   2329   0    213750;
      3   3   2   1351   0    215000;
      4   4   1   1376   0    215000;
      2   4   2   1566   0    220000;
      1   2   1   1115   0    220000;
      1   2   1   1032   0    220000;
      2   4   2   1419   0    220000;
      3   3   2   1261   0    220000;
      2   2   2   1637   0    220702;
      3   3   2   1338   0    222000;
      3   5   2   2254   0    222750;
      2   3   2   1441   0    225000;
      2   4   2   1991   0    225000;
      3   4   3   2126   0    228750;
      3   3   2   1094   0    229000;
      4   3   2   1462   0    230095;
      2   5   3   2258   0    232500;
      2   3   2   1074   0    233000;
      3   4   2   2111   0    233500;
      2   3   2   1686   0    239000;
      2   4   3   1915   0    240000;
      3   4   2   2367   0    240000;
      3   3   2   1962   0    240971;
      2   2   2   1406   0    242000;
      3   3   2   1789   0    243450;
      2   4   2   1876   0    243500;
      2   3   2   1235   0    246544;
      2   4   2   2504   0    246750;
      2   3   2   1676   0    247000;
      2   3   2   1367   0    249000;
      3   4   3   1899   0    249000;
      3   3   2   1636   0    250000;
      2   3   2   1828   0    250000;
      3   4   2   1438   0    252000;
      3   3   2   1451   0    255000;
      2   3   1   1520   0    255000;
      4   3   2   1506   0    255000;
      2   4   2   2605   0    257200;
      2   3   2   1196   0    260000;
      4   3   2   1621   0    260000;
      2   3   2   1811   0    263500;
      3   3   2   1540   0    266510;
      3   3   2   1543   0    275000;
      2   5   3   2494   0    276000;
      4   3   2   1650   0    276500;
      3   4   3   2214   0    278000;
      2   5   3   2280   0    279000;
      2   3   2   1443   0    280000;
      2   4   2   1582   0    280000;
      3   3   2   1857   0    285000;
      3   3   2   1735   0    288000;
      3   4   3   2096   0    289000;
      2   3   2   1720   0    290000;
      2   4   2   2160   0    290000;
      2   4   2   1382   0    293996;
      3   4   2   1721   0    294173;
      4   4   2   1328   0    295000;
      3   4   2   1982   0    298000;
      1   2   1   1144   0    299000;
      2   2   2   1623   0    300000;
      4   3   2   1457   0    300000;
      3   6   3   2555   0    300000;
      4   3   2   1577   0    300567;
      3   5   3   2592   0    303000;
      2   3   2   1401   0    305000;
      2   3   2   1502   0    310000;
      4   3   2   1327   0    310000;
      4   4   3   1800   0    310000;
      3   4   2   2169   0    311518;
      4   5   3   2457   0    312000;
      2   4   2   2004   0    315000;
      4   4   3   2212   0    315000;
      2   5   3   3134   0    315000;
      2   3   2   1360   0    315000;
      3   3   2   1276   0    320000;
      2   4   3   2962   0    322000;
      4   4   2   1888   0    325000;
      3   3   2   1548   0    328370;
      2   4   3   2109   0    330000;
      2   4   2   2484   0    331200;
      2   4   3   2258   0    332000;
      2   3   3   2212   0    334000;
      2   3   2   1616   0    335000;
      2   4   2   2372   0    341000;
      4   5   3   2606   0    346375;
      3   5   3   2877   0    349000;
      2   3   2   2960   0    350000;
      4   3   2   2172   0    350000;
      4   3   2   2100   1    350000;
      3   3   2   1795   0    351000;
      4   4   2   2295   0    360000;
      4   4   3   2577   0    367463;
      3   3   1   1727   0    380000;
      3   3   2   1485   0    380578;
      2   3   2   1655   0    386222;
      4   3   2   2049   0    395500;
      3   5   3   2875   0    397000;
      4   4   2   2199   0    400000;
      1   2   1   1304   0    413500;
      2   3   2   2334   0    415000;
      4   4   3   2278   0    420454;
      1   3   1   1493   0    425000;
      4   5   3   2787   0    441000;
      3   5   3   2824   0    445000;
      4   4   3   3261   0    446000;
      2   4   2   2053   0    450000;
      4   4   3   2379   0    455000;
      2   3   2   3173   0    525000;
      2   3   1   1348   0    545000;
      1   2   1   1252   0    575000;
      4   4   3   3229   0    575000;
      3   5   4   3863   0    598695;
      4   4   3   2356   0    600000;
      4   5   3   3579   0    610000;
      3   4   2   1512   0     56950;
      3   1   1    611   1     60000;
      3   2   1    876   0     61000;
      2   2   1    933   1     62000;
      3   2   1    864   0     68566;
      2   2   1   1011   0     70000;
      2   4   2   1158   0     80000;
      2   3   2   1092   0     85500;
      2   2   1    956   1     92000;
      3   2   2   1139   0     93600;
      3   3   1   1058   0     95000;
      2   3   2   1040   0     97750;
      3   3   2   1354   0    104000;
      2   3   1   1051   0    105000;
      2   1   1    682   1    107666;
      3   3   1   1161   0    109000;
      2   3   1   1004   0    110000;
      2   3   1   1229   0    110000;
      3   3   2   1249   0    112500;
      3   3   2   1161   0    114800;
      3   3   1   1010   0    116000;
      3   4   2   1462   0    121500;
      3   3   2   1269   0    122000;
      3   2   2   1188   0    123675;
      2   4   2   1570   0    126854;
      1   3   2   1093   0    127059;
      3   3   1    962   0    128687;
      3   3   2   1089   0    129500;
      3   3   2   1127   0    130000;
      3   4   2   1309   0    131750;
      2   2   1    970   0    132000;
      3   3   2   1144   0    134000;
      2   3   1   1000   0    134000;
      2   3   2   1206   0    142000;
      2   3   1   1285   0    143012;
      3   3   2   1543   0    145846;
      2   2   1    884   0    147000;
      1   3   1   1019   0    148750;
      3   4   2   1392   0    150000;
      2   2   1    924   1    150454;
      3   3   2   1217   0    151087;
      2   3   2   1670   0    157296;
      3   3   2   1302   0    157500;
      3   3   2   1488   0    160000;
      2   3   2   1373   0    160000;
      2   4   2   1381   0    161250;
      3   3   2   1265   0    164000;
      1   2   1    881   0    165000;
      3   4   2   1608   0    165750;
      2   3   1   1344   0    166000;
      2   3   2   1202   0    169000;
      4   3   2   1104   0    170000;
      3   3   2   1232   0    170000;
      3   3   1   1638   0    170725;
      3   2   2   1177   0    171750;
      2   3   2   1582   0    172000;
      3   2   2    904   0    173056;
      3   3   2   1340   0    174000;
      2   3   2   1204   0    174250;
      3   4   2   1477   0    176850;
      3   4   2   1497   0    179500;
      2   3   1    960   0    185000;
      2   3   2   1428   0    188700;
      3   3   1   1039   0    189000;
      2   3   1   1529   0    189000;
      2   4   3   1892   0    189836;
      2   4   2   1887   0    190000;
      2   3   2   1294   0    191250;
      3   3   2   1638   0    191675;
      3   3   2   1677   0    195500;
      2   3   1   1073   0    198000;
      2   3   2   1231   0    200000;
      3   3   2   1175   0    200000;
      3   3   2   1416   0    200000;
      2   3   2   1358   0    201528;
      3   4   2   1609   0    204750;
      2   4   3   1968   0    205000;
      1   2   2   1089   0    205000;
      2   3   2   1296   0    205900;
      3   2   2   1189   0    207000;
      2   2   1    795   0    207973;
      4   3   2   1371   0    208250;
      2   3   1   1310   0    208318;
      3   3   2   1262   0    209347;
      3   4   2   1740   0    211500;
      2   3   2   1517   0    212000;
      3   3   2   1450   0    213000;
      3   3   2   1416   0    216000;
      3   3   1    888   0    216021;
      2   3   2   1882   0    219000;
      3   3   2   1302   0    219794;
      3   3   2   1418   0    220000;
      2   4   2   1319   0    220000;
      3   4   2   1770   0    220000;
      2   4   2   1627   0    223000;
      2   3   1   1040   0    224000;
      2   3   1    960   0    224252;
      2   3   1   1456   0    225000;
      3   3   2   1450   0    228000;
      4   3   2   1358   0    229027;
      3   4   2   1329   0    229500;
      3   4   2   1715   0    230000;
      3   3   2   1262   0    230000;
      3   4   3   2280   0    232425;
      3   3   2   1477   0    234000;
      2   3   2   1216   0    235000;
      3   4   2   1685   0    235301;
      4   3   2   1362   0    235738 ];
    return Dict([
        ("price", X[:,6] / 1000),  # selling price in 1000 dollars
        ("area", X[:,4] / 1000),   # house area in 1000 square feet
        ("beds", X[:,2]),          # number of bedrooms
        ("baths", X[:,3]),         # number of bathrooms
        ("condo", X[:,5]),         # 1 if condo, 0 otherwise
        ("location", X[:,1])])     # location (1,2,3,4)
end

max_issues_repo_name: lynnlangit/julia-linear-algebra


text:
module AtlasSim

using LinearAlgebra
using RigidBodySim
using HumanoidLCMSim
using RigidBodyDynamics
using RigidBodyDynamics.Contact

import AtlasRobot

using LCMCore: LCM, publish
using DiffEqBase: CallbackSet, solve, init
using OrdinaryDiffEq: Tsit5
using MechanismGeometries: URDFVisuals
using Blink: Window

function atlasrobotinfo(mechanism::Mechanism)
    actuators = [Actuator(string(j), JointID(j)) for j in tree_joints(mechanism) if num_positions(j) == 1]
    feet = Dict(
        Sides.left => findbody(mechanism, "l_foot"),
        Sides.right => findbody(mechanism, "r_foot"))
    hands = Dict(
        Sides.left => findbody(mechanism, "l_hand"),
        Sides.right => findbody(mechanism, "r_hand"))
    HumanoidRobotInfo(mechanism, feet, hands, actuators)
end

function send_init_messages(state::MechanismState, receiver::LCMControlReceiver)
    HumanoidLCMSim.publish_robot_state(receiver, 0.0, state)
    utime = HumanoidLCMSim.utime_t()
    lcm = LCM()
    @info "Publishing START_MIT_STAND."
    publish(lcm, "START_MIT_STAND", utime)
    sleep(2)
    nothing
end

function make_callback(state::MechanismState, headless::Bool, max_rate; controls::Bool = true)
    callback = CallbackSet()
    if max_rate < Inf
        callback = CallbackSet(callback, RealtimeRateLimiter(max_rate = max_rate))
    end
    if headless
        if controls
            controls = SimulationControls()
            open(controls, Window())
            callback = CallbackSet(callback, CallbackSet(controls))
        end
    else
        visuals = URDFVisuals(AtlasRobot.urdfpath(); package_path = [AtlasRobot.packagepath()])
        gui = GUI(state.mechanism, visuals)
        open(gui)
        copyto!(gui.visualizer, state)
        callback = CallbackSet(callback, CallbackSet(gui))
    end
    callback
end

function simulate(dynamics::Dynamics, state0, final_time, callback)
    problem = ODEProblem(dynamics, state0, (0., final_time), callback = callback)
    integrator = init(problem, Tsit5(); abs_tol = 1e-8, dt = 1e-6, dtmin = 0.0)
    @info "Starting simulation."
    walltime = @elapsed solve!(integrator)
    integrator.sol, walltime
end

"""
    run(; controlΔt::Float64 = 1 / 300; headless = false)

Start a simulation of the Atlas robot, controlled using a `HumanoidLCMSim.LCMControlReceiver` running
at a rate of `1 / controlΔt` Hertz.

# Examples

Default usage:

```julia
using HumanoidLCMSim; AtlasSim.run()
```
"""
function run(; final_time = Inf, controlΔt::Float64 = 1 / 300, headless = false, max_rate = Inf, controls = true)
    BLAS.set_num_threads(max(floor(Int, Sys.CPU_THREADS / 2  - 1), 1)) # leave some cores for other processes
    mechanism = AtlasRobot.mechanism(add_flat_ground=true)
    info = atlasrobotinfo(mechanism)
    state0 = MechanismState(mechanism)
    AtlasRobot.setnominal!(state0)
    receiver = LCMControlReceiver(info;
        robot_state_channel="EST_ROBOT_STATE",
        robot_command_channel="ATLAS_COMMAND")
    pcontroller = PeriodicController(controlΔt, receiver)
    control! = let pcontroller = pcontroller
        function (τ, t, state)
            pcontroller(τ, t, state)
            # add some damping. TODO: do in a more appropriate place
            v = velocity(state)
            τ .-= 1.0 .* v
            τ
        end
    end
    send_init_messages(state0, receiver)
    callback = CallbackSet(make_callback(state0, headless, max_rate; controls = controls),
        PeriodicCallback(pcontroller))
    sol, walltime = simulate(Dynamics(mechanism, control!), state0, final_time, callback)
    simtime = sol.t[end]
    println("Simulated $simtime s in $walltime s ($(simtime / walltime) × realtime).")
    sol
end

end # module

ext: jl


text:
# # meets
#
#md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/generated/sketches/Partitions.ipynb)
#
# Our first example of a concept defined by a universal mapping property is a meet respectively meet.
#

# The first step is our Catlab imports
using Core: GeneratedFunctionStub
using Test

using Catlab, Catlab.Theories, Catlab.CategoricalAlgebra, Catlab.CategoricalAlgebra.FinSets
using Catlab.Present
using Catlab.Graphics
using Catlab.Graphics.Graphviz

import Catlab.Theories: compose
using DataStructures

# # Defining some basic preorders

@present P(FreeSchema) begin
  (a₁,a₂,a₃,a₄)::Ob
  f::Hom(a₁, a₂)
  g::Hom(a₁, a₃)
  h::Hom(a₂, a₄)
  k::Hom(a₃, a₄)
end

# We can draw a picture of our preorder as a Hasse Diagram.

to_graphviz(P)

# It will be convenient to program with our preorders based on the Hasse Diagram
# represent as a labeled graph so we convert the Presentation{Schema, Symbol} into a FreeDigram.
# FreeDiagrams are implemented as an ACSet which you can think of as an in-memory database.
# ACSets are a key feature of Catlab that allow you to represent many data structures in a
# common framework.

g = FreeDiagram(P)

# To give ourselves a graph-like API for Hasse Diagrams, we define parents and children.

parents(g, y::Int) = subpart(g, incident(g, y, :tgt), :src)
children(g, x::Int) = subpart(g, incident(g, x, :src), :tgt)

# We can compute upsets/downsets with breadth first search.

function bfs(g, x::Int, f=children)
  explored = falses(nparts(g, :V))
  explored[x] = 1
  q = Queue{Int}()
  enqueue!(q, x)
  while !isempty(q)
    v = dequeue!(q)
    S = f(g,v)
    map(filter(s -> !explored[s], S)) do s
      enqueue!(q, s)
    end
    explored[S] .= true
  end
  return findall(explored)
end

# The upset of a preorder element is all the elements that come after it in the preorder.

upset(g,x) = bfs(g,x,children)

# The downset is the dual notion, which we compute by reversing the role of children and parents.

downset(g,x) = bfs(g,x,parents)

upset(g, 1)

# We can use upsets to define the less than or equal two relation implied by any Hasse Diagram

function leq(g::FreeDiagram, x::Int, y::Int)
  return y in upset(g, x)
end

# ### Exercise 1
# Define a more efficient algorithm for checking whether two elements satisfy the leq relation.

# Multiple dispatch allows us to overload the leq function with another method for symbols.

function leq(g::FreeDiagram, x::Symbol, y::Symbol)
  leq(g, incident(g, x, :ob), incident(g, y, :ob))
end

# the meet of two elements is the largest element in the intersection of their downsets.

function meet(g::FreeDiagram, x::Int, y::Int)
  U = downset(g, x) ∩ downset(g,y)
  maxima(g, U)
  return maximum(g, U)
end

function meet(g::FreeDiagram, x, y)
  meet(g, incident(g, x, :ob)[1], incident(g, y, :ob)[1])
end

# assuming that D is a downset, the maxima are those elements whose children are disjoint from D.

function maxima(g::FreeDiagram, D::Vector{Int})
  X = Set(D)
  M = filter(D) do x
    Pₓ = children(g, x) ∩ X
    length(Pₓ) == 0
  end
  return M
end

function hastop(g::FreeDiagram, xs::Vector{Int})
  length(maxima(g, xs)) == 1
end

function maximum(g::FreeDiagram, xs::Vector{Int})
  m = maxima(g, xs::Vector{Int})
  if length(m) == 1
    return m[1]
  end
  if length(m) > 1
    all_iso = all(m) do a
      Uₐ = downset(g, a)
      a_le_allb = all(m) do b
        b in Uₐ
      end
      return a_le_allb
    end
    if all_iso
      return  m[1]
    end
  end
  return nothing
end

# From the definition of minimum, you can see that when you want to do many leq queries
# in sequence, you can reuse the upsets that you compute with bfs. This is a place where
# mathematical abstractions don't work well with the operational needs of computer programming.
# In a mathematical definition you can define x ≤ y as y ∈ upset(x), but in programming, that is
# inefficient when you want to check a property like for all y in Y, x ≤ y. Programming requires
# you to reason about not only the correctness of the code, but also the performance. Much of the
# complexity of software engineering comes from the fact that computational performance requires
# the programmers to break down their clean abstractions to optimize the code.

# ### Exercise 2
# If you wanted to perform many x ≤ y queries in a loop, you might want to
# precompute the matrix L where L[i,j] = 1 if and only if i ≤ j in the preorder P.
# Implement an algorithm that performs this computation in O(V⋅E) time where V is the number of
# elements in P and E is the number of edges in the corresponding FreeDiagram.

# ## Testing it out

# Let's make sure we get the answers that we expect.

using Test
@testset "Upsets" begin
  @test upset(g, 3) == [3,4]
  @test upset(g, 2) == [2,4]
  @test upset(g, 1) == [1,2,3,4]
  @test upset(g, 4) == [4]
end
@testset "Downsets" begin
  @test downset(g, 3) == [1,3]
  @test downset(g, 2) == [1,2]
  @test downset(g, 4) == [1,2,3,4]
  @test downset(g, 1) == [1]
end

@testset "Meets" begin
  @test meet(g, 2,3) == 1
  @test meet(g, 1,2) == 1
  @test meet(g, 3,4) == 3
  @test meet(g, 1, 4) == 1
  @test meet(g, 1, 1) == 1
  @test meet(g, 2, 2) == 2
end

# ## Another Example:

@present P(FreeSchema) begin
  (a₁,a₂,a₃,a₄, a₅)::Ob
  f::Hom(a₁, a₂)
  g::Hom(a₁, a₃)
  h::Hom(a₂, a₄)
  k::Hom(a₃, a₄)
  l::Hom(a₅, a₂)
end

# Which can be viewed as a picture:

to_graphviz(P)

# Or, as tables:

g = FreeDiagram(P)

# ### Test suite

@testset "meets2" begin
  @test meet(g, 2,3) == 1
  @test meet(g, 1,2) == 1
  @test meet(g, 3,4) == 3
  @test meet(g, 1, 4) == 1
  @test meet(g, 1, 1) == 1
  @test meet(g, 2, 2) == 2
  @test meet(g, 3, 5) == nothing
  @test meet(g, 2, 5) == 5
end

# ### Exercise 3
# Make bigger preorders to test corner cases in the above code.
# If you find an example that breaks these implementations, please report it.

# ### Exercise 4
# Implement the dual constructions for joins.


text:
#==============================================================================#
# STS.jl
#
# This file is generated from:
# https://github.com/aws/aws-sdk-js/blob/master/apis/sts-2011-06-15.normal.json
#==============================================================================#

__precompile__()

module STS

using AWSCore

"""
    using AWSSDK.STS.assume_role
    assume_role([::AWSConfig], arguments::Dict)
    assume_role([::AWSConfig]; RoleArn=, RoleSessionName=, <keyword arguments>)

    using AWSCore.Services.sts
    sts([::AWSConfig], "AssumeRole", arguments::Dict)
    sts([::AWSConfig], "AssumeRole", RoleArn=, RoleSessionName=, <keyword arguments>)

# AssumeRole Operation

Returns a set of temporary security credentials (consisting of an access key ID, a secret access key, and a security token) that you can use to access AWS resources that you might not normally have access to. Typically, you use `AssumeRole` for cross-account access or federation. For a comparison of `AssumeRole` with the other APIs that produce temporary credentials, see [Requesting Temporary Security Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) and [Comparing the AWS STS APIs](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#stsapi_comparison) in the *IAM User Guide*.

**Important:** You cannot call `AssumeRole` by using AWS root account credentials; access is denied. You must use credentials for an IAM user or an IAM role to call `AssumeRole`.

For cross-account access, imagine that you own multiple accounts and need to access resources in each account. You could create long-term credentials in each account to access those resources. However, managing all those credentials and remembering which one can access which account can be time consuming. Instead, you can create one set of long-term credentials in one account and then use temporary security credentials to access all the other accounts by assuming roles in those accounts. For more information about roles, see [IAM Roles (Delegation and Federation)](http://docs.aws.amazon.com/IAM/latest/UserGuide/roles-toplevel.html) in the *IAM User Guide*.

For federation, you can, for example, grant single sign-on access to the AWS Management Console. If you already have an identity and authentication system in your corporate network, you don't have to recreate user identities in AWS in order to grant those user identities access to AWS. Instead, after a user has been authenticated, you call `AssumeRole` (and specify the role with the appropriate permissions) to get temporary security credentials for that user. With those temporary security credentials, you construct a sign-in URL that users can use to access the console. For more information, see [Common Scenarios for Temporary Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html#sts-introduction) in the *IAM User Guide*.

By default, the temporary security credentials created by `AssumeRole` last for one hour. However, you can use the optional `DurationSeconds` parameter to specify the duration of your session. You can provide a value from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*. The maximum session duration limit applies when you use the `AssumeRole*` API operations or the `assume-role*` CLI operations but does not apply when you use those operations to create a console URL. For more information, see [Using IAM Roles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html) in the *IAM User Guide*.

The temporary security credentials created by `AssumeRole` can be used to make API calls to any AWS service with the following exception: you cannot call the STS service's `GetFederationToken` or `GetSessionToken` APIs.

Optionally, you can pass an IAM access policy to this operation. If you choose not to pass a policy, the temporary security credentials that are returned by the operation have the permissions that are defined in the access policy of the role that is being assumed. If you pass a policy to this operation, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, ***and*** the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see [Permissions for AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

To assume a role, your AWS account must be trusted by the role. The trust relationship is defined in the role's trust policy when the role is created. That trust policy states which accounts are allowed to delegate access to this account's role.

The user who wants to access the role must also have permissions delegated from the role's administrator. If the user is in a different account than the role, then the user's administrator must attach a policy that allows the user to call AssumeRole on the ARN of the role in the other account. If the user is in the same account as the role, then you can either attach a policy to the user (identical to the previous different account user), or you can add the user as a principal directly in the role's trust policy. In this case, the trust policy acts as the only resource-based policy in IAM, and users in the same account as the role do not need explicit permission to assume the role. For more information about trust policies and resource-based policies, see [IAM Policies](http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html) in the *IAM User Guide*.

**Using MFA with AssumeRole**

You can optionally include multi-factor authentication (MFA) information when you call `AssumeRole`. This is useful for cross-account scenarios in which you want to make sure that the user who is assuming the role has been authenticated using an AWS MFA device. In that scenario, the trust policy of the role being assumed includes a condition that tests for MFA authentication; if the caller does not include valid MFA information, the request to assume the role is denied. The condition in a trust policy that tests for MFA authentication might look like the following example.

`"Condition": {"Bool": {"aws:MultiFactorAuthPresent": true}}`

For more information, see [Configuring MFA-Protected API Access](http://docs.aws.amazon.com/IAM/latest/UserGuide/MFAProtectedAPI.html) in the *IAM User Guide* guide.

To use MFA with `AssumeRole`, you pass values for the `SerialNumber` and `TokenCode` parameters. The `SerialNumber` value identifies the user's hardware or virtual MFA device. The `TokenCode` is the time-based one-time password (TOTP) that the MFA devices produces.

# Arguments

## `RoleArn = ::String` -- *Required*
The Amazon Resource Name (ARN) of the role to assume.

## `RoleSessionName = ::String` -- *Required*
An identifier for the assumed role session.

Use the role session name to uniquely identify a session when the same role is assumed by different principals or for different reasons. In cross-account scenarios, the role session name is visible to, and can be logged by the account that owns the role. The role session name is also used in the ARN of the assumed role principal. This means that subsequent cross-account API requests using the temporary security credentials will expose the role session name to the external account in their CloudTrail logs.

The regex used to validate this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@-

## `Policy = ::String`
An IAM policy in JSON format.

This parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both (the intersection of) the access policy of the role that is being assumed, *and* the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see [Permissions for AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

The format for this parameter, as described by its regex pattern, is a string of characters up to 2048 characters in length. The characters can be any ASCII character from the space character to the end of the valid character list (\\u0020-\\u00FF). It can also include the tab (\\u0009), linefeed (\\u000A), and carriage return (\\u000D) characters.

**Note**
> The policy plain text must be 2048 bytes or shorter. However, an internal conversion compresses it into a packed binary format with a separate limit. The PackedPolicySize response element indicates by percentage how close to the upper size limit the policy is, with 100% equaling the maximum allowed size.

## `DurationSeconds = ::Int`
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. If you specify a value higher than this setting, the operation fails. For example, if you specify a session duration of 12 hours, but your administrator set the maximum session duration to 6 hours, your operation fails. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*.

By default, the value is set to 3600 seconds.

**Note**
> The `DurationSeconds` parameter is separate from the duration of a console session that you might request using the returned credentials. The request to the federation endpoint for a console sign-in token takes a `SessionDuration` parameter that specifies the maximum length of the console session. For more information, see [Creating a URL that Enables Federated Users to Access the AWS Management Console](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html) in the *IAM User Guide*.

## `ExternalId = ::String`
A unique identifier that is used by third parties when assuming roles in their customers' accounts. For each role that the third party can assume, they should instruct their customers to ensure the role's trust policy checks for the external ID that the third party generated. Each time the third party assumes the role, they should pass the customer's external ID. The external ID is useful in order to help third parties bind a role to the customer who created it. For more information about the external ID, see [How to Use an External ID When Granting Access to Your AWS Resources to a Third Party](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html) in the *IAM User Guide*.

The regex used to validated this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@:/-

## `SerialNumber = ::String`
The identification number of the MFA device that is associated with the user who is making the `AssumeRole` call. Specify this value if the trust policy of the role being assumed includes a condition that requires MFA authentication. The value is either the serial number for a hardware device (such as `GAHT12345678`) or an Amazon Resource Name (ARN) for a virtual device (such as `arn:aws:iam::123456789012:mfa/user`).

The regex used to validate this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@-

## `TokenCode = ::String`
The value provided by the MFA device, if the trust policy of the role being assumed requires MFA (that is, if the policy includes a condition that tests for MFA). If the role being assumed requires MFA and if the `TokenCode` value is missing or expired, the `AssumeRole` call returns an "access denied" error.

The format for this parameter, as described by its regex pattern, is a sequence of six numeric digits.

# Returns

`AssumeRoleResponse`

# Exceptions

`MalformedPolicyDocumentException`, `PackedPolicyTooLargeException` or `RegionDisabledException`.

# Example: To assume a role

Input:
```
[
    "DurationSeconds" => 3600,
    "ExternalId" => "123ABC",
    "Policy" => "{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}",
    "RoleArn" => "arn:aws:iam::123456789012:role/demo",
    "RoleSessionName" => "Bob"
]
```

Output:
```
Dict(
    "AssumedRoleUser" => Dict(
        "Arn" => "arn:aws:sts::123456789012:assumed-role/demo/Bob",
        "AssumedRoleId" => "ARO123EXAMPLE123:Bob"
    ),
    "Credentials" => Dict(
        "AccessKeyId" => "AKIAIOSFODNN7EXAMPLE",
        "Expiration" => "2011-07-15T23:28:33.359Z",
        "SecretAccessKey" => "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
        "SessionToken" => "AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA=="
    ),
    "PackedPolicySize" => 6
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/AssumeRole)
"""
@inline assume_role(aws::AWSConfig=default_aws_config(); args...) = assume_role(aws, args)

@inline assume_role(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "AssumeRole", args)

@inline assume_role(args) = assume_role(default_aws_config(), args)

"""
    using AWSSDK.STS.assume_role_with_saml
    assume_role_with_saml([::AWSConfig], arguments::Dict)
    assume_role_with_saml([::AWSConfig]; RoleArn=, PrincipalArn=, SAMLAssertion=, <keyword arguments>)

    using AWSCore.Services.sts
    sts([::AWSConfig], "AssumeRoleWithSAML", arguments::Dict)
    sts([::AWSConfig], "AssumeRoleWithSAML", RoleArn=, PrincipalArn=, SAMLAssertion=, <keyword arguments>)

# AssumeRoleWithSAML Operation

Returns a set of temporary security credentials for users who have been authenticated via a SAML authentication response. This operation provides a mechanism for tying an enterprise identity store or directory to role-based AWS access without user-specific credentials or configuration. For a comparison of `AssumeRoleWithSAML` with the other APIs that produce temporary credentials, see [Requesting Temporary Security Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) and [Comparing the AWS STS APIs](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#stsapi_comparison) in the *IAM User Guide*.

The temporary security credentials returned by this operation consist of an access key ID, a secret access key, and a security token. Applications can use these temporary security credentials to sign calls to AWS services.

By default, the temporary security credentials created by `AssumeRoleWithSAML` last for one hour. However, you can use the optional `DurationSeconds` parameter to specify the duration of your session. Your role session lasts for the duration that you specify, or until the time specified in the SAML authentication response's `SessionNotOnOrAfter` value, whichever is shorter. You can provide a `DurationSeconds` value from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*. The maximum session duration limit applies when you use the `AssumeRole*` API operations or the `assume-role*` CLI operations but does not apply when you use those operations to create a console URL. For more information, see [Using IAM Roles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html) in the *IAM User Guide*.

The temporary security credentials created by `AssumeRoleWithSAML` can be used to make API calls to any AWS service with the following exception: you cannot call the STS service's `GetFederationToken` or `GetSessionToken` APIs.

Optionally, you can pass an IAM access policy to this operation. If you choose not to pass a policy, the temporary security credentials that are returned by the operation have the permissions that are defined in the access policy of the role that is being assumed. If you pass a policy to this operation, the temporary security credentials that are returned by the operation have the permissions that are allowed by the intersection of both the access policy of the role that is being assumed, ***and*** the policy that you pass. This means that both policies must grant the permission for the action to be allowed. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see [Permissions for AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

Before your application can call `AssumeRoleWithSAML`, you must configure your SAML identity provider (IdP) to issue the claims required by AWS. Additionally, you must use AWS Identity and Access Management (IAM) to create a SAML provider entity in your AWS account that represents your identity provider, and create an IAM role that specifies this SAML provider in its trust policy.

Calling `AssumeRoleWithSAML` does not require the use of AWS security credentials. The identity of the caller is validated by using keys in the metadata document that is uploaded for the SAML provider entity for your identity provider.

**Important**
> Calling `AssumeRoleWithSAML` can result in an entry in your AWS CloudTrail logs. The entry includes the value in the `NameID` element of the SAML assertion. We recommend that you use a NameIDType that is not associated with any personally identifiable information (PII). For example, you could instead use the Persistent Identifier (`urn:oasis:names:tc:SAML:2.0:nameid-format:persistent`).

For more information, see the following resources:

*   [About SAML 2.0-based Federation](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html) in the *IAM User Guide*.

*   [Creating SAML Identity Providers](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html) in the *IAM User Guide*.

*   [Configuring a Relying Party and Claims](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml_relying-party.html) in the *IAM User Guide*.

*   [Creating a Role for SAML 2.0 Federation](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_saml.html) in the *IAM User Guide*.

# Arguments

## `RoleArn = ::String` -- *Required*
The Amazon Resource Name (ARN) of the role that the caller is assuming.

## `PrincipalArn = ::String` -- *Required*
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.

## `SAMLAssertion = ::String` -- *Required*
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see [Configuring a Relying Party and Adding Claims](http://docs.aws.amazon.com/IAM/latest/UserGuide/create-role-saml-IdP-tasks.html) in the *Using IAM* guide.

## `Policy = ::String`
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, ***and*** the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, [Permissions for AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

The format for this parameter, as described by its regex pattern, is a string of characters up to 2048 characters in length. The characters can be any ASCII character from the space character to the end of the valid character list (\\u0020-\\u00FF). It can also include the tab (\\u0009), linefeed (\\u000A), and carriage return (\\u000D) characters.

**Note**
> The policy plain text must be 2048 bytes or shorter. However, an internal conversion compresses it into a packed binary format with a separate limit. The PackedPolicySize response element indicates by percentage how close to the upper size limit the policy is, with 100% equaling the maximum allowed size.

## `DurationSeconds = ::Int`
The duration, in seconds, of the role session. Your role session lasts for the duration that you specify for the `DurationSeconds` parameter, or until the time specified in the SAML authentication response's `SessionNotOnOrAfter` value, whichever is shorter. You can provide a `DurationSeconds` value from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. If you specify a value higher than this setting, the operation fails. For example, if you specify a session duration of 12 hours, but your administrator set the maximum session duration to 6 hours, your operation fails. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*.

By default, the value is set to 3600 seconds.

**Note**
> The `DurationSeconds` parameter is separate from the duration of a console session that you might request using the returned credentials. The request to the federation endpoint for a console sign-in token takes a `SessionDuration` parameter that specifies the maximum length of the console session. For more information, see [Creating a URL that Enables Federated Users to Access the AWS Management Console](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html) in the *IAM User Guide*.

# Returns

`AssumeRoleWithSAMLResponse`

# Exceptions

`MalformedPolicyDocumentException`, `PackedPolicyTooLargeException`, `IDPRejectedClaimException`, `InvalidIdentityTokenException`, `ExpiredTokenException` or `RegionDisabledException`.

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/AssumeRoleWithSAML)
"""
@inline assume_role_with_saml(aws::AWSConfig=default_aws_config(); args...) = assume_role_with_saml(aws, args)

@inline assume_role_with_saml(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "AssumeRoleWithSAML", args)

@inline assume_role_with_saml(args) = assume_role_with_saml(default_aws_config(), args)

"""
    using AWSSDK.STS.assume_role_with_web_identity
    assume_role_with_web_identity([::AWSConfig], arguments::Dict)
    assume_role_with_web_identity([::AWSConfig]; RoleArn=, RoleSessionName=, WebIdentityToken=, <keyword arguments>)

    using AWSCore.Services.sts
    sts([::AWSConfig], "AssumeRoleWithWebIdentity", arguments::Dict)
    sts([::AWSConfig], "AssumeRoleWithWebIdentity", RoleArn=, RoleSessionName=, WebIdentityToken=, <keyword arguments>)

# AssumeRoleWithWebIdentity Operation

Returns a set of temporary security credentials for users who have been authenticated in a mobile or web application with a web identity provider, such as Amazon Cognito, Login with Amazon, Facebook, Google, or any OpenID Connect-compatible identity provider.

**Note**
> For mobile applications, we recommend that you use Amazon Cognito. You can use Amazon Cognito with the [AWS SDK for iOS](http://aws.amazon.com/sdkforios/) and the [AWS SDK for Android](http://aws.amazon.com/sdkforandroid/) to uniquely identify a user and supply the user with a consistent identity throughout the lifetime of an application.

To learn more about Amazon Cognito, see [Amazon Cognito Overview](http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/cognito-auth.html#d0e840) in the *AWS SDK for Android Developer Guide* guide and [Amazon Cognito Overview](http://docs.aws.amazon.com/mobile/sdkforios/developerguide/cognito-auth.html#d0e664) in the *AWS SDK for iOS Developer Guide*.

Calling `AssumeRoleWithWebIdentity` does not require the use of AWS security credentials. Therefore, you can distribute an application (for example, on mobile devices) that requests temporary security credentials without including long-term AWS credentials in the application, and without deploying server-based proxy services that use long-term AWS credentials. Instead, the identity of the caller is validated by using a token from the web identity provider. For a comparison of `AssumeRoleWithWebIdentity` with the other APIs that produce temporary credentials, see [Requesting Temporary Security Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) and [Comparing the AWS STS APIs](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#stsapi_comparison) in the *IAM User Guide*.

The temporary security credentials returned by this API consist of an access key ID, a secret access key, and a security token. Applications can use these temporary security credentials to sign calls to AWS service APIs.

By default, the temporary security credentials created by `AssumeRoleWithWebIdentity` last for one hour. However, you can use the optional `DurationSeconds` parameter to specify the duration of your session. You can provide a value from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*. The maximum session duration limit applies when you use the `AssumeRole*` API operations or the `assume-role*` CLI operations but does not apply when you use those operations to create a console URL. For more information, see [Using IAM Roles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html) in the *IAM User Guide*.

The temporary security credentials created by `AssumeRoleWithWebIdentity` can be used to make API calls to any AWS service with the following exception: you cannot call the STS service's `GetFederationToken` or `GetSessionToken` APIs.

Optionally, you can pass an IAM access policy to this operation. If you choose not to pass a policy, the temporary security credentials that are returned by the operation have the permissions that are defined in the access policy of the role that is being assumed. If you pass a policy to this operation, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, ***and*** the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see [Permissions for AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

Before your application can call `AssumeRoleWithWebIdentity`, you must have an identity token from a supported identity provider and create a role that the application can assume. The role that your application assumes must trust the identity provider that is associated with the identity token. In other words, the identity provider must be specified in the role's trust policy.

**Important**
> Calling `AssumeRoleWithWebIdentity` can result in an entry in your AWS CloudTrail logs. The entry includes the [Subject](http://openid.net/specs/openid-connect-core-1_0.html#Claims) of the provided Web Identity Token. We recommend that you avoid using any personally identifiable information (PII) in this field. For example, you could instead use a GUID or a pairwise identifier, as [suggested in the OIDC specification](http://openid.net/specs/openid-connect-core-1_0.html#SubjectIDTypes).

For more information about how to use web identity federation and the `AssumeRoleWithWebIdentity` API, see the following resources:

*   [Using Web Identity Federation APIs for Mobile Apps](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_oidc_manual.html) and [Federation Through a Web-based Identity Provider](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#api_assumerolewithwebidentity).

*   [Web Identity Federation Playground](https://web-identity-federation-playground.s3.amazonaws.com/index.html). This interactive website lets you walk through the process of authenticating via Login with Amazon, Facebook, or Google, getting temporary security credentials, and then using those credentials to make a request to AWS.

*   [AWS SDK for iOS](http://aws.amazon.com/sdkforios/) and [AWS SDK for Android](http://aws.amazon.com/sdkforandroid/). These toolkits contain sample apps that show how to invoke the identity providers, and then how to use the information from these providers to get and use temporary security credentials.

*   [Web Identity Federation with Mobile Applications](http://aws.amazon.com/articles/web-identity-federation-with-mobile-applications). This article discusses web identity federation and shows an example of how to use web identity federation to get access to content in Amazon S3.

# Arguments

## `RoleArn = ::String` -- *Required*
The Amazon Resource Name (ARN) of the role that the caller is assuming.

## `RoleSessionName = ::String` -- *Required*
An identifier for the assumed role session. Typically, you pass the name or identifier that is associated with the user who is using your application. That way, the temporary security credentials that your application will use are associated with that user. This session name is included as part of the ARN and assumed role ID in the `AssumedRoleUser` response element.

The regex used to validate this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@-

## `WebIdentityToken = ::String` -- *Required*
The OAuth 2.0 access token or OpenID Connect ID token that is provided by the identity provider. Your application must get this token by authenticating the user who is using your application with a web identity provider before the application makes an `AssumeRoleWithWebIdentity` call.

## `ProviderId = ::String`
The fully qualified host component of the domain name of the identity provider.

Specify this value only for OAuth 2.0 access tokens. Currently `www.amazon.com` and `graph.facebook.com` are the only supported identity providers for OAuth 2.0 access tokens. Do not include URL schemes and port numbers.

Do not specify this value for OpenID Connect ID tokens.

## `Policy = ::String`
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, ***and*** the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see [Permissions for AssumeRoleWithWebIdentity](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_assumerole.html) in the *IAM User Guide*.

The format for this parameter, as described by its regex pattern, is a string of characters up to 2048 characters in length. The characters can be any ASCII character from the space character to the end of the valid character list (\\u0020-\\u00FF). It can also include the tab (\\u0009), linefeed (\\u000A), and carriage return (\\u000D) characters.

**Note**
> The policy plain text must be 2048 bytes or shorter. However, an internal conversion compresses it into a packed binary format with a separate limit. The PackedPolicySize response element indicates by percentage how close to the upper size limit the policy is, with 100% equaling the maximum allowed size.

## `DurationSeconds = ::Int`
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. If you specify a value higher than this setting, the operation fails. For example, if you specify a session duration of 12 hours, but your administrator set the maximum session duration to 6 hours, your operation fails. To learn how to view the maximum value for your role, see [View the Maximum Session Duration Setting for a Role](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html#id_roles_use_view-role-max-session) in the *IAM User Guide*.

By default, the value is set to 3600 seconds.

**Note**
> The `DurationSeconds` parameter is separate from the duration of a console session that you might request using the returned credentials. The request to the federation endpoint for a console sign-in token takes a `SessionDuration` parameter that specifies the maximum length of the console session. For more information, see [Creating a URL that Enables Federated Users to Access the AWS Management Console](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html) in the *IAM User Guide*.

# Returns

`AssumeRoleWithWebIdentityResponse`

# Exceptions

`MalformedPolicyDocumentException`, `PackedPolicyTooLargeException`, `IDPRejectedClaimException`, `IDPCommunicationErrorException`, `InvalidIdentityTokenException`, `ExpiredTokenException` or `RegionDisabledException`.

# Example: To assume a role as an OpenID Connect-federated user

Input:
```
[
    "DurationSeconds" => 3600,
    "ProviderId" => "www.amazon.com",
    "RoleArn" => "arn:aws:iam::123456789012:role/FederatedWebIdentityRole",
    "RoleSessionName" => "app1",
    "WebIdentityToken" => "Atza%7CIQEBLjAsAhRFiXuWpUXuRvQ9PZL3GMFcYevydwIUFAHZwXZXXXXXXXXJnrulxKDHwy87oGKPznh0D6bEQZTSCzyoCtL_8S07pLpr0zMbn6w1lfVZKNTBdDansFBmtGnIsIapjI6xKR02Yc_2bQ8LZbUXSGm6Ry6_BG7PrtLZtj_dfCTj92xNGed-CrKqjG7nPBjNIL016GGvuS5gSvPRUxWES3VYfm1wl7WTI7jn-Pcb6M-buCgHhFOzTQxod27L9CqnOLio7N3gZAGpsp6n1-AJBOCJckcyXe2c6uD0srOJeZlKUm2eTDVMf8IehDVI0r1QOnTV6KzzAI3OY87Vd_cVMQ"
]
```

Output:
```
Dict(
    "AssumedRoleUser" => Dict(
        "Arn" => "arn:aws:sts::123456789012:assumed-role/FederatedWebIdentityRole/app1",
        "AssumedRoleId" => "AROACLKWSDQRAOEXAMPLE:app1"
    ),
    "Audience" => "client.5498841531868486423.1548@apps.example.com",
    "Credentials" => Dict(
        "AccessKeyId" => "AKIAIOSFODNN7EXAMPLE",
        "Expiration" => "2014-10-24T23:00:23Z",
        "SecretAccessKey" => "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
        "SessionToken" => "AQoDYXdzEE0a8ANXXXXXXXXNO1ewxE5TijQyp+IEXAMPLE"
    ),
    "PackedPolicySize" => 123,
    "Provider" => "www.amazon.com",
    "SubjectFromWebIdentityToken" => "amzn1.account.AF6RHO7KZU5XRVQJGXK6HEXAMPLE"
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/AssumeRoleWithWebIdentity)
"""
@inline assume_role_with_web_identity(aws::AWSConfig=default_aws_config(); args...) = assume_role_with_web_identity(aws, args)

@inline assume_role_with_web_identity(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "AssumeRoleWithWebIdentity", args)

@inline assume_role_with_web_identity(args) = assume_role_with_web_identity(default_aws_config(), args)

"""
    using AWSSDK.STS.decode_authorization_message
    decode_authorization_message([::AWSConfig], arguments::Dict)
    decode_authorization_message([::AWSConfig]; EncodedMessage=)

    using AWSCore.Services.sts
    sts([::AWSConfig], "DecodeAuthorizationMessage", arguments::Dict)
    sts([::AWSConfig], "DecodeAuthorizationMessage", EncodedMessage=)

# DecodeAuthorizationMessage Operation

Decodes additional information about the authorization status of a request from an encoded message returned in response to an AWS request.

For example, if a user is not authorized to perform an action that he or she has requested, the request returns a `Client.UnauthorizedOperation` response (an HTTP 403 response). Some AWS actions additionally return an encoded message that can provide details about this authorization failure.

**Note**
> Only certain AWS actions return an encoded authorization message. The documentation for an individual action indicates whether that action returns an encoded message in addition to returning an HTTP code.

The message is encoded because the details of the authorization status can constitute privileged information that the user who requested the action should not see. To decode an authorization status message, a user must be granted permissions via an IAM policy to request the `DecodeAuthorizationMessage` (`sts:DecodeAuthorizationMessage`) action.

The decoded message includes the following type of information:

*   Whether the request was denied due to an explicit deny or due to the absence of an explicit allow. For more information, see [Determining Whether a Request is Allowed or Denied](http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html#policy-eval-denyallow) in the *IAM User Guide*.

*   The principal who made the request.

*   The requested action.

*   The requested resource.

*   The values of condition keys in the context of the user's request.

# Arguments

## `EncodedMessage = ::String` -- *Required*
The encoded message that was returned with the response.

# Returns

`DecodeAuthorizationMessageResponse`

# Exceptions

`InvalidAuthorizationMessageException`.

# Example: To decode information about an authorization status of a request

Input:
```
[
    "EncodedMessage" => "<encoded-message>"
]
```

Output:
```
Dict(
    "DecodedMessage" => "{"allowed": "false","explicitDeny": "false","matchedStatements": "","failures": "","context": {"principal": {"id": "AIDACKCEVSQ6C2EXAMPLE","name": "Bob","arn": "arn:aws:iam::123456789012:user/Bob"},"action": "ec2:StopInstances","resource": "arn:aws:ec2:us-east-1:123456789012:instance/i-dd01c9bd","conditions": [{"item": {"key": "ec2:Tenancy","values": ["default"]},{"item": {"key": "ec2:ResourceTag/elasticbeanstalk:environment-name","values": ["Default-Environment"]}},(Additional items ...)]}}"
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/DecodeAuthorizationMessage)
"""
@inline decode_authorization_message(aws::AWSConfig=default_aws_config(); args...) = decode_authorization_message(aws, args)

@inline decode_authorization_message(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "DecodeAuthorizationMessage", args)

@inline decode_authorization_message(args) = decode_authorization_message(default_aws_config(), args)

"""
    using AWSSDK.STS.get_caller_identity
    get_caller_identity([::AWSConfig], arguments::Dict)
    get_caller_identity([::AWSConfig]; )

    using AWSCore.Services.sts
    sts([::AWSConfig], "GetCallerIdentity", arguments::Dict)
    sts([::AWSConfig], "GetCallerIdentity", )

# GetCallerIdentity Operation

Returns details about the IAM identity whose credentials are used to call the API.

# Arguments

# Returns

`GetCallerIdentityResponse`

# Example: To get details about a calling IAM user

This example shows a request and response made with the credentials for a user named Alice in the AWS account 123456789012.

Input:
```
[

]
```

Output:
```
Dict(
    "Account" => "123456789012",
    "Arn" => "arn:aws:iam::123456789012:user/Alice",
    "UserId" => "AKIAI44QH8DHBEXAMPLE"
)
```

# Example: To get details about a calling user federated with AssumeRole

This example shows a request and response made with temporary credentials created by AssumeRole. The name of the assumed role is my-role-name, and the RoleSessionName is set to my-role-session-name.

Input:
```
[

]
```

Output:
```
Dict(
    "Account" => "123456789012",
    "Arn" => "arn:aws:sts::123456789012:assumed-role/my-role-name/my-role-session-name",
    "UserId" => "AKIAI44QH8DHBEXAMPLE:my-role-session-name"
)
```

# Example: To get details about a calling user federated with GetFederationToken

This example shows a request and response made with temporary credentials created by using GetFederationToken. The Name parameter is set to my-federated-user-name.

Input:
```
[

]
```

Output:
```
Dict(
    "Account" => "123456789012",
    "Arn" => "arn:aws:sts::123456789012:federated-user/my-federated-user-name",
    "UserId" => "123456789012:my-federated-user-name"
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/GetCallerIdentity)
"""
@inline get_caller_identity(aws::AWSConfig=default_aws_config(); args...) = get_caller_identity(aws, args)

@inline get_caller_identity(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "GetCallerIdentity", args)

@inline get_caller_identity(args) = get_caller_identity(default_aws_config(), args)

"""
    using AWSSDK.STS.get_federation_token
    get_federation_token([::AWSConfig], arguments::Dict)
    get_federation_token([::AWSConfig]; Name=, <keyword arguments>)

    using AWSCore.Services.sts
    sts([::AWSConfig], "GetFederationToken", arguments::Dict)
    sts([::AWSConfig], "GetFederationToken", Name=, <keyword arguments>)

# GetFederationToken Operation

Returns a set of temporary security credentials (consisting of an access key ID, a secret access key, and a security token) for a federated user. A typical use is in a proxy application that gets temporary security credentials on behalf of distributed applications inside a corporate network. Because you must call the `GetFederationToken` action using the long-term security credentials of an IAM user, this call is appropriate in contexts where those credentials can be safely stored, usually in a server-based application. For a comparison of `GetFederationToken` with the other APIs that produce temporary credentials, see [Requesting Temporary Security Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) and [Comparing the AWS STS APIs](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#stsapi_comparison) in the *IAM User Guide*.

**Note**
> If you are creating a mobile-based or browser-based app that can authenticate users using a web identity provider like Login with Amazon, Facebook, Google, or an OpenID Connect-compatible identity provider, we recommend that you use [Amazon Cognito](http://aws.amazon.com/cognito/) or `AssumeRoleWithWebIdentity`. For more information, see [Federation Through a Web-based Identity Provider](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#api_assumerolewithwebidentity).

The `GetFederationToken` action must be called by using the long-term AWS security credentials of an IAM user. You can also call `GetFederationToken` using the security credentials of an AWS root account, but we do not recommended it. Instead, we recommend that you create an IAM user for the purpose of the proxy application and then attach a policy to the IAM user that limits federated users to only the actions and resources that they need access to. For more information, see [IAM Best Practices](http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) in the *IAM User Guide*.

The temporary security credentials that are obtained by using the long-term credentials of an IAM user are valid for the specified duration, from 900 seconds (15 minutes) up to a maximium of 129600 seconds (36 hours). The default is 43200 seconds (12 hours). Temporary credentials that are obtained by using AWS root account credentials have a maximum duration of 3600 seconds (1 hour).

The temporary security credentials created by `GetFederationToken` can be used to make API calls to any AWS service with the following exceptions:

*   You cannot use these credentials to call any IAM APIs.

*   You cannot call any STS APIs except `GetCallerIdentity`.

**Permissions**

The permissions for the temporary security credentials returned by `GetFederationToken` are determined by a combination of the following:

*   The policy or policies that are attached to the IAM user whose credentials are used to call `GetFederationToken`.

*   The policy that is passed as a parameter in the call.

The passed policy is attached to the temporary security credentials that result from the `GetFederationToken` API call--that is, to the *federated user*. When the federated user makes an AWS request, AWS evaluates the policy attached to the federated user in combination with the policy or policies attached to the IAM user whose credentials were used to call `GetFederationToken`. AWS allows the federated user's request only when both the federated user ***and*** the IAM user are explicitly allowed to perform the requested action. The passed policy cannot grant more permissions than those that are defined in the IAM user policy.

A typical use case is that the permissions of the IAM user whose credentials are used to call `GetFederationToken` are designed to allow access to all the actions and resources that any federated user will need. Then, for individual users, you pass a policy to the operation that scopes down the permissions to a level that's appropriate to that individual user, using a policy that allows only a subset of permissions that are granted to the IAM user.

If you do not pass a policy, the resulting temporary security credentials have no effective permissions. The only exception is when the temporary security credentials are used to access a resource that has a resource-based policy that specifically allows the federated user to access the resource.

For more information about how permissions work, see [Permissions for GetFederationToken](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_getfederationtoken.html). For information about using `GetFederationToken` to create temporary security credentials, see [GetFederationToken—Federation Through a Custom Identity Broker](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#api_getfederationtoken).

# Arguments

## `Name = ::String` -- *Required*
The name of the federated user. The name is used as an identifier for the temporary security credentials (such as `Bob`). For example, you can reference the federated user name in a resource-based policy, such as in an Amazon S3 bucket policy.

The regex used to validate this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@-

## `Policy = ::String`
An IAM policy in JSON format that is passed with the `GetFederationToken` call and evaluated along with the policy or policies that are attached to the IAM user whose credentials are used to call `GetFederationToken`. The passed policy is used to scope down the permissions that are available to the IAM user, by allowing only a subset of the permissions that are granted to the IAM user. The passed policy cannot grant more permissions than those granted to the IAM user. The final permissions for the federated user are the most restrictive set based on the intersection of the passed policy and the IAM user policy.

If you do not pass a policy, the resulting temporary security credentials have no effective permissions. The only exception is when the temporary security credentials are used to access a resource that has a resource-based policy that specifically allows the federated user to access the resource.

The format for this parameter, as described by its regex pattern, is a string of characters up to 2048 characters in length. The characters can be any ASCII character from the space character to the end of the valid character list (\\u0020-\\u00FF). It can also include the tab (\\u0009), linefeed (\\u000A), and carriage return (\\u000D) characters.

**Note**
> The policy plain text must be 2048 bytes or shorter. However, an internal conversion compresses it into a packed binary format with a separate limit. The PackedPolicySize response element indicates by percentage how close to the upper size limit the policy is, with 100% equaling the maximum allowed size.

For more information about how permissions work, see [Permissions for GetFederationToken](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_getfederationtoken.html).

## `DurationSeconds = ::Int`
The duration, in seconds, that the session should last. Acceptable durations for federation sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions obtained using AWS account (root) credentials are restricted to a maximum of 3600 seconds (one hour). If the specified duration is longer than one hour, the session obtained by using AWS account (root) credentials defaults to one hour.

# Returns

`GetFederationTokenResponse`

# Exceptions

`MalformedPolicyDocumentException`, `PackedPolicyTooLargeException` or `RegionDisabledException`.

# Example: To get temporary credentials for a role by using GetFederationToken

Input:
```
[
    "DurationSeconds" => 3600,
    "Name" => "Bob",
    "Policy" => "{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"*"}]}"
]
```

Output:
```
Dict(
    "Credentials" => Dict(
        "AccessKeyId" => "AKIAIOSFODNN7EXAMPLE",
        "Expiration" => "2011-07-15T23:28:33.359Z",
        "SecretAccessKey" => "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
        "SessionToken" => "AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA=="
    ),
    "FederatedUser" => Dict(
        "Arn" => "arn:aws:sts::123456789012:federated-user/Bob",
        "FederatedUserId" => "123456789012:Bob"
    ),
    "PackedPolicySize" => 6
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/GetFederationToken)
"""
@inline get_federation_token(aws::AWSConfig=default_aws_config(); args...) = get_federation_token(aws, args)

@inline get_federation_token(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "GetFederationToken", args)

@inline get_federation_token(args) = get_federation_token(default_aws_config(), args)

"""
    using AWSSDK.STS.get_session_token
    get_session_token([::AWSConfig], arguments::Dict)
    get_session_token([::AWSConfig]; <keyword arguments>)

    using AWSCore.Services.sts
    sts([::AWSConfig], "GetSessionToken", arguments::Dict)
    sts([::AWSConfig], "GetSessionToken", <keyword arguments>)

# GetSessionToken Operation

Returns a set of temporary credentials for an AWS account or IAM user. The credentials consist of an access key ID, a secret access key, and a security token. Typically, you use `GetSessionToken` if you want to use MFA to protect programmatic calls to specific AWS APIs like Amazon EC2 `StopInstances`. MFA-enabled IAM users would need to call `GetSessionToken` and submit an MFA code that is associated with their MFA device. Using the temporary security credentials that are returned from the call, IAM users can then make programmatic calls to APIs that require MFA authentication. If you do not supply a correct MFA code, then the API returns an access denied error. For a comparison of `GetSessionToken` with the other APIs that produce temporary credentials, see [Requesting Temporary Security Credentials](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) and [Comparing the AWS STS APIs](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#stsapi_comparison) in the *IAM User Guide*.

The `GetSessionToken` action must be called by using the long-term AWS security credentials of the AWS account or an IAM user. Credentials that are created by IAM users are valid for the duration that you specify, from 900 seconds (15 minutes) up to a maximum of 129600 seconds (36 hours), with a default of 43200 seconds (12 hours); credentials that are created by using account credentials can range from 900 seconds (15 minutes) up to a maximum of 3600 seconds (1 hour), with a default of 1 hour.

The temporary security credentials created by `GetSessionToken` can be used to make API calls to any AWS service with the following exceptions:

*   You cannot call any IAM APIs unless MFA authentication information is included in the request.

*   You cannot call any STS API *except* `AssumeRole` or `GetCallerIdentity`.

**Note**
> We recommend that you do not call `GetSessionToken` with root account credentials. Instead, follow our [best practices](http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#create-iam-users) by creating one or more IAM users, giving them the necessary permissions, and using IAM users for everyday interaction with AWS.

The permissions associated with the temporary security credentials returned by `GetSessionToken` are based on the permissions associated with account or IAM user whose credentials are used to call the action. If `GetSessionToken` is called using root account credentials, the temporary credentials have root account permissions. Similarly, if `GetSessionToken` is called using the credentials of an IAM user, the temporary credentials have the same permissions as the IAM user.

For more information about using `GetSessionToken` to create temporary credentials, go to [Temporary Credentials for Users in Untrusted Environments](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html#api_getsessiontoken) in the *IAM User Guide*.

# Arguments

## `DurationSeconds = ::Int`
The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

## `SerialNumber = ::String`
The identification number of the MFA device that is associated with the IAM user who is making the `GetSessionToken` call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as `GAHT12345678`) or an Amazon Resource Name (ARN) for a virtual device (such as `arn:aws:iam::123456789012:mfa/user`). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

The regex used to validated this parameter is a string of characters consisting of upper- and lower-case alphanumeric characters with no spaces. You can also include underscores or any of the following characters: =,.@:/-

## `TokenCode = ::String`
The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

The format for this parameter, as described by its regex pattern, is a sequence of six numeric digits.

# Returns

`GetSessionTokenResponse`

# Exceptions

`RegionDisabledException`.

# Example: To get temporary credentials for an IAM user or an AWS account

Input:
```
[
    "DurationSeconds" => 3600,
    "SerialNumber" => "YourMFASerialNumber",
    "TokenCode" => "123456"
]
```

Output:
```
Dict(
    "Credentials" => Dict(
        "AccessKeyId" => "AKIAIOSFODNN7EXAMPLE",
        "Expiration" => "2011-07-11T19:55:29.611Z",
        "SecretAccessKey" => "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
        "SessionToken" => "AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE"
    )
)
```

See also: [AWS API Documentation](https://docs.aws.amazon.com/goto/WebAPI/sts-2011-06-15/GetSessionToken)
"""
@inline get_session_token(aws::AWSConfig=default_aws_config(); args...) = get_session_token(aws, args)

@inline get_session_token(aws::AWSConfig, args) = AWSCore.Services.sts(aws, "GetSessionToken", args)

@inline get_session_token(args) = get_session_token(default_aws_config(), args)

end # module STS

#==============================================================================#
# End of file
#==============================================================================#