1and1 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/1and1-1.0.gem +0 -0
  4. data/1and1.gemspec +20 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +201 -0
  7. data/README.md +499 -0
  8. data/docs/reference.md +2447 -0
  9. data/examples/dvd_examples.rb +15 -0
  10. data/examples/example_app.rb +100 -0
  11. data/examples/firewall_examples.rb +137 -0
  12. data/examples/image_examples.rb +48 -0
  13. data/examples/load_balancer_examples.rb +145 -0
  14. data/examples/log_examples.rb +15 -0
  15. data/examples/monitoring_center_examples.rb +15 -0
  16. data/examples/monitoring_policy_examples.rb +343 -0
  17. data/examples/private_network_examples.rb +86 -0
  18. data/examples/public_ip_examples.rb +42 -0
  19. data/examples/role_examples.rb +113 -0
  20. data/examples/server_appliance_examples.rb +15 -0
  21. data/examples/server_examples.rb +438 -0
  22. data/examples/shared_storage_examples.rb +108 -0
  23. data/examples/usage_examples.rb +6 -0
  24. data/examples/user_examples.rb +113 -0
  25. data/examples/vpn_examples.rb +56 -0
  26. data/lib/1and1/datacenter.rb +73 -0
  27. data/lib/1and1/dvd.rb +73 -0
  28. data/lib/1and1/firewall.rb +427 -0
  29. data/lib/1and1/image.rb +231 -0
  30. data/lib/1and1/load_balancer.rb +448 -0
  31. data/lib/1and1/log.rb +77 -0
  32. data/lib/1and1/monitoring_center.rb +84 -0
  33. data/lib/1and1/monitoring_policy.rb +598 -0
  34. data/lib/1and1/oneandone.rb +57 -0
  35. data/lib/1and1/ping.rb +41 -0
  36. data/lib/1and1/ping_auth.rb +41 -0
  37. data/lib/1and1/pricing.rb +41 -0
  38. data/lib/1and1/private_network.rb +333 -0
  39. data/lib/1and1/public_ip.rb +192 -0
  40. data/lib/1and1/role.rb +381 -0
  41. data/lib/1and1/server.rb +1208 -0
  42. data/lib/1and1/server_appliance.rb +73 -0
  43. data/lib/1and1/shared_storage.rb +379 -0
  44. data/lib/1and1/usage.rb +58 -0
  45. data/lib/1and1/user.rb +374 -0
  46. data/lib/1and1/vpn.rb +249 -0
  47. data/lib/oneandone.rb +27 -0
  48. data/sphinx/Makefile +192 -0
  49. data/sphinx/_build/doctrees/dvds.doctree +0 -0
  50. data/sphinx/_build/doctrees/environment.pickle +0 -0
  51. data/sphinx/_build/doctrees/firewalls.doctree +0 -0
  52. data/sphinx/_build/doctrees/images.doctree +0 -0
  53. data/sphinx/_build/doctrees/index.doctree +0 -0
  54. data/sphinx/_build/doctrees/load_balancers.doctree +0 -0
  55. data/sphinx/_build/doctrees/logs.doctree +0 -0
  56. data/sphinx/_build/doctrees/monitoring_center.doctree +0 -0
  57. data/sphinx/_build/doctrees/monitoring_policies.doctree +0 -0
  58. data/sphinx/_build/doctrees/private_networks.doctree +0 -0
  59. data/sphinx/_build/doctrees/public_ips.doctree +0 -0
  60. data/sphinx/_build/doctrees/server_appliances.doctree +0 -0
  61. data/sphinx/_build/doctrees/servers.doctree +0 -0
  62. data/sphinx/_build/doctrees/shared_storages.doctree +0 -0
  63. data/sphinx/_build/doctrees/usages.doctree +0 -0
  64. data/sphinx/_build/doctrees/users.doctree +0 -0
  65. data/sphinx/_build/html/.buildinfo +4 -0
  66. data/sphinx/_build/html/_sources/dvds.txt +42 -0
  67. data/sphinx/_build/html/_sources/firewalls.txt +189 -0
  68. data/sphinx/_build/html/_sources/images.txt +101 -0
  69. data/sphinx/_build/html/_sources/index.txt +499 -0
  70. data/sphinx/_build/html/_sources/load_balancers.txt +231 -0
  71. data/sphinx/_build/html/_sources/logs.txt +55 -0
  72. data/sphinx/_build/html/_sources/monitoring_center.txt +55 -0
  73. data/sphinx/_build/html/_sources/monitoring_policies.txt +288 -0
  74. data/sphinx/_build/html/_sources/private_networks.txt +146 -0
  75. data/sphinx/_build/html/_sources/public_ips.txt +78 -0
  76. data/sphinx/_build/html/_sources/server_appliances.txt +42 -0
  77. data/sphinx/_build/html/_sources/servers.txt +630 -0
  78. data/sphinx/_build/html/_sources/shared_storages.txt +160 -0
  79. data/sphinx/_build/html/_sources/usages.txt +45 -0
  80. data/sphinx/_build/html/_sources/users.txt +172 -0
  81. data/sphinx/_build/html/_static/ajax-loader.gif +0 -0
  82. data/sphinx/_build/html/_static/alabaster.css +585 -0
  83. data/sphinx/_build/html/_static/basic.css +599 -0
  84. data/sphinx/_build/html/_static/comment-bright.png +0 -0
  85. data/sphinx/_build/html/_static/comment-close.png +0 -0
  86. data/sphinx/_build/html/_static/comment.png +0 -0
  87. data/sphinx/_build/html/_static/doctools.js +263 -0
  88. data/sphinx/_build/html/_static/down-pressed.png +0 -0
  89. data/sphinx/_build/html/_static/down.png +0 -0
  90. data/sphinx/_build/html/_static/file.png +0 -0
  91. data/sphinx/_build/html/_static/jquery-1.11.1.js +10308 -0
  92. data/sphinx/_build/html/_static/jquery.js +4 -0
  93. data/sphinx/_build/html/_static/minus.png +0 -0
  94. data/sphinx/_build/html/_static/plus.png +0 -0
  95. data/sphinx/_build/html/_static/pygments.css +63 -0
  96. data/sphinx/_build/html/_static/searchtools.js +651 -0
  97. data/sphinx/_build/html/_static/underscore-1.3.1.js +999 -0
  98. data/sphinx/_build/html/_static/underscore.js +31 -0
  99. data/sphinx/_build/html/_static/up-pressed.png +0 -0
  100. data/sphinx/_build/html/_static/up.png +0 -0
  101. data/sphinx/_build/html/_static/websupport.js +808 -0
  102. data/sphinx/_build/html/dvds.html +151 -0
  103. data/sphinx/_build/html/firewalls.html +397 -0
  104. data/sphinx/_build/html/genindex.html +114 -0
  105. data/sphinx/_build/html/images.html +236 -0
  106. data/sphinx/_build/html/index.html +571 -0
  107. data/sphinx/_build/html/load_balancers.html +409 -0
  108. data/sphinx/_build/html/logs.html +160 -0
  109. data/sphinx/_build/html/monitoring_center.html +160 -0
  110. data/sphinx/_build/html/monitoring_policies.html +530 -0
  111. data/sphinx/_build/html/objects.inv +0 -0
  112. data/sphinx/_build/html/private_networks.html +316 -0
  113. data/sphinx/_build/html/public_ips.html +215 -0
  114. data/sphinx/_build/html/rb-modindex.html +106 -0
  115. data/sphinx/_build/html/search.html +99 -0
  116. data/sphinx/_build/html/searchindex.js +1 -0
  117. data/sphinx/_build/html/server_appliances.html +153 -0
  118. data/sphinx/_build/html/servers.html +994 -0
  119. data/sphinx/_build/html/shared_storages.html +349 -0
  120. data/sphinx/_build/html/usages.html +140 -0
  121. data/sphinx/_build/html/users.html +363 -0
  122. data/sphinx/conf.py +287 -0
  123. data/sphinx/dvds.rst +42 -0
  124. data/sphinx/firewalls.rst +189 -0
  125. data/sphinx/images.rst +101 -0
  126. data/sphinx/index.rst +499 -0
  127. data/sphinx/load_balancers.rst +231 -0
  128. data/sphinx/logs.rst +55 -0
  129. data/sphinx/make.bat +263 -0
  130. data/sphinx/monitoring_center.rst +55 -0
  131. data/sphinx/monitoring_policies.rst +288 -0
  132. data/sphinx/private_networks.rst +146 -0
  133. data/sphinx/public_ips.rst +78 -0
  134. data/sphinx/server_appliances.rst +42 -0
  135. data/sphinx/servers.rst +630 -0
  136. data/sphinx/shared_storages.rst +160 -0
  137. data/sphinx/usages.rst +45 -0
  138. data/sphinx/users.rst +172 -0
  139. data/test/mock-api/add-firewall.json +66 -0
  140. data/test/mock-api/add-hdd.json +49 -0
  141. data/test/mock-api/add-lb.json +71 -0
  142. data/test/mock-api/add-new-ip.json +18 -0
  143. data/test/mock-api/add-pn.json +66 -0
  144. data/test/mock-api/add-port-mp.json +81 -0
  145. data/test/mock-api/add-process-mp.json +20 -0
  146. data/test/mock-api/add-rule-fp.json +33 -0
  147. data/test/mock-api/add-rule-lb.json +40 -0
  148. data/test/mock-api/add-server-ip.json +66 -0
  149. data/test/mock-api/add-server-mp.json +66 -0
  150. data/test/mock-api/assign-ip-fp.json +32 -0
  151. data/test/mock-api/assign-server-lb.json +39 -0
  152. data/test/mock-api/attach-server-pn.json +14 -0
  153. data/test/mock-api/attach-server-storage.json +24 -0
  154. data/test/mock-api/change-api-key.json +15 -0
  155. data/test/mock-api/change-password.json +5 -0
  156. data/test/mock-api/change-server-status.json +70 -0
  157. data/test/mock-api/clone-server.json +29 -0
  158. data/test/mock-api/create-fp.json +26 -0
  159. data/test/mock-api/create-image.json +30 -0
  160. data/test/mock-api/create-lb.json +33 -0
  161. data/test/mock-api/create-mp.json +81 -0
  162. data/test/mock-api/create-pn.json +11 -0
  163. data/test/mock-api/create-public-ip.json +10 -0
  164. data/test/mock-api/create-server.json +34 -0
  165. data/test/mock-api/create-snapshot.json +74 -0
  166. data/test/mock-api/create-storage.json +13 -0
  167. data/test/mock-api/create-user.json +14 -0
  168. data/test/mock-api/delete-fp.json +26 -0
  169. data/test/mock-api/delete-image.json +26 -0
  170. data/test/mock-api/delete-ip.json +15 -0
  171. data/test/mock-api/delete-lb.json +33 -0
  172. data/test/mock-api/delete-mp.json +71 -0
  173. data/test/mock-api/delete-pn.json +11 -0
  174. data/test/mock-api/delete-public-ip.json +10 -0
  175. data/test/mock-api/delete-rule-fp.json +26 -0
  176. data/test/mock-api/delete-server.json +50 -0
  177. data/test/mock-api/delete-snapshot.json +74 -0
  178. data/test/mock-api/delete-storage.json +24 -0
  179. data/test/mock-api/delete-user.json +15 -0
  180. data/test/mock-api/detach-server-lb.json +33 -0
  181. data/test/mock-api/detach-server-mp.json +65 -0
  182. data/test/mock-api/detach-server-storage.json +19 -0
  183. data/test/mock-api/edit-image.json +26 -0
  184. data/test/mock-api/eject-dvd.json +66 -0
  185. data/test/mock-api/fixed-server-flavors.json +70 -0
  186. data/test/mock-api/get-appliance.json +16 -0
  187. data/test/mock-api/get-dvd.json +9 -0
  188. data/test/mock-api/get-firewall.json +26 -0
  189. data/test/mock-api/get-fixed-server.json +17 -0
  190. data/test/mock-api/get-fp-rule.json +7 -0
  191. data/test/mock-api/get-hardware.json +13 -0
  192. data/test/mock-api/get-hdd.json +5 -0
  193. data/test/mock-api/get-image.json +26 -0
  194. data/test/mock-api/get-lb-rule.json +7 -0
  195. data/test/mock-api/get-lb-server.json +5 -0
  196. data/test/mock-api/get-load-balancer.json +33 -0
  197. data/test/mock-api/get-log.json +23 -0
  198. data/test/mock-api/get-monitoring-center.json +161 -0
  199. data/test/mock-api/get-mp-port.json +7 -0
  200. data/test/mock-api/get-mp-process.json +6 -0
  201. data/test/mock-api/get-mp-server.json +4 -0
  202. data/test/mock-api/get-mp.json +65 -0
  203. data/test/mock-api/get-pn-server.json +4 -0
  204. data/test/mock-api/get-private-network.json +20 -0
  205. data/test/mock-api/get-public-ip.json +10 -0
  206. data/test/mock-api/get-server-dvd.json +4 -0
  207. data/test/mock-api/get-server-image.json +4 -0
  208. data/test/mock-api/get-server-ip-fp.json +4 -0
  209. data/test/mock-api/get-server-ip.json +8 -0
  210. data/test/mock-api/get-server-pn.json +16 -0
  211. data/test/mock-api/get-server-status.json +4 -0
  212. data/test/mock-api/get-server-storage.json +5 -0
  213. data/test/mock-api/get-server.json +44 -0
  214. data/test/mock-api/get-storage.json +19 -0
  215. data/test/mock-api/get-usage.json +161 -0
  216. data/test/mock-api/get-user-api-key.json +3 -0
  217. data/test/mock-api/get-user-api.json +7 -0
  218. data/test/mock-api/get-user.json +15 -0
  219. data/test/mock-api/list-appliances.json +66 -0
  220. data/test/mock-api/list-credentials.json +5 -0
  221. data/test/mock-api/list-dvds.json +128 -0
  222. data/test/mock-api/list-firewalls.json +54 -0
  223. data/test/mock-api/list-fp-rules.json +16 -0
  224. data/test/mock-api/list-hdds.json +7 -0
  225. data/test/mock-api/list-images.json +54 -0
  226. data/test/mock-api/list-lb-rules.json +16 -0
  227. data/test/mock-api/list-lb-servers.json +12 -0
  228. data/test/mock-api/list-load-balancers.json +68 -0
  229. data/test/mock-api/list-logs.json +49 -0
  230. data/test/mock-api/list-monitoring-center-usages.json +90 -0
  231. data/test/mock-api/list-mp-ports.json +16 -0
  232. data/test/mock-api/list-mp-processes.json +14 -0
  233. data/test/mock-api/list-mp-servers.json +10 -0
  234. data/test/mock-api/list-mps.json +152 -0
  235. data/test/mock-api/list-pn-servers.json +10 -0
  236. data/test/mock-api/list-private-networks.json +24 -0
  237. data/test/mock-api/list-public-ips.json +44 -0
  238. data/test/mock-api/list-server-fps.json +4 -0
  239. data/test/mock-api/list-server-ips-fp.json +7 -0
  240. data/test/mock-api/list-server-ips.json +10 -0
  241. data/test/mock-api/list-server-lbs.json +6 -0
  242. data/test/mock-api/list-server-pns.json +6 -0
  243. data/test/mock-api/list-servers.json +66 -0
  244. data/test/mock-api/list-snapshots.json +7 -0
  245. data/test/mock-api/list-storages.json +47 -0
  246. data/test/mock-api/list-usages.json +144 -0
  247. data/test/mock-api/list-user-ips.json +5 -0
  248. data/test/mock-api/list-users.json +31 -0
  249. data/test/mock-api/load-dvd.json +63 -0
  250. data/test/mock-api/modify-fp.json +26 -0
  251. data/test/mock-api/modify-lb.json +33 -0
  252. data/test/mock-api/modify-mp.json +81 -0
  253. data/test/mock-api/modify-pn.json +20 -0
  254. data/test/mock-api/modify-port-mp.json +81 -0
  255. data/test/mock-api/modify-process-mp.json +73 -0
  256. data/test/mock-api/modify-public-ip.json +10 -0
  257. data/test/mock-api/modify-server-hardware.json +44 -0
  258. data/test/mock-api/modify-server-hdd.json +54 -0
  259. data/test/mock-api/modify-server.json +44 -0
  260. data/test/mock-api/modify-storage.json +19 -0
  261. data/test/mock-api/modify-user-api.json +15 -0
  262. data/test/mock-api/modify-user.json +15 -0
  263. data/test/mock-api/reinstall-image.json +52 -0
  264. data/test/mock-api/remove-firewall-policy.json +26 -0
  265. data/test/mock-api/remove-hdd.json +54 -0
  266. data/test/mock-api/remove-ip-fp.json +26 -0
  267. data/test/mock-api/remove-lb.json +66 -0
  268. data/test/mock-api/remove-pn.json +71 -0
  269. data/test/mock-api/remove-port-mp.json +73 -0
  270. data/test/mock-api/remove-process-mp.json +66 -0
  271. data/test/mock-api/remove-rule-lb.json +33 -0
  272. data/test/mock-api/remove-server-ip.json +58 -0
  273. data/test/mock-api/remove-server-pn.json +16 -0
  274. data/test/mock-api/restore-snapshot.json +55 -0
  275. data/test/mock-api/storage-servers.json +12 -0
  276. data/test/test_mock_dvd.rb +55 -0
  277. data/test/test_mock_firewall.rb +309 -0
  278. data/test/test_mock_image.rb +123 -0
  279. data/test/test_mock_load_balancer.rb +312 -0
  280. data/test/test_mock_log.rb +55 -0
  281. data/test/test_mock_monitoring_center.rb +55 -0
  282. data/test/test_mock_monitoring_policy.rb +587 -0
  283. data/test/test_mock_private_network.rb +206 -0
  284. data/test/test_mock_public_ip.rb +118 -0
  285. data/test/test_mock_server.rb +929 -0
  286. data/test/test_mock_server_appliance.rb +55 -0
  287. data/test/test_mock_shared_storage.rb +256 -0
  288. data/test/test_mock_usage.rb +34 -0
  289. data/test/test_mock_user.rb +270 -0
  290. metadata +360 -0
