fog-oneandone 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,82 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Returns information about a server's current hardware configurations
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__hardware_get]
|
|
10
|
+
##
|
|
11
|
+
def update_hardware(server_id: nil, fixed_instance_id: nil, vcore: nil,
|
|
12
|
+
cores_per_processor: nil, ram: nil)
|
|
13
|
+
|
|
14
|
+
# Build PUT body
|
|
15
|
+
hardware_specs = {
|
|
16
|
+
'fixed_instance_size_id' => fixed_instance_id,
|
|
17
|
+
'vcore' => vcore,
|
|
18
|
+
'cores_per_processor' => cores_per_processor,
|
|
19
|
+
'ram' => ram
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Clean out null keys in PUT body
|
|
23
|
+
body = clean_hash(hardware_specs)
|
|
24
|
+
|
|
25
|
+
# Stringify the PUT body
|
|
26
|
+
string_body = Fog::JSON.encode(body)
|
|
27
|
+
|
|
28
|
+
# Request
|
|
29
|
+
params = {
|
|
30
|
+
'method' => :put,
|
|
31
|
+
'endpoint' => "/servers/#{server_id}/hardware",
|
|
32
|
+
'body' => string_body
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
request(params)
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end # Real
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Mock
|
|
43
|
+
|
|
44
|
+
def update_hardware(server_id: nil, fixed_instance_id: nil, vcore: nil,
|
|
45
|
+
cores_per_processor: nil, ram: nil)
|
|
46
|
+
|
|
47
|
+
# Search for server to update
|
|
48
|
+
if server = self.data[:servers].find {
|
|
49
|
+
|hash| hash['id'] == server_id
|
|
50
|
+
}
|
|
51
|
+
# Create parameter hash
|
|
52
|
+
params = {
|
|
53
|
+
'fixed_instance_id' => fixed_instance_id,
|
|
54
|
+
'vcore' => vcore,
|
|
55
|
+
'cores_per_processor' => cores_per_processor,
|
|
56
|
+
'ram' => ram
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Update the server hardware with new values
|
|
60
|
+
params.each do |key, value|
|
|
61
|
+
if value
|
|
62
|
+
server['hardware'][key] = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
67
|
+
not be found.')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Return Response Object to User
|
|
71
|
+
response = Excon::Response.new
|
|
72
|
+
response.status = 202
|
|
73
|
+
response.body = server
|
|
74
|
+
response
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end # Mock
|
|
79
|
+
|
|
80
|
+
end # OneAndOne
|
|
81
|
+
end # Compute
|
|
82
|
+
end # Fog
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Resize a server's HDD
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__hardware_hdds__hdd_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_hdd(server_id: nil, hdd_id: nil, size: nil)
|
|
12
|
+
|
|
13
|
+
# Build PUT body
|
|
14
|
+
hdd_specs = {
|
|
15
|
+
'size' => size
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# Stringify the PUT body
|
|
19
|
+
string_body = Fog::JSON.encode(hdd_specs)
|
|
20
|
+
|
|
21
|
+
# Request
|
|
22
|
+
params = {
|
|
23
|
+
'method' => :put,
|
|
24
|
+
'endpoint' => "/servers/#{server_id}/hardware/hdds/#{hdd_id}",
|
|
25
|
+
'body' => string_body
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(params)
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end # Real
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Mock
|
|
36
|
+
|
|
37
|
+
def update_hdd(server_id: nil, hdd_id: nil, size: nil)
|
|
38
|
+
|
|
39
|
+
# Search for server to update
|
|
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 server's hdd to update
|
|
49
|
+
if hdd = server['hardware']['hdds'].find {
|
|
50
|
+
|hash| hash['id'] == hdd_id
|
|
51
|
+
}
|
|
52
|
+
# Update the server hdd with new values
|
|
53
|
+
hdd['size'] = size
|
|
54
|
+
else
|
|
55
|
+
raise Fog::Errors::NotFound.new('The requested HDD 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,80 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify an image
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#images__image_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_image(image_id: nil, name: nil, description: nil,
|
|
12
|
+
frequency: nil)
|
|
13
|
+
|
|
14
|
+
# Build PUT body
|
|
15
|
+
new_image = {
|
|
16
|
+
'name' => name,
|
|
17
|
+
'description' => description,
|
|
18
|
+
'frequency' => frequency
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Clean out null values from PUT body
|
|
22
|
+
body = clean_hash(new_image)
|
|
23
|
+
|
|
24
|
+
# Stringify the PUT body
|
|
25
|
+
string_body = Fog::JSON.encode(body)
|
|
26
|
+
|
|
27
|
+
# Request
|
|
28
|
+
params = {
|
|
29
|
+
'method' => :put,
|
|
30
|
+
'endpoint' => "/images/#{image_id}",
|
|
31
|
+
'body' => string_body
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
request(params)
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end # Real
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Mock
|
|
42
|
+
|
|
43
|
+
def update_image(image_id: nil, name: nil, description: nil,
|
|
44
|
+
frequency: nil)
|
|
45
|
+
|
|
46
|
+
# Search for image to update
|
|
47
|
+
if image = self.data[:images].find {
|
|
48
|
+
|hash| hash['id'] == image_id
|
|
49
|
+
}
|
|
50
|
+
# Create parameter hash
|
|
51
|
+
params = {
|
|
52
|
+
'name' => name,
|
|
53
|
+
'description' => description,
|
|
54
|
+
'frequency' => frequency
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Update the image we found with new values
|
|
58
|
+
params.each do |key, value|
|
|
59
|
+
if value
|
|
60
|
+
image[key] = value
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
65
|
+
not be found.')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Return Response Object to User
|
|
69
|
+
response = Excon::Response.new
|
|
70
|
+
response.status = 202
|
|
71
|
+
response.body = image
|
|
72
|
+
response
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end # Mock
|
|
77
|
+
|
|
78
|
+
end # OneAndOne
|
|
79
|
+
end # Compute
|
|
80
|
+
end # Fog
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify a load balancer
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#load_balancers__load_balancer_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_load_balancer(load_balancer_id: nil, name: nil,
|
|
12
|
+
description: nil, health_check_test: nil, health_check_interval: nil,
|
|
13
|
+
persistence: nil, persistence_time: nil, method: nil,
|
|
14
|
+
health_check_path: nil, health_check_parse: nil)
|
|
15
|
+
|
|
16
|
+
# Build PUT body
|
|
17
|
+
new_load_balancer = {
|
|
18
|
+
'name' => name,
|
|
19
|
+
'description' => description,
|
|
20
|
+
'health_check_test' => health_check_test,
|
|
21
|
+
'health_check_interval' => health_check_interval,
|
|
22
|
+
'persistence' => persistence,
|
|
23
|
+
'persistence_time' => persistence_time,
|
|
24
|
+
'method' => method,
|
|
25
|
+
'health_check_path' => health_check_path,
|
|
26
|
+
'health_check_parse' => health_check_parse
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Clean out null keys in PUT body
|
|
30
|
+
body = clean_hash(new_load_balancer)
|
|
31
|
+
|
|
32
|
+
# Stringify the POST body
|
|
33
|
+
string_body = Fog::JSON.encode(body)
|
|
34
|
+
|
|
35
|
+
# Request
|
|
36
|
+
params = {
|
|
37
|
+
'method' => :put,
|
|
38
|
+
'endpoint' => "/load_balancers/#{load_balancer_id}",
|
|
39
|
+
'body' => string_body
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
request(params)
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end # Real
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Mock
|
|
50
|
+
|
|
51
|
+
def update_load_balancer(load_balancer_id: nil, name: nil,
|
|
52
|
+
description: nil, health_check_test: nil, health_check_interval: nil,
|
|
53
|
+
persistence: nil, persistence_time: nil, method: nil,
|
|
54
|
+
health_check_path: nil, health_check_parse: nil)
|
|
55
|
+
|
|
56
|
+
# Search for load balancer to update
|
|
57
|
+
if load_balancer = self.data[:load_balancers].find {
|
|
58
|
+
|hash| hash['id'] == load_balancer_id
|
|
59
|
+
}
|
|
60
|
+
# Create parameter hash
|
|
61
|
+
params = {
|
|
62
|
+
'name' => name,
|
|
63
|
+
'description' => description,
|
|
64
|
+
'health_check_test' => health_check_test,
|
|
65
|
+
'health_check_interval' => health_check_interval,
|
|
66
|
+
'persistence' => persistence,
|
|
67
|
+
'persistence_time' => persistence_time,
|
|
68
|
+
'method' => method,
|
|
69
|
+
'health_check_path' => health_check_path,
|
|
70
|
+
'health_check_parse' => health_check_parse
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Update the load balancer we found with new values
|
|
74
|
+
params.each do |key, value|
|
|
75
|
+
if value
|
|
76
|
+
load_balancer[key] = value
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
else
|
|
80
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
81
|
+
not be found.')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Return Response Object to User
|
|
85
|
+
response = Excon::Response.new
|
|
86
|
+
response.status = 202
|
|
87
|
+
response.body = load_balancer
|
|
88
|
+
response
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end # Mock
|
|
93
|
+
|
|
94
|
+
end # OneAndOne
|
|
95
|
+
end # Compute
|
|
96
|
+
end # Fog
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify a monitoring policy
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_monitoring_policy(monitoring_policy_id: nil, name: nil,
|
|
12
|
+
description: nil, email: nil, thresholds: nil)
|
|
13
|
+
|
|
14
|
+
# Build PUT body
|
|
15
|
+
modified_mp = {
|
|
16
|
+
'name' => name,
|
|
17
|
+
'description' => description,
|
|
18
|
+
'email' => email,
|
|
19
|
+
'thresholds' => thresholds
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Clean out null keys in PUT body
|
|
23
|
+
body = clean_hash(modified_mp)
|
|
24
|
+
|
|
25
|
+
# Stringify the PUT body
|
|
26
|
+
string_body = Fog::JSON.encode(body)
|
|
27
|
+
|
|
28
|
+
# Request
|
|
29
|
+
params = {
|
|
30
|
+
'method' => :put,
|
|
31
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}",
|
|
32
|
+
'body' => string_body
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
request(params)
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end # Real
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Mock
|
|
43
|
+
|
|
44
|
+
def update_monitoring_policy(monitoring_policy_id: nil, name: nil,
|
|
45
|
+
description: nil, email: nil, thresholds: nil)
|
|
46
|
+
|
|
47
|
+
# Search for MP to update
|
|
48
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
|
49
|
+
|hash| hash['id'] == monitoring_policy_id
|
|
50
|
+
}
|
|
51
|
+
# Create parameter hash
|
|
52
|
+
params = {
|
|
53
|
+
'name' => name,
|
|
54
|
+
'description' => description,
|
|
55
|
+
'email' => email,
|
|
56
|
+
'thresholds' => thresholds
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Update the MP we found with new values
|
|
60
|
+
params.each do |key, value|
|
|
61
|
+
if value
|
|
62
|
+
monitoring_policy[key] = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
67
|
+
not be found.')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Return Response Object to User
|
|
71
|
+
response = Excon::Response.new
|
|
72
|
+
response.status = 202
|
|
73
|
+
response.body = monitoring_policy
|
|
74
|
+
response
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end # Mock
|
|
79
|
+
|
|
80
|
+
end # OneAndOne
|
|
81
|
+
end # Compute
|
|
82
|
+
end # Fog
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify a monitoring policy's port
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__ports__port_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_port(monitoring_policy_id: nil, port_id: nil, new_port: nil)
|
|
12
|
+
|
|
13
|
+
# Build PUT body
|
|
14
|
+
modified_port = {
|
|
15
|
+
'ports' => new_port
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# Stringify the PUT body
|
|
19
|
+
string_body = Fog::JSON.encode(modified_port)
|
|
20
|
+
|
|
21
|
+
# Request
|
|
22
|
+
params = {
|
|
23
|
+
'method' => :put,
|
|
24
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/ports/#{port_id}",
|
|
25
|
+
'body' => string_body
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(params)
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end # Real
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Mock
|
|
36
|
+
|
|
37
|
+
def update_port(monitoring_policy_id: nil, port_id: nil, new_port: nil)
|
|
38
|
+
|
|
39
|
+
# Search for MP
|
|
40
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
|
41
|
+
|hash| hash['id'] == monitoring_policy_id
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
45
|
+
not be found.')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Search for port to update
|
|
49
|
+
if port = monitoring_policy['ports'].find {
|
|
50
|
+
|index| index['id'] == port_id
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Update the port with new values
|
|
54
|
+
new_port.each do |key, value|
|
|
55
|
+
port[key] = value
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
raise Fog::Errors::NotFound.new('The requested port could
|
|
59
|
+
not be found.')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Return Response Object to User
|
|
63
|
+
response = Excon::Response.new
|
|
64
|
+
response.status = 202
|
|
65
|
+
response.body = monitoring_policy
|
|
66
|
+
response
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end # Mock
|
|
71
|
+
|
|
72
|
+
end # OneAndOne
|
|
73
|
+
end # Compute
|
|
74
|
+
end # Fog
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify a private network
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#private_networks__private_network_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_private_network(private_network_id: nil, name: nil,
|
|
12
|
+
description: nil, network_address: nil, subnet_mask: nil)
|
|
13
|
+
|
|
14
|
+
# Build PUT body
|
|
15
|
+
new_private_network = {
|
|
16
|
+
'name' => name,
|
|
17
|
+
'description' => description,
|
|
18
|
+
'network_address' => network_address,
|
|
19
|
+
'subnet_mask' => subnet_mask
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Clean out null keys in PUT body
|
|
23
|
+
body = clean_hash(new_private_network)
|
|
24
|
+
|
|
25
|
+
# Stringify the PUT body
|
|
26
|
+
string_body = Fog::JSON.encode(body)
|
|
27
|
+
|
|
28
|
+
# Request
|
|
29
|
+
params = {
|
|
30
|
+
'method' => :put,
|
|
31
|
+
'endpoint' => "/private_networks/#{private_network_id}",
|
|
32
|
+
'body' => string_body
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
request(params)
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end # Real
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Mock
|
|
43
|
+
|
|
44
|
+
def update_private_network(private_network_id: nil, name: nil,
|
|
45
|
+
description: nil, network_address: nil, subnet_mask: nil)
|
|
46
|
+
|
|
47
|
+
# Search for private network to update
|
|
48
|
+
if private_network = self.data[:private_networks].find {
|
|
49
|
+
|hash| hash['id'] == private_network_id
|
|
50
|
+
}
|
|
51
|
+
# Create parameter hash
|
|
52
|
+
params = {
|
|
53
|
+
'name' => name,
|
|
54
|
+
'description' => description,
|
|
55
|
+
'network_address' => network_address,
|
|
56
|
+
'subnet_mask' => subnet_mask,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Update the private network we found with new values
|
|
60
|
+
params.each do |key, value|
|
|
61
|
+
if value
|
|
62
|
+
private_network[key] = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
67
|
+
not be found.')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Return Response Object to User
|
|
71
|
+
response = Excon::Response.new
|
|
72
|
+
response.status = 202
|
|
73
|
+
response.body = private_network
|
|
74
|
+
response
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end # Mock
|
|
79
|
+
|
|
80
|
+
end # OneAndOne
|
|
81
|
+
end # Compute
|
|
82
|
+
end # Fog
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class OneAndOne
|
|
4
|
+
|
|
5
|
+
class Real
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Modify a monitoring policy's process
|
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__processes__process_id__put]
|
|
10
|
+
##
|
|
11
|
+
def update_process(monitoring_policy_id: nil, process_id: nil,
|
|
12
|
+
new_process: nil)
|
|
13
|
+
|
|
14
|
+
# Build PUT body
|
|
15
|
+
modified_process = {
|
|
16
|
+
'processes' => new_process
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Stringify the PUT body
|
|
20
|
+
string_body = Fog::JSON.encode(modified_process)
|
|
21
|
+
|
|
22
|
+
# Request
|
|
23
|
+
params = {
|
|
24
|
+
'method' => :put,
|
|
25
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/processes/#{process_id}",
|
|
26
|
+
'body' => string_body
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
request(params)
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end # Real
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Mock
|
|
37
|
+
|
|
38
|
+
def update_process(monitoring_policy_id: nil, process_id: nil,
|
|
39
|
+
new_process: nil)
|
|
40
|
+
|
|
41
|
+
# Search for MP
|
|
42
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
|
43
|
+
|hash| hash['id'] == monitoring_policy_id
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
|
47
|
+
not be found.')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Search for process to update
|
|
51
|
+
if process = monitoring_policy['processes'].find {
|
|
52
|
+
|index| index['id'] == process_id
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Update the process with new values
|
|
56
|
+
new_process.each do |key, value|
|
|
57
|
+
process[key] = value
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
raise Fog::Errors::NotFound.new('The requested process 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 = monitoring_policy
|
|
68
|
+
response
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end # Mock
|
|
73
|
+
|
|
74
|
+
end # OneAndOne
|
|
75
|
+
end # Compute
|
|
76
|
+
end # Fog
|