Commit dc63c2ec18f85f0f535ca7e73dd69dd255a49c62

Stephen Moloney 2016-04-24T14:34:18

starting migration from old version of ex_ovh to new version.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
diff --git a/.gitignore b/.gitignore
index 5fdd9aa..79a493c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,11 +3,14 @@
 /cover
 /deps
 /doc
-erl_crash.dump
+/.idea
+/.deprecated
+/.notes
+/.backup
+
 *.ez
+erl_crash.dump
 *.secret.exs
-.deprecated
-.notes
-.idea
+.env
 mix.lock
-
+todo.md
diff --git a/config/config.exs b/config/config.exs
index e7b3dfb..86c91eb 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -5,23 +5,10 @@ config :logger,
   level: :debug,
   format: "\n$date $time [$level] $metadata$message"
 
-
-if Mix.env == :dev do
-  config :logger,
-    backends: [:console],
-    compile_time_purge_level: :debug
-end
-
 if Mix.env == :prod do
   config :logger,
     backends: [:console],
     compile_time_purge_level: :warn
 end
 
-if Mix.env == :test do
-  config :logger,
-    backends: [:console],
-    compile_time_purge_level: :warn
-end
-
-import_config "#{Mix.env}.exs"
\ No newline at end of file
+import_config "#{Mix.env}.exs"
diff --git a/config/dev.exs b/config/dev.exs
index 0af5a88..4a1a288 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -1,4 +1,16 @@
 use Mix.Config
 
-import_config "#{Mix.env}.secret.exs"
+config :logger,
+  backends: [:console],
+  compile_time_purge_level: :debug
 
+config :ex_ovh,
+  ovh: %{
+    application_key: System.get_env("EX_OVH_APPLICATION_KEY"),
+    application_secret: System.get_env("EX_OVH_APPLICATION_SECRET"),
+    consumer_key: System.get_env("EX_OVH_CONSUMER_KEY"),
+    endpoint: System.get_env("EX_OVH_ENDPOINT"),
+    api_version: System.get_env("EX_OVH_API_VERSION") || "1.0",
+    connect_timeout: 30000, # 30 seconds
+    connect_timeout: (60000 * 30) # 30 minutes
+  }
diff --git a/config/test.exs b/config/test.exs
new file mode 100644
index 0000000..83948ca
--- /dev/null
+++ b/config/test.exs
@@ -0,0 +1,16 @@
+use Mix.Config
+
+config :logger,
+  backends: [:console],
+  compile_time_purge_level: :error
+
+config :ex_ovh,
+  ovh: %{
+    application_key: System.get_env("EX_OVH_APPLICATION_KEY"),
+    application_secret: System.get_env("EX_OVH_APPLICATION_SECRET"),
+    consumer_key: System.get_env("EX_OVH_CONSUMER_KEY"),
+    endpoint: System.get_env("EX_OVH_ENDPOINT"),
+    api_version: System.get_env("EX_OVH_API_VERSION") || "1.0",
+    connect_timeout: 30000, # 30 seconds
+    connect_timeout: (60000 * 30) # 30 minutes
+  }
\ No newline at end of file
diff --git a/lib/application.ex b/lib/application.ex
new file mode 100644
index 0000000..317ce3d
--- /dev/null
+++ b/lib/application.ex
@@ -0,0 +1,13 @@
+defmodule ExOvh.Application do
+  @moduledoc :false
+  use Application
+  @ex_ovh_config Application.get_all_env(:ex_ovh) |> Keyword.get(:ovh, :nil)
+
+  # Start the ex_ovh client only if a config :ex_ovh, ex_ovh: %{...} configuration file has been set.
+  unless @ex_ovh_config in [%{}, :nil] do
+    def start(_type, _args) do
+      ExOvh.Supervisor.start_link(ExOvh, @ex_ovh_config, :ex_ovh)
+    end
+  end
+
+end
diff --git a/lib/auth/openstack/swift/cache.ex b/lib/auth/openstack/swift/cache.ex
new file mode 100644
index 0000000..6c4771b
--- /dev/null
+++ b/lib/auth/openstack/swift/cache.ex
@@ -0,0 +1,316 @@
+defmodule ExOvh.Auth.Openstack.Swift.Cache do
+  @moduledoc :false
+
+  use GenServer
+  alias ExOvh.Auth.Supervisor, as: AuthSupervisor
+  alias ExOvh.Utils
+  @get_credentials_retries 10
+  @get_credentials_sleep_interval 450
+
+
+  # Public
+
+
+  def start_link({client, config, opts}, service) do
+    Og.context(__ENV__, :debug)
+    GenServer.start_link(__MODULE__, {client, service}, [name: gen_server_name(client, service)])
+  end
+
+
+  def get_credentials(client, service) do
+    unless supervisor_exists?(client, service), do: Supervisor.start_child(AuthSupervisor, [service])
+    get_credentials(client, service, 0)
+  end
+
+
+  def get_credentials_token(client, service), do: get_credentials(client, service).token
+
+
+  def get_swift_endpoint(client, service) do
+    credentials = get_credentials(client, service)
+    path = URI.parse(credentials.swift_endpoint) |> Map.get(:path)
+    {version, account} = String.split_at(path, 4)
+    endpoint = List.first(String.split(credentials.swift_endpoint, account))
+    endpoint
+  end
+
+
+  def get_account(service), do: get_account(ExOvh, service)
+  def get_account(client, service) do
+    credentials = get_credentials(client, service)
+    path = URI.parse(credentials.swift_endpoint) |> Map.get(:path)
+    {version, account} = String.split_at(path, 4)
+    account
+  end
+
+
+  # Genserver Callbacks
+
+
+  # trap exits so that terminate callback is invoked
+  # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
+  def init({client, service}) do
+    Og.context(__ENV__, :debug)
+    :erlang.process_flag(:trap_exit, :true)
+    create_ets_table(client, service)
+
+    {:ok, credentials} = identity(client, service)
+
+    credentials = Map.put(credentials, :lock, :false)
+    :ets.insert(ets_tablename(client, service), {:credentials, credentials})
+    expires = to_seconds(credentials.token_expires_on)
+    Task.start_link(fn -> monitor_expiry(expires) end)
+    {:ok, {client, service, credentials}}
+  end
+
+  def handle_call(:add_lock, _from, {client, service, credentials}) do
+    Og.context(__ENV__, :debug)
+    new_credentials = Map.put(credentials, :lock, :true)
+    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
+    {:reply, :ok, {client, service, new_credentials}}
+  end
+
+  def handle_call(:remove_lock, _from, {client, service, credentials}) do
+    Og.context(__ENV__, :debug)
+    new_credentials = Map.put(credentials, :lock, :false)
+    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
+    {:reply, :ok, {client, service, new_credentials}}
+  end
+
+  def handle_call(:update_credentials, _from, {client, service, credentials}) do
+    Og.context(__ENV__, :debug)
+    {:ok, new_credentials} = identity(client, service)
+    |> Map.put(credentials, :lock, :false)
+    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
+    {:reply, :ok, {client, service, new_credentials}}
+  end
+
+  def handle_call(:stop, _from, state) do
+    Og.context(__ENV__, :debug)
+    {:stop, :shutdown, :ok, state}
+  end
+
+  def terminate(:shutdown, {client, service, credentials}) do
+    Og.context(__ENV__, :debug)
+    :ets.delete(ets_tablename(client, service)) # explicilty remove
+    :ok
+  end
+
+
+  # Private
+
+
+  defp gen_server_name(client, service), do:  String.to_atom(Atom.to_string(client) <> service)
+  defp ets_tablename(client, service), do: String.to_atom(Atom.to_string(client) <> "-" <> service)
+
+
+
+  def identity(client, {service_name, :webstorage} = service) when is_atom(client) do
+    credentials =  ExOvh.Ovh.V1.Webstorage.Query.get_credentials(service_name) |> client.request!()
+    identity(service_name, credentials, client)
+  end
+  def identity(client, {service_name, pcs_service_name, :cloudstorage} = service) when is_atom(client) do
+    credentials = ExOvh.Ovh.V1.Cloudstorage.Query.get_credentials(service_name, pcs_service_name) |> client.request!()
+    identity(service_name, credentials, client)
+  end
+
+
+  def identity(service_name, credentials, client) do
+
+    config = Utils.config(client)
+    q1 = ExOvh.Ovh.V1.Webstorage.Query.get_service(service_name)
+    {:ok, resp} = ExOvh.request(service_name)
+
+    %{
+      "server" => domain,
+      "storageLimit" => storage_limit,
+      "server" => server
+    } = resp.body
+
+
+    {:ok, resp} = ExOvh.request(credentials)
+
+    %{
+      "endpoint" => endpoint,
+      "login" => login,
+      "password" => password,
+      "tenant" => tenant
+    } = resp.body
+
+
+    method = :post
+    uri = endpoint <> "/tokens"
+    body = %{"auth" =>
+                %{
+                "passwordCredentials" => %{"username" => login, "password" => password}
+                }
+        }
+        |> Poison.encode!()
+    headers = [{"Content-Type", "application/json; charset=utf-8"}]
+    options = Utils.set_opts([], config)
+    resp = HTTPoison.request(method, uri, body, headers, options)
+
+    unless resp.status_code >= 200 and resp.status_code <= 203, do: raise resp.body
+
+    %{
+      "access" =>
+                  %{
+                    "token" => %{
+                                 "expires" => expires_on,
+                                 "id" => token,
+                                 "issued_at" => created_on
+                                },
+                  }
+      } = Poison.decode!(resp.body)
+
+
+    method = :post
+    uri = endpoint <> "/tokens"
+    body = %{
+            "auth" =>
+                      %{
+                      "tenantName" => tenant,
+                      "token" => %{"id" => token}
+                      }
+            }
+    |> Poison.decode!()
+    headers = [{"Content-Type", "application/json; charset=utf-8"}]
+    options = Utils.set_opts([], config)
+    resp = HTTPoison.request(method, uri, body, headers, options)
+
+    unless resp.status_code >= 200 and resp.status_code <= 203, do: raise resp.body
+
+    %{
+      "serviceCatalog" => [
+                          %{
+                            "endpoints" => [%{"publicURL" => swift_endpoint}],
+                            "name" => "swift",
+                          },
+                          %{
+                            "endpoints" => [%{"publicURL" => identity_endpoint}],
+                            "name" => "keystone",
+                          }
+                         ],
+                          "token" => %{
+                                          "expires" => token_expires_on,
+                                          "id" => token,
+                                          "issued_at" => token_created_on,
+                                        },
+                          "user" => _user
+      } = Poison.decode!(resp.body) |> Map.get("access")
+
+      {:ok,
+          %{
+            token: token,
+            token_expires_on: expires_on,
+            token_created_on: token_created_on,
+            swift_endpoint: swift_endpoint,
+            identity_endpoint: identity_endpoint,
+            service: service_name,
+            public_url: public_url(domain, swift_endpoint),
+            storage_limit: storage_limit,
+            server: server
+          }
+      }
+
+  end
+
+
+  # private
+
+
+  defp public_url(domain, swift_endpoint) do
+    path = URI.parse(swift_endpoint) |> Map.get(:path)
+    {version, account} = String.split_at(path, 4)
+    domain <> version <> account
+  end
+
+  defp get_credentials(client, service, index) do
+    Og.context(__ENV__, :debug)
+
+    retry = fn(client, service, index) ->
+      if index > @get_credentials_retries do
+        raise "Cannot retrieve openstack credentials from ets table, #{__ENV__.module}, #{__ENV__.line}"
+      else
+        :timer.sleep(@get_credentials_sleep_interval)
+        get_credentials(client, service, index + 1)
+      end
+    end
+
+    if ets_tablename(client, service) in :ets.all() do
+      table = :ets.lookup(ets_tablename(client, service), :credentials)
+      case table do
+        [credentials: credentials] ->
+          if credentials.lock === :true do
+            retry.(client, service, index)
+          else
+            credentials
+          end
+        [] -> retry.(client,service,index)
+      end
+    else
+      retry.(client, service, index)
+    end
+  end
+
+
+  defp monitor_expiry(expires) do
+    Og.context(__ENV__, :debug)
+    interval = (expires - 30) * 1000
+    :timer.sleep(interval)
+    {:reply, :ok, _credentials} = GenServer.call(self(), :add_lock)
+    {:reply, :ok, _credentials} = GenServer.call(self(), :update_credentials)
+    {:reply, :ok, credentials} = GenServer.call(self(), :remove_lock)
+    expires = to_seconds(credentials["expires"])
+    monitor_expiry(expires)
+  end
+
+
+  defp create_ets_table(client, service) do
+    Og.context(__ENV__, :debug)
+    ets_options = [
+                   :set, # type
+                   :protected, # read - all, write this process only.
+                   :named_table,
+                   {:heir, :none}, # don't let any process inherit the table. when the ets table dies, it dies.
+                   {:write_concurrency, :false},
+                   {:read_concurrency, :true}
+                  ]
+    unless ets_tablename(client, service) in :ets.all() do
+      :ets.new(ets_tablename(client, service), ets_options)
+    end
+  end
+
+
+  defp to_seconds(iso_time) do
+    {:ok, expiry_ndt, offset} = Calendar.NaiveDateTime.Parse.iso8601(iso_time)
+    offset =
+    case offset do
+      :nil -> 0
+      offset -> offset
+    end
+    {:ok, expiry_dt_utc} = Calendar.NaiveDateTime.with_offset_to_datetime_utc(expiry_ndt, offset)
+    {:ok, now} = Calendar.DateTime.from_erl(:calendar.universal_time(), "UTC")
+    {:ok, seconds, _microseconds, _when} = Calendar.DateTime.diff(expiry_dt_utc, now)
+    if seconds > 0 do
+      seconds
+    else
+      0
+    end
+  end
+
+
+  defp supervisor_exists?(client, service) do
+    case Process.whereis(registered_supervisor_name(client, service)) do
+      :nil -> :false
+      _pid -> :true
+    end
+  end
+
+
+  defp registered_supervisor_name(client, service) do
+    String.to_atom(Atom.to_string(client) <> service)
+  end
+
+
+end
\ No newline at end of file
diff --git a/lib/auth/ovh/auth.ex b/lib/auth/ovh/auth.ex
new file mode 100644
index 0000000..05a585b
--- /dev/null
+++ b/lib/auth/ovh/auth.ex
@@ -0,0 +1,62 @@
+defimpl Openstex.Auth, for: ExOvh.Ovh.Query do
+  @moduledoc :false
+
+  alias ExOvh.Utils
+  alias ExOvh.Ovh.Query
+  alias ExOvh.Auth.Ovh.Cache
+  @default_headers [{"Content-Type", "application/json; charset=utf-8"}]
+
+
+  # Public
+
+
+  @spec prepare_request(Query.t, Keyword.t, atom) :: Openstex.HttpQuery.t
+  def prepare_request(query, opts, client)
+
+  def prepare_request(%Query{method: method, uri: uri, params: params}, opts, client) when method in [:get, :head, :delete] do
+    config = Utils.config(client)
+    if params !== :nil and params !== "" and is_map(params), do: uri = uri <> "?" <> URI.encode_query(params)
+    if params !== :nil and params !== "" and is_map(params) === :false, do: uri = uri <> URI.encode_www_form(params)
+    uri = Utils.uri(uri, config)
+    body = params || ""
+    headers = headers([Utils.app_secret(config), Utils.app_key(config), Utils.get_consumer_key(config), Atom.to_string(method), uri, ""], client)
+    options = Utils.set_opts(opts, config)
+    %Openstex.HttpQuery{method: method, uri: uri, body: body, headers: headers, options: options, service: :ovh}
+  end
+
+  def prepare_request(%Query{method: method, uri: uri, params: params}, opts, client) when method in [:post, :put] do
+    config = Utils.config(client)
+    if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
+    uri = Utils.uri(uri, config)
+    body = params || ""
+    header_opts = [Utils.app_secret(config), Utils.app_key(config), Utils.get_consumer_key(config), Atom.to_string(method), uri, params]
+    headers = headers([Utils.app_secret(config), Utils.app_key(config), Utils.get_consumer_key(config), Atom.to_string(method), uri, ""], client)
+    options = Utils.set_opts(opts, config)
+    %Openstex.HttpQuery{method: method, uri: uri, body: body, headers: headers, options: options, service: :ovh}
+  end
+
+
+  # Private
+
+
+  defp headers([app_secret, app_key, consumer_key, method, uri, body] = opts, client) do
+    time = :os.system_time(:seconds) + Cache.get_time_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([])
+  end
+
+
+  defp sign_request([app_secret, consumer_key, method, uri, body, time] = opts) do
+    pre_hash = Enum.join(opts, "+")
+    post_hash = :crypto.hash(:sha, pre_hash) |> Base.encode16(case: :lower)
+    "$1$" <> post_hash
+  end
+
+
+end
diff --git a/lib/auth/ovh/cache.ex b/lib/auth/ovh/cache.ex
new file mode 100644
index 0000000..9671384
--- /dev/null
+++ b/lib/auth/ovh/cache.ex
@@ -0,0 +1,98 @@
+defmodule ExOvh.Auth.Ovh.Cache do
+  @moduledoc :false
+  use GenServer
+  import ExOvh.Utils, only: [gen_server_name: 1]
+  alias ExOvh.Utils
+
+
+  # Public
+
+
+  def start_link({client, config, opts}) do
+    Og.context(__ENV__, :debug)
+    client
+    |> Og.log_return(__ENV__, :warn)
+    GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
+  end
+
+
+  @doc "Retrieves the ovh api time diff from the state"
+  def get_time_diff(client) do
+    client |> Og.log_return(__ENV__, :warn)
+    gen_server_name(client) |> Og.log_return(__ENV__, :warn)
+
+    GenServer.call(gen_server_name(client), :get_diff)
+  end
+  @doc "Retrieves the ovh config map"
+  def get_config(client) do
+    client |> Og.log_return(__ENV__, :warn)
+    gen_server_name(client) |> Og.log_return(__ENV__, :warn)
+
+    GenServer.call(gen_server_name(client), :get_config)
+  end
+
+
+  # Genserver Callbacks
+
+
+  def init({client, config, opts}) do
+    Og.context(__ENV__, :debug)
+    diff = calculate_diff(config)
+    {:ok, {config, diff}}
+  end
+
+  def handle_call(:get_diff, _from, {config, diff}) do
+    Og.context(__ENV__, :debug)
+    {:reply, diff, {config, diff}}
+  end
+
+  def handle_call(:get_config, _from, {config, diff}) do
+    Og.context(__ENV__, :debug)
+    {:reply, config, {config, diff}}
+  end
+
+  def handle_cast({:set_diff, new_diff}, {config, diff}) do
+    Og.context(__ENV__, :debug)
+    {:noreply, {config, new_diff}}
+  end
+
+  def terminate(:shutdown, state) do
+    Og.context(__ENV__, :warn)
+    Og.log_return("gen_server #{__MODULE__} shutting down", :warn)
+    :ok
+  end
+
+
+  # Private
+
+
+  defp api_time_request(config) do
+    method = :get
+    uri = Utils.endpoint(config) <> Utils.api_version(config) <> "/auth/time"
+    body = ""
+    headers = [{"Content-Type", "application/json; charset=utf-8"}]
+    options = Utils.set_opts([], config)
+    resp = HTTPoison.request!(method, uri, body, headers, options)
+    api_time = Poison.decode!(resp.body)
+  end
+
+
+  defp calculate_diff(config) do
+    api_time = api_time_request(config)
+    os_t = :os.system_time(:seconds)
+    os_t - api_time
+  end
+
+
+  #Caches the ovh api time diff
+  defp set_time_diff(client) do
+    config = get_config(client)
+    set_time_diff(client, config)
+  end
+  defp set_time_diff(client, config) when is_map(config) do
+    diff = calculate_diff(config)
+    GenServer.cast(gen_server_name(client), {:set_diff, diff})
+  end
+
+
+end
\ No newline at end of file
diff --git a/lib/auth/supervisor.ex b/lib/auth/supervisor.ex
new file mode 100644
index 0000000..78f45c7
--- /dev/null
+++ b/lib/auth/supervisor.ex
@@ -0,0 +1,40 @@
+defmodule ExOvh.Auth.Supervisor do
+  @moduledoc :false
+
+  use Supervisor
+  import ExOvh.Utils, only: [supervisor_name: 1]
+  alias ExOvh.Auth.Ovh.Cache, as: OvhCache
+  alias ExOvh.Auth.Openstack.Swift.Cache, as: SwiftCache
+
+
+  #  Public
+
+
+  @doc ~S"""
+  Starts the OVH supervisor.
+  """
+  def start_link(client, config, opts) do
+    Og.context(__ENV__, :debug)
+    Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
+  end
+
+
+  # Supervisor Callbacks
+
+
+  def init({client, config, opts}) do
+    Og.context(__ENV__, :debug)
+    Og.log({client, config, opts}, __ENV__, :debug)
+
+    tree = [
+            {OvhCache,
+              {OvhCache, :start_link, [{client, config, opts}]}, :transient, 10_000, :worker, [OvhCache]},
+#            {SwiftCache,
+#              {SwiftCache, :start_link, [{client, config, opts}]}, :permanent, 10_000, :worker, [SwiftCache]}
+           ]
+
+    supervise(tree, strategy: :one_for_one)
+  end
+
+
+end
diff --git a/lib/client.ex b/lib/client.ex
index 9a00e48..f556248 100644
--- a/lib/client.ex
+++ b/lib/client.ex
@@ -1,86 +1,39 @@
 defmodule ExOvh.Client do
   @moduledoc ~S"""
-  Defines a client.
-
-  When used, it expects the :otp_app as an option. The :otp_app should be an
-  application with the configuration settings for ovh and/or hubic.
-
-  ## Example app using the `ExOvh.Client` behaviour
-
-      defmodule TestOs.ExOvh do
-        use ExOvh.Client, otp_app: :test_os
-      end
-
-  ## Example configuration
-
-      config :test_os, TestOs.ExOvh,
-        ovh:  %{
-                application_key: "<app_key>",
-                application_secret: "<app_secret>",
-                consumer_key: "<con_key>"
-        },
-        hubic: %{
-                client_id: "<client_id>",
-                client_secret: "<client_secret>",
-                refresh_token: "<refresh_token>",
-                redirect_uri: "<redirect_uri>"
-                }
-
-  Either ovh or hubic can be set to :nil but not both. Both hubic and ovh being absent
-  will result in the supervision tree crashing since there are no application data with
-  which to authenticate requests.
-  For example, if hubic is set to :nil, then the hubic side of the supervision tree
-  will not be started. Then the only functions available will be:
-
-      TestOs.ExOvh.ovh_request/3
-      TestOs.ExOvh.ovh_prepare_request/3
   """
   alias ExOvh.Defaults
 
 
