ExOvh v0.3.0 ExOvh.Client behaviour

A behaviour for setting up an OVH client.

Example 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"
  ],
  # default hackney options to each request (optional)
  hackney: [
     connect_timeout: 20000,
     recv_timeout: 100000
  ]

Example using the ExOvh client

%HTTPipe.Request{ method: :get, url: "/me", params: %{}} |> ExOvh.request!()
%HTTPipe.Request{ method: :get, url: "/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")
  ],
  # default hackney options to each request (optional)
  hackney: [
     connect_timeout: 20000,
     recv_timeout: 100000
  ]

Example using the MyApp.MyClient client

%HTTPipe.Request{ method: :get, url: "/me", params: %{}} |> MyApp.MyClient.request!()
%ExOvh.Query{ method: :get, url: "/cloud/project", params: %{}} |> MyApp.MyClient.request!()

Summary

Callbacks

config()
config() :: Keyword.t
hackney_opts()
hackney_opts() :: Keyword.t
ovh_config()
ovh_config() :: Keyword.t
request(conn)
request(conn :: HTTPipe.Conn.t) ::
  {:ok, HTTPipe.Conn.t} |
  {:error, HTTPipe.Conn.t}
request!(conn)
request!(conn :: HTTPipe.Conn.t) :: HTTPipe.Conn.t | no_return
start_link(sup_opts)
start_link(sup_opts :: list) :: {:ok, pid} | {:error, atom}