leaseweb-rest-api 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d2aac5e36fa1ddbeab7ca822846a079aaea17d9
4
- data.tar.gz: c2112b2e361ab38d9748b32492a40b2394f3a559
3
+ metadata.gz: ac512f54b172ce83fb45963e66a45cfc96389a7b
4
+ data.tar.gz: 73cec703553b22fd64965ca24c8cba991b19b505
5
5
  SHA512:
6
- metadata.gz: 8890b2ab77228b22a50143188f8734a373dab38f52f2292ac81496abd7574474feea457d73560b107d05401af4b2c415eae837ac67d8c7e9244c6d9d056df23c
7
- data.tar.gz: 1ae5426e7ff41dce43d73d4a5bcde4d1c12ed65f4b9876e29413fe719d3ac39ddb881a0a5fc159744ea0dfe32ed2b2024e401015bc1fe7dd48d1f2348e813ebd
6
+ metadata.gz: 470183d2e7732fa4ebe15629a56fc07b359fc53110e4fae117e018b15e2e35a64a1a5deff4771d2e0781d019b93fccc61cc5fc54858e696e13c3d92fa7967c84
7
+ data.tar.gz: 16c873c41aee0a124b4ae949e8c039a2f5374c3389c2521242f0128ed29256bef747087d182d8a8cbe8172bcd3f204665cc09befa6b0487f700373ab95c6d6d0
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'leaseweb-rest-api'
3
- s.version = '1.1.0'
3
+ s.version = '1.1.1'
4
4
  s.authors = 'Arnoud Vermeer'
5
5
  s.email = 'a.vermeer@tech.leaseweb.com'
6
6
  s.license = 'Apache'
@@ -11,7 +11,7 @@ class LeasewebAPI
11
11
  format :json
12
12
  # debug_output $stderr
13
13
 
14
- base_uri 'https://api.leaseweb.com/v1'
14
+ base_uri 'https://api.leaseweb.com'
15
15
 
16
16
  def apiKeyAuth(apikey)
17
17
  @options = { headers: { 'X-Lsw-Auth' => apikey } }
@@ -62,21 +62,21 @@ class LeasewebAPI
62
62
 
63
63
  # Domains
64
64
  def getDomains
65
- self.class.get('/domains', @options)
65
+ self.class.get('/v1/domains', @options)
66
66
  end
67
67
 
68
68
  def getDomain(domain)
69
- self.class.get("/domains/#{domain}", @options)
69
+ self.class.get("/v1/domains/#{domain}", @options)
70
70
  end
71
71
 
72
72
  def updateDomain(domain, ttl)
73
73
  opt = @options.merge!(body: { ttl: ttl })
74
74
 
75
- self.class.put("/domains/#{domain}", opt)
75
+ self.class.put("/v1/domains/#{domain}", opt)
76
76
  end
77
77
 
78
78
  def getDNSRecords(domain)
79
- self.class.get("/domains/#{domain}/dnsRecords", @options)
79
+ self.class.get("/v1/domains/#{domain}/dnsRecords", @options)
80
80
  end
81
81
 
82
82
  def createDNSRecords(domain, host, content, type, priority = nil)
@@ -86,11 +86,11 @@ class LeasewebAPI
86
86
  opt[:body][:priority] = priority
87
87
  end
88
88
 
89
- self.class.post("/domains/#{domain}/dnsRecords", opt)
89
+ self.class.post("/v1/domains/#{domain}/dnsRecords", opt)
90
90
  end
91
91
 
92
92
  def getDNSRecord(domain, dnsRecordId)
93
- self.class.get("/domains/#{domain}/dnsRecords/#{dnsRecordId}", @options)
93
+ self.class.get("/v1/domains/#{domain}/dnsRecords/#{dnsRecordId}", @options)
94
94
  end
95
95
 
96
96
  def updateDNSRecord(domain, dnsRecordId, host, content, type, priority = nil)
