docs improvements
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 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
diff --git a/README.md b/README.md
index a4b7112..f428402 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
-# ExOvh
-ExOvh is an elixir library for the [Ovh Api](https://api.ovh.com/).
+# ExOvh [![Build Status](https://travis-ci.org/stephenmoloney/ex_ovh.svg)](https://travis-ci.org/stephenmoloney/ex_ovh) [![Hex Version](http://img.shields.io/hexpm/v/ex_ovh.svg?style=flat)](https://hex.pm/packages/ex_ovh) [![Hex docs](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/ex_ovh)
+
+ExOvh is an helper library in the [elixir language](http://elixir-lang.org/) for the [Ovh Api](https://api.ovh.com/).
## Project Features
@@ -10,247 +11,14 @@ ExOvh is an elixir library for the [Ovh Api](https://api.ovh.com/).
and their [public cloud storage service](https://www.ovh.ie/cloud/storage/)
-## Getting Started
-
-- Add :ex_ovh to the dependencies.
-
- ```elixir
- defp deps() do
- [
- {:ex_ovh, "~> 0.0.1"}
- ]
- end
- ```
-
-- 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. This is the correct way to create the OVH application.
+## Documentation
-- Alternatively, there is a mix task which:
+- [hex package manager](https://hexdocs.pm/ex_hubic/api-reference.html).
- 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.
-
-- Examples using the mix ovh task:
-
- - Most basic usage:
-
- **Shell Input:**
+## Getting started
- ```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: System.get_env("EX_OVH_ENDPOINT"),
- api_version: System.get_env("EX_OVH_API_VERSION") || "1.0"
- ]
- ```
- This configuration can be added to `config.exs`.
-
- - `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.
- - `EX_OVH_ENDPOINT`: The system environment variable name for the ovh endpoint.
- - `EX_OVH_API_VERSION`: The system environment variable name for the api version.
-
-
- - 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
- ```
-
- - Advanced usage:
-
- **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,/cdn]::post-[/me,/cdn]::delete-[]' \
- --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.Ovh.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: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
- api_version: System.get_env("MY_APP_OVH_CLIENT_API_VERSION") || "1.0"
- ]
- ```
- This configuration can be added to `config.exs`.
-
- - `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.
- - `EX_OVH_ENDPOINT`: The system environment variable name for the ovh endpoint.
- - `EX_OVH_API_VERSION`: The system environment variable name for the api version.
-
-
- - 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
- ```
-
-- 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, `EX_OVH_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
- ]
- ```
-
-- The final phase of configuration is to set up the supervision tree. There are effectively two ways to do
- this:
-
- 1. The 'quick way' which is quite useful when only one client is needed.
-
- Example Configuration:
-
- ```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: System.get_env("EX_OVH_ENDPOINT"),
- api_version: System.get_env("EX_OVH_API_VERSION") || "1.0"
- ]
- ```
-
- Then simply add the application to the project applications list. The supervision
- tree is then started from the application level.
-
- ```elixir
- def application do
- [
- applications: [:ex_ovh]
- ]
- end
- ```
-
- 2. The 'correct way' where a client is setup for the otp_app, therefore allowing for the creation of
- multiple clients.
-
- Example configuration:
-
- ```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"
- ]
- ```
-
- Add supervisors to the supervision tree of the application, for example:
-
- ```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
- ```
-
+- For setting up just one `ExHubic` client, see [getting started basic](https://hexdocs.pm/ex_hubic/doc/getting_started_basic.md.html).
+- Setting up a custom client or multiple clients, see [getting started advanced](https://hexdocs.pm/ex_hubic/doc/getting_started_advanced.md.html) *(recommended method)*.
## Examples
@@ -282,16 +50,15 @@ Listing all objects for "default" container in [OVH CDN Webstorage](https://www.
## Tests
-*Warning* No tests have been performed or added yet. This is on my radar.
-
+- Tests against the Swift portion of the library are carried out in the [Openstex library](https://github.com/stephenmoloney/openstex).
+- Tests against the OVH portion of the library have not been written yet.
-## Potential TODO list
+## TODO
-- [ ] *Needed* - generate hex docs
-- [ ] *Needed* - generate release and publish to hex packages
-- [ ] *Needed* - Tests
-- [ ] *Maybe* - Option to set the application ttl when running ovh mix task.
+- [ ] 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)
## Note
diff --git a/docs/getting_started_advanced.md b/docs/getting_started_advanced.md
new file mode 100644
index 0000000..edfbd1f
--- /dev/null
+++ b/docs/getting_started_advanced.md
@@ -0,0 +1,94 @@
+# 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
+ ]
+```
\ No newline at end of file
diff --git a/docs/getting_started_basic.md b/docs/getting_started_basic.md
new file mode 100644
index 0000000..f0897d5
--- /dev/null
+++ b/docs/getting_started_basic.md
@@ -0,0 +1,91 @@
+# Getting Started (Basic)
+
+## Installation
+
+- Add `:ex_ovh` to the dependencies.
+
+```elixir
+defp deps() do
+ [{:ex_ovh, "~> 0.0.1"}]
+end
+```
+
+- Start `ExOvh` application which in makes `ExOvh` client ready for use.
+
+```elixir
+def application do
+ [applications: [:ex_ovh]]
+end
+```
+
+
+## Configuration
+
+*Note:* The configuration assumes that the environment variables such as `EX_OVH_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 :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: System.get_env("EX_OVH_ENDPOINT"),
+ api_version: System.get_env("EX_OVH_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, `EX_OVH_WEBSTORAGE_CDN_NAME` is added to the environment variables.
+
+```elixir
+config :ex_ovh,
+ ovh: [],
+ swift: [
+ webstorage: [
+ cdn_name: System.get_env("EX_OVH_WEBSTORAGE_CDN_NAME"),
+ type: :webstorage
+ ]
+ ]
+```
+
+- Configuration for public cloud storage service](https://www.ovh.ie/cloud/storage/)
+
+In the example below, `EX_OVH_CLOUDSTORAGE_TENANT_ID` and `EX_OVH_CLOUDSTORAGE_USER_ID` are
+added to the environment variables.
+
+```elixir
+config :ex_ovh,
+ ovh: [],
+ swift: [
+ cloudstorage: [
+ tenant_id: System.get_env("EX_OVH_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
+ user_id: System.get_env("EX_OVH_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
+ ]
+```
\ No newline at end of file
diff --git a/docs/mix_task_advanced.md b/docs/mix_task_advanced.md
new file mode 100644
index 0000000..4277b07
--- /dev/null
+++ b/docs/mix_task_advanced.md
@@ -0,0 +1,74 @@
+# Mix Task (Advanced)
+
+## Generate client config
+
+The hubic mix task makes requests to the Hubic Api on the user's behalf to get details
+such as the referesh token and then generates a configuration which can copied and pasted into `config.exs`.
+
+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,/cdn]::post-[/me,/cdn]::delete-[]' \
+--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.Ovh.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: System.get_env("MY_APP_OVH_CLIENT_ENDPOINT"),
+ api_version: System.get_env("MY_APP_OVH_CLIENT_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.
+- `MY_APP_OVH_CLIENT_ENDPOINT`: The system environment variable name for the ovh endpoint.
+- `MY_APP_OVH_CLIENT_API_VERSION`: The system environment variable name for the api version.
+
+
+- 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
new file mode 100644
index 0000000..8e44964
--- /dev/null
+++ b/docs/mix_task_basic.md
@@ -0,0 +1,70 @@
+# 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: System.get_env("EX_OVH_ENDPOINT"),
+ api_version: System.get_env("EX_OVH_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.
+- `EX_OVH_ENDPOINT`: The system environment variable name for the ovh endpoint.
+- `EX_OVH_API_VERSION`: The system environment variable name for the api version.
+
+
+- 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/lib/ex_ovh.ex b/lib/ex_ovh.ex
index 4b3d8e3..75f9d3b 100644
--- a/lib/ex_ovh.ex
+++ b/lib/ex_ovh.ex
@@ -1,13 +1,4 @@
defmodule ExOvh do
@moduledoc :false
-
use ExOvh.Client, otp_app: :ex_ovh
-
end
-
-# The following way multiple clients to be configured and created.
-#defmodule MyApp.ExOvhClient1 do
-# @moduledoc :false
-# use ExOvh.Client, otp_app: :my_app
-#end
-
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index d4bcad0..2689828 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -1,5 +1,5 @@
defmodule Mix.Tasks.Ovh do
- @shortdoc "Create a new app and new credentials for accessing ovh api"
+ @shortdoc "Create a new application and new credentials for accessing ovh api"
@moduledoc ~S"""
A mix task that generates the ex_ovh application secrets on the user's behalf.
@@ -31,13 +31,12 @@ defmodule Mix.Tasks.Ovh do
api_version: System.get_env("EX_OVH_API_VERSION") || "1.0"
]
- See `README.md` for more advanced usage of the mix ovh task.
+ 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.
"""
use Mix.Task
alias ExOvh.Utils
alias ExOvh.Ovh.Defaults
-
-
@default_headers [{"Content-Type", "application/json; charset=utf-8"}]
@default_options [ timeout: 30000, recv_timeout: (60000 * 1) ]
diff --git a/mix.exs b/mix.exs
index 36687a5..4d96f7b 100644
--- a/mix.exs
+++ b/mix.exs
@@ -13,11 +13,7 @@ defmodule ExOvh.Mixfile do
description: description(),
package: package(),
deps: deps(),
- docs: [
- main: "README.md",
- extra_section: "Readme",
- extras: ["README.md": [path: "README.md", title: "Readme"]]
- ]
+ docs: docs()
]
end
@@ -49,7 +45,7 @@ defmodule ExOvh.Mixfile do
end
- defp package do
+ defp package() do
%{
licenses: ["MIT"],
maintainers: ["Stephen Moloney"],
@@ -58,4 +54,16 @@ defmodule ExOvh.Mixfile do
}
end
+ defp docs() do
+ [
+ main: "api-reference",
+ extras: [
+ "docs/getting_started_basic.md": [path: "getting_started_basic.md", title: "Getting Started (Basic)"],
+ "docs/getting_started_advanced.md": [path: "getting_started_advanced.md", title: "Getting Started (Advanced)"],
+ "docs/mix_task_basic.md": [path: "mix_task_basic.md", title: "Basic Mix Task (Optional)"],
+ "docs/mix_task_advanced.md": [path: "mix_task_advanced.md", title: "Advanced Mix Task (Optional)"]
+ ]
+ ]
+ end
+
end