fog-oneandone 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/CONTRIBUTING.md +276 -0
  4. data/CONTRIBUTORS.md +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.md +20 -0
  7. data/README.md +317 -0
  8. data/bin/fog +78 -0
  9. data/examples/example_app.rb +80 -0
  10. data/fog-oneandone.gemspec +22 -0
  11. data/gemfiles/Gemfile-edge +7 -0
  12. data/lib/fog-oneandone.rb +10 -0
  13. data/lib/oneandone/compute.rb +713 -0
  14. data/lib/oneandone/core.rb +11 -0
  15. data/lib/oneandone/models/compute/firewall.rb +128 -0
  16. data/lib/oneandone/models/compute/firewalls.rb +24 -0
  17. data/lib/oneandone/models/compute/image.rb +72 -0
  18. data/lib/oneandone/models/compute/images.rb +24 -0
  19. data/lib/oneandone/models/compute/load_balancer.rb +149 -0
  20. data/lib/oneandone/models/compute/load_balancers.rb +24 -0
  21. data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
  22. data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
  23. data/lib/oneandone/models/compute/private_network.rb +105 -0
  24. data/lib/oneandone/models/compute/private_networks.rb +24 -0
  25. data/lib/oneandone/models/compute/public_ip.rb +68 -0
  26. data/lib/oneandone/models/compute/public_ips.rb +24 -0
  27. data/lib/oneandone/models/compute/server.rb +434 -0
  28. data/lib/oneandone/models/compute/servers.rb +24 -0
  29. data/lib/oneandone/models/compute/shared_storage.rb +101 -0
  30. data/lib/oneandone/models/compute/shared_storages.rb +24 -0
  31. data/lib/oneandone/models/compute/vpn.rb +70 -0
  32. data/lib/oneandone/models/compute/vpns.rb +24 -0
  33. data/lib/oneandone/requests/compute/access.rb +35 -0
  34. data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
  35. data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
  36. data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
  37. data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
  38. data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
  39. data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
  40. data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
  41. data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
  42. data/lib/oneandone/requests/compute/add_ports.rb +65 -0
  43. data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
  44. data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
  45. data/lib/oneandone/requests/compute/add_processes.rb +65 -0
  46. data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
  47. data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
  48. data/lib/oneandone/requests/compute/change_password.rb +45 -0
  49. data/lib/oneandone/requests/compute/change_status.rb +69 -0
  50. data/lib/oneandone/requests/compute/clone_server.rb +67 -0
  51. data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
  52. data/lib/oneandone/requests/compute/create_image.rb +101 -0
  53. data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
  54. data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
  55. data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
  56. data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
  57. data/lib/oneandone/requests/compute/create_server.rb +139 -0
  58. data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
  59. data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
  60. data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
  61. data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
  62. data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
  63. data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
  64. data/lib/oneandone/requests/compute/delete_image.rb +51 -0
  65. data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
  66. data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
  67. data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
  68. data/lib/oneandone/requests/compute/delete_port.rb +60 -0
  69. data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
  70. data/lib/oneandone/requests/compute/delete_process.rb +60 -0
  71. data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
  72. data/lib/oneandone/requests/compute/delete_server.rb +51 -0
  73. data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
  74. data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
  75. data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
  76. data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
  77. data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
  78. data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
  79. data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
  80. data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
  81. data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
  82. data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
  83. data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
  84. data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
  85. data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
  86. data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
  87. data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
  88. data/lib/oneandone/requests/compute/get_image.rb +50 -0
  89. data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
  90. data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
  91. data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
  92. data/lib/oneandone/requests/compute/get_log.rb +51 -0
  93. data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
  94. data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
  95. data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
  96. data/lib/oneandone/requests/compute/get_port.rb +59 -0
  97. data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
  98. data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
  99. data/lib/oneandone/requests/compute/get_process.rb +59 -0
  100. data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
  101. data/lib/oneandone/requests/compute/get_server.rb +50 -0
  102. data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
  103. data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
  104. data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
  105. data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
  106. data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
  107. data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
  108. data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
  109. data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
  110. data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
  111. data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
  112. data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
  113. data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
  114. data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
  115. data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
  116. data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
  117. data/lib/oneandone/requests/compute/list_images.rb +56 -0
  118. data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
  119. data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
  120. data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
  121. data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
  122. data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
  123. data/lib/oneandone/requests/compute/list_logs.rb +59 -0
  124. data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
  125. data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
  126. data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
  127. data/lib/oneandone/requests/compute/list_ports.rb +51 -0
  128. data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
  129. data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
  130. data/lib/oneandone/requests/compute/list_processes.rb +51 -0
  131. data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
  132. data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
  133. data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
  134. data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
  135. data/lib/oneandone/requests/compute/list_servers.rb +56 -0
  136. data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
  137. data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
  138. data/lib/oneandone/requests/compute/list_usages.rb +54 -0
  139. data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
  140. data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
  141. data/lib/oneandone/requests/compute/ping.rb +38 -0
  142. data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
  143. data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
  144. data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
  145. data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
  146. data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
  147. data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
  148. data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
  149. data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
  150. data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
  151. data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
  152. data/lib/oneandone/requests/compute/status.rb +50 -0
  153. data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
  154. data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
  155. data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
  156. data/lib/oneandone/requests/compute/update_image.rb +80 -0
  157. data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
  158. data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
  159. data/lib/oneandone/requests/compute/update_port.rb +74 -0
  160. data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
  161. data/lib/oneandone/requests/compute/update_process.rb +76 -0
  162. data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
  163. data/lib/oneandone/requests/compute/update_server.rb +76 -0
  164. data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
  165. data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
  166. data/tests/oneandone/test_firewalls.rb +188 -0
  167. data/tests/oneandone/test_images.rb +79 -0
  168. data/tests/oneandone/test_load_balancers.rb +192 -0
  169. data/tests/oneandone/test_monitoring_policies.rb +342 -0
  170. data/tests/oneandone/test_private_networks.rb +123 -0
  171. data/tests/oneandone/test_public_ips.rb +75 -0
  172. data/tests/oneandone/test_servers.rb +465 -0
  173. data/tests/oneandone/test_shared_storages.rb +131 -0
  174. metadata +259 -0
