datacentred 0.1.1pre → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +11 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +2 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile.lock +39 -2
- data/LICENSE +21 -0
- data/README.md +160 -2
- data/circle.yml +0 -2
- data/datacentred.gemspec +17 -14
- data/docs/Datacentred.html +537 -0
- data/docs/Datacentred/Errors.html +260 -0
- data/docs/Datacentred/Errors/Error.html +139 -0
- data/docs/Datacentred/Errors/NotFound.html +145 -0
- data/docs/Datacentred/Errors/Unauthorized.html +149 -0
- data/docs/Datacentred/Errors/UnprocessableEntity.html +145 -0
- data/docs/Datacentred/Model.html +128 -0
- data/docs/Datacentred/Model/Base.html +255 -0
- data/docs/Datacentred/Model/Project.html +1729 -0
- data/docs/Datacentred/Model/Role.html +1830 -0
- data/docs/Datacentred/Model/Usage.html +510 -0
- data/docs/Datacentred/Model/User.html +832 -0
- data/docs/Datacentred/Model/Version.html +451 -0
- data/docs/Datacentred/Project.html +142 -0
- data/docs/Datacentred/Request.html +128 -0
- data/docs/Datacentred/Request/Base.html +675 -0
- data/docs/Datacentred/Request/Projects.html +1286 -0
- data/docs/Datacentred/Request/Roles.html +1286 -0
- data/docs/Datacentred/Request/Usage.html +315 -0
- data/docs/Datacentred/Request/Users.html +841 -0
- data/docs/Datacentred/Request/Versions.html +258 -0
- data/docs/Datacentred/Response.html +410 -0
- data/docs/Datacentred/Role.html +142 -0
- data/docs/Datacentred/Usage.html +142 -0
- data/docs/Datacentred/User.html +142 -0
- data/docs/Datacentred/Version.html +142 -0
- data/docs/_index.html +349 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +231 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +231 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +643 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/datacentred.rb +65 -12
- data/lib/datacentred/error.rb +37 -15
- data/lib/datacentred/model/base.rb +21 -0
- data/lib/datacentred/model/project.rb +90 -31
- data/lib/datacentred/model/role.rb +89 -31
- data/lib/datacentred/model/usage.rb +16 -9
- data/lib/datacentred/model/user.rb +54 -22
- data/lib/datacentred/model/version.rb +17 -8
- data/lib/datacentred/request/base.rb +68 -31
- data/lib/datacentred/request/projects.rb +92 -24
- data/lib/datacentred/request/roles.rb +92 -24
- data/lib/datacentred/request/usage.rb +10 -1
- data/lib/datacentred/request/users.rb +58 -15
- data/lib/datacentred/request/versions.rb +13 -1
- data/lib/datacentred/response.rb +6 -2
- data/test/integration/authorization_test.rb +30 -0
- data/test/integration/projects_test.rb +11 -11
- data/test/integration/roles_test.rb +17 -17
- data/test/integration/usage_test.rb +8 -8
- data/test/integration/users_test.rb +23 -19
- data/test/integration/versions_test.rb +1 -2
- data/test/test_helper.rb +8 -5
- data/test/vcr_cassettes/not_authorized.yml +57 -0
- data/test/vcr_cassettes/unexpected_error.yml +56 -0
- 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
|
+
— 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> »
|
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&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'>'</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>my_access</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>my_access</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>'</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'># => [#<Datacentred::Model::User id="2bd21ee25cde40fdb9454954e4fbb4b5", ...>, ...]
|
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'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
152
|
+
<span class='comment'># => #<Datacentred::Model::User id="2bd21ee25cde40fdb9454954e4fbb4b5", ...>
|
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'>"</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Foo</span><span class='tstring_end'>"</span></span>
|
158
|
+
<span class='comment'># => #<Datacentred::Model::Project id="6d5277716c4b10d2177814af50b77175", name= "Foo", ...>
|
159
|
+
</span></code></pre>
|
160
|
+
|
161
|
+
<h3>Create a role</h3>
|
162
|
+
|
163
|
+
<p>Acceptable permissions are: 'api.read', 'cloud.read', 'roles.modify', 'roles.read', 'storage.read', 'tickets.modify', 'usage.read'.</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'>"</span><span class='tstring_content'>foo</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>permissions:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>usage.read</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
166
|
+
<span class='comment'># => #<Datacentred::Model::Role id="654f423e-646a-4742-849d-d8c9ab9b4f39", name="foo", admin=false, permissions=["usage.read"] ...>
|
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'>"</span><span class='tstring_content'>654f423e-646a-4742-849d-d8c9ab9b4f39</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
172
|
+
<span class='comment'># => 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'>"</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
178
|
+
<span class='comment'># => 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
|
+
# => #<Datacentred::Model::Usage last_updated_at=2017-07-12 09:46:54 UTC, projects=[{:id=>"37033518a4514f12adeb8346ac3f188c"
|
187
|
+
@usage.projects.first.name
|
188
|
+
# => "wyld_stallyns"
|
189
|
+
@usage.projects.first.usage.instances.first.current_flavor.name
|
190
|
+
=> "dc1.1x1"
|
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't authorized for API access.</li>
|
210
|
+
<li><code>NotFound</code> - The entity you referred to can'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>
|
data/docs/file_list.html
ADDED
@@ -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>
|
data/docs/frames.html
ADDED
@@ -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>
|
data/docs/index.html
ADDED
@@ -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
|
+
— 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> »
|
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&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'>'</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>datacentred</span><span class='tstring_end'>'</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'>"</span><span class='tstring_content'>my_access</span><span class='tstring_end'>"</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'>"</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>"</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'>'</span><span class='tstring_content'>my_access</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>my_secret</span><span class='tstring_end'>'</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'># => [#<Datacentred::Model::User id="2bd21ee25cde40fdb9454954e4fbb4b5", ...>, ...]
|
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'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
152
|
+
<span class='comment'># => #<Datacentred::Model::User id="2bd21ee25cde40fdb9454954e4fbb4b5", ...>
|
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'>"</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Foo</span><span class='tstring_end'>"</span></span>
|
158
|
+
<span class='comment'># => #<Datacentred::Model::Project id="6d5277716c4b10d2177814af50b77175", name= "Foo", ...>
|
159
|
+
</span></code></pre>
|
160
|
+
|
161
|
+
<h3>Create a role</h3>
|
162
|
+
|
163
|
+
<p>Acceptable permissions are: 'api.read', 'cloud.read', 'roles.modify', 'roles.read', 'storage.read', 'tickets.modify', 'usage.read'.</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'>"</span><span class='tstring_content'>foo</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>permissions:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>usage.read</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
166
|
+
<span class='comment'># => #<Datacentred::Model::Role id="654f423e-646a-4742-849d-d8c9ab9b4f39", name="foo", admin=false, permissions=["usage.read"] ...>
|
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'>"</span><span class='tstring_content'>654f423e-646a-4742-849d-d8c9ab9b4f39</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
172
|
+
<span class='comment'># => 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'>"</span><span class='tstring_content'>6d5277716c4b10d2177814af50b77175</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2bd21ee25cde40fdb9454954e4fbb4b5</span><span class='tstring_end'>"</span></span>
|
178
|
+
<span class='comment'># => 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
|
+
# => #<Datacentred::Model::Usage last_updated_at=2017-07-12 09:46:54 UTC, projects=[{:id=>"37033518a4514f12adeb8346ac3f188c"
|
187
|
+
@usage.projects.first.name
|
188
|
+
# => "wyld_stallyns"
|
189
|
+
@usage.projects.first.usage.instances.first.current_flavor.name
|
190
|
+
=> "dc1.1x1"
|
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't authorized for API access.</li>
|
210
|
+
<li><code>NotFound</code> - The entity you referred to can'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>
|