Commit ad68b73902fbd38fa3dce7af023e95fc842f48fe

Stephen Moloney 2016-02-14T12:43:34

refactoring docs

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
diff --git a/lib/client.ex b/lib/client.ex
index fdc4e58..f235aa3 100644
--- a/lib/client.ex
+++ b/lib/client.ex
@@ -1,18 +1,16 @@
 defmodule ExOvh.Client do
-  alias LoggingUtils
   alias ExOvh.Defaults
 
-  # <<TODO>> Reconsider is here the best place to declare the types
+
   @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
@@ -60,32 +58,70 @@ defmodule ExOvh.Client do
   @callback start_link() :: :ok | {:error, {:already_started, pid}} | {:error, term}
 
 
-  @doc ~s"""
-  Makes a request to the ovh api.
-  Returns a map `%{ body: <body>, headers: [<headers>], status_code: <code>}`
+  @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.
   """
-  @callback ovh_request(query :: raw_query_t, opts :: map)
-                        :: {:ok, response_t} | {:error, response_t}
+  @callback config() :: :nil | map
 
 
-  @doc ~s"""
-  Prepares all elements necessary prior to making a request to the ovh api.
-  Returns a tuple `{method, uri, options}`
+
+  @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
+  the `ovh_request` function or [HTTPotion](http://hexdocs.pm/httpotion/HTTPotion.html).
+
+  ## Example
+
+  Making a request to the custom ovh api:
+      query = ExOvh.ovh_prepare_request({:get, "/cdn/webstorage", :nil}, %{})
+
+
+  Making a request to the openstack compliant ovh cdn webstorage service:
+      query = ExOvh.ovh_prepare_request({:get, "<account_name>", %{"format" => "json"}}, %{ openstack: :true, webstorage: "<ovh_service_name>" })
   """
   @callback ovh_prepare_request(query :: raw_query_t)
                              :: query_t
 
 
-  @doc ~s"""
+
+  @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:
+      ExOvh.ovh_request({:get, "/cdn/webstorage", :nil}, %{})
+
+  Making a request to the openstack compliant ovh cdn webstorage service:
+      ExOvh.ovh_request({:get, "<account_name>", %{"format" => "json"}}, %{ 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>}`
   """
   @callback hubic_request(query :: raw_query_t, opts :: map)
                          :: {:ok, response_t} | {:error, response_t}
 
 
-  @doc ~s"""
+  @doc ~S"""
   Prepares all elements necessary prior to making a request to the hubic api.
