improve query 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
diff --git a/lib/hubic/hubic_api/request.ex b/lib/hubic/hubic_api/request.ex
index 5cfd436..fba7ac6 100644
--- a/lib/hubic/hubic_api/request.ex
+++ b/lib/hubic/hubic_api/request.ex
@@ -6,6 +6,7 @@ defmodule ExOvh.Hubic.HubicApi.Request do
@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)
LoggingUtils.log_return({method, uri, options}, :debug)
@@ -32,7 +33,7 @@ defmodule ExOvh.Hubic.HubicApi.Request do
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(query, opts, 1) # Try request one more time
+ unless retries >= 1, do: request(client, query, opts, 1) # Try request one more time
else
{:error, resp}
end
diff --git a/lib/hubic/openstack_api/cache.ex b/lib/hubic/openstack_api/cache.ex
index d1fa358..94b7344 100644
--- a/lib/hubic/openstack_api/cache.ex
+++ b/lib/hubic/openstack_api/cache.ex
@@ -5,7 +5,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
alias ExOvh.Hubic.Request
@get_credentials_retries 10
@get_credentials_sleep_interval 150
- @init_delay 3_000
+ @init_delay 2_000
#####################
@@ -62,7 +62,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
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", ""}, %{})
+ {:ok, resp} = Request.request(client, {:get, "/account/credentials", :nil}, %{})
|> LoggingUtils.log_return(:debug)
credentials = Map.put(resp.body, :lock, :false)
:ets.insert(ets_tablename(client), {:credentials, credentials})
diff --git a/lib/hubic/request.ex b/lib/hubic/request.ex
index 9e0f115..4d1b00b 100644
--- a/lib/hubic/request.ex
+++ b/lib/hubic/request.ex
@@ -30,7 +30,7 @@ defmodule ExOvh.Hubic.Request do
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.HubicApi.Request, as: Hubic
alias ExOvh.Hubic.OpenstackApi.Request, as: Open
@@ -58,7 +58,7 @@ defmodule ExOvh.Hubic.Request do
end
def request(client, {method, uri, params} = query, opts) do
- Hub.request(client, query)
+ Hubic.request(client, query, opts)
end
diff --git a/lib/hubic/request_helpers.ex b/lib/hubic/request_helpers.ex
index 9ed8a82..18c4afc 100644
--- a/lib/hubic/request_helpers.ex
+++ b/lib/hubic/request_helpers.ex
@@ -1,4 +1,7 @@
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
@@ -12,11 +15,9 @@ defmodule ExOvh.Hubic.RequestHelpers do
## Example
- ```elixir
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}
@@ -42,13 +43,18 @@ defmodule ExOvh.Hubic.RequestHelpers do
## Example
- ```elixir
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}
diff --git a/lib/mix/tasks/hubic.ex b/lib/mix/tasks/hubic.ex
index e59e9e7..8755faa 100644
--- a/lib/mix/tasks/hubic.ex
+++ b/lib/mix/tasks/hubic.ex
@@ -171,7 +171,7 @@ defmodule Mix.Tasks.Hubic do
#- Adds the refresh_token to the opts_map
@spec get_refresh_token(opts_map :: map) :: map
- def get_refresh_token(opts_map) do
+ defp get_refresh_token(opts_map) do
LoggingUtils.log_mod_func_line(__ENV__, :debug)
auth_credentials = opts_map.client_id <> ":" <> opts_map.client_secret
auth_credentials_base64 = Base.encode64(auth_credentials)
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index d03848c..05f68b0 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -221,7 +221,7 @@ defmodule Mix.Tasks.Ovh do
defp get_application_key(body), do: Map.get(extract(body), "key")
defp get_application_name(body), do: Map.get(extract(body), "name")
defp get_application_description(body), do: Map.get(extract(body), "description")
- def extract(body) do
+ defp extract(body) do
Floki.find(body, "pre")
|> Enum.map(fn({"pre", [], [val]}) -> val end)
|> Enum.map(fn(ext) ->
diff --git a/lib/ovh/request.ex b/lib/ovh/request.ex
index 8a541b8..4a6e8d4 100644
--- a/lib/ovh/request.ex
+++ b/lib/ovh/request.ex
@@ -60,7 +60,7 @@ defmodule ExOvh.Ovh.Request do
end
def request(client, {method, uri, params} = query, opts) do
- Ovh.request(client, query)
+ Ovh.request(client, query, opts)
end
diff --git a/lib/query/hubic/query.ex b/lib/query/hubic/query.ex
index 2a35b2e..4ecb55f 100644
--- a/lib/query/hubic/query.ex
+++ b/lib/query/hubic/query.ex
@@ -1,15 +1,13 @@
defmodule ExOvh.Query.Hubic do
@moduledoc ~S"""
- Helps to build queries for the hubic api.
+ Helper functions for building queries for the hubic api.
- The raw query can be passed into a client request.
+ The raw query can be passed into a client request.
## Example
- ```elixir
import ExOvh.Query.Hubic, only: [scope: 0]
scope = ExOvh.hubic_request(scope())
- ```
"""
@@ -17,6 +15,7 @@ defmodule ExOvh.Query.Hubic do
# General Hubic Requests
#########################
+
@doc ~S"""
GET /scope/scope, Get the possible scopes for hubiC API
diff --git a/lib/query/openstack/swift/query.ex b/lib/query/openstack/swift/query.ex
index 1f535f7..c99b7f7 100644
--- a/lib/query/openstack/swift/query.ex
+++ b/lib/query/openstack/swift/query.ex
@@ -1,16 +1,15 @@
defmodule ExOvh.Query.Openstack.Swift do
@moduledoc ~S"""
- Helps to build queries for the openstack swift api.
+ Helper functions for to building queries for the openstack compatible swift apis.
+
The raw query can be passed into a client request.
## Example
- ```elixir
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
diff --git a/lib/query/ovh/webstorage/query.ex b/lib/query/ovh/webstorage/query.ex
index c3fd0fb..3a22bc8 100644
--- a/lib/query/ovh/webstorage/query.ex
+++ b/lib/query/ovh/webstorage/query.ex
@@ -1,13 +1,14 @@
defmodule ExOvh.Query.Ovh.Webstorage do
@moduledoc ~S"""
- Helps to build queries for the openstack swift api.
+ 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
- ```elixir
import ExOvh.Query.Ovh.Webstorage
- ```
+ query = get_all_webstorage()
+ ExOvh.ovh_request(query, %{})
"""
alias ExOvh.Ovh.OvhApi.Cache, as: OvhApiCache
@@ -18,10 +19,8 @@ defmodule ExOvh.Query.Ovh.Webstorage do
### Example usage
- ```elixir
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}
@@ -33,7 +32,6 @@ defmodule ExOvh.Query.Ovh.Webstorage do
### Example usage
- ```elixir
import ExOvh.Query.Ovh.Webstorage
service_name = "cdnwebstorage-????"
resp = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
@@ -42,7 +40,6 @@ defmodule ExOvh.Query.Ovh.Webstorage do
"storageLimit => storage_limit,
"server" => server
} = resp.body
- ```
"""
@spec get_webstorage_service(service_name :: String.t)
:: ExOvh.Client.raw_query_t
@@ -55,11 +52,9 @@ defmodule ExOvh.Query.Ovh.Webstorage do
### Example usage
- ```elixir
import ExOvh.Query.Ovh.Webstorage
service_name = "cdnwebstorage-????"
resp = ExOvh.ovh_request(get_webstorage_service_info(service_name), %{})
- ```
"""
@spec get_webstorage_service_info(service_name :: String.t)
:: ExOvh.Client.raw_query_t
@@ -75,11 +70,9 @@ defmodule ExOvh.Query.Ovh.Webstorage do
### Example usage
- ```elixir
import ExOvh.Query.Ovh.Webstorage
# service_name = "cdnwebstorage-????"
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
@@ -94,11 +87,9 @@ defmodule ExOvh.Query.Ovh.Webstorage do
### Example usage
- ```elixir
import ExOvh.Query.Ovh.Webstorage
# service_name = "cdnwebstorage-????"
resp = ExOvh.ovh_request(get_webstorage_credentials(service_name), %{})
- ```
"""
@spec get_webstorage_credentials(service_name :: String.t)
:: ExOvh.Client.raw_query_t