clc_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8734752df7e382dcbc7e516e0dd507b788c7fd8
4
+ data.tar.gz: a0d8dcfc2ddf7475b6203f06b9884e1798f461d3
5
+ SHA512:
6
+ metadata.gz: 832ff61fcdab8cdf45100f191a1f20d743a3ff582ac8f50f09d8c2e3cb7b58feff9771b97e813ed629fb2bd8820952bf8b065c0edcef34ea681652fe6a3a6172
7
+ data.tar.gz: 35167c2a4fbb13d67a9b690a915587126367397a2d4ade0ae574f94f0b93903ad24ca5b790185b73eb7d8ec60df99881404e13a363aab132a518cbdd1473cead
data/.DS_Store ADDED
Binary file
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in clc_client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # ClcClient
2
+
3
+ ClcClient is a ruby gem for CenturyLink Cloud's API V2.0.
4
+ Full documentation on the API can be found on [CenturyLink Cloud's Website](http://www.centurylinkcloud.com/api-docs/v2/).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem `clc_client`
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install clc_client
21
+
22
+ ## Usage
23
+
24
+ To start using the login you must have a token. If you already have one you may simply set your token using `setToken(token)`.
25
+ Otherwise you may use `login(username, password)` to generate one for you.
26
+
27
+ Each call will return JSON that contains information returned by the API.
28
+
29
+ Any call that has something like `variable = {}` will take in a JSON payload as a parameter. Be sure to have your JSON payloads set up correctly.
30
+
31
+ All of the required and optional parameters including JSON payloads can be found in [Centurylink Cloud's documentation](http://www.centurylinkcloud.com/api-docs/v2/).
32
+
33
+ ## Anti-Affinity Policies
34
+
35
+ * `createAntiAffinityPolicy(accountAlias)`
36
+ * `deleteAntiAffinityPolicy(accountAlias, policyId, payload = {})`
37
+ * `getAntiAffinityPolicy(accountAlias, policyId)`
38
+ * `getAntiAffinityPolicies(accountAlias)`
39
+ * `updateAntiAffinityPolicy(accountAlias, policyId, name)`
40
+
41
+ ## Authentication
42
+
43
+ These do not return JSON, instead they return your token as a string.
44
+
45
+ * `setToken(token)`
46
+ * `login(username, name)`
47
+
48
+ ## CustomFields
49
+
50
+ * `getCustomFields(accountAlias)`
51
+
52
+ ## DataCenters
53
+
54
+ * `getDataCenter(accountAlias, dataCenter)`
55
+ * `getDataCenterDeploymentCapabilities(accountAlias, datacenter)`
56
+ * `getDataCenterList(accountAlias)`
57
+
58
+ ## Groups
59
+
60
+ * `createGroup(accountAlias, payload)`
61
+ * `deleteGroup(accountAlias, groupId)`
62
+ * `getGroup(accountAlias, groupId)`
63
+ * `getGroupBillingDetails(accountAlias, groupId)`
64
+ * `getGroupMonitoringStatistics(accountAlias, groupId)`
65
+ * `setCustomGroupCustomFields(accountAlias, groupId, patchOperation = {})`
66
+ * `setGroupNameOrDescription(accountAlias, groupId, patchOperation = {})`
67
+ * `setGroupParent(accountAlias, groupId, patchOperation = {})`
68
+
69
+ ## Group Actions
70
+
71
+ * `archiveGroup(accountAlias, groupId, payload = {})`
72
+ * `restoreGroup(accountAlias, groupId, targetGroupId)`
73
+
74
+ ## Power Operations
75
+
76
+ * `setPowerOperation(accountAlias, powerOperation, serverIds = {})`
77
+ * `setMaintenanceMode(accountAlias, servers = {})`
78
+
79
+ ## Public IP
80
+
81
+ * `addPublicIpAddress(accountAlias, serverId, payload = {})`
82
+ * `getPublicIpAddress(accountAlias, serverId, publicIP)`
83
+ * `deletePublicIpAddress(accountAlias, serverId, publicIP)`
84
+ * `updatePublicIpAddress(accountAlias, serverId, publicIP, payload = {})`
85
+
86
+ ## Queue
87
+
88
+ * `getQueueStatus(accountAlias, serverId)`
89
+
90
+ ## Servers
91
+
92
+ * `getserverDetails(accountAlias, serverId)`
93
+ * `createServer(accountAlias, payload = {})`
94
+ * `deleteServer(accountAlias, serverId)`
95
+ * `getServerCredentials(accountAlias, serverId)`
96
+ * `setServerCpuOrMemory(accountAlias, serverId, payload = {})`
97
+ * `setServerCredentials(accountAlias, serverId, payload = {})`
98
+ * `setServerCustomFields(accountAlias, serverId, payload = {})`
99
+ * `setServerDescriptionOrGroup(accountAlias, serverId, payload = {})`
100
+ * `setServerDisks(accountAlias, serverId, payload = {})`
101
+
102
+ ## Server Actions
103
+
104
+ * `archiveServer(accountAlias, serverIds = {})`
105
+ * `createSnapShot(accountAlias, payload = {})`
106
+ * `executePackage(accountAlias, payload = {})`
107
+ * `restoreServer(accountAlias, targetGroupId)`
108
+
109
+ ## Development
110
+
111
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
112
+
113
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
114
+
115
+ ## Contributing
116
+
117
+ 1. Fork it ( https://github.com/[my-github-username]/clc_client/fork )
118
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
119
+ 3. Commit your changes (`git commit -am `Add some feature``)
120
+ 4. Push to the branch (`git push origin my-new-feature`)
121
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "clc_client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'clc_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "clc_client"
8
+ spec.version = ClcClient::VERSION
9
+ spec.authors = ["Jonathan Hinds", "Anthony Howell"]
10
+ spec.email = ["jonathan.a.hinds@gmail.com", "anthony.howell@centurylink.com"]
11
+
12
+ spec.summary = %q{A ruby client for CenturyLink Cloud}
13
+ spec.homepage = "https://github.com/jhinds/clc_client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_dependency "rest-client"
25
+ end
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,3 @@
1
+ module ClcClient
2
+ VERSION = "0.1.0"
3
+ end
data/lib/clc_client.rb ADDED
@@ -0,0 +1,332 @@
1
+ require "clc_client/version"
2
+ require "rest-client"
3
+
4
+ module ClcClient
5
+
6
+ createServerRequest = {
7
+ :name => "DFT",
8
+ :groupId => "a163d30b196f436aac885f2e28ad28b9",
9
+ :sourceServerId => "UBUNTU-14-64-TEMPLATE",
10
+ :cpu => 1,
11
+ :memoryGB => 2,
12
+ :type => "standard",
13
+ }
14
+
15
+ CLC_API = "https://api.ctl.io"
16
+
17
+ def self.setToken(token)
18
+ $token = token
19
+ end
20
+
21
+ def self.login(username, password)
22
+ begin
23
+ response = RestClient.post("https://api.ctl.io/v2/authentication/login",
24
+ {:username => username,
25
+ :password => password
26
+ }.to_json,
27
+ :content_type => :json, :accept => :json
28
+ )
29
+ rescue => e
30
+ puts e.response
31
+ end
32
+ $token = JSON.parse(response)['bearerToken']
33
+ end
34
+
35
+ def self.getServerDetails(accountAlias, serverId)
36
+ begin
37
+ response = RestClient.get("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}", :authorization => "Bearer #{$token}")
38
+ rescue => e
39
+ puts e
40
+ end
41
+ JSON.parse(response)
42
+ end
43
+
44
+ def self.createServer(accountAlias, payload = {})
45
+ response = RestClient.post("https://api.ctl.io/v2/servers/#{accountAlias}",
46
+ payload.to_json,
47
+ :content_type => :json, :accept => :json,
48
+ :authorization => "Bearer #{$token}"
49
+ )
50
+ puts response
51
+ JSON.parse(response)
52
+ end
53
+
54
+ def self.deleteServer(accountAlias, serverId)
55
+ response = RestClient.delete("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}", :authorization => "Bearer #{$token}")
56
+ JSON.parse(response)
57
+ end
58
+
59
+ def self.getServerCredentials(accountAlias, serverId)
60
+ response = RestClient.get("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}/credentials", :authorization => "Bearer #{$token}")
61
+ JSON.parse(response)
62
+ end
63
+
64
+ def self.setServerCpuOrMemory(accountAlias, serverId, payload = {})
65
+ response = RestClient.patch("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}",
66
+ payload.to_json,
67
+ :content_type => :json,
68
+ :accept => :json,
69
+ :authorization => "Bearer #{$token}")
70
+ JSON.parse(response)
71
+ end
72
+
73
+ def self.setServerCredentials(accountAlias, serverId, payload = {})
74
+ response = RestClient.patch("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}",
75
+ payload.to_json,
76
+ :content_type => :json, :accept => :json,
77
+ :authorization => "Bearer #{$token}"
78
+ )
79
+ JSON.parse(response)
80
+ end
81
+
82
+ def self.setServerCustomsFields(accountAlias, serverId, payload = {})
83
+ response = RestClient.patch("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}",
84
+
85
+ payload.to_json,
86
+ :content_type => :json, :accept => :json,
87
+ :authorization => "Bearer #{$token}"
88
+ )
89
+ JSON.parse(response)
90
+ end
91
+
92
+ def self.setServerDescriptionOrGroup(accountAlias, serverId, payload = {})
93
+ response = RestClient.patch("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}",
94
+ payload.to_json,
95
+ :content_type => :json, :accept => :json,
96
+ :authorization => "Bearer #{$token}"
97
+ )
98
+ JSON.parse(response)
99
+ end
100
+
101
+ def self.setServerDisks(accountAlias, serverId, payload = {})
102
+ response = RestClient.patch("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}",
103
+ payload.to_json,
104
+ :content_type => :json, :accept => :json,
105
+ :authorization => "Bearer #{$token}"
106
+ )
107
+ JSON.parse(response)
108
+ end
109
+
110
+ def self.getQueueStatus(accountAlias, serverId)
111
+ response = RestClient.get("https://api.ctl.io/v2/operations/#{acctAlias}/status/#{statusId}",
112
+ :authorization => "Bearer #{$token}"
113
+ )
114
+ end
115
+
116
+ def self.addPublicIpAddress(accountAlias, serverId, payload = {})
117
+ response = RestClient.post("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}/publicIPAddresses",
118
+ payload.to_json,
119
+ :content_type => :json, :accept => :json,
120
+ :authorization => "Bearer #{$token}"
121
+ )
122
+ JSON.parse(response)
123
+ end
124
+
125
+ def self.getPublicIpAddress(accountAlias, serverId, publicIP)
126
+ response = RestClient.get("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}/publicIPAddresses/#{publicIP}", :authorization => "Bearer #{$token}")
127
+ JSON.parse(response)
128
+ end
129
+
130
+ def self.deletePublicIpAddress(accountAlias, serverId, publicIP)
131
+ response = RestClient.get("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}/publicIPAddresses/#{publicIP}", :authorization => "Bearer #{$token}")
132
+ JSON.parse(response)
133
+ end
134
+
135
+ def self.updatePublicIpAddress(accountAlias, serverId, publicIP, payload = {})
136
+ response = RestClient.post("https://api.ctl.io/v2/servers/#{accountAlias}/#{serverId}/publicIPAddresses",
137
+ payload.to_json,
138
+ :content_type => :json, :accept => :json,
139
+ :authorization => "Bearer #{$token}"
140
+ )
141
+ JSON.parse(response)
142
+ end
143
+
144
+ def self.archiveServer(accountAlias, serverIds = {})
145
+ response = RestClient.post("https://api.ctl.io/v2/operations/#{accountAlias}/servers/archive",
146
+ serversIds.to_json,
147
+ :content_type => :json, :accept => :json,
148
+ :authorization => "Bearer #{$token}"
149
+ )
150
+ JSON.parse(response)
151
+ end
152
+
153
+ def self.createSnapshot(accountAlias, payload = {})
154
+ response = RestClient.post("https://api.ctl.io/v2/operations/{accountAlias}/servers/createSnapshot",
155
+ payload.to_json,
156
+ :content_type => :json, :accept => :json,
157
+ :authorization => "Bearer #{$token}"
158
+ )
159
+ end
160
+
161
+ def self.executePackage(accountAlias, payload = {})
162
+ response = RestClient.post("https://api.ctl.io/v2/operations/#{accountAlias}/servers/executePackage",
163
+ payload.to_json,
164
+ :content_type => :json, :accept => :json,
165
+ :authorization => "Bearer #{$token}"
166
+ )
167
+ JSON.parse(response)
168
+ end
169
+
170
+ def self.restoreServer(accountAlias, targetGroupId)
171
+ response = RestClient.post("https://api.ctl.io/v2/servers/{accountAlias}/{serverId}/restore",
172
+ {:targetGroupId => targetGroupId}.to_json,
173
+ :content_type => :json, :accept => :json,
174
+ :authorization => "Bearer #{$token}")
175
+ JSON.parse(response)
176
+ end
177
+
178
+ def self.setPowerOperation(accountAlias, powerOperation, serverIds = {})
179
+ response = RestClient.post("https://api.ctl.io/v2/operations/#{accountAlias}/servers/#{powerOperation}",
180
+ {:serverIds => serverIds}.to_json,
181
+ :content_type => :json, :accept => :json,
182
+ :authorization => "Bearer #{$token}")
183
+ JSON.parse(response)
184
+ end
185
+
186
+ def self.setMaintenanceMode(accountAlias, servers = {})
187
+ response = RestClient.post("https://api.ctl.io/v2/operations/#{accountAlias}/servers/setMaintenance",
188
+ servers.to_json,
189
+ :content_type => :json, :accept => :json,
190
+ :authorization => "Bearer #{$token}")
191
+ JSON.parse(response)
192
+ end
193
+
194
+ def self.archiveGroup(accountAlias, groupId, payload = {})
195
+ response = RestClient.post("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}/archive",
196
+ payload.to_json,
197
+ :content_type => :json, :accept => :json,
198
+ :authorization => authorization
199
+ )
200
+ JSON.parse(response)
201
+ end
202
+
203
+ def self.restoreGroup(accountAlias, groupId, targetGroupId)
204
+ response = RestClient.post("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}/restore",
205
+ {:targetGroupId => targetGroupId}.to_json,
206
+ :content_type => :json, :accept => :json,
207
+ :authorization => "Bearer #{$token}")
208
+ end
209
+
210
+ def self.createGroup(accountAlias, payload)
211
+ response = RestClient.post("https://api.ctl.io/v2/groups/#{accountAlias}",
212
+ payload.to_json,
213
+ :content_type => :json, :accept => :json,
214
+ :authorization => "Bearer #{$token}")
215
+ JSON.parse(response)
216
+ end
217
+
218
+ def self.deleteGroup(accountAlias, groupId)
219
+ response = RestClient.delete("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}",
220
+ :authorization => "Bearer #{$token}")
221
+ JSON.parse(response)
222
+ end
223
+
224
+ def self.getGroup(accountAlias, groupId)
225
+ response = RestClient.get("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}",
226
+ :authorization => "Bearer #{$token}")
227
+ JSON.parse(response)
228
+ end
229
+
230
+ def self.getGroupBillingDetails(accountAlias, groupId)
231
+ response = RestClient.get("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}/billing",
232
+ :authorization => authorization)
233
+ JSON.parse(response)
234
+ end
235
+
236
+ def self.getGroupMonitorinfStatistics(accountAlias, groupId)
237
+ response = RestClient.get("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}/statistics?start=#{datetime}&sampleInterval=dd:hh:mm:ss",
238
+ :authorization => "Bearer #{$token}")
239
+ JSON.parse(response)
240
+ end
241
+
242
+ def self.setCustomFields(accountAlias, groupId, patchOperation = {})
243
+ response = RestClient.get("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}",
244
+ {:patchOperation => patchOperation}.to_json,
245
+ :content_type => :json, :accept => :json,
246
+ :authorization => "Bearer #{$token}")
247
+ JSON.parse(response)
248
+ end
249
+
250
+ def self.setGroupNameOrDescription(accountAlias, groupId, patchOperation = {})
251
+ response = RestClient.patch("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}",
252
+ {:patchOperation => patchOperation}.to_json,
253
+ :content_type => :json, :accept => :json,
254
+ :authorization => "Bearer #{$token}")
255
+ JSON.parse(response)
256
+ end
257
+
258
+
259
+ def self.setGroupParent(accountAlias, groupId, patchOperation = {})
260
+ response = RestClient.patch("https://api.ctl.io/v2/groups/#{accountAlias}/#{groupId}",
261
+ {:patchOperation => patchOperation}.to_json,
262
+ :content_type => :json, :accept => :json,
263
+ :authorization => "Bearer #{$token}")
264
+ JSON.parse(response)
265
+ end
266
+
267
+ def self.getCustomGroups(accountAlias)
268
+ response = RestClient.get("https://api.ctl.io/v2/accounts/#{accountAlias}/customFields",
269
+ :authorization => "Bearer #{$token}"
270
+ )
271
+ JSON.parse(response)
272
+ end
273
+
274
+ def self.getDataCenter(accountAlias, dataCenter)
275
+ response = RestClient.get("https://api.ctl.io/v2/datacenters/#{accountAlias}/#{dataCenter}?groupLinks=true|false",
276
+ :authorization => "Bearer #{$token}")
277
+ JSON.parse(response)
278
+ end
279
+
280
+ def self.getDataCentereploymentCapalities(accountAlias, datacenter)
281
+ response = RestClient.get("https://api.ctl.io/v2/datacenters/#{accountAlias}/#{dataCenter}/deploymentCapabilities",
282
+ :authorization => "Bearer #{$token}")
283
+ JSON.parse(response)
284
+ end
285
+
286
+ def self.getDataCenterList(accountAlias)
287
+ response = RestClient.get("https://api.ctl.io/v2/datacenters/#{accountAlias}",
288
+ :authorization => "Bearer #{$token}")
289
+ JSON.parse(response)
290
+ end
291
+
292
+ def self.getCustomFields(accountAlias)
293
+ response = RestClient.get("https://api.ctl.io/v2/accounts/#{accountAlias}/customFields",
294
+ :authorization => "Bearer #{$token}")
295
+ JSON.parse(response)
296
+ end
297
+
298
+ def self.createAntiAffinityPolicy(accountAlias)
299
+ response = RestClient.get("https://api.ctl.io/v2/antiAffinityPolicies/#{accountAlias}",
300
+ :authorization => "Bearer #{$token}")
301
+ JSON.parse(response)
302
+ end
303
+
304
+ def self.deleteAntiAffinityPolicy(accountAlias, policyId, payload = {})
305
+ response = RestClient.get("https://api.ctl.io/v2/antiAffinityPolicies/#{accountAlias}/#{policyId}",
306
+ payload.to_json,
307
+ :content_type => :json, :accept => :json,
308
+ :authorization => "Bearer #{$token}")
309
+ JSON.parse(response)
310
+ end
311
+
312
+ def self.updateAntiAffinityPolicy(accountAlias, policyId, name)
313
+ response = RestClient.get("https://api.ctl.io/v2/antiAffinityPolicies/#{accountAlias}/#{policyId}",
314
+ {:name => name}.to_json,
315
+ :content_type => :json, :accept => :json,
316
+ :authorization => "Bearer #{$token}")
317
+ JSON.parse(response)
318
+ end
319
+
320
+ def self.getAntiAffinityPolicy(accountAlias, policyId)
321
+ response = RestClient.get("https://api.ctl.io/v2/antiAffinityPolicies/#{accountAlias}/#{policyId}",
322
+ :authorization => "Bearer #{$token}")
323
+ JSON.parse(response)
324
+ end
325
+
326
+ def self.getAntiAffinityPolicies(accountAlias)
327
+ response = RestClient.get("https://api.ctl.io/v2/antiAffinityPolicies/#{accountAlias}",
328
+ :authorization => "Bearer #{$token}")
329
+ JSON.parse(response)
330
+ end
331
+
332
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clc_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Hinds
8
+ - Anthony Howell
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2015-03-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.9'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rest-client
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description:
71
+ email:
72
+ - jonathan.a.hinds@gmail.com
73
+ - anthony.howell@centurylink.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".DS_Store"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - clc_client.gemspec
87
+ - lib/.DS_Store
88
+ - lib/clc_client.rb
89
+ - lib/clc_client/.DS_Store
90
+ - lib/clc_client/version.rb
91
+ homepage: https://github.com/jhinds/clc_client
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A ruby client for CenturyLink Cloud
115
+ test_files: []