+
   Returns a tuple `{method, uri, options}`
   """
   @callback hubic_prepare_request(query :: raw_query_t)
diff --git a/lib/hubic/auth.ex b/lib/hubic/auth.ex
index 6e67fc3..cfa030d 100644
--- a/lib/hubic/auth.ex
+++ b/lib/hubic/auth.ex
@@ -1,5 +1,5 @@
 defmodule ExOvh.Hubic.Auth do
-  @moduledoc ~s"""
+  @moduledoc ~S"""
     Delegates the prepare_request to the appropriate module and function
     depending on the opts specified.
     `%{ openstack: :true }` ==> delegates the query to the OpenstackApi.Auth Module
diff --git a/lib/hubic/defaults.ex b/lib/hubic/defaults.ex
index 3105036..54f9ca7 100644
--- a/lib/hubic/defaults.ex
+++ b/lib/hubic/defaults.ex
@@ -1,5 +1,5 @@
 defmodule ExOvh.Hubic.Defaults do
-
+  @moduledoc :false
 
   @doc "Returns hubic default configuration settings"
   @spec hubic() :: map
diff --git a/lib/hubic/hubic_api/auth.ex b/lib/hubic/hubic_api/auth.ex
index fa0b7cb..0fc028d 100644
--- a/lib/hubic/hubic_api/auth.ex
+++ b/lib/hubic/hubic_api/auth.ex
@@ -1,6 +1,6 @@
 defmodule ExOvh.Hubic.HubicApi.Auth do
-  @moduledoc "Gets the access and refresh token for access the hubic api"
-
+  #@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
@@ -10,10 +10,6 @@ defmodule ExOvh.Hubic.HubicApi.Auth do
   # 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
diff --git a/lib/hubic/hubic_api/cache.ex b/lib/hubic/hubic_api/cache.ex
index ce507c4..fdfa69f 100644
--- a/lib/hubic/hubic_api/cache.ex
+++ b/lib/hubic/hubic_api/cache.ex
@@ -1,29 +1,30 @@
 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 ~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
diff --git a/lib/hubic/hubic_api/request.ex b/lib/hubic/hubic_api/request.ex
index 358a8db..d370bdf 100644
--- a/lib/hubic/hubic_api/request.ex
+++ b/lib/hubic/hubic_api/request.ex
@@ -1,12 +1,9 @@
 defmodule ExOvh.Hubic.HubicApi.Request do
+  @moduledoc :false
   alias ExOvh.Hubic.HubicApi.Auth
   alias ExOvh.Hubic.HubicApi.Cache, as: TokenCache
 
 
-  ###################
-  # Public
-  ###################
-
   @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, retries :: integer)
                 :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
   def request(client, {method, uri, params} = query, retries \\ 0) do
@@ -33,7 +30,6 @@ defmodule ExOvh.Hubic.HubicApi.Request do
       end
     else
       if Map.has_key?(resp.body, "error") do
-        #error = Map.get(body, "error") <> " :: " <> Map.get(body, "error_description")
         if resp.body["error"] === "invalid_token" do
           GenServer.call(TokenCache, :stop) # Restart the gen_server to recuperate state
           unless retries >= 1, do: request(query, 1) # Try request one more time
@@ -47,9 +43,5 @@ defmodule ExOvh.Hubic.HubicApi.Request do
 
   end
 
-  ###################
-  # Private
-  ###################
-
 
 end
\ No newline at end of file
diff --git a/lib/hubic/openstack_api/auth.ex b/lib/hubic/openstack_api/auth.ex
index 4b60dfd..c2dbd3e 100644
--- a/lib/hubic/openstack_api/auth.ex
+++ b/lib/hubic/openstack_api/auth.ex
@@ -1,4 +1,5 @@
 defmodule ExOvh.Hubic.OpenstackApi.Auth do
+  @moduledoc :false
   alias ExOvh.Hubic.OpenstackApi.Cache
 
   @methods [:get, :post, :put, :delete]
@@ -10,10 +11,6 @@ defmodule ExOvh.Hubic.OpenstackApi.Auth do
   ############################
 
 
-  @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)
diff --git a/lib/hubic/openstack_api/cache.ex b/lib/hubic/openstack_api/cache.ex
index b8501d3..d1fa358 100644
--- a/lib/hubic/openstack_api/cache.ex
+++ b/lib/hubic/openstack_api/cache.ex
@@ -1,8 +1,5 @@
 defmodule ExOvh.Hubic.OpenstackApi.Cache do
-  @moduledoc """
-  Caches the openstack credentials for access to the openstack api
-  Hubic does not use the standard Openstack Identity (Keystone) api for auth.
-  """
+  @moduledoc :false
   use GenServer
   alias ExOvh.Hubic.HubicApi.Cache
   alias ExOvh.Hubic.Request
diff --git a/lib/hubic/openstack_api/request.ex b/lib/hubic/openstack_api/request.ex
index d948616..2b5d590 100644
--- a/lib/hubic/openstack_api/request.ex
+++ b/lib/hubic/openstack_api/request.ex
@@ -1,11 +1,8 @@
 defmodule ExOvh.Hubic.OpenstackApi.Request do
+  @moduledoc :false
   alias ExOvh.Hubic.OpenstackApi.Cache
   alias ExOvh.Hubic.OpenstackApi.Auth
 
-  ###################
-  # Public
-  ###################
-
 
   @spec request(client :: atom, query :: ExOvh.Client.raw_query_t)
                 :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
@@ -40,10 +37,4 @@ defmodule ExOvh.Hubic.OpenstackApi.Request do
   end
 
 
-
-  ###################
-  # Private
-  ###################
-
-
 end
\ No newline at end of file
diff --git a/lib/hubic/request.ex b/lib/hubic/request.ex
index 7bb82a6..a164262 100644
--- a/lib/hubic/request.ex
+++ b/lib/hubic/request.ex
@@ -1,30 +1,59 @@
 defmodule ExOvh.Hubic.Request do
-  @moduledoc ~s"""
-    Delegates the request to the correct module and functions
-    according to what the opts map specifies.
-    `%{ openstack: :true }` ==> delegates the query to the OpenstackApi Module
-    `%{ }` ==> delegates the query to the HubicApi Module
+  @moduledoc ~S"""
+  Contains the `request` function which delegates the request
+  to the correct module and functions depending on the parameters in `opts`.
+
+  Hubic uses it's own custom api and also a distinct Openstack compliant api 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.
+
+  This module's request function delegates the query to the correct `prepare_request`
+  function by pattern matching on the `opts` map.
+
+  ## Routing/Delegating depending on opts
+
+  `%{ }` -> `ExOvh.Hubic.HubicApi.Request`
+
+  `%{ openstack: :true}` -> `ExOvh.Hubic.OpenstackApi.Request`
+
+  ## Subsequent Request modules
+
+  The subsequent request modules 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: Hub
   alias ExOvh.Hubic.OpenstackApi.Request, as: Open
 
 
-  ###################
-  # Public
-  ###################
+  @doc ~S"""
+  Redirects the query to the appropriate function dependeing on the `opts` key-values.
 