-  @type method_t :: atom()
-  @type path_t :: String.t
-  @type params_t :: map() | :nil
-  @type options_t :: map() | :nil
-  @type raw_query_t :: { method_t, path_t, params_t }
-  @type query_t :: { method_t, path_t, options_t }
-  @type response_t :: %{ body: map() | String.t, headers: map(), status_code: integer() }
-
-
   defmacro __using__(opts) do
     quote bind_quoted: [opts: opts] do
-      @otp_app opts[:otp_app] || :ex_ovh
-
+      @otp_app Keyword.get(opts, :otp_app, :ex_ovh)
 
-      if(@otp_app !== :ex_ovh)  do
-        def config(), do: Application.get_env(@otp_app, __MODULE__) |> Enum.into(%{})
-      else
-        def config(), do: Application.get_all_env(@otp_app) |> Enum.into(%{})
-      end
-
-
-      def start_link(opts \\ []) do
-        ExOvh.Supervisor.start_link(__MODULE__, config(), opts)
-      end
+      use Openstex.Client, client: __MODULE__, swift_cache: __MODULE__.Auth.Openstack.Swift.Cache
 
+      # Incorporation of the Swift Oject Storage Helpers modules.
+      defmodule Helpers.Swift do
+        %Macro.Env{context_modules: [_, client_module]} = __ENV__
+         use Openstex.Helpers.V1.Swift, client: client_module
+       end
 
-      def ovh_request({method, uri, params} = query, opts \\ %{}) do
-        ExOvh.Ovh.Request.request(__MODULE__, query, opts)
+      # Incorporation of the Custom Ovh Helpers modules.
+      defmodule Helpers.Ovh do
+       %Macro.Env{context_modules: [_, _, client_module]} = __ENV__
+        use ExOvh.Ovh.V1.Webstorage.Helpers, client: client_module
       end
 
 
-      def ovh_prepare_request({method, uri, params} = query, opts \\ %{}) do
-        ExOvh.Ovh.Auth.prepare_request(__MODULE__, query, opts)
-      end
-
-
-      def hubic_request({method, uri, params} = query, opts \\ %{}) do
-        ExOvh.Hubic.Request.request(__MODULE__, query, opts)
+      if (@otp_app != :ex_ovh)  do
+        def config(), do: Application.get_env(@otp_app, __MODULE__)
+        |> Keyword.fetch!(:ovh)
+      else
+        def config(), do: Application.get_all_env(@otp_app)
+        |> Keyword.fetch!(:ovh)
       end
 
 
-      def hubic_prepare_request({method, uri, params} = query, opts \\ %{}) do
-        ExOvh.Hubic.Auth.prepare_request(__MODULE__, query, opts)
+      def start_link(opts \\ []) do
+        ExOvh.Supervisor.start_link(__MODULE__, config(), opts)
       end
 
 
@@ -88,114 +41,16 @@ defmodule ExOvh.Client do
   end
 
 
-  @doc """
-  Starts the ovh and the hubic supervisors.
+  @doc ~s"""
+  Starts the ovh supervisors.
   """
   @callback start_link() :: :ok | {:error, {:already_started, pid}} | {:error, term}
 
 
-  @doc ~S"""
-  Gets the ovh and hubic config from the application environment.
-
-  Returns a map if the config is present in the config.exs file(s)
-  or
-  Returns :nil if the config is absent.
+  @doc ~s"""
+  Gets the ovh config from the application environment.
   """
   @callback config() :: :nil | map
 
 
-
-  @doc """
-  Prepares all elements necessary for making a request to the ovh api.
-
-  Returns a tuple `{method, uri, options}` which is the `query_t` tuple.
-  With the returned query_t, a request can easily be made with
-  [HTTPotion](http://hexdocs.pm/httpotion/HTTPotion.html).
-
-  ## Example
-
-  Building a request to the custom ovh api:
-      raw_query = {:get, "<account_name>", %{"format" => "json"}}
-      query = ExOvh.ovh_prepare_request(raw_query, %{})
-
-
-  Building a request to the openstack compliant ovh cdn webstorage service:
-      raw_query = {:get, "<account_name>", %{"format" => "json"}}
-      query = ExOvh.ovh_prepare_request(raw_query, %{ openstack: :true, webstorage: "<ovh_service_name>" })
-  """
-  @callback ovh_prepare_request(query :: raw_query_t)
-                             :: query_t
-
-
-
-  @doc ~S"""
-  Makes a request to the ovh api.
-
-  Returns a `response_t` map  with the structure:
-  `%{ body: <body>, headers: [<headers>], status_code: <code>}`
-
-  ## Example
-
-  Making a request to the custom ovh api:
-      raw_query = {:get, "<account_name>", %{"format" => "json"}}
-      ExOvh.ovh_request(raw_query, %{})
-
-  Making a request to the openstack compliant ovh cdn webstorage service:
-      raw_query = {:get, "<account_name>", %{"format" => "json"}}
-      ExOvh.ovh_request(raw_query, %{ openstack: :true, webstorage: "<ovh_service_name>" })
-  """
-  @callback ovh_request(query :: raw_query_t, opts :: map)
-                        :: {:ok, response_t} | {:error, response_t}
-
-
-
-
-  @doc ~S"""
-  Makes a request to the hubic api.
-
-  Returns a map `%{ body: <body>, headers: %{<headers>}, status_code: <code>}`
-
-  Making a request to the custom hubic api:
-      raw_query = {:get, "/scope/scope", :nil}
-      ExOvh.hubic_request(raw_query, %{})
-
-  Making a request to the openstack compliant hubic storage:
-      client = ExOvh
-      account = ExOvh.Hubic.OpenstackApi.Cache.get_account(client)
-      raw_query = {:get, account, %{"format" => "json"}}
-      ExOvh.hubic_request(raw_query, %{ openstack: :true })
-  """
-  @callback hubic_request(query :: raw_query_t, opts :: map)
-                         :: {:ok, response_t} | {:error, response_t}
-
-
-  @doc ~S"""
-  Prepares all elements necessary for making a request to the hubic api.
-
-  Returns a tuple `{method, uri, options}`
-
-  Building a request to the custom hubic api:
-      raw_query = {:get, "/scope/scope", :nil}
-      ExOvh.hubic_prepare_request(raw_query, %{})
-
-  Building a request to the openstack compliant hubic storage
-  with the default client `ExOvh`:
-
-      account = ExOvh.Hubic.OpenstackApi.Cache.get_account()
-      raw_query = {:get, account, %{"format" => "json"}}
-      ExOvh.hubic_prepare_request(raw_query, %{ openstack: :true })
-
-
-  Building a request to the openstack compliant hubic storage with your own
-  client:
-
-      client = MyApp.ExOvh # <-- enter your client here.
-      account = ExOvh.Hubic.OpenstackApi.Cache.get_account(client)
-      raw_query = {:get, account, %{"format" => "json"}}
-      ExOvh.hubic_prepare_request(raw_query, %{ openstack: :true })
-  """
-  @callback hubic_prepare_request(query :: raw_query_t)
-                               :: query_t
-
-
 end
diff --git a/lib/defaults.ex b/lib/defaults.ex
new file mode 100644
index 0000000..03958ae
--- /dev/null
+++ b/lib/defaults.ex
@@ -0,0 +1,54 @@
+defmodule ExOvh.Defaults do
+  @moduledoc :false
+
+  @doc "Returns ovh default configuration settings"
+  @spec ovh() :: map
+  def ovh() do
+    %{
+      endpoint: "ovh-eu",
+      api_version: "1.0"
+    }
+  end
+
+
+  @doc "Returns a map of ovh endpoints"
+  @spec endpoints() :: map
+  def endpoints() do
+    %{
+      "ovh-eu"        => "https://api.ovh.com/",
+      "ovh-ca"        => "https://ca.api.ovh.com/",
+      "kimsufi-eu"    => "https://eu.api.kimsufi.com/",
+      "kimsufi-ca"    => "https://ca.api.kimsufi.com/",
+      "soyoustart-eu" => "https://eu.api.soyoustart.com/",
+      "soyoustart-ca" => "https://ca.api.soyoustart.com/",
+      "runabove-ca"   => "https://api.runabove.com/"
+    }
+  end
+
+
+  @doc "Returns the default access rules (all methods and paths by default)"
+  @spec access_rules() :: [map]
+  def access_rules() do
+     [
+        %{
+            method: "GET",
+            path: "/*"
+        },
+        %{
+            method: "POST",
+            path: "/*"
+        },
+        %{
+            method: "PUT",
+            path: "/*"
+        },
+        %{
+            method: "DELETE",
+            path: "/*"
+        }
+    ]
+  end
+
+
+end
+
diff --git a/lib/ex_ovh.ex b/lib/ex_ovh.ex
index 50c641c..4919798 100644
--- a/lib/ex_ovh.ex
+++ b/lib/ex_ovh.ex
@@ -1,4 +1,10 @@
 defmodule ExOvh do