@@ -100,103 +100,103 @@ class LeasewebAPI
100
100
  opt[:body][:priority] = priority
101
101
  end
102
102
 
103
- self.class.put("/domains/#{domain}/dnsRecords/#{dnsRecordId}", opt)
103
+ self.class.put("/v1/domains/#{domain}/dnsRecords/#{dnsRecordId}", opt)
104
104
  end
105
105
 
106
106
  def deleteDNSRecord(domain, dnsRecordId)
107
- self.class.delete("/domains/#{domain}/dnsRecords/#{dnsRecordId}", @options)
107
+ self.class.delete("/v1/domains/#{domain}/dnsRecords/#{dnsRecordId}", @options)
108
108
  end
109
109
 
110
110
  # Rescue
111
111
  def getRescueImages
112
- self.class.get('/rescueImages', @options)
112
+ self.class.get('/v1/rescueImages', @options)
113
113
  end
114
114
 
115
115
  # BareMetals
116
116
  def getBareMetals
117
- self.class.get('/bareMetals', @options)
117
+ self.class.get('/v1/bareMetals', @options)
118
118
  end
119
119
 
120
120
  def getBareMetal(bareMetalId)
121
- self.class.get("/bareMetals/#{bareMetalId}", @options)
121
+ self.class.get("/v1/bareMetals/#{bareMetalId}", @options)
122
122
  end
123
123
 
124
124
  def updateBareMetal(bareMetalId, reference)
125
125
  opt = @options.merge!(body: { reference: reference })
126
126
 
127
- self.class.put("/bareMetals/#{bareMetalId}", opt)
127
+ self.class.put("/v1/bareMetals/#{bareMetalId}", opt)
128
128
  end
129
129
 
130
130
  def getSwitchPort(bareMetalId)
131
- self.class.get("/bareMetals/#{bareMetalId}/switchPort", @options)
131
+ self.class.get("/v1/bareMetals/#{bareMetalId}/switchPort", @options)
132
132
  end
133
133
 
134
134
  def postSwitchPortOpen(bareMetalId)
135
- self.class.post("/bareMetals/#{bareMetalId}/switchPort/open", @options)
135
+ self.class.post("/v1/bareMetals/#{bareMetalId}/switchPort/open", @options)
136
136
  end
137
137
 
138
138
  def postSwitchPortClose(bareMetalId)
139
- self.class.post("/bareMetals/#{bareMetalId}/switchPort/close", @options)
139
+ self.class.post("/v1/bareMetals/#{bareMetalId}/switchPort/close", @options)
140
140
  end
141
141
 
142
142
  def getPowerStatus(bareMetalId)
143
- self.class.get("/bareMetals/#{bareMetalId}/powerStatus", @options)
143
+ self.class.get("/v1/bareMetals/#{bareMetalId}/powerStatus", @options)
144
144
  end
145
145
 
146
146
  def getIPs(bareMetalId)
147
- self.class.get("/bareMetals/#{bareMetalId}/ips", @options)
147
+ self.class.get("/v1/bareMetals/#{bareMetalId}/ips", @options)
148
148
  end
149
149
 
150
150
  def getIP(bareMetalId, ipAddress)
151
- self.class.get("/bareMetals/#{bareMetalId}/ips/#{ipAddress}", @options)
151
+ self.class.get("/v1/bareMetals/#{bareMetalId}/ips/#{ipAddress}", @options)
152
152
  end
153
153
 
154
154
  def updateIP(bareMetalId, ipAddress, reverseLookup = '', nullRouted = 0)
155
155
  opt = @options.merge!(body: { reverseLookup: reverseLookup, nullRouted: nullRouted })
156
156
 
157
- self.class.put("/bareMetals/#{bareMetalId}/ips/#{ipAddress}", opt)
157
+ self.class.put("/v1/bareMetals/#{bareMetalId}/ips/#{ipAddress}", opt)
158
158
  end
159
159
 
