The basic installation is intended for use cases where only a single client is required on a given server.
:ex_ovh
to the dependencies. defp deps() do
[{:ex_ovh, "~> 0.2"}]
end
OVH
ConfigurationCreate an OVH account at OVH
Create an API application at the OVH API page. Follow the steps outlined by OVH there.
Add the configuration settings for the OVH application to your project config.exs
. The following
environment variables should be set:
EX_OVH_APPLICATION_KEY
EX_OVH_APPLICATION_SECRET
EX_OVH_CONSUMER_KEY
Set them by adding them to the .env
file. It’s best not to share .env
so run
echo ‘.env’ >> .gitignorefor the git repository to ensure it doesn't get added to source control. The
.envfile will be similar to as follows: ``` #!/usr/bin/env bash # updated on 16.2.2017 export MY_APP_OVH_CLIENT_APPLICATION_KEY="<application_key>" export MY_APP_OVH_CLIENT_APPLICATION_SECRET="<application_secret>" export MY_APP_OVH_CLIENT_CONSUMER_KEY="<application_consumer_key>" ``` - If all of the above seems like too much work, then there is a mix task to help generate the application, see [basic mix task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_basic.md) or [advanced mix task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_advanced.md) #### Some useful requests in the
OVH consoleto see applications -
GET /me/api/application-- returns a list of application ids. -
GET /me/api/application/{applicationId}-- returns json with application key. #### Creating the appropriate
config.exsfile. ```elixir config :ex_ovh, 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") ] ``` - Start the
ExOvhapplication. ```elixir def application do [applications: [:ex_ovh]] end ``` - Add the client to your project. ```elixir defmodule ExOvh do @moduledoc :false use ExOvh.Client, otp_app: :my_app, client: __MODULE__ end ``` - Add the
ExOvhclient to the supervision tree of your application. ```elixir def start(_type, _args) do import Supervisor.Spec, warn: false spec1 = [supervisor(MyApp.Endpoint, [])] spec2 = [supervisor(ExOvh, [])] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(spec1 ++ spec2, opts) end ``` - Now you are read to use the api, open up an
iex` console and give it a try.
iex -S mix
ExOvh.
```
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
# Getting Started (Basic)
The basic installation is intended for use cases where only a single client is required
on a given server.
#### Installation
- Add `:ex_ovh` to the dependencies.
```elixir
defp deps() do
[{:ex_ovh, "~> 0.2"}]
end
```
#### `OVH` Configuration
- 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.
- Add the configuration settings for the OVH application to your project `config.exs`. The following
environment variables should be set:
- `EX_OVH_APPLICATION_KEY`
- `EX_OVH_APPLICATION_SECRET`
- `EX_OVH_CONSUMER_KEY`
- Set them by adding them to the `.env` file. It's best not to share `.env` so run
echo '.env' >> .gitignore` for the git repository to ensure it doesn't get added to source control.
The `.env` file will be similar to as follows:
```
#!/usr/bin/env bash
# updated on 16.2.2017
export MY_APP_OVH_CLIENT_APPLICATION_KEY="<application_key>"
export MY_APP_OVH_CLIENT_APPLICATION_SECRET="<application_secret>"
export MY_APP_OVH_CLIENT_CONSUMER_KEY="<application_consumer_key>"
```
- If all of the above seems like too much work, then there is a mix task to help generate the application, see
[basic mix task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_basic.md) or
[advanced mix task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_advanced.md)
#### Some useful requests in the `OVH console` to see applications
- `GET /me/api/application` -- returns a list of application ids.
- `GET /me/api/application/{applicationId}` -- returns json with application key.
#### Creating the appropriate `config.exs` file.
```elixir
config :ex_ovh,
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")
]
```
- Start the `ExOvh` application.
```elixir
def application do
[applications: [:ex_ovh]]
end
```
- Add the client to your project.
```elixir
defmodule ExOvh do
@moduledoc :false
use ExOvh.Client, otp_app: :my_app, client: __MODULE__
end
```
- Add the `ExOvh` client to the supervision tree of your application.
```elixir
def start(_type, _args) do
import Supervisor.Spec, warn: false
spec1 = [supervisor(MyApp.Endpoint, [])]
spec2 = [supervisor(ExOvh, [])]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(spec1 ++ spec2, opts)
end
```
- Now you are read to use the api, open up an `iex` console and give it a try.
```
iex -S mix
```
ExOvh.
```