ExOvh v0.1.1 ExOvh.Client behaviour
A behaviour for setting up an OVH client.
Example (1): Setting up the ExOvh
Client
Defining a client:
defmodule ExOvh do
@moduledoc :false
use ExOvh.Client, otp_app: :ex_ovh, client: __MODULE__
end
Configuring a client:
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: "ovh-eu",
api_version: "1.0"
],
httpoison: [ # optional
connect_timeout: 20000,
receive_timeout: 100000
]
Example using the ExOvh
client
%ExOvh.Query{ method: :get, uri: "/me", params: %{}} |> ExOvh.request!()
%ExOvh.Query{ method: :get, uri: "/cloud/project", params: %{}} |> ExOvh.request!()
Example (2): Setting up an additional MyApp.MyClient
client.
Defining the MyApp.MyClient
defmodule MyApp.MyClient do
@moduledoc :false
use ExOvh.Client, otp_app: :my_app
end
Configuring the MyApp.MyClient
config :my_app, MyApp.MyClient,
ovh: [
application_key: System.get_env("MY_APP_MY_CLIENT_APPLICATION_KEY"),
application_secret: System.get_env("MY_APP_MY_CLIENT_APPLICATION_SECRET"),
consumer_key: System.get_env("MY_APP_MY_CLIENT_CONSUMER_KEY")
# if left out, :endpoint will default to "ovh-eu"
# if left out, :api_version will default to "1.0"
],
httpoison: [ # optional
connect_timeout: 20000,
receive_timeout: 100000
]
Example using the MyApp.MyClient
client
%ExOvh.Query{ method: :get, uri: "/me", params: %{}} |> MyApp.MyClient.request!()
%ExOvh.Query{ method: :get, uri: "/cloud/project", params: %{}} |> MyApp.MyClient.request!()
Summary
Callbacks
Specs
prepare_request(query :: ExOvh.Query.t, httpoison_opts :: Keyword.t) ::
ExOvh.Query.t |
no_return
Specs
request(query :: ExOvh.Query.t | ExOvh.HttpQuery.t, httpoison_opts :: Keyword.t) ::
{:ok, ExOvh.Response.t} |
{:error, ExOvh.Response.t}
Specs
request!(query :: ExOvh.Query.t | ExOvh.HttpQuery.t, httpoison_opts :: Keyword.t) ::
{:ok, ExOvh.Response.t} |
no_return