-  @spec request(query :: ExOvh.Client.raw_query_t, opts :: map)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request({method, uri, params} = query, opts), do: request(ExOvh, query, opts)
+  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
+
+  ## Options
+
+      { } = opts
 
+  The request will be delegated to `ExOvh.Hubic.HubicApi.Request` and processed as a hubic api request.
+
+      { openstack: :true } = opts
+
+  The request will be delegated to `ExOvh.Hubic.OpenstackApi.Request` and processed as an openstack api request.
+  """
   @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)
-  def request(client, {method, uri, params} = query, opts), do: Hub.request(client, query)
+  def request(client, {method, uri, params} = query, %{ openstack: :true } = opts) do
+    Open.request(client, query)
+  end
 
-  ###################
-  # Private
-  ###################
+  def request(client, {method, uri, params} = query, opts) do
+    Hub.request(client, query)
+  end
 
 
 end
\ No newline at end of file
diff --git a/lib/hubic/request_helpers.ex b/lib/hubic/request_helpers.ex
index 60d93a6..9ed8a82 100644
--- a/lib/hubic/request_helpers.ex
+++ b/lib/hubic/request_helpers.ex
@@ -3,7 +3,7 @@ defmodule ExOvh.Hubic.RequestHelpers do
   alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenCache
 
 
-  @doc ~s"""
+  @doc ~S"""
   Gets a list of all openstack swift containers for the hubic app
 
   Returns `{:ok, [<container_name>, <container_name> ...]`
@@ -32,7 +32,7 @@ defmodule ExOvh.Hubic.RequestHelpers do
   end
 
 
-  @doc ~s"""
+  @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.
 
diff --git a/lib/hubic/supervisor.ex b/lib/hubic/supervisor.ex
index 49ed8fd..5b22a21 100644
--- a/lib/hubic/supervisor.ex
+++ b/lib/hubic/supervisor.ex
@@ -1,7 +1,5 @@
 defmodule ExOvh.Hubic.Supervisor do
-  @moduledoc ~s"""
-  Supervisor for the Hubic Configuration
-  """
+  @moduledoc :false
   use Supervisor
   alias LoggingUtils
   alias ExOvh.Hubic.HubicApi.Cache, as: TokenCache