-  @moduledoc File.read!("#{__DIR__}/../README.md") |> String.replace("# ExOvh", "")
-  use ExOvh.Client, otp_app: :ex_ovh
-end
+  @moduledoc :false
+  @ex_ovh_config Application.get_all_env(:ex_ovh) |> Keyword.get(:ovh, :nil)
+
+  # Define a standard ExOvh client only if the user has entered a config :ex_ovh, ex_ovh: %{...} into the configuration file.
+  unless  @ex_ovh_config in [%{}, :nil] do
+    use ExOvh.Client, otp_app: :ex_ovh
+  end
+
+end
\ No newline at end of file
diff --git a/lib/hubic/auth.ex b/lib/hubic/auth.ex
deleted file mode 100644
index aa1e570..0000000
--- a/lib/hubic/auth.ex
+++ /dev/null
@@ -1,69 +0,0 @@
-defmodule ExOvh.Hubic.Auth do
-  @moduledoc :false
-  @doc ~S"""
-  Houses the `prepare_request` function which delegates the function call to the appropriate
-  module & function depending on the `opts` key-values.
-
-  Ovh uses it's own custom api and also separate Openstack compliant apis so
-  and these apis are quite different.
-  Therefore, the request needs to be routed to the correct `prepare_request` function so
-  that the correct auth credentials are put into the `options_t` in the returned
-  `ExOvh.Client.query_t` query tuple.
-
-  ## Examples of what some delegation depending on opts
-
-      ExOvh.hubic_prepare_request(query, %{} = opts)
-      calls
-      ExOvh.Hubic.HubicApi.Auth.hubic_prepare_request(ExOvh, query, opts)
-
-  -
-
-      ExOvh.hubic_prepare_request(query, %{ openstack: :true } = opts)
-      calls
-      ExOvh.Hubic.OpenstackApi.Auth.hubic_prepare_request(ExOvh, query, opts)
-
-
-  ## Subsequent Request modules
-
-  The subsequent request functions process the request by
-
-  1. Calling the appropriate `prepare_request` function which has been delegated to.
-  2. Getting the appropriate auth credentials and adding them to the headers as needed.
-  3. Returning `ExOvh.Client.query_t` which is a tuple of the format {method, uri, options} which
-     can then be easily used to make requests using HTTPpotion, `ovh_request` or `hubic_request`.
-  """
-  alias ExOvh.Hubic.OpenstackApi.Auth, as: OpenstackAuth
-  alias ExOvh.Hubic.HubicApi.Auth, as: HubicAuth
-
-
-  @doc ~S"""
-  Delegates the function call to the appropriate module & function depending on the `opts` key-values.
-
-  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
-
-  ## Options
-
-      { } = opts
-
-  The function call will be delegated to `ExOvh.Hubic.HubicApi.Auth`.
-
-      { openstack: :true, webstorage: "<service>" } = opts
-
-  The function call will be delegated to `ExOvh.Hubic.HubicApi.Webstorage.Auth`.
-
-  `openstack: :true` - boolean - indicates whether the request is an openstack one or not.
-
-  `webstorage: service` - String.t and is the name the cdn webstorage in your ovh stack which you which to use.
-  """
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map())
-                     :: ExOvh.Client.query_t
-  def prepare_request(client, {method, uri, params} = query, %{openstack: :true} = opts) do
-    OpenstackAuth.prepare_request(client, query)
-  end
-
-  def prepare_request(client, {method, uri, params} = query, opts) do
-    HubicAuth.prepare_request(client, query)
-  end
-
-
-end
diff --git a/lib/hubic/defaults.ex b/lib/hubic/defaults.ex
deleted file mode 100644
index 54f9ca7..0000000
--- a/lib/hubic/defaults.ex
+++ /dev/null
@@ -1,19 +0,0 @@
-defmodule ExOvh.Hubic.Defaults do
-  @moduledoc :false
-
-  @doc "Returns hubic default configuration settings"
-  @spec hubic() :: map
-  def hubic() do
-    %{
-      auth_uri:    "https://api.hubic.com/oauth/auth",
-      token_uri:   "https://api.hubic.com/oauth/token",
-      api_uri:     "https://api.hubic.com",
-      api_version: "1.0"
-    }
-  end
-
-
-end
-
-
-
diff --git a/lib/hubic/hubic_api/auth.ex b/lib/hubic/hubic_api/auth.ex
deleted file mode 100644
index 2623160..0000000
--- a/lib/hubic/hubic_api/auth.ex
+++ /dev/null
@@ -1,92 +0,0 @@
-defmodule ExOvh.Hubic.HubicApi.Auth do
-  #@moduledoc "Gets the access and refresh token for access the hubic api"
-  @moduledoc :false
-  alias ExOvh.Hubic.Defaults
-  alias ExOvh.Hubic.HubicApi.Cache
-  @timeout 20_000
-
-
-  ###################
-  # Public
-  ###################
-  
-
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t)
-                    :: ExOvh.Client.query_t
-  def prepare_request(client, query)
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:get, :head, :delete] do
-    config = config(client)
-    uri = uri(config, uri)
-    if params !== :nil and params !== "" and is_map(params), do: uri = uri <> "?" <> URI.encode_query(params)
-    if params !== :nil and params !== "" and is_map(params) === :false, do: uri = uri <> URI.encode_www_form(params)
-    options = %{ headers: headers(client, method), timeout: @timeout }
-    {method, uri, options}
-  end
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:post, :put] do
-    config = config(client)
-    uri = uri(config, uri)
-    if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
-    options = %{ body: params, headers: headers(client, method), timeout: @timeout }
-    {method, uri, options}
-  end
-
-
-  @doc """
-  - It is necessary to perform this request every time the access token expires.
-  - The refresh token needs to be available to perform this request.
-  - returned map structure is as follows:
-    %{
-      "access_token" => "access_token",
-      "expires_in" => 21600,
-      "token_type" => "Bearer"
-     }
-  """
-  @spec get_latest_access_token(refresh_token :: String.t, config :: map) :: map
-  def get_latest_access_token(refresh_token, config) do
-    Og.context(__ENV__, :debug)
-    auth_credentials = config.client_id <> ":" <> config.client_secret
-    auth_credentials_base64 = Base.encode64(auth_credentials)
-    req_body = "refresh_token=" <> refresh_token <>
-                "&grant_type=refresh_token"
-    headers = %{
-               "Content-Type": "application/x-www-form-urlencoded",
-               "Authorization": "Basic " <> auth_credentials_base64
-              }
-    options = %{ body: req_body, headers: headers, timeout: @timeout }
-    resp = HTTPotion.request(:post, hubic_token_uri(config), options)
-    resp =
-    %{
-      body: resp.body |> Poison.decode!(),
-      headers: resp.headers,
-      status_code: resp.status_code
-    }
-    if Map.has_key?(resp, "error") do
-      error = Map.get(resp, "error") <> " :: " <> Map.get(resp, "error_description")
-      raise error
-    end
-    body = resp |> Map.get(:body)
-  end
-
-
-  ###################
-  # Private
-  ###################
-
-  defp default_headers(client), do: %{ "Authorization": "Bearer " <> Cache.get_token(client) }
-  defp headers(client, method) when method in [:post, :put] do
-    Map.merge(default_headers(client), %{ "Content-Type": "application/json;charset=utf-8" })
-  end
-  defp headers(client, method) when method in [:get, :head, :delete], do: default_headers(client)
-
-  defp config(), do: Cache.get_config(ExOvh)
-  defp config(client), do: Cache.get_config(client)
-  defp api_version(config), do: config[:api_version]
-  defp uri(config, uri), do: hubic_api_uri(config) <> "/" <> api_version(config) <> uri
-  defp hubic_auth_uri(config), do: config[:auth_uri]
-  defp hubic_token_uri(config), do: config[:token_uri]
-  defp hubic_api_uri(config), do: config[:api_uri]
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/hubic_api/cache.ex b/lib/hubic/hubic_api/cache.ex
deleted file mode 100644
index e2d0ec1..0000000
--- a/lib/hubic/hubic_api/cache.ex
+++ /dev/null
@@ -1,195 +0,0 @@
-defmodule ExOvh.Hubic.HubicApi.Cache do
-  #@moduledoc ~S"""
-  #Caches the access_token and provides a simple get_token() api to other modules through one function get_token()
-  #Caches the hubic config map.
-
-  #Maintains the access token so that:
-  #- State is maintained in gen_server state but gen_server could be a bottleneck so it is also copied to a public ets table.
-  #- So state is also stored in an ets table and is quickly and globally retrievable.
-  #- State in :ets and :gen_server should be synchronised.
-  #- It is automatically refreshed in the background when it expires
-  #- If the gen_server crashes, it will attempt to re-establish the access token
-  #- The refresh token by attempting the following:
-  #  - 1. Firstly, try to recuperate the refresh_token from a dets entry.
-  #  - 2. Secondly, by checking for the refresh_token in the config secret file.
-  #- If both of the above methods fail, then ultimately the gen_server will crash and the user
-  #  will have to retrieve another refresh_token using the `mix hubic` task
-  #
-  #tokens is a map with the following structure:
-  #- `%{
-  #     :lock => :true,
-  #     "access_token" => "access_token",
-  #     "expires_in" => 21600,
-  #     "refresh_token" => "refresh_token",
-  #     "token_type" => "Bearer"
-  #  }`
-  #"""
-  @moduledoc :false
-  use GenServer
-  alias ExOvh.Hubic.HubicApi.Auth
-  @get_token_retries 20
-  @get_token_sleep_interval 300
-
-
-  #####################
-  # Public
-  #####################
-
-
-  @doc "Starts the genserver"
-  def start_link({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
-  end
-
-
-  @doc "Gets the access_token from the :ets table"
-  @spec get_token() :: String.t
-  def get_token(), do: get_token(ExOvh, 0)
-
-  @doc "Gets the access_token from the :ets table"
-  @spec get_token(client :: atom) :: String.t
-  def get_token(client), do: get_token(client, 0)
-
-  @doc "Retrieves the hubic config map"
-  def get_config(client) do
-    GenServer.call(gen_server_name(client), :get_config)
-  end
-
-
-  #####################
-  # Genserver Callbacks
-  #####################
-
-  # trap exits so that terminate callback is invoked
-  # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
-  def init({client, config, _opts}) do
-    Og.context(__ENV__, :debug)
-    :erlang.process_flag(:trap_exit, :true)
-    create_ets_table(client)
-    refresh_token = config.refresh_token
-    case refresh_token  do
-      :nil -> # RAISE AN EXCEPTION DUE TO UNAVAILABILITY OF THE REFRESH TOKEN
-        error = "Valid refresh token not available"
-        Og.log_return(error, :error)
-        raise error
-      refresh_token -> # TRY TO GET REFRESH TOKEN FROM THE CONFIG
-        tokens = get_latest_tokens(%{"refresh_token" => refresh_token}, config) |> Map.put(:lock, :false)
-        :ets.insert(ets_tablename(client), {:tokens, tokens})
-        Task.start_link(fn -> monitor_expiry(client, tokens["expires_in"]) end)
-        {:ok, {client, config, tokens}}
-    end
-  end
-
-  def handle_call(:add_lock, _from, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    new_tokens = Map.put(tokens, :lock, :true)
-    :ets.insert(ets_tablename(client), {:tokens, new_tokens})
-    {:reply, :ok, new_tokens}
-  end
-
-  def handle_call(:remove_lock, _from, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    new_tokens = Map.put(tokens, :lock, :false)
-    :ets.insert(ets_tablename(client), {:tokens, new_tokens})
-    {:reply, :ok, new_tokens}
-  end
-
-  def handle_call(:update_tokens, _from, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    new_tokens = get_latest_tokens(tokens, config)
-    |> Map.put(tokens, :lock, :false)
-    :ets.insert(ets_tablename(client), {:tokens, new_tokens})
-    {:reply, :ok, {client, new_tokens}}
-  end
-
-  def handle_call(:get_config, _from, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    {:reply, config, {client, config, tokens}}
-  end
-
-  def handle_call(:stop, _from, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    {:stop, :shutdown, :ok, {client, config, tokens}}
-  end
-
-  def terminate(:shutdown, {client, config, tokens}) do
-    Og.context(__ENV__, :debug)
-    :ets.delete(ets_tablename(client))
-    :ok
-  end
-
-
-  #####################
-  # Private
-  #####################
-
-  defp gen_server_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
-  defp ets_tablename(client), do: String.to_atom("Ets" <> Atom.to_string(gen_server_name(client)))
-
-  # get the token from the :ets table
-  defp get_token(client, index) do
-    Og.context(__ENV__, :debug)
-    if ets_tablename(client) in :ets.all() do
-      [tokens: tokens] = :ets.lookup(ets_tablename(client), :tokens)
-      if tokens.lock === :true do
-        if index > @get_token_retries do
-          raise "Problem retrieving the access token from ets table"
-        else
-          :timer.sleep(@get_token_sleep_interval)
-          get_token(client, index + 1)
-        end
-      else
-        tokens["access_token"]
-      end
-    else
-      if index > @get_token_retries do
-        raise "Problem retrieving the access token from ets table"
-      else
-        :timer.sleep(@get_token_sleep_interval)
-        get_token(client, index + 1)
-      end
-    end
-  end
-
-
-  # Returns a map in following format with the latest tokens:
-  # %{"access_token" => "access_token", "expires_in" => 21600, "refresh_token" => "refresh_token", "token_type" => "Bearer"}
-  defp get_latest_tokens(tokens, config) do
-    Og.context(__ENV__, :debug)
-    Auth.get_latest_access_token(tokens["refresh_token"], config)
-    |> Map.put("refresh_token", tokens["refresh_token"])
-  end
-
-  # Recursive function
-  # Modifies the gen_server state every time the access_token expiry is within 30 seconds of expiry.
-  # expires_in parameter is in seconds
-  # This function is used as a worker `Task` everytime the genserver is initialised.
-  defp monitor_expiry(client, expires_in) do
-    Og.context(__ENV__, :debug)
-    interval = (expires_in - 30) * 1000
-    :timer.sleep(interval)
-    {:reply, :ok, _state} = GenServer.call(gen_server_name(client), :add_lock)
-    {:reply, :ok, _state} = GenServer.call(gen_server_name(client), :update_tokens)
-    {:reply, :ok, state} = GenServer.call(gen_server_name(client), :remove_lock)
-    monitor_expiry(client, state["expires_in"])
-  end
-
-  # creates the ets table
-  defp create_ets_table(client) do
-    Og.context(__ENV__, :debug)
-    ets_options = [
-                   :set, # type
-                   :protected, # read - all, write this process only.
-                   :named_table,
-                   {:heir, :none}, # don't let any process inherit the table. when the ets table dies, it dies.
-                   {:write_concurrency, :false},
-                   {:read_concurrency, :true}
-                  ]
-    unless ets_tablename(client) in :ets.all() do
-      :ets.new(ets_tablename(client), ets_options)
-    end
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/hubic_api/request.ex b/lib/hubic/hubic_api/request.ex
deleted file mode 100644
index e3d4853..0000000
--- a/lib/hubic/hubic_api/request.ex
+++ /dev/null
@@ -1,48 +0,0 @@
-defmodule ExOvh.Hubic.HubicApi.Request do
-  @moduledoc :false
-  alias ExOvh.Hubic.HubicApi.Auth
-  alias ExOvh.Hubic.HubicApi.Cache, as: TokenCache
-
-
-  @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map, retries :: integer)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-
-  def request(client, {method, uri, params} = query, opts, retries \\ 0) do
-    {method, uri, options} = Auth.prepare_request(client, query)
-    Og.log_return({method, uri, options}, :debug)
-    resp = HTTPotion.request(method, uri, options)
-    |> Og.log_return(:debug)
-    if resp.status_code >= 100 and resp.status_code < 300 do
-      try do
-        {:ok, %{
-               body: resp.body |> Poison.decode!(),
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      rescue
-        _ ->
-        {:ok, %{
-               body: resp.body,
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      end
-    else
-      if Map.has_key?(resp.body, "error") do
-        if resp.body["error"] === "invalid_token" do
-          GenServer.call(TokenCache, :stop) # Restart the gen_server to recuperate state
-          unless retries >= 1, do: request(client, query, opts, 1) # Try request one more time
-        else
-          {:error, resp}
-        end
-      else
-        {:error, resp}
-      end
-    end
-
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/openstack_api/auth.ex b/lib/hubic/openstack_api/auth.ex
deleted file mode 100644
index 52f677d..0000000
--- a/lib/hubic/openstack_api/auth.ex
+++ /dev/null
@@ -1,42 +0,0 @@
-defmodule ExOvh.Hubic.OpenstackApi.Auth do
-  @moduledoc :false
-  alias ExOvh.Hubic.OpenstackApi.Cache
-
-  @methods [:get, :post, :put, :delete]
-  @timeout 10_000
-
-
-  ############################
-  # Public
-  ############################
-
-
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t)
-                     :: ExOvh.Client.query_t
-  def prepare_request(client, query)
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:get, :head, :delete] do
-    uri =  Cache.get_endpoint(client) <> uri
-    if params !== :nil and params !== "", do: uri = uri <> "?" <> URI.encode_query(params)
-    options = %{ headers: headers(client), timeout: @timeout }
-    {method, uri, options}
-  end
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:post, :put] do
-    uri =  Cache.get_endpoint(client) <> uri
-    if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
-    options = %{ body: params, headers: headers(client), timeout: @timeout }
-    {method, uri, options}
-  end
-
-
-
-  ############################
-  # Private
-  ############################
-
-
-  defp headers(client), do: %{ "X-Auth-Token": Cache.get_credentials_token(client) }
-
-
-end
diff --git a/lib/hubic/openstack_api/cache.ex b/lib/hubic/openstack_api/cache.ex
deleted file mode 100644
index e56e030..0000000
--- a/lib/hubic/openstack_api/cache.ex
+++ /dev/null
@@ -1,186 +0,0 @@
-defmodule ExOvh.Hubic.OpenstackApi.Cache do
-  @moduledoc :false
-  use GenServer
-  alias ExOvh.Hubic.HubicApi.Cache
-  alias ExOvh.Hubic.Request
-  @get_credentials_retries 10
-  @get_credentials_sleep_interval 150
-  @init_delay 2_000
-
-
-  #####################
-  # Public
-  #####################
-
-
-  @doc "Starts the genserver"
-  def start_link({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
-  end
-
-
-  def get_credentials(), do: get_credentials(ExOvh)
-  def get_credentials(client), do: get_credentials(client, 0)
-
-
-  def get_credentials_token(), do: get_credentials_token(ExOvh)
-  def get_credentials_token(client), do: get_credentials(client)["token"]
-
-
-  def get_endpoint(), do: get_endpoint(ExOvh)
-  def get_endpoint(client) do
-    credentials = get_credentials(client)
-    path = URI.parse(credentials["endpoint"])
-    |> Map.get(:path)
-    {version, account} = String.split_at(path, 4)
-    endpoint = List.first(String.split(credentials["endpoint"], account))
-    endpoint
-  end
-
-
-  def get_account(), do: get_account(ExOvh)
-  def get_account(client) do
-    credentials = get_credentials(client)
-    path = URI.parse(credentials["endpoint"])
-    |> Map.get(:path)
-    {version, account} = String.split_at(path, 4)
-    account
-  end
-
-
-  #####################
-  # Genserver Callbacks
-  #####################
-
-
-  # trap exits so that terminate callback is invoked
-  # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
-  def init({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    :erlang.process_flag(:trap_exit, :true)
-    token = Cache.get_token(client)
-    :timer.sleep(@init_delay) # give some time for TokenCache Genserver to initialize
-    create_ets_table(client)
-    {:ok, resp} = Request.request(client, {:get, "/account/credentials", :nil}, %{})
-    |> Og.log_return(:debug)
-    credentials = Map.put(resp.body, :lock, :false)
-    :ets.insert(ets_tablename(client), {:credentials, credentials})
-    expires = to_seconds(credentials["expires"])
-    Task.start_link(fn -> monitor_expiry(client, expires) end)
-    {:ok, {client, config, credentials}}
-  end
-
-
-  def handle_call(:add_lock, _from, {client, config, credentials}) do
-    Og.context(__ENV__, :debug)
-    new_credentials = Map.put(credentials, :lock, :true)
-    :ets.insert(ets_tablename(client), {:credentials, new_credentials})
-    {:reply, :ok, {client, config, new_credentials}}
-  end
-  def handle_call(:remove_lock, _from, {client, config, credentials}) do
-    Og.context(__ENV__, :debug)
-    new_credentials = Map.put(credentials, :lock, :false)
-    :ets.insert(ets_tablename(client), {:credentials, new_credentials})
-    {:reply, :ok, {client, config, new_credentials}}
-  end
-  def handle_call(:update_credentials, _from, {client, config, credentials}) do
-    Og.context(__ENV__, :debug)
-    {:ok, resp} = Request.request(client, {:get, "/account/credentials", ""}, %{})
-    new_credentials = resp.body
-    |> Map.put(credentials, :lock, :false)
-    :ets.insert(ets_tablename(client), {:credentials, new_credentials})
-    {:reply, :ok, {client, config, new_credentials}}
-  end
-  def handle_call(:stop, _from, state) do
-    Og.context(__ENV__, :debug)
-    {:stop, :shutdown, :ok, state}
-  end
-  def terminate(:shutdown, {client, config, credentials}) do
-    Og.context(__ENV__, :debug)
-    :ets.delete(ets_tablename(client)) # explicilty remove
-    :ok
-  end
-
-
-
-  #####################
-  # Private
-  #####################
-
-  defp gen_server_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
-  defp ets_tablename(client), do: String.to_atom("Ets" <> Atom.to_string(gen_server_name(client)))
-
-
-  defp get_credentials(client, index) do
-    Og.context(__ENV__, :debug)
-    if ets_tablename(client) in :ets.all() do
-      [credentials: credentials] = :ets.lookup(ets_tablename(client), :credentials)
-      if credentials.lock === :true do
-        if index > @get_credentials_retries do
-          raise "Problem retrieving the openstack credentials from ets table"
-        else
-          :timer.sleep(@get_credentials_sleep_interval)
-          get_credentials(client, index + 1)
-        end
-      else
-        credentials
-      end
-    else
-      if index > @get_credentials_retries do
-        raise "Problem retrieving the openstack credentials from ets table"
-      else
-        :timer.sleep(@get_credentials_sleep_interval)
-        get_credentials(client, index + 1)
-      end
-    end
-  end
-
-
-  defp monitor_expiry(client, expires) do
-    Og.context(__ENV__, :debug)
-    interval = (expires - 30) * 1000
-    :timer.sleep(interval)
-    {:reply, :ok, _credentials} = GenServer.call(gen_server_name(client), :add_lock)
-    {:reply, :ok, _credentials} = GenServer.call(gen_server_name(client), :update_credentials)
-    {:reply, :ok, credentials} = GenServer.call(gen_server_name(client), :remove_lock)
-    expires = to_seconds(credentials["expires"])
-    monitor_expiry(client, expires)
-  end
-
-
-  defp create_ets_table(client) do
-    Og.context(__ENV__, :debug)
-    ets_options = [
-                   :set, # type
-                   :protected, # read - all, write this process only.
-                   :named_table,
-                   {:heir, :none}, # don't let any process inherit the table. when the ets table dies, it dies.
-                   {:write_concurrency, :false},
-                   {:read_concurrency, :true}
-                  ]
-    unless ets_tablename(client) in :ets.all() do
-      :ets.new(ets_tablename(client), ets_options)
-    end
-  end
-
-
-  defp to_seconds(iso_time) do
-    {:ok, expiry_ndt, offset} = Calendar.NaiveDateTime.Parse.iso8601(iso_time)
-    offset =
-    case offset do
-      :nil -> 0
-      offset -> offset
-    end
-    {:ok, expiry_dt_utc} = Calendar.NaiveDateTime.with_offset_to_datetime_utc(expiry_ndt, offset)
-    {:ok, now} = Calendar.DateTime.from_erl(:calendar.universal_time(), "UTC")
-    {:ok, seconds, _microseconds, _when} = Calendar.DateTime.diff(expiry_dt_utc, now)
-    if seconds > 0 do
-      seconds
-    else
-      0
-    end
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/openstack_api/request.ex b/lib/hubic/openstack_api/request.ex
deleted file mode 100644
index a4e9793..0000000
--- a/lib/hubic/openstack_api/request.ex
+++ /dev/null
@@ -1,40 +0,0 @@
-defmodule ExOvh.Hubic.OpenstackApi.Request do
-  @moduledoc :false
-  alias ExOvh.Hubic.OpenstackApi.Cache
-  alias ExOvh.Hubic.OpenstackApi.Auth
-
-
-  @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request(client, {method, uri, params} = query, opts) do
-    Og.context(__ENV__, :debug)
-    {method, uri, options} = Auth.prepare_request(client, query)
-    |> Og.log_return(:debug)
-    resp = HTTPotion.request(method, uri, options)
-    |> Og.log_return(:debug)
-
-    if resp.status_code >= 100 and resp.status_code < 300 do
-      try do
-        {:ok, %{
-               body: resp.body |> Poison.decode!(),
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      rescue
-        _ ->
-        {:ok, %{
-               body: resp.body,
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      end
-    else
-     {:error, resp}
-    end
-
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/request.ex b/lib/hubic/request.ex
deleted file mode 100644
index 260f9ea..0000000
--- a/lib/hubic/request.ex
+++ /dev/null
@@ -1,66 +0,0 @@
-defmodule ExOvh.Hubic.Request do
-  @moduledoc :false
-  @doc ~S"""
-  Houses the `request` function which delegates the function call to the appropriate
-  module & function depending on the `opts` key-values.
-
-  Hubic uses it's own custom api and also separate Openstack compliant apis so
-  and these apis are quite different.
-  Therefore, the request needs to be routed to the correct `request` function so
-  that the correct auth credentials are put into the `options_t` in the returned
-  `ExOvh.Client.query_t` query tuple.
-
-  ## Examples of what some delegation depending on opts
-
-      ExOvh.hubic_request(query, %{} = opts)
-      calls
-      ExOvh.Hubic.HubicApi.Request.request(ExOvh, query, opts)
-
-  -
-
-      ExOvh.hubic_request(query, %{ openstack: :true } = opts)
-      calls
-      ExOvh.Hubic.OpenstackApi.Request.request(ExOvh, query, opts)
-
-
-  ## Subsequent Request modules
-
-  The subsequent request functions process the request by
-
-  1. Calling the appropriate `prepare_request` function which has been delegated to.
-  2. Making the actual request with `HTTPotion`
-  3. Returning the response as `{:ok, response_t}` or `{:error, response_t}`
-  """
-  alias ExOvh.Hubic.HubicApi.Request, as: Hubic
-  alias ExOvh.Hubic.OpenstackApi.Request, as: Open
-
-
-  @doc ~S"""
-  Delegates the function call to the appropriate module & function depending on the `opts` key-values.
-
-  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
-
-  ## Options
-
-      { } = opts
-
-  The function call will be delegated to `ExOvh.Hubic.HubicApi.Request` and processed as a hubic api request.
-
-      { openstack: :true } = opts
-
-  The function call will be delegated to `ExOvh.Hubic.OpenstackApi.Request`.
-
-  `openstack: :true` - boolean - indicates whether the request is an openstack one or not.
-  """
-  @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request(client, {method, uri, params} = query, %{ openstack: :true } = opts) do
-    Open.request(client, query, opts)
-  end
-
-  def request(client, {method, uri, params} = query, opts) do
-    Hubic.request(client, query, opts)
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/request_helpers.ex b/lib/hubic/request_helpers.ex
deleted file mode 100644
index 2ca74a8..0000000
--- a/lib/hubic/request_helpers.ex
+++ /dev/null
@@ -1,86 +0,0 @@
-defmodule ExOvh.Hubic.RequestHelpers do
-  @moduledoc ~S"""
-  Helper functions for making requests to the hubic custom api and hubic openstack api.
-  """
-  import ExOvh.Query.Openstack.Swift
-  alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-
-
-  @doc ~S"""
-  Gets a list of all openstack swift containers for the hubic app
-
-  Returns `{:ok, [<container_name>, <container_name> ...]`
-  or
-  Returns `{:error, resp}`
-
-  ## Example
-
-      alias ExOvh.Hubic.RequestHelpers
-      client = ExOvh # Enter your client here
-      RequestHelpers.containers(client)
-  """
-  @spec containers(client :: atom)
-                   :: {:ok, [String.t]} | {:error, ExOvh.Client.response_t}
-  def containers(client) do
-    account = OpenCache.get_account(client)
-    case ExOvh.hubic_request(account_info(account), %{ openstack: :true }) do
-      {:ok, resp} ->
-        Og.log_return(resp)
-        {:ok, resp.body |> Enum.map(fn(%{"name" => container}) -> container end)}
-      {:error, resp} ->
-        {:error, resp}
-    end
-  end
-
-
-  @doc ~S"""
-  Gets a list of all objects by name in an openstack swift container for the hubic app
-  Allows to filter the returned list by hash or by name depending on the filter used.
-
-  Returns `{:ok, [<object_name>, <object_name> ...]`
-  or
-  Returns `{:error, resp}`
-
-  ## Example
-
-      alias ExOvh.Hubic.RequestHelpers
-      client = ExOvh
-      container = "new_container"
-      RequestHelpers.get_objects(client, container, :name)
-
-
-  ## Example
-
-      alias ExOvh.Hubic.RequestHelpers
-      client = ExOvh
-      container = "new_container"
-      RequestHelpers.get_objects(client, container, :hash)
-  """
-  @spec get_objects(client :: atom, container :: String.t, filter :: atom)
-                   :: {:ok, [String.t]} | {:error, ExOvh.Client.response_t}
-  def get_objects(client, container, filter)
-
-  def get_objects(client, container, :name) do
-    account = OpenCache.get_account(client)
-    case ExOvh.hubic_request(get_objects(account, container), %{ openstack: :true }) do
-      {:ok, resp} ->
-        Og.log_return(resp)
-        {:ok, resp.body |> Enum.map(fn(%{"name" => object_name}) -> object_name end)}
-      {:error, resp} ->
-        {:error, resp}
-    end
-  end
-
-  def get_objects(client, container, :hash) do
-    account = OpenCache.get_account(client)
-    case ExOvh.hubic_request(get_objects(account, container), %{ openstack: :true }) do
-      {:ok, resp} ->
-        Og.log_return(resp)
-        {:ok, resp.body |> Enum.map(fn(%{"hash" => object_hash}) -> object_hash end)}
-      {:error, resp} ->
-        {:error, resp}
-    end
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/hubic/supervisor.ex b/lib/hubic/supervisor.ex
deleted file mode 100644
index 76b7602..0000000
--- a/lib/hubic/supervisor.ex
+++ /dev/null
@@ -1,31 +0,0 @@
-defmodule ExOvh.Hubic.Supervisor do
-  @moduledoc :false
-  use Supervisor
-  alias ExOvh.Hubic.HubicApi.Cache, as: TokenCache
-  alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenstackCache
-
-  #####################
-  # Public
-  #####################
-
-  def start_link(client, config, opts) do
-    Og.context(__ENV__, :debug)
-    Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
-  end
-
-  #####################
-  # Supervisor Callbacks
-  #####################
-
-  def init({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    workers = [
-                {TokenCache, {TokenCache, :start_link, [{client, config, opts}]}, :permanent, 15000, :worker, [TokenCache]},
-                {OpenstackCache, {OpenstackCache, :start_link, [{client, config, opts}]}, :permanent, 20000, :worker, [OpenstackCache]}
-              ]
-    supervise(workers, strategy: :one_for_one, max_restarts: 20)
-  end
-
-  defp supervisor_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
-
-end
diff --git a/lib/mix/tasks/hubic.ex b/lib/mix/tasks/hubic.ex
deleted file mode 100644
index 79a5793..0000000
--- a/lib/mix/tasks/hubic.ex
+++ /dev/null
@@ -1,255 +0,0 @@
-defmodule Mix.Tasks.Hubic do
-  @moduledoc ~S"""
-  A mix task that generates the hubic application refresh token on the user's behalf.
-
-  ## Steps
-
-  - The user needs to go to https://hubic.com/ and set up an account and retrieve a username and password.
-  - Then the user is prompted to do some activations.
-  - Upon completion of activations, the user needs to create an application in the hubic website.
-  - With the username, password, client_id, client_secret and redirect url from the recently created application,
-  a mixtask can be run which will apply the scope of the user and get the refresh_token on the user's behalf.
-
-  The mix task can be run as follows in a linux terminal:
-
-  ```shell
-  mix hubic
-  --login=<login>
-  --password=<password>
-  --clientid=<client_id>
-  --clientsecret=<client_secret>
-  --redirecturi=<uri>
-  ```
-
-  ## Shell Output
-
-  ```elixir
-  %{
-  client_id: "<client_id>",
-  client_secret: "<client_secret>",
-  refresh_token: "<refresh_token>",
-  redirect_uri: "<uri>"
-  }
-  ```
-
-  This map can then be manually added by the user to the `config/prod.secret.exs` file
-
-  ```
-  config :test_os, TestOs.ExOvh,
-    ovh: :nil
-    hubic:   %{
-              client_id: "<client_id>",
-              client_secret: "<client_secret>",
-              refresh_token: "<refresh_token>",
-              redirect_uri: "<uri>"
-             }
-  ```
-
-  - Then the hubic configuration is complete. Start up the app and the hubic wrapper is ready.
-  """
-  use Mix.Task
-  alias ExOvh.Hubic.Defaults
-  @hubic_auth_uri Defaults.hubic()[:auth_uri]
-  @hubic_token_uri Defaults.hubic()[:token_uri]
-  @timeout 20_000
-
-
-  ##########################
-  # Public
-  #########################
-
-
-  def run(args) do
-    Og.log_return(args, :debug)
-    opts_map = parse_args(args)
-    Og.log_return(opts_map, :debug)
-    IO.inspect(opts_map, pretty: :true)
-    Mix.Shell.IO.info("")
-    Mix.Shell.IO.info("The details in the map above will be used to get the hubic refresh token.")
-    Mix.Shell.IO.info("")
-    if Mix.Shell.IO.yes?("Do you want to proceed?") do
-      Application.start(:ibrowse, :permanent)
-      Application.start(:httpotion, :permanent)
-      options = get_auth_code(opts_map) |> get_refresh_token() |> remove_private()
-      message = "
-      %{
-        client_id: \"#{options.client_id}\",
-        client_secret: \"#{options.client_secret}\",
-        refresh_token: \"#{options.refresh_token}\",
-        redirect_uri: \"#{options.redirect_uri}\"
-       }
-      "
-      Mix.Shell.IO.info(message)
-    end
-  end
-
-
-  ##########################
-  # Private
-  #########################
-
-
-  defp parse_args(args) do
-    {opts, _, _} = OptionParser.parse(args)
-    Og.log_return(opts, :debug)
-    {opts, opts_map} = opts
-    |> has_required_args()
-    |> parsers_login()
-    |> parsers_password()
-    |> parsers_client_id()
-    |> parsers_client_secret()
-    |> parsers_redirect_uri()
-    opts_map
-  end
-
-  defp has_required_args(opts) do
-    login = Keyword.get(opts, :login, :nil)
-    if login === :nil do
-      raise "Task requires login argument"
-    end
-    password = Keyword.get(opts, :password, :nil)
-    if password === :nil do
-      raise "Task requires password argument"
-    end
-    client_id = Keyword.get(opts, :clientid, :nil)
-    if client_id === :nil do
-      raise "Task requires client_id argument"
-    end
-    client_secret = Keyword.get(opts, :clientsecret, :nil)
-    if client_secret === :nil do
-      raise "Task requires client_secret argument"
-    end
-    redirect_uri = Keyword.get(opts, :redirecturi, :nil)
-    if redirect_uri === :nil do
-      raise "Task requires redirect_uri argument"
-    end
-    {opts, %{}}
-  end
-
-
-  defp parsers_login({opts, acc}), do: {opts, Map.merge(acc, %{login: Keyword.fetch!(opts, :login)}) }
-  defp parsers_password({opts, acc}), do: {opts, Map.merge(acc, %{ password: Keyword.fetch!(opts, :password)}) }
-  defp parsers_client_id({opts, acc}), do: {opts, Map.merge(acc, %{ client_id: Keyword.fetch!(opts, :clientid)}) }
-  defp parsers_client_secret({opts, acc}), do: {opts, Map.merge(acc, %{ client_secret: Keyword.fetch!(opts, :clientsecret)}) }
-  defp parsers_redirect_uri({opts, acc}), do: {opts, Map.merge(acc, %{ redirect_uri: Keyword.fetch!(opts, :redirecturi)}) }
-
-
-  # - Summary: Gets the authorisation code when the refresh token is not provided in config.exs by the user
-  # - Makes a request to the @hubic_auth_uri with the client id and scopes for the code
-  # - Autocompletes the form information to acquire the code
-  # - Sends the application/x-www-form-urlencoded information to the @hubic_auth_uri on behalf of the user
-  # - Parses and returns the authorisation code inside the opts_map
-  defp get_auth_code(opts_map) do
-    Og.context(__ENV__, :debug)
-    query_string = "?client_id=" <> opts_map.client_id <>
-                   "&redirect_uri=" <> URI.encode_www_form(opts_map.redirect_uri) <>
-                   "&scope=" <> "usage.r,account.r,getAllLinks.r,credentials.r,sponsorCode.r,activate.w,sponsored.r,links.drw" <>
-                   "&response_type=" <> "code" <>
-                   "&state=" <> SecureRandom.urlsafe_base64(10)
-    options = %{ timeout: @timeout }
-    uri = @hubic_auth_uri <> query_string
-    resp = HTTPotion.request(:get, uri, options)
-    resp =
-    %{
-      body: resp.body,
-      headers: resp.headers,
-      status_code: resp.status_code
-     }
-    inputs = get_validated_inputs(resp.body)
-    {req_body, _, _} = Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({"input", input, _}, acc) ->
-      name = :proplists.get_value("name", input)
-      value = ""
-      {name, value} =
-      case name do
-        "login" ->
-          value = opts_map.login
-          {name, value}
-        "user_pwd" ->
-          value = opts_map.password
-          {name, value}
-        _ ->
-          value = :proplists.get_value("value", input)
-          {name, value}
-      end
-      param =  name <> "=" <> value
-      {acc, index, max} = acc
-      if index === max do
-        acc = acc <> param
-      else
-        acc = acc <> param <> "&"
-      end
-      {acc, index + 1, max}
-    end)
-
-    req_body = req_body <> "&links=d" # bug fix: *delete links needed - unknown why not in inputs already*
-    options = %{ body: req_body, headers: %{ "Content-Type": "application/x-www-form-urlencoded" } }
-    resp = HTTPotion.request(:post, @hubic_auth_uri, options)
-
-    if resp.status_code !== 302, do: raise Floki.find(resp.body, "h4.text-error") |> Floki.text
-
-    resp =
-    %{
-      body: resp.body,
-      headers: resp.headers  |> Enum.into(%{}),
-      status_code: resp.status_code
-    }
-
-    code = resp.headers
-    |> Map.get(:Location)
-    |> URI.parse
-    |> Map.get(:query)
-    |> URI.decode_query
-    |> Map.get("code")
-    Map.merge(opts_map, %{ auth_code: code })
-  end
-
-
-  defp get_validated_inputs(resp_body) do
-    Og.context(__ENV__, :debug)
-    inputs = Floki.find(resp_body, "form input[type=text], form input[type=password], form input[type=checkbox], form input[type=hidden]")
-    |> List.flatten()
-    if Enum.any?(inputs, fn(input) -> input === [] end), do: raise "Empty input found"
-    inputs
-  end
-
-  #- Adds the refresh_token to the opts_map
-  @spec get_refresh_token(opts_map :: map) :: map
-  defp get_refresh_token(opts_map) do
-    Og.context(__ENV__, :debug)
-    auth_credentials = opts_map.client_id <> ":" <> opts_map.client_secret
-    auth_credentials_base64 = Base.encode64(auth_credentials)
-    req_body = "code=" <> opts_map.auth_code <>
-               "&redirect_uri=" <> URI.encode_www_form(opts_map.redirect_uri) <>
-               "&grant_type=authorization_code"
-    headers = %{
-               "Content-Type": "application/x-www-form-urlencoded",
-               "Authorization": "Basic " <> auth_credentials_base64
-              }
-    options = %{ body: req_body, headers: headers, timeout: @timeout }
-    resp = HTTPotion.request(:post, @hubic_token_uri, options)
-    now_milli_seconds = :os.system_time(:milli_seconds)
-    body =
-    %{
-      body: resp.body |> Poison.decode!(),
-      headers: resp.headers,
-      status_code: resp.status_code
-    }
-    |> Map.get(:body)
-    if Map.has_key?(body, "error") do
-      error = Map.get(resp, "error") <> " :: " <> Map.get(resp, "error_description")
-      raise error
-    end
-    refresh_token = Map.get(body, "refresh_token")
-    Map.merge(opts_map, %{ refresh_token: refresh_token })
-  end
-
-
-  defp remove_private(opts_map) do
-    opts_map |> Map.delete(:login) |> Map.delete(:password) |> Map.delete(:auth_code)
-  end
-
-
-end
-
-
-
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index 5d212ba..c835415 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -1,6 +1,7 @@
 defmodule Mix.Tasks.Ovh do
+  @shortdoc "Create a new app and new credentials for accessing ovh api"
   @moduledoc ~S"""
-  A mix task that generates the hubic application refresh token on the user's behalf.
+  A mix task that generates the ex_ovh application secrets on the user's behalf.
 
   ## Steps
 
@@ -13,123 +14,69 @@ defmodule Mix.Tasks.Ovh do
   - Then the user can create an application at `https://eu.api.ovh.com/createApp/` or
     alternatively the user can use this mix task to generate the application:
 
-  ## Example
+  ## Examples
 
   Create an app with access to all apis:
 
+      mix ovh \
+      --login=<username> \
+      --password=<password> \
+      --appname='ex_ovh'
 
-  ```shell
-  mix ovh
-  --login=<username>
-  --password=<password>
-  ```
-
-  Uses defaults:
-  ```
-  app name - ex_ovh,
-  app description - ex_ovh,
-  redirect_uri - "",
-  api_version - "1.0",
-  endpoint - "ovh-eu"
-  ```
+  Output:
 
+      config :ex_ovh,
+        ovh: %{
+          application_key: System.get_env("EX_OVH_APPLICATION_KEY"),
+          application_secret: System.get_env("EX_OVH_APPLICATION_SECRET"),
+          consumer_key: System.get_env("EX_OVH_CONSUMER_KEY"),
+          endpoint: System.get_env("EX_OVH_ENDPOINT"),
+          api_version: System.get_env("EX_OVH_API_VERSION") || "1.0",
+          connect_timeout: 30000, # 30 seconds
+          connect_timeout: (60000 * 30) # 30 minutes
+        }
 
-  ## Example
 
   Create an app with access to all apis with specific app name and description:
 
-
-  ```shell
-  mix ovh
-  --login=<username>
-  --password=<password>
-  --appname='My app'
-  --appdesc='my app for api'
-  ```
-
-  Uses defaults:
-  ```
-  redirect_uri - "",
-  api_version - "1.0",
-  endpoint - "ovh-eu"
-  ```
-
-  ## Example
-
-  Create an app with access to all apis with specific everything:
-
-
-  ```shell
-  mix ovh
-  --login=<username>
-  --password=<password>
-  --appname='My app'
-  --appdesc='my app for api'
-  --endpoint=ovh-eu
-  --apiversion=1.0
-  --redirect_uri='http://localhost:4000/',
-  --accessrules='get-[/*]::put-[/me,/cdn]::post-[/me,/cdn]::delete-[]'
-  ```
-
-
-  A note on access rules:
-
-  The default for access rules will give your ovh application access to *all* of the api calls.
-  More than likely this is not a good idea. To limit the number of api endpoints available, generate access
-  rules using the commandline arguments as seen in the example above.
-
-
-  ## Shell Output
-
-  A map is printed to the shell as follows:
-
-  ```elixir
-  %{
-  application_key: "<app_key>",
-  application_secret: "<app_secret>",
-  consumer_key: "<consumer_secret>",
-  endpoint: "ovh-eu",
-  api_version: "1.0"
-  }
-  ```
-
-  - This map can then be manually added by the user to the `config/prod.secret.exs` file
-
-  ```
-  config :test_os, TestOs.ExOvh,
-  ovh: %{
-        application_key: "<app_key>",
-        application_secret: "<app_secret>",
-        consumer_key: "<consumer_secret>",
-        endpoint: "ovh-eu",
-        api_version: "1.0"
-       },
-  hubic: :nil
-  ```
-
-  - Then the ovh configuration is complete. Start up the app and the ovh wrapper is ready.
+      mix ovh \
+      --login=<username> \
+      --password=<password> \
+      --appdescription='my app for api' \
+      --endpoint='ovh-eu' \
+      --apiversion='1.0' \
+      --redirect_uri='http://localhost:4000/' \
+      --accessrules='get-[/*]::put-[/me,/cdn]::post-[/me,/cdn]::delete-[]' \
+      --appname='my_app'
+
+  Output:
+
+      config :my_app, MyApp.ExOvh,
+          ovh: %{
+            application_key: System.get_env("MY_APP_EX_OVH_APPLICATION_KEY"),
+            application_secret: System.get_env("MY_APP_EX_OVH_APPLICATION_SECRET"),
+            consumer_key: System.get_env("MY_APP_EX_OVH_CONSUMER_KEY"),
+            endpoint: System.get_env("MY_APP_EX_OVH_ENDPOINT"),
+            api_version: System.get_env("MY_APP_EX_OVH_API_VERSION") || "1.0",
+            connect_timeout: 30000, # 30 seconds
+            connect_timeout: (60000 * 30) # 30 minutes
+          }
+
+  ## Notes
+
+  - Access rules: The default for access rules will give your ovh application access to *all* of the api calls. More
+  than likely this is not a good idea. To limit the number of api endpoints available, generate access rules using
+  the commandline arguments as seen in the example above.
   """
   use Mix.Task
-  alias ExOvh.Ovh.Defaults
-  alias ExOvh.Ovh.Auth
-  import ExOvh.Query.Ovh.Webstorage, only: [get_all_webstorage: 0]
+  alias ExOvh.Utils
 
-  @shortdoc "Create a new app and new credentials for accessing ovh api"
-  @default_headers %{ "Content-Type": "application/json; charset=utf-8" }
-  @timeout 10_000
 
-  defp endpoint(config), do: Defaults.endpoints()[config[:endpoint]]
-  defp access_rules(config), do: config[:access_rules]
-  defp api_version(config), do: config[:api_version]
-  defp app_secret(config), do: config[:application_secret]
-  defp app_key(config), do: config[:application_key]
-  defp default_create_app_uri(config), do: endpoint(config) <> "createApp/"
-  defp consumer_key_uri(config), do: endpoint(config) <> api_version(config) <> "/auth/credential/"
+  @default_headers [{"Content-Type", "application/json; charset=utf-8"}]
+  @default_options [ timeout: 30000, recv_timeout: (60000 * 1) ]
 
 
-  ##########################
   # Public
-  #########################
 
 
   def run(args) do
@@ -139,20 +86,21 @@ defmodule Mix.Tasks.Ovh do
     Mix.Shell.IO.info("The details in the map above will be used to create the ovh application.")
     Mix.Shell.IO.info("")
     if Mix.Shell.IO.yes?("Do you want to proceed?") do
-      Application.start(:ibrowse, :permanent)
-      Application.start(:httpotion, :permanent)
+      HTTPoison.start
       opts_map = parse_args(args)
-      options = get_credentials(opts_map)
-      message = "
-      %{
-        application_key: \"#{options.application_key}\",
-        application_secret: \"#{options.application_secret}\",
-        consumer_key: \"#{options.consumer_key}\",
-        endpoint: \"#{options.endpoint}\",
-        api_version: \"#{options.api_version}\"
-       }
-       "
-       Mix.Shell.IO.info(message)
+
+      message = get_credentials(opts_map)
+      |> remove_private()
+      |> create_or_update_env_file()
+      |> print_config()
+
+      Mix.Shell.IO.info(message)
+      Mix.Shell.IO.info("")
+      Mix.Shell.IO.info("Update your environment variables and your set.")
+      Mix.Shell.IO.info("")
+      Mix.Shell.IO.info("For example: ")
+      Mix.Shell.IO.info("")
+      Mix.Shell.IO.info("source .env")
     end
   end
 
@@ -175,6 +123,7 @@ defmodule Mix.Tasks.Ovh do
     |> parsers_app_name()
     |> parsers_app_desc()
     |> parsers_access_rules()
+    |> parsers_client_name()
     opts_map
   end
 
@@ -189,11 +138,17 @@ defmodule Mix.Tasks.Ovh do
       raise "Task requires password argument"
     end
     {opts, %{}}
+    client_name = Keyword.get(opts, :appname, :ex_ovh)
+    if client_name === :nil do
+      raise "Task requires appname argument"
+    end
+    {opts, %{}}
   end
 
 
   defp parsers_login({opts, acc}), do: {opts, Map.merge(acc, %{login: Keyword.fetch!(opts, :login)}) }
   defp parsers_password({opts, acc}), do: {opts, Map.merge(acc, %{ password: Keyword.fetch!(opts, :password)}) }
+  defp parsers_client_name({opts, acc}), do: {opts, Map.merge(acc, %{ client_name: Keyword.fetch!(opts, :appname)}) }
   defp parsers_endpoint({opts, acc}) do
     endpoint = Keyword.get(opts, :endpoint, :nil)
     if endpoint === :nil do
@@ -223,7 +178,7 @@ defmodule Mix.Tasks.Ovh do
     {opts, Map.merge(acc, %{ application_name: application_name }) }
   end
   defp parsers_app_desc({opts, acc}) do
-    application_description = Keyword.get(opts, :appdesc, :nil)
+    application_description = Keyword.get(opts, :appdescription, :nil)
     if application_description === :nil do
       application_description = "ex_ovh"
     end
@@ -232,7 +187,7 @@ defmodule Mix.Tasks.Ovh do
   defp parsers_access_rules({opts, acc}) do
     access_rules = Keyword.get(opts, :accessrules, :nil)
     if access_rules === :nil do
-      access_rules = Defaults.access_rules()
+      access_rules = Utils.access_rules()
     else
       access_rules = access_rules
       |> String.split("::")
@@ -263,11 +218,14 @@ defmodule Mix.Tasks.Ovh do
 
   defp get_app_create_page(opts_map) do
     Og.context(__ENV__, :debug)
-    options = [ timeout: @timeout ]
-    default_create_app_uri(opts_map)
-    %HTTPotion.Response{body: resp_body, headers: headers, status_code: status_code} =
-      HTTPotion.request(:get, default_create_app_uri(opts_map), options)
-    resp_body
+
+    method = :get
+    uri = Utils.default_create_app_uri(opts_map)
+    body = ""
+    headers = []
+    options = @default_options
+    resp = HTTPoison.request!(method, uri, body, headers, options)
+    Map.get(resp, :body)
   end
 
 
@@ -313,17 +271,30 @@ defmodule Mix.Tasks.Ovh do
 
   defp send_app_request(req_body, opts_map) do
     Og.context(__ENV__, :debug)
-    uri = Defaults.endpoints()[opts_map.endpoint] <> "createApp/"
-    resp = HTTPotion.request(:post, uri, [body: req_body, headers: ["Content-Type": "application/x-www-form-urlencoded"]])
-    error_msg1 = "There is already an application with that name for that Account ID"
+
+    method = :post
+    uri = Utils.endpoints()[opts_map.endpoint] <> "createApp/"
+    body = req_body
+    headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
+    options = @default_options
+    resp = HTTPoison.request!(method, uri, body, headers, options)
+
+    resp.body
+    |> Og.log_return(__ENV__, :warn)
+
+    error_msg1 =
+    # Error checking
     cond do
-     String.contains?(resp.body, error_msg1) ->
-      raise error_msg1
+     String.contains?(resp.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") ->
+      raise(msg <> ", try adding '-ovh' to the end of the login")
      String.contains?(resp.body, "Application created") ->
       resp.body
      true ->
       raise "unknown error"
     end
+
   end
 
 
@@ -352,24 +323,32 @@ defmodule Mix.Tasks.Ovh do
 
   defp get_consumer_key(%{access_rules: access_rules, redirect_uri: redirect_uri} = opts_map) do
     Og.context(__ENV__, :debug)
-    body = %{ accessRules: access_rules, redirection: redirect_uri }
-    # {method, uri, options} = Auth.ovh_prepare_request(ExOvh, query, %{})
-    options = %{ body: Poison.encode!(body), headers: Map.merge(@default_headers, %{ "X-Ovh-Application": app_key(opts_map) } ), timeout: @timeout }
-    |> Og.log_return(:debug)
 
-    Og.log_return(consumer_key_uri(opts_map), :debug)
-    Og.log_return(options, :debug)
+    method = :post
+    uri = Utils.consumer_key_uri(opts_map)
+    body = %{ accessRules: access_rules, redirection: redirect_uri } |> Poison.encode!()
+    headers = Map.merge(Enum.into(@default_headers, %{}), Enum.into([{"X-Ovh-Application", Utils.app_key(opts_map)}], %{})) |> Enum.into([])
+    options = @default_options
+    resp = HTTPoison.request!(method, uri, body, headers, options)
 
-    body = HTTPotion.request(:post, consumer_key_uri(opts_map), options) |> Map.get(:body) |> Poison.decode!()
+    body = Poison.decode!(Map.get(resp, :body))
     {Map.get(body, "consumerKey"), Map.get(body, "validationUrl")}
   end
 
 
   defp bind_consumer_key_to_app({ck, validation_url}, opts_map) do
-      HTTPotion.request(:get, validation_url) |> Map.get(:body)
-      |> get_bind_ck_to_app_inputs()
-      |> build_ck_binding_request(opts_map)
-      |> send_ck_binding_request(validation_url, ck)
+
+    method = :get
+    uri = validation_url
+    body = ""
+    headers = []
+    options = @default_options
+    resp = HTTPoison.request!(method, uri, body, headers, options)
+
+    Map.get(resp, :body)
+    |> get_bind_ck_to_app_inputs()
+    |> build_ck_binding_request(opts_map)
+    |> send_ck_binding_request(validation_url, ck)
   end
 
 
@@ -425,7 +404,15 @@ defmodule Mix.Tasks.Ovh do
 
   defp send_ck_binding_request(req_body, validation_url, ck) do
     Og.context(__ENV__, :debug)
-    resp = HTTPotion.request(:post, validation_url, [body: req_body, headers: ["Content-Type": "application/x-www-form-urlencoded"]])
+
+
+    method = :post
+    uri = validation_url
+    body = req_body
+    headers = [{"Content-Type", "application/x-www-form-urlencoded"}]
+    options = @default_options
+    resp = HTTPoison.request!(method, uri, body, headers, options)
+
     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}"
     cond do
@@ -436,6 +423,7 @@ defmodule Mix.Tasks.Ovh do
      true ->
       raise error_msg1
     end
+
   end
 
 
@@ -453,4 +441,72 @@ defmodule Mix.Tasks.Ovh do
   end
 
 
+  defp remove_private(opts_map) do
+    opts_map |> Map.delete(:login) |> Map.delete(:password)
+  end
+
+
+  defp config_names(client_name) do
+    {config_header, mod_client_name} =
+    case client_name  do
+      "ex_ovh" ->
+        {
+          ":" <> client_name,
+          "EX_OVH_"
+        }
+      other ->
+        {
+          ":" <> client_name <> ", " <> Macro.camelize(client_name) <> "." <> "ExOvh",
+          String.upcase(other) <> "_EX_OVH_"
+        }
+    end
+    {config_header, mod_client_name}
+  end
+
+  defp create_or_update_env_file(options) do
+    env_path = ".env"
+    File.touch!(env_path)
+    existing = File.read!(env_path)
+    {_config_header, mod_client_name} = config_names(options.client_name)
+    format_date = ExOvh.Utils.formatted_date()
+    new = existing <>
+    ~s"""
+
+    # updated on #{format_date}
+    export #{mod_client_name <> "APPLICATION_KEY"}=\"#{options.application_key}\"
+    export #{mod_client_name <> "APPLICATION_SECRET"}="#{options.application_secret}\"
+    export #{mod_client_name <> "CONSUMER_KEY"}="#{options.consumer_key}\"
+    export #{mod_client_name <> "ENDPOINT"}=\"#{options.endpoint}\"
+    export #{mod_client_name <> "API_VERSION"}=\"#{options.api_version}\"
+
+    """
+    {:ok, file} = File.open(env_path, [:write, :utf8])
+    IO.binwrite(file, new)
+    File.close(file)
+    options
+  end
+
+
+  defp print_config(options) do
+    client_name = options.client_name
+    {config_header, mod_client_name} = config_names(client_name)
+
+    ~s"""
+
+    Add the following paragraph to your config.exs file(s):
+
+    config #{config_header},
+        ovh: %{
+          application_key: System.get_env(\"#{mod_client_name <> "APPLICATION_KEY"}\"),
+          application_secret: System.get_env(\"#{mod_client_name <> "APPLICATION_SECRET"}\"),
+          consumer_key: System.get_env(\"#{mod_client_name <> "CONSUMER_KEY"}\"),
+          endpoint: System.get_env(\"#{mod_client_name <> "ENDPOINT"}\"),
+          api_version: System.get_env(\"#{mod_client_name <> "API_VERSION"}\") || "1.0",
+          connect_timeout: 30000, # 30 seconds
+          connect_timeout: (60000 * 30) # 30 minutes
+        }
+    """
+  end
+
+
 end
\ No newline at end of file
diff --git a/lib/ovh/auth.ex b/lib/ovh/auth.ex
deleted file mode 100644
index 00b1163..0000000
--- a/lib/ovh/auth.ex
+++ /dev/null
@@ -1,69 +0,0 @@
-defmodule ExOvh.Ovh.Auth do
-  @moduledoc :false
-  @doc ~s"""
-  Houses the `prepare_request` function which delegates the function call to the appropriate
-  module & function depending on the `opts` key-values.
-
-  Ovh uses it's own custom api and also separate Openstack compliant apis so
-  and these apis are quite different.
-  Therefore, the request needs to be routed to the correct `prepare_request` function so
-  that the correct auth credentials are put into the `options_t` in the returned
-  `ExOvh.Client.query_t` query tuple.
-
-  ## Examples of what some delegation depending on opts
-
-      ExOvh.ovh_prepare_request(query, %{} = opts)
-      calls
-      ExOvh.Ovh.OvhApi.Auth.ovh_prepare_request(ExOvh, query, opts)
-
-  -
-
-      ExOvh.ovh_prepare_request(query, %{ openstack: :true, webstorage: "service_name" } = opts)
-      calls
-      ExOvh.Ovh.OpenstackApi.Webstorage.Auth.ovh_prepare_request(ExOvh, query, opts)
-
-
-  ## Subsequent Request modules
-
-  The subsequent request functions process the request by
-
-  1. Calling the appropriate `prepare_request` function which has been delegated to.
-  2. Getting the appropriate auth credentials and adding them to the headers as needed.
-  3. Returning `ExOvh.Client.query_t` which is a tuple of the format {method, uri, options} which
-     can then be easily used to make requests using HTTPpotion, `ovh_request` or `hubic_request`.
-  """
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Auth, as: Webstorage
-  alias ExOvh.Ovh.OvhApi.Auth, as: OvhAuth
-
-
-  @doc ~S"""
-  Delegates the function call to the appropriate module & function depending on the `opts` key-values.
-
-  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
-
-  ## Options
-
-      { } = opts
-
-  The function call will be delegated to `ExOvh.Ovh.OvhApi.Auth`.
-
-      { openstack: :true, webstorage: "<service>" } = opts
-
-  The function call will be delegated to `ExOvh.Ovh.OpenstackApi.Webstorage.Auth`.
-
-  `openstack: :true` - boolean - indicates whether the request is an openstack one or not.
-
-  `webstorage: service` - String.t and is the name the cdn webstorage in your ovh stack which you which to use.
-  """
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map())
-                     :: ExOvh.Client.query_t
-  def prepare_request(client, {method, uri, params} = query, %{ openstack: :true, webstorage: service } = opts) do
-    Webstorage.prepare_request(client, query, service)
-  end
-
-  def prepare_request(client, {method, uri, params} = query, opts) do
-    OvhAuth.prepare_request(client, query)
-  end
-
-
-end
diff --git a/lib/ovh/defaults.ex b/lib/ovh/defaults.ex
deleted file mode 100644
index a575029..0000000
--- a/lib/ovh/defaults.ex
+++ /dev/null
@@ -1,54 +0,0 @@
-defmodule ExOvh.Ovh.Defaults do
-  @moduledoc :false
-
-  @doc "Returns ovh default configuration settings"
-  @spec ovh() :: map
-  def ovh() do
-    %{
-      endpoint: "ovh-eu",
-      api_version: "1.0"
-    }
-  end
-
-
-  @doc "Returns map of ovh endpoints"
-  @spec endpoints() :: map
-  def endpoints() do
-    %{
-      "ovh-eu"        => "https://api.ovh.com/",
-      "ovh-ca"        => "https://ca.api.ovh.com/",
-      "kimsufi-eu"    => "https://eu.api.kimsufi.com/",
-      "kimsufi-ca"    => "https://ca.api.kimsufi.com/",
-      "soyoustart-eu" => "https://eu.api.soyoustart.com/",
-      "soyoustart-ca" => "https://ca.api.soyoustart.com/",
-      "runabove-ca"   => "https://api.runabove.com/"
-    }
-  end
-
-
-  @doc "Returns the default access rules (all methods and paths)"
-  @spec access_rules() :: [map]
-  def access_rules() do
-     [
-        %{
-            method: "GET",
-            path: "/*"
-        },
-        %{
-            method: "POST",
-            path: "/*"
-        },
-        %{
-            method: "PUT",
-            path: "/*"
-        },
-        %{
-            method: "DELETE",
-            path: "/*"
-        }
-    ]
-  end
-
-
-end
-
diff --git a/lib/ovh/openstack_api/webstorage/auth.ex b/lib/ovh/openstack_api/webstorage/auth.ex
deleted file mode 100644
index fa2cfa5..0000000
--- a/lib/ovh/openstack_api/webstorage/auth.ex
+++ /dev/null
@@ -1,48 +0,0 @@
-defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Auth do
-  @moduledoc :false
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Cache, as: WebStorageCache
-
-  @methods [:get, :post, :put, :delete]
-  @timeout 10_000
-
-
-  ############################
-  # Public
-  ############################
-
-
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t, service :: String.t)
-                     :: ExOvh.Client.query_t
-  def prepare_request(client, query)
-
-  def prepare_request(client, {method, uri, params} = query, service) when method in [:get, :head, :delete] do
-    uri =  WebStorageCache.get_swift_endpoint(client, service) <> uri
-    if params !== :nil and params !== "", do: uri = uri <> "?" <> URI.encode_query(params)
-    options = %{ headers: headers(client, service), timeout: @timeout }
-    {method, uri, options}
-    |> Og.log_return(:debug)
-  end
-
-  def prepare_request(client, {method, uri, params} = query, service) when method in [:post, :put] do
-    uri =  WebStorageCache.get_swift_endpoint(client, service) <> uri
-    if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
-    options = %{ body: params, headers: headers(client, service), timeout: @timeout }
-    {method, uri, options}
-    |> Og.log_return(:debug)
-  end
-
-
-  ############################
-  # Private
-  ############################
-
-
-  defp headers(client, service) do
-    %{
-      "Content-Type": "application/json; charset=utf-8",
-      "X-Auth-Token": WebStorageCache.get_credentials_token(client, service)
-     }
-  end
-
-
-end
diff --git a/lib/ovh/openstack_api/webstorage/cache.ex b/lib/ovh/openstack_api/webstorage/cache.ex
deleted file mode 100644
index 049d93f..0000000
--- a/lib/ovh/openstack_api/webstorage/cache.ex
+++ /dev/null
@@ -1,303 +0,0 @@
-defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
-  @moduledoc :false
-  use GenServer
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor, as: WebStorageSupervisor
-  import ExOvh.Query.Ovh.Webstorage, only: [get_webstorage_credentials: 1, get_webstorage_service: 1]
-  @get_credentials_retries 10
-  @get_credentials_sleep_interval 450
-
-
-  #####################
-  # Public
-  #####################
-
-
-  @doc "Starts the genserver"
-  def start_link({client, config, opts}, service) do
-    Og.context(__ENV__, :debug)
-    GenServer.start_link(__MODULE__, {client, service}, [name: gen_server_name(client, service)])
-  end
-
-
-  def get_credentials(service), do: get_credentials(ExOvh, service)
-  def get_credentials(client, service) do
-    unless supervisor_exists?(client, service), do: Supervisor.start_child(WebStorageSupervisor, [service])
-    get_credentials(client, service, 0)
-  end
-
-
-  def get_credentials_token(service), do: get_credentials_token(ExOvh, service)
-  def get_credentials_token(client, service), do: get_credentials(client, service).token
-
-
-  def get_swift_endpoint(service), do: get_swift_endpoint(ExOvh, service)
-  def get_swift_endpoint(client, service) do
-    credentials = get_credentials(client, service)
-    path = URI.parse(credentials.swift_endpoint) |> Map.get(:path)
-    {version, account} = String.split_at(path, 4)
-    endpoint = List.first(String.split(credentials.swift_endpoint, account))
-    endpoint
-  end
-
-
-  def get_account(service), do: get_account(ExOvh, service)
-  def get_account(client, service) do
-    credentials = get_credentials(client, service)
-    path = URI.parse(credentials.swift_endpoint) |> Map.get(:path)
-    {version, account} = String.split_at(path, 4)
-    account
-  end
-
-
-  #####################
-  # Genserver Callbacks
-  #####################
-
-
-  # trap exits so that terminate callback is invoked
-  # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
-  def init({client, service}) do
-    Og.context(__ENV__, :debug)
-    :erlang.process_flag(:trap_exit, :true)
-    create_ets_table(client, service)
-    {:ok, credentials} = identity(service)
-    credentials = Map.put(credentials, :lock, :false)
-    :ets.insert(ets_tablename(client, service), {:credentials, credentials})
-    expires = to_seconds(credentials.token_expires_on)
-    Task.start_link(fn -> monitor_expiry(expires) end)
-    {:ok, {client, service, credentials}}
-  end
-
-  def handle_call(:add_lock, _from, {client, service, credentials}) do
-    Og.context(__ENV__, :debug)
-    new_credentials = Map.put(credentials, :lock, :true)
-    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
-    {:reply, :ok, {client, service, new_credentials}}
-  end
-
-  def handle_call(:remove_lock, _from, {client, service, credentials}) do
-    Og.context(__ENV__, :debug)
-    new_credentials = Map.put(credentials, :lock, :false)
-    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
-    {:reply, :ok, {client, service, new_credentials}}
-  end
-
-  def handle_call(:update_credentials, _from, {client, service, credentials}) do
-    Og.context(__ENV__, :debug)
-    {:ok, new_credentials} = identity(service)
-    |> Map.put(credentials, :lock, :false)
-    :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
-    {:reply, :ok, {client, service, new_credentials}}
-  end
-
-  def handle_call(:stop, _from, state) do
-    Og.context(__ENV__, :debug)
-    {:stop, :shutdown, :ok, state}
-  end
-
-  def terminate(:shutdown, {client, service, credentials}) do
-    Og.context(__ENV__, :debug)
-    :ets.delete(ets_tablename(client, service)) # explicilty remove
-    :ok
-  end
-
-
-
-  #####################
-  # Private
-  #####################
-
-  defp gen_server_name(client, service), do:  String.to_atom(Atom.to_string(client) <> service)
-  defp ets_tablename(client, service), do: String.to_atom(Atom.to_string(client) <> "-" <> service)
-
-
-  #@spec identity(service :: String.t, username :: String.t, password :: String.t)
-  #               :: {:ok, map()} | {:error, map()} ??
-  # This function probably should be broken down into smaller parts
-  def identity(service) do
-
-    {:ok, resp} = ExOvh.ovh_request(get_webstorage_service(service), %{})
-
-    %{
-      "server" => domain,
-      "storageLimit" => storage_limit
-    } = resp.body
-
-
-    {:ok, resp} = ExOvh.ovh_request(get_webstorage_credentials(service), %{})
-
-    %{
-      "endpoint" => endpoint,
-      "login" => login,
-      "password" => password,
-      "tenant" => tenant
-    } = resp.body
-
-    params = %{"auth" =>
-                        %{
-                        "passwordCredentials" => %{"username" => login, "password" => password}
-                        }
-              }
-    options = %{
-                body: params |> Poison.encode!,
-                headers: %{ "Content-Type": "application/json; charset=utf-8" },
-                timeout: 10_000
-               }
-    resp = HTTPotion.request(:post, endpoint <> "/tokens", options)
-
-    unless resp.status_code >= 200 and resp.status_code <= 203, do: raise resp.body
-
-    %{
-      "access" =>
-                  %{
-                    "token" => %{
-                                 "expires" => expires_on,
-                                 "id" => token,
-                                 "issued_at" => created_on
-                                },
-                  }
-      } = Poison.decode!(resp.body)
-
-    params = %{"auth" =>
-                        %{
-                        "tenantName" => tenant,
-                        "token" => %{"id" => token}}
-                        }
-    options = %{
-                body: params |> Poison.encode!,
-                headers: %{ "Content-Type": "application/json; charset=utf-8" },
-                timeout: 10_000
-               }
-    resp = HTTPotion.request(:post, endpoint <> "/tokens", options)
-
-    unless resp.status_code >= 200 and resp.status_code <= 203, do: raise resp.body
-
-    %{
-      "serviceCatalog" => [
-                          %{
-                            "endpoints" => [%{"publicURL" => swift_endpoint}],
-                            "name" => "swift",
-                          },
-                          %{
-                            "endpoints" => [%{"publicURL" => identity_endpoint}],
-                            "name" => "keystone",
-                          }
-                         ],
-                          "token" => %{
-                                          "expires" => token_expires_on,
-                                          "id" => token,
-                                          "issued_at" => token_created_on,
-                                        },
-                          "user" => _user
-      } = Poison.decode!(resp.body) |> Map.get("access")
-
-      {:ok,
-          %{
-            token: token,
-            token_expires_on: expires_on,
-            token_created_on: token_created_on,
-            swift_endpoint: swift_endpoint,
-            identity_endpoint: identity_endpoint,
-            service: service,
-            public_url: public_url(domain, swift_endpoint),
-            storage_limit: storage_limit
-          }
-      }
-
-  end
-
-  defp public_url(domain, swift_endpoint) do
-    path = URI.parse(swift_endpoint) |> Map.get(:path)
-    {version, account} = String.split_at(path, 4)
-    domain <> version <> account
-  end
-
-  defp get_credentials(client, service, index) do
-    Og.context(__ENV__, :debug)
-
-    retry = fn(client, service, index) ->
-      if index > @get_credentials_retries do
-        raise "Cannot retrieve openstack credentials from ets table, #{__ENV__.module}, #{__ENV__.line}"
-      else
-        :timer.sleep(@get_credentials_sleep_interval)
-        get_credentials(client, service, index + 1)
-      end
-    end
-
-    if ets_tablename(client, service) in :ets.all() do
-      table = :ets.lookup(ets_tablename(client, service), :credentials)
-      case table do
-        [credentials: credentials] ->
-          if credentials.lock === :true do
-            retry.(client, service, index)
-          else
-            credentials
-          end
-        [] -> retry.(client,service,index)
-      end
-    else
-      retry.(client, service, index)
-    end
-  end
-
-
-  defp monitor_expiry(expires) do
-    Og.context(__ENV__, :debug)
-    interval = (expires - 30) * 1000
-    :timer.sleep(interval)
-    {:reply, :ok, _credentials} = GenServer.call(self(), :add_lock)
-    {:reply, :ok, _credentials} = GenServer.call(self(), :update_credentials)
-    {:reply, :ok, credentials} = GenServer.call(self(), :remove_lock)
-    expires = to_seconds(credentials["expires"])
-    monitor_expiry(expires)
-  end
-
-
-  defp create_ets_table(client, service) do
-    Og.context(__ENV__, :debug)
-    ets_options = [
-                   :set, # type
-                   :protected, # read - all, write this process only.
-                   :named_table,
-                   {:heir, :none}, # don't let any process inherit the table. when the ets table dies, it dies.
-                   {:write_concurrency, :false},
-                   {:read_concurrency, :true}
-                  ]
-    unless ets_tablename(client, service) in :ets.all() do
-      :ets.new(ets_tablename(client, service), ets_options)
-    end
-  end
-
-
-  defp to_seconds(iso_time) do
-    {:ok, expiry_ndt, offset} = Calendar.NaiveDateTime.Parse.iso8601(iso_time)
-    offset =
-    case offset do
-      :nil -> 0
-      offset -> offset
-    end
-    {:ok, expiry_dt_utc} = Calendar.NaiveDateTime.with_offset_to_datetime_utc(expiry_ndt, offset)
-    {:ok, now} = Calendar.DateTime.from_erl(:calendar.universal_time(), "UTC")
-    {:ok, seconds, _microseconds, _when} = Calendar.DateTime.diff(expiry_dt_utc, now)
-    if seconds > 0 do
-      seconds
-    else
-      0
-    end
-  end
-
-
-  defp supervisor_exists?(client, service) do
-    case Process.whereis(registered_supervisor_name(client, service)) do
-      :nil -> :false
-      _pid -> :true
-    end
-  end
-
-
-  defp registered_supervisor_name(client, service) do
-    String.to_atom(Atom.to_string(client) <> service)
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/ovh/openstack_api/webstorage/request.ex b/lib/ovh/openstack_api/webstorage/request.ex
deleted file mode 100644
index 1b47734..0000000
--- a/lib/ovh/openstack_api/webstorage/request.ex
+++ /dev/null
@@ -1,40 +0,0 @@
-defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Request do
-  @moduledoc :false
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Auth
-
-
-  @spec request(client :: atom, query :: ExOvh.Client.query_t, service :: String.t)
-               :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request(client, {method, uri, params} = query, %{ webstorage: service } = opts) do
-    Og.context(__ENV__, :debug)
-
-    {method, uri, options} = Auth.prepare_request(client, query, service)
-    resp = HTTPotion.request(method, uri, options)
-    |> Og.log_return(:debug)
-
-    if resp.status_code >= 100 and resp.status_code < 300 do
-      try do
-        {:ok, %{
-               body: resp.body |> Poison.decode!(),
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      rescue
-        _ ->
-        {:ok, %{
-               body: resp.body,
-               headers: resp.headers,
-               status_code: resp.status_code
-              }
-        }
-      end
-    else
-      {:error, resp}
-    end
-
-  end
-
-
-end
-
diff --git a/lib/ovh/openstack_api/webstorage/supervisor.ex b/lib/ovh/openstack_api/webstorage/supervisor.ex
deleted file mode 100644
index 3a08675..0000000
--- a/lib/ovh/openstack_api/webstorage/supervisor.ex
+++ /dev/null
@@ -1,32 +0,0 @@
-defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor do
-  @moduledoc :false
-  use Supervisor
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Cache
-
-  #####################
-  #  Public
-  #####################
-
-  @doc ~S"""
-  Starts the OVH Openstack dynamic supervisor.
-  """
-  def start_link({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    Supervisor.start_link(__MODULE__, {client, config, opts}, [name: __MODULE__])
-  end
-
-
-  #####################
-  #  Callbacks
-  #####################
-
-  def init({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    tree = [
-            {Cache, {Cache, :start_link, [{client, config, opts}]}, :transient, 10_000, :worker, []}
-           ]
-    supervise(tree, strategy: :simple_one_for_one)
-  end
-
-
-end
diff --git a/lib/ovh/ovh_api/auth.ex b/lib/ovh/ovh_api/auth.ex
deleted file mode 100644
index 7ffea99..0000000
--- a/lib/ovh/ovh_api/auth.ex
+++ /dev/null
@@ -1,81 +0,0 @@
-defmodule ExOvh.Ovh.OvhApi.Auth do
-  @moduledoc :false
-  alias ExOvh.Ovh.Defaults
-  alias ExOvh.Ovh.OvhApi.Cache
-
-  @default_headers %{ "Content-Type": "application/json; charset=utf-8" }
-  @methods [:get, :post, :put, :delete]
-  @timeout 10_000
-
-
-  ############################
-  # Public
-  ############################
-
-
-  @spec prepare_request(query :: ExOvh.Client.raw_query_t)
-                     :: ExOvh.Client.query_t
-  def prepare_request({method, uri, params} = query), do: prepare_request(ExOvh, query)
-
-  @spec prepare_request(client :: atom, query :: ExOvh.Client.raw_query_t)
-                     :: ExOvh.Client.query_t
-  def prepare_request(client, query)
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:get, :head, :delete] do
-    uri = uri(config, uri)
-    config = config(client)
-    if params !== :nil and params !== "" and is_map(params), do: uri = uri <> "?" <> URI.encode_query(params)
-    if params !== :nil and params !== "" and is_map(params) === :false, do: uri = uri <> URI.encode_www_form(params)
-    consumer_key = get_consumer_key(config)
-    opts = [app_secret(config), app_key(config), consumer_key, Atom.to_string(method), uri, ""]
-    options = %{ headers: headers(opts, client), timeout: @timeout }
-    {method, uri, options}
-  end
-
-  def prepare_request(client, {method, uri, params} = query) when method in [:post, :put] do
-    uri = uri(config, uri)
-    config = config(client)
-    consumer_key = get_consumer_key(config)
-    if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
-    opts = [app_secret(config), app_key(config), consumer_key, Atom.to_string(method), uri, params]
-    #opts = [app_secret(config), consumer_key, Atom.to_string(method), uri, params]
-    options = %{ body: params, headers: headers(opts, client), timeout: @timeout }
-    {method, uri, options}
-  end
-
-
-  ############################
-  # Private
-  ############################
-
-
-  defp headers([app_secret, app_key, consumer_key, method, uri, body] = opts, client) do
-    time = :os.system_time(:seconds) + Cache.get_time_diff(client)
-    Map.merge(@default_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])
-    })
-  end
-
-
-  defp sign_request([app_secret, consumer_key, method, uri, body, time] = opts) do
-    pre_hash = Enum.join(opts, "+")
-    post_hash = :crypto.hash(:sha, pre_hash) |> Base.encode16(case: :lower)
-    "$1$" <> post_hash
-  end
-
-
-  defp config(), do: Cache.get_config(ExOvh)
-  defp config(client), do: Cache.get_config(client)
-  defp endpoint(config), do: Defaults.endpoints()[config[:endpoint]]
-  defp api_version(config), do: config[:api_version]
-  defp uri(config, uri), do: endpoint(config) <> api_version(config) <> uri
-  defp app_secret(config), do: config[:application_secret]
-  defp app_key(config), do: config[:application_key]
-  defp get_consumer_key(config), do: config[:consumer_key]
-
-
-end
diff --git a/lib/ovh/ovh_api/cache.ex b/lib/ovh/ovh_api/cache.ex
deleted file mode 100644
index 4d59de5..0000000
--- a/lib/ovh/ovh_api/cache.ex
+++ /dev/null
@@ -1,94 +0,0 @@
-defmodule ExOvh.Ovh.OvhApi.Cache do
-  @moduledoc :false
-  use GenServer
-  alias ExOvh.Ovh.Defaults
-
-  ############################
-  # Public
-  ###########################
-
-  @doc "Starts a genserver to keep state on the config and time diff"
-  def start_link({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
-  end
-
-
-  @doc "Retrieves the ovh api time diff from the cache"
-  def get_time_diff(client) do
-    GenServer.call(gen_server_name(client), :get_diff)
-  end
-  @doc "Retrieves the ovh config map"
-  def get_config(client) do
-    GenServer.call(gen_server_name(client), :get_config)
-  end
-
-
-  ############################
-  # Genserver Callbacks
-  ###########################
-
-  def init({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    diff = calculate_diff(config)
-    {:ok, {config, diff}}
-  end
-
-  def handle_call(:get_diff, _from, {config, diff}) do
-    Og.context(__ENV__, :debug)
-    {:reply, diff, {config, diff}}
-  end
-
-  def handle_call(:get_config, _from, {config, diff}) do
-    Og.context(__ENV__, :debug)
-    {:reply, config, {config, diff}}
-  end
-
-  def handle_cast({:set_diff, new_diff}, {config, diff}) do
-    Og.context(__ENV__, :debug)
-    {:noreply, {config, new_diff}}
-  end
-
-  def terminate(:shutdown, state) do
-    Og.context(__ENV__, :warn)
-    Og.log_return("gen_server #{__MODULE__} shutting down", :warn)
-    :ok
-  end
-
-
-  ############################
-  # Private
-  ###########################
-
-
-  defp gen_server_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
-  defp endpoint(config), do: Defaults.endpoints()[config[:endpoint]]
-  defp api_version(config), do: config[:api_version]
-
-
-  defp api_time_request(config) do
-    time_uri = endpoint(config) <> api_version(config) <> "/auth/time"
-    options = %{ headers: %{ "Content-Type": "application/json; charset=utf-8" }, timeout: 10_000 }
-    api_time = HTTPotion.request(:get, time_uri, options) |> Map.get(:body) |> Poison.decode!()
-  end
-
-
-  defp calculate_diff(config) do
-    api_time = api_time_request(config)
-    os_t = :os.system_time(:seconds)
-    os_t - api_time
-  end
-
-
-  #Caches the ovh api time diff
-  defp set_time_diff(client) do
-    config = get_config(client)
-    set_time_diff(client, config)
-  end
-  defp set_time_diff(client, config) when is_map(config) do
-    diff = calculate_diff(config)
-    GenServer.cast(gen_server_name(client), {:set_diff, diff})
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/ovh/ovh_api/request.ex b/lib/ovh/ovh_api/request.ex
deleted file mode 100644
index c39a513..0000000
--- a/lib/ovh/ovh_api/request.ex
+++ /dev/null
@@ -1,43 +0,0 @@
-defmodule ExOvh.Ovh.OvhApi.Request do
-  @moduledoc :false
-  alias ExOvh.Ovh.OvhApi.Auth
-  alias ExOvh.Ovh.OvhApi.Cache
-  alias ExOvh.Ovh.Defaults
-
-  ############################
-  # Public
-  ############################
-
-
-  @spec request(client :: atom, query :: ExOvh.Client.query_t, opts :: map)
-               :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request(client, {method, uri, params} = query, opts) do
-    Og.context(__ENV__, :debug)
-    config = config(client)
-
-    {method, uri, options} = Auth.prepare_request(client, query)
-    |> Og.log_return(:debug)
-
-    resp = HTTPotion.request(method, uri, options)
-    if resp.status_code >= 100 and resp.status_code < 300 do
-      {:ok, %{
-             body: resp.body |> Poison.decode!(),
-             headers: resp.headers,
-             status_code: resp.status_code
-            }
-      }
-    else
-     {:error, resp}
-    end
-  end
-
-
-  ############################
-  # Private
-  ############################
-
-  defp config(client), do: Cache.get_config(client)
-
-
-end
-
diff --git a/lib/ovh/request.ex b/lib/ovh/request.ex
deleted file mode 100644
index befb30a..0000000
--- a/lib/ovh/request.ex
+++ /dev/null
@@ -1,68 +0,0 @@
-defmodule ExOvh.Ovh.Request do
-  @moduledoc :false
-  @doc ~S"""
-  Houses the `request` function which delegates the function call to the appropriate
-  module & function depending on the `opts` key-values.
-
-  Ovh uses it's own custom api and also separate Openstack compliant apis so
-  and these apis are quite different.
-  Therefore, the request needs to be routed to the correct `request` function so
-  that the correct auth credentials are put into the `options_t` in the returned
-  `ExOvh.Client.query_t` query tuple.
-
-  ## Examples of what some delegation depending on opts
-
-      ExOvh.ovh_request(query, %{} = opts)
-      calls
-      ExOvh.Ovh.OvhApi.Request.request(ExOvh, query, opts)
-
-  -
-
-      ExOvh.ovh_request(query, %{ openstack: :true, webstorage: "service_name" } = opts)
-      calls
-      ExOvh.Ovh.OpenstackApi.Webstorage.Request.request(ExOvh, query, opts)
-
-
-  ## Subsequent Request modules
-
-  The subsequent request functions process the request by
-
-  1. Calling the appropriate `prepare_request` function which has been delegated to.
-  2. Making the actual request with `HTTPotion`
-  3. Returning the response as `{:ok, response_t}` or `{:error, response_t}`
-  """
-  alias ExOvh.Ovh.OvhApi.Request, as: Ovh
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Request, as: Webstorage
-
-
-  @doc ~S"""
-  Delegates the function call to the appropriate module & function depending on the `opts` key-values.
-
-  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
-
-  ## Options
-
-      { } = opts
-
-  The function call will be delegated to `ExOvh.Ovh.OvhApi.Request` and processed as a hubic api request.
-
-      { openstack: :true, webstorage: service } = opts
-
-  The function call will be delegated to `ExOvh.Ovh.OpenstackApi.Webstorage.Request`.
-
-  `openstack: :true` - boolean - indicates whether the request is an openstack one or not.
-
-  `webstorage: service` - String.t and is the name the cdn webstorage in your ovh stack which you which to use.
-  """
-  @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request(client, {method, uri, params} = query, %{ openstack: :true, webstorage: service } = opts) do
-    Webstorage.request(client, query, opts)
-  end
-
-  def request(client, {method, uri, params} = query, opts) do
-    Ovh.request(client, query, opts)
-  end
-
-
-end
\ No newline at end of file
diff --git a/lib/ovh/supervisor.ex b/lib/ovh/supervisor.ex
deleted file mode 100644
index 06a2a4a..0000000
--- a/lib/ovh/supervisor.ex
+++ /dev/null
@@ -1,41 +0,0 @@
-defmodule ExOvh.Ovh.Supervisor do
-  @moduledoc :false
-  use Supervisor
-  alias ExOvh.Ovh.OvhApi.Cache
-  alias ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor, as: Webstorage
-
-  #####################
-  #  Public
-  #####################
-
-  @doc ~S"""
-  Starts the OVH supervisor.
-  """
-  def start_link(client, config, opts) do
-    Og.context(__ENV__, :debug)
-    Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
-  end
-
-
-  #####################
-  #  Callbacks
-  #####################
-
-  def init({client, config, opts}) do
-    Og.context(__ENV__, :debug)
-    tree = [
-            {Cache, {Cache, :start_link, [{client, config, opts}]}, :permanent, 10_000, :worker, [Cache]},
-            {Webstorage, {Webstorage, :start_link, [{client, config, opts}]}, :permanent, 10_000, :supervisor, [Webstorage]}
-           ]
-    supervise(tree, strategy: :one_for_one, max_restarts: 20)
-  end
-
-
-  #####################
-  #  Private
-  #####################
-
-  defp supervisor_name(client), do: String.to_atom(Atom.to_string(client) <> Atom.to_string(__MODULE__))
-
-
-end
diff --git a/lib/ovh/v1/webstorage/helpers.ex b/lib/ovh/v1/webstorage/helpers.ex
new file mode 100644
index 0000000..679eef8
--- /dev/null
+++ b/lib/ovh/v1/webstorage/helpers.ex
@@ -0,0 +1,16 @@
+defmodule ExOvh.Ovh.V1.Webstorage.Helpers do
+  @moduledoc :false
+  # alias ExOvh.Ovh.V1.Webstorage.Query
+  # alias Openstex.Response
+
+  defmacro __using__(opts) do
+    quote bind_quoted: [opts: opts] do
+      @client Keyword.fetch!(opts, :client)
+
+      # No helpers yet
+
+    end
+  end
+
+
+end
diff --git a/lib/ovh/v1/webstorage/query.ex b/lib/ovh/v1/webstorage/query.ex
new file mode 100644
index 0000000..d80cd75
--- /dev/null
+++ b/lib/ovh/v1/webstorage/query.ex
@@ -0,0 +1,127 @@
+defmodule ExOvh.Ovh.V1.Webstorage.Query do
+  @moduledoc ~s"""
+  Helper functions for building `queries directed at the `/cdn/webstorage` part of the custom ovh api.
+
+  ## Example
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      query = Query.get_all_webstorage()
+      ExOvh.request(query)
+  """
+  alias ExOvh.Ovh.Query
+
+
+
+  @doc ~s"""
+  GET /v1/​cdn/webstorage​, Get a list of all webstorage cdn services available for the client account
+
+  ### Example usage
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      query = Query.get_services()
+      ExOvh.request(query)
+  """
+  @spec get_services() :: Query.t
+  def get_services() do
+    %Query{
+          method: :get,
+          uri: "/cdn/webstorage",
+          params: :nil
+          }
+  end
+
+
+
+  @doc ~s"""
+  GET /v1/​cdn/webstorage​/{serviceName}, Get the domain, server and storage limits for a specific webstorage cdn service
+
+  ### Example usage
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      service_name = "cdnwebstorage-????"
+      query = Query.get_service(service_name)
+      {:ok, resp} = ExOvh.request(query)
+      %{
+        "domain" => domain,
+        "storageLimit => storage_limit,
+        "server" => server
+       } = resp.body
+  """
+  @spec get_service(String.t) :: Query.t
+  def get_service(service_name) do
+   %Query{
+          method: :get,
+          uri: "/cdn/webstorage/",
+          params: service_name
+          }
+  end
+
+
+
+  @doc ~s"""
+  GET /v1/​cdn/webstorage​/{serviceName}/serviceInfos, Get a administrative details for a specific webstorage cdn service
+
+  ### Example usage
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      service_name = "cdnwebstorage-????"
+      Query.get_service_info(service_name)
+      {:ok, resp} = ExOvh.request(query)
+  """
+  @spec get_service_info(String.t) :: Query.t
+  def get_service_info(service_name) do
+    %Query{
+      method: :get,
+      uri: "/cdn/webstorage/#{service_name}/serviceInfos",
+      params: :nil
+      }
+  end
+
+
+
+  @doc ~s"""
+  GET /v1/​cdn/webstorage​/{serviceName}/statistics, Get statistics for a specific webstorage cdn service
+
+    `period can be "month", "week" or "day"`
+    `type can be "backend", "quota" or "cdn"`
+
+  ### Example usage
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      service_name = "cdnwebstorage-????"
+      query = Query.get_service_stats(service_name, [period: "month", type: "backend"])
+      {:ok, resp} = ExOvh.request(query)
+  """
+  @spec get_service_stats(String.t, Keyword.t) :: Query.t
+  def get_service_stats(service_name, opts \\ []) do
+    period = Keyword.get(opts, "period", "month")
+    type = Keyword.get(opts, "type", "cdn")
+    %Query{
+          method: :get,
+          uri: "/cdn/webstorage/#{service_name}/statistics",
+          params: %{"period" => period, "type" => type}
+          }
+  end
+
+
+
+  @doc ~s"""
+  GET /v1/​cdn/webstorage​/{serviceName}/credentials, Get credentials for using the swift compliant api
+
+  ### Example usage
+
+      alias ExOvh.Ovh.V1.Webstorage.Query
+      service_name = "cdnwebstorage-????"
+      query = Query.get_webstorage_credentials(service_name)
+      {:ok, resp} = ExOvh.request(query)
+  """
+  @spec get_credentials(String.t) :: ExOvh.Query.Ovh.t
+  def get_credentials(service_name) do
+    %Query{
+          method: :get,
+          uri: "/cdn/webstorage/#{service_name}/credentials",
+          params: :nil
+          }
+  end
+
+end
diff --git a/lib/query.ex b/lib/query.ex
new file mode 100644
index 0000000..7d69cdc
--- /dev/null
+++ b/lib/query.ex
@@ -0,0 +1,5 @@
+defmodule ExOvh.Ovh.Query do
+  @moduledoc false
+  defstruct [:method, :uri, :params,  service: :ovh]
+  @type t :: %__MODULE__{method: atom, uri: String.t, params: any, service: :ovh}
+end
\ No newline at end of file
diff --git a/lib/query/hubic/query.ex b/lib/query/hubic/query.ex
deleted file mode 100644
index 4ecb55f..0000000
--- a/lib/query/hubic/query.ex
+++ /dev/null
@@ -1,183 +0,0 @@
-defmodule ExOvh.Query.Hubic do
-  @moduledoc ~S"""
-  Helper functions for building queries for the hubic api.
-
-  The raw query can be passed into a client request.
-
-    ## Example
-
-      import ExOvh.Query.Hubic, only: [scope: 0]
-      scope = ExOvh.hubic_request(scope())
-  """
-
-
-  #########################
-  # General Hubic Requests
-  #########################
-
-
-  @doc ~S"""
-  GET /scope/scope, Get the possible scopes for hubiC API
-
-    ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(scope())
-  """
-  @spec scope() :: ExOvh.Client.raw_query_t
-  def scope(), do: {:get, "/scope/scope", :nil}
-
-
-  @doc ~S"""
-  GET /account, Get the account object properties
-
-    ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(account())
-  """
-  @spec account() :: ExOvh.Client.raw_query_t
-  def account(), do: {:get, "/account", :nil}
-
-
-  @doc ~S"""
-  GET /account/credentials, Returns openstack credentials for connecting to the file API
-
-      ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(openstack_credentials())
-  """
-  @spec openstack_credentials() :: ExOvh.Client.raw_query_t
-  def openstack_credentials(), do: {:get, "/account/credentials", :nil}
-
-
-  @doc ~S"""
-  GET /account/usage, Returns used space & quota of your account
-
-      ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(account_usage())
-  """
-  @spec account_usage() :: ExOvh.Client.raw_query_t
-  def account_usage(), do: {:get, "/account/usage", :nil}
-
-
-
-  ########################
-  # Link related Requests
-  ########################
-
-
-
-  @doc """
-  GET /account/links, Get all links as a list of links (showing the object internal uri - not the indirectUri)
-
-    ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(get_links())
-      ```
-  """
-  @spec get_links() :: ExOvh.Client.raw_query_t
-  def get_links(), do: {:get, "/account/links", :nil}
-
-
-  @doc """
-  GET /account/getAllLinks, Get all published objects' public urls with detailed info
-
-    ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      ExOvh.hubic_request(get_links_detailed())
-      ```
-  """
-  @spec get_links_detailed() :: ExOvh.Client.raw_query_t
-  def get_links_detailed(), do: {:get, "/account/getAllLinks", :nil}
-
-
-  @doc """
-  GET /account/links/{uri}, Get detailed information for an object at a given uri
-
-
-  ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      container = "new_container"
-      folder = "/"
-      object = "server_file.txt"
-      uri = folder <> object
-      ExOvh.hubic_request(get_link(uri))
-  """
-  @spec get_link(uri :: String.t) :: ExOvh.Client.raw_query_t
-  def get_link(uri), do: {:get, "/account/links/", uri}
-
-
-  @doc ~S"""
-  POST /account/links, Create a public url to a file
-
-  Note: links have a max ttl of 30 days on hubic currently.
-  ttl can be 1,5,10,15,20,25 or 30
-  See hubic ovh [docs](https://hubic.com/en/faq) under 'What is sharing?'.
-
-  ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      container = "new_container"
-      object = "server_file.txt"
-      {:ok, resp} = ExOvh.hubic_request(publish_object(container, object))
-      %{ "indirectUrl" => link_indirect_uri, "expirationDate" => exp,
-         "creationDate" => created_on, "uri" => uri } = resp.body
-      object_attrs = %{
-                      link: link_indirect_uri,
-                      expiry: exp,
-                      created: created_on,
-                      object: object,
-                      folder: String.replace(uri, object, ""),
-                      object_uri: uri
-                     }
-      ```
-  """
-  @spec publish_object(container :: String.t, object :: String.t, opts :: map)
-                             :: ExOvh.Client.raw_query_t
-  def publish_object(container, object, folder \\ "/", ttl \\ "5", file \\ "file") do
-    params = %{
-               "comment" => "none",
-               "container" => container,
-               "mode" => "ro",
-               "ttl" => ttl,
-               "type" => file,
-               "uri" => folder <> object
-              }
-    {:post, "/account/links", params}
-  end
-
-
-
-  @doc ~S"""
-  DELETE /account/links/{uri}, Deletes a public url to a file
-
-
-  ### Example:
-      ```elixir
-      import ExOvh.Query.Hubic
-      container = "new_container"
-      object = "server_file.txt"
-      folder = "/"
-      uri = folder <> object
-      ExOvh.hubic_request(delete_link(uri))
-  """
-  @spec delete_link(uri :: String.t) :: ExOvh.Client.raw_query_t
-  def delete_link(uri), do: {:delete, "/account/links/", uri}
-
-
-
-  ########################################
-  # Folder related requests
-  ########################################
-
-
-
-
-end
\ No newline at end of file
diff --git a/lib/query/openstack/swift/query.ex b/lib/query/openstack/swift/query.ex
deleted file mode 100644
index db0892d..0000000
--- a/lib/query/openstack/swift/query.ex
+++ /dev/null
@@ -1,199 +0,0 @@
-defmodule ExOvh.Query.Openstack.Swift do
-  @moduledoc ~S"""
-  Helper functions for to building queries for the openstack compatible swift apis.
-
-  The raw query can be passed into a client request.
-
-    ## Example
-
-      import ExOvh.Query.Openstack.Swift, only: [scope: 0]
-      account = ExOvh.Hubic.OpenstackApi.Cache.get_account()
-      client = ExOvh
-      scope = ExOvh.hubic_request(account_info(client), %{ openstack: : true })
-  """
-  alias ExOvh.Hubic.OpenstackApi.Cache, as: HubicOpenstackCache
-
-
-  #############################
-  # CONTAINER RELATED REQUESTS
-  #############################
-
-
-  @doc ~S"""
-  GET /v1/​{account}​, Get account details and containers for given account
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(account_info(account), %{ openstack: :true })
-      ```
-  """
-  @spec account_info(account :: String.t) :: [map]
-  def account_info(account), do: {:get, account, %{ "format" => "json" }}
-
-
-  @doc ~S"""
-  PUT /v1/​{account}/{container}​, Create a new container
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(create_container(account, "new_container"), %{ openstack: :true })
-      ```
-  """
-  @spec create_container(account :: String.t, container :: String.t)
-                         :: ExOvh.Client.raw_query_t
-  def create_container(account, container), do: {:put, account <> "/" <> container, %{ "format" => "json" }}
-
-
-  @doc ~S"""
-  DELETE /v1/​{account}/{container}​, Delete a container
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(delete_container(account, "new_container"), %{ openstack: :true })
-      ```
-  """
-  @spec delete_container(account :: String.t, container :: String.t)
-                         :: ExOvh.Client.raw_query_t
-  def delete_container(account, container), do: {:delete, account <> "/" <> container, %{ "format" => "json" }}
-
-
-  @doc ~S"""
-  DELETE /v1/​{account}/{container}​, Delete a container
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(container_info(account, "new_container"), %{ openstack: :true })
-      ```
-  """
-  @spec container_info(account :: String.t, container :: String.t)
-                         :: ExOvh.Client.raw_query_t
-  def container_info(account, container), do: {:head, account <> "/" <> container, %{ "format" => "json" }}
-
-
-  ##########################
-  # OBJECT RELATED REQUESTS
-  ##########################
-
-
-  @doc ~S"""
-  GET /v1/​{account}​/{container}, List objects in a container
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(get_objects(account, "default"), %{ openstack: :true })
-      ```
-  """
-  @spec get_objects(account :: String.t, container :: String.t)
-                    :: ExOvh.Client.raw_query_t
-  def get_objects(account, container), do: {:get, account <> "/" <> container, %{ "format" => "json" }}
-
-
-
-  @doc ~S"""
-  GET /v1/​{account}​/{container}/{object}, Get/Download a specific object (file)
-
-  ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      file = "server_file.txt"
-      container = "new_container"
-      account = OpenCache.get_account(client)
-      ExOvh.hubic_request(get_object(account, container, file), %{ openstack: :true })
-      ```
-  """
-  @spec get_object(account :: String.t, container :: String.t, object :: String.t)
-                   :: ExOvh.Client.raw_query_t
-  def get_object(account, container, object), do: {:get, account <> "/" <> container <> "/" <> object, :nil}
-
-
-  @doc """
-  PUT /v1/​{account}​/{container}/{object}, Create or replace an object (file)
-
-    ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      object_name = "client_file.txt"
-      client_object = Kernel.to_string(:code.priv_dir(:ex_ovh)) <> "/" <> object_name
-      container = "new_container"
-      server_object = String.replace(object_name, "client", "server")
-      ExOvh.hubic_request(create_object(account, container, client_object, server_object), %{ openstack: :true })
-      ```
-  """
-  @spec create_object(account :: String.t, container :: String.t, client_object :: String.t, server_object :: String.t)
-                      :: ExOvh.Client.raw_query_t
-  def create_object(account, container, client_object, server_object) do
-    case File.read(client_object) do
-      {:ok, binary_object} ->
-        path = account <> "/" <> container <> "/" <> server_object
-        {:put, path, binary_object}
-      {:error, posix_error} ->
-        Og.context(__ENV__, :error)
-        Og.log_return(posix_error, :error)
-        raise posix_error
-    end
-  end
-
-
-  @doc """
-  DELETE /v1/​{account}​/{container}/{object}, Delete an Object (Delete a file)
-
-    ### Example usage
-
-      ```elixir
-      import ExOvh.Query.Openstack.Swift
-      alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
-      client = ExOvh
-      account = OpenCache.get_account(client)
-      container = "new_container"
-      server_object = "server_file.txt"
-      ExOvh.hubic_request(delete_object(account, container, server_object), %{ openstack: :true })
-  """
-  @spec delete_object(account :: String.t, container :: String.t, server_object :: String.t)
-                      :: ExOvh.Client.raw_query_t
-  def delete_object(account, container, server_object) do
-    {:delete, account <> "/" <> container <> "/" <> server_object, :nil}
-  end
-
-
-
-end
-
-
-
-
-
-
-
-
diff --git a/lib/query/ovh/webstorage/query.ex b/lib/query/ovh/webstorage/query.ex
deleted file mode 100644
index 9b5a793..0000000
--- a/lib/query/ovh/webstorage/query.ex
+++ /dev/null
@@ -1,109 +0,0 @@
-defmodule ExOvh.Query.Ovh.Webstorage do
-  @moduledoc ~S"""
-  Helper functions for to building queries to the `/cdn/webstorage` part of the custom ovh api.
-
-  The raw query can be passed into a client request.
-
-    ## Example
-
-      import ExOvh.Query.Ovh.Webstorage
-      query = get_all_webstorage()
-      ExOvh.ovh_request(query, %{})
-  """
-  alias ExOvh.Ovh.OvhApi.Cache, as: OvhApiCache
-
-
-
-  @doc ~S"""
-  GET /v1/​cdn/webstorage​, Get a list of all webstorage cdn services available for the client account
-
-  ### Example usage
-
-      import ExOvh.Query.Ovh.Webstorage
-      ExOvh.ovh_request(get_all_webstorage(), %{})
-  """
-  @spec get_all_webstorage() :: ExOvh.Client.raw_query_t
-  def get_all_webstorage(), do: {:get, "/cdn/webstorage", :nil}
-
-
-
-  @doc ~S"""
-  GET /v1/​cdn/webstorage​/{serviceName}, Get the domain, server and storage limits for a specific webstorage cdn service
-
-  ### Example usage
-
-      import ExOvh.Query.Ovh.Webstorage
-      service_name = "cdnwebstorage-????"
-      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
-      %{
-        "domain" => domain,
-        "storageLimit => storage_limit,
-        "server" => server
-       } = resp.body
-  """
-  @spec get_webstorage_service(service_name :: String.t)
-                               :: ExOvh.Client.raw_query_t
-  def get_webstorage_service(service_name), do: {:get, "/cdn/webstorage/", service_name}
-
-
-
-  @doc ~S"""
-  GET /v1/​cdn/webstorage​/{serviceName}/serviceInfos, Get a administrative details for a specific webstorage cdn service
-
-  ### Example usage
-
-      import ExOvh.Query.Ovh.Webstorage
-      service_name = "cdnwebstorage-????"
-      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service_info(service_name), %{})
-  """
-  @spec get_webstorage_service_info(service_name :: String.t)
-                               :: ExOvh.Client.raw_query_t
-  def get_webstorage_service_info(service_name), do: {:get, "/cdn/webstorage/#{service_name}/serviceInfos", :nil}
-
-
-
-  @doc ~S"""
-  GET /v1/​cdn/webstorage​/{serviceName}/statistics, Get statistics for a specific webstorage cdn service
-
-    `period can be "month", "week" or "day"`
-    `type can be "backend", "quota" or "cdn"`
-
-  ### Example usage
-
-      import ExOvh.Query.Ovh.Webstorage
-      # service_name = "cdnwebstorage-????"
-      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service_stats(service_name, "month", "backend"), %{})
-  """
-  @spec get_webstorage_service_stats(service_name :: String.t, period :: String.t, type :: String.t)
-                               :: ExOvh.Client.raw_query_t
-  def get_webstorage_service_stats(service_name, period \\ "month", type \\ "cdn") do
-    {:get, "/cdn/webstorage/#{service_name}/statistics", %{"period" => period, "type" => type} }
-  end
-
-
-
-  @doc ~S"""
-  GET /v1/​cdn/webstorage​/{serviceName}/credentials, Get credentials for using the swift compliant api
-
-  ### Example usage
-
-      import ExOvh.Query.Ovh.Webstorage
-      # service = "cdnwebstorage-????"
-      {:ok, resp} = ExOvh.ovh_request(get_webstorage_credentials(service), %{})
-  """
-  @spec get_webstorage_credentials(service_name :: String.t)
-                               :: ExOvh.Client.raw_query_t
-  def get_webstorage_credentials(service_name), do: {:get, "/cdn/webstorage/#{service_name}/credentials", :nil}
-
-
-
-
-end
-
-
-
-
-
-
-
-
diff --git a/lib/request/ovh/request.ex b/lib/request/ovh/request.ex
new file mode 100644
index 0000000..f7aa6a2
--- /dev/null
+++ b/lib/request/ovh/request.ex
@@ -0,0 +1,52 @@
+defimpl Openstex.Request, for: ExOvh.Ovh.Query do
+  @moduledoc :false
+
+  alias Openstex.{Auth, Response}
+  alias ExOvh.Ovh.Query
+
+
+  # Public
+
+
+  @spec request(Query.t, Keyword.t, atom) :: {:ok, Response.t} | {:error, Response.t}
+  def request(query, opts, client) do
+    Og.context(__ENV__, :debug)
+
+    q = Auth.prepare_request(query, opts, client) |> Map.from_struct()
+
+    options = set_opts(q.options, opts)
+    case HTTPoison.request(q.method, q.uri, q.body, q.headers, options) do
+      {:ok, resp} ->
+        body = parse_body(resp)
+        resp = %Response{ body: body, headers: resp.headers |> Enum.into(%{}), status_code: resp.status_code }
+        if resp.status_code >= 100 and resp.status_code < 300 do
+          {:ok, resp}
+        else
+          {:error, resp}
+        end
+      {:error, resp} ->
+        {:error, %HTTPoison.Error{reason: resp.reason}}
+    end
+
+  end
+
+
+  # private
+
+
+  def parse_body(resp) do
+    try do
+       resp.body |> Poison.decode!()
+    rescue
+      _ ->
+        resp.body
+    end
+  end
+
+
+  defp set_opts(query_opts, opts), do: Keyword.merge(query_opts, opts)
+
+
+end
+
+
diff --git a/lib/supervisor.ex b/lib/supervisor.ex
index c933947..8dbada8 100644
--- a/lib/supervisor.ex
+++ b/lib/supervisor.ex
@@ -1,96 +1,51 @@
 defmodule ExOvh.Supervisor do
   @moduledoc :false
-  @doc ~S"""
-  Supervisor for the Hubic and Ovh api configuration.
-  """
+
   use Supervisor
-  alias ExOvh.Ovh.Cache
-  alias ExOvh.Ovh.Defaults, as: OvhDefaults
-  alias ExOvh.Hubic.Defaults, as: HubicDefaults
-  alias ExOvh.Ovh.Supervisor, as: OvhSupervisor
-  alias ExOvh.Hubic.Supervisor, as: HubicSupervisor
-  require Logger
+  alias ExOvh.Defaults
+  alias ExOvh.Auth.Supervisor, as: AuthSupervisor
 
 
-  #####################
   #  Public
-  #####################
-
-  @doc ~S"""
-  Starts the OVH and Hubic supervisors.
 
-  If the hubic_config is set to :nil, it will simply ignore hubic and start ovh only.
-  If the ovh_config is set to :nil, it will simply ignore ovh and start hubic only.
 
-  If the both ovh_config and hubic_config are set to :nil, then an error will be raised
-  which will crash the supervisor.
-  """
   def start_link(client, config, opts) do
     Og.context(__ENV__, :debug)
     Supervisor.start_link(__MODULE__, {client, config, opts}, [name: client])
   end
 
-  #####################
+
   #  Callbacks
-  #####################
+
 
   def init({client, config, opts}) do
     Og.context(__ENV__, :debug)
     sup_tree =
     case ovh_config(config, client) do
       {:error, :config_not_found} ->
-        Logger.warn(IO. inspect("No ovh config found. OVH supervisor will not be started for client #{client}"))
+        Og.log("No ovh config found. Ovh supervisor will not be started for client #{client}", :error)
         []
       valid_config ->
-        [{OvhSupervisor,
-         {OvhSupervisor, :start_link, [client, valid_config, opts]}, :permanent, 10_000, :supervisor, [OvhSupervisor]}]
-    end
-    sup_tree =
-    case hubic_config(config, client) do
-      {:error, :config_not_found} ->
-        Og.log_return("No hubic config found. Hubic supervisor will not be started for client #{client}", :warn)
-        sup_tree
-      valid_config -> sup_tree ++
-        [{HubicSupervisor,
-         {HubicSupervisor, :start_link, [client, valid_config, opts]}, :permanent, 10_000, :supervisor, [HubicSupervisor]}]
+        [{AuthSupervisor,
+         {AuthSupervisor, :start_link, [client, valid_config, opts]}, :permanent, 10_000, :supervisor, [AuthSupervisor]}]
     end
     if sup_tree === [] do
-        raise "No configuration found for hubic or ovh."
+        raise "No configuration found for ovh."
     end
     supervise(sup_tree, strategy: :one_for_one, max_restarts: 20)
   end
 
 
-
   @doc """
   Gets the ovh config settings.
-
-  Returns the config_map if the ovh_config is not :nil.
-  or
-  Returns {:error, :config_not_found} if the ovh_config is set to :nil.
   """
   @spec ovh_config(config :: map, client :: atom) :: map | {:error, atom}
   def ovh_config(config, client) do
-    case config[:ovh] do
+    case config do
       :nil -> {:error, :config_not_found}
-      _ -> Map.merge(OvhDefaults.ovh(), client.config()[:ovh])
+      _ -> Map.merge(Defaults.ovh(), client.config())
     end
   end
 
 
-  @doc """
-  Gets the hubic config settings.
-
-  Returns the config_map if the hubic_config is not :nil.
-  or
-  Returns {:error, :config_not_found} if the hubic_config is set to :nil.
-  """
-  @spec hubic_config(config :: map, client :: atom) :: map | :nil
-  def hubic_config(config, client) do
-    case config[:hubic] do
-      :nil -> {:error, :config_not_found}
-      _ -> Map.merge(HubicDefaults.hubic(), client.config()[:hubic])
-    end
-  end
-
 end
diff --git a/lib/utils/utils.ex b/lib/utils/utils.ex
new file mode 100644
index 0000000..bed4f44
--- /dev/null
+++ b/lib/utils/utils.ex
@@ -0,0 +1,114 @@
+defmodule ExOvh.Utils do
+  @moduledoc false
+
+  alias ExOvh.Auth.Ovh.Cache
+  alias ExOvh.Defaults
+
+
+  @doc """
+  For naming a supervisor to incorporate the name of the client.
+
+  The client name is required so that when a client makes a request, the correct supervisor
+  is called if there are multiple clients in use.
+  """
+  defmacro supervisor_name(client) do
+    caller = __CALLER__.module
+    quote do
+      (
+        (
+         Atom.to_string(unquote(client))
+         <>
+         "."
+         )
+         <>
+         Atom.to_string(unquote(caller))
+       )
+       |> String.replace("Elixir.", "")
+       |> String.to_atom()
+     end
+  end
+
+
+  @doc """
+  For naming a genserver to incorporate the name of the client.
+
+  The client name is required so that when a client makes a request, the correct genserver
+  is called if there are multiple clients in use.
+  """
+  defmacro gen_server_name(client) do
+    caller = __CALLER__.module
+    quote do
+      (
+        (
+         Atom.to_string(unquote(client))
+         <>
+         "."
+         )
+         <>
+         Atom.to_string(unquote(caller))
+      )
+      |> String.replace("Elixir.", "")
+      |> String.to_atom()
+    end
+  end
+
+
+  @doc """
+  For naming an ets table to incorporate the name of the client.
+
+  The client name is required so that when a client makes a request, the correct ets table
+  is looked up if there are multiple clients in use.
+  """
+  defmacro ets_tablename(client) do
+    # caller = __CALLER__.module
+    quote do
+      "Ets."
+      <>
+      (
+        gen_server_name(unquote(client))
+        |> Atom.to_string()
+      )
+      |> String.to_atom()
+    end
+  end
+
+  @doc """
+  Changes the timeout option for a http_query.
+  """
+  @spec change_http_query_timeout(Openstex.HttpQuery.t, integer) :: Openstex.HttpQuery.t
+  def change_http_query_timeout(%Openstex.HttpQuery{options: options} = http_query, new_timeout) do
+    new_options = Map.merge(options, Map.put(options, :timeout, new_timeout))
+    Map.put(http_query, :options, new_options)
+  end
+
+
+  @doc """
+  Returns a string with the formatted date
+  """
+  @spec formatted_date() :: String.t
+  def formatted_date() do
+    {year, month, date} = :erlang.date()
+    Integer.to_string(date) <> "." <>
+    Integer.to_string(month) <> "." <>
+    Integer.to_string(year)
+  end
+
+
+  def config(client), do: Cache.get_config(client)
+  def endpoints(), do: Defaults.endpoints()
+  def endpoint(config), do: Defaults.endpoints()[config[:endpoint]]
+  def api_version(config), do: config[:api_version]
+  def uri(uri, config), do: endpoint(config) <> api_version(config) <> uri
+  def app_secret(config), do: config[:application_secret]
+  def app_key(config), do: config[:application_key]
+  def get_consumer_key(config), do: config[:consumer_key]
+  def connect_timeout(config), do: config[:connect_timeout]
+  def receive_timeout(config), do: config[:receive_timeout]
+  def set_opts(opts, config), do: Keyword.merge([ timeout: connect_timeout(config), recv_timeout: receive_timeout(config) ], opts)
+  def access_rules(), do: Defaults.access_rules()
+  def access_rules(config), do: config[:access_rules]
+  def default_create_app_uri(config), do: endpoint(config) <> "createApp/"
+  def consumer_key_uri(config), do: endpoint(config) <> api_version(config) <> "/auth/credential/"
+
+
+end
diff --git a/mix.exs b/mix.exs
index 58d9a63..ca70f13 100644
--- a/mix.exs
+++ b/mix.exs
@@ -19,18 +19,19 @@ defmodule ExOvh.Mixfile do
   def application() do
     [
       mod: [],
-      applications: [:calendar, :crypto, :httpotion, :logger]
+      applications: [:calendar, :crypto, :logger, :openstex]
     ]
   end
 
   defp deps() do
     [
-      {:httpotion, "<= 2.2.0"},
-      {:poison, "~> 1.0"},
       {:secure_random, "~> 0.2"},
       {:floki, "~> 0.7.1"},
       {:calendar, "~> 0.13.2"},
-      {:og, "~> 0.0", only: :dev},
+      {:og, "~> 0.1"},
+      # {:openstex, github: "stephenmoloney/openstex", branch: "master"}, # incorporates :poison and httpoison
+      {:openstex, path: "../openstex"},
+
       {:earmark, "~> 0.2.1", only: :dev},
       {:ex_doc,  "~> 0.11", only: :dev}
     ]
@@ -38,7 +39,7 @@ defmodule ExOvh.Mixfile do
 
   defp description() do
     ~s"""
-    An elixir client library for easier use of the Hubic api and Ovh api.
+    An elixir client library for easier use of the Ovh api.
     """
   end