datacentred 0.1.1pre → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +11 -0
  3. data/.coveralls.yml +1 -0
  4. data/.gitignore +9 -0
  5. data/.rubocop.yml +2 -0
  6. data/.yardopts +1 -0
  7. data/CODE_OF_CONDUCT.md +46 -0
  8. data/Gemfile.lock +39 -2
  9. data/LICENSE +21 -0
  10. data/README.md +160 -2
  11. data/circle.yml +0 -2
  12. data/datacentred.gemspec +17 -14
  13. data/docs/Datacentred.html +537 -0
  14. data/docs/Datacentred/Errors.html +260 -0
  15. data/docs/Datacentred/Errors/Error.html +139 -0
  16. data/docs/Datacentred/Errors/NotFound.html +145 -0
  17. data/docs/Datacentred/Errors/Unauthorized.html +149 -0
  18. data/docs/Datacentred/Errors/UnprocessableEntity.html +145 -0
  19. data/docs/Datacentred/Model.html +128 -0
  20. data/docs/Datacentred/Model/Base.html +255 -0
  21. data/docs/Datacentred/Model/Project.html +1729 -0
  22. data/docs/Datacentred/Model/Role.html +1830 -0
  23. data/docs/Datacentred/Model/Usage.html +510 -0
  24. data/docs/Datacentred/Model/User.html +832 -0
  25. data/docs/Datacentred/Model/Version.html +451 -0
  26. data/docs/Datacentred/Project.html +142 -0
  27. data/docs/Datacentred/Request.html +128 -0
  28. data/docs/Datacentred/Request/Base.html +675 -0
  29. data/docs/Datacentred/Request/Projects.html +1286 -0
  30. data/docs/Datacentred/Request/Roles.html +1286 -0
  31. data/docs/Datacentred/Request/Usage.html +315 -0
  32. data/docs/Datacentred/Request/Users.html +841 -0
  33. data/docs/Datacentred/Request/Versions.html +258 -0
  34. data/docs/Datacentred/Response.html +410 -0
  35. data/docs/Datacentred/Role.html +142 -0
  36. data/docs/Datacentred/Usage.html +142 -0
  37. data/docs/Datacentred/User.html +142 -0
  38. data/docs/Datacentred/Version.html +142 -0
  39. data/docs/_index.html +349 -0
  40. data/docs/class_list.html +51 -0
  41. data/docs/css/common.css +1 -0
  42. data/docs/css/full_list.css +58 -0
  43. data/docs/css/style.css +492 -0
  44. data/docs/file.README.html +231 -0
  45. data/docs/file_list.html +56 -0
  46. data/docs/frames.html +17 -0
  47. data/docs/index.html +231 -0
  48. data/docs/js/app.js +248 -0
  49. data/docs/js/full_list.js +216 -0
  50. data/docs/js/jquery.js +4 -0
  51. data/docs/method_list.html +643 -0
  52. data/docs/top-level-namespace.html +110 -0
  53. data/lib/datacentred.rb +65 -12
  54. data/lib/datacentred/error.rb +37 -15
  55. data/lib/datacentred/model/base.rb +21 -0
  56. data/lib/datacentred/model/project.rb +90 -31
  57. data/lib/datacentred/model/role.rb +89 -31
  58. data/lib/datacentred/model/usage.rb +16 -9
  59. data/lib/datacentred/model/user.rb +54 -22
  60. data/lib/datacentred/model/version.rb +17 -8
  61. data/lib/datacentred/request/base.rb +68 -31
  62. data/lib/datacentred/request/projects.rb +92 -24
  63. data/lib/datacentred/request/roles.rb +92 -24
  64. data/lib/datacentred/request/usage.rb +10 -1
  65. data/lib/datacentred/request/users.rb +58 -15
  66. data/lib/datacentred/request/versions.rb +13 -1
  67. data/lib/datacentred/response.rb +6 -2
  68. data/test/integration/authorization_test.rb +30 -0
  69. data/test/integration/projects_test.rb +11 -11
  70. data/test/integration/roles_test.rb +17 -17
  71. data/test/integration/usage_test.rb +8 -8
  72. data/test/integration/users_test.rb +23 -19
  73. data/test/integration/versions_test.rb +1 -2
  74. data/test/test_helper.rb +8 -5
  75. data/test/vcr_cassettes/not_authorized.yml +57 -0
  76. data/test/vcr_cassettes/unexpected_error.yml +56 -0
  77. metadata +115 -9