160
160
  def getIpmiCredentials(bareMetalId)
161
- self.class.get("/bareMetals/#{bareMetalId}/ipmiCredentials", @options)
161
+ self.class.get("/v1/bareMetals/#{bareMetalId}/ipmiCredentials", @options)
162
162
  end
163
163
 
164
164
  def getNetworkUsage(bareMetalId)
165
- self.class.get("/bareMetals/#{bareMetalId}/networkUsage", @options)
165
+ self.class.get("/v1/bareMetals/#{bareMetalId}/networkUsage", @options)
166
166
  end
167
167
 
168
168
  def getNetworkUsageBandWidth(bareMetalId, dateFrom, dateTo, format = 'json')
169
- self.class.get("/bareMetals/#{bareMetalId}/networkUsage/bandWidth", formatRequest(dateFrom, dateTo, format))
169
+ self.class.get("/v1/bareMetals/#{bareMetalId}/networkUsage/bandWidth", formatRequest(dateFrom, dateTo, format))
170
170
  end
171
171
 
172
172
  def getNetworkUsageDataTraffic(bareMetalId, dateFrom, dateTo, format = 'json')
173
- self.class.get("/bareMetals/#{bareMetalId}/networkUsage/dataTraffic", formatRequest(dateFrom, dateTo, format))
173
+ self.class.get("/v1/bareMetals/#{bareMetalId}/networkUsage/dataTraffic", formatRequest(dateFrom, dateTo, format))
174
174
  end
175
175
 
176
176
  def postReboot(bareMetalId)
177
- self.class.post("/bareMetals/#{bareMetalId}/reboot", @options)
177
+ self.class.post("/v1/bareMetals/#{bareMetalId}/reboot", @options)
178
178
  end
179
179
 
180
180
  def installServer(bareMetalId, osId, hdd = [])
181
181
  opt = @options.merge!(body: { osId: osId, hdd: hdd }, query_string_normalizer: ->(h) { HashToURIConversion.new.to_params(h) })
182
182
 
183
- self.class.post("/bareMetals/#{bareMetalId}/install", opt)
183
+ self.class.post("/v1/bareMetals/#{bareMetalId}/install", opt)
184
184
  end
185
185
 
186
186
  def postResqueMode(bareMetalId, osId)
187
187
  opt = @options.merge!(body: { osId: osId })
188
188
 
189
- self.class.post("/bareMetals/#{bareMetalId}/rescueMode", opt)
189
+ self.class.post("/v1/bareMetals/#{bareMetalId}/rescueMode", opt)
190
190
  end
191
191
 
192
192
  def getRootPassword(bareMetalId, format = 'json')
193
193
  opt = @options.merge!(headers: formatHeader(format))
194
194
 
195
- self.class.get("/bareMetals/#{bareMetalId}/rootPassword", opt)
195
+ self.class.get("/v1/bareMetals/#{bareMetalId}/rootPassword", opt)
196
196
  end
197
197
 
198
198
  def getInstallationStatus(bareMetalId)
199
- response = self.class.get("/bareMetals/#{bareMetalId}/installationStatus", @options)
199
+ response = self.class.get("/v1/bareMetals/#{bareMetalId}/installationStatus", @options)
200
200
 
201
201
  if response['installationStatus'].include?('initRootPassword')
202
202
  response['installationStatus']['initRootPassword'] = decrypt(response['installationStatus']['initRootPassword'])
@@ -210,131 +210,123 @@ class LeasewebAPI
210
210
  end
211
211
 
212
212
  def getLeases(bareMetalId)
213
- self.class.get("/bareMetals/#{bareMetalId}/leases", @options)
213
+ self.class.get("/v1/bareMetals/#{bareMetalId}/leases", @options)
214
214
  end
215
215
 
216
216
  def setLease(bareMetalId, bootFileName)
217
217
  opt = @options.merge!(body: { bootFileName: bootFileName })
218
218
 