@@ -0,0 +1,101 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+ class SharedStorage < Fog::Model
5
+
6
+ # Declare Model Attributes
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :description
11
+ attribute :size
12
+ attribute :datacenter_id
13
+ attribute :state
14
+ attribute :datacenter
15
+ attribute :creation_date
16
+ attribute :servers
17
+
18
+
19
+ def save
20
+
21
+ requires :name, :size
22
+
23
+ # Perform Request
24
+ response = service.create_shared_storage(name: name, size: size,
25
+ description: description, datacenter_id: datacenter_id)
26
+
27
+ # Merge Attributes
28
+ merge_attributes(response.body)
29
+
30
+ true
31
+
32
+ end
33
+
34
+
35
+ def update(options = {})
36
+
37
+ requires :id
38
+
39
+ response = service.update_shared_storage(shared_storage_id: id,
40
+ name: options[:name], description: options[:description],
41
+ size: options[:size])
42
+
43
+ # Merge Attributes
44
+ merge_attributes(response.body)
45
+
46
+ true
47
+
48
+ end
49
+
50
+
51
+ def add_servers(options = {})
52
+
53
+ requires :id
54
+
55
+ response = service.add_shared_storage_servers(shared_storage_id: id,
56
+ servers: options[:servers])
57
+
58
+ # Merge Attributes
59
+ merge_attributes(response.body)
60
+
61
+ true
62
+
63
+ end
64
+
65
+
66
+ def remove_server(options = {})
67
+
68
+ requires :id
69
+
70
+ response = service.remove_shared_storage_server(shared_storage_id: id,
71
+ server_id: options[:server_id])
72
+
73
+ # Merge Attributes
74
+ merge_attributes(response.body)
75
+
76
+ true
77
+
78
+ end
79
+
80
+
81
+ def destroy
82
+
83
+ requires :id
84
+
85
+ service.delete_shared_storage(id)
86
+
87
+ true
88
+
89
+ end
90
+
91
+
92
+ def ready?
93
+
94
+ state == 'ACTIVE'
95
+
96
+ end
97
+
98
+ end # SharedStorage
99
+ end # OneAndOne
100
+ end # Compute
101
+ end # Fog
@@ -0,0 +1,24 @@
1
+ require_relative 'shared_storage'
2
+
3
+ module Fog
4
+ module Compute
5
+ class OneAndOne
6
+ class SharedStorages < Fog::Collection
7
+ model Fog::Compute::OneAndOne::SharedStorage
8
+
9
+ def all
10
+ response = service.list_shared_storages
11
+ load(response.body)
12
+ end
13
+
14
+ def get(id)
15
+ response = service.get_shared_storage(id)
16
+ new(response.body)
17
+ rescue Excon::Errors::NotFound
18
+ nil
19
+ end
20
+
21
+ end # SharedStorages
22
+ end # OneAndOne
23
+ end # Compute
24
+ end # Fog
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+ class Vpn < Fog::Model
5
+
6
+ # Declare Model Attributes
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :description
11
+ attribute :datacenter
12
+ attribute :datacenter_id
13
+ attribute :state
14
+ attribute :type
15
+ attribute :ips
16
+ attribute :creation_date
17
+
18
+
19
+ def save
20
+
21
+ requires :name
22
+
23
+ # Perform Request
24
+ response = service.create_vpn(name: name, description: description,
25
+ datacenter_id: datacenter_id)
26
+
27
+ # Merge Attributes
28
+ merge_attributes(response.body)
29
+
30
+ true
31
+
32
+ end
33
+
34
+
35
+ def update(options = {})
36
+
37
+ requires :id
38
+
39
+ response = service.update_vpn(vpn_id: id, name: options[:name],
40
+ description: options[:description])
41
+
42
+ # Merge Attributes
43
+ merge_attributes(response.body)
44
+
45
+ true
46
+
47
+ end
48
+
49
+
50
+ def destroy
51
+
52
+ requires :id
53
+
54
+ service.delete_vpn(id)
55
+
56
+ true
57
+
58
+ end
59
+
60
+
61
+ def ready?
62
+
63
+ state == 'ACTIVE'
64
+
65
+ end
66
+
67
+ end # Vpn
68
+ end # OneAndOne
69
+ end # Compute
70
+ end # Fog
@@ -0,0 +1,24 @@
1
+ require_relative 'vpn'
2
+
3
+ module Fog
4
+ module Compute
5
+ class OneAndOne
6
+ class Vpns < Fog::Collection
7
+ model Fog::Compute::OneAndOne::Vpn
8
+
9
+ def all
10
+ response = service.list_vpns
11
+ load(response.body)
12
+ end
13
+
14
+ def get(id)
15
+ response = service.get_vpn(id)
16
+ new(response.body)
17
+ rescue Excon::Errors::NotFound
18
+ nil
19
+ end
20
+
21
+ end # Vpns
22
+ end # OneAndOne
23
+ end # Compute
24
+ end # Fog
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Returns the credentials for accessing the shared storages
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#shared_storages_access_get]
10
+ ##
11
+ def access
12
+
13
+ params = {
14
+ 'method' => :get,
15
+ 'endpoint' => '/shared_storages/access'
16
+ }
17
+
18
+ request(params)
19
+
20
+ end
21
+
22
+ end # Real
23
+
24
+
25
+ class Mock
26
+
27
+ def access
28
+ Fog::Mock.not_implemented
29
+ end
30
+
31
+ end # Mock
32
+
33
+ end # OneAndOne
34
+ end # Compute
35
+ end # Fog
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add a firewall policy to a server's IP
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__ips__ip_id__firewall_policy_put]
10
+ ##
11
+ def add_firewall(server_id: nil, ip_id: nil, firewall_id: nil)
12
+
13
+ # Build PUT body
14
+ firewall_specs = {
15
+ 'id' => firewall_id
16
+ }
17
+
18
+ # Stringify the PUT body
19
+ string_body = Fog::JSON.encode(firewall_specs)
20
+
21
+ # Request
22
+ params = {
23
+ 'method' => :put,
24
+ 'endpoint' => "/servers/#{server_id}/ips/#{ip_id}/firewall_policy",
25
+ 'body' => string_body
26
+ }
27
+
28
+ request(params)
29
+
30
+ end
31
+
32
+ end # Real
33
+
34
+
35
+ class Mock
36
+
37
+ def add_firewall(server_id: nil, ip_id: nil, firewall_id: nil)
38
+
39
+ # Search for server
40
+ if server = self.data[:servers].find {
41
+ |hash| hash['id'] == server_id
42
+ }
43
+ else
44
+ raise Fog::Errors::NotFound.new('The requested resource could
45
+ not be found.')
46
+ end
47
+
48
+ # Search for IP to return
49
+ if ip = server['ips'].find {
50
+ |index| index['id'] == ip_id
51
+ }
52
+ ip['firewall_policy']['id'] = firewall_id
53
+ else
54
+ raise Fog::Errors::NotFound.new('The requested server IP could
55
+ not be found.')
56
+ end
57
+
58
+ # Return Response Object to User
59
+ response = Excon::Response.new
60
+ response.status = 202
61
+ response.body = server
62
+ response
63
+
64
+ end
65
+
66
+ end # Mock
67
+
68
+ end # OneAndOne
69
+ end # Compute
70
+ end # Fog
@@ -0,0 +1,67 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add IPs to a firewall policy
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#firewall_policies__firewall_id__server_ips_post]
10
+ ##
11
+ def add_firewall_ips(firewall_id: nil, ips: nil)
12
+
13
+ # Build POST body
14
+ new_ips = {
15
+ 'server_ips' => ips
16
+ }
17
+
18
+ # Clean out null keys in POST body
19
+ body = clean_hash(new_ips)
20
+
21
+ # Stringify the POST body
22
+ string_body = Fog::JSON.encode(body)
23
+
24
+ # Request
25
+ params = {
26
+ 'method' => :post,
27
+ 'endpoint' => "/firewall_policies/#{firewall_id}/server_ips",
28
+ 'body' => string_body
29
+ }
30
+
31
+ request(params)
32
+
33
+ end
34
+
35
+ end # Real
36
+
37
+
38
+ class Mock
39
+
40
+ def add_firewall_ips(firewall_id: nil, ips: nil)
41
+
42
+ # Search for firewall to return
43
+ if firewall = self.data[:firewalls].find {
44
+ |hash| hash['id'] == firewall_id
45
+ }
46
+ # Add server IPs
47
+ ips.each do |ip|
48
+ firewall['server_ips'] << ip
49
+ end
50
+ else
51
+ raise Fog::Errors::NotFound.new('The requested resource could
52
+ not be found.')
53
+ end
54
+
55
+ # Return Response Object to User
56
+ response = Excon::Response.new
57
+ response.status = 202
58
+ response.body = firewall
59
+ response
60
+
61
+ end
62
+
63
+ end # Mock
64
+
65
+ end # OneAndOne
66
+ end # Compute
67
+ end # Fog
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add new rules to a firewall policy
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#firewall_policies__firewall_id__rules_post]
10
+ ##
11
+ def add_firewall_rules(firewall_id: nil, rules: nil)
12
+
13
+ # Build POST body
14
+ new_rules = {
15
+ 'rules' => rules
16
+ }
17
+
18
+ # Clean out null keys in POST body
19
+ body = clean_hash(new_rules)
20
+
21
+ # Stringify the POST body
22
+ string_body = Fog::JSON.encode(body)
23
+
24
+ # Request
25
+ params = {
26
+ 'method' => :post,
27
+ 'endpoint' => "/firewall_policies/#{firewall_id}/rules",
28
+ 'body' => string_body
29
+ }
30
+
31
+ request(params)
32
+
33
+ end
34
+
35
+ end # Real
36
+
37
+
38
+ class Mock
39
+
40
+ def add_firewall_rules(firewall_id: nil, rules: nil)
41
+
42
+ # Search for firewall to return
43
+ if firewall = self.data[:firewalls].find {
44
+ |hash| hash['id'] == firewall_id
45
+ }
46
+ # Add rules
47
+ rules.each do |rule|
48
+ rule['id'] = Fog::UUID.uuid
49
+ firewall['rules'] << rule
50
+ end
51
+ else
52
+ raise Fog::Errors::NotFound.new('The requested resource could
53
+ not be found.')
54
+ end
55
+
56
+ # Return Response Object to User
57
+ response = Excon::Response.new
58
+ response.status = 202
59
+ response.body = firewall
60
+ response
61
+
62
+ end
63
+
64
+ end # Mock
65
+
66
+ end # OneAndOne
67
+ end # Compute
68
+ end # Fog
@@ -0,0 +1,65 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add new HDD's to a server
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__hardware_hdds_post]
10
+ ##
11
+ def add_hdds(server_id: nil, hdds: nil)
12
+
13
+ # Build POST body
14
+ new_hdds = {
15
+ 'hdds' => hdds
16
+ }
17
+
18
+ # Stringify the POST body
19
+ string_body = Fog::JSON.encode(new_hdds)
20
+
21
+ # Request
22
+ params = {
23
+ 'method' => :post,
24
+ 'endpoint' => "/servers/#{server_id}/hardware/hdds",
25
+ 'body' => string_body
26
+ }
27
+
28
+ request(params)
29
+
30
+ end
31
+
32
+ end # Real
33
+
34
+
35
+ class Mock
36
+
37
+ def add_hdds(server_id: nil, hdds: nil)
38
+
39
+ # Search for server to return
40
+ if server = self.data[:servers].find {
41
+ |hash| hash['id'] == server_id
42
+ }
43
+ # Add hdds
44
+ hdds.each do |hdd|
45
+ hdd['id'] = Fog::UUID.uuid
46
+ server['hardware']['hdds'] << hdd
47
+ end
48
+ else
49
+ raise Fog::Errors::NotFound.new('The requested resource could
50
+ not be found.')
51
+ end
52
+
53
+ # Return Response Object to User
54
+ response = Excon::Response.new
55
+ response.status = 202
56
+ response.body = server
57
+ response
58
+
59
+ end
60
+
61
+ end # Mock
62
+
63
+ end # OneAndOne
64
+ end # Compute
65
+ end # Fog
@@ -0,0 +1,76 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add a load balancer to a server's IP
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__ips__ip_id__load_balancers_post]
10
+ ##
11
+ def add_load_balancer(server_id: nil, ip_id: nil,
12
+ load_balancer_id: nil)
13
+
14
+ # Build POST body
15
+ load_balancer_specs = {
16
+ 'load_balancer_id' => load_balancer_id
17
+ }
18
+
19
+ # Stringify the POST body
20
+ string_body = Fog::JSON.encode(load_balancer_specs)
21
+
22
+ # Request
23
+ params = {
24
+ 'method' => :post,
25
+ 'endpoint' => "/servers/#{server_id}/ips/#{ip_id}/load_balancers",
26
+ 'body' => string_body
27
+ }
28
+
29
+ request(params)
30
+
31
+ end
32
+
33
+ end # Real
34
+
35
+
36
+ class Mock
37
+
38
+ def add_load_balancer(server_id: nil, ip_id: nil,
39
+ load_balancer_id: nil)
40
+
41
+ # Search for server
42
+ if server = self.data[:servers].find {
43
+ |hash| hash['id'] == server_id
44
+ }
45
+ else
46
+ raise Fog::Errors::NotFound.new('The requested resource could
47
+ not be found.')
48
+ end
49
+
50
+ # Search for IP to return
51
+ if ip = server['ips'].find {
52
+ |index| index['id'] == ip_id
53
+ }
54
+ load_balancer = {
55
+ 'id' => load_balancer_id
56
+ }
57
+
58
+ ip['load_balancers'] << load_balancer
59
+ else
60
+ raise Fog::Errors::NotFound.new('The requested server IP could
61
+ not be found.')
62
+ end
63
+
64
+ # Return Response Object to User
65
+ response = Excon::Response.new
66
+ response.status = 202
67
+ response.body = server
68
+ response
69
+
70
+ end
71
+
72
+ end # Mock
73
+
74
+ end # OneAndOne
75
+ end # Compute
76
+ end # Fog
@@ -0,0 +1,67 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+
5
+ class Real
6
+
7
+ ##
8
+ # Add IPs to a load balancer
9
+ # URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#load_balancers__load_balancer_id__server_ips_post]
10
+ ##
11
+ def add_load_balancer_ips(load_balancer_id: nil, ips: nil)
12
+
13
+ # Build POST body
14
+ new_ips = {
15
+ 'server_ips' => ips
16
+ }
17
+
18
+ # Clean out null keys in POST body
19
+ body = clean_hash(new_ips)
20
+
21
+ # Stringify the POST body
22
+ string_body = Fog::JSON.encode(body)
23
+
24
+ # Request
25
+ params = {
26
+ 'method' => :post,
27
+ 'endpoint' => "/load_balancers/#{load_balancer_id}/server_ips",
28
+ 'body' => string_body
29
+ }
30
+
31
+ request(params)
32
+
33
+ end
34
+
35
+ end # Real
36
+
37
+
38
+ class Mock
39
+
40
+ def add_load_balancer_ips(load_balancer_id: nil, ips: nil)
41
+
42
+ # Search for load balancer to return
43
+ if load_balancer = self.data[:load_balancers].find {
44
+ |hash| hash['id'] == load_balancer_id
45
+ }
46
+ # Add server IPs
47
+ ips.each do |ip|
48
+ load_balancer['server_ips'] << ip
49
+ end
50
+ else
51
+ raise Fog::Errors::NotFound.new('The requested resource could
52
+ not be found.')
53
+ end
54
+
55
+ # Return Response Object to User
56
+ response = Excon::Response.new
57
+ response.status = 202
58
+ response.body = load_balancer
59
+ response
60
+
61
+ end
62
+
63
+ end # Mock
64
+
65
+ end # OneAndOne
66
+ end # Compute
67
+ end # Fog