Commit 94c60f390169d22719a00d1d9a93a3ce4c445735

Stephen Moloney 2017-02-16T14:34:24

simplify 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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
diff --git a/docs/getting_started_advanced.md b/docs/getting_started_advanced.md
deleted file mode 100644
index f166cbb..0000000
--- a/docs/getting_started_advanced.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# Getting Started
-
-## Installation 
-
-- Add `:ex_ovh` to the dependencies.
-
-```elixir
-defp deps() do
-  [{:ex_ovh, "~> 0.2"}]
-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://github.com/stephenmoloney/ex_ovh/blob/master/docs/mix_task_advanced.md) 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
-```
\ No newline at end of file
diff --git a/docs/getting_started_basic.md b/docs/getting_started_basic.md
deleted file mode 100644
index afe00b8..0000000
--- a/docs/getting_started_basic.md
+++ /dev/null
@@ -1,102 +0,0 @@
-# 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.
-```
-
diff --git a/docs/mix_task.md b/docs/mix_task.md
index e69de29..d9ede9f 100644
--- a/docs/mix_task.md
+++ b/docs/mix_task.md
@@ -0,0 +1,128 @@
+# Mix Task
+
+#### Generate ExOvh Config
+
+The ovh mix task makes requests to the OVH API on the user's behalf to generate an OVH application.
+
+- The mix task:
+
+  1. Creates an application on the user's behalf by sending http requests using the user's username and password credentials.
+  2. Gets a consumer key and validation url.
+  3. Validates the validation url on the user's behalf by sending http requests using the user's username and password credentials.
+  4. Adds the application key, application secret and associated consumer key to the environment configuration.
+  
+The environment variables generated by the task are automatically save to a `.env` file. It is best to ensure that this file is outside
+version control.
+
+
+#### Example 1
+
+
+**Shell input:**
+
+```shell
+mix ovh \
+--login=<username-ovh> \
+--password=<password> \
+--appname='ex_ovh'
+```
+
+- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
+- `password`: password for logging into OVH services.
+- `appname`: this should correspond to the `otp_app` name in the elixir application. It also doubles as the application name 
+for the application in the OVH servers.
+- `redirecturi`: defaults to `""` when absent.
+- `endpoint`: defaults to `"ovh-eu"` wen absent.
+- `accessrules`: defaults to `get-[/*]::put-[/*]::post-[/*]::delete-[/*]` when absent giving the application all
+  full priveleges. One may consider fine-tuning the accessrules, see advanced example below.
+- `appdescription`: defaults to `appname` if absent
+- `clientname`:" This is the elixir client name. defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`.
+
+
+**Shell Output:**
+
+```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"
+  ]
+```
+
+Terms explained:
+
+- `EX_OVH_APPLICATION_KEY`: The system environment variable name for the application key.
+- `EX_OVH_APPLICATION_SECRET`: The system environment variable name for the application secret.
+- `EX_OVH_CONSUMER_KEY`: The system environment variable name for the consumer key.
+
+
+#### Example 2
+
+**Shell Input:**
+
+```shell
+mix ovh \
+--login=<username-ovh> \
+--password=<password> \
+--appdescription='Ovh Application for my app' \
+--endpoint='ovh-eu' \
+--apiversion='1.0' \
+--redirecturi='http://localhost:4000/' \
+--accessrules='get-[/*]::put-[/me,/me/*,/cdn/webstorage,/cdn/webstorage/*]::post-[/me,/cdn/webstorage,/cdn/webstorage/*]::delete-[/cdn/webstorage,/cdn/webstorage/*]' \
+--appname='my_app' \
+--clientname='OvhClient'
+```
+
+- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
+- `password`: password for logging into OVH services.
+- `appname`: this should correspond to the `otp_app` name in the elixir application. It also doubles as the application name
+for the application in the OVH servers.
+- `clientname`:" This is the elixir client name. defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`. `clientname` corresponds to the name of the client. So for example, if appname is `'my_app'` and clientname is
+  `'Client'` then the config file will be `config :my_app, MyApp.Client`. Also, the client in application code can be referred
+  to as `MyApp.Client.function_name`.
+- `appdescription`: A description for the application saved to OVH.
+- `endpoint`: OVH endpoint to be used. May vary depending on the OVH service. See `ExOvh.Defaults`.
+- `apiversion`: version of the api to use. Only one version available currently.
+- `redirecturi`: redirect url for oauth authentication. Should be https.
+- `accessrules`: restrictions can be added to the access rules. In this example, `get` requests to all endpoints are allowed,
+  `put` and `post` requests to `/me` and `/cdn` and `delete` requests are forbidden.
+
+
+**Shell Output:**
+
+
+```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"
+    ]
+```
+
+
+Terms explained:
+
+- `MY_APP_OVH_CLIENT_APPLICATION_KEY`: The system environment variable name for the application key.
+- `MY_APP_OVH_CLIENT_APPLICATION_SECRET`: The system environment variable name for the application secret.
+- `MY_APP_OVH_CLIENT_CONSUMER_KEY`: The system environment variable name for the consumer key.
+
+
+#### Add the settings to the environment
+
+- Copy the configuration outputted by the commandline to `config.exs`.
+
+- The enviroment variables are saved to a file called `.env` automatically by the mix task.
+**Do not add the `.env` file to version control.** It would be prudent to add `.env` to the `.gitignore` file.
+Add the variables to the system environment by running the command or some other commands as appropriate
+to the deployment method.
+
+
+```shell
+source .env
+```
\ No newline at end of file
diff --git a/docs/mix_task_advanced.md b/docs/mix_task_advanced.md
deleted file mode 100644
index 84ed27f..0000000
--- a/docs/mix_task_advanced.md
+++ /dev/null
@@ -1,79 +0,0 @@
-# Mix Task (Advanced)
-
-## Generate client config
-
-The ovh mix task makes requests to the OVH API on the user's behalf to generate an OVH application.
-
-- The mix task:
-
-  1. Creates an application on the user's behalf by sending http requests using the user's username and password credentials.
-  2. Gets a consumer key and validation url.
-  3. Validates the validation url on the user's behalf by sending http requests using the user's username and password credentials.
-  4. Adds the application key, application secret and associated consumer key to the environment configuration.
-
-The environment variables generated by the task are automatically save to a `.env` file. It is best to ensure that this file is outside
-version control.
-
-
-**Shell Input:**
-
-```shell
-mix ovh \
---login=<username-ovh> \
---password=<password> \
---appdescription='Ovh Application for my app' \
---endpoint='ovh-eu' \
---apiversion='1.0' \
---redirecturi='http://localhost:4000/' \
---accessrules='get-[/*]::put-[/me,/me/*,/cdn/webstorage,/cdn/webstorage/*]::post-[/me,/cdn/webstorage,/cdn/webstorage/*]::delete-[/cdn/webstorage,/cdn/webstorage/*]' \
---appname='my_app' \
---clientname='OvhClient'
-```
-
-- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
-- `password`: password for logging into OVH services.
-- `appname`: this should correspond to the `otp_app` name in the elixir application. It also doubles as the application name 
-for the application in the OVH servers.
-- `clientname`:" This is the elixir client name. defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`. `clientname` corresponds to the name of the client. So for example, if appname is `'my_app'` and clientname is
-  `'Client'` then the config file will be `config :my_app, MyApp.Client`. Also, the client in application code can be referred
-  to as `MyApp.Client.function_name`.
-- `appdescription`: A description for the application saved to OVH.
-- `endpoint`: OVH endpoint to be used. May vary depending on the OVH service. See `ExOvh.Defaults`.
-- `apiversion`: version of the api to use. Only one version available currently.
-- `redirecturi`: redirect url for oauth authentication. Should be https.
-- `accessrules`: restrictions can be added to the access rules. In this example, `get` requests to all endpoints are allowed,
-  `put` and `post` requests to `/me` and `/cdn` and `delete` requests are forbidden.
-
-  
-**Shell Output:**
-
-
-```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"
-    ]
-```
-
-
-Terms explained:
-
-- `MY_APP_OVH_CLIENT_APPLICATION_KEY`: The system environment variable name for the application key.
-- `MY_APP_OVH_CLIENT_APPLICATION_SECRET`: The system environment variable name for the application secret.
-- `MY_APP_OVH_CLIENT_CONSUMER_KEY`: The system environment variable name for the consumer key.
-
-
-- Copy the configuration outputted by the commandline to `config.exs`.
-
-
-- The enviroment variables are saved to a file called `.env` automatically by the mix task.
-**Do not add the `.env` file to version control.** Add the variables to the system environment
-by running the command or some other commands as appropriate to the deployment method.
-
-```shell
-source .env
-```
\ No newline at end of file
diff --git a/docs/mix_task_basic.md b/docs/mix_task_basic.md
deleted file mode 100644
index 9bdc9e7..0000000
--- a/docs/mix_task_basic.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# Mix Task (Basic)
-
-## Generate ExOvh Config
-
-The ovh mix task makes requests to the OVH API on the user's behalf to generate an OVH application.
-
-- The mix task:
-
-  1. Creates an application on the user's behalf by sending http requests using the user's username and password credentials.
-  2. Gets a consumer key and validation url.
-  3. Validates the validation url on the user's behalf by sending http requests using the user's username and password credentials.
-  4. Adds the application key, application secret and associated consumer key to the environment configuration.
-  
-The environment variables generated by the task are automatically save to a `.env` file. It is best to ensure that this file is outside
-version control.
-
-**Shell input:**
-
-```shell
-mix ovh \
---login=<username-ovh> \
---password=<password> \
---appname='ex_ovh'
-```
-
-- `login`: username/nic_handle for logging into OVH services. *Note*: must include `-ovh` at the end of the string.
-- `password`: password for logging into OVH services.
-- `appname`: this should correspond to the `otp_app` name in the elixir application. It also doubles as the application name 
-for the application in the OVH servers.
-- `redirecturi`: defaults to `""` when absent.
-- `endpoint`: defaults to `"ovh-eu"` wen absent.
-- `accessrules`: defaults to `get-[/*]::put-[/*]::post-[/*]::delete-[/*]` when absent giving the application all
-  full priveleges. One may consider fine-tuning the accessrules, see advanced example below.
-- `appdescription`: defaults to `appname` if absent
-- `clientname`:" This is the elixir client name. defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`.
-
-
-**Shell Output:**
-
-```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"
-  ]
-```
-
-Terms explained:
-
-- `EX_OVH_APPLICATION_KEY`: The system environment variable name for the application key.
-- `EX_OVH_APPLICATION_SECRET`: The system environment variable name for the application secret.
-- `EX_OVH_CONSUMER_KEY`: The system environment variable name for the consumer key.
-
-
-- Copy the configuration outputted by the commandline to `config.exs`.
-
-
-- The enviroment variables are saved to a file called `.env` automatically by the mix task.
-**Do not add the `.env` file to version control.** Add the variables to the system environment
-by running the command or some other commands as appropriate to the deployment method.
-
-
-```shell
-source .env
-```
\ No newline at end of file