v0.3.0 (refactor for httpipe)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6abbb09..2e30c1f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,10 +12,14 @@
- Reduce depency base - use `:hackney` only
- remove `Cloud.Cloudstorage` module and place all functions in `Cloud` module ***(breaking change)***
- change naming of various modules to reduce length ***(breaking change)***
+- change the docs to reflect the move to [httpipe](https://hex.pm/packages/httpipe)
+- with the use of [httpipe](https://hex.pm/packages/httpipe), the abstraction changes from `Query` to `Request` -
+this is essentially a name change only.
[enhancements]
-- Reduce the types of `Query` to simply one query type. Having two types makes for unecessary complexity. Removes
-`ExOvh.Query` and only have `ExOvh.HttpQuery`.
+- Use [httpipe](https://hex.pm/packages/httpipe) and the corresponding hackney adapter.
+- Remove the abstractions based on `Query` and `HTTPQuery` and in it's place use a similar abstraction
+in the third party library [httpipe](https://hex.pm/packages/httpipe)
## v0.2
diff --git a/README.md b/README.md
index b3c1642..ece4ed2 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,8 @@ To use the Openstack components of the OVH API, see [Openstex](https://github.co
#### Project Features
- ***A Supervised agent*** running in the background which stores frequently accessed authentication information.
-- ***Query*** modules for making building requests to the [Ovh Api](https://api.ovh.com/).
-- ***Request*** functions to send Queries to the [Ovh Api](https://api.ovh.com/).
+- ***Helper*** modules for making building requests to the [Ovh Api](https://api.ovh.com/).
+- ***Request*** functions to send requests to the [Ovh Api](https://api.ovh.com/).
#### Getting started - Step 1: Generating the OVH `application key`, `application secret` and `consumer key`.
@@ -37,12 +37,9 @@ functions of the ***ex_ovh*** `API`.
- `GET /me/api/application/#{app_id}`
```
app_id = "0"
-%ExOvh.Query{
- headers: [],
+req = %HTTPipe.Request{
method: :get,
- params: %{},
- service: :ovh,
- uri: "/me/api/application/#{app_id}"
+ url: "/me/api/application/#{app_id}"
}
|> MyApp.OvhClient.request!()
```
@@ -50,28 +47,22 @@ app_id = "0"
- `GET /cloud/project/{serviceName}/storage`
```
service_name = "service_name"
-%ExOvh.Query{
- headers: [],
+req = %HTTPipe.Request{
method: :get,
- params: %{},
- service: :ovh,
- uri: "/cloud/project/#{service_name}/storage"
-}
+ url: "/cloud/project/#{service_name}/storage"
+}s
|> MyApp.OvhClient.request!()
```
-#### Examples - Method 2 - Build the query using provided helper functions and send the request
+#### Examples - Method 2 - Build the request using provided helper functions and send the request
-***Note:*** The Helper functions are listed under `Services`. Helper functions are only available currently for the
-`/Cloud` portion of the OVH API. Where other parts of the api need to be queried, just build the query manually
-using *Method 1* as above. Pull requests for helper functions for other parts of the OVH API are welcome.
+***Note:*** Helper functions are only available currently for the `/Cloud` portion of the OVH API.
*Eventually, I would like to write a macro to create the queries.*
- `GET /cloud/project/{serviceName}/storage`
```
-alias ExOvh.Query.V1.Cloud.Cloudstorage
-Cloudstorage.Query.get_containers(service_name) |> ExOvh.request!()
+ExOvh.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
```
- For more information [See Hex Docs](https://hexdocs.pm/ex_ovh/0.2/api-reference.html)
@@ -92,7 +83,7 @@ Cloudstorage.Query.get_containers(service_name) |> ExOvh.request!()
- [ ] Tests for OVH portion of library
- [ ] Option to set the application ttl when running ovh mix task.
- [ ] Add queries for the remainder of the OVH API. (~~Webstorage CDN~~ (now a deprecated service) and Cloud are the only ones covered so far)
-- [ ] Basic examples to be added to readme of usage of the api.
+- [x] Basic examples to be added to readme of usage of the api.
- [ ] Add macro for building queries.
- [ ] Write the usage guide - more examples of using the API.
diff --git a/config/config.exs b/config/config.exs
index a8c4e27..ddf2fe8 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -15,5 +15,4 @@ end
unless Mix.env == :test do
import_config "#{Mix.env}.exs"
-end
-
+end
\ No newline at end of file
diff --git a/config/dev.exs b/config/dev.exs
index 6febbee..ce04a66 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -12,8 +12,8 @@ config :ex_ovh,
],
hackney: [
connect_timeout: 20000,
- receive_timeout: 180000
+ recv_timeout: 180000
]
- config :httpipe,
- :adapter, HTTPipe.Adapters.Hackney
+#config :httpipe,
+# :adapter, HTTPipe.Adapters.Hackney
diff --git a/docs/getting_started.md b/docs/getting_started.md
index 7f88a8c..926cdf0 100644
--- a/docs/getting_started.md
+++ b/docs/getting_started.md
@@ -72,9 +72,9 @@ export MY_APP_OVH_CLIENT_CONSUMER_KEY="<application_consumer_key>"
endpoint: "ovh-eu",
api_version: "1.0"
],
- httpoison: [ # optional
+ hackney: [ # optional
connect_timeout: 20000,
- receive_timeout: 100000
+ recv_timeout: 100000
]
```
@@ -131,14 +131,20 @@ end
- `GET /me`
```
-%ExOvh.Query{headers: [], method: :get, params: %{}, service: :ovh, uri: "/me"} \
+req = %HTTPipe.Request{
+ method: :get,
+ url: "/me"
+}
|> MyApp.OvhClient.request!()
```
- `GET /me/api/application`
```
-%ExOvh.Query{headers: [], method: :get, params: %{}, service: :ovh, uri: "/me/api/application"} \
+req = %HTTPipe.Request{
+ method: :get,
+ url: "/me/api/application"
+}
|> MyApp.OvhClient.request!()
```
@@ -146,31 +152,40 @@ end
```
app_id = "0"
-%ExOvh.Query{headers: [], method: :get, params: %{}, service: :ovh, uri: "/me/api/application/#{app_id}"} \
+req = %HTTPipe.Request{
+ method: :get,
+ url: "/me/api/application/#{app_id}"
+}
|> MyApp.OvhClient.request!()
```
- `GET /cloud/project/{serviceName}/storage`
```
-service_name = "service_name" \
-%ExOvh.Query{headers: [], method: :get, params: %{}, service: :ovh, uri: "/cloud/project/#{service_name}/storage"} \
-MyApp.OvhClient.request!()
+service_name = "service_name"
+req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/storage"
+}
+|> MyApp.OvhClient.request!()
```
-#### Examples - Method 2 - Build the query using provided helper functions and sending the request
+#### Examples - Method 2 - Build the request using provided helper functions and sending the request
-***Note:*** The Helper functions are listed under `Services`. Helper functions are only available currently for the
-`/Cloud` portion of the OVH API. Where other parts of the api need to be queried, just build the query manually
-using *Method 1* as above. Pull requests for helper functions for other parts of the OVH API are welcome.
+***Note:*** Helper functions are only available currently for the `/Cloud` portion of the OVH API.
*Eventually, I would like to write a macro to create the queries.*
+- `GET /cloud/project`
+
+```
+ExOvh.V1.Cloud.list_services() |> ExOvh.request!()
+```
+
- `GET /cloud/project/{serviceName}/storage`
```
-ExOvh.Query.V1.Cloud.Cloudstorage.Query.get_containers(service_name) \
-|> ExOvh.request!()
+ExOvh.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
```
diff --git a/docs/mix_task.md b/docs/mix_task.md
index d9ede9f..cf94673 100644
--- a/docs/mix_task.md
+++ b/docs/mix_task.md
@@ -21,10 +21,7 @@ version control.
**Shell input:**
```shell
-mix ovh \
---login=<username-ovh> \
---password=<password> \
---appname='ex_ovh'
+mix ovh --login=<username-ovh> --password=<password> --appname='my_app_name'
```
- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
diff --git a/docs/usage.md b/docs/usage.md
index 63501fa..df95b22 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -1,5 +1,7 @@
## Examples using the OVH api
+## TODO
+
#### Examples (1) - Building queries manually
diff --git a/lib/ex_ovh/client.ex b/lib/ex_ovh/client.ex
index 217c41f..ea2beeb 100644
--- a/lib/ex_ovh/client.ex
+++ b/lib/ex_ovh/client.ex
@@ -29,8 +29,8 @@ defmodule ExOvh.Client do
## Example using the `ExOvh` client
- %ExOvh.Query{ method: :get, uri: "/me", params: %{}} |> ExOvh.request!()
- %ExOvh.Query{ method: :get, uri: "/cloud/project", params: %{}} |> ExOvh.request!()
+ %HTTPipe.Request{ method: :get, url: "/me", params: %{}} |> ExOvh.request!()
+ %HTTPipe.Request{ method: :get, url: "/cloud/project", params: %{}} |> ExOvh.request!()
## Example (2): Setting up an additional `MyApp.MyClient` client.
@@ -57,10 +57,9 @@ defmodule ExOvh.Client do
## Example using the `MyApp.MyClient` client
- %ExOvh.Query{ method: :get, uri: "/me", params: %{}} |> MyApp.MyClient.request!()
- %ExOvh.Query{ method: :get, uri: "/cloud/project", params: %{}} |> MyApp.MyClient.request!()
+ %HTTPipe.Request{ method: :get, url: "/me", params: %{}} |> MyApp.MyClient.request!()
+ %ExOvh.Query{ method: :get, url: "/cloud/project", params: %{}} |> MyApp.MyClient.request!()
"""
- alias ExOvh.{HttpQuery, Response}
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
@@ -70,7 +69,7 @@ defmodule ExOvh.Client do
`ExOvh` is the default client. Additional clients such as `MyApp.MyClient.Ovh` can be created - see `PAGES`.
"""
- alias ExOvh.{Defaults, HttpQuery, Request, Response, ResponseError}
+ alias ExOvh.{Defaults, ResponseError}
@behaviour ExOvh.Client
# public callback functions
@@ -98,19 +97,19 @@ defmodule ExOvh.Client do
@spec hackney_opts() :: Keyword.t
def hackney_opts(), do: config() |> Keyword.fetch!(:hackney)
- @doc "Sends a request to the ovh api using [httpoison](https://hex.pm/packages/httpoison)."
- @spec request(HttpQuery.t) :: {:ok, Response.t} | {:error, Response.t}
- def request(query) do
+ @doc "Sends a request to the ovh api using [httpipe](https://hex.pm/packages/httpipe)."
+ @spec request(HTTPipe.Conn.t) :: {:ok, HTTPipe.Conn.t} | {:error, HTTPipe.Conn.t}
+ def request(conn) do
client = unquote(opts) |> Keyword.fetch!(:client)
- Request.request(query, client)
+ ExOvh.Request.request(conn, client)
end
- @doc "Sends a request to the ovh api using [httpoison](https://hex.pm/packages/httpoison)."
- @spec request!(HttpQuery.t) :: Response.t | no_return
- def request!(query) do
- case request(query) do
- {:ok, resp} -> resp
- {:error, resp} -> raise(ResponseError, response: resp, query: query)
+ @doc "Sends a request to the ovh api using [httpipe](https://hex.pm/packages/httpipe)."
+ @spec request!(HTTPipe.Conn.t) :: HTTPipe.Conn.t | no_return
+ def request!(conn) do
+ case request(conn) do
+ {:ok, conn} -> conn
+ {:error, conn} -> raise(ResponseError, conn: conn)
end
end
@@ -129,7 +128,7 @@ defmodule ExOvh.Client do
@callback config() :: Keyword.t
@callback ovh_config() :: Keyword.t
@callback hackney_opts() :: Keyword.t
- @callback request(query :: HttpQuery.t) :: {:ok, Response.t} | {:error, Response.t}
- @callback request!(query :: HttpQuery.t) :: Response.t | no_return
+ @callback request(conn :: HTTPipe.Conn.t) :: {:ok, HTTPipe.Conn.t} | {:error, HTTPipe.Conn.t}
+ @callback request!(conn :: HTTPipe.Conn.t) :: HTTPipe.Conn.t | no_return
end
\ No newline at end of file
diff --git a/lib/ex_ovh/config.ex b/lib/ex_ovh/config.ex
index 89304a8..5fd6ceb 100644
--- a/lib/ex_ovh/config.ex
+++ b/lib/ex_ovh/config.ex
@@ -5,8 +5,8 @@ defmodule ExOvh.Config do
@doc "Starts an agent for the storage of credentials in memory"
def start_agent(client, opts) do
- Og.context(__ENV__, :debug)
- otp_app = Keyword.get(opts, :otp_app, :false) || Og.log_return(__ENV__, :error) |> raise()
+ Og.log("***logging context***", __ENV__, :debug)
+ otp_app = Keyword.get(opts, :otp_app, :false) || Og.log_r(__ENV__, :error) |> raise()
Agent.start_link(fn -> config(client, otp_app) end, name: agent_name(client))
end
@@ -26,7 +26,7 @@ defmodule ExOvh.Config do
end
end
- @doc "Gets the httpoison config.exs environment variables"
+ @doc "Gets the hackney config.exs environment variables"
def get_ovh_config_from_env(client, otp_app) do
try do
get_config_from_env(client, otp_app) |> Keyword.fetch!(:ovh)
@@ -38,18 +38,18 @@ defmodule ExOvh.Config do
end
end)
rescue
- _error -> Og.log_return("No ovh_config was found. ", __ENV__, :warn) |> raise()
+ _error -> Og.log_r("No ovh_config was found. ", __ENV__, :warn) |> raise()
end
end
- @doc "Gets the httpoison config.exs environment variables"
+ @doc "Gets the hackney config.exs environment variables"
def get_hackney_opts_from_env(client, otp_app) do
try do
get_config_from_env(client, otp_app) |> Keyword.fetch!(:hackney)
rescue
_error ->
- Og.log_return("No hackney_opts was found. " <>
- "Falling back to default httpoison settings #{inspect(@default_hackney_opts)}", __ENV__, :warn)
+ Og.log_r("No hackney_opts was found. " <>
+ "Falling back to default hackney settings #{inspect(@default_hackney_opts)}", __ENV__, :warn)
@default_hackney_opts
end
end
@@ -85,7 +85,7 @@ defmodule ExOvh.Config do
[
ovh: ovh_config,
- httpoison:
+ hackney:
[
timeout: connect_timeout,
recv_timeout: recv_timeout,
@@ -106,12 +106,21 @@ defmodule ExOvh.Config do
defp api_time_request(client, otp_app) do
ovh_config = get_ovh_config_from_env(client, otp_app)
method = :get
- uri = ovh_config[:endpoint] <> ovh_config[:api_version] <> "/auth/time"
+ url = ovh_config[:endpoint] <> ovh_config[:api_version] <> "/auth/time"
body = ""
headers = [{"Content-Type", "application/json; charset=utf-8"}]
options = get_hackney_opts_from_env(client, otp_app)
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- Poison.decode!(resp.body)
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers,
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+ Poison.decode!(conn.response.body)
end
end
diff --git a/lib/ex_ovh/http_query.ex b/lib/ex_ovh/http_query.ex
deleted file mode 100644
index 9ac1ad4..0000000
--- a/lib/ex_ovh/http_query.ex
+++ /dev/null
@@ -1,12 +0,0 @@
-defmodule ExOvh.HttpQuery do
- @moduledoc false
- defstruct [method: :nil, uri: :nil, body: "", headers: [], hackney_options: [], completed_transformations: []]
- @type t :: %__MODULE__{
- method: atom,
- uri: String.t,
- body: :binary | {:file, :binary},
- headers: [{binary, binary}],
- hackney_options: Keyword.t,
- completed_transformations: []
- }
-end
diff --git a/lib/ex_ovh/query/v1/cloud.ex b/lib/ex_ovh/query/v1/cloud.ex
deleted file mode 100644
index cb45652..0000000
--- a/lib/ex_ovh/query/v1/cloud.ex
+++ /dev/null
@@ -1,948 +0,0 @@
-defmodule ExOvh.Query.V1.Cloud do
- @moduledoc ~s"""
- Helper functions for building queries directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
-
- See `ExOvh.Query.V1.Cloud` for generic cloud requests.
-
- ## Functions Summary
-
- | Function | Description | OVH API call |
- |---|---|---|
- | `list_services/0` | <small>List available services or list available cloud projects. A returned project id in OVH terms is similar to a tenant id in swift terms</small> | <sub><sup>GET /cloud/project</sup></sub> |
- | `get_users/1` | <small>Get all users</small> | <sub><sup>GET /cloud/project/{serviceName}/user</sup></sub> |
- | `create_user/2` | <small>Create user</small> | <sub><sup>POST /ctsloud/project/{serviceName}/user</sup></sub> |
- | `get_user_details/2` | <small>Get user details. Returns the user_id and username and other details.</small> | <sub><sup>GET /cloud/project/{serviceName}/user/{userId}</sup></sub> |
- | `delete_user/2` | <small>Delete user</small> | <sub><sup>DELETE /cloud/project/{serviceName}/user/{userId}</sup></sub> |
- | `download_openrc_script/3` | <small>Get RC file of OpenStack</small> | <sub><sup>GET /cloud/project/{serviceName}/user/{userId}/openrc</sup></sub> |
- | `regenerate_credentials/2` | <small>Regenerate user credentials including password</small> | <sub><sup>POST /cloud/project/{serviceName}/user/{userId}/regeneratePassword</sup></sub> |
- | `swift_identity/3` | <small>Gets a json object similar to that returned by Keystone Identity. Includes the 'X-Auth-Token'</small> | <sub><sup>POST /cloud/project/{serviceName}/user/{userId}/token</sup></sub> |
- | `create_project/2` | <small>Start a new cloud project in the OVH cloud. Corresponds to creating a new Swift stack with a new tenant_id.</small> | <sub><sup>POST /cloud/createProject</sup></sub> |
- | `get_prices/2` | <small>Get Prices for OVH cloud services.</small> | <sub><sup>GET /cloud/price</sup></sub> |
- | `project_info/1` | <small>Get information about a project with the project_id (tenant_id)</small> | <sub><sup>GET /cloud/project/{serviceName}</sup></sub> |
- | `modify_project/2` | <small>Modify a project properties. Change the project description.</small> | <sub><sup>PUT /cloud/project/{serviceName}</sup></sub> |
- | `project_administrative_info/1` | <small>Get administration information about the project.</small> | <sub><sup>GET /cloud/project/{serviceName}/serviceInfos</sup></sub> |
- | `project_quotas/1` | <small>Get project quotas.</small> | <sub><sup>GET /cloud/project/{serviceName}/quota</sup></sub> |
- | `project_regions/1` | <small>Get project regions.</small> | <sub><sup>GET /cloud/project/{serviceName}/region</sup></sub> |
- | `project_region_info/2` | <small>Get details about a project region.</small> | <sub><sup>GET /cloud/project/{serviceName}/region/{regionName}</sup></sub> |
- | `project_consumption/3` | <small>Get details about a project consumption for a given `date_from` and `date_to`.</small> | <sub><sup>GET /cloud/project/{serviceName}/consumption</sup></sub> |
- | `project_bills/3` | <small>Get details about a project billing for a given `date_from` and `date_to`..</small> | <sub><sup>GET /cloud/project/{serviceName}/bill</sup></sub> |
- | `create_project_alert/4` | <small>Add a new project alert</small> | <sub><sup>POST /cloud/project/{serviceName}/alerting</sup></sub> |
- | `get_project_alert_info/2` | <small>Get detailed information about a project alert.</small> | <sub><sup>GET /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
- | `modify_project_alert/5` | <small>Modify an existing project alert.</small> | <sub><sup>PUT /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
- | `delete_project_alert/2` | <small>Delete an existing project alert.</small> | <sub><sup>DELETE /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
- | `terminate_service/2` | <small>Terminate a cloud project.</small> | <sub><sup>POST /cloud/project/{serviceName}/terminate</sup></sub> |
- | `get_containers/1` | <small>Get containers for a given swift tenant id (project id or ovh service name)</small> | <sub><sup>GET /cloud/project/{serviceName}/storage </sup></sub> |
- | `create_container/3` | <small>Create a container for a given tenant_id (ovh service_name), a container and a region.</small> | <sub><sup>POST /cloud/project/{serviceName}/storage</sup></sub> |
- | `get_access/1` | <small>Get access details for the Swift API for a given swift tenant_id (ovh service_name)</small> | <sub><sup>GET /cloud/project/{serviceName}/storage/access</sup></sub> |
- | `container_info/2` | <small>Gets details about a container such as objects, size, region, public or not, static_url, name, ...</small> | <sub><sup>GET /cloud/project/{serviceName}/storage/{containerId}</sup></sub> |
- | `delete_container/2` | <small>Deletes a given container.</small> | <sub><sup>DELETE /cloud/project/{serviceName}/storage/{containerId}</sup></sub> |
- | `modify_container_cors/3` | <small>Modify the CORS settings for a container. See [swift docs](http://docs.openstack.org/developer/swift/cors.html)</small> | <sub><sup>POST /cloud/project/{serviceName}/storage/{containerId}/cors Add CORS support on your container</sup></sub> |
- | `deploy_container_as_static_website/2` | <small>Deploy the container files as a static web site.</small> | <sub><sup>POST /cloud/project/{serviceName}/storage/{containerId}/static</sup></sub> |
-
- ## Notes
-
- - `service_name` or `serviceName` corresponds to the Openstack `tenant_id`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
- """
- alias ExOvh.HttpQuery
- alias ExOvh.Transformation.{Body, Uri}
-
-
- @doc ~s"""
- Get storage containers
-
- ## Api call
-
- GET /cloud/project/{serviceName}/storage
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
- """
- @spec get_containers(String.t) :: HttpQuery.t
- def get_containers(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/storage",
- }
- end
-
-
- @doc ~s"""
- Create container
-
- ## Api call
-
- POST /cloud/project/{serviceName}/storage
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
- - `container_name`: name for the new container
- - `region`: region for the new container, defaults to "SBG1". See regions by running:
- Currently can choose from "GRA1", "BHS1", "SBG1".
-
-
- ## Example
-
- ExOvh.Query.V1.Cloud.create_container(service_name, "test_container") |> ExOvh.request!()
- """
- @spec create_container(String.t, String.t, String.t) :: HttpQuery.t
- def create_container(service_name, container_name, region \\ "SBG1") do
- # POST /cloud/project/{serviceName}/storage Create container
- body =
- %{
- "containerName" => container_name,
- "region" => region
- }
- |> Poison.encode!()
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/storage"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Gets the x_auth_token and the swift endpoints for a given tenant_id (ovh service_name). A different endpoint is returned
- depending on the region. Examples of regions include "BHS1", "SBG1", "GRA1". With these details, requests can be made through
- the Swift api.
-
- ## Api call
-
- GET /cloud/project/{serviceName}/storage/access
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_access(service_name) |> ExOvh.request!()
- """
- @spec get_access(String.t) :: HttpQuery.t
- def get_access(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/storage/access"
- }
- end
-
-
-
- @doc ~s"""
- Gets the details for a given container.
-
- Returns information such as a list of objects in the container, size of the container, whether the container is public
- or not, the region of the container, the name of the container, the number of stored objects for the container and the
- static url for the container.
-
- ## Api call
-
- GET /cloud/project/{serviceName}/storage/{containerId}
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
- - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.container_info(service_name, container_id) |> ExOvh.request!()
- """
- @spec container_info(String.t, String.t) :: HttpQuery.t
- def container_info(service_name, container_id) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/storage/#{container_id}"
- }
- end
-
-
- @doc ~s"""
- Deletes a given container.
-
- *Note:* container_d is not the same as container_name.
-
- ## Api call
-
- DELETE /cloud/project/{serviceName}/storage/{containerId}
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
- - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.delete_container(service_name, container_id) |> ExOvh.request!()
- """
- @spec delete_container(String.t, String.t) :: HttpQuery.t
- def delete_container(service_name, container_id) do
- %HttpQuery{
- method: :delete,
- uri: "/cloud/project/#{service_name}/storage/#{container_id}"
- }
- end
-
-
- @doc ~s"""
- Modify CORS settings for a container.
-
- Modifies the container metadata such that cross origin requests can be permitted.
- See [CORS section of swift docs](http://docs.openstack.org/developer/swift/cors.html) for more info. Ans see here for more
- on [CORS in general](http://enable-cors.org/resources.html)
-
- | Metadata | Use |
- | --- | --- |
- | X-Container-Meta-Access-Control-Allow-Origin | Origins to be allowed to make Cross Origin Requests, space separated. |
-
-
- *Note:* container_d is not the same as container_name.
-
- ## Api call
-
- DELETE /cloud/project/{serviceName}/storage/{containerId}
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
- - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
- - `origin`: an origin that may make cross origin requests to the container. Defaults to `{}` (none) if left absent.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.request!()
-
- ## Notes
-
- To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following
- command for the `container_name` associated with this `container_id`. In fact, the OVH functions are not really required, most changes can be made directly
- using queries sent via the `Swift.Cloudstorage` client.
-
- account = ExOvh.Swift.Cloudstorage.account()
- container = "test_container"
- Openstex.Swift.V1.Query.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers) |> Map.get("X-Container-Meta-Access-Control-Allow-Origin")
- """
- @spec modify_container_cors(String.t, String.t, String.t) :: HttpQuery.t
- def modify_container_cors(service_name, container_id, origin \\ {}) do
- body =
- %{
- "origin" => origin
- }
- |> Poison.encode!()
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/storage/#{container_id}/cors"
- }
- |> Body.apply(body)
- end
-
-
-
- @doc ~s"""
- Deploy a container as a static website.
-
- Modifies the ACL settings for a container on the "X-Container-Read" header and also other container metadata.
- See [swift auth docs](http://docs.openstack.org/developer/swift/overview_auth.html),
- [swift acl middleware](http://docs.openstack.org/developer/swift/misc.html#module-swift.common.middleware.acl)
- and [swift account middleware](http://docs.openstack.org/developer/swift/middleware.html#module-swift.common.middleware.tempauth)
- for more information.
-
- ## Api call
-
- POST /cloud/project/{serviceName}/storage/{containerId}/static
-
- ## Arguments
-
- - `service_name`: service name for the ovh cloud service
- - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.request!()
-
- ## Notes
-
- To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following
- command for the `container_name` associated with this `container_id`. In fact, the OVH functions are not really required, most changes can be made directly
- using queries sent via the `Swift.Cloudstorage` client.
-
- account = ExOvh.Swift.Cloudstorage.account()
- container = "test_container"
- Openstex.Swift.V1.Query.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers)
- """
- @spec deploy_container_as_static_website(String.t, String.t) :: HttpQuery.t
- def deploy_container_as_static_website(service_name, container_id) do
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/storage/#{container_id}/static"
- }
- end
-
-
-
- @doc ~s"""
- List available services
-
- ## Api Call
-
- GET /cloud/project
-
- ## Example
-
- ExOvh.Query.V1.Cloud.list_services() |> ExOvh.request!()
- """
- @spec list_services() :: HttpQuery.t
- def list_services() do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project"
- }
- end
-
-
- @doc ~s"""
- Get all users
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/user
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_users(service_name) |> ExOvh.request!()
- """
- @spec get_users(String.t) :: HttpQuery.t
- def get_users(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/user"
- }
- end
-
-
- @doc ~s"""
- Create user
-
- ## Api Call
-
- POST /cloud/project/{serviceName}/user
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `description`: description ascribed to the new user.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.create_user(service_name, "ex_ovh") |> ExOvh.request!()
- """
- @spec create_user(String.t, String.t) :: HttpQuery.t
- def create_user(service_name, description) do
- body =
- %{
- "description" => description
- } |> Poison.encode!()
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/user"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Get user details. Returns the user_id and username and other details.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/user/{userId}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `user_id`: corresponds to user_id. See `get_users/1`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_user_details(service_name, user_id) |> ExOvh.request!()
- """
- @spec get_user_details(String.t, String.t) :: HttpQuery.t
- def get_user_details(service_name, user_id) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/user/#{user_id}"
- }
- end
-
-
- @doc ~s"""
- Delete a specific user.
-
- ## Api Call
-
- DELETE /cloud/project/{serviceName}/user/{userId}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `user_id`: The user_id. See `get_users/1`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.delete_user(service_name, user_id) |> ExOvh.request!()
- """
- @spec delete_user(String.t, String.t) :: HttpQuery.t
- def delete_user(service_name, user_id) do
- %HttpQuery{
- method: :delete,
- uri: "/cloud/project/#{service_name}/user/#{user_id}"
- }
- end
-
-
- @doc ~s"""
- Get RC file of OpenStack. This file is a bash script with much of the openstack credentials. Makes it easier for
- setting up a swift client from the terminal.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/user/{userId}/openrc
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `user_id`: user_id for user accessing the service.
- - `region`: region for which the rc file will be created. Defaults to "SBG1" if left absent.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.download_openrc_script(service_name, user_id, "SBG1") |> ExOvh.request!()
- """
- @spec download_openrc_script(String.t, String.t, String.t) :: HttpQuery.t
- def download_openrc_script(service_name, user_id, region \\ "SBG1") do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/user/#{user_id}/openrc",
- }
- |> Uri.add_query_string(%{region: region})
- end
-
-
- @doc ~s"""
- Regenerate user password and other credentials.
-
- ## Api Call
-
- POST /cloud/project/{serviceName}/user/{userId}/regeneratePassword
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `user_id`: user_id for accessing the project. See `get_users/1`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.regenerate_credentials(service_name, user_id) |> ExOvh.request!()
- """
- @spec regenerate_credentials(String.t, String.t) :: HttpQuery.t
- def regenerate_credentials(service_name, user_id) do
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/user/#{user_id}/regeneratePassword"
- }
- end
-
-
- @doc ~s"""
- Get the token for the user (very similar to keystone identity)
-
- ## Api Call
-
- POST /cloud/project/{serviceName}/user/{userId}/token
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `user_id`: The swift user_id to login with. See `get_users/1`.
- - `password`: The swift password to login with. See `regenerate_credentials/2`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.swift_identity(service_name, user_id) |> ExOvh.request!()
- """
- @spec swift_identity(String.t, String.t, String.t) :: HttpQuery.t
- def swift_identity(service_name, user_id, password) do
- body =
- %{
- "password" => password
- } |> Poison.encode!()
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/user/#{user_id}/token"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Create a new Cloud Project.
-
- ## Api Call
-
- POST /cloud/createProject
-
- ## Arguments
-
- - `description`: project description
- - `voucher`: ovh voucher code
-
- ## Example
-
- ExOvh.Query.V1.Cloud.create_project(description, voucher) |> ExOvh.request!()
- """
- @spec create_project(String.t, String.t) :: HttpQuery.t
- def create_project(description, voucher) do
- body =
- %{
- "description" => description,
- "voucher" => voucher
- } |> Poison.encode!()
- %HttpQuery{
- method: :post,
- uri: "/cloud/createProject"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Get services prices for the OVH public cloud.
-
- ## Api Call
-
- GET /cloud/price
-
- ## Arguments
-
- - `region`: prices for a particular region (optional)
- - `flavor_id`: ovh voucher code (optional)
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_prices() |> ExOvh.request!()
- """
- @spec get_prices(String.t | :nil, String.t | :nil) :: HttpQuery.t
- def get_prices(region \\ :nil, flavor_id \\ :nil) do
- params =
- cond do
- region == :nil and flavor_id == :nil -> %{}
- region != :nil and flavor_id == :nil -> %{"region" => region}
- region == :nil and flavor_id != :nil -> %{"flavorId" => flavor_id}
- region != :nil and flavor_id != :nil -> %{ "region" => region, "flavorId" => flavor_id }
- end
- body = if params == %{}, do: "", else: Poison.encode!(params)
- %HttpQuery{
- method: :get,
- uri: "/cloud/createProject"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Get details for a given project.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_info(service_name) |> ExOvh.request!()
- """
- @spec project_info(String.t) :: HttpQuery.t
- def project_info(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}"
- }
- end
-
-
- @doc ~s"""
- Modify the project description for a project.
-
- ## Api Call
-
- PUT /cloud/project/{serviceName}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.modify_project(service_name, new_description) |> ExOvh.request!()
- """
- @spec modify_project(String.t, String.t) :: HttpQuery.t
- def modify_project(service_name, new_description) do
- body =
- %{
- "description" => new_description
- } |> Poison.encode!()
- %HttpQuery{
- method: :put,
- uri: "/cloud/project/#{service_name}"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Get administration information about the project
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/serviceInfos
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_administrative_info(service_name) |> ExOvh.request!()
- """
- @spec project_administrative_info(String.t) :: HttpQuery.t
- def project_administrative_info(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/serviceInfos"
- }
- end
-
-
- @doc ~s"""
- Get project quotas.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/quota
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_quotas(service_name) |> ExOvh.request!()
- """
- @spec project_quotas(String.t) :: HttpQuery.t
- def project_quotas(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/quota"
- }
- end
-
-
- @doc ~s"""
- Get project regions.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/region
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_regions(service_name) |> ExOvh.request!()
- """
- @spec project_regions(String.t) :: HttpQuery.t
- def project_regions(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/region"
- }
- end
-
-
- @doc ~s"""
- Get project details about a project region.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/region/{regionName}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_region_info(service_name) |> ExOvh.request!()
- """
- @spec project_region_info(String.t, String.t) :: HttpQuery.t
- def project_region_info(service_name, region_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/region/#{region_name}"
- }
- end
-
-
- @doc ~s"""
- Get project details about a project consumption.
-
- *Note:* Will only allow for up to one month of data to be returned.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/consumption
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `date_from`: starting date in `ISO 8601` format. defaults to 4 weeks/28 days ago (UTC time) if left absent.
- - `date_to`: end date in `ISO 8601` format. defaults to now (UTC time) if left absent.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_consumption(service_name) |> ExOvh.request!()
- """
- @spec project_consumption(String.t, String.t, String.t) :: HttpQuery.t
- def project_consumption(service_name, date_from \\ :nil, date_to \\ :nil) do
- date_from = if date_from == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
- date_to = if date_to == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.Format.rfc3339(), else: date_to
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/consumption"
- }
- |> Uri.add_query_string(%{from: date_from, to: date_to})
- end
-
-
- @doc ~s"""
- Get project details about a project bills.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/bill
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `date_from`: starting date in `ISO 8601` format. defaults to 4 weeks/28 days ago (UTC time) if left absent.
- - `date_to`: end date in `ISO 8601` format. defaults to now (UTC time) if left absent.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.project_bills(service_name) |> ExOvh.request!()
- """
- @spec project_bills(String.t, String.t, String.t) :: HttpQuery.t
- def project_bills(service_name, date_from \\ :nil, date_to \\ :nil) do
- date_from = if date_from == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
- date_to = if date_to == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.Format.rfc3339(), else: date_to
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/bill"
- }
- |> Uri.add_query_string(%{from: date_from,to: date_to})
- end
-
-
- @doc ~s"""
- Get a list of project alert ids. These project alert ids can then be looked up in a separate query for more information.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/alerting
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_project_alerts(service_name) |> ExOvh.request!()
- """
- @spec get_project_alerts(String.t) :: HttpQuery.t
- def get_project_alerts(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/alerting"
- }
- end
-
-
- @doc ~s"""
- Create a new project alert.
-
- *Notes:*
- It seems only one alert is allowed per project. To create a new one alter the old one or delete the old one and add a new one.
- Once the monthly threshold in the given currency is exceeded, then the alert email is sent.
-
- ## Api Call
-
- POST /cloud/project/{serviceName}/alerting
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `delay`: The delay between each alert in seconds. This has to be selected from an enumerable (a list). 3600 is the lowest. defaults to 3600. (1 hour)
- - `email`: The email to send the alert to.
- - `monthlyThreshold`: The maximum monetary (cash) usage allowed in one month. This is an integer value. Ask OVH about how the currency is chosen.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.create_project_alert(service_name, "email_address@email.email", 5) |> ExOvh.request!()
- """
- @spec create_project_alert(String.t, String.t, integer, String.t) :: HttpQuery.t | no_return
- def create_project_alert(service_name, email, monthly_threshold, delay \\ "3600") do
- unless is_integer(monthly_threshold), do: Og.log_return("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
- body =
- %{
- "delay" => delay,
- "email" => email,
- "monthlyThreshold" => monthly_threshold
- } |> Poison.encode!()
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/alerting"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Get detailed information about a project alert.
-
- ## Api Call
-
- GET /cloud/project/{serviceName}/alerting/{id}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `alert_id`: The id of the project alert. See `get_project_alerts/1`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_project_alert_info(service_name, alert_id) |> ExOvh.request!()
- """
- @spec get_project_alert_info(String.t, String.t) :: HttpQuery.t
- def get_project_alert_info(service_name, alert_id) do
- %HttpQuery{
- method: :get,
- uri: "/cloud/project/#{service_name}/alerting/#{alert_id}"
- }
- end
-
-
- @doc ~s"""
- Modify an existing project alert.
-
- ## Api Call
-
- PUT /cloud/project/{serviceName}/alerting/{id}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `alert_id`: The alert to be modified.
- - `delay`: The delay between each alert in seconds. This has to be selected from an enumerable (a list). 3600 is the lowest. defaults to 3600. (1 hour)
- - `email`: The email to send the alert to.
- - `monthlyThreshold`: The maximum monetary (cash) usage allowed in one month. This is an integer value. Ask OVH about how the currency is chosen.
-
- ## Example
-
- ExOvh.Query.V1.Cloud.modify_project_alert(service_name, alert_id, "email_address@email.email", 5) |> ExOvh.request!()
- """
- @spec modify_project_alert(String.t, String.t, String.t, integer, String.t) :: HttpQuery.t
- def modify_project_alert(service_name, alert_id, email, monthly_threshold, delay \\ "3600") do
- unless is_integer(monthly_threshold), do: Og.log_return("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
- body = %{
- "delay" => delay,
- "email" => email,
- "monthlyThreshold" => monthly_threshold
- } |> Poison.encode!()
- %HttpQuery{
- method: :put,
- uri: "/cloud/project/#{service_name}/alerting/#{alert_id}"
- }
- |> Body.apply(body)
- end
-
-
- @doc ~s"""
- Delete a project alert.
-
- ## Api Call
-
- DELETE /cloud/project/{serviceName}/alerting/{id}
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
- - `alert_id`: The id of the project alert. See `get_project_alerts/1`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.get_project_alert_info(service_name, alert_id) |> ExOvh.request!()
- """
- @spec delete_project_alert(String.t, String.t) :: HttpQuery.t
- def delete_project_alert(service_name, alert_id) do
- %HttpQuery{
- method: :delete,
- uri: "/cloud/project/#{service_name}/alerting/#{alert_id}"
- }
- end
-
-
- @doc ~s"""
- Terminate a cloud project.
-
- ## Api Call
-
- POST /cloud/project/{serviceName}/terminate
-
- ## Arguments
-
- - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
-
- ## Example
-
- ExOvh.Query.V1.Cloud.HttpQuery.terminate_project(service_name) |> ExOvh.request!()
- """
- @spec terminate_project(String.t) :: HttpQuery.t
- def terminate_project(service_name) do
- %HttpQuery{
- method: :post,
- uri: "/cloud/project/#{service_name}/terminate"
- }
- end
-
-
-
-end
diff --git a/lib/ex_ovh/query/v1/webstorage.ex b/lib/ex_ovh/query/v1/webstorage.ex
deleted file mode 100644
index ea29511..0000000
--- a/lib/ex_ovh/query/v1/webstorage.ex
+++ /dev/null
@@ -1,170 +0,0 @@
-defmodule ExOvh.Query.V1.Webstorage do
- @moduledoc ~s"""
-
- ***NOTE:*** This is a deprecated service!!!
-
- Helper functions for building queries directed at the `/cdn/webstorage` part of the [OVH API](https://api.ovh.com/console/).
-
- ## Functions Summary
-
- | Function | Description | OVH API call |
- |---|---|---|
- | `get_services/0` | <small>Get a list of all webstorage cdn services.</small> | <sub><sup>GET /v1/cdn/webstorage</sup></sub> |
- | `get_service/1` | <small>Get the domain, server and storage limits for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}</sup></sub> |
- | `get_service_info/1` | <small>Get a administrative details for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/serviceInfos</sup></sub> |
- | `get_service_stats/2` | <small>Get statistics for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
- | `get_credentials/1` | <small>Get credentials for using the swift compliant api</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
-
-
- ## Example
-
- ExOvh.Query.V1.Webstorage.get_services() |> ExOvh.request()
- """
- alias ExOvh.HttpQuery
- alias ExOvh.Transformation.Uri
-
-
-
- @doc ~s"""
- Get a list of all webstorage cdn services available for the client account
-
- ## Api call
-
- GET /v1/cdn/webstorage
-
- ## Example
-
- ExOvh.Query.V1.Webstorage.get_services() |> ExOvh.request()
- """
- @spec get_services() :: HttpQuery.t
- def get_services() do
- %HttpQuery{
- method: :get,
- uri: "/cdn/webstorage"
- }
- end
-
-
-
- @doc ~s"""
- Get the domain, server and storage limits for a specific webstorage cdn service
-
- ## Api call
-
- GET /v1/cdn/webstorage/{serviceName}
-
- ## Arguments
-
- - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
-
- ## Example
-
- alias ExOvh.Query.V1.Webstorage
- service_name = "cdnwebstorage-????"
- query = Query.get_service(service_name)
- {:ok, resp} = ExOvh.Ovh.request(query)
- %{
- "domain" => domain,
- "storageLimit => storage_limit,
- "server" => server
- } = resp.body
- """
- @spec get_service(String.t) :: HttpQuery.t
- def get_service(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cdn/webstorage/#{service_name}"
- }
- end
-
-
-
- @doc ~s"""
- Get a administrative details for a specific webstorage cdn service
-
- ## Api call
-
- GET /v1/cdn/webstorage/{serviceName}/serviceInfos
-
- ## Arguments
-
- - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
-
- ## Example
-
- alias ExOvh.Query.V1.Webstorage
- service_name = "cdnwebstorage-????"
- Query.get_service_info(service_name)
- {:ok, resp} = ExOvh.Ovh.request(query)
- """
- @spec get_service_info(String.t) :: HttpQuery.t
- def get_service_info(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cdn/webstorage/#{service_name}/serviceInfos"
- }
- end
-
-
-
- @doc ~s"""
- Get statistics for a specific webstorage cdn service
-
- ## Api call
-
- GET /v1/cdn/webstorage/{serviceName}/statistics
-
- ## Arguments
-
- - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
- - `options`:
- - `period can be "month", "week" or "day"`
- - `type can be "backend", "quota" or "cdn"`
-
- ## Example
-
- alias ExOvh.Query.V1.Webstorage
- service_name = "cdnwebstorage-????"
- query = Query.get_service_stats(service_name, [period: "month", type: "backend"])
- {:ok, resp} = ExOvh.Ovh.request(query)
- """
- @spec get_service_stats(String.t, Keyword.t) :: HttpQuery.t
- def get_service_stats(service_name, opts \\ []) do
- period = Keyword.get(opts, "period", "month")
- type = Keyword.get(opts, "type", "cdn")
- %HttpQuery{
- method: :get,
- uri: "/cdn/webstorage/#{service_name}/statistics"
- }
- |> Uri.add_query_string(%{"period" => period,"type" => type})
- end
-
-
- @doc ~s"""
- Get credentials for using the swift compliant api
-
- ## Api call
-
- GET /v1/cdn/webstorage/{serviceName}/credentials
-
- ## Arguments
-
- - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
-
- ## Example
-
- alias ExOvh.Query.V1.Webstorage
- service_name = "cdnwebstorage-????"
- query = Query.get_webstorage_credentials(service_name)
- {:ok, resp} = ExOvh.Ovh.request(query)
- """
- @spec get_credentials(String.t) :: ExOvh.Query.Ovh.t
- def get_credentials(service_name) do
- %HttpQuery{
- method: :get,
- uri: "/cdn/webstorage/#{service_name}/credentials"
- }
- end
-
-
-end
diff --git a/lib/ex_ovh/request.ex b/lib/ex_ovh/request.ex
index dcb83f2..dabb4f9 100644
--- a/lib/ex_ovh/request.ex
+++ b/lib/ex_ovh/request.ex
@@ -1,27 +1,27 @@
defmodule ExOvh.Request do
@moduledoc :false
- alias ExOvh.{Transformation, HttpQuery, Response}
# Public
- @spec request(HttpQuery.t, atom) :: {:ok, Response.t} | {:error, Response.t}
- def request(%HttpQuery{} = query, client) do
- Og.context(__ENV__, :debug)
-
- q = apply_transformations(query, client)
+ @spec request(HTTPipe.Conn.t | HTTPipe.Request.t, atom) :: {:ok, HTTPipe.Conn.t} | {:error, HTTPipe.Conn.t}
+ def request(%HTTPipe.Request{} = request, client) do
+ Map.put(HTTPipe.Conn.new(), :request, request)
+ |> request(client)
+ end
+ def request(%HTTPipe.Conn{} = conn, client) do
+ conn = apply_transformations(conn, client)
- case :hackney.request(q.method, q.uri, q.headers, q.body, q.hackney_options) do
- {:ok, resp} ->
- Og.log_return(resp, __ENV__, :debug)
-
- body = parse_body(resp)
- resp = %Response{ body: body, headers: resp.headers |> Enum.into(%{}), status_code: resp.status_code }
+ case HTTPipe.Conn.execute(conn) do
+ {:ok, conn} ->
+ body = parse_body(conn.response)
+ resp = Map.put(conn.response, :body, body)
+ conn = Map.put(conn, :response, resp)
if resp.status_code >= 100 and resp.status_code < 400 do
- {:ok, resp}
+ {:ok, conn}
else
- {:error, resp}
+ {:error, conn}
end
- {:error, resp} -> {:error, resp}
+ {:error, conn} -> {:error, conn}
end
end
@@ -39,29 +39,29 @@ defmodule ExOvh.Request do
end
- defp apply_transformations(%HttpQuery{} = query, client) do
- query =
- unless (:auth in query.completed_transformations) do
- Transformation.Auth.apply(query, client)
+ defp apply_transformations(conn, client) do
+ conn =
+ unless (:url in Map.get(conn, :completed_transformations, [])) do
+ ExOvh.Transformation.Url.apply(conn, client)
else
- query
+ conn
end
- query =
- unless (:uri in query.completed_transformations) do
- Transformation.Uri.apply(query, client)
+ conn =
+ unless (:body in Map.get(conn, :completed_transformations, [])) do
+ ExOvh.Transformation.Body.apply(conn, "")
else
- query
+ conn
end
- query =
- unless (:body in query.completed_transformations) do
- Transformation.Body.apply(client, "")
+ conn =
+ unless (:hackney_options in Map.get(conn, :completed_transformations, [])) do
+ ExOvh.Transformation.HackneyOptions.apply(conn, client)
else
- query
+ conn
end
- unless (:hackney_options in query.completed_transformations) do
- Transformation.HackneyOptions.apply(query, client)
+ unless (:auth in Map.get(conn, :completed_transformations, [])) do
+ ExOvh.Transformation.Auth.apply(conn, client)
else
- query
+ conn
end
end
diff --git a/lib/ex_ovh/response.ex b/lib/ex_ovh/response.ex
deleted file mode 100644
index db0ed78..0000000
--- a/lib/ex_ovh/response.ex
+++ /dev/null
@@ -1,5 +0,0 @@
-defmodule ExOvh.Response do
- @moduledoc false
- defstruct [:body, :headers, :status_code]
- @type t :: %__MODULE__{body: any, headers: list, status_code: integer}
-end
\ No newline at end of file
diff --git a/lib/ex_ovh/response_error.ex b/lib/ex_ovh/response_error.ex
index 341d7d0..26b5686 100644
--- a/lib/ex_ovh/response_error.ex
+++ b/lib/ex_ovh/response_error.ex
@@ -1,27 +1,51 @@
defmodule ExOvh.ResponseError do
@moduledoc :false
- defexception [:response, :query]
+ defexception [:conn]
- def message(%{query: query, response: resp}) do
+ def exception([conn: %HTTPipe.Conn{} = conn]) do
+ %ExOvh.ResponseError{conn: conn}
+ end
+
+ def message(%ExOvh.ResponseError{conn: conn}) do
~s"""
- The following http query was unsuccessful, unexpected or erroneous in some way:
+ The following http connection execution was unsuccessful, unexpected or erroneous in some way:
- #{Kernel.inspect(query)} was unsuccessful.
+ Request Details:
"""
<>
- message(%{response: resp})
+ request_output(conn)
+ <>
+ "\nResponse Details:\n"
+ <>
+ response_output(conn)
+ end
+
+ def request_output(conn) do
+ ~s"""
+ ** Request Method **
+ #{Kernel.inspect(conn.request.method)}
+
+ ** Request Body **
+ #{Kernel.inspect conn.request.body}
+
+ ** Request Headers **
+ #{Kernel.inspect(conn.request.headers)}
+
+ ** Request Url **
+ #{Kernel.inspect(conn.request.url)}
+ """
end
- def message(%{response: resp}) do
+ def response_output(conn) do
~s"""
** Reponse Status Code **
- #{inspect resp.status_code}
+ #{Kernel.inspect conn.response.status_code}
** Response Body **
- #{Kernel.inspect(resp.body)}
+ #{Kernel.inspect(conn.response.body)}
** Response Headers **
- #{Kernel.inspect(resp.headers)}
+ #{Kernel.inspect(conn.response.headers)}
"""
end
end
\ No newline at end of file
diff --git a/lib/ex_ovh/supervisor.ex b/lib/ex_ovh/supervisor.ex
index 6ec6be5..091518c 100644
--- a/lib/ex_ovh/supervisor.ex
+++ b/lib/ex_ovh/supervisor.ex
@@ -7,7 +7,7 @@ defmodule ExOvh.Supervisor do
def start_link(client, opts \\ []) do
- Og.context(__ENV__, :debug)
+ Og.log("***logging context***", __ENV__, :debug)
Supervisor.start_link(__MODULE__, {client, opts})
end
@@ -16,7 +16,7 @@ defmodule ExOvh.Supervisor do
def init({client, opts}) do
- Og.context(__ENV__, :debug)
+ Og.log("***logging context***", __ENV__, :debug)
sup_tree =
[
{client, {ExOvh.Config, :start_agent, [client, opts]}, :permanent, 10_000, :worker, [ExOvh.Config]}
diff --git a/lib/ex_ovh/transformation/auth.ex b/lib/ex_ovh/transformation/auth.ex
index 4ae4858..d99df4b 100644
--- a/lib/ex_ovh/transformation/auth.ex
+++ b/lib/ex_ovh/transformation/auth.ex
@@ -1,32 +1,34 @@
defmodule ExOvh.Transformation.Auth do
@moduledoc :false
- alias ExOvh.{Config, HttpQuery}
@default_headers [{"Content-Type", "application/json; charset=utf-8"}]
# Public
- @spec apply(HttpQuery.t, atom) :: HttpQuery.t
- def apply(%HttpQuery{method: method, headers: headers, uri: uri, completed_transformations: trans} = query, client) do
+ @spec apply(HTTPipe.Conn.t, atom) :: HTTPipe.Conn.t
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{method: method, headers: headers, url: url}} = conn, client) do
+ trans = Map.get(conn, :completed_transformations, [])
+ unless (Enum.member?(trans, :url)), do: raise ":url must be added to the transformations before applying the :auth step"
ovh_config = client.ovh_config()
- headers = headers ++ headers([ovh_config[:application_secret], ovh_config[:application_key], ovh_config[:consumer_key], Atom.to_string(method), uri, ""], client)
- Map.put(query, :headers, headers)
+ headers = Map.merge(headers, headers([ovh_config[:application_secret], ovh_config[:application_key], ovh_config[:consumer_key], Atom.to_string(method), url, ""], client))
+ request = Map.put(conn.request, :headers, headers)
+ Map.put(conn, :request, request)
|> Map.put(:completed_transformations, trans ++ [:auth])
end
# Private
- defp headers([app_secret, app_key, consumer_key, method, uri, body] = _opts, client) do
- time = :os.system_time(:seconds) + Config.get_diff(client)
+ defp headers([app_secret, app_key, consumer_key, method, url, body] = _opts, client) do
+ time = :os.system_time(:seconds) + ExOvh.Config.get_diff(client)
headers = [
- {"X-Ovh-Application", app_key},
- {"X-Ovh-Consumer", consumer_key},
- {"X-Ovh-Timestamp", time},
- {"X-Ovh-Signature", sign_request([app_secret, consumer_key, String.upcase(method), uri, body, time])}
- ]
- |> Enum.into(%{})
- Map.merge(Enum.into(@default_headers, %{}), headers) |> Enum.into([])
+ {"X-Ovh-Application", app_key},
+ {"X-Ovh-Consumer", consumer_key},
+ {"X-Ovh-Timestamp", time},
+ {"X-Ovh-Signature", sign_request([app_secret, consumer_key, String.upcase(method), url, body, time])}
+ ]
+ |> Enum.into(%{})
+ Map.merge(Enum.into(@default_headers, %{}), headers)
end
defp sign_request([_app_secret, _consumer_key, _method, _uri, _body, _time] = opts) do
diff --git a/lib/ex_ovh/transformation/body.ex b/lib/ex_ovh/transformation/body.ex
index abe1619..40bc7a3 100644
--- a/lib/ex_ovh/transformation/body.ex
+++ b/lib/ex_ovh/transformation/body.ex
@@ -1,13 +1,14 @@
defmodule ExOvh.Transformation.Body do
@moduledoc :false
- alias ExOvh.HttpQuery
# Public
- @spec apply(HttpQuery.t, binary) :: HttpQuery.t
- def apply(%HttpQuery{completed_transformations: trans} = query, body) when is_binary(body) do
- Map.put(query, :body, body)
+ @spec apply(HTTPipe.Conn.t, binary) :: HTTPipe.Conn.t
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{}} = conn, body) when is_binary(body) do
+ trans = Map.get(conn, :completed_transformations, [])
+ request = Map.put(conn.request, :body, body)
+ Map.put(conn, :request, request)
|> Map.put(:completed_transformations, trans ++ [:body])
end
diff --git a/lib/ex_ovh/transformation/hackney_options.ex b/lib/ex_ovh/transformation/hackney_options.ex
index 43c2143..c2f39a0 100644
--- a/lib/ex_ovh/transformation/hackney_options.ex
+++ b/lib/ex_ovh/transformation/hackney_options.ex
@@ -1,14 +1,15 @@
defmodule ExOvh.Transformation.HackneyOptions do
@moduledoc :false
- alias ExOvh.HttpQuery
# Public
- @spec apply(HttpQuery.t, atom) :: HttpQuery.t
- def apply(%HttpQuery{hackney_options: hackney_options, completed_transformations: trans} = query, client) do
+ @spec apply(HTTPipe.Conn.t, atom) :: HTTPipe.Conn.t
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{}} = conn, client) do
+ hackney_options = Map.get(conn, :adapter_options, [])
+ trans = Map.get(conn, :completed_transformations, [])
options = merge_options(client.hackney_opts(), hackney_options)
- Map.put(query, :hackney_options, options)
+ Map.put(conn, :adapter_options, options)
|> Map.put(:completed_transformations, trans ++ [:hackney_options])
end
diff --git a/lib/ex_ovh/transformation/uri.ex b/lib/ex_ovh/transformation/uri.ex
deleted file mode 100644
index a5e9df8..0000000
--- a/lib/ex_ovh/transformation/uri.ex
+++ /dev/null
@@ -1,55 +0,0 @@
-defmodule ExOvh.Transformation.Uri do
- @moduledoc :false
- alias ExOvh.HttpQuery
-
-
- # Public
-
- @spec apply(HttpQuery.t, atom) :: HttpQuery.t
- def apply(%HttpQuery{uri: uri, completed_transformations: trans} = query, client) do
- ovh_config = client.ovh_config()
- uri = ovh_config[:endpoint] <> ovh_config[:api_version] <> uri
- Map.put(query, :uri, uri)
- |> Map.put(:completed_transformations, trans ++ [:uri])
- end
- @spec apply(HttpQuery.t, map, atom) :: HttpQuery.t
- def apply(%HttpQuery{uri: uri, completed_transformations: trans} = query, query_string, client) when query_string == %{} do
- ovh_config = client.ovh_config()
- uri = ovh_config[:endpoint] <> ovh_config[:api_version] <> uri
- Map.put(query, :uri, uri)
- |> Map.put(:completed_transformations, trans ++ [:uri])
- end
- def apply(%HttpQuery{uri: uri, completed_transformations: trans} = query, query_string, client) do
- ovh_config = client.ovh_config()
- uri = ovh_config[:endpoint] <> ovh_config[:api_version] <> uri <> "?" <> (query_string |> URI.encode_query())
- Map.put(query, :uri, uri)
- |> Map.put(:completed_transformations, trans ++ [:uri])
- end
-
-
- @doc ~S"""
- Add the query string to a query from a map of `name`=`value` elements. Use instead of
- `ExOvh.Transformation.Uri.apply/3` when the `client` is not available but the query should
- be modified without marking it as fully `transformed` with :uri.
-
- To be used for GET requests.
-
- ## Example
-
- service_name="service_name"
- %ExOvh.HttpQuery{
- method: :get,
- uri: "/cdn/webstorage/#{service_name}/statistics"
- }
- |> ExOvh.Transformation.Uri.add_query_string(%{"containerName" => container_name, "region" => region
-
- """
- @spec add_query_string(HttpQuery.t, map) :: HttpQuery.t
- def add_query_string(%HttpQuery{} = query, qs_map) when qs_map == %{}, do: query
- def add_query_string(%HttpQuery{uri: uri} = query, qs_map) do
- uri = uri <> "?" <> URI.encode_query(qs_map)
- Map.put(query, :uri, uri)
- end
-
-
-end
diff --git a/lib/ex_ovh/transformation/url.ex b/lib/ex_ovh/transformation/url.ex
new file mode 100644
index 0000000..a49b4b4
--- /dev/null
+++ b/lib/ex_ovh/transformation/url.ex
@@ -0,0 +1,61 @@
+defmodule ExOvh.Transformation.Url do
+ @moduledoc :false
+
+
+ # Public
+
+ @spec apply(HTTPipe.Conn.t, atom) :: HTTPipe.Conn.t
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, client) do
+ ovh_config = client.ovh_config()
+ trans = Map.get(conn, :completed_transformations, [])
+ url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
+ request = Map.put(conn.request, :url, url)
+ Map.put(conn, :request, request)
+ |> Map.put(:completed_transformations, trans ++ [:url])
+ end
+ @spec apply(HTTPipe.Conn.t, map, atom) :: HTTPipe.Conn.t
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) when query_string == %{} do
+ ovh_config = client.ovh_config()
+ trans = Map.get(conn, :completed_transformations, [])
+ url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
+ request = Map.put(conn.request, :url, url)
+ Map.put(conn, :request, request)
+ |> Map.put(:completed_transformations, trans ++ [:url])
+ end
+ def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) do
+ ovh_config = client.ovh_config()
+ trans = Map.get(conn, :completed_transformations, [])
+ url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url <> "?" <> (query_string |> url.encode_query())
+ request = Map.put(conn.request, :url, url)
+ Map.put(conn, :request, request)
+ |> Map.put(:completed_transformations, trans ++ [:url])
+ end
+
+
+ @doc ~S"""
+ Add the request string to a request from a map of `name`=`value` elements. Use instead of
+ `ExOvh.Transformation.url.apply/3` when the `client` is not available but the request should
+ be modified without marking it as fully `transformed` with :url.
+
+ To be used for GET requests.
+
+ ## Example
+
+ service_name="service_name"
+ %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage/#{service_name}/statistics"
+ }
+ |> ExOvh.Transformation.Url.add_query_string(%{"containerName" => container_name, "region" => region})
+ |> ExOvh.Request!()
+
+ """
+ @spec add_query_string(HTTPipe.Request.t, map) :: HTTPipe.Request.t
+ def add_query_string(%HTTPipe.Request{} = request, qs_map) when qs_map == %{}, do: request
+ def add_query_string(%HTTPipe.Request{url: url} = request, qs_map) do
+ url = url <> "?" <> url.encode_query(qs_map)
+ Map.put(request, :url, url)
+ end
+
+
+end
diff --git a/lib/ex_ovh/v1/cloud.ex b/lib/ex_ovh/v1/cloud.ex
new file mode 100644
index 0000000..c917754
--- /dev/null
+++ b/lib/ex_ovh/v1/cloud.ex
@@ -0,0 +1,976 @@
+defmodule ExOvh.V1.Cloud do
+ @moduledoc ~s"""
+ Helper functions for building queries directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
+
+ See `ExOvh.V1.Cloud` for generic cloud requests.
+
+ ## Functions Summary
+
+ | Function | Description | OVH API call |
+ |---|---|---|
+ | `list_services/0` | <small>List available services or list available cloud projects. A returned project id in OVH terms is similar to a tenant id in swift terms</small> | <sub><sup>GET /cloud/project</sup></sub> |
+ | `get_users/1` | <small>Get all users</small> | <sub><sup>GET /cloud/project/{serviceName}/user</sup></sub> |
+ | `create_user/2` | <small>Create user</small> | <sub><sup>POST /ctsloud/project/{serviceName}/user</sup></sub> |
+ | `get_user_details/2` | <small>Get user details. Returns the user_id and username and other details.</small> | <sub><sup>GET /cloud/project/{serviceName}/user/{userId}</sup></sub> |
+ | `delete_user/2` | <small>Delete user</small> | <sub><sup>DELETE /cloud/project/{serviceName}/user/{userId}</sup></sub> |
+ | `download_openrc_script/3` | <small>Get RC file of OpenStack</small> | <sub><sup>GET /cloud/project/{serviceName}/user/{userId}/openrc</sup></sub> |
+ | `regenerate_credentials/2` | <small>Regenerate user credentials including password</small> | <sub><sup>POST /cloud/project/{serviceName}/user/{userId}/regeneratePassword</sup></sub> |
+ | `swift_identity/3` | <small>Gets a json object similar to that returned by Keystone Identity. Includes the 'X-Auth-Token'</small> | <sub><sup>POST /cloud/project/{serviceName}/user/{userId}/token</sup></sub> |
+ | `create_project/2` | <small>Start a new cloud project in the OVH cloud. Corresponds to creating a new Swift stack with a new tenant_id.</small> | <sub><sup>POST /cloud/createProject</sup></sub> |
+ | `get_prices/2` | <small>Get Prices for OVH cloud services.</small> | <sub><sup>GET /cloud/price</sup></sub> |
+ | `project_info/1` | <small>Get information about a project with the project_id (tenant_id)</small> | <sub><sup>GET /cloud/project/{serviceName}</sup></sub> |
+ | `modify_project/2` | <small>Modify a project properties. Change the project description.</small> | <sub><sup>PUT /cloud/project/{serviceName}</sup></sub> |
+ | `project_administrative_info/1` | <small>Get administration information about the project.</small> | <sub><sup>GET /cloud/project/{serviceName}/serviceInfos</sup></sub> |
+ | `project_quotas/1` | <small>Get project quotas.</small> | <sub><sup>GET /cloud/project/{serviceName}/quota</sup></sub> |
+ | `project_regions/1` | <small>Get project regions.</small> | <sub><sup>GET /cloud/project/{serviceName}/region</sup></sub> |
+ | `project_region_info/2` | <small>Get details about a project region.</small> | <sub><sup>GET /cloud/project/{serviceName}/region/{regionName}</sup></sub> |
+ | `project_consumption/3` | <small>Get details about a project consumption for a given `date_from` and `date_to`.</small> | <sub><sup>GET /cloud/project/{serviceName}/consumption</sup></sub> |
+ | `project_bills/3` | <small>Get details about a project billing for a given `date_from` and `date_to`..</small> | <sub><sup>GET /cloud/project/{serviceName}/bill</sup></sub> |
+ | `create_project_alert/4` | <small>Add a new project alert</small> | <sub><sup>POST /cloud/project/{serviceName}/alerting</sup></sub> |
+ | `get_project_alert_info/2` | <small>Get detailed information about a project alert.</small> | <sub><sup>GET /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
+ | `modify_project_alert/5` | <small>Modify an existing project alert.</small> | <sub><sup>PUT /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
+ | `delete_project_alert/2` | <small>Delete an existing project alert.</small> | <sub><sup>DELETE /cloud/project/{serviceName}/alerting/{id}</sup></sub> |
+ | `terminate_service/2` | <small>Terminate a cloud project.</small> | <sub><sup>POST /cloud/project/{serviceName}/terminate</sup></sub> |
+ | `get_containers/1` | <small>Get containers for a given swift tenant id (project id or ovh service name)</small> | <sub><sup>GET /cloud/project/{serviceName}/storage </sup></sub> |
+ | `create_container/3` | <small>Create a container for a given tenant_id (ovh service_name), a container and a region.</small> | <sub><sup>POST /cloud/project/{serviceName}/storage</sup></sub> |
+ | `get_access/1` | <small>Get access details for the Swift API for a given swift tenant_id (ovh service_name)</small> | <sub><sup>GET /cloud/project/{serviceName}/storage/access</sup></sub> |
+ | `container_info/2` | <small>Gets details about a container such as objects, size, region, public or not, static_url, name, ...</small> | <sub><sup>GET /cloud/project/{serviceName}/storage/{containerId}</sup></sub> |
+ | `delete_container/2` | <small>Deletes a given container.</small> | <sub><sup>DELETE /cloud/project/{serviceName}/storage/{containerId}</sup></sub> |
+ | `modify_container_cors/3` | <small>Modify the CORS settings for a container. See [swift docs](http://docs.openstack.org/developer/swift/cors.html)</small> | <sub><sup>POST /cloud/project/{serviceName}/storage/{containerId}/cors Add CORS support on your container</sup></sub> |
+ | `deploy_container_as_static_website/2` | <small>Deploy the container files as a static web site.</small> | <sub><sup>POST /cloud/project/{serviceName}/storage/{containerId}/static</sup></sub> |
+
+ ## Notes
+
+ - `service_name` or `serviceName` corresponds to the Openstack `tenant_id`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
+ """
+ alias ExOvh.Transformation.{Body, Url}
+
+
+ @doc ~s"""
+ Get storage containers
+
+ ## Api call
+
+ GET /cloud/project/{serviceName}/storage
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_containers(service_name) |> ExOvh.request!()
+ """
+ @spec get_containers(String.t) :: HTTPipe.Conn.t
+ def get_containers(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/storage",
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Create container
+
+ ## Api call
+
+ POST /cloud/project/{serviceName}/storage
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+ - `container_name`: name for the new container
+ - `region`: region for the new container, defaults to "SBG1". See regions by running:
+ Currently can choose from "GRA1", "BHS1", "SBG1".
+
+
+ ## Example
+
+ ExOvh.V1.Cloud.create_container(service_name, "test_container") |> ExOvh.request!()
+ """
+ @spec create_container(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def create_container(service_name, container_name, region \\ "SBG1") do
+ # POST /cloud/project/{serviceName}/storage Create container
+ body =
+ %{
+ "containerName" => container_name,
+ "region" => region
+ }
+ |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/storage"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Gets the x_auth_token and the swift endpoints for a given tenant_id (ovh service_name). A different endpoint is returned
+ depending on the region. Examples of regions include "BHS1", "SBG1", "GRA1". With these details, requests can be made through
+ the Swift api.
+
+ ## Api call
+
+ GET /cloud/project/{serviceName}/storage/access
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_access(service_name) |> ExOvh.request!()
+ """
+ @spec get_access(String.t) :: HTTPipe.Conn.t
+ def get_access(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/storage/access"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ Gets the details for a given container.
+
+ Returns information such as a list of objects in the container, size of the container, whether the container is public
+ or not, the region of the container, the name of the container, the number of stored objects for the container and the
+ static url for the container.
+
+ ## Api call
+
+ GET /cloud/project/{serviceName}/storage/{containerId}
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+ - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
+
+ ## Example
+
+ ExOvh.V1.Cloud.container_info(service_name, container_id) |> ExOvh.request!()
+ """
+ @spec container_info(String.t, String.t) :: HTTPipe.Conn.t
+ def container_info(service_name, container_id) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/storage/#{container_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Deletes a given container.
+
+ *Note:* container_d is not the same as container_name.
+
+ ## Api call
+
+ DELETE /cloud/project/{serviceName}/storage/{containerId}
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+ - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
+
+ ## Example
+
+ ExOvh.V1.Cloud.delete_container(service_name, container_id) |> ExOvh.request!()
+ """
+ @spec delete_container(String.t, String.t) :: HTTPipe.Conn.t
+ def delete_container(service_name, container_id) do
+ req = %HTTPipe.Request{
+ method: :delete,
+ url: "/cloud/project/#{service_name}/storage/#{container_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Modify CORS settings for a container.
+
+ Modifies the container metadata such that cross origin requests can be permitted.
+ See [CORS section of swift docs](http://docs.openstack.org/developer/swift/cors.html) for more info. Ans see here for more
+ on [CORS in general](http://enable-cors.org/resources.html)
+
+ | Metadata | Use |
+ | --- | --- |
+ | X-Container-Meta-Access-Control-Allow-Origin | Origins to be allowed to make Cross Origin Requests, space separated. |
+
+
+ *Note:* container_d is not the same as container_name.
+
+ ## Api call
+
+ DELETE /cloud/project/{serviceName}/storage/{containerId}
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+ - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
+ - `origin`: an origin that may make cross origin requests to the container. Defaults to `{}` (none) if left absent.
+
+ ## Example
+
+ ExOvh.V1.Cloud.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.request!()
+
+ ## Notes
+
+ To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following
+ command for the `container_name` associated with this `container_id`. In fact, the OVH functions are not really required, most changes can be made directly
+ using queries sent via the `Swift.Cloudstorage` client.
+
+ account = ExOvh.Swift.Cloudstorage.account()
+ container = "test_container"
+ Openstex.Swift.V1.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers) |> Map.get("X-Container-Meta-Access-Control-Allow-Origin")
+ """
+ @spec modify_container_cors(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def modify_container_cors(service_name, container_id, origin \\ {}) do
+ body =
+ %{
+ "origin" => origin
+ }
+ |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/storage/#{container_id}/cors"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ Deploy a container as a static website.
+
+ Modifies the ACL settings for a container on the "X-Container-Read" header and also other container metadata.
+ See [swift auth docs](http://docs.openstack.org/developer/swift/overview_auth.html),
+ [swift acl middleware](http://docs.openstack.org/developer/swift/misc.html#module-swift.common.middleware.acl)
+ and [swift account middleware](http://docs.openstack.org/developer/swift/middleware.html#module-swift.common.middleware.tempauth)
+ for more information.
+
+ ## Api call
+
+ POST /cloud/project/{serviceName}/storage/{containerId}/static
+
+ ## Arguments
+
+ - `service_name`: service name for the ovh cloud service
+ - `container_id`: container_id for a given container. *Note*: this is not the same as the container_name.
+
+ ## Example
+
+ ExOvh.V1.Cloud.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.request!()
+
+ ## Notes
+
+ To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following
+ command for the `container_name` associated with this `container_id`. In fact, the OVH functions are not really required, most changes can be made directly
+ using queries sent via the `Swift.Cloudstorage` client.
+
+ account = ExOvh.Swift.Cloudstorage.account()
+ container = "test_container"
+ Openstex.Swift.V1.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers)
+ """
+ @spec deploy_container_as_static_website(String.t, String.t) :: HTTPipe.Conn.t
+ def deploy_container_as_static_website(service_name, container_id) do
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/storage/#{container_id}/static"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ List available services
+
+ ## Api Call
+
+ GET /cloud/project
+
+ ## Example
+
+ ExOvh.V1.Cloud.list_services() |> ExOvh.request!()
+ """
+ @spec list_services() :: HTTPipe.Conn.t
+ def list_services() do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get all users
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/user
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_users(service_name) |> ExOvh.request!()
+ """
+ @spec get_users(String.t) :: HTTPipe.Conn.t
+ def get_users(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/user"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Create user
+
+ ## Api Call
+
+ POST /cloud/project/{serviceName}/user
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `description`: description ascribed to the new user.
+
+ ## Example
+
+ ExOvh.V1.Cloud.create_user(service_name, "ex_ovh") |> ExOvh.request!()
+ """
+ @spec create_user(String.t, String.t) :: HTTPipe.Conn.t
+ def create_user(service_name, description) do
+ body =
+ %{
+ "description" => description
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/user"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get user details. Returns the user_id and username and other details.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/user/{userId}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `user_id`: corresponds to user_id. See `get_users/1`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_user_details(service_name, user_id) |> ExOvh.request!()
+ """
+ @spec get_user_details(String.t, String.t) :: HTTPipe.Conn.t
+ def get_user_details(service_name, user_id) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/user/#{user_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Delete a specific user.
+
+ ## Api Call
+
+ DELETE /cloud/project/{serviceName}/user/{userId}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `user_id`: The user_id. See `get_users/1`
+
+ ## Example
+
+ ExOvh.V1.Cloud.delete_user(service_name, user_id) |> ExOvh.request!()
+ """
+ @spec delete_user(String.t, String.t) :: HTTPipe.Conn.t
+ def delete_user(service_name, user_id) do
+ req = %HTTPipe.Request{
+ method: :delete,
+ url: "/cloud/project/#{service_name}/user/#{user_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get RC file of OpenStack. This file is a bash script with much of the openstack credentials. Makes it easier for
+ setting up a swift client from the terminal.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/user/{userId}/openrc
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `user_id`: user_id for user accessing the service.
+ - `region`: region for which the rc file will be created. Defaults to "SBG1" if left absent.
+
+ ## Example
+
+ ExOvh.V1.Cloud.download_openrc_script(service_name, user_id, "SBG1") |> ExOvh.request!()
+ """
+ @spec download_openrc_script(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def download_openrc_script(service_name, user_id, region \\ "SBG1") do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/user/#{user_id}/openrc",
+ }
+ |> Url.add_query_string(%{region: region})
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Regenerate user password and other credentials.
+
+ ## Api Call
+
+ POST /cloud/project/{serviceName}/user/{userId}/regeneratePassword
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `user_id`: user_id for accessing the project. See `get_users/1`
+
+ ## Example
+
+ ExOvh.V1.Cloud.regenerate_credentials(service_name, user_id) |> ExOvh.request!()
+ """
+ @spec regenerate_credentials(String.t, String.t) :: HTTPipe.Conn.t
+ def regenerate_credentials(service_name, user_id) do
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/user/#{user_id}/regeneratePassword"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get the token for the user (very similar to keystone identity)
+
+ ## Api Call
+
+ POST /cloud/project/{serviceName}/user/{userId}/token
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `user_id`: The swift user_id to login with. See `get_users/1`.
+ - `password`: The swift password to login with. See `regenerate_credentials/2`
+
+ ## Example
+
+ ExOvh.V1.Cloud.swift_identity(service_name, user_id) |> ExOvh.request!()
+ """
+ @spec swift_identity(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def swift_identity(service_name, user_id, password) do
+ body =
+ %{
+ "password" => password
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/user/#{user_id}/token"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Create a new Cloud Project.
+
+ ## Api Call
+
+ POST /cloud/createProject
+
+ ## Arguments
+
+ - `description`: project description
+ - `voucher`: ovh voucher code
+
+ ## Example
+
+ ExOvh.V1.Cloud.create_project(description, voucher) |> ExOvh.request!()
+ """
+ @spec create_project(String.t, String.t) :: HTTPipe.Conn.t
+ def create_project(description, voucher) do
+ body =
+ %{
+ "description" => description,
+ "voucher" => voucher
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/createProject"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get services prices for the OVH public cloud.
+
+ ## Api Call
+
+ GET /cloud/price
+
+ ## Arguments
+
+ - `region`: prices for a particular region (optional)
+ - `flavor_id`: ovh voucher code (optional)
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_prices() |> ExOvh.request!()
+ """
+ @spec get_prices(String.t | :nil, String.t | :nil) :: HTTPipe.Conn.t
+ def get_prices(region \\ :nil, flavor_id \\ :nil) do
+ params =
+ cond do
+ region == :nil and flavor_id == :nil -> %{}
+ region != :nil and flavor_id == :nil -> %{"region" => region}
+ region == :nil and flavor_id != :nil -> %{"flavorId" => flavor_id}
+ region != :nil and flavor_id != :nil -> %{ "region" => region, "flavorId" => flavor_id }
+ end
+ body = if params == %{}, do: "", else: Poison.encode!(params)
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/createProject"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get details for a given project.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_info(service_name) |> ExOvh.request!()
+ """
+ @spec project_info(String.t) :: HTTPipe.Conn.t
+ def project_info(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Modify the project description for a project.
+
+ ## Api Call
+
+ PUT /cloud/project/{serviceName}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.modify_project(service_name, new_description) |> ExOvh.request!()
+ """
+ @spec modify_project(String.t, String.t) :: HTTPipe.Conn.t
+ def modify_project(service_name, new_description) do
+ body =
+ %{
+ "description" => new_description
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :put,
+ url: "/cloud/project/#{service_name}"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get administration information about the project
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/serviceInfos
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_administrative_info(service_name) |> ExOvh.request!()
+ """
+ @spec project_administrative_info(String.t) :: HTTPipe.Conn.t
+ def project_administrative_info(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/serviceInfos"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get project quotas.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/quota
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_quotas(service_name) |> ExOvh.request!()
+ """
+ @spec project_quotas(String.t) :: HTTPipe.Conn.t
+ def project_quotas(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/quota"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get project regions.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/region
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_regions(service_name) |> ExOvh.request!()
+ """
+ @spec project_regions(String.t) :: HTTPipe.Conn.t
+ def project_regions(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/region"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get project details about a project region.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/region/{regionName}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_region_info(service_name) |> ExOvh.request!()
+ """
+ @spec project_region_info(String.t, String.t) :: HTTPipe.Conn.t
+ def project_region_info(service_name, region_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/region/#{region_name}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get project details about a project consumption.
+
+ *Note:* Will only allow for up to one month of data to be returned.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/consumption
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `date_from`: starting date in `ISO 8601` format. defaults to 4 weeks/28 days ago (UTC time) if left absent.
+ - `date_to`: end date in `ISO 8601` format. defaults to now (UTC time) if left absent.
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_consumption(service_name) |> ExOvh.request!()
+ """
+ @spec project_consumption(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def project_consumption(service_name, date_from \\ :nil, date_to \\ :nil) do
+ date_from = if date_from == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
+ date_to = if date_to == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.Format.rfc3339(), else: date_to
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/consumption"
+ }
+ |> Url.add_query_string(%{from: date_from, to: date_to})
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get project details about a project bills.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/bill
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `date_from`: starting date in `ISO 8601` format. defaults to 4 weeks/28 days ago (UTC time) if left absent.
+ - `date_to`: end date in `ISO 8601` format. defaults to now (UTC time) if left absent.
+
+ ## Example
+
+ ExOvh.V1.Cloud.project_bills(service_name) |> ExOvh.request!()
+ """
+ @spec project_bills(String.t, String.t, String.t) :: HTTPipe.Conn.t
+ def project_bills(service_name, date_from \\ :nil, date_to \\ :nil) do
+ date_from = if date_from == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
+ date_to = if date_to == :nil, do: Calendar.DateTime.now!("Etc/UTC") |> Calendar.DateTime.Format.rfc3339(), else: date_to
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/bill"
+ }
+ |> Url.add_query_string(%{from: date_from,to: date_to})
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get a list of project alert ids. These project alert ids can then be looked up in a separate request for more information.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/alerting
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_project_alerts(service_name) |> ExOvh.request!()
+ """
+ @spec get_project_alerts(String.t) :: HTTPipe.Conn.t
+ def get_project_alerts(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/alerting"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Create a new project alert.
+
+ *Notes:*
+ It seems only one alert is allowed per project. To create a new one alter the old one or delete the old one and add a new one.
+ Once the monthly threshold in the given currency is exceeded, then the alert email is sent.
+
+ ## Api Call
+
+ POST /cloud/project/{serviceName}/alerting
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `delay`: The delay between each alert in seconds. This has to be selected from an enumerable (a list). 3600 is the lowest. defaults to 3600. (1 hour)
+ - `email`: The email to send the alert to.
+ - `monthlyThreshold`: The maximum monetary (cash) usage allowed in one month. This is an integer value. Ask OVH about how the currency is chosen.
+
+ ## Example
+
+ ExOvh.V1.Cloud.create_project_alert(service_name, "email_address@email.email", 5) |> ExOvh.request!()
+ """
+ @spec create_project_alert(String.t, String.t, integer, String.t) :: HTTPipe.Conn.t | no_return
+ def create_project_alert(service_name, email, monthly_threshold, delay \\ "3600") do
+ unless is_integer(monthly_threshold), do: Og.log_r("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
+ body =
+ %{
+ "delay" => delay,
+ "email" => email,
+ "monthlyThreshold" => monthly_threshold
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/alerting"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get detailed information about a project alert.
+
+ ## Api Call
+
+ GET /cloud/project/{serviceName}/alerting/{id}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `alert_id`: The id of the project alert. See `get_project_alerts/1`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_project_alert_info(service_name, alert_id) |> ExOvh.request!()
+ """
+ @spec get_project_alert_info(String.t, String.t) :: HTTPipe.Conn.t
+ def get_project_alert_info(service_name, alert_id) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cloud/project/#{service_name}/alerting/#{alert_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Modify an existing project alert.
+
+ ## Api Call
+
+ PUT /cloud/project/{serviceName}/alerting/{id}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `alert_id`: The alert to be modified.
+ - `delay`: The delay between each alert in seconds. This has to be selected from an enumerable (a list). 3600 is the lowest. defaults to 3600. (1 hour)
+ - `email`: The email to send the alert to.
+ - `monthlyThreshold`: The maximum monetary (cash) usage allowed in one month. This is an integer value. Ask OVH about how the currency is chosen.
+
+ ## Example
+
+ ExOvh.V1.Cloud.modify_project_alert(service_name, alert_id, "email_address@email.email", 5) |> ExOvh.request!()
+ """
+ @spec modify_project_alert(String.t, String.t, String.t, integer, String.t) :: HTTPipe.Conn.t
+ def modify_project_alert(service_name, alert_id, email, monthly_threshold, delay \\ "3600") do
+ unless is_integer(monthly_threshold), do: Og.log_r("monthly_threshold should be an integer!", __ENV__, :error) |> raise()
+ body = %{
+ "delay" => delay,
+ "email" => email,
+ "monthlyThreshold" => monthly_threshold
+ } |> Poison.encode!()
+ req = %HTTPipe.Request{
+ method: :put,
+ url: "/cloud/project/#{service_name}/alerting/#{alert_id}"
+ }
+ |> Body.apply(body)
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Delete a project alert.
+
+ ## Api Call
+
+ DELETE /cloud/project/{serviceName}/alerting/{id}
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+ - `alert_id`: The id of the project alert. See `get_project_alerts/1`
+
+ ## Example
+
+ ExOvh.V1.Cloud.get_project_alert_info(service_name, alert_id) |> ExOvh.request!()
+ """
+ @spec delete_project_alert(String.t, String.t) :: HTTPipe.Conn.t
+ def delete_project_alert(service_name, alert_id) do
+ req = %HTTPipe.Request{
+ method: :delete,
+ url: "/cloud/project/#{service_name}/alerting/#{alert_id}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Terminate a cloud project.
+
+ ## Api Call
+
+ POST /cloud/project/{serviceName}/terminate
+
+ ## Arguments
+
+ - `service_name`: corresponds to project_id or tenant_id. See `list_services/0`
+
+ ## Example
+
+ ExOvh.V1.Cloud.HTTPipe.Conn.terminate_project(service_name) |> ExOvh.request!()
+ """
+ @spec terminate_project(String.t) :: HTTPipe.Conn.t
+ def terminate_project(service_name) do
+ req = %HTTPipe.Request{
+ method: :post,
+ url: "/cloud/project/#{service_name}/terminate"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+end
diff --git a/lib/ex_ovh/v1/webstorage.ex b/lib/ex_ovh/v1/webstorage.ex
new file mode 100644
index 0000000..b8fe4ad
--- /dev/null
+++ b/lib/ex_ovh/v1/webstorage.ex
@@ -0,0 +1,174 @@
+defmodule ExOvh.V1.Webstorage do
+ @moduledoc ~s"""
+
+ ***NOTE:*** This is a deprecated service!!!
+
+ Helper functions for building queries directed at the `/cdn/webstorage` part of the [OVH API](https://api.ovh.com/console/).
+
+ ## Functions Summary
+
+ | Function | Description | OVH API call |
+ |---|---|---|
+ | `get_services/0` | <small>Get a list of all webstorage cdn services.</small> | <sub><sup>GET /v1/cdn/webstorage</sup></sub> |
+ | `get_service/1` | <small>Get the domain, server and storage limits for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}</sup></sub> |
+ | `get_service_info/1` | <small>Get a administrative details for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/serviceInfos</sup></sub> |
+ | `get_service_stats/2` | <small>Get statistics for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
+ | `get_credentials/1` | <small>Get credentials for using the swift compliant api</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
+
+
+ ## Example
+
+ ExOvh.V1.Webstorage.get_services() |> ExOvh.request()
+ """
+ alias ExOvh.Transformation.Url
+
+
+
+ @doc ~s"""
+ Get a list of all webstorage cdn services available for the client account
+
+ ## Api call
+
+ GET /v1/cdn/webstorage
+
+ ## Example
+
+ ExOvh.V1.Webstorage.get_services() |> ExOvh.request()
+ """
+ @spec get_services() :: HTTPipe.Conn.t
+ def get_services() do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ Get the domain, server and storage limits for a specific webstorage cdn service
+
+ ## Api call
+
+ GET /v1/cdn/webstorage/{serviceName}
+
+ ## Arguments
+
+ - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
+
+ ## Example
+
+ alias ExOvh.V1.Webstorage
+ service_name = "cdnwebstorage-????"
+ conn = Webstorage.get_service(service_name)
+ {:ok, conn} = ExOvh.Ovh.request(conn)
+ %{
+ "domain" => domain,
+ "storageLimit => storage_limit,
+ "server" => server
+ } = conn.response.body
+ """
+ @spec get_service(String.t) :: HTTPipe.Conn.t
+ def get_service(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage/#{service_name}"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ Get a administrative details for a specific webstorage cdn service
+
+ ## Api call
+
+ GET /v1/cdn/webstorage/{serviceName}/serviceInfos
+
+ ## Arguments
+
+ - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
+
+ ## Example
+
+ alias ExOvh.V1.Webstorage
+ service_name = "cdnwebstorage-????"
+ Webstorage.get_service_info(service_name)
+ {:ok, conn} = ExOvh.Ovh.request(conn)
+ """
+ @spec get_service_info(String.t) :: HTTPipe.Conn.t
+ def get_service_info(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage/#{service_name}/serviceInfos"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+
+ @doc ~s"""
+ Get statistics for a specific webstorage cdn service
+
+ ## Api call
+
+ GET /v1/cdn/webstorage/{serviceName}/statistics
+
+ ## Arguments
+
+ - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
+ - `options`:
+ - `period can be "month", "week" or "day"`
+ - `type can be "backend", "quota" or "cdn"`
+
+ ## Example
+
+ alias ExOvh.V1.Webstorage
+ service_name = "cdnwebstorage-????"
+ conn = Webstorage.get_service_stats(service_name, [period: "month", type: "backend"])
+ {:ok, conn} = ExOvh.Ovh.request(conn)
+ """
+ @spec get_service_stats(String.t, Keyword.t) :: HTTPipe.Conn.t
+ def get_service_stats(service_name, opts \\ []) do
+ period = Keyword.get(opts, "period", "month")
+ type = Keyword.get(opts, "type", "cdn")
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage/#{service_name}/statistics"
+ }
+ |> Url.add_query_string(%{"period" => period,"type" => type})
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+ @doc ~s"""
+ Get credentials for using the swift compliant api
+
+ ## Api call
+
+ GET /v1/cdn/webstorage/{serviceName}/credentials
+
+ ## Arguments
+
+ - `service_name`: Name of the Webstorage CDN service - assigned by OVH.
+
+ ## Example
+
+ alias ExOvh.V1.Webstorage
+ service_name = "cdnwebstorage-????"
+ conn = Webstorage.get_webstorage_credentials(service_name)
+ {:ok, conn} = ExOvh.Ovh.request(conn)
+ """
+ @spec get_credentials(String.t) :: HTTPipe.Conn.t
+ def get_credentials(service_name) do
+ req = %HTTPipe.Request{
+ method: :get,
+ url: "/cdn/webstorage/#{service_name}/credentials"
+ }
+ Map.put(HTTPipe.Conn.new(), :request, req)
+ end
+
+
+end
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index 00bc8be..5d690b0 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -34,7 +34,8 @@ defmodule Mix.Tasks.Ovh do
use Mix.Task
alias ExOvh.Defaults
@default_headers [{"Content-Type", "application/json; charset=utf-8"}]
- @default_options [ timeout: 30000, recv_timeout: (60000 * 1) ]
+ @default_adapter :hackney
+ @default_hackney_options [ timeout: 30000, recv_timeout: (60000 * 1) ]
@default_name "ex_ovh"
@default_description "ex_ovh application"
@default_redirect_uri ""
@@ -191,21 +192,31 @@ defmodule Mix.Tasks.Ovh do
defp get_app_create_page(opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :get
- uri = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
+ url = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
body = ""
headers = []
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
- Map.get(resp, :body)
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+
+ conn.response.body
end
defp get_create_app_inputs(resp_body) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
inputs = Floki.find(resp_body, "form input")
|> List.flatten()
@@ -215,7 +226,7 @@ defmodule Mix.Tasks.Ovh do
defp build_app_request(inputs, %{login: login, password: password} = opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
{acc, _index, _max} =
Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({"input", input, _}, acc) ->
@@ -243,26 +254,34 @@ defmodule Mix.Tasks.Ovh do
defp send_app_request(req_body, opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :post
- uri = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
+ url = Defaults.endpoints()[opts_map[:endpoint]] <> Defaults.create_app_uri_suffix()
body = req_body
headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+ body = conn.response.body
# Error checking
cond do
- String.contains?(resp.body, msg = "There is already an application with that name for that Account ID") ->
+ String.contains?(body, msg = "There is already an application with that name for that Account ID") ->
raise(msg <> ", try removing the old application first using the ovh api console or just create a new one.")
- String.contains?(resp.body, msg = "Invalid account/password") ->
+ String.contains?(body, msg = "Invalid account/password") ->
raise(msg <> ", try adding '-ovh' to the end of the login")
- String.contains?(resp.body, "Application created") ->
- resp.body
- true ->
- raise "unknown error"
+ String.contains?(body, "Application created") -> body
+ true -> raise "unknown error"
end
end
@@ -292,33 +311,51 @@ defmodule Mix.Tasks.Ovh do
defp get_consumer_key(%{access_rules: access_rules, redirect_uri: redirect_uri} = opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :post
- uri = Defaults.endpoints()[opts_map[:endpoint]] <> opts_map[:api_version] <> Defaults.consumer_key_suffix()
+ url = Defaults.endpoints()[opts_map[:endpoint]] <> opts_map[:api_version] <> Defaults.consumer_key_suffix()
body = %{ accessRules: access_rules, redirection: redirect_uri } |> Poison.encode!()
headers = Map.merge(Enum.into(@default_headers, %{}), Enum.into([{"X-Ovh-Application", opts_map[:application_key]}], %{})) |> Enum.into([])
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
-
- body = Poison.decode!(Map.get(resp, :body))
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+
+ body = Poison.decode!(conn.response.body)
{Map.get(body, "consumerKey"), Map.get(body, "validationUrl")}
end
defp bind_consumer_key_to_app({ck, validation_url}, opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :get
- uri = validation_url
+ url = validation_url
body = ""
headers = []
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
-
- Map.get(resp, :body)
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+
+ conn.response.body
|> get_bind_ck_to_app_inputs()
|> build_ck_binding_request(opts_map)
|> send_ck_binding_request(validation_url, ck)
@@ -326,7 +363,7 @@ defmodule Mix.Tasks.Ovh do
defp get_bind_ck_to_app_inputs(resp_body) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
inputs = Floki.find(resp_body, "form input") ++
Floki.find(resp_body, "form select")
@@ -340,7 +377,7 @@ defmodule Mix.Tasks.Ovh do
defp build_ck_binding_request(inputs, %{login: login, password: password} = _opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
Enum.reduce(inputs, "", fn({type, input, _options}, acc) ->
{name_val, value} =
@@ -376,25 +413,34 @@ defmodule Mix.Tasks.Ovh do
defp send_ck_binding_request(req_body, validation_url, ck) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :post
- uri = validation_url
+ url = validation_url
body = req_body
headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
-
- case check_for_successful_binding(resp, validation_url, ck) do
- {:ok, :handle_2fa} -> handle_2fa(resp.body, validation_url, ck)
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
+
+ case check_for_successful_binding(conn.response, validation_url, ck) do
+ {:ok, :handle_2fa} -> handle_2fa(conn.response.body, validation_url, ck)
{:ok, ck} -> ck
{:error, msg} -> raise msg
end
end
defp check_for_successful_binding(resp, validation_url, ck) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
error_msg1 = "Failed to bind the consumer token to the application. Please try to validate the consumer token manually at #{validation_url}"
error_msg2 = "Invalid validity period entered for the consumer token. Please try to validate the consumer token manually at #{validation_url}"
@@ -404,7 +450,7 @@ defmodule Mix.Tasks.Ovh do
String.contains?(resp.body, "Your token is now valid, you can use it in your application") -> {:ok, ck}
String.contains?(resp.body, "token is now valid") -> {:ok, ck}
String.contains?(resp.body, "You have activated the double factor authentication") -> {:ok, :handle_2fa}
- # presume the validation was successful if redirected to redirect uri
+ # presume the validation was successful if redirected to redirect url
resp.status_code == 302 && (resp.headers |> Enum.into(%{}) |> Map.has_key?("Location")) -> {:ok, ck}
true -> {:error, "Unexpected error " <> error_msg1}
end
@@ -412,7 +458,7 @@ defmodule Mix.Tasks.Ovh do
defp build_2fa_request(resp_body) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
Mix.Shell.IO.info("You have activated 2FA on your OVH account, you need to verify your account via 2FA")
@@ -454,18 +500,27 @@ defmodule Mix.Tasks.Ovh do
defp handle_2fa(resp_body, validation_url, ck) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
method = :post
- uri = validation_url
+ url = validation_url
body = build_2fa_request(resp_body)
headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
- options = @default_options
- {:ok, resp} = :hackney.request(method, uri, headers, body, options)
- |> Og.log_return()
+ options = @default_hackney_options
+
+ conn = %HTTPipe.Conn{
+ request: %HTTPipe.Request{
+ method: method,
+ url: url,
+ body: body,
+ headers: headers
+ },
+ adapter_options: options
+ }
+ {:ok, conn} = HTTPipe.Conn.execute(conn)
error_msg = "function check_for_successful_binding seems to be entering an error loop"
- case check_for_successful_binding(resp, validation_url, ck) do
+ case check_for_successful_binding(conn.response, validation_url, ck) do
{:ok, :handle_2fa} -> raise error_msg
{:ok, ck} -> ck
{:error, msg} -> raise "#{error_msg} - #{msg}"
@@ -474,7 +529,7 @@ defmodule Mix.Tasks.Ovh do
defp get_credentials(opts_map) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
create_app_body = get_app_create_page(opts_map) |> get_create_app_inputs() |> build_app_request(opts_map) |> send_app_request(opts_map)
opts_map = Map.merge(opts_map, %{
@@ -498,7 +553,7 @@ defmodule Mix.Tasks.Ovh do
config_names(Atom.to_string(app_name), client_name)
end
defp config_names(app_name, client_name) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
{config_header, mod_client_name} =
case app_name do
@@ -549,7 +604,7 @@ defmodule Mix.Tasks.Ovh do
defp print_config(options, elixir_app_name) do
-# Og.context(__ENV__, :debug)
+# Og.log("***logging context***", __ENV__, :debug)
app_name = elixir_app_name || options.application_name
{config_header, mod_client_name} = config_names(app_name, options.client_name)
diff --git a/mix.exs b/mix.exs
index cca96a0..c7ad420 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,6 +1,7 @@
defmodule ExOvh.Mixfile do
use Mix.Project
- @version "0.2.0"
+ @version "0.3.0"
+ @elixir ">= 1.2.0"
def project do
[
@@ -8,7 +9,7 @@ defmodule ExOvh.Mixfile do
name: "ExOvh",
version: @version,
source_url: "https://github.com/stephenmoloney/ex_ovh",
- elixir: "~> 1.2",
+ elixir: @elixir,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
description: description(),
@@ -27,10 +28,8 @@ defmodule ExOvh.Mixfile do
defp deps() do
[
{:calendar, "~> 0.17"},
- {:og, "~> 0.1"},
+ {:og, ">= 0.2.4"},
{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0"},
- {:hackney, "~> 1.0"},
- {:httpipe, "~> 0.9"},
{:httpipe_adapters_hackney, "~> 0.9"},
{:floki, ">= 0.7.0"},
diff --git a/mix.lock b/mix.lock
index 9201a9d..1b8afd9 100644
--- a/mix.lock
+++ b/mix.lock
@@ -1,7 +1,8 @@
-%{"calendar": {:hex, :calendar, "0.17.1", "5c7dfffde2b68011c2d6832ff1a15496292de965a3b57b3fad32405f1176f024", [:mix], [{:tzdata, "~> 0.5.8 or ~> 0.1.201603", [hex: :tzdata, optional: false]}]},
+%{"apex": {:hex, :apex, "1.0.0", "abf230314d35ca4c48a902f693247f190ad42fc14862b9c4f7dbb7077b21c20a", [:mix], []},
+ "calendar": {:hex, :calendar, "0.17.1", "5c7dfffde2b68011c2d6832ff1a15496292de965a3b57b3fad32405f1176f024", [:mix], [{:tzdata, "~> 0.5.8 or ~> 0.1.201603", [hex: :tzdata, optional: false]}]},
"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
"earmark": {:hex, :earmark, "1.1.1", "433136b7f2e99cde88b745b3a0cfc3fbc81fe58b918a09b40fce7f00db4d8187", [:mix], []},
- "ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
+ "ex_doc": {:hex, :ex_doc, "0.15.0", "e73333785eef3488cf9144a6e847d3d647e67d02bd6fdac500687854dd5c599f", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
"hackney": {:hex, :hackney, "1.6.5", "8c025ee397ac94a184b0743c73b33b96465e85f90a02e210e86df6cbafaa5065", [:rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"hoedown": {:git, "https://github.com/hoedown/hoedown.git", "980b9c549b4348d50b683ecee6abee470b98acda", []},
@@ -12,7 +13,7 @@
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], []},
- "og": {:hex, :og, "0.1.0", "e21cbb6fd0130a43308f922b482b83bcf03000a154af633e3b98445147ea737b", [:mix], []},
+ "og": {:hex, :og, "0.2.4", "0041226e485576231abecf8a33db81557be338da2c6bcb3aedd7cac678064ae1", [:mix], [{:apex, "~> 1.0", [hex: :apex, optional: false]}]},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
"tzdata": {:hex, :tzdata, "0.5.10", "087e8dfe8c0283473115ad8ca6974b898ecb55ca5c725427a142a79593391e90", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}}