@@ -0,0 +1,15 @@
1
+ # List all DVD's on your account
2
+ dvd = OneAndOne::Dvd.new()
3
+
4
+ response = dvd.list
5
+
6
+ puts JSON.pretty_generate(response)
7
+
8
+
9
+
10
+ # Returns information about a DVD
11
+ dvd = OneAndOne::Dvd.new()
12
+
13
+ response = dvd.get(dvd_id: '<DVD-ID>')
14
+
15
+ puts JSON.pretty_generate(response)
@@ -0,0 +1,100 @@
1
+ require_relative '../lib/oneandone'
2
+
3
+ OneAndOne.start('<API-TOKEN>') # Init module with API key
4
+
5
+
6
+
7
+ ### Create load balancer
8
+ load_balancer = OneAndOne::LoadBalancer.new
9
+
10
+ rule1 = {
11
+ 'protocol' => 'TCP',
12
+ 'port_balancer' => 80,
13
+ 'port_server' => 80,
14
+ 'source' => '0.0.0.0'
15
+ }
16
+
17
+ rules = [rule1]
18
+
19
+ lb1 = load_balancer.create(name: 'Example App LB', description: 'Example Desc',
20
+ health_check_test: 'TCP', health_check_interval: 40, persistence: true,
21
+ persistence_time: 1200, method: 'ROUND_ROBIN', rules: rules)
22
+
23
+ # Wait for load balancer to deploy
24
+ puts "\nCreating load balancer...\n"
25
+ puts load_balancer.wait_for
26
+
27
+
28
+
29
+ ### Create firewall policy
30
+ firewall = OneAndOne::Firewall.new
31
+
32
+ rule1 = {
33
+ 'protocol' => 'TCP',
34
+ 'port_from' => 80,
35
+ 'port_to' => 80,
36
+ 'source' => '0.0.0.0'
37
+ }
38
+
39
+ rules = [rule1]
40
+
41
+ fp1 = firewall.create(name: 'Example App Firewall', description: 'Example Desc',
42
+ rules: rules)
43
+
44
+ # Wait for firewall policy to deploy
45
+ puts "\nCreating firewall policy...\n"
46
+ puts firewall.wait_for
47
+
48
+
49
+
50
+ ### Create a server
51
+ server = OneAndOne::Server.new
52
+
53
+ server1 = server.create(name: 'Example App Server',
54
+ fixed_instance_id: '65929629F35BBFBA63022008F773F3EB',
55
+ appliance_id: '6C902E5899CC6F7ED18595EBEB542EE1',
56
+ datacenter_id: '5091F6D8CBFEF9C26ACE957C652D5D49')
57
+
58
+ # Wait for server to deploy
59
+ puts "\nCreating server...\n"
60
+ puts server.wait_for
61
+
62
+
63
+
64
+ ### Add the load balancer to the new IP
65
+ response = server.add_load_balancer(ip_id: server.first_ip['id'],
66
+ load_balancer_id: load_balancer.id)
67
+
68
+ # Wait for load balancer to be added
69
+ puts "\nAdding load balancer to server IP...\n"
70
+ puts server.wait_for
71
+
72
+
73
+
74
+ ### Add the firewall policy to the new IP
75
+ response = server.add_firewall(ip_id: server.first_ip['id'],
76
+ firewall_id: firewall.id)
77
+
78
+ # Wait for firewall policy to be added
79
+ puts "\nAdding firewall policy to server IP...\n"
80
+ puts server.wait_for
81
+ puts "\nEverything looks good!"
82
+
83
+
84
+
85
+ ### Cleanup
86
+ puts "\nLet's clean up the mess we just made.\n"
87
+
88
+ puts "\nDeleting server...\n"
89
+ server.delete
90
+ puts "Success!\n"
91
+
92
+ puts "\nDeleting firewall policy...\n"
93
+ firewall.delete
94
+ puts "Success!\n"
95
+
96
+ puts "\nDeleting load balancer...\n"
97
+ load_balancer.delete
98
+ puts "Success!\n"
99
+
100
+ puts "\nAll done!\n"
@@ -0,0 +1,137 @@
1
+ # List all firewall policies on your account
2
+ firewall = OneAndOne::Firewall.new()
3
+
4
+ response = firewall.list
5
+
6
+ puts JSON.pretty_generate(response)
7
+
8
+
9
+
10
+ # Create a firewall policy
11
+ firewall = OneAndOne::Firewall.new()
12
+
13
+ rule1 = {
14
+ 'protocol' => 'TCP',
15
+ 'port_from' => 80,
16
+ 'port_to' => 80,
17
+ 'source' => '0.0.0.0'
18
+ }
19
+
20
+ rules = [rule1]
21
+
22
+ response = firewall.create(name: 'Test Firewall', description: 'Example Desc',
23
+ rules: rules)
24
+
25
+ puts JSON.pretty_generate(response)
26
+
27
+
28
+
29
+ # Retrieve a firewall policy's current specs
30
+ firewall = OneAndOne::Firewall.new()
31
+
32
+ response = firewall.get(firewall_id: '<FIREWALL-ID>')
33
+
34
+ puts JSON.pretty_generate(response)
35
+
36
+
37
+
38
+ # Modify a firewall policy
39
+ firewall = OneAndOne::Firewall.new()
40
+
41
+ response = firewall.modify(firewall_id: '<FIREWALL-ID>', name: 'New Name')
42
+
43
+ puts JSON.pretty_generate(response)
44
+
45
+
46
+
47
+ # Delete a firewall policy
48
+ firewall = OneAndOne::Firewall.new()
49
+
50
+ response = firewall.delete(firewall_id: '<FIREWALL-ID>')
51
+
52
+ puts JSON.pretty_generate(response)
53
+
54
+
55
+
56
+ # List the IPs assigned to a firewall policy
57
+ firewall = OneAndOne::Firewall.new()
58
+
59
+ response = firewall.ips(firewall_id: '<FIREWALL-ID>')
60
+
61
+ puts JSON.pretty_generate(response)
62
+
63
+
64
+
65
+ # Retrieve information about an IP assigned to a firewall policy
66
+ firewall = OneAndOne::Firewall.new()
67
+
68
+ response = firewall.ip(firewall_id: '<FIREWALL-ID>', ip_id: '<IP-ID>')
69
+
70
+ puts JSON.pretty_generate(response)
71
+
72
+
73
+
74
+ # Add IPs to a firewall policy
75
+ firewall = OneAndOne::Firewall.new()
76
+
77
+ ip1 = '<IP-ID>'
78
+
79
+ ips = [ip1]
80
+
81
+ response = firewall.add_ips(firewall_id: '<FIREWALL-ID>', ips: ips)
82
+
83
+ puts JSON.pretty_generate(response)
84
+
85
+
86
+
87
+ # Remove a firewall policy's IP
88
+ firewall = OneAndOne::Firewall.new()
89
+
90
+ response = firewall.remove_ip(firewall_id: '<FIREWALL-ID>', ip_id: '<IP-ID>')
91
+
92
+ puts JSON.pretty_generate(response)
93
+
94
+
95
+
96
+ # List a firewall policy's rules
97
+ firewall = OneAndOne::Firewall.new()
98
+
99
+ response = firewall.rules(firewall_id: '<FIREWALL-ID>')
100
+
101
+ puts JSON.pretty_generate(response)
102
+
103
+
104
+
105
+ # Retrieve information about a firewall policy's rule
106
+ firewall = OneAndOne::Firewall.new()
107
+
108
+ response = firewall.rule(firewall_id: '<FIREWALL-ID>', rule_id: '<RULE-ID>')
109
+
110
+ puts JSON.pretty_generate(response)
111
+
112
+
113
+
114
+ # Add new rules to a firewall policy
115
+ firewall = OneAndOne::Firewall.new()
116
+
117
+ rule2 = {
118
+ 'protocol' => 'TCP',
119
+ 'port_from' => 90,
120
+ 'port_to' => 90,
121
+ 'source' => '0.0.0.0'
122
+ }
123
+
124
+ rules = [rule2]
125
+
126
+ response = firewall.add_rules(firewall_id: '<FIREWALL-ID>', rules: rules)
127
+
128
+ puts JSON.pretty_generate(response)
129
+
130
+
131
+
132
+ # Remove a rule
133
+ firewall = OneAndOne::Firewall.new()
134
+
135
+ response = firewall.remove_rule(firewall_id: '<FIREWALL-ID>', rule_id: '<RULE-ID>')
136
+
137
+ puts JSON.pretty_generate(response)
@@ -0,0 +1,48 @@
1
+ # List all images on your account
2
+ image = OneAndOne::Image.new()
3
+
4
+ response = image.list
5
+
6
+ puts JSON.pretty_generate(response)
7
+
8
+
9
+
10
+ # Create a new image
11
+ image = OneAndOne::Image.new()
12
+
13
+ response = image.create(server_id: '<SERVER-ID>', name: 'Example Image',
14
+ frequency: 'ONCE', num_images: 1)
15
+
16
+ puts JSON.pretty_generate(response)
17
+
18
+ ## Wait for image to deploy before performing other actions ##
19
+ puts "\nCreating image, please wait..."
20
+ image.wait_for
21
+
22
+
23
+
24
+ # Retrieve the current specs for an image
25
+ image = OneAndOne::Image.new()
26
+
27
+ response = image.get(image_id: '<IMAGE-ID>')
28
+
29
+ puts JSON.pretty_generate(response)
30
+
31
+
32
+
33
+ # Modify an image
34
+ image = OneAndOne::Image.new()
35
+
36
+ response = image.modify(image_id: '<IMAGE-ID>', name: 'New Name')
37
+
38
+ puts JSON.pretty_generate(response)
39
+
40
+
41
+
42
+ # Delete the new image
43
+ image = OneAndOne::Image.new()
44
+
45
+ response = image.delete(image_id: '<IMAGE-ID>')
46
+
47
+ puts JSON.pretty_generate(response)
48
+
@@ -0,0 +1,145 @@
1
+ # List all load balancers on your account
2
+ load_balancer = OneAndOne::LoadBalancer.new()
3
+
4
+ response = load_balancer.list
5
+
6
+ puts JSON.pretty_generate(response)
7
+
8
+
9
+
10
+ # Create a load balancer
11
+ load_balancer = OneAndOne::LoadBalancer.new()
12
+
13
+ rule1 = {
14
+ 'protocol' => 'TCP',
15
+ 'port_balancer' => 80,
16
+ 'port_server' => 80,
17
+ 'source' => '0.0.0.0'
18
+ }
19
+
20
+ rules = [rule1]
21
+
22
+ response = load_balancer.create(name: 'Test LB', description: 'Example Desc',
23
+ health_check_test: 'TCP', health_check_interval: 40, persistence: true,
24
+ persistence_time: 1200, method: 'ROUND_ROBIN', rules: rules)
25
+
26
+ puts JSON.pretty_generate(response)
27
+
28
+
29
+
30
+ # Return information about a load balancer
31
+ load_balancer = OneAndOne::LoadBalancer.new()
32
+
33
+ response = load_balancer.get(load_balancer_id: '<LOAD-BALANCER-ID>')
34
+
35
+ puts JSON.pretty_generate(response)
36
+
37
+
38
+
39
+ # Modify a load balancer
40
+ load_balancer = OneAndOne::LoadBalancer.new()
41
+
42
+ response = load_balancer.modify(load_balancer_id: '<LOAD-BALANCER-ID>',
43
+ name: 'New Name')
44
+
45
+ puts JSON.pretty_generate(response)
46
+
47
+
48
+
49
+ # Delete a load balancer
50
+ load_balancer = OneAndOne::LoadBalancer.new()
51
+
52
+ response = load_balancer.delete(load_balancer_id: '<LOAD-BALANCER-ID>')
53
+
54
+ puts JSON.pretty_generate(response)
55
+
56
+
57
+
58
+ # List the IP's assigned to a load balancer
59
+ load_balancer = OneAndOne::LoadBalancer.new()
60
+
61
+ response = load_balancer.ips(load_balancer_id: '<LOAD-BALANCER-ID>')
62
+
63
+ puts JSON.pretty_generate(response)
64
+
65
+
66
+
67
+ # Returns information about an IP assigned to the load balancer
68
+ load_balancer = OneAndOne::LoadBalancer.new()
69
+
70
+ response = load_balancer.ip(load_balancer_id: '<LOAD-BALANCER-ID>',
71
+ ip_id: '<IP-ID>')
72
+
73
+ puts JSON.pretty_generate(response)
74
+
75
+
76
+
77
+ # Remove a load balancer from an IP
78
+ load_balancer = OneAndOne::LoadBalancer.new()
79
+
80
+ response = load_balancer.remove_ip(load_balancer_id: '<LOAD-BALANCER-ID>',
81
+ ip_id: '<IP-ID>')
82
+
83
+ puts JSON.pretty_generate(response)
84
+
85
+
86
+
87
+ # Add a load balancer to IP's
88
+ load_balancer = OneAndOne::LoadBalancer.new()
89
+
90
+ ip1 = '<IP-ID>'
91
+
92
+ ips = [ip1]
93
+
94
+ response = load_balancer.add_ips(load_balancer_id: '<LOAD-BALANCER-ID>',
95
+ ips: ips)
96
+
97
+ puts JSON.pretty_generate(response)
98
+
99
+
100
+
101
+ # List a load balancer's rules
102
+ load_balancer = OneAndOne::LoadBalancer.new()
103
+
104
+ response = load_balancer.rules(load_balancer_id: '<LOAD-BALANCER-ID>')
105
+
106
+ puts JSON.pretty_generate(response)
107
+
108
+
109
+
110
+ # Returns information about a load balancer's rule
111
+ load_balancer = OneAndOne::LoadBalancer.new()
112
+
113
+ response = load_balancer.rule(load_balancer_id: '<LOAD-BALANCER-ID>',
114
+ rule_id: '<RULE-ID>')
115
+
116
+ puts JSON.pretty_generate(response)
117
+
118
+
119
+
120
+ # Add new rules to a load balancer
121
+ load_balancer = OneAndOne::LoadBalancer.new()
122
+
123
+ rule2 = {
124
+ 'protocol' => 'TCP',
125
+ 'port_balancer' => 90,
126
+ 'port_server' => 90,
127
+ 'source' => '0.0.0.0'
128
+ }
129
+
130
+ rules = [rule2]
131
+
132
+ response = load_balancer.add_rules(load_balancer_id: '<LOAD-BALANCER-ID>',
133
+ rules: rules)
134
+
135
+ puts JSON.pretty_generate(response)
136
+
137
+
138
+
139
+ # Remove a load balancer's rule
140
+ load_balancer = OneAndOne::LoadBalancer.new()
141
+
142
+ response = load_balancer.remove_rule(load_balancer_id: '<LOAD-BALANCER-ID>',
143
+ rule_id: '<RULE-ID>')
144
+
145
+ puts JSON.pretty_generate(response)