diff --git a/lib/mix/tasks/hubic.ex b/lib/mix/tasks/hubic.ex
index 12c27da..e59e9e7 100644
--- a/lib/mix/tasks/hubic.ex
+++ b/lib/mix/tasks/hubic.ex
@@ -1,5 +1,5 @@
 defmodule Mix.Tasks.Hubic do
-  @moduledoc ~s"""
+  @moduledoc ~S"""
   Gets the access and refresh token for access the hubic api
   and returns them as a map to assist setting up the
   configuration file `secret.prod.exs`
diff --git a/lib/ovh/defaults.ex b/lib/ovh/defaults.ex
index 86c124b..a575029 100644
--- a/lib/ovh/defaults.ex
+++ b/lib/ovh/defaults.ex
@@ -1,4 +1,5 @@
 defmodule ExOvh.Ovh.Defaults do
+  @moduledoc :false
 
   @doc "Returns ovh default configuration settings"
   @spec ovh() :: map
diff --git a/lib/ovh/openstack_api/webstorage/auth.ex b/lib/ovh/openstack_api/webstorage/auth.ex
index 8c8ce50..b70a3ff 100644
--- a/lib/ovh/openstack_api/webstorage/auth.ex
+++ b/lib/ovh/openstack_api/webstorage/auth.ex
@@ -1,6 +1,6 @@
 defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Auth do
+  @moduledoc :false
   alias ExOvh.Ovh.OpenstackApi.Webstorage.Cache, as: WebStorageCache
-  # import ExOvh.Query.Ovh.Webstorage, only: []
 
   @methods [:get, :post, :put, :delete]
   @timeout 10_000
diff --git a/lib/ovh/openstack_api/webstorage/cache.ex b/lib/ovh/openstack_api/webstorage/cache.ex
index 4384d53..eeea32f 100644
--- a/lib/ovh/openstack_api/webstorage/cache.ex
+++ b/lib/ovh/openstack_api/webstorage/cache.ex
@@ -1,9 +1,5 @@
 defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
-  @moduledoc """
-  Caches the openstack credentials for access to the openstack api associated with the webstorage cdn.
-
-  Uses the standard Openstack Identity (Keystone) api for auth.
-  """
+  @moduledoc :false
   use GenServer
   alias ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor, as: WebStorageSupervisor
   import ExOvh.Query.Ovh.Webstorage, only: [get_webstorage_credentials: 1]
@@ -25,9 +21,6 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
 
   def get_credentials(service), do: get_credentials(ExOvh, service)
   def get_credentials(client, service) do
-    LoggingUtils.log_return("client, service", :warn)
-    LoggingUtils.log_return(client, :warn)
-    LoggingUtils.log_return(service, :warn)
     unless supervisor_exists?(client, service), do: Supervisor.start_child(WebStorageSupervisor, [service])
     get_credentials(client, service, 0)
   end
@@ -68,7 +61,6 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
     :erlang.process_flag(:trap_exit, :true)
     create_ets_table(client, service)
     {:ok, credentials} = identity(service)
-    |> LoggingUtils.log_return(:debug)
     credentials = Map.put(credentials, :lock, :false)
     :ets.insert(ets_tablename(client, service), {:credentials, credentials})
     expires = to_seconds(credentials.token_expires_on)
diff --git a/lib/ovh/openstack_api/webstorage/request.ex b/lib/ovh/openstack_api/webstorage/request.ex
index 21354b2..57233f9 100644
--- a/lib/ovh/openstack_api/webstorage/request.ex
+++ b/lib/ovh/openstack_api/webstorage/request.ex
@@ -1,6 +1,6 @@
 defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Request do
+  @moduledoc :false
   alias ExOvh.Ovh.OpenstackApi.Webstorage.Auth
-  alias ExOvh.Ovh.OvhApi.Cache, as: ClientCache
 
 
   @spec request(client :: atom, query :: ExOvh.Client.query_t, service :: String.t)
