:ex_ovh
to the dependencies. defp deps() do
[{:ex_ovh, "~> 0.0.1"}]
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
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: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
api_version: System.get_env("MY_APP_OVH_CLIENT_API_VERSION") || "1.0"
]
Make further configurations if necessary, depending on which OVH services are being used.
Configuration for webstorage cdn service
In the example below, MY_APP_OVH_CLIENT_WEBSTORAGE_CDN_NAME
is added to the environment variables.
config :ex_ovh,
ovh: [],
swift: [
webstorage: [
cdn_name: System.get_env("MY_APP_OVH_CLIENT_WEBSTORAGE_CDN_NAME"),
type: :webstorage
]
]
In the example below, MY_APP_OVH_CLIENT_CLOUDSTORAGE_TENANT_ID
and MY_APP_OVH_CLIENT_CLOUDSTORAGE_USER_ID
are
added to the environment variables.
config :ex_ovh,
ovh: [],
swift: [
cloudstorage: [
tenant_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
user_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_USER_ID"), # optional, if absent a user will be created using the ovh api.
keystone_endpoint: "https://auth.cloud.ovh.net/v2.0", # default endpoint for keystone (identity) auth
region: :nil, # defaults to "SBG1" if set to :nil
type: :cloudstorage
]
]
:openstex
which allows customization of httpoison opts
for each request. Example configuration for custom httpoison opts (optional): config :openstex,
httpoison: [
connect_timeout: 30000, # 30 seconds
receive_timeout: (60000 * 30) # 30 minutes
]
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
# Getting Started (Advanced)
## Installation
- Add `:ex_ovh` to the dependencies.
```elixir
defp deps() do
[{:ex_ovh, "~> 0.0.1"}]
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
```
## 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: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
api_version: System.get_env("MY_APP_OVH_CLIENT_API_VERSION") || "1.0"
]
```
- Make further configurations if necessary, depending on which OVH services are being used.
- Configuration for [webstorage cdn service](https://www.ovh.ie/cdn/webstorage/)
In the example below, `MY_APP_OVH_CLIENT_WEBSTORAGE_CDN_NAME` is added to the environment variables.
```elixir
config :ex_ovh,
ovh: [],
swift: [
webstorage: [
cdn_name: System.get_env("MY_APP_OVH_CLIENT_WEBSTORAGE_CDN_NAME"),
type: :webstorage
]
]
```
- Configuration for public cloud storage service](https://www.ovh.ie/cloud/storage/)
In the example below, `MY_APP_OVH_CLIENT_CLOUDSTORAGE_TENANT_ID` and `MY_APP_OVH_CLIENT_CLOUDSTORAGE_USER_ID` are
added to the environment variables.
```elixir
config :ex_ovh,
ovh: [],
swift: [
cloudstorage: [
tenant_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
user_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_USER_ID"), # optional, if absent a user will be created using the ovh api.
keystone_endpoint: "https://auth.cloud.ovh.net/v2.0", # default endpoint for keystone (identity) auth
region: :nil, # defaults to "SBG1" if set to :nil
type: :cloudstorage
]
]
```
- Optionally configure `:openstex` which allows customization of [httpoison opts](https://github.com/edgurgel/httpoison/blob/master/lib/httpoison/base.ex#L127)
for each request. Example configuration for custom [httpoison opts](https://github.com/edgurgel/httpoison/blob/master/lib/httpoison/base.ex#L127) (optional):
```elixir
config :openstex,
httpoison: [
connect_timeout: 30000, # 30 seconds
receive_timeout: (60000 * 30) # 30 minutes
]
```