configuration and readme changes
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
diff --git a/README.md b/README.md
index 9aa205a..a4b7112 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ and their [public cloud storage service](https://www.ovh.ie/cloud/storage/)
- Most basic usage:
**Shell Input:**
+
```shell
mix ovh \
--login=<username-ovh> \
@@ -48,14 +49,14 @@ and their [public cloud storage service](https://www.ovh.ie/cloud/storage/)
- `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. The same name will be used as
- the name for the application in OVH.
+ - `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`:" defaults to `ExOvh` when the appname is exactly equal to `ex_ovh`, otherwise defaults to `OvhClient`.
+ - `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:**
@@ -105,9 +106,9 @@ and their [public cloud storage service](https://www.ovh.ie/cloud/storage/)
- `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`: appname corresponds to the `otp_app` name in the elixir application. The same name will be used as
- the name for the application in OVH.
- - `clientname`:" 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
+ - `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.
@@ -196,59 +197,59 @@ and their [public cloud storage service](https://www.ovh.ie/cloud/storage/)
- The final phase of configuration is to set up the supervision tree. There are effectively two ways to do
this:
- 1. 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
- ```
-
- 2. The 'quick way' which is quite useful when only one client is needed.
-
- Example Configuration:
-
- ```elixir
- config :ex_ovh,
+ 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("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"
+ 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"
]
- ```
+ ```
- Then simply add the application to the project applications list. The supervision
- tree is then started from the application level.
+ Add supervisors to the supervision tree of the application, for example:
- ```elixir
- def application do
- [
- applications: [:ex_ovh]
- ]
- end
- ```
+ ```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
+ ```
## Examples
@@ -275,12 +276,10 @@ Listing all objects for "default" container in [OVH CDN Webstorage](https://www.
- Create [issues here](https://github.com/stephenmoloney/ex_ovh/issues/new) to communicate your ideas to me. Thanks.
-
## Contributing
- Pull requests welcome.
-
## Tests
*Warning* No tests have been performed or added yet. This is on my radar.
diff --git a/config/config.exs b/config/config.exs
index d802880..9ad05a5 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -1,16 +1,17 @@
use Mix.Config
+
config :logger,
backends: [:console],
level: :debug,
format: "\n$date $time [$level] $metadata$message"
+
if Mix.env == :prod do
config :logger,
backends: [:console],
compile_time_purge_level: :warn
end
-config :ex_doc, :markdown_processor, ExDoc.Markdown.Hoedown
import_config "#{Mix.env}.exs"
diff --git a/config/dev.exs b/config/dev.exs
index d828ad5..4651724 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -1,5 +1,9 @@
use Mix.Config
+
+config :ex_doc, :markdown_processor, ExDoc.Markdown.Hoedown
+
+
config :logger,
backends: [:console],
compile_time_purge_level: :debug
@@ -35,8 +39,6 @@ config :ex_ovh,
]
-
-
#config :my_app, MyApp.OvhClient,
# ... then as above
diff --git a/config/test.exs b/config/test.exs
index ac0d294..c3970ca 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -1,19 +1,29 @@
use Mix.Config
+
config :logger,
backends: [:console],
compile_time_purge_level: :error
+
config :ex_ovh,
- 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",
- connect_timeout: 30000, # 30 seconds
- connect_timeout: (60000 * 30) # 30 minutes
- },
- swift: %{
- webstorage: "EX_OVH_WEBSTORAGE_CDN_NAME"
- }
\ No newline at end of file
+ api_version: System.get_env("EX_OVH_API_VERSION") || "1.0"
+ ],
+ swift: [
+ webstorage: [
+ cdn_name: System.get_env("EX_OVH_WEBSTORAGE_CDN_NAME"),
+ type: :webstorage
+ ],
+ 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
+ ]
+ ]
\ No newline at end of file