changes to docs
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
diff --git a/README.md b/README.md
index 7aaedaa..dd1ada0 100644
--- a/README.md
+++ b/README.md
@@ -2,62 +2,65 @@
ExOvh is an helper library for the [elixir language](http://elixir-lang.org/) for the [Ovh Api](https://api.ovh.com/).
-
To use the Openstack components of the OVH API, see [Openstex](https://github.com/stephenmoloney/openstex)
-## Project Features
+#### Project Features
-- Config supervised Agent running in the background which stores frequently accessed authentication information.
+- Config supervised agent running in the background which stores frequently accessed authentication information.
- Query modules for making building requests to the [Ovh Api](https://api.ovh.com/).
-- request functions to send Queries to the [Ovh Api](https://api.ovh.com/).
+- Request functions to send Queries to the [Ovh Api](https://api.ovh.com/).
+
+
+
+#### Getting started - Step 1: Generating the OVH `application key`, `application secret` and `consumer key`.
-## Documentation
+- This may be done manually by going to `https://eu.api.ovh.com/createApp/` and following the directions outlined by `OVH` ath
+[their first steps guide](https://api.ovh.com/g934.first_step_with_api).
-- [See Hex Docs](https://hexdocs.pm/ex_ovh/0.1.1/api-reference.html)
+- Alternatively, this may be achieved by running a mix task. This saves me a lot of time when generating a new application.
+ [Documentation here](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task.md)
-## Getting started
-#### Example (1)
+#### Getting Started - Step 2: Generating the OVH client module for your elixir application
-| Step 1: Generating the OVH application | Step 2: Setup |
-|---|---|
-| [Mix Task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_basic.md) (optional) | [Setting up the Client](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/getting_started_basic.md) |
+- The client module (eg `AwesomeApp.OvhClient`) is the interface for accessing the
+functions of the ***ex_ovh*** `API`.
-#### Example (2) - Recommended way of getting started
+- [Documentation here](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/getting_started.md)
-| Step 1: Generating the OVH application | Step 2: Setup |
-|---|---|
-| [Mix Task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_advanced.md) (optional) | [Setting up Clients](https://hexdocs.pm/ex_ovh/blob/master/docs/getting_started_advanced.md) |
+#### Usage
-## Usage
+- Basic examples to be added to readme.
-- To be added
+[See Hex Docs](https://hexdocs.pm/ex_ovh/0.2/api-reference.html)
-## Contributing
+#### Contributing
- Pull requests welcome.
-## Tests
+#### Tests
- Tests have not been written yet.
-## TODO
+#### TODO
- [ ] Tests for OVH portion of library
- [ ] Option to set the application ttl when running ovh mix task.
- [ ] Add queries for the remainder of the OVH API. (Webstorage CDN and Cloud are the only ones covered so far)
+- [ ] Basic examples to be added to readme of usage of the api.
+- [ ] Add macro for building queries.
-## Note
+#### Note
This is an unofficial client to the OVH api and is not maintained by OVH.
-## Licence
+#### Licence
[MIT Licence](LICENCE.md)
\ No newline at end of file
diff --git a/docs/getting_started.md b/docs/getting_started.md
new file mode 100644
index 0000000..a5c1cd2
--- /dev/null
+++ b/docs/getting_started.md
@@ -0,0 +1,129 @@
+# Getting Started
+
+- This guide assumes your application is called `MyApp`. If your app is called something else, for example `Awesome`,
+then substitute `Awesome` for `MyApp` and `AWESOME_OVH_CLIENT_` for `MY_APP_OVH_CLIENT_` everywhere in this guide.
+
+
+#### Installation
+
+- Add `:ex_ovh` to the dependencies inx `mix.exs`.
+
+```elixir
+defp deps() do
+ [{:ex_ovh, "~> 0.1"}]
+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 the project `config.exs`. The following
+environment variables should be set:
+
+ - `MY_APP_OVH_CLIENT_APPLICATION_KEY`
+ - `MY_APP_OVH_CLIENT_APPLICATION_KEY`
+ - `MY_APP_OVH_CLIENT_APPLICATION_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
+[mix task docs](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task.md).
+
+
+#### Creating a client module
+
+***NOTE:*** Matching naming between `MyApp.OvhClient` and `MY_APP_OVH_CLIENT_APPLICATION_KEY` variables is expected.
+
+- Basic settings
+ ```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"),
+ ]
+ ```
+
+- More elaborate settings
+ ```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
+ ]
+ ```
+
+#### Starting the `ex_ovh application`
+
+- Add `ex_ovh` to the list of applications so that it is started. Start the `ExOvh` application.
+
+```elixir
+def application do
+ [applications: [:ex_ovh]]
+end
+```
+
+
+#### Create the ovh client module
+
+
+```elixir
+defmodule MyApp.OvhClient do
+ @moduledoc :false
+ use ExOvh.Client, otp_app: :my_app, client: __MODULE__
+end
+```
+
+#### Add the client to the application supervision tree
+
+```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
+```
+
+#### Making requests
+
+- The client `MyApp.OvhClient` is now ready.
+
+- To make requests see example usages below:
+
+
+#### Example usages
+
+- First start the application `iex -S mix`
+
+- Then try running some requests against the `API`
+
+
+
+#### 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.
\ No newline at end of file
diff --git a/docs/getting_started_advanced.md b/docs/getting_started_advanced.md
index 20c8922..9123584 100644
--- a/docs/getting_started_advanced.md
+++ b/docs/getting_started_advanced.md
@@ -1,4 +1,4 @@
-# Getting Started (Advanced)
+# Getting Started
## Installation
diff --git a/docs/getting_started_basic.md b/docs/getting_started_basic.md
index f19a70c..2dbcb9a 100644
--- a/docs/getting_started_basic.md
+++ b/docs/getting_started_basic.md
@@ -3,7 +3,7 @@
The basic installation is intended for use cases where only a single client is required
on a given server.
-## Installation
+#### Installation
- Add `:ex_ovh` to the dependencies.
@@ -13,30 +13,53 @@ defp deps() do
end
```
-## Configuration
-
-*Note:* The configuration assumes that the environment variables such as `EX_OVH_CLIENT_ID` are already created.
+#### `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. Alternatively, there is a [mix task](https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_basic.md) which can help
- generate the OVH application.
-
-- Add the configuration settings for the OVH application to your project `config.exs`.
+ 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("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
+ 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")
]
```
@@ -69,3 +92,11 @@ def start(_type, _args) do
end
```
+- Now you are read to use the api, open up an `iex` console and give it a try.
+
+```
+iex -S mix
+```
+ExOvh.
+```
+
diff --git a/docs/mix_task.md b/docs/mix_task.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/docs/mix_task.md
diff --git a/lib/ex_ovh/docs/mix_task.ex b/lib/ex_ovh/docs/mix_task.ex
index fac40fe..3ef0483 100644
--- a/lib/ex_ovh/docs/mix_task.ex
+++ b/lib/ex_ovh/docs/mix_task.ex
@@ -29,17 +29,10 @@ defmodule Mix.Tasks.Ovh.Docs do
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
+ consumer_key: System.get_env("EX_OVH_CONSUMER_KEY")
]
- See the [mix task basic](https://hexdocs.pm/ex_ovh/doc/mix_task_basic.md.html) or
- [mix task advanced](https://hexdocs.pm/ex_ovh/doc/mix_task_advanced.md.html) for practical steps involved in running the hubic mix task.
+ See the [mix task documentation]((https://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task.md).
"""
end
diff --git a/mix.exs b/mix.exs
index 1e51d64..6205d4f 100644
--- a/mix.exs
+++ b/mix.exs
@@ -26,7 +26,8 @@ defmodule ExOvh.Mixfile do
defp deps() do
[
- {:calendar, "~> 0.13.2"},
+# {:calendar, "~> 0.13.2"},
+ {:calendar, "~> 0.14.0"},
{:og, "~> 0.1"},
{:morph, "~> 0.1.0"},
{:poison, "~> 1.5 or ~> 2.0"},
@@ -58,8 +59,8 @@ defmodule ExOvh.Mixfile do
[
main: "ExOvh",
extras: [
- "docs/mix_task_advanced.md": [path: "mix_task_advanced.md", title: "Step 1: Generating the OVH application (Optional)"],
- "docs/getting_started_advanced.md": [path: "getting_started_advanced.md", title: "Step 2: Setting up client(s)"]
+ "docs/mix_task.md": [path: "mix_task.md", title: "Step 1: Generating the OVH application"],
+ "docs/getting_started.md": [path: "getting_started.md", title: "Step 2: Setting up client"]
]
]
end