1and1 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/1and1-1.0.gem +0 -0
- data/1and1.gemspec +20 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/README.md +499 -0
- data/docs/reference.md +2447 -0
- data/examples/dvd_examples.rb +15 -0
- data/examples/example_app.rb +100 -0
- data/examples/firewall_examples.rb +137 -0
- data/examples/image_examples.rb +48 -0
- data/examples/load_balancer_examples.rb +145 -0
- data/examples/log_examples.rb +15 -0
- data/examples/monitoring_center_examples.rb +15 -0
- data/examples/monitoring_policy_examples.rb +343 -0
- data/examples/private_network_examples.rb +86 -0
- data/examples/public_ip_examples.rb +42 -0
- data/examples/role_examples.rb +113 -0
- data/examples/server_appliance_examples.rb +15 -0
- data/examples/server_examples.rb +438 -0
- data/examples/shared_storage_examples.rb +108 -0
- data/examples/usage_examples.rb +6 -0
- data/examples/user_examples.rb +113 -0
- data/examples/vpn_examples.rb +56 -0
- data/lib/1and1/datacenter.rb +73 -0
- data/lib/1and1/dvd.rb +73 -0
- data/lib/1and1/firewall.rb +427 -0
- data/lib/1and1/image.rb +231 -0
- data/lib/1and1/load_balancer.rb +448 -0
- data/lib/1and1/log.rb +77 -0
- data/lib/1and1/monitoring_center.rb +84 -0
- data/lib/1and1/monitoring_policy.rb +598 -0
- data/lib/1and1/oneandone.rb +57 -0
- data/lib/1and1/ping.rb +41 -0
- data/lib/1and1/ping_auth.rb +41 -0
- data/lib/1and1/pricing.rb +41 -0
- data/lib/1and1/private_network.rb +333 -0
- data/lib/1and1/public_ip.rb +192 -0
- data/lib/1and1/role.rb +381 -0
- data/lib/1and1/server.rb +1208 -0
- data/lib/1and1/server_appliance.rb +73 -0
- data/lib/1and1/shared_storage.rb +379 -0
- data/lib/1and1/usage.rb +58 -0
- data/lib/1and1/user.rb +374 -0
- data/lib/1and1/vpn.rb +249 -0
- data/lib/oneandone.rb +27 -0
- data/sphinx/Makefile +192 -0
- data/sphinx/_build/doctrees/dvds.doctree +0 -0
- data/sphinx/_build/doctrees/environment.pickle +0 -0
- data/sphinx/_build/doctrees/firewalls.doctree +0 -0
- data/sphinx/_build/doctrees/images.doctree +0 -0
- data/sphinx/_build/doctrees/index.doctree +0 -0
- data/sphinx/_build/doctrees/load_balancers.doctree +0 -0
- data/sphinx/_build/doctrees/logs.doctree +0 -0
- data/sphinx/_build/doctrees/monitoring_center.doctree +0 -0
- data/sphinx/_build/doctrees/monitoring_policies.doctree +0 -0
- data/sphinx/_build/doctrees/private_networks.doctree +0 -0
- data/sphinx/_build/doctrees/public_ips.doctree +0 -0
- data/sphinx/_build/doctrees/server_appliances.doctree +0 -0
- data/sphinx/_build/doctrees/servers.doctree +0 -0
- data/sphinx/_build/doctrees/shared_storages.doctree +0 -0
- data/sphinx/_build/doctrees/usages.doctree +0 -0
- data/sphinx/_build/doctrees/users.doctree +0 -0
- data/sphinx/_build/html/.buildinfo +4 -0
- data/sphinx/_build/html/_sources/dvds.txt +42 -0
- data/sphinx/_build/html/_sources/firewalls.txt +189 -0
- data/sphinx/_build/html/_sources/images.txt +101 -0
- data/sphinx/_build/html/_sources/index.txt +499 -0
- data/sphinx/_build/html/_sources/load_balancers.txt +231 -0
- data/sphinx/_build/html/_sources/logs.txt +55 -0
- data/sphinx/_build/html/_sources/monitoring_center.txt +55 -0
- data/sphinx/_build/html/_sources/monitoring_policies.txt +288 -0
- data/sphinx/_build/html/_sources/private_networks.txt +146 -0
- data/sphinx/_build/html/_sources/public_ips.txt +78 -0
- data/sphinx/_build/html/_sources/server_appliances.txt +42 -0
- data/sphinx/_build/html/_sources/servers.txt +630 -0
- data/sphinx/_build/html/_sources/shared_storages.txt +160 -0
- data/sphinx/_build/html/_sources/usages.txt +45 -0
- data/sphinx/_build/html/_sources/users.txt +172 -0
- data/sphinx/_build/html/_static/ajax-loader.gif +0 -0
- data/sphinx/_build/html/_static/alabaster.css +585 -0
- data/sphinx/_build/html/_static/basic.css +599 -0
- data/sphinx/_build/html/_static/comment-bright.png +0 -0
- data/sphinx/_build/html/_static/comment-close.png +0 -0
- data/sphinx/_build/html/_static/comment.png +0 -0
- data/sphinx/_build/html/_static/doctools.js +263 -0
- data/sphinx/_build/html/_static/down-pressed.png +0 -0
- data/sphinx/_build/html/_static/down.png +0 -0
- data/sphinx/_build/html/_static/file.png +0 -0
- data/sphinx/_build/html/_static/jquery-1.11.1.js +10308 -0
- data/sphinx/_build/html/_static/jquery.js +4 -0
- data/sphinx/_build/html/_static/minus.png +0 -0
- data/sphinx/_build/html/_static/plus.png +0 -0
- data/sphinx/_build/html/_static/pygments.css +63 -0
- data/sphinx/_build/html/_static/searchtools.js +651 -0
- data/sphinx/_build/html/_static/underscore-1.3.1.js +999 -0
- data/sphinx/_build/html/_static/underscore.js +31 -0
- data/sphinx/_build/html/_static/up-pressed.png +0 -0
- data/sphinx/_build/html/_static/up.png +0 -0
- data/sphinx/_build/html/_static/websupport.js +808 -0
- data/sphinx/_build/html/dvds.html +151 -0
- data/sphinx/_build/html/firewalls.html +397 -0
- data/sphinx/_build/html/genindex.html +114 -0
- data/sphinx/_build/html/images.html +236 -0
- data/sphinx/_build/html/index.html +571 -0
- data/sphinx/_build/html/load_balancers.html +409 -0
- data/sphinx/_build/html/logs.html +160 -0
- data/sphinx/_build/html/monitoring_center.html +160 -0
- data/sphinx/_build/html/monitoring_policies.html +530 -0
- data/sphinx/_build/html/objects.inv +0 -0
- data/sphinx/_build/html/private_networks.html +316 -0
- data/sphinx/_build/html/public_ips.html +215 -0
- data/sphinx/_build/html/rb-modindex.html +106 -0
- data/sphinx/_build/html/search.html +99 -0
- data/sphinx/_build/html/searchindex.js +1 -0
- data/sphinx/_build/html/server_appliances.html +153 -0
- data/sphinx/_build/html/servers.html +994 -0
- data/sphinx/_build/html/shared_storages.html +349 -0
- data/sphinx/_build/html/usages.html +140 -0
- data/sphinx/_build/html/users.html +363 -0
- data/sphinx/conf.py +287 -0
- data/sphinx/dvds.rst +42 -0
- data/sphinx/firewalls.rst +189 -0
- data/sphinx/images.rst +101 -0
- data/sphinx/index.rst +499 -0
- data/sphinx/load_balancers.rst +231 -0
- data/sphinx/logs.rst +55 -0
- data/sphinx/make.bat +263 -0
- data/sphinx/monitoring_center.rst +55 -0
- data/sphinx/monitoring_policies.rst +288 -0
- data/sphinx/private_networks.rst +146 -0
- data/sphinx/public_ips.rst +78 -0
- data/sphinx/server_appliances.rst +42 -0
- data/sphinx/servers.rst +630 -0
- data/sphinx/shared_storages.rst +160 -0
- data/sphinx/usages.rst +45 -0
- data/sphinx/users.rst +172 -0
- data/test/mock-api/add-firewall.json +66 -0
- data/test/mock-api/add-hdd.json +49 -0
- data/test/mock-api/add-lb.json +71 -0
- data/test/mock-api/add-new-ip.json +18 -0
- data/test/mock-api/add-pn.json +66 -0
- data/test/mock-api/add-port-mp.json +81 -0
- data/test/mock-api/add-process-mp.json +20 -0
- data/test/mock-api/add-rule-fp.json +33 -0
- data/test/mock-api/add-rule-lb.json +40 -0
- data/test/mock-api/add-server-ip.json +66 -0
- data/test/mock-api/add-server-mp.json +66 -0
- data/test/mock-api/assign-ip-fp.json +32 -0
- data/test/mock-api/assign-server-lb.json +39 -0
- data/test/mock-api/attach-server-pn.json +14 -0
- data/test/mock-api/attach-server-storage.json +24 -0
- data/test/mock-api/change-api-key.json +15 -0
- data/test/mock-api/change-password.json +5 -0
- data/test/mock-api/change-server-status.json +70 -0
- data/test/mock-api/clone-server.json +29 -0
- data/test/mock-api/create-fp.json +26 -0
- data/test/mock-api/create-image.json +30 -0
- data/test/mock-api/create-lb.json +33 -0
- data/test/mock-api/create-mp.json +81 -0
- data/test/mock-api/create-pn.json +11 -0
- data/test/mock-api/create-public-ip.json +10 -0
- data/test/mock-api/create-server.json +34 -0
- data/test/mock-api/create-snapshot.json +74 -0
- data/test/mock-api/create-storage.json +13 -0
- data/test/mock-api/create-user.json +14 -0
- data/test/mock-api/delete-fp.json +26 -0
- data/test/mock-api/delete-image.json +26 -0
- data/test/mock-api/delete-ip.json +15 -0
- data/test/mock-api/delete-lb.json +33 -0
- data/test/mock-api/delete-mp.json +71 -0
- data/test/mock-api/delete-pn.json +11 -0
- data/test/mock-api/delete-public-ip.json +10 -0
- data/test/mock-api/delete-rule-fp.json +26 -0
- data/test/mock-api/delete-server.json +50 -0
- data/test/mock-api/delete-snapshot.json +74 -0
- data/test/mock-api/delete-storage.json +24 -0
- data/test/mock-api/delete-user.json +15 -0
- data/test/mock-api/detach-server-lb.json +33 -0
- data/test/mock-api/detach-server-mp.json +65 -0
- data/test/mock-api/detach-server-storage.json +19 -0
- data/test/mock-api/edit-image.json +26 -0
- data/test/mock-api/eject-dvd.json +66 -0
- data/test/mock-api/fixed-server-flavors.json +70 -0
- data/test/mock-api/get-appliance.json +16 -0
- data/test/mock-api/get-dvd.json +9 -0
- data/test/mock-api/get-firewall.json +26 -0
- data/test/mock-api/get-fixed-server.json +17 -0
- data/test/mock-api/get-fp-rule.json +7 -0
- data/test/mock-api/get-hardware.json +13 -0
- data/test/mock-api/get-hdd.json +5 -0
- data/test/mock-api/get-image.json +26 -0
- data/test/mock-api/get-lb-rule.json +7 -0
- data/test/mock-api/get-lb-server.json +5 -0
- data/test/mock-api/get-load-balancer.json +33 -0
- data/test/mock-api/get-log.json +23 -0
- data/test/mock-api/get-monitoring-center.json +161 -0
- data/test/mock-api/get-mp-port.json +7 -0
- data/test/mock-api/get-mp-process.json +6 -0
- data/test/mock-api/get-mp-server.json +4 -0
- data/test/mock-api/get-mp.json +65 -0
- data/test/mock-api/get-pn-server.json +4 -0
- data/test/mock-api/get-private-network.json +20 -0
- data/test/mock-api/get-public-ip.json +10 -0
- data/test/mock-api/get-server-dvd.json +4 -0
- data/test/mock-api/get-server-image.json +4 -0
- data/test/mock-api/get-server-ip-fp.json +4 -0
- data/test/mock-api/get-server-ip.json +8 -0
- data/test/mock-api/get-server-pn.json +16 -0
- data/test/mock-api/get-server-status.json +4 -0
- data/test/mock-api/get-server-storage.json +5 -0
- data/test/mock-api/get-server.json +44 -0
- data/test/mock-api/get-storage.json +19 -0
- data/test/mock-api/get-usage.json +161 -0
- data/test/mock-api/get-user-api-key.json +3 -0
- data/test/mock-api/get-user-api.json +7 -0
- data/test/mock-api/get-user.json +15 -0
- data/test/mock-api/list-appliances.json +66 -0
- data/test/mock-api/list-credentials.json +5 -0
- data/test/mock-api/list-dvds.json +128 -0
- data/test/mock-api/list-firewalls.json +54 -0
- data/test/mock-api/list-fp-rules.json +16 -0
- data/test/mock-api/list-hdds.json +7 -0
- data/test/mock-api/list-images.json +54 -0
- data/test/mock-api/list-lb-rules.json +16 -0
- data/test/mock-api/list-lb-servers.json +12 -0
- data/test/mock-api/list-load-balancers.json +68 -0
- data/test/mock-api/list-logs.json +49 -0
- data/test/mock-api/list-monitoring-center-usages.json +90 -0
- data/test/mock-api/list-mp-ports.json +16 -0
- data/test/mock-api/list-mp-processes.json +14 -0
- data/test/mock-api/list-mp-servers.json +10 -0
- data/test/mock-api/list-mps.json +152 -0
- data/test/mock-api/list-pn-servers.json +10 -0
- data/test/mock-api/list-private-networks.json +24 -0
- data/test/mock-api/list-public-ips.json +44 -0
- data/test/mock-api/list-server-fps.json +4 -0
- data/test/mock-api/list-server-ips-fp.json +7 -0
- data/test/mock-api/list-server-ips.json +10 -0
- data/test/mock-api/list-server-lbs.json +6 -0
- data/test/mock-api/list-server-pns.json +6 -0
- data/test/mock-api/list-servers.json +66 -0
- data/test/mock-api/list-snapshots.json +7 -0
- data/test/mock-api/list-storages.json +47 -0
- data/test/mock-api/list-usages.json +144 -0
- data/test/mock-api/list-user-ips.json +5 -0
- data/test/mock-api/list-users.json +31 -0
- data/test/mock-api/load-dvd.json +63 -0
- data/test/mock-api/modify-fp.json +26 -0
- data/test/mock-api/modify-lb.json +33 -0
- data/test/mock-api/modify-mp.json +81 -0
- data/test/mock-api/modify-pn.json +20 -0
- data/test/mock-api/modify-port-mp.json +81 -0
- data/test/mock-api/modify-process-mp.json +73 -0
- data/test/mock-api/modify-public-ip.json +10 -0
- data/test/mock-api/modify-server-hardware.json +44 -0
- data/test/mock-api/modify-server-hdd.json +54 -0
- data/test/mock-api/modify-server.json +44 -0
- data/test/mock-api/modify-storage.json +19 -0
- data/test/mock-api/modify-user-api.json +15 -0
- data/test/mock-api/modify-user.json +15 -0
- data/test/mock-api/reinstall-image.json +52 -0
- data/test/mock-api/remove-firewall-policy.json +26 -0
- data/test/mock-api/remove-hdd.json +54 -0
- data/test/mock-api/remove-ip-fp.json +26 -0
- data/test/mock-api/remove-lb.json +66 -0
- data/test/mock-api/remove-pn.json +71 -0
- data/test/mock-api/remove-port-mp.json +73 -0
- data/test/mock-api/remove-process-mp.json +66 -0
- data/test/mock-api/remove-rule-lb.json +33 -0
- data/test/mock-api/remove-server-ip.json +58 -0
- data/test/mock-api/remove-server-pn.json +16 -0
- data/test/mock-api/restore-snapshot.json +55 -0
- data/test/mock-api/storage-servers.json +12 -0
- data/test/test_mock_dvd.rb +55 -0
- data/test/test_mock_firewall.rb +309 -0
- data/test/test_mock_image.rb +123 -0
- data/test/test_mock_load_balancer.rb +312 -0
- data/test/test_mock_log.rb +55 -0
- data/test/test_mock_monitoring_center.rb +55 -0
- data/test/test_mock_monitoring_policy.rb +587 -0
- data/test/test_mock_private_network.rb +206 -0
- data/test/test_mock_public_ip.rb +118 -0
- data/test/test_mock_server.rb +929 -0
- data/test/test_mock_server_appliance.rb +55 -0
- data/test/test_mock_shared_storage.rb +256 -0
- data/test/test_mock_usage.rb +34 -0
- data/test/test_mock_user.rb +270 -0
- metadata +360 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# List all public IPs on your account
|
2
|
+
public_ip = OneAndOne::PublicIP.new()
|
3
|
+
|
4
|
+
response = public_ip.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a public IP
|
11
|
+
public_ip = OneAndOne::PublicIP.new()
|
12
|
+
|
13
|
+
response = public_ip.create(reverse_dns: 'example.com')
|
14
|
+
|
15
|
+
puts JSON.pretty_generate(response)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
# Returns a public IP's current specs
|
20
|
+
public_ip = OneAndOne::PublicIP.new()
|
21
|
+
|
22
|
+
response = public_ip.get(ip_id: '<IP-ID>')
|
23
|
+
|
24
|
+
puts JSON.pretty_generate(response)
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# Modify a public IP
|
29
|
+
public_ip = OneAndOne::PublicIP.new()
|
30
|
+
|
31
|
+
response = public_ip.modify(ip_id: '<IP-ID>', reverse_dns: 'newexample.com')
|
32
|
+
|
33
|
+
puts JSON.pretty_generate(response)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# Delete a public IP
|
38
|
+
public_ip = OneAndOne::PublicIP.new()
|
39
|
+
|
40
|
+
response = public_ip.delete(ip_id: '<IP-ID>')
|
41
|
+
|
42
|
+
puts JSON.pretty_generate(response)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# List all available roles on your account
|
2
|
+
role = OneAndOne::Role.new()
|
3
|
+
|
4
|
+
response = role.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a new role
|
11
|
+
role = OneAndOne::Role.new()
|
12
|
+
|
13
|
+
response = role.create(name: 'Example Role')
|
14
|
+
|
15
|
+
puts JSON.pretty_generate(response)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
# Retrieve the current specs for a role
|
20
|
+
role = OneAndOne::Role.new()
|
21
|
+
|
22
|
+
response = role.get(role_id: '<ROLE-ID>')
|
23
|
+
|
24
|
+
puts JSON.pretty_generate(response)
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# Modify a role
|
29
|
+
role = OneAndOne::Role.new()
|
30
|
+
|
31
|
+
response = role.modify(role_id: '<ROLE-ID>', name: 'New Name', state: 'ACTIVE')
|
32
|
+
|
33
|
+
puts JSON.pretty_generate(response)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# Delete a role
|
38
|
+
role = OneAndOne::Role.new()
|
39
|
+
|
40
|
+
response = role.delete(role_id: '<ROLE-ID>')
|
41
|
+
|
42
|
+
puts JSON.pretty_generate(response)
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
# List a role's permissions
|
47
|
+
role = OneAndOne::Role.new()
|
48
|
+
|
49
|
+
response = role.permissions(role_id: '<ROLE-ID>')
|
50
|
+
|
51
|
+
puts JSON.pretty_generate(response)
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
# Modify a role's permissions
|
56
|
+
role = OneAndOne::Role.new()
|
57
|
+
|
58
|
+
server_perms = {
|
59
|
+
'show' => true,
|
60
|
+
'create' => true,
|
61
|
+
'delete' => false
|
62
|
+
}
|
63
|
+
|
64
|
+
response = role.modify_permissions(role_id: '<ROLE-ID>', servers: server_perms)
|
65
|
+
|
66
|
+
puts JSON.pretty_generate(response)
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
# List the users assigned to a role
|
71
|
+
role = OneAndOne::Role.new()
|
72
|
+
|
73
|
+
response = role.users(role_id: '<ROLE-ID>')
|
74
|
+
|
75
|
+
puts JSON.pretty_generate(response)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
# Assign users to a role
|
80
|
+
role = OneAndOne::Role.new()
|
81
|
+
|
82
|
+
users = ['<USER1-ID>', '<USER2-ID>']
|
83
|
+
|
84
|
+
response = role.add_users(role_id: '<ROLE-ID>', users: users)
|
85
|
+
|
86
|
+
puts JSON.pretty_generate(response)
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
# Returns information about a user assigned to a role
|
91
|
+
role = OneAndOne::Role.new()
|
92
|
+
|
93
|
+
response = role.get_user(role_id: '<ROLE-ID>', user_id: '<USER-ID>')
|
94
|
+
|
95
|
+
puts JSON.pretty_generate(response)
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# Unassign a user from a role
|
100
|
+
role = OneAndOne::Role.new()
|
101
|
+
|
102
|
+
response = role.remove_user(role_id: '<ROLE-ID>', user_id: '<USER-ID>')
|
103
|
+
|
104
|
+
puts JSON.pretty_generate(response)
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
# Clone a role
|
109
|
+
role = OneAndOne::Role.new()
|
110
|
+
|
111
|
+
response = role.clone(role_id: '<ROLE-ID>', name: 'Role Clone')
|
112
|
+
|
113
|
+
puts JSON.pretty_generate(response)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# List all server appliances on your account
|
2
|
+
appliance = OneAndOne::ServerAppliance.new()
|
3
|
+
|
4
|
+
response = appliance.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Returns information about an appliance
|
11
|
+
appliance = OneAndOne::ServerAppliance.new()
|
12
|
+
|
13
|
+
response = appliance.get(appliance_id: '<APPLIANCE-ID>')
|
14
|
+
|
15
|
+
puts JSON.pretty_generate(response)
|
@@ -0,0 +1,438 @@
|
|
1
|
+
# List all servers on your account
|
2
|
+
server = OneAndOne::Server.new()
|
3
|
+
|
4
|
+
response = server.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a new server
|
11
|
+
server = OneAndOne::Server.new()
|
12
|
+
|
13
|
+
hdd1 = {
|
14
|
+
'size' => 120,
|
15
|
+
'is_main' => true
|
16
|
+
}
|
17
|
+
|
18
|
+
hdds = [hdd1]
|
19
|
+
|
20
|
+
response = server.create(name: 'Example Server', vcore: 1,
|
21
|
+
cores_per_processor: 1, ram: 1,
|
22
|
+
appliance_id: '<IMAGE-ID>', hdds: hdds)
|
23
|
+
|
24
|
+
puts JSON.pretty_generate(response)
|
25
|
+
|
26
|
+
## Wait for server to deploy before performing other actions ##
|
27
|
+
puts "\nCreating server, please wait..."
|
28
|
+
server.wait_for
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
# Create a new server with SSH Key access
|
33
|
+
server = OneAndOne::Server.new()
|
34
|
+
|
35
|
+
pub_key = '<PUB-KEY>'
|
36
|
+
|
37
|
+
hdd1 = {
|
38
|
+
'size' => 120,
|
39
|
+
'is_main' => true
|
40
|
+
}
|
41
|
+
|
42
|
+
hdds = [hdd1]
|
43
|
+
|
44
|
+
response = server.create(name: 'Example Server', vcore: 1,
|
45
|
+
cores_per_processor: 1, ram: 1,
|
46
|
+
appliance_id: '<IMAGE-ID>', hdds: hdds, rsa_key: pub_key)
|
47
|
+
|
48
|
+
puts JSON.pretty_generate(response)
|
49
|
+
|
50
|
+
## Wait for server to deploy before performing other actions ##
|
51
|
+
puts "\nCreating server, please wait..."
|
52
|
+
server.wait_for
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
# Create a new server with SSH Key access and explicitly declare your datacenter
|
57
|
+
server = OneAndOne::Server.new()
|
58
|
+
|
59
|
+
pub_key = '<PUB-KEY>'
|
60
|
+
datacenter = '<DATACENTER-ID>'
|
61
|
+
|
62
|
+
hdd1 = {
|
63
|
+
'size' => 120,
|
64
|
+
'is_main' => true
|
65
|
+
}
|
66
|
+
|
67
|
+
hdds = [hdd1]
|
68
|
+
|
69
|
+
response = server.create(name: 'Example Server', vcore: 1,
|
70
|
+
cores_per_processor: 1, ram: 1,
|
71
|
+
appliance_id: '<IMAGE-ID>', hdds: hdds, rsa_key: pub_key,
|
72
|
+
datacenter_id: datacenter)
|
73
|
+
|
74
|
+
puts JSON.pretty_generate(response)
|
75
|
+
|
76
|
+
## Wait for server to deploy before performing other actions ##
|
77
|
+
puts "\nCreating server, please wait..."
|
78
|
+
server.wait_for
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# List all fixed server options
|
83
|
+
server = OneAndOne::Server.new()
|
84
|
+
|
85
|
+
response = server.list_fixed
|
86
|
+
|
87
|
+
puts JSON.pretty_generate(response)
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# Retrieve information about a fixed server option
|
92
|
+
server = OneAndOne::Server.new()
|
93
|
+
|
94
|
+
response = server.get_fixed(fixed_instance_id: '<FIXED-ID>')
|
95
|
+
|
96
|
+
puts JSON.pretty_generate(response)
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
# Retrieve the current specs for a server
|
101
|
+
server = OneAndOne::Server.new()
|
102
|
+
|
103
|
+
response = server.get(server_id: '<SERVER-ID>')
|
104
|
+
|
105
|
+
puts JSON.pretty_generate(response)
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
# Modify a server
|
110
|
+
server = OneAndOne::Server.new()
|
111
|
+
|
112
|
+
response = server.modify(server_id: '<SERVER-ID>', name: 'New Name')
|
113
|
+
|
114
|
+
puts JSON.pretty_generate(response)
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
# Delete a server
|
119
|
+
server = OneAndOne::Server.new()
|
120
|
+
|
121
|
+
response = server.delete(server_id: '<SERVER-ID>')
|
122
|
+
|
123
|
+
puts JSON.pretty_generate(response)
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
# Retrieve a server's current hardware configuration
|
128
|
+
server = OneAndOne::Server.new()
|
129
|
+
|
130
|
+
response = server.hardware(server_id: '<SERVER-ID>')
|
131
|
+
|
132
|
+
puts JSON.pretty_generate(response)
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
# Modify a server's hardware configurations
|
137
|
+
server = OneAndOne::Server.new()
|
138
|
+
|
139
|
+
response = server.modify_hardware(server_id: '<SERVER-ID>', ram: 2)
|
140
|
+
|
141
|
+
puts JSON.pretty_generate(response)
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
# List a server's hdds
|
146
|
+
server = OneAndOne::Server.new()
|
147
|
+
|
148
|
+
response = server.hdds(server_id: '<SERVER-ID>')
|
149
|
+
|
150
|
+
puts JSON.pretty_generate(response)
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
# Add hdds to a server
|
155
|
+
server = OneAndOne::Server.new()
|
156
|
+
|
157
|
+
hdd2 = {
|
158
|
+
'size' => 100,
|
159
|
+
'is_main' => false
|
160
|
+
}
|
161
|
+
|
162
|
+
hdds = [hdd2]
|
163
|
+
|
164
|
+
response = server.add_hdds(server_id: '<SERVER-ID>', hdds: hdds)
|
165
|
+
|
166
|
+
puts JSON.pretty_generate(response)
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
# Retrieve a server's hdd
|
171
|
+
server = OneAndOne::Server.new()
|
172
|
+
|
173
|
+
response = server.get_hdd(server_id: '<SERVER-ID>', hdd_id: '<HDD-ID>')
|
174
|
+
|
175
|
+
puts JSON.pretty_generate(response)
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
# Modify a server's hdd
|
180
|
+
server = OneAndOne::Server.new()
|
181
|
+
|
182
|
+
response = server.modify_hdd(server_id: '<SERVER-ID>', hdd_id: '<HDD-ID>',
|
183
|
+
size: 140)
|
184
|
+
|
185
|
+
puts JSON.pretty_generate(response)
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
# Delete a server's hdd
|
190
|
+
server = OneAndOne::Server.new()
|
191
|
+
|
192
|
+
response = server.delete_hdd(server_id: '<SERVER-ID>', hdd_id: '<HDD-ID>')
|
193
|
+
|
194
|
+
puts JSON.pretty_generate(response)
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
# Retrieve information about a server's image
|
199
|
+
server = OneAndOne::Server.new()
|
200
|
+
|
201
|
+
response = server.image(server_id: '<SERVER-ID>')
|
202
|
+
|
203
|
+
puts JSON.pretty_generate(response)
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
# Install an image onto a server
|
208
|
+
server = OneAndOne::Server.new()
|
209
|
+
|
210
|
+
response = server.install_image(server_id: '<SERVER-ID>', image_id: '<IMAGE-ID>')
|
211
|
+
|
212
|
+
puts JSON.pretty_generate(response)
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
# List a servers IPs
|
217
|
+
server = OneAndOne::Server.new()
|
218
|
+
|
219
|
+
response = server.ips(server_id: '<SERVER-ID>')
|
220
|
+
|
221
|
+
puts JSON.pretty_generate(response)
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
# Add an IP to a server
|
226
|
+
server = OneAndOne::Server.new()
|
227
|
+
|
228
|
+
response = server.add_ip(server_id: '<SERVER-ID>')
|
229
|
+
|
230
|
+
puts JSON.pretty_generate(response)
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
# Retrieve a server's IP
|
235
|
+
server = OneAndOne::Server.new()
|
236
|
+
|
237
|
+
response = server.ip(server_id: '<SERVER-ID>', ip_id: '<IP-ID>')
|
238
|
+
|
239
|
+
puts JSON.pretty_generate(response)
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# Release a server's IP
|
244
|
+
server = OneAndOne::Server.new()
|
245
|
+
|
246
|
+
response = server.release_ip(server_id: '<SERVER-ID>', ip_id: '<IP-ID>')
|
247
|
+
|
248
|
+
puts JSON.pretty_generate(response)
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
# Add a firewall to a server
|
253
|
+
server = OneAndOne::Server.new()
|
254
|
+
|
255
|
+
response = server.add_firewall(server_id: '<SERVER-ID>', ip_id: '<IP-ID>',
|
256
|
+
firewall_id: '<FIREWALL-ID>')
|
257
|
+
|
258
|
+
puts JSON.pretty_generate(response)
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
# Retrieve a server IP's firewall
|
263
|
+
server = OneAndOne::Server.new()
|
264
|
+
|
265
|
+
response = server.firewall(server_id: '<SERVER-ID>', ip_id: '<IP-ID>')
|
266
|
+
|
267
|
+
puts JSON.pretty_generate(response)
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
# Remove a server IP's firewall
|
272
|
+
server = OneAndOne::Server.new()
|
273
|
+
|
274
|
+
response = server.remove_firewall(server_id: '<SERVER-ID>', ip_id: '<IP-ID>')
|
275
|
+
|
276
|
+
puts JSON.pretty_generate(response)
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
# List a server IP's load balancers
|
281
|
+
server = OneAndOne::Server.new()
|
282
|
+
|
283
|
+
response = server.load_balancers(server_id: '<SERVER-ID>', ip_id: '<IP-ID>')
|
284
|
+
|
285
|
+
puts JSON.pretty_generate(response)
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
# Add a load balancer to a server's IP
|
290
|
+
server = OneAndOne::Server.new()
|
291
|
+
|
292
|
+
response = server.add_load_balancer(server_id: '<SERVER-ID>', ip_id: '<IP-ID>',
|
293
|
+
load_balancer_id: '<LOAD-BALANCER-ID>')
|
294
|
+
|
295
|
+
puts JSON.pretty_generate(response)
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
# Remove a load balancer from a server's IP
|
300
|
+
server = OneAndOne::Server.new()
|
301
|
+
|
302
|
+
response = server.remove_load_balancer(server_id: '<SERVER-ID>', ip_id: '<IP-ID>',
|
303
|
+
load_balancer_id: '<LOAD-BALANCER-ID>')
|
304
|
+
|
305
|
+
puts JSON.pretty_generate(response)
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
# Retrieve a server's current status
|
310
|
+
server = OneAndOne::Server.new()
|
311
|
+
|
312
|
+
response = server.status(server_id: '<SERVER-ID>')
|
313
|
+
|
314
|
+
puts JSON.pretty_generate(response)
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
# Change a server's status
|
319
|
+
server = OneAndOne::Server.new()
|
320
|
+
|
321
|
+
response = server.change_status(server_id: '<SERVER-ID>', action: 'REBOOT',
|
322
|
+
method: 'SOFTWARE')
|
323
|
+
|
324
|
+
puts JSON.pretty_generate(response)
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
# Retrieve a server's DVD
|
329
|
+
server = OneAndOne::Server.new()
|
330
|
+
|
331
|
+
response = server.dvd(server_id: '<SERVER-ID>')
|
332
|
+
|
333
|
+
puts JSON.pretty_generate(response)
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
# Eject a server's DVD
|
338
|
+
server = OneAndOne::Server.new()
|
339
|
+
|
340
|
+
response = server.eject_dvd(server_id: '<SERVER-ID>')
|
341
|
+
|
342
|
+
puts JSON.pretty_generate(response)
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
# Load a DVD into a server
|
347
|
+
server = OneAndOne::Server.new()
|
348
|
+
|
349
|
+
response = server.load_dvd(server_id: '<SERVER-ID>', dvd_id: '<DVD-ID>')
|
350
|
+
|
351
|
+
puts JSON.pretty_generate(response)
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
# List a server's private networks
|
356
|
+
server = OneAndOne::Server.new()
|
357
|
+
|
358
|
+
response = server.private_networks(server_id: '<SERVER-ID>')
|
359
|
+
|
360
|
+
puts JSON.pretty_generate(response)
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
# Retrieve information about a server's private network
|
365
|
+
server = OneAndOne::Server.new()
|
366
|
+
|
367
|
+
response = server.private_network(server_id: '<SERVER-ID>',
|
368
|
+
private_network_id: '<PRIVATE-NETWORK-ID>')
|
369
|
+
|
370
|
+
puts JSON.pretty_generate(response)
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
# Add a server to a private network
|
375
|
+
server = OneAndOne::Server.new()
|
376
|
+
|
377
|
+
response = server.add_private_network(server_id: '<SERVER-ID>',
|
378
|
+
private_network_id: '<PRIVATE-NETWORK-ID>')
|
379
|
+
|
380
|
+
puts JSON.pretty_generate(response)
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
# Remove a server from a private network
|
385
|
+
server = OneAndOne::Server.new()
|
386
|
+
|
387
|
+
response = server.remove_private_network(server_id: '<SERVER-ID>',
|
388
|
+
private_network_id: '<PRIVATE-NETWORK-ID>')
|
389
|
+
|
390
|
+
puts JSON.pretty_generate(response)
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
# Create a server snapshot
|
395
|
+
server = OneAndOne::Server.new()
|
396
|
+
|
397
|
+
response = server.create_snapshot(server_id: '<SERVER-ID>')
|
398
|
+
|
399
|
+
puts JSON.pretty_generate(response)
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
# Retrieve a server's snapshot
|
404
|
+
server = OneAndOne::Server.new()
|
405
|
+
|
406
|
+
response = server.snapshot(server_id: '<SERVER-ID>')
|
407
|
+
|
408
|
+
puts JSON.pretty_generate(response)
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
# Restore a server's snapshot
|
413
|
+
server = OneAndOne::Server.new()
|
414
|
+
|
415
|
+
response = server.restore_snapshot(server_id: '<SERVER-ID>',
|
416
|
+
snapshot_id: '<SNAPSHOT-ID>')
|
417
|
+
|
418
|
+
puts JSON.pretty_generate(response)
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
# Delete a server's snapshot
|
423
|
+
server = OneAndOne::Server.new()
|
424
|
+
|
425
|
+
response = server.delete_snapshot(server_id: '<SERVER-ID>',
|
426
|
+
snapshot_id: '<SNAPSHOT-ID>')
|
427
|
+
|
428
|
+
puts JSON.pretty_generate(response)
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
# Clone a server
|
433
|
+
server = OneAndOne::Server.new()
|
434
|
+
|
435
|
+
response = server.clone(server_id: '<SERVER-ID>',
|
436
|
+
name: 'My Server Clone')
|
437
|
+
|
438
|
+
puts JSON.pretty_generate(response)
|