fog-oneandone 1.0 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -1
  3. data/Rakefile +24 -0
  4. data/examples/example_app.rb +39 -12
  5. data/fog-oneandone.gemspec +2 -1
  6. data/lib/oneandone/compute.rb +103 -16
  7. data/lib/oneandone/models/compute/baremetal_model.rb +15 -0
  8. data/lib/oneandone/models/compute/baremetal_models.rb +24 -0
  9. data/lib/oneandone/models/compute/block_storage.rb +100 -0
  10. data/lib/oneandone/models/compute/block_storages.rb +24 -0
  11. data/lib/oneandone/models/compute/firewall.rb +0 -15
  12. data/lib/oneandone/models/compute/image.rb +6 -1
  13. data/lib/oneandone/models/compute/public_ip.rb +2 -1
  14. data/lib/oneandone/models/compute/recovery_appliance.rb +18 -0
  15. data/lib/oneandone/models/compute/recovery_appliances.rb +24 -0
  16. data/lib/oneandone/models/compute/server.rb +44 -105
  17. data/lib/oneandone/models/compute/server_appliance.rb +25 -0
  18. data/lib/oneandone/models/compute/server_appliances.rb +24 -0
  19. data/lib/oneandone/models/compute/ssh_key.rb +67 -0
  20. data/lib/oneandone/models/compute/ssh_keys.rb +24 -0
  21. data/lib/oneandone/requests/compute/add_block_storage_server.rb +61 -0
  22. data/lib/oneandone/requests/compute/add_ports.rb +1 -1
  23. data/lib/oneandone/requests/compute/create_block_storage.rb +80 -0
  24. data/lib/oneandone/requests/compute/create_image.rb +9 -3
  25. data/lib/oneandone/requests/compute/create_server.rb +11 -5
  26. data/lib/oneandone/requests/compute/create_ssh_key.rb +74 -0
  27. data/lib/oneandone/requests/compute/delete_block_storage.rb +51 -0
  28. data/lib/oneandone/requests/compute/delete_ssh_key.rb +51 -0
  29. data/lib/oneandone/requests/compute/get_baremetal_model.rb +42 -0
  30. data/lib/oneandone/requests/compute/get_block_storage.rb +50 -0
  31. data/lib/oneandone/requests/compute/get_block_storage_server.rb +50 -0
  32. data/lib/oneandone/requests/compute/get_recovery_appliance.rb +41 -0
  33. data/lib/oneandone/requests/compute/get_ssh_key.rb +50 -0
  34. data/lib/oneandone/requests/compute/list_baremetal_models.rb +49 -0
  35. data/lib/oneandone/requests/compute/list_block_storages.rb +56 -0
  36. data/lib/oneandone/requests/compute/list_recovery_appliances.rb +47 -0
  37. data/lib/oneandone/requests/compute/list_ssh_keys.rb +56 -0
  38. data/lib/oneandone/requests/compute/remove_block_storage_server.rb +50 -0
  39. data/lib/oneandone/requests/compute/update_block_storage.rb +80 -0
  40. data/lib/oneandone/requests/compute/update_ssh_key.rb +78 -0
  41. data/tests/oneandone/test_block_storages.rb +82 -0
  42. data/tests/oneandone/test_firewalls.rb +5 -16
  43. data/tests/oneandone/test_recovery_appliances.rb +34 -0
  44. data/tests/oneandone/test_server_appliances.rb +34 -0
  45. data/tests/oneandone/test_ssh_keys.rb +82 -0
  46. metadata +58 -13
  47. data/lib/oneandone/requests/compute/remove_firewall_ip.rb +0 -60