diff --git a/lib/ovh/openstack_api/webstorage/supervisor.ex b/lib/ovh/openstack_api/webstorage/supervisor.ex
index 454662a..d399400 100644
--- a/lib/ovh/openstack_api/webstorage/supervisor.ex
+++ b/lib/ovh/openstack_api/webstorage/supervisor.ex
@@ -1,12 +1,5 @@
 defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor do
-  @moduledoc ~s"""
-  Supervisor for the Ovh Openstack Configurations.
-
-  Rather than adding every single instance of an openstack account to the `secret.prod.exs` file, it is
-  probably better to start the openstack workers on demand.
-
-  The openstack workers cache the openstack token and maintain it.
-  """
+  @moduledoc :false
   use Supervisor
   alias ExOvh.Ovh.OpenstackApi.Webstorage.Cache
 
@@ -14,7 +7,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor do
   #  Public
   #####################
 
-  @doc ~s"""
+  @doc ~S"""
   Starts the OVH Openstack dynamic supervisor.
   """
   def start_link({client, config, opts}) do
diff --git a/lib/ovh/ovh_api/cache.ex b/lib/ovh/ovh_api/cache.ex
index 2ea1eba..eafe5a8 100644
--- a/lib/ovh/ovh_api/cache.ex
+++ b/lib/ovh/ovh_api/cache.ex
@@ -1,7 +1,5 @@
 defmodule ExOvh.Ovh.OvhApi.Cache do
-  @moduledoc ~s"""
-    Caches the ovh api time diff
-  """
+  @moduledoc :false
   use GenServer
   alias ExOvh.Ovh.Defaults
 
diff --git a/lib/ovh/ovh_api/request.ex b/lib/ovh/ovh_api/request.ex
index ef1ee77..e3addfa 100644
--- a/lib/ovh/ovh_api/request.ex
+++ b/lib/ovh/ovh_api/request.ex
@@ -1,4 +1,5 @@
 defmodule ExOvh.Ovh.OvhApi.Request do
+  @moduledoc :false
   alias ExOvh.Ovh.OvhApi.Auth
   alias ExOvh.Ovh.OvhApi.Cache
   alias ExOvh.Ovh.Defaults
@@ -35,11 +36,7 @@ defmodule ExOvh.Ovh.OvhApi.Request do
   # Private
   ############################
 
-
-  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]
 
 
 end
diff --git a/lib/ovh/request.ex b/lib/ovh/request.ex
index 7524f6a..acf9ce0 100644
--- a/lib/ovh/request.ex
+++ b/lib/ovh/request.ex
@@ -1,31 +1,61 @@
 defmodule ExOvh.Ovh.Request do
-  @moduledoc ~s"""
-    Delegates the request to the correct module and functions
-    according to what the opts map specifies.
-    `%{ openstack: :true }` ==> delegates the query to the OpenstackApi Module
-    `%{ }` ==> delegates the query to the HubicApi Module
+  @moduledoc ~S"""
+  Contains the `request` function which delegates the request
+  to the correct module and functions depending on the parameters in `opts`.
+
+  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.
+
+  This module's request function delegates the query to the correct `prepare_request`
+  function by pattern matching on the `opts` map.
+
+  ## Routing/Delegating depending on opts
+
+  `%{ }` -> `ExOvh.Ovh.OvhApi.Request`
+
+  `%{ openstack: :true, webstorage: "service_name" }` -> `ExOvh.Ovh.OpenstackApi.Webstorage.Request`
+
+  ## Subsequent Request modules
+
+  The subsequent request modules 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.Request, as: Open
+  alias ExOvh.Ovh.OpenstackApi.Webstorage.Request, as: Webstorage
 
 
-  ###################
-  # Public
-  ###################
+  @doc ~S"""
+  Redirects the query to the appropriate function dependeing on the `opts` key-values.
 
+  Subsequent request functions return `{:ok, response_t}` or `{:error, response_t}`
 
-  @spec request(query :: ExOvh.Client.raw_query_t, opts :: map)
-                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
-  def request({method, uri, params} = query, opts), do: request(ExOvh, query, opts)
+  ## Options
+
+      { } = opts
 