219
- self.class.post("/bareMetals/#{bareMetalId}/leases", opt)
219
+ self.class.post("/v1/bareMetals/#{bareMetalId}/leases", opt)
220
220
  end
221
221
 
222
222
  def getLease(bareMetalId, macAddress)
223
- self.class.get("/bareMetals/#{bareMetalId}/leases/#{macAddress}", @options)
223
+ self.class.get("/v1/bareMetals/#{bareMetalId}/leases/#{macAddress}", @options)
224
224
  end
225
225
 
226
226
  def deleteLease(bareMetalId, macAddress)
227
- self.class.delete("/bareMetals/#{bareMetalId}/leases/#{macAddress}", @options)
228
- end
229
-
230
- # New install call
231
- def install(bareMetalId, operatingSystemId, options = {})
232
- options[:operatingSystemId] = operatingSystemId
233
- opt = @options.merge!(body: options.to_json)
234
-
235
- self.class.post("/bmpapi/bareMetals/#{bareMetalId}/install", opt)
227
+ self.class.delete("/v1/bareMetals/#{bareMetalId}/leases/#{macAddress}", @options)
236
228
  end
237
229
 
238
230
  # Private Networks
239
231
  def getPrivateNetworks
240
- self.class.get('/privateNetworks', @options)
232
+ self.class.get('/v1/privateNetworks', @options)
241
233
  end
242
234
 
243
235
  # TODO: check post with name
244
236
  def createPrivateNetworks(name = '')
245
237
  opt = @options.merge!(body: { name: name })
246
238
 
247
- self.class.post('/privateNetworks', opt)
239
+ self.class.post('/v1/privateNetworks', opt)
248
240
  end
249
241
 
250
242
  def getPrivateNetwork(id)
251
- self.class.get("/privateNetworks/#{id}", @options)
243
+ self.class.get("/v1/privateNetworks/#{id}", @options)
252
244
  end
253
245
 
254
246
  # TODO: Check with Jeroen if it works
255
247
  def updatePrivateNetwork(id, name = '')
256
248
  opt = @options.merge!(body: { name: name })
257
249
 
258
- self.class.put("/privateNetworks/#{id}", opt)
250
+ self.class.put("/v1/privateNetworks/#{id}", opt)
259
251
  end
260
252
 
261
253
  def deletePrivateNetwork(id)
262
- self.class.delete("/privateNetworks/#{id}", @options)
254
+ self.class.delete("/v1/privateNetworks/#{id}", @options)
263
255
  end
264
256
 
265
257
  def createPrivateNetworksBareMetals(id, bareMetalId)
266
258
  opt = @options.merge!(body: { bareMetalId: bareMetalId })
267
259
 
268
- self.class.post("/privateNetworks/#{id}/bareMetals", opt)
260
+ self.class.post("/v1/privateNetworks/#{id}/bareMetals", opt)
269
261
  end
270
262
 
271
263
  def deletePrivateNetworksBareMetals(id, bareMetalId)
272
- self.class.delete("/privateNetworks/#{id}/bareMetals/#{bareMetalId}", @options)
264
+ self.class.delete("/v1/privateNetworks/#{id}/bareMetals/#{bareMetalId}", @options)
273
265
  end
274
266
 
275
267
  # Operating Systems
276
268
  def getOperatingSystems
277
- self.class.get('/operatingSystems', @options)
269
+ self.class.get('/v1/operatingSystems', @options)
278
270
  end
279
271
 
280
272
  def getOperatingSystem(operatingSystemId)
281
- self.class.get("/operatingSystems/#{operatingSystemId}", @options)
273
+ self.class.get("/v1/operatingSystems/#{operatingSystemId}", @options)
282
274
  end
283
275
 
284
276
  def getControlPanels(operatingSystemId)
285
- self.class.get("/operatingSystems/#{operatingSystemId}/controlPanels", @options)
277
+ self.class.get("/v1/operatingSystems/#{operatingSystemId}/controlPanels", @options)
286
278
  end