@@ -0,0 +1,82 @@
1
+ require_relative '../../lib/fog-oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ Fog.mock!
5
+
6
+ class TestSshKey < Minitest::Test
7
+
8
+ def self.test_order
9
+ :alpha
10
+ end
11
+
12
+ def setup
13
+
14
+ # Establish Connection
15
+ @compute = Fog::Compute::OneAndOne.new({
16
+ :oneandone_api_key => '<API-TOKEN>'
17
+ })
18
+
19
+ end
20
+
21
+
22
+ def test_a_create_ssh_key
23
+
24
+ # Perform Request
25
+ response = @compute.create_ssh_key(name: 'Test SSH Key',
26
+ description: 'Example Desc',
27
+ public_key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCezYMOgAan+JmatgFJ+Q1FUNjrqNVgAvcTkjYJwHVcQaolq9f9qB7tEeUPDNj2oNN49joAmTcllDcPIxryT5PnQUaaUhu4ZJ9+bRtXCyhnf2LJQdVfzBFEBJX9fW4RiV1XtSAtLRBrbrCb4JjHmhIYpvhBHC29Ve+g64nhdvBhqyLZ3SLI2U/opEmt5u2xftWGl0TBSQYveqc4ntz3fe+f9XlBHvK3Nw12bCLmLle7jQuZ4lXyAYqNAfdOMTs2zMTk422Dl/h4+zRh1h4rM9zaCk4+g3kdugJm7Vul03wm43cHmHsJv51R3XKSHzgb7q/eNj+YdMi5Ndt0Bm+bLjw7')
28
+
29
+ @@ssh_key_id = response.body['id']
30
+
31
+ # Assertions
32
+ assert_equal response.body['name'], 'Test SSH Key'
33
+ assert_equal response.body['description'], 'Example Desc'
34
+ assert_equal response.body['public_key'].end_with?('YdMi5Ndt0Bm+bLjw7') , true
35
+
36
+ end
37
+
38
+ def test_b_list_ssh_keys
39
+
40
+ # Perform Request
41
+ response = @compute.list_ssh_keys
42
+
43
+ # Assertions
44
+ assert_equal response.body.length>0, true
45
+
46
+ end
47
+
48
+ def test_c_update_ssh_key
49
+
50
+ # Perform Request
51
+ response = @compute.update_ssh_key(ssh_key_id: @@ssh_key_id,
52
+ name: 'New Name', description: 'New Desc')
53
+
54
+ # Assertions
55
+ assert_equal response.body['name'], 'New Name'
56
+ assert_equal response.body['description'], 'New Desc'
57
+
58
+ end
59
+
60
+ def test_d_get_ssh_key
61
+
62
+ # Perform Request
63
+ response = @compute.get_ssh_key(@@ssh_key_id)
64
+
65
+ # Assertions
66
+ assert_equal response.body['id'], @@ssh_key_id
67
+
68
+ end
69
+
70
+ def test_i_delete_ssh_key
71
+
72
+ # Perform Request
73
+ response = @compute.delete_ssh_key(@@ssh_key_id)
74
+
75
+ puts "response.body: #{response.body}"
76
+
77
+ # Assertions
78
+ assert_equal response.body, []
79
+
80
+ end
81
+
82
+ end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-oneandone
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Burkhardt (stackpointcloud.com)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fog-json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
55
69
  description: |-
56
70
  This library can be used as a module for 'fog' or as
57
71
  a standalone 1and1 provider.
@@ -60,12 +74,13 @@ executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
- - .gitignore
77
+ - ".gitignore"
64
78
  - CONTRIBUTING.md
65
79
  - CONTRIBUTORS.md
66
80
  - Gemfile
67
81
  - LICENSE.md
68
82
  - README.md
83
+ - Rakefile
69
84
  - bin/fog
70
85
  - examples/example_app.rb
71
86
  - fog-oneandone.gemspec
@@ -73,6 +88,10 @@ files:
73
88
  - lib/fog-oneandone.rb
74
89
  - lib/oneandone/compute.rb
75
90
  - lib/oneandone/core.rb
91
+ - lib/oneandone/models/compute/baremetal_model.rb
92
+ - lib/oneandone/models/compute/baremetal_models.rb
93
+ - lib/oneandone/models/compute/block_storage.rb
94
+ - lib/oneandone/models/compute/block_storages.rb
76
95
  - lib/oneandone/models/compute/firewall.rb
77
96
  - lib/oneandone/models/compute/firewalls.rb
78
97
  - lib/oneandone/models/compute/image.rb
@@ -85,13 +104,20 @@ files:
85
104
  - lib/oneandone/models/compute/private_networks.rb
86
105
  - lib/oneandone/models/compute/public_ip.rb
87
106
  - lib/oneandone/models/compute/public_ips.rb
107
+ - lib/oneandone/models/compute/recovery_appliance.rb
108
+ - lib/oneandone/models/compute/recovery_appliances.rb
88
109
  - lib/oneandone/models/compute/server.rb
110
+ - lib/oneandone/models/compute/server_appliance.rb
111
+ - lib/oneandone/models/compute/server_appliances.rb
89
112
  - lib/oneandone/models/compute/servers.rb
90
113
  - lib/oneandone/models/compute/shared_storage.rb
91
114
  - lib/oneandone/models/compute/shared_storages.rb
115
+ - lib/oneandone/models/compute/ssh_key.rb
116
+ - lib/oneandone/models/compute/ssh_keys.rb
92
117
  - lib/oneandone/models/compute/vpn.rb
93
118
  - lib/oneandone/models/compute/vpns.rb
94
119
  - lib/oneandone/requests/compute/access.rb
120
+ - lib/oneandone/requests/compute/add_block_storage_server.rb
95
121
  - lib/oneandone/requests/compute/add_firewall.rb
96
122
  - lib/oneandone/requests/compute/add_firewall_ips.rb
97
123
  - lib/oneandone/requests/compute/add_firewall_rules.rb
@@ -109,6 +135,7 @@ files:
109
135
  - lib/oneandone/requests/compute/change_password.rb
110
136
  - lib/oneandone/requests/compute/change_status.rb
111
137
  - lib/oneandone/requests/compute/clone_server.rb
138
+ - lib/oneandone/requests/compute/create_block_storage.rb
112
139
  - lib/oneandone/requests/compute/create_firewall.rb
113
140
  - lib/oneandone/requests/compute/create_image.rb
114
141
  - lib/oneandone/requests/compute/create_load_balancer.rb
@@ -118,7 +145,9 @@ files:
118
145
  - lib/oneandone/requests/compute/create_server.rb
119
146
  - lib/oneandone/requests/compute/create_shared_storage.rb
120
147
  - lib/oneandone/requests/compute/create_snapshot.rb
148
+ - lib/oneandone/requests/compute/create_ssh_key.rb
121
149
  - lib/oneandone/requests/compute/create_vpn.rb
150
+ - lib/oneandone/requests/compute/delete_block_storage.rb
122
151
  - lib/oneandone/requests/compute/delete_firewall.rb
123
152
  - lib/oneandone/requests/compute/delete_firewall_rule.rb
124
153
  - lib/oneandone/requests/compute/delete_hdd.rb
@@ -134,8 +163,12 @@ files:
134
163
  - lib/oneandone/requests/compute/delete_server_ip.rb
135
164
  - lib/oneandone/requests/compute/delete_shared_storage.rb
136
165
  - lib/oneandone/requests/compute/delete_snapshot.rb
166
+ - lib/oneandone/requests/compute/delete_ssh_key.rb
137
167
  - lib/oneandone/requests/compute/delete_vpn.rb
138
168
  - lib/oneandone/requests/compute/eject_dvd.rb
169
+ - lib/oneandone/requests/compute/get_baremetal_model.rb
170
+ - lib/oneandone/requests/compute/get_block_storage.rb
171
+ - lib/oneandone/requests/compute/get_block_storage_server.rb
139
172
  - lib/oneandone/requests/compute/get_datacenter.rb
140
173
  - lib/oneandone/requests/compute/get_dvd.rb
141
174
  - lib/oneandone/requests/compute/get_dvd_iso.rb
@@ -159,6 +192,7 @@ files:
159
192
  - lib/oneandone/requests/compute/get_private_network_server.rb
160
193
  - lib/oneandone/requests/compute/get_process.rb
161
194
  - lib/oneandone/requests/compute/get_public_ip.rb
195
+ - lib/oneandone/requests/compute/get_recovery_appliance.rb
162
196
  - lib/oneandone/requests/compute/get_server.rb
163
197
  - lib/oneandone/requests/compute/get_server_appliance.rb
164
198
  - lib/oneandone/requests/compute/get_server_image.rb
@@ -167,8 +201,11 @@ files:
167
201
  - lib/oneandone/requests/compute/get_shared_storage.rb
168
202
  - lib/oneandone/requests/compute/get_shared_storage_server.rb
169
203
  - lib/oneandone/requests/compute/get_snapshot.rb
204
+ - lib/oneandone/requests/compute/get_ssh_key.rb
170
205
  - lib/oneandone/requests/compute/get_vpn.rb
171
206
  - lib/oneandone/requests/compute/install_server_image.rb
207
+ - lib/oneandone/requests/compute/list_baremetal_models.rb
208
+ - lib/oneandone/requests/compute/list_block_storages.rb
172
209
  - lib/oneandone/requests/compute/list_datacenters.rb
173
210
  - lib/oneandone/requests/compute/list_dvds.rb
174
211
  - lib/oneandone/requests/compute/list_firewall_ips.rb
@@ -190,19 +227,21 @@ files:
190
227
  - lib/oneandone/requests/compute/list_private_networks.rb
191
228
  - lib/oneandone/requests/compute/list_processes.rb
192
229
  - lib/oneandone/requests/compute/list_public_ips.rb
230
+ - lib/oneandone/requests/compute/list_recovery_appliances.rb
193
231
  - lib/oneandone/requests/compute/list_server_appliances.rb
194
232
  - lib/oneandone/requests/compute/list_server_ips.rb
195
233
  - lib/oneandone/requests/compute/list_server_private_networks.rb
196
234
  - lib/oneandone/requests/compute/list_servers.rb
197
235
  - lib/oneandone/requests/compute/list_shared_storage_servers.rb
198
236
  - lib/oneandone/requests/compute/list_shared_storages.rb
237
+ - lib/oneandone/requests/compute/list_ssh_keys.rb
199
238
  - lib/oneandone/requests/compute/list_usages.rb
200
239
  - lib/oneandone/requests/compute/list_vpns.rb
201
240
  - lib/oneandone/requests/compute/load_dvd.rb
202
241
  - lib/oneandone/requests/compute/ping.rb
203
242
  - lib/oneandone/requests/compute/ping_auth.rb
243
+ - lib/oneandone/requests/compute/remove_block_storage_server.rb
204
244
  - lib/oneandone/requests/compute/remove_firewall.rb
205
- - lib/oneandone/requests/compute/remove_firewall_ip.rb
206
245
  - lib/oneandone/requests/compute/remove_load_balancer.rb
207
246
  - lib/oneandone/requests/compute/remove_load_balancer_ip.rb
208
247
  - lib/oneandone/requests/compute/remove_mp_server.rb
@@ -211,6 +250,7 @@ files:
211
250
  - lib/oneandone/requests/compute/remove_shared_storage_server.rb
212
251
  - lib/oneandone/requests/compute/restore_snapshot.rb
213
252
  - lib/oneandone/requests/compute/status.rb
253
+ - lib/oneandone/requests/compute/update_block_storage.rb
214
254
  - lib/oneandone/requests/compute/update_firewall.rb
215
255
  - lib/oneandone/requests/compute/update_hardware.rb
216
256
  - lib/oneandone/requests/compute/update_hdd.rb
@@ -223,15 +263,20 @@ files:
223
263
  - lib/oneandone/requests/compute/update_public_ip.rb
224
264
  - lib/oneandone/requests/compute/update_server.rb
225
265
  - lib/oneandone/requests/compute/update_shared_storage.rb
266
+ - lib/oneandone/requests/compute/update_ssh_key.rb
226
267
  - lib/oneandone/requests/compute/update_vpn.rb
268
+ - tests/oneandone/test_block_storages.rb
227
269
  - tests/oneandone/test_firewalls.rb
228
270
  - tests/oneandone/test_images.rb
229
271
  - tests/oneandone/test_load_balancers.rb
230
272
  - tests/oneandone/test_monitoring_policies.rb
231
273
  - tests/oneandone/test_private_networks.rb
232
274
  - tests/oneandone/test_public_ips.rb
275
+ - tests/oneandone/test_recovery_appliances.rb
276
+ - tests/oneandone/test_server_appliances.rb
233
277
  - tests/oneandone/test_servers.rb
234
278
  - tests/oneandone/test_shared_storages.rb
279
+ - tests/oneandone/test_ssh_keys.rb
235
280
  homepage: https://github.com/1and1/fog-oneandone
236
281
  licenses:
237
282
  - MIT
@@ -242,17 +287,17 @@ require_paths:
242
287
  - lib
243
288
  required_ruby_version: !ruby/object:Gem::Requirement
244
289
  requirements:
245
- - - '>='
290
+ - - ">="
246
291
  - !ruby/object:Gem::Version
247
292
  version: '0'
248
293
  required_rubygems_version: !ruby/object:Gem::Requirement
249
294
  requirements:
250
- - - '>='
295
+ - - ">="
251
296
  - !ruby/object:Gem::Version
252
297
  version: '0'
253
298
  requirements: []
254
299
  rubyforge_project:
255
- rubygems_version: 2.0.14
300
+ rubygems_version: 2.7.6
256
301
  signing_key:
257
302
  specification_version: 4
258
303
  summary: Module for the 'fog' gem to support 1and1.
@@ -1,60 +0,0 @@
1
- module Fog
2
- module Compute
3
- class OneAndOne
4
-
5
- class Real
6
-
7
- ##
8
- # Removes an IP from a firewall policy
9
- # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#firewall_policies__firewall_id__server_ips__server_ip__delete]
10
- ##
11
- def remove_firewall_ip(firewall_id: nil, ip_id: nil)
12
-
13
- params = {
14
- 'method' => :delete,
15
- 'endpoint' => "/firewall_policies/#{firewall_id}/server_ips/#{ip_id}"
16
- }
17
-
18
- request(params)
19
-
20
- end
21
-
22
- end # Real
23
-
24
-
25
- class Mock
26
-
27
- def remove_firewall_ip(firewall_id: nil, ip_id: nil)
28
-
29
- # Search for firewall
30
- if firewall = self.data[:firewalls].find {
31
- |hash| hash['id'] == firewall_id
32
- }
33
- else
34
- raise Fog::Errors::NotFound.new('The requested resource could
35
- not be found.')
36
- end
37
-
38
- # Search for server IP to destroy
39
- if ip = firewall['server_ips'].find {
40
- |index| index == ip_id
41
- }
42
- firewall['server_ips'].delete(ip)
43
- else
44
- raise Fog::Errors::NotFound.new('The requested server IP could
45
- not be found.')
46
- end
47
-
48
- # Return Response Object to User
49
- response = Excon::Response.new
50
- response.status = 202
51
- response.body = firewall
52
- response
53
-
54
- end
55
-
56
- end # Mock
57
-
58
- end # OneAndOne
59
- end # Compute
60
- end # Fog