+  The request will be delegated to `ExOvh.Ovh.OvhApi.Request` and processed as a hubic api request.
+
+      { openstack: :true, webstorage: service } = opts
+
+  The request will be delegated to `ExOvh.Ovh.OpenstackApi.Webstorage.Request`
+  and processed as an openstack api request with the service value. The `service` value is a 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 } = opts), do: Open.request(client, query, opts)
-  def request(client, {method, uri, params} = query, opts), do: Ovh.request(client, query)
+  def request(client, {method, uri, params} = query, %{ openstack: :true, webstorage: service } = opts) do
+    Webstorage.request(client, query, service)
+  end
 
-  ###################
-  # Private
-  ###################
+  def request(client, {method, uri, params} = query, opts) do
+    Ovh.request(client, query)
+  end
 
 
 end
\ No newline at end of file
diff --git a/lib/ovh/supervisor.ex b/lib/ovh/supervisor.ex
index 2c7f4f6..89ac21f 100644
--- a/lib/ovh/supervisor.ex
+++ b/lib/ovh/supervisor.ex
@@ -1,7 +1,5 @@
 defmodule ExOvh.Ovh.Supervisor do
-  @moduledoc ~s"""
-  Supervisor for the Ovh Configuration
-  """
+  @moduledoc :false
   use Supervisor
   alias ExOvh.Ovh.OvhApi.Cache
   alias ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor, as: Webstorage
@@ -10,7 +8,7 @@ defmodule ExOvh.Ovh.Supervisor do
   #  Public
   #####################
 
