change to Webstorage.Request
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
diff --git a/lib/ovh/openstack_api/webstorage/request.ex b/lib/ovh/openstack_api/webstorage/request.ex
index 9af33a4..5cd5e5f 100644
--- a/lib/ovh/openstack_api/webstorage/request.ex
+++ b/lib/ovh/openstack_api/webstorage/request.ex
@@ -10,18 +10,29 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Request do
{method, uri, options} = Auth.prepare_request(client, query, service)
resp = HTTPotion.request(method, uri, options)
- resp =
- %{
- body: resp.body |> Poison.decode!(),
- headers: resp.headers,
- status_code: resp.status_code
- }
+ |> Og.log_return(:debug)
if resp.status_code >= 100 and resp.status_code < 300 do
- {:ok, resp}
+ 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
diff --git a/lib/query/ovh/webstorage/query.ex b/lib/query/ovh/webstorage/query.ex
index 3a22bc8..73e1539 100644
--- a/lib/query/ovh/webstorage/query.ex
+++ b/lib/query/ovh/webstorage/query.ex
@@ -34,7 +34,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
import ExOvh.Query.Ovh.Webstorage
service_name = "cdnwebstorage-????"
- resp = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
+ {:ok, resp} = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
%{
"domain" => domain,
"storageLimit => storage_limit,
@@ -54,7 +54,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
import ExOvh.Query.Ovh.Webstorage
service_name = "cdnwebstorage-????"
- resp = ExOvh.ovh_request(get_webstorage_service_info(service_name), %{})
+ {: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
@@ -72,7 +72,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
import ExOvh.Query.Ovh.Webstorage
# service_name = "cdnwebstorage-????"
- resp = ExOvh.ovh_request(get_webstorage_service_stats(service_name, "month", "backend"), %{})
+ {: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
@@ -89,7 +89,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
import ExOvh.Query.Ovh.Webstorage
# service_name = "cdnwebstorage-????"
- resp = ExOvh.ovh_request(get_webstorage_credentials(service_name), %{})
+ {:ok, resp} = ExOvh.ovh_request(get_webstorage_credentials(service_name), %{})
"""
@spec get_webstorage_credentials(service_name :: String.t)
:: ExOvh.Client.raw_query_t