fog-oneandone 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/CONTRIBUTING.md +276 -0
- data/CONTRIBUTORS.md +1 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +317 -0
- data/bin/fog +78 -0
- data/examples/example_app.rb +80 -0
- data/fog-oneandone.gemspec +22 -0
- data/gemfiles/Gemfile-edge +7 -0
- data/lib/fog-oneandone.rb +10 -0
- data/lib/oneandone/compute.rb +713 -0
- data/lib/oneandone/core.rb +11 -0
- data/lib/oneandone/models/compute/firewall.rb +128 -0
- data/lib/oneandone/models/compute/firewalls.rb +24 -0
- data/lib/oneandone/models/compute/image.rb +72 -0
- data/lib/oneandone/models/compute/images.rb +24 -0
- data/lib/oneandone/models/compute/load_balancer.rb +149 -0
- data/lib/oneandone/models/compute/load_balancers.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
- data/lib/oneandone/models/compute/private_network.rb +105 -0
- data/lib/oneandone/models/compute/private_networks.rb +24 -0
- data/lib/oneandone/models/compute/public_ip.rb +68 -0
- data/lib/oneandone/models/compute/public_ips.rb +24 -0
- data/lib/oneandone/models/compute/server.rb +434 -0
- data/lib/oneandone/models/compute/servers.rb +24 -0
- data/lib/oneandone/models/compute/shared_storage.rb +101 -0
- data/lib/oneandone/models/compute/shared_storages.rb +24 -0
- data/lib/oneandone/models/compute/vpn.rb +70 -0
- data/lib/oneandone/models/compute/vpns.rb +24 -0
- data/lib/oneandone/requests/compute/access.rb +35 -0
- data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
- data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
- data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
- data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
- data/lib/oneandone/requests/compute/add_ports.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
- data/lib/oneandone/requests/compute/add_processes.rb +65 -0
- data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
- data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
- data/lib/oneandone/requests/compute/change_password.rb +45 -0
- data/lib/oneandone/requests/compute/change_status.rb +69 -0
- data/lib/oneandone/requests/compute/clone_server.rb +67 -0
- data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
- data/lib/oneandone/requests/compute/create_image.rb +101 -0
- data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
- data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
- data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
- data/lib/oneandone/requests/compute/create_server.rb +139 -0
- data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
- data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
- data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
- data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
- data/lib/oneandone/requests/compute/delete_image.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
- data/lib/oneandone/requests/compute/delete_port.rb +60 -0
- data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
- data/lib/oneandone/requests/compute/delete_process.rb +60 -0
- data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
- data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
- data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
- data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
- data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
- data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
- data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
- data/lib/oneandone/requests/compute/get_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_log.rb +51 -0
- data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
- data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
- data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_port.rb +59 -0
- data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
- data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_process.rb +59 -0
- data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
- data/lib/oneandone/requests/compute/get_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
- data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
- data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
- data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
- data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
- data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
- data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
- data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
- data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
- data/lib/oneandone/requests/compute/list_images.rb +56 -0
- data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
- data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
- data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
- data/lib/oneandone/requests/compute/list_logs.rb +59 -0
- data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
- data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
- data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_ports.rb +51 -0
- data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
- data/lib/oneandone/requests/compute/list_processes.rb +51 -0
- data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
- data/lib/oneandone/requests/compute/list_servers.rb +56 -0
- data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
- data/lib/oneandone/requests/compute/list_usages.rb +54 -0
- data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
- data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
- data/lib/oneandone/requests/compute/ping.rb +38 -0
- data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
- data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
- data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
- data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
- data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
- data/lib/oneandone/requests/compute/status.rb +50 -0
- data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
- data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
- data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
- data/lib/oneandone/requests/compute/update_image.rb +80 -0
- data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
- data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
- data/lib/oneandone/requests/compute/update_port.rb +74 -0
- data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/update_process.rb +76 -0
- data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
- data/lib/oneandone/requests/compute/update_server.rb +76 -0
- data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
- data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
- data/tests/oneandone/test_firewalls.rb +188 -0
- data/tests/oneandone/test_images.rb +79 -0
- data/tests/oneandone/test_load_balancers.rb +192 -0
- data/tests/oneandone/test_monitoring_policies.rb +342 -0
- data/tests/oneandone/test_private_networks.rb +123 -0
- data/tests/oneandone/test_public_ips.rb +75 -0
- data/tests/oneandone/test_servers.rb +465 -0
- data/tests/oneandone/test_shared_storages.rb +131 -0
- metadata +259 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns "PONG" if API is running and your token is valid.
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#ping_auth_get]
|
10
|
+
##
|
11
|
+
def ping_auth
|
12
|
+
|
13
|
+
# Request
|
14
|
+
params = {
|
15
|
+
'method' => :get,
|
16
|
+
'endpoint' => '/ping_auth'
|
17
|
+
}
|
18
|
+
|
19
|
+
request(params)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end # Real
|
24
|
+
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
|
28
|
+
def ping_auth
|
29
|
+
|
30
|
+
Fog::Mock.not_implemented
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end # Mock
|
35
|
+
|
36
|
+
end # OneAndOne
|
37
|
+
end # Compute
|
38
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Remove a firewall policy from 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_delete]
|
10
|
+
##
|
11
|
+
def remove_firewall(server_id: nil, ip_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/servers/#{server_id}/ips/#{ip_id}/firewall_policy"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def remove_firewall(server_id: nil, ip_id: nil)
|
28
|
+
|
29
|
+
# Search for server
|
30
|
+
if server = self.data[:servers].find {
|
31
|
+
|hash| hash['id'] == server_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Search for IP to remove firewall from
|
39
|
+
if ip = server['ips'].find {
|
40
|
+
|index| index['id'] == ip_id
|
41
|
+
}
|
42
|
+
ip['firewall_policy'] = {}
|
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 = server
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
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
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Remove a load balancer from 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__load_balancer_id__delete]
|
10
|
+
##
|
11
|
+
def remove_load_balancer(server_id: nil, ip_id: nil,
|
12
|
+
load_balancer_id: nil)
|
13
|
+
|
14
|
+
params = {
|
15
|
+
'method' => :delete,
|
16
|
+
'endpoint' => "/servers/#{server_id}/ips/#{ip_id}/load_balancers/#{load_balancer_id}"
|
17
|
+
}
|
18
|
+
|
19
|
+
request(params)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end # Real
|
24
|
+
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
|
28
|
+
def remove_load_balancer(server_id: nil, ip_id: nil,
|
29
|
+
load_balancer_id: nil)
|
30
|
+
|
31
|
+
# Search for server
|
32
|
+
if server = self.data[:servers].find {
|
33
|
+
|hash| hash['id'] == server_id
|
34
|
+
}
|
35
|
+
else
|
36
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
37
|
+
not be found.')
|
38
|
+
end
|
39
|
+
|
40
|
+
# Search for IP
|
41
|
+
if ip = server['ips'].find {
|
42
|
+
|index| index['id'] == ip_id
|
43
|
+
}
|
44
|
+
else
|
45
|
+
raise Fog::Errors::NotFound.new('The requested server IP could
|
46
|
+
not be found.')
|
47
|
+
end
|
48
|
+
|
49
|
+
# Search for load balancer to destroy
|
50
|
+
if load_balancer = ip['load_balancers'].find {
|
51
|
+
|index| index['id'] == load_balancer_id
|
52
|
+
}
|
53
|
+
ip['load_balancers'].delete(load_balancer)
|
54
|
+
else
|
55
|
+
raise Fog::Errors::NotFound.new('The requested load balancer could
|
56
|
+
not be found.')
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return Response Object to User
|
60
|
+
response = Excon::Response.new
|
61
|
+
response.status = 202
|
62
|
+
response.body = server
|
63
|
+
response
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end # Mock
|
68
|
+
|
69
|
+
end # OneAndOne
|
70
|
+
end # Compute
|
71
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Removes an IP from a load balancer
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#load_balancers__load_balancer_id__server_ips__server_ip__delete]
|
10
|
+
##
|
11
|
+
def remove_load_balancer_ip(load_balancer_id: nil, ip_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/load_balancers/#{load_balancer_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_load_balancer_ip(load_balancer_id: nil, ip_id: nil)
|
28
|
+
|
29
|
+
# Search for load balancer
|
30
|
+
if load_balancer = self.data[:load_balancers].find {
|
31
|
+
|hash| hash['id'] == load_balancer_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 = load_balancer['server_ips'].find {
|
40
|
+
|index| index == ip_id
|
41
|
+
}
|
42
|
+
load_balancer['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 = load_balancer
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Removes a monitoring policy's server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__servers__server_id__delete]
|
10
|
+
##
|
11
|
+
def remove_mp_server(monitoring_policy_id: nil, server_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/servers/#{server_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def remove_mp_server(monitoring_policy_id: nil, server_id: nil)
|
28
|
+
|
29
|
+
# Search for MP
|
30
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
31
|
+
|hash| hash['id'] == monitoring_policy_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 to remove
|
39
|
+
if server = monitoring_policy['servers'].find {
|
40
|
+
|index| index == server_id
|
41
|
+
}
|
42
|
+
monitoring_policy['servers'].delete(server)
|
43
|
+
else
|
44
|
+
raise Fog::Errors::NotFound.new('The requested server 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 = monitoring_policy
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Remove a server from a private network
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__private_networks__private_network_id__delete]
|
10
|
+
##
|
11
|
+
def remove_private_network(server_id: nil, private_network_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/servers/#{server_id}/private_networks/#{private_network_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def remove_private_network(server_id: nil, private_network_id: nil)
|
28
|
+
|
29
|
+
# Search for server
|
30
|
+
if server = self.data[:servers].find {
|
31
|
+
|hash| hash['id'] == server_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Search for private network
|
39
|
+
if private_network = server['private_networks'].find {
|
40
|
+
|hash| hash['id'] == private_network_id
|
41
|
+
}
|
42
|
+
server['private_networks'].delete(private_network)
|
43
|
+
else
|
44
|
+
raise Fog::Errors::NotFound.new('The requested private network 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 = server
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Removes a private network's server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#private_networks__private_network_id__servers__server_id__delete]
|
10
|
+
##
|
11
|
+
def remove_private_network_server(private_network_id: nil, server_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/private_networks/#{private_network_id}/servers/#{server_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def remove_private_network_server(private_network_id: nil, server_id: nil)
|
28
|
+
|
29
|
+
# Search for private network
|
30
|
+
if private_network = self.data[:private_networks].find {
|
31
|
+
|hash| hash['id'] == private_network_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 to destroy
|
39
|
+
if server = private_network['servers'].find {
|
40
|
+
|index| index == server_id
|
41
|
+
}
|
42
|
+
private_network['servers'].delete(server)
|
43
|
+
else
|
44
|
+
raise Fog::Errors::NotFound.new('The requested server 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 = private_network
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Removes a server from a shared storage
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#shared_storages__shared_storage_id__servers__server_id__delete]
|
10
|
+
##
|
11
|
+
def remove_shared_storage_server(shared_storage_id: nil, server_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :delete,
|
15
|
+
'endpoint' => "/shared_storages/#{shared_storage_id}/servers/#{server_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def remove_shared_storage_server(shared_storage_id: nil, server_id: nil)
|
28
|
+
|
29
|
+
# Search for shared storage
|
30
|
+
if shared_storage = self.data[:shared_storages].find {
|
31
|
+
|hash| hash['id'] == shared_storage_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 to destroy
|
39
|
+
if server = shared_storage['servers'].find {
|
40
|
+
|index| index['id'] == server_id
|
41
|
+
}
|
42
|
+
shared_storage['servers'].delete(server)
|
43
|
+
else
|
44
|
+
raise Fog::Errors::NotFound.new('The requested server 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 = shared_storage
|
52
|
+
response
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end # Mock
|
57
|
+
|
58
|
+
end # OneAndOne
|
59
|
+
end # Compute
|
60
|
+
end # Fog
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Restore a snapshot into the server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__snapshots__snapshot_id__put]
|
10
|
+
##
|
11
|
+
def restore_snapshot(server_id: nil, snapshot_id: nil)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :put,
|
15
|
+
'endpoint' => "/servers/#{server_id}/snapshots/#{snapshot_id}"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def restore_snapshot(server_id: nil, snapshot_id: nil)
|
28
|
+
Fog::Mock.not_implemented
|
29
|
+
end
|
30
|
+
|
31
|
+
end # Mock
|
32
|
+
|
33
|
+
end # OneAndOne
|
34
|
+
end # Compute
|
35
|
+
end # Fog
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns information about a server's status
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__status_get]
|
10
|
+
##
|
11
|
+
def status(server_id)
|
12
|
+
|
13
|
+
params = {
|
14
|
+
'method' => :get,
|
15
|
+
'endpoint' => "/servers/#{server_id}/status"
|
16
|
+
}
|
17
|
+
|
18
|
+
request(params)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def status(server_id)
|
28
|
+
|
29
|
+
# Search for server
|
30
|
+
if server = self.data[:servers].find {
|
31
|
+
|hash| hash['id'] == server_id
|
32
|
+
}
|
33
|
+
else
|
34
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
35
|
+
not be found.')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return Response Object to User
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 200
|
41
|
+
response.body = server['status']
|
42
|
+
response
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Mock
|
47
|
+
|
48
|
+
end # OneAndOne
|
49
|
+
end # Compute
|
50
|
+
end # Fog
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Modify a firewall policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#firewall_policies__firewall_id__put]
|
10
|
+
##
|
11
|
+
def update_firewall(firewall_id: nil, name: nil, description: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_firewall = {
|
15
|
+
'name' => name,
|
16
|
+
'description' => description
|
17
|
+
}
|
18
|
+
|
19
|
+
# Clean out null keys in POST body
|
20
|
+
body = clean_hash(new_firewall)
|
21
|
+
|
22
|
+
# Stringify the POST body
|
23
|
+
string_body = Fog::JSON.encode(body)
|
24
|
+
|
25
|
+
# Request
|
26
|
+
params = {
|
27
|
+
'method' => :put,
|
28
|
+
'endpoint' => "/firewall_policies/#{firewall_id}",
|
29
|
+
'body' => string_body
|
30
|
+
}
|
31
|
+
|
32
|
+
request(params)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Real
|
37
|
+
|
38
|
+
|
39
|
+
class Mock
|
40
|
+
|
41
|
+
def update_firewall(firewall_id: nil, name: nil, description: nil)
|
42
|
+
|
43
|
+
# Search for firewall to update
|
44
|
+
if firewall = self.data[:firewalls].find {
|
45
|
+
|hash| hash['id'] == firewall_id
|
46
|
+
}
|
47
|
+
# Create parameter hash
|
48
|
+
params = {
|
49
|
+
'name' => name,
|
50
|
+
'description' => description
|
51
|
+
}
|
52
|
+
|
53
|
+
# Update the firewall we found with new values
|
54
|
+
params.each do |key, value|
|
55
|
+
if value
|
56
|
+
firewall[key] = value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise Fog::Errors::NotFound.new('The requested resource 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 = firewall
|
68
|
+
response
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end # Mock
|
73
|
+
|
74
|
+
end # OneAndOne
|
75
|
+
end # Compute
|
76
|
+
end # Fog
|