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,108 @@
|
|
1
|
+
# List all shared storages on your account
|
2
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
3
|
+
|
4
|
+
response = shared_storage.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a shared storage
|
11
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
12
|
+
|
13
|
+
response = shared_storage.create(name: 'Test SS', description: 'Example Desc',
|
14
|
+
size: 200)
|
15
|
+
|
16
|
+
puts JSON.pretty_generate(response)
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
# Retrieve a shared storage's current specs
|
21
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
22
|
+
|
23
|
+
response = shared_storage.get(shared_storage_id: '<SHARED-STORAGE-ID>')
|
24
|
+
|
25
|
+
puts JSON.pretty_generate(response)
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# Modify a shared storage
|
30
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
31
|
+
|
32
|
+
response = shared_storage.modify(shared_storage_id: '<SHARED-STORAGE-ID>',
|
33
|
+
name: 'Test SS Rename', size: 400)
|
34
|
+
|
35
|
+
puts JSON.pretty_generate(response)
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# Delete a shared storage
|
40
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
41
|
+
|
42
|
+
response = shared_storage.delete(shared_storage_id: '<SHARED-STORAGE-ID>')
|
43
|
+
|
44
|
+
puts JSON.pretty_generate(response)
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
# Add servers to a shared storage
|
49
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
50
|
+
|
51
|
+
server1 = {
|
52
|
+
'id' => '<SERVER-ID>',
|
53
|
+
'rights' => 'RW'
|
54
|
+
}
|
55
|
+
|
56
|
+
servers = [server1]
|
57
|
+
|
58
|
+
response = shared_storage.add_servers(shared_storage_id: '<SHARED-STORAGE-ID>',
|
59
|
+
servers: servers)
|
60
|
+
|
61
|
+
puts JSON.pretty_generate(response)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# List a shared storage's servers
|
66
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
67
|
+
|
68
|
+
response = shared_storage.servers(shared_storage_id: '<SHARED-STORAGE-ID>')
|
69
|
+
|
70
|
+
puts JSON.pretty_generate(response)
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
# Retrieve information about a shared storage's server
|
75
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
76
|
+
|
77
|
+
response = shared_storage.server(shared_storage_id: '<SHARED-STORAGE-ID>',
|
78
|
+
server_id: '<SERVER-ID>')
|
79
|
+
|
80
|
+
puts JSON.pretty_generate(response)
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
# Remove a server from a shared storage
|
85
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
86
|
+
|
87
|
+
response = shared_storage.remove_server(shared_storage_id: '<SHARED-STORAGE-ID>',
|
88
|
+
server_id: '<SERVER-ID>')
|
89
|
+
|
90
|
+
puts JSON.pretty_generate(response)
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
# Retrieve the credentials for accessing shared storages
|
95
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
96
|
+
|
97
|
+
response = shared_storage.access
|
98
|
+
|
99
|
+
puts JSON.pretty_generate(response)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
# Change the password for accessing shared storages
|
104
|
+
shared_storage = OneAndOne::SharedStorage.new()
|
105
|
+
|
106
|
+
response = shared_storage.change_password(password: 'newpassword22')
|
107
|
+
|
108
|
+
puts JSON.pretty_generate(response)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# List all users on your account
|
2
|
+
user = OneAndOne::User.new()
|
3
|
+
|
4
|
+
response = user.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a new user
|
11
|
+
user = OneAndOne::User.new()
|
12
|
+
|
13
|
+
response = user.create(name: 'TestUser', email: 'test@example.com',
|
14
|
+
password: 'testpass')
|
15
|
+
|
16
|
+
puts JSON.pretty_generate(response)
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
# Return a user's current specs
|
21
|
+
user = OneAndOne::User.new()
|
22
|
+
|
23
|
+
response = user.get(user_id: '<USER-ID>')
|
24
|
+
|
25
|
+
puts JSON.pretty_generate(response)
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# Modify a user account
|
30
|
+
user = OneAndOne::User.new()
|
31
|
+
|
32
|
+
response = user.modify(user_id: '<USER-ID>', description: 'New Description',
|
33
|
+
email: 'newemail@example.com')
|
34
|
+
|
35
|
+
puts JSON.pretty_generate(response)
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# Delete a user
|
40
|
+
user = OneAndOne::User.new()
|
41
|
+
|
42
|
+
response = user.delete(user_id: '<USER-ID>')
|
43
|
+
|
44
|
+
puts JSON.pretty_generate(response)
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
# Return a user's API access credentials
|
49
|
+
user = OneAndOne::User.new()
|
50
|
+
|
51
|
+
response = user.api(user_id: '<USER-ID>')
|
52
|
+
|
53
|
+
puts JSON.pretty_generate(response)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# Enable or disable a user's API access
|
58
|
+
user = OneAndOne::User.new()
|
59
|
+
|
60
|
+
response = user.enable_api(user_id: '<USER-ID>', active: true)
|
61
|
+
|
62
|
+
puts JSON.pretty_generate(response)
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# Return a user's API key
|
67
|
+
user = OneAndOne::User.new()
|
68
|
+
|
69
|
+
response = user.api_key(user_id: '<USER-ID>')
|
70
|
+
|
71
|
+
puts JSON.pretty_generate(response)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
# Change a user's API key
|
76
|
+
user = OneAndOne::User.new()
|
77
|
+
|
78
|
+
response = user.change_key(user_id: '<USER-ID>')
|
79
|
+
|
80
|
+
puts JSON.pretty_generate(response)
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
# List the IP's from which a user can access the API
|
85
|
+
user = OneAndOne::User.new()
|
86
|
+
|
87
|
+
response = user.ips(user_id: '<USER-ID>')
|
88
|
+
|
89
|
+
puts JSON.pretty_generate(response)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
# Add IP's from which a user can access the API
|
94
|
+
user = OneAndOne::User.new()
|
95
|
+
|
96
|
+
ip1 = '1.2.3.4'
|
97
|
+
|
98
|
+
ips = [ip1]
|
99
|
+
|
100
|
+
response = user.add_ips(user_id: '<USER-ID>', ips: ips)
|
101
|
+
|
102
|
+
puts JSON.pretty_generate(response)
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
# Remove API access for an IP
|
107
|
+
user = OneAndOne::User.new()
|
108
|
+
|
109
|
+
ip1 = '1.2.3.4'
|
110
|
+
|
111
|
+
response = user.remove_ip(user_id: '<USER-ID>', ip: ip1)
|
112
|
+
|
113
|
+
puts JSON.pretty_generate(response)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# List all VPN's on your account
|
2
|
+
vpn = OneAndOne::Vpn.new()
|
3
|
+
|
4
|
+
response = vpn.list
|
5
|
+
|
6
|
+
puts JSON.pretty_generate(response)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# Create a new VPN
|
11
|
+
vpn = OneAndOne::Vpn.new()
|
12
|
+
|
13
|
+
response = vpn.create(name: 'Example VPN')
|
14
|
+
|
15
|
+
puts JSON.pretty_generate(response)
|
16
|
+
|
17
|
+
## Wait for VPN to deploy before performing other actions ##
|
18
|
+
puts "\nCreating VPN, please wait..."
|
19
|
+
puts vpn.wait_for
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# Retrieve the current specs for a VPN
|
24
|
+
vpn = OneAndOne::Vpn.new()
|
25
|
+
|
26
|
+
response = vpn.get(vpn_id: '<VPN-ID>')
|
27
|
+
|
28
|
+
puts JSON.pretty_generate(response)
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
# Modify a VPN
|
33
|
+
vpn = OneAndOne::Vpn.new()
|
34
|
+
|
35
|
+
response = vpn.modify(vpn_id: '<VPN-ID>', name: 'New Name')
|
36
|
+
|
37
|
+
puts JSON.pretty_generate(response)
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# Delete a VPN
|
42
|
+
vpn = OneAndOne::Vpn.new()
|
43
|
+
|
44
|
+
response = vpn.delete(vpn_id: '<VPN-ID>')
|
45
|
+
|
46
|
+
puts JSON.pretty_generate(response)
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# Download a VPN's config file
|
51
|
+
vpn = OneAndOne::Vpn.new()
|
52
|
+
|
53
|
+
response = vpn.download_config(vpn_id: '<VPN-ID>')
|
54
|
+
|
55
|
+
puts JSON.pretty_generate(response)
|
56
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module OneAndOne
|
2
|
+
|
3
|
+
|
4
|
+
class Datacenter
|
5
|
+
|
6
|
+
|
7
|
+
def initialize(test: false)
|
8
|
+
|
9
|
+
# Check if hitting mock api or live api
|
10
|
+
if test
|
11
|
+
@connection = Excon.new($base_url, :mock => true)
|
12
|
+
else
|
13
|
+
@connection = Excon.new($base_url)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def list(page: nil, per_page: nil, sort: nil, q: nil, fields: nil)
|
20
|
+
|
21
|
+
# Build hash for query parameters
|
22
|
+
keyword_args = {
|
23
|
+
:page => page,
|
24
|
+
:per_page => per_page,
|
25
|
+
:sort => sort,
|
26
|
+
:q => q,
|
27
|
+
:fields => fields
|
28
|
+
}
|
29
|
+
|
30
|
+
# Clean out null query parameters
|
31
|
+
params = OneAndOne.clean_hash(keyword_args)
|
32
|
+
|
33
|
+
# Build URL
|
34
|
+
path = OneAndOne.build_url('/datacenters')
|
35
|
+
|
36
|
+
# Perform request
|
37
|
+
response = @connection.request(:method => :get,
|
38
|
+
:path => path,
|
39
|
+
:headers => $header,
|
40
|
+
:query => params)
|
41
|
+
|
42
|
+
# Check response status
|
43
|
+
OneAndOne.check_response(response.body, response.status)
|
44
|
+
|
45
|
+
#JSON-ify the response string
|
46
|
+
JSON.parse(response.body)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def get(datacenter_id: nil)
|
52
|
+
|
53
|
+
# Build URL
|
54
|
+
path = OneAndOne.build_url("/datacenters/#{datacenter_id}")
|
55
|
+
|
56
|
+
# Perform request
|
57
|
+
response = @connection.request(:method => :get,
|
58
|
+
:path => path,
|
59
|
+
:headers => $header)
|
60
|
+
|
61
|
+
# Check response status
|
62
|
+
OneAndOne.check_response(response.body, response.status)
|
63
|
+
|
64
|
+
#JSON-ify the response string
|
65
|
+
JSON.parse(response.body)
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
data/lib/1and1/dvd.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
module OneAndOne
|
2
|
+
|
3
|
+
|
4
|
+
class Dvd
|
5
|
+
|
6
|
+
|
7
|
+
def initialize(test: false)
|
8
|
+
|
9
|
+
# Check if hitting mock api or live api
|
10
|
+
if test
|
11
|
+
@connection = Excon.new($base_url, :mock => true)
|
12
|
+
else
|
13
|
+
@connection = Excon.new($base_url)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def list(page: nil, per_page: nil, sort: nil, q: nil, fields: nil)
|
20
|
+
|
21
|
+
# Build hash for query parameters
|
22
|
+
keyword_args = {
|
23
|
+
:page => page,
|
24
|
+
:per_page => per_page,
|
25
|
+
:sort => sort,
|
26
|
+
:q => q,
|
27
|
+
:fields => fields
|
28
|
+
}
|
29
|
+
|
30
|
+
# Clean out null query parameters
|
31
|
+
params = OneAndOne.clean_hash(keyword_args)
|
32
|
+
|
33
|
+
# Build URL
|
34
|
+
path = OneAndOne.build_url('/dvd_isos')
|
35
|
+
|
36
|
+
# Perform request
|
37
|
+
response = @connection.request(:method => :get,
|
38
|
+
:path => path,
|
39
|
+
:headers => $header,
|
40
|
+
:query => params)
|
41
|
+
|
42
|
+
# Check response status
|
43
|
+
OneAndOne.check_response(response.body, response.status)
|
44
|
+
|
45
|
+
#JSON-ify the response string
|
46
|
+
JSON.parse(response.body)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def get(dvd_id: nil)
|
52
|
+
|
53
|
+
# Build URL
|
54
|
+
path = OneAndOne.build_url("/dvd_isos/#{dvd_id}")
|
55
|
+
|
56
|
+
# Perform request
|
57
|
+
response = @connection.request(:method => :get,
|
58
|
+
:path => path,
|
59
|
+
:headers => $header)
|
60
|
+
|
61
|
+
# Check response status
|
62
|
+
OneAndOne.check_response(response.body, response.status)
|
63
|
+
|
64
|
+
#JSON-ify the response string
|
65
|
+
JSON.parse(response.body)
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,427 @@
|
|
1
|
+
module OneAndOne
|
2
|
+
|
3
|
+
|
4
|
+
class Firewall
|
5
|
+
|
6
|
+
|
7
|
+
attr_accessor :id
|
8
|
+
attr_accessor :specs
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(test: false)
|
12
|
+
@id = nil
|
13
|
+
@specs = nil
|
14
|
+
|
15
|
+
# Check if hitting mock api or live api
|
16
|
+
if test
|
17
|
+
@connection = Excon.new($base_url, :mock => true)
|
18
|
+
else
|
19
|
+
@connection = Excon.new($base_url)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def list(page: nil, per_page: nil, sort: nil, q: nil, fields: nil)
|
26
|
+
|
27
|
+
# Build hash for query parameters
|
28
|
+
keyword_args = {
|
29
|
+
:page => page,
|
30
|
+
:per_page => per_page,
|
31
|
+
:sort => sort,
|
32
|
+
:q => q,
|
33
|
+
:fields => fields
|
34
|
+
}
|
35
|
+
|
36
|
+
# Clean out null query parameters
|
37
|
+
params = OneAndOne.clean_hash(keyword_args)
|
38
|
+
|
39
|
+
# Build URL
|
40
|
+
path = OneAndOne.build_url('/firewall_policies')
|
41
|
+
|
42
|
+
# Perform request
|
43
|
+
response = @connection.request(:method => :get,
|
44
|
+
:path => path,
|
45
|
+
:headers => $header,
|
46
|
+
:query => params)
|
47
|
+
|
48
|
+
# Check response status
|
49
|
+
OneAndOne.check_response(response.body, response.status)
|
50
|
+
|
51
|
+
#JSON-ify the response string
|
52
|
+
JSON.parse(response.body)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def create(name: nil, description: nil, rules: nil)
|
58
|
+
|
59
|
+
# Build POST body
|
60
|
+
new_firewall = {
|
61
|
+
'name' => name,
|
62
|
+
'description' => description,
|
63
|
+
'rules' => rules,
|
64
|
+
}
|
65
|
+
|
66
|
+
# Clean out null keys in POST body
|
67
|
+
body = OneAndOne.clean_hash(new_firewall)
|
68
|
+
|
69
|
+
# Stringify the POST body
|
70
|
+
string_body = body.to_json
|
71
|
+
|
72
|
+
# Build URL
|
73
|
+
path = OneAndOne.build_url('/firewall_policies')
|
74
|
+
|
75
|
+
# Perform request
|
76
|
+
response = @connection.request(:method => :post,
|
77
|
+
:path => path,
|
78
|
+
:headers => $header,
|
79
|
+
:body => string_body)
|
80
|
+
|
81
|
+
# Check response status
|
82
|
+
OneAndOne.check_response(response.body, response.status)
|
83
|
+
|
84
|
+
#JSON-ify the response string
|
85
|
+
json = JSON.parse(response.body)
|
86
|
+
|
87
|
+
# Save new firewall ID to Firewall instance
|
88
|
+
@id = json['id']
|
89
|
+
@specs = json
|
90
|
+
|
91
|
+
# If all good, return JSON
|
92
|
+
json
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def get(firewall_id: @id)
|
98
|
+
|
99
|
+
# If user passed in firewall ID, reassign
|
100
|
+
@id = firewall_id
|
101
|
+
|
102
|
+
# Build URL
|
103
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}")
|
104
|
+
|
105
|
+
# Perform request
|
106
|
+
response = @connection.request(:method => :get,
|
107
|
+
:path => path,
|
108
|
+
:headers => $header)
|
109
|
+
|
110
|
+
# Check response status
|
111
|
+
OneAndOne.check_response(response.body, response.status)
|
112
|
+
|
113
|
+
#JSON-ify the response string
|
114
|
+
json = JSON.parse(response.body)
|
115
|
+
|
116
|
+
# Reload specs attribute
|
117
|
+
@specs = json
|
118
|
+
|
119
|
+
# If all good, return JSON
|
120
|
+
json
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def modify(firewall_id: @id, name: nil, description: nil)
|
126
|
+
|
127
|
+
# If user passed in firewall ID, reassign
|
128
|
+
@id = firewall_id
|
129
|
+
|
130
|
+
# Build PUT body
|
131
|
+
new_firewall = {
|
132
|
+
'name' => name,
|
133
|
+
'description' => description
|
134
|
+
}
|
135
|
+
|
136
|
+
# Clean out null keys in PUT body
|
137
|
+
body = OneAndOne.clean_hash(new_firewall)
|
138
|
+
|
139
|
+
# Stringify the PUT body
|
140
|
+
string_body = body.to_json
|
141
|
+
|
142
|
+
# Build URL
|
143
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}")
|
144
|
+
|
145
|
+
# Perform request
|
146
|
+
response = @connection.request(:method => :put,
|
147
|
+
:path => path,
|
148
|
+
:headers => $header,
|
149
|
+
:body => string_body)
|
150
|
+
|
151
|
+
# Check response status
|
152
|
+
OneAndOne.check_response(response.body, response.status)
|
153
|
+
|
154
|
+
#JSON-ify the response string
|
155
|
+
JSON.parse(response.body)
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def delete(firewall_id: @id)
|
161
|
+
|
162
|
+
# If user passed in firewall ID, reassign
|
163
|
+
@id = firewall_id
|
164
|
+
|
165
|
+
# Build URL
|
166
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}")
|
167
|
+
|
168
|
+
# Perform request
|
169
|
+
response = @connection.request(:method => :delete,
|
170
|
+
:path => path,
|
171
|
+
:headers => $header)
|
172
|
+
|
173
|
+
# Check response status
|
174
|
+
OneAndOne.check_response(response.body, response.status)
|
175
|
+
|
176
|
+
#JSON-ify the response string
|
177
|
+
JSON.parse(response.body)
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def ips(firewall_id: @id)
|
183
|
+
|
184
|
+
# If user passed in firewall ID, reassign
|
185
|
+
@id = firewall_id
|
186
|
+
|
187
|
+
# Build URL
|
188
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/server_ips")
|
189
|
+
|
190
|
+
# Perform request
|
191
|
+
response = @connection.request(:method => :get,
|
192
|
+
:path => path,
|
193
|
+
:headers => $header)
|
194
|
+
|
195
|
+
# Check response status
|
196
|
+
OneAndOne.check_response(response.body, response.status)
|
197
|
+
|
198
|
+
#JSON-ify the response string
|
199
|
+
JSON.parse(response.body)
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def ip(firewall_id: @id, ip_id: nil)
|
205
|
+
|
206
|
+
# If user passed in firewall ID, reassign
|
207
|
+
@id = firewall_id
|
208
|
+
|
209
|
+
# Build URL
|
210
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/server_ips/#{ip_id}")
|
211
|
+
|
212
|
+
# Perform request
|
213
|
+
response = @connection.request(:method => :get,
|
214
|
+
:path => path,
|
215
|
+
:headers => $header)
|
216
|
+
|
217
|
+
# Check response status
|
218
|
+
OneAndOne.check_response(response.body, response.status)
|
219
|
+
|
220
|
+
#JSON-ify the response string
|
221
|
+
JSON.parse(response.body)
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
def add_ips(firewall_id: @id, ips: nil)
|
227
|
+
|
228
|
+
# If user passed in firewall ID, reassign
|
229
|
+
@id = firewall_id
|
230
|
+
|
231
|
+
# Build POST body
|
232
|
+
new_ips = {
|
233
|
+
'server_ips' => ips
|
234
|
+
}
|
235
|
+
|
236
|
+
# Clean out null keys in POST body
|
237
|
+
body = OneAndOne.clean_hash(new_ips)
|
238
|
+
|
239
|
+
# Stringify the POST body
|
240
|
+
string_body = body.to_json
|
241
|
+
|
242
|
+
# Build URL
|
243
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/server_ips")
|
244
|
+
|
245
|
+
# Perform request
|
246
|
+
response = @connection.request(:method => :post,
|
247
|
+
:path => path,
|
248
|
+
:headers => $header,
|
249
|
+
:body => string_body)
|
250
|
+
|
251
|
+
# Check response status
|
252
|
+
OneAndOne.check_response(response.body, response.status)
|
253
|
+
|
254
|
+
#JSON-ify the response string
|
255
|
+
JSON.parse(response.body)
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
def remove_ip(firewall_id: @id, ip_id: nil)
|
261
|
+
|
262
|
+
# If user passed in firewall ID, reassign
|
263
|
+
@id = firewall_id
|
264
|
+
|
265
|
+
# Build URL
|
266
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/server_ips/#{ip_id}")
|
267
|
+
|
268
|
+
# Perform request
|
269
|
+
response = @connection.request(:method => :delete,
|
270
|
+
:path => path,
|
271
|
+
:headers => $header)
|
272
|
+
|
273
|
+
# Check response status
|
274
|
+
OneAndOne.check_response(response.body, response.status)
|
275
|
+
|
276
|
+
#JSON-ify the response string
|
277
|
+
JSON.parse(response.body)
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
def rules(firewall_id: @id)
|
283
|
+
|
284
|
+
# If user passed in firewall ID, reassign
|
285
|
+
@id = firewall_id
|
286
|
+
|
287
|
+
# Build URL
|
288
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/rules")
|
289
|
+
|
290
|
+
# Perform request
|
291
|
+
response = @connection.request(:method => :get,
|
292
|
+
:path => path,
|
293
|
+
:headers => $header)
|
294
|
+
|
295
|
+
# Check response status
|
296
|
+
OneAndOne.check_response(response.body, response.status)
|
297
|
+
|
298
|
+
#JSON-ify the response string
|
299
|
+
JSON.parse(response.body)
|
300
|
+
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
def rule(firewall_id: @id, rule_id: nil)
|
305
|
+
|
306
|
+
# If user passed in firewall ID, reassign
|
307
|
+
@id = firewall_id
|
308
|
+
|
309
|
+
# Build URL
|
310
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/rules/#{rule_id}")
|
311
|
+
|
312
|
+
# Perform request
|
313
|
+
response = @connection.request(:method => :get,
|
314
|
+
:path => path,
|
315
|
+
:headers => $header)
|
316
|
+
|
317
|
+
# Check response status
|
318
|
+
OneAndOne.check_response(response.body, response.status)
|
319
|
+
|
320
|
+
#JSON-ify the response string
|
321
|
+
JSON.parse(response.body)
|
322
|
+
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
def add_rules(firewall_id: @id, rules: nil)
|
327
|
+
|
328
|
+
# If user passed in firewall ID, reassign
|
329
|
+
@id = firewall_id
|
330
|
+
|
331
|
+
# Build POST body
|
332
|
+
new_rules = {
|
333
|
+
'rules' => rules
|
334
|
+
}
|
335
|
+
|
336
|
+
# Clean out null keys in POST body
|
337
|
+
body = OneAndOne.clean_hash(new_rules)
|
338
|
+
|
339
|
+
# Stringify the POST body
|
340
|
+
string_body = body.to_json
|
341
|
+
|
342
|
+
# Build URL
|
343
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/rules")
|
344
|
+
|
345
|
+
# Perform request
|
346
|
+
response = @connection.request(:method => :post,
|
347
|
+
:path => path,
|
348
|
+
:headers => $header,
|
349
|
+
:body => string_body)
|
350
|
+
|
351
|
+
# Check response status
|
352
|
+
OneAndOne.check_response(response.body, response.status)
|
353
|
+
|
354
|
+
#JSON-ify the response string
|
355
|
+
JSON.parse(response.body)
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
|
360
|
+
def remove_rule(firewall_id: @id, rule_id: nil)
|
361
|
+
|
362
|
+
# If user passed in firewall ID, reassign
|
363
|
+
@id = firewall_id
|
364
|
+
|
365
|
+
# Build URL
|
366
|
+
path = OneAndOne.build_url("/firewall_policies/#{@id}/rules/#{rule_id}")
|
367
|
+
|
368
|
+
# Perform request
|
369
|
+
response = @connection.request(:method => :delete,
|
370
|
+
:path => path,
|
371
|
+
:headers => $header)
|
372
|
+
|
373
|
+
# Check response status
|
374
|
+
OneAndOne.check_response(response.body, response.status)
|
375
|
+
|
376
|
+
#JSON-ify the response string
|
377
|
+
JSON.parse(response.body)
|
378
|
+
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
def reload
|
383
|
+
|
384
|
+
# This reload fx is just a wrapper for the get fx
|
385
|
+
get
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
|
390
|
+
def wait_for(timeout: 25, interval: 1)
|
391
|
+
|
392
|
+
# Capture start time
|
393
|
+
start = Time.now
|
394
|
+
|
395
|
+
# Poll firewall and check initial state
|
396
|
+
initial_response = get
|
397
|
+
firewall_state = initial_response['state']
|
398
|
+
|
399
|
+
# Keep polling the firewall's state until good
|
400
|
+
until $good_states.include? firewall_state
|
401
|
+
|
402
|
+
# Wait 1 second before polling again
|
403
|
+
sleep interval
|
404
|
+
|
405
|
+
# Check firewall state again
|
406
|
+
current_response = get
|
407
|
+
firewall_state = current_response['state']
|
408
|
+
|
409
|
+
# Calculate current duration and check for timeout
|
410
|
+
duration = (Time.now - start) / 60
|
411
|
+
if duration > timeout
|
412
|
+
puts "The operation timed out after #{timeout} minutes.\n"
|
413
|
+
return
|
414
|
+
end
|
415
|
+
|
416
|
+
end
|
417
|
+
|
418
|
+
# Return Duration
|
419
|
+
{:duration => duration}
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
end
|
425
|
+
|
426
|
+
|
427
|
+
end
|