@@ -0,0 +1,231 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><p><img src="https://assets-cdn.datacentred.io/assets/DC_Mono_B-903aac5ca4f5c6887193d880dbd1196deb8a978027eef5cb32de78b66d085935.png" alt="Datacentred"></p>
61
+
62
+ <p>Ruby client library for automating DataCentred account management.</p>
63
+
64
+ <p><a href="https://www.datacentred.co.uk">www.datacentred.co.uk</a></p>
65
+
66
+ <p><a href="https://circleci.com/gh/datacentred/datacentred-api-ruby"><img src="https://circleci.com/gh/datacentred/datacentred-api-ruby.svg?style=svg&amp;circle-token=c284db6421742dcfe8c50f52945c31d9b976effb" alt="CircleCI"></a>
67
+ <a href="http://badge.fury.io/rb/keybase-core"><img src="https://badge.fury.io/rb/datacentred.png" alt="Gem Version"></a> <a href="https://codeclimate.com/github/datacentred/datacentred-api-ruby"><img src="https://codeclimate.com/github/datacentred/datacentred-api-ruby/badges/gpa.svg" alt="Code Climate"></a> <a href="https://coveralls.io/github/datacentred/datacentred-api-ruby?branch=master"><img src="https://coveralls.io/repos/github/datacentred/datacentred-api-ruby/badge.svg?branch=master" alt="Coverage Status"></a></p>
68
+
69
+ <h1>Installation</h1>
70
+
71
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_datacentred'>datacentred</span>
72
+ </code></pre>
73
+
74
+ <p>or</p>
75
+
76
+ <p>(in Gemfile or .gemspec)</p>
77
+
78
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>&#39;</span></span>
79
+ </code></pre>
80
+
81
+ <p>then</p>
82
+
83
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>&#39;</span></span>
84
+ </code></pre>
85
+
86
+ <h1>Usage</h1>
87
+
88
+ <p>This API allows you to automate operations against your DataCentred account.</p>
89
+
90
+ <p>Operations include:</p>
91
+
92
+ <ul>
93
+ <li>Creating and managing users;</li>
94
+ <li>Creating and managing roles for users;</li>
95
+ <li>Managing OpenStack Project creation, quota adjustments, and user assignments;</li>
96
+ <li>Viewing detailed usage/billing information for your account.</li>
97
+ </ul>
98
+
99
+ <h2>Authentication</h2>
100
+
101
+ <p>The API uses two pieces of information to authenticate access.</p>
102
+
103
+ <p>A unique access key specific to your DataCentred account, and a secret key which is generated once.</p>
104
+
105
+ <p>To get started:</p>
106
+
107
+ <ol>
108
+ <li>Find your API access key and secret key at <a href="https://my.datacentred.io">my.datacentred.io</a></li>
109
+ </ol>
110
+
111
+ <p><img src="https://user-images.githubusercontent.com/98526/30334767-79f4617c-97d8-11e7-962c-ec3115d13896.png" alt="API Credentials"></p>
112
+
113
+ <ol>
114
+ <li>Set your credentials by exporting your access key and secret key as environment variables:</li>
115
+ </ol>
116
+
117
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_export'>export</span> <span class='const'>DATACENTRED_ACCESS</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my_access</span><span class='tstring_end'>&quot;</span></span>
118
+ <span class='id identifier rubyid_export'>export</span> <span class='const'>DATACENTRED_SECRET</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>&quot;</span></span>
119
+ </code></pre>
120
+
121
+ <p>Or setting your keys manually using the following methods:</p>
122
+
123
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='period'>.</span><span class='id identifier rubyid_access_key'><span class='object_link'><a href="Datacentred.html#access_key-class_method" title="Datacentred.access_key (method)">access_key</a></span></span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>my_access</span><span class='tstring_end'>&#39;</span></span>
124
+ <span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='period'>.</span><span class='id identifier rubyid_secret_key'><span class='object_link'><a href="Datacentred.html#secret_key-class_method" title="Datacentred.secret_key (method)">secret_key</a></span></span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>&#39;</span></span>
125
+ </code></pre>
126
+
127
+ <p>NOTE: If you use this approach, the gem will ignore any values assigned to the environment variables.</p>
128
+
129
+ <h2>Usage Examples</h2>
130
+
131
+ <p>The <code>User</code>, <code>Project</code>, and <code>Role</code> entities all support CRUD operations via the following methods:</p>
132
+
133
+ <ul>
134
+ <li><code>.all</code> - returns an index of all entities of this type.</li>
135
+ <li><code>.create params</code> - creates a new entity where <code>params</code> is a hash of properties.</li>
136
+ <li><code>.update id, params</code> - updates the entity identified by <code>id</code> with the hash of properties defined by <code>params</code>.</li>
137
+ <li><code>.find id</code> - finds the entity via the unique identifier <code>id</code>.</li>
138
+ <li><code>.destroy id</code> - removes the entity via the unique identifier <code>id</code>.</li>
139
+ </ul>
140
+
141
+ <p>Here are some worked examples:</p>
142
+
143
+ <h3>List all available users</h3>
144
+
145
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/User.html" title="Datacentred::User (class)">User</a></span></span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
146
+ <span class='comment'># =&gt; [#&lt;Datacentred::Model::User id=&quot;2bd21ee25cde40fdb9454954e4fbb4b5&quot;, ...&gt;, ...]
147
+ </span></code></pre>
148
+
149
+ <h3>Find a user by id</h3>
150
+
151
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/User.html" title="Datacentred::User (class)">User</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
152
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::User id=&quot;2bd21ee25cde40fdb9454954e4fbb4b5&quot;, ...&gt;
153
+ </span></code></pre>
154
+
155
+ <h3>Update a project</h3>
156
+
157
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Project.html" title="Datacentred::Project (class)">Project</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Foo</span><span class='tstring_end'>&quot;</span></span>
158
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::Project id=&quot;6d5277716c4b10d2177814af50b77175&quot;, name= &quot;Foo&quot;, ...&gt;
159
+ </span></code></pre>
160
+
161
+ <h3>Create a role</h3>
162
+
163
+ <p>Acceptable permissions are: &#39;api.read&#39;, &#39;cloud.read&#39;, &#39;roles.modify&#39;, &#39;roles.read&#39;, &#39;storage.read&#39;, &#39;tickets.modify&#39;, &#39;usage.read&#39;.</p>
164
+
165
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Role.html" title="Datacentred::Role (class)">Role</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>permissions:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>usage.read</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
166
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::Role id=&quot;654f423e-646a-4742-849d-d8c9ab9b4f39&quot;, name=&quot;foo&quot;, admin=false, permissions=[&quot;usage.read&quot;] ...&gt;
167
+ </span></code></pre>
168
+
169
+ <h3>Add a user to a role</h3>
170
+
171
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Role.html" title="Datacentred::Role (class)">Role</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add_user'>add_user</span> <span class='label'>role_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>654f423e-646a-4742-849d-d8c9ab9b4f39</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
172
+ <span class='comment'># =&gt; true
173
+ </span></code></pre>
174
+
175
+ <h3>Remove a user from a project</h3>
176
+
177
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Project.html" title="Datacentred::Project (class)">Project</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove_user'>remove_user</span> <span class='label'>project_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
178
+ <span class='comment'># =&gt; true
179
+ </span></code></pre>
180
+
181
+ <h3>Get usage data for a given year and month</h3>
182
+
183
+ <p>Usage data is returned simply by supplying a year and a month. If the year/month are current then the data will be as recent as the time contained within the <code>last_updated_at</code> property.</p>
184
+
185
+ <pre class="code ruby"><code class="ruby">@usage = Datacentred::Usage.find 2017, 6
186
+ # =&gt; #&lt;Datacentred::Model::Usage last_updated_at=2017-07-12 09:46:54 UTC, projects=[{:id=&gt;&quot;37033518a4514f12adeb8346ac3f188c&quot;
187
+ @usage.projects.first.name
188
+ # =&gt; &quot;wyld_stallyns&quot;
189
+ @usage.projects.first.usage.instances.first.current_flavor.name
190
+ =&gt; &quot;dc1.1x1&quot;
191
+ </code></pre>
192
+
193
+ <h2>Schemas</h2>
194
+
195
+ <p>There are JSON schemas available for each entity in the gem:</p>
196
+
197
+ <ul>
198
+ <li>Projects: <a href="https://my.datacentred.io/api/schemas/project">https://my.datacentred.io/api/schemas/project</a></li>
199
+ <li>Roles: <a href="https://my.datacentred.io/api/schemas/role">https://my.datacentred.io/api/schemas/role</a></li>
200
+ <li>Usage: <a href="https://my.datacentred.io/api/schemas/usage">https://my.datacentred.io/api/schemas/usage</a></li>
201
+ <li>User: <a href="https://my.datacentred.io/api/schemas/user">https://my.datacentred.io/api/schemas/user</a></li>
202
+ </ul>
203
+
204
+ <h2>Errors</h2>
205
+
206
+ <p>The gem may raise the following standard errors:</p>
207
+
208
+ <ul>
209
+ <li><code>Unauthorized</code> - Your credentials are incorrect or your account isn&#39;t authorized for API access.</li>
210
+ <li><code>NotFound</code> - The entity you referred to can&#39;t be found with the ID you supplied.</li>
211
+ <li><code>UnprocessableEntity</code> - There was a validation issue with your request (only applies to create/delete/update operations)</li>
212
+ </ul>
213
+
214
+ <h2>Documentation</h2>
215
+
216
+ <p>Full documentation is also available via <a href="https://datacentred.github.io/datacentred-api-ruby/">https://datacentred.github.io/datacentred-api-ruby/</a></p>
217
+
218
+ <h2>API Reference Manual</h2>
219
+
220
+ <p>Please check out the <a href="https://my.datacentred.io/api/docs/v1">DataCentred API Documentation</a> for a comprehensive description of the API itself.</p>
221
+ </div></div>
222
+
223
+ <div id="footer">
224
+ Generated on Fri Sep 15 16:27:41 2017 by
225
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
226
+ 0.9.9 (ruby-2.3.1).
227
+ </div>
228
+
229
+ </div>
230
+ </body>
231
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.9</title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
@@ -0,0 +1,231 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><p><img src="https://assets-cdn.datacentred.io/assets/DC_Mono_B-903aac5ca4f5c6887193d880dbd1196deb8a978027eef5cb32de78b66d085935.png" alt="Datacentred"></p>
61
+
62
+ <p>Ruby client library for automating DataCentred account management.</p>
63
+
64
+ <p><a href="https://www.datacentred.co.uk">www.datacentred.co.uk</a></p>
65
+
66
+ <p><a href="https://circleci.com/gh/datacentred/datacentred-api-ruby"><img src="https://circleci.com/gh/datacentred/datacentred-api-ruby.svg?style=svg&amp;circle-token=c284db6421742dcfe8c50f52945c31d9b976effb" alt="CircleCI"></a>
67
+ <a href="http://badge.fury.io/rb/keybase-core"><img src="https://badge.fury.io/rb/datacentred.png" alt="Gem Version"></a> <a href="https://codeclimate.com/github/datacentred/datacentred-api-ruby"><img src="https://codeclimate.com/github/datacentred/datacentred-api-ruby/badges/gpa.svg" alt="Code Climate"></a> <a href="https://coveralls.io/github/datacentred/datacentred-api-ruby?branch=master"><img src="https://coveralls.io/repos/github/datacentred/datacentred-api-ruby/badge.svg?branch=master" alt="Coverage Status"></a></p>
68
+
69
+ <h1>Installation</h1>
70
+
71
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_datacentred'>datacentred</span>
72
+ </code></pre>
73
+
74
+ <p>or</p>
75
+
76
+ <p>(in Gemfile or .gemspec)</p>
77
+
78
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>&#39;</span></span>
79
+ </code></pre>
80
+
81
+ <p>then</p>
82
+
83
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>&#39;</span></span>
84
+ </code></pre>
85
+
86
+ <h1>Usage</h1>
87
+
88
+ <p>This API allows you to automate operations against your DataCentred account.</p>
89
+
90
+ <p>Operations include:</p>
91
+
92
+ <ul>
93
+ <li>Creating and managing users;</li>
94
+ <li>Creating and managing roles for users;</li>
95
+ <li>Managing OpenStack Project creation, quota adjustments, and user assignments;</li>
96
+ <li>Viewing detailed usage/billing information for your account.</li>
97
+ </ul>
98
+
99
+ <h2>Authentication</h2>
100
+
101
+ <p>The API uses two pieces of information to authenticate access.</p>
102
+
103
+ <p>A unique access key specific to your DataCentred account, and a secret key which is generated once.</p>
104
+
105
+ <p>To get started:</p>
106
+
107
+ <ol>
108
+ <li>Find your API access key and secret key at <a href="https://my.datacentred.io">my.datacentred.io</a></li>
109
+ </ol>
110
+
111
+ <p><img src="https://user-images.githubusercontent.com/98526/30334767-79f4617c-97d8-11e7-962c-ec3115d13896.png" alt="API Credentials"></p>
112
+
113
+ <ol>
114
+ <li>Set your credentials by exporting your access key and secret key as environment variables:</li>
115
+ </ol>
116
+
117
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_export'>export</span> <span class='const'>DATACENTRED_ACCESS</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my_access</span><span class='tstring_end'>&quot;</span></span>
118
+ <span class='id identifier rubyid_export'>export</span> <span class='const'>DATACENTRED_SECRET</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>&quot;</span></span>
119
+ </code></pre>
120
+
121
+ <p>Or setting your keys manually using the following methods:</p>
122
+
123
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='period'>.</span><span class='id identifier rubyid_access_key'><span class='object_link'><a href="Datacentred.html#access_key-class_method" title="Datacentred.access_key (method)">access_key</a></span></span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>my_access</span><span class='tstring_end'>&#39;</span></span>
124
+ <span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='period'>.</span><span class='id identifier rubyid_secret_key'><span class='object_link'><a href="Datacentred.html#secret_key-class_method" title="Datacentred.secret_key (method)">secret_key</a></span></span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>&#39;</span></span>
125
+ </code></pre>
126
+
127
+ <p>NOTE: If you use this approach, the gem will ignore any values assigned to the environment variables.</p>
128
+
129
+ <h2>Usage Examples</h2>
130
+
131
+ <p>The <code>User</code>, <code>Project</code>, and <code>Role</code> entities all support CRUD operations via the following methods:</p>
132
+
133
+ <ul>
134
+ <li><code>.all</code> - returns an index of all entities of this type.</li>
135
+ <li><code>.create params</code> - creates a new entity where <code>params</code> is a hash of properties.</li>
136
+ <li><code>.update id, params</code> - updates the entity identified by <code>id</code> with the hash of properties defined by <code>params</code>.</li>
137
+ <li><code>.find id</code> - finds the entity via the unique identifier <code>id</code>.</li>
138
+ <li><code>.destroy id</code> - removes the entity via the unique identifier <code>id</code>.</li>
139
+ </ul>
140
+
141
+ <p>Here are some worked examples:</p>
142
+
143
+ <h3>List all available users</h3>
144
+
145
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/User.html" title="Datacentred::User (class)">User</a></span></span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
146
+ <span class='comment'># =&gt; [#&lt;Datacentred::Model::User id=&quot;2bd21ee25cde40fdb9454954e4fbb4b5&quot;, ...&gt;, ...]
147
+ </span></code></pre>
148
+
149
+ <h3>Find a user by id</h3>
150
+
151
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/User.html" title="Datacentred::User (class)">User</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
152
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::User id=&quot;2bd21ee25cde40fdb9454954e4fbb4b5&quot;, ...&gt;
153
+ </span></code></pre>
154
+
155
+ <h3>Update a project</h3>
156
+
157
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Project.html" title="Datacentred::Project (class)">Project</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Foo</span><span class='tstring_end'>&quot;</span></span>
158
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::Project id=&quot;6d5277716c4b10d2177814af50b77175&quot;, name= &quot;Foo&quot;, ...&gt;
159
+ </span></code></pre>
160
+
161
+ <h3>Create a role</h3>
162
+
163
+ <p>Acceptable permissions are: &#39;api.read&#39;, &#39;cloud.read&#39;, &#39;roles.modify&#39;, &#39;roles.read&#39;, &#39;storage.read&#39;, &#39;tickets.modify&#39;, &#39;usage.read&#39;.</p>
164
+
165
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Role.html" title="Datacentred::Role (class)">Role</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>permissions:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>usage.read</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
166
+ <span class='comment'># =&gt; #&lt;Datacentred::Model::Role id=&quot;654f423e-646a-4742-849d-d8c9ab9b4f39&quot;, name=&quot;foo&quot;, admin=false, permissions=[&quot;usage.read&quot;] ...&gt;
167
+ </span></code></pre>
168
+
169
+ <h3>Add a user to a role</h3>
170
+
171
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Role.html" title="Datacentred::Role (class)">Role</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add_user'>add_user</span> <span class='label'>role_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>654f423e-646a-4742-849d-d8c9ab9b4f39</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
172
+ <span class='comment'># =&gt; true
173
+ </span></code></pre>
174
+
175
+ <h3>Remove a user from a project</h3>
176
+
177
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Datacentred.html" title="Datacentred (module)">Datacentred</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Datacentred/Project.html" title="Datacentred::Project (class)">Project</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove_user'>remove_user</span> <span class='label'>project_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>&quot;</span></span>
178
+ <span class='comment'># =&gt; true
179
+ </span></code></pre>
180
+
181
+ <h3>Get usage data for a given year and month</h3>
182
+
183
+ <p>Usage data is returned simply by supplying a year and a month. If the year/month are current then the data will be as recent as the time contained within the <code>last_updated_at</code> property.</p>
184
+
185
+ <pre class="code ruby"><code class="ruby">@usage = Datacentred::Usage.find 2017, 6
186
+ # =&gt; #&lt;Datacentred::Model::Usage last_updated_at=2017-07-12 09:46:54 UTC, projects=[{:id=&gt;&quot;37033518a4514f12adeb8346ac3f188c&quot;
187
+ @usage.projects.first.name
188
+ # =&gt; &quot;wyld_stallyns&quot;
189
+ @usage.projects.first.usage.instances.first.current_flavor.name
190
+ =&gt; &quot;dc1.1x1&quot;
191
+ </code></pre>
192
+
193
+ <h2>Schemas</h2>
194
+
195
+ <p>There are JSON schemas available for each entity in the gem:</p>
196
+
197
+ <ul>
198
+ <li>Projects: <a href="https://my.datacentred.io/api/schemas/project">https://my.datacentred.io/api/schemas/project</a></li>
199
+ <li>Roles: <a href="https://my.datacentred.io/api/schemas/role">https://my.datacentred.io/api/schemas/role</a></li>
200
+ <li>Usage: <a href="https://my.datacentred.io/api/schemas/usage">https://my.datacentred.io/api/schemas/usage</a></li>
201
+ <li>User: <a href="https://my.datacentred.io/api/schemas/user">https://my.datacentred.io/api/schemas/user</a></li>
202
+ </ul>
203
+
204
+ <h2>Errors</h2>
205
+
206
+ <p>The gem may raise the following standard errors:</p>
207
+
208
+ <ul>
209
+ <li><code>Unauthorized</code> - Your credentials are incorrect or your account isn&#39;t authorized for API access.</li>
210
+ <li><code>NotFound</code> - The entity you referred to can&#39;t be found with the ID you supplied.</li>
211
+ <li><code>UnprocessableEntity</code> - There was a validation issue with your request (only applies to create/delete/update operations)</li>
212
+ </ul>
213
+
214
+ <h2>Documentation</h2>
215
+
216
+ <p>Full documentation is also available via <a href="https://datacentred.github.io/datacentred-api-ruby/">https://datacentred.github.io/datacentred-api-ruby/</a></p>
217
+
218
+ <h2>API Reference Manual</h2>
219
+
220
+ <p>Please check out the <a href="https://my.datacentred.io/api/docs/v1">DataCentred API Documentation</a> for a comprehensive description of the API itself.</p>
221
+ </div></div>
222
+
223
+ <div id="footer">
224
+ Generated on Fri Sep 15 16:27:41 2017 by
225
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
226
+ 0.9.9 (ruby-2.3.1).
227
+ </div>
228
+
229
+ </div>
230
+ </body>
231
+ </html>