287
279
 
288
280
  def getControlPanel(operatingSystemId, controlPanelId)
289
- self.class.get("/operatingSystems/#{operatingSystemId}/controlPanels/#{controlPanelId}", @options)
281
+ self.class.get("/v1/operatingSystems/#{operatingSystemId}/controlPanels/#{controlPanelId}", @options)
290
282
  end
291
283
 
292
284
  def getPartitionSchema(operatingSystemId, bareMetalId)
293
285
  opt = @options.merge!(query: { serverPackId: bareMetalId })
294
286
 
295
- self.class.get("/operatingSystems/#{operatingSystemId}/partitionSchema", opt)
287
+ self.class.get("/v1/operatingSystems/#{operatingSystemId}/partitionSchema", opt)
296
288
  end
297
289
 
298
290
  # IPs
299
291
  def getIps
300
- self.class.get('/ips', @options)
292
+ self.class.get('/v1/ips', @options)
301
293
  end
302
294
 
303
295
  def getIp(ipAddress)
304
- self.class.get("/ips/#{ipAddress}", @options)
296
+ self.class.get("/v1/ips/#{ipAddress}", @options)
305
297
  end
306
298
 
307
299
  def updateIp(ipAddress, reverseLookup = '', nullRouted = 0)
308
300
  opt = @options.merge!(body: { reverseLookup: reverseLookup, nullRouted: nullRouted })
309
301
 
310
- self.class.put("/ips/#{ipAddress}", opt)
302
+ self.class.put("/v1/ips/#{ipAddress}", opt)
311
303
  end
312
304
 
313
305
  # Pay as you go
314
306
  def getPAYGInstances
315
- self.class.get('/payAsYouGo/bareMetals/instances', @options)
307
+ self.class.get('/v1/payAsYouGo/bareMetals/instances', @options)
316
308
  end
317
309
 
318
310
  def createPAYGInstance(modelId)
319
311
  opt = @options.merge!(model: modelId)
320
312
 
321
- self.class.post('/payAsYouGo/bareMetals/instances', opt)
313
+ self.class.post('/v1/payAsYouGo/bareMetals/instances', opt)
322
314
  end
323
315
 
324
316
  def getPAYGInstance(bareMetalId)
325
- self.class.get("/payAsYouGo/bareMetals/instances/#{bareMetalId}", @options)
317
+ self.class.get("/v1/payAsYouGo/bareMetals/instances/#{bareMetalId}", @options)
326
318
  end
327
319
 
328
320
  def destroyPAYGInstance(bareMetalId)
329
- self.class.post("/payAsYouGo/bareMetals/instances/#{bareMetalId}/destroy", @options)
321
+ self.class.post("/v1/payAsYouGo/bareMetals/instances/#{bareMetalId}/destroy", @options)
330
322
  end
331
323
 
332
324
  def getPAYGModels
333
- self.class.get('/payAsYouGo/bareMetals/models', @options)
325
+ self.class.get('/v1/payAsYouGo/bareMetals/models', @options)
334
326
  end
335
327
 
336
328
  def getPAYGModelInstance(modelId)
337
- self.class.get("/payAsYouGo/bareMetals/models/#{modelId}", @options)
329
+ self.class.get("/v1/payAsYouGo/bareMetals/models/#{modelId}", @options)
338
330
  end
339
331
 
340
332
  protected
data/readme.md CHANGED
@@ -58,7 +58,7 @@ privateKeyFile = './id_rsa'
58
58
  password = 'my_super_strong_s3cr3t_passw0rd'
59
59
 
60
60
  api = LeasewebAPI.new
61
- getOauthToken(client_id, client_secret)
61
+ api.getOauthToken(client_id, client_secret)
62
62
  api.readPrivateKey(privateKeyFile, password)
63
63
  ```
64
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leaseweb-rest-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnoud Vermeer