:ex_ovh
to the dependencies. defp deps() do
[{:ex_ovh, "~> 0.0.1"}]
end
Note: The configuration assumes that the environment variables such as MY_APP_OVH_CLIENT_CLIENT_ID
are already created.
Create an OVH account at OVH
Create an API application at the OVH API page. Follow the steps outlined by OVH there. Alternatively, there is a mix task which can help generate the OVH application.
Add the configuration settings for the OVH application to your project config.exs
.
config :my_app, MyApp.OvhClient,
ovh: [
application_key: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_KEY"),
application_secret: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_SECRET"),
consumer_key: System.get_env("MY_APP_OVH_CLIENT_CONSUMER_KEY"),
endpoint: "ovh-eu",
api_version: "1.0"
],
httpoison: [ # optional
connect_timeout: 20000,
receive_timeout: 100000
]
ExOvh
application. def application do
[applications: [:ex_ovh]]
end
defmodule MyApp.OvhClient do
@moduledoc :false
use ExOvh.Client, otp_app: :my_app, client: __MODULE__
end
def start(_type, _args) do
import Supervisor.Spec, warn: false
spec1 = [supervisor(MyApp.Endpoint, [])]
spec2 = [supervisor(MyApp.OvhClient, [])]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(spec1 ++ spec2, opts)
end
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
# Getting Started (Advanced)
## Installation
- Add `:ex_ovh` to the dependencies.
```elixir
defp deps() do
[{:ex_ovh, "~> 0.0.1"}]
end
```
## Configuration
*Note:* The configuration assumes that the environment variables such as `MY_APP_OVH_CLIENT_CLIENT_ID` are already created.
- Create an OVH account at [OVH](https://www.ovh.com/us/)
- Create an API application at the [OVH API page](https://eu.api.ovh.com/createApp/). Follow the
steps outlined by OVH there. Alternatively, there is a [mix task](https://hexdocs.pm/ex_hubic/doc/mix_task_advanced.md.html) which can help
generate the OVH application.
- Add the configuration settings for the OVH application to your project `config.exs`.
```elixir
config :my_app, MyApp.OvhClient,
ovh: [
application_key: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_KEY"),
application_secret: System.get_env("MY_APP_OVH_CLIENT_APPLICATION_SECRET"),
consumer_key: System.get_env("MY_APP_OVH_CLIENT_CONSUMER_KEY"),
endpoint: "ovh-eu",
api_version: "1.0"
],
httpoison: [ # optional
connect_timeout: 20000,
receive_timeout: 100000
]
```
- Start the `ExOvh` application.
```elixir
def application do
[applications: [:ex_ovh]]
end
```
- Add the client to your project.
```elixir
defmodule MyApp.OvhClient do
@moduledoc :false
use ExOvh.Client, otp_app: :my_app, client: __MODULE__
end
```
- Add the client as a supervisor directly to the supervision tree of your application.
```elixir
def start(_type, _args) do
import Supervisor.Spec, warn: false
spec1 = [supervisor(MyApp.Endpoint, [])]
spec2 = [supervisor(MyApp.OvhClient, [])]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(spec1 ++ spec2, opts)
end
```