-  @doc ~s"""
+  @doc ~S"""
   Starts the OVH supervisor.
   """
   def start_link(client, config, opts) do
@@ -32,6 +30,11 @@ defmodule ExOvh.Ovh.Supervisor do
     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__))
 
 
diff --git a/lib/query/hubic/query.ex b/lib/query/hubic/query.ex
index 567505d..2a35b2e 100644
--- a/lib/query/hubic/query.ex
+++ b/lib/query/hubic/query.ex
@@ -1,5 +1,5 @@
 defmodule ExOvh.Query.Hubic do
-  @moduledoc ~s"""
+  @moduledoc ~S"""
     Helps to build queries for the hubic api.
 
     The raw query can be passed into a client request.
@@ -17,7 +17,7 @@ defmodule ExOvh.Query.Hubic do
   # General Hubic Requests
   #########################
 
-  @doc ~s"""
+  @doc ~S"""
   GET /scope/scope, Get the possible scopes for hubiC API
 
     ### Example:
@@ -29,7 +29,7 @@ defmodule ExOvh.Query.Hubic do
   def scope(), do: {:get, "/scope/scope", :nil}
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /account, Get the account object properties
 
     ### Example:
@@ -41,7 +41,7 @@ defmodule ExOvh.Query.Hubic do
   def account(), do: {:get, "/account", :nil}
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /account/credentials, Returns openstack credentials for connecting to the file API
 
       ### Example:
@@ -53,7 +53,7 @@ defmodule ExOvh.Query.Hubic do
   def openstack_credentials(), do: {:get, "/account/credentials", :nil}
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /account/usage, Returns used space & quota of your account
 
       ### Example:
@@ -115,7 +115,7 @@ defmodule ExOvh.Query.Hubic do
   def get_link(uri), do: {:get, "/account/links/", uri}
 
 
-  @doc ~s"""
+  @doc ~S"""
   POST /account/links, Create a public url to a file
 
   Note: links have a max ttl of 30 days on hubic currently.
@@ -156,7 +156,7 @@ defmodule ExOvh.Query.Hubic do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   DELETE /account/links/{uri}, Deletes a public url to a file
 
 
diff --git a/lib/query/openstack/swift/query.ex b/lib/query/openstack/swift/query.ex
index 1079e9b..1f535f7 100644
--- a/lib/query/openstack/swift/query.ex
+++ b/lib/query/openstack/swift/query.ex
@@ -1,5 +1,5 @@
 defmodule ExOvh.Query.Openstack.Swift do
-  @moduledoc ~s"""
+  @moduledoc ~S"""
   Helps to build queries for the openstack swift api.
   The raw query can be passed into a client request.
 
@@ -20,7 +20,7 @@ defmodule ExOvh.Query.Openstack.Swift do
   #############################
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​{account}​, Get account details and containers for given account
 
   ### Example usage
@@ -37,7 +37,7 @@ defmodule ExOvh.Query.Openstack.Swift do
   def account_info(account), do: {:get, account, %{ "format" => "json" }}
 
 
-  @doc ~s"""
+  @doc ~S"""
   PUT /v1/​{account}/{container}​, Create a new container
 
   ### Example usage
@@ -55,7 +55,7 @@ defmodule ExOvh.Query.Openstack.Swift do
   def create_container(account, container), do: {:put, account <> "/" <> container, %{ "format" => "json" }}
 
 
-  @doc ~s"""
+  @doc ~S"""
   DELETE /v1/​{account}/{container}​, Delete a container
 
   ### Example usage
@@ -78,7 +78,7 @@ defmodule ExOvh.Query.Openstack.Swift do
   ##########################
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​{account}​/{container}, List objects in a container
 
   ### Example usage
@@ -97,7 +97,7 @@ defmodule ExOvh.Query.Openstack.Swift do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​{account}​/{container}/{object}, Get/Download a specific object (file)
 
   ### Example usage
diff --git a/lib/query/ovh/webstorage/query.ex b/lib/query/ovh/webstorage/query.ex
index f7fa779..c3fd0fb 100644
--- a/lib/query/ovh/webstorage/query.ex
+++ b/lib/query/ovh/webstorage/query.ex
@@ -1,5 +1,5 @@
 defmodule ExOvh.Query.Ovh.Webstorage do
-  @moduledoc ~s"""
+  @moduledoc ~S"""
   Helps to build queries for the openstack swift api.
   The raw query can be passed into a client request.
 
@@ -13,7 +13,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​cdn/webstorage​, Get a list of all webstorage cdn services available for the client account
 
   ### Example usage
@@ -28,7 +28,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​cdn/webstorage​/{serviceName}, Get the domain, server and storage limits for a specific webstorage cdn service
 
   ### Example usage
@@ -50,7 +50,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​cdn/webstorage​/{serviceName}/serviceInfos, Get a administrative details for a specific webstorage cdn service
 
   ### Example usage
@@ -67,7 +67,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​cdn/webstorage​/{serviceName}/statistics, Get statistics for a specific webstorage cdn service
 
     `period can be "month", "week" or "day"`
@@ -89,7 +89,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
 
 
-  @doc ~s"""
+  @doc ~S"""
   GET /v1/​cdn/webstorage​/{serviceName}/credentials, Get credentials for using the swift compliant api
 
   ### Example usage
diff --git a/lib/supervisor.ex b/lib/supervisor.ex
index 3a77372..768b123 100644
--- a/lib/supervisor.ex
+++ b/lib/supervisor.ex
@@ -1,6 +1,6 @@
 defmodule ExOvh.Supervisor do
-  @moduledoc ~s"""
-  Supervisor for the Ovh Configuration
+  @moduledoc ~S"""
+  Supervisor for the Hubic and Ovh api configuration.
   """
   use Supervisor
   alias ExOvh.Ovh.Cache
@@ -15,8 +15,14 @@ defmodule ExOvh.Supervisor do
   #  Public
   #####################
 
-  @doc ~s"""
+  @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
     LoggingUtils.log_mod_func_line(__ENV__, :debug)
@@ -56,10 +62,11 @@ defmodule ExOvh.Supervisor do
 
 
   @doc """
-  Returns ovh configuration settings or an error
-  if the ovh config is not found
-  ## <<TODO>> Add some additional config validation (
-  to test absence of essential information)
+  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
@@ -71,7 +78,11 @@ defmodule ExOvh.Supervisor do
 
 
   @doc """
-  Returns hubic configuration settings
+  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