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,33 @@
1
+ {
2
+ "id": "BD8318616581A9C3C53F94402503230F",
3
+ "name": "My load balancer",
4
+ "state": "CONFIGURING",
5
+ "creation_date": "2015-05-04T07:26:24+00:00",
6
+ "description": "My load balancer description",
7
+ "ip": null,
8
+ "health_check_test": "TCP",
9
+ "health_check_interval": 40,
10
+ "health_check_path": null,
11
+ "health_check_path_parser": null,
12
+ "persistence": true,
13
+ "persistence_time": 1200,
14
+ "method": "ROUND_ROBIN",
15
+ "rules": [
16
+ {
17
+ "id": "4E2E2E596F3D7839554C3CCB091038C2",
18
+ "protocol": "TCP",
19
+ "port_balancer": 80,
20
+ "port_server": 80,
21
+ "source": "0.0.0.0"
22
+ },
23
+ {
24
+ "id": "38797962095C33C2ACE883E1254A0EFA",
25
+ "protocol": "TCP",
26
+ "port_balancer": 9999,
27
+ "port_server": 8888,
28
+ "source": "0.0.0.0"
29
+ }
30
+ ],
31
+ "server_ips": [],
32
+ "cloudpanel_id": "LB99AA4_1"
33
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "id": "92AA60BEC8333A21EDB9EAAA61852860",
3
+ "cloudpanel_id": "5061DE9",
4
+ "name": "My server",
5
+ "description": null,
6
+ "creation_date": "2015-05-06T11:09:55+00:00",
7
+ "first_password": null,
8
+ "status": {
9
+ "state": "POWERED_ON",
10
+ "percent": null
11
+ },
12
+ "hardware": {
13
+ "fixed_instance_size_id": 0,
14
+ "vcore": 1,
15
+ "cores_per_processor": 1,
16
+ "ram": 1,
17
+ "hdds": [
18
+ {
19
+ "id": "77F5BC74C9B3532A37D31FEED070BE01",
20
+ "size": 40,
21
+ "is_main": true
22
+ }
23
+ ]
24
+ },
25
+ "image": {
26
+ "id": "07C170D67C8EC776933FCFF1C299C1C5",
27
+ "name": "w2012r2datacenter64min"
28
+ },
29
+ "dvd": {
30
+ "id": "05F2EF8C89A12782B7DBE445256BD7A5",
31
+ "name": "centos7-64iso"
32
+ },
33
+ "snapshot": null,
34
+ "ips": [
35
+ {
36
+ "id": "696469547988D3945B3FE59DFCB93C90",
37
+ "ip": "10.4.141.161",
38
+ "type": "IPV4",
39
+ "reverse_dns": null,
40
+ "firewall_policy": null,
41
+ "load_balancers": []
42
+ }
43
+ ],
44
+ "alerts": {
45
+ "critical": [
46
+ {
47
+ "type": "agent",
48
+ "description": "MONITORING_AGENT_NOT_INSTALLED",
49
+ "date": "2015-05-07 09:56:13"
50
+ }
51
+ ]
52
+ },
53
+ "monitoring_policy": {
54
+ "id": "5DF232A92E9635249B8A4EB31C5B14F4",
55
+ "name": "My Monitoring Policy 1"
56
+ },
57
+ "private_networks": null
58
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": "E9E144DED84EAC9D97C1A022E0351024",
3
+ "name": "New private network 1",
4
+ "description": null,
5
+ "network_address": null,
6
+ "subnet_mask": null,
7
+ "state": "CONFIGURING",
8
+ "creation_date": "2015-05-06T11:34:41+00:00",
9
+ "servers": [
10
+ {
11
+ "id": "92AA60BEC8333A21EDB9EAAA61852860",
12
+ "name": "My monitoring policy"
13
+ }
14
+ ],
15
+ "cloudpanel_id": "pn8962D_1"
16
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "id": "4B86A3ACC4CEB7A89E012E49FC17F312",
3
+ "cloudpanel_id": "FE7ED7D",
4
+ "name": "My Server remame",
5
+ "description": "My server rename description",
6
+ "creation_date": "2015-05-07T08:25:37+00:00",
7
+ "first_password": null,
8
+ "status": {
9
+ "state": "CONFIGURING",
10
+ "percent": null
11
+ },
12
+ "hardware": {
13
+ "fixed_instance_size_id": 0,
14
+ "vcore": 2,
15
+ "cores_per_processor": 1,
16
+ "ram": 2,
17
+ "hdds": [
18
+ {
19
+ "id": "0DDE06DFA47743DF928E76AE7DC195C1",
20
+ "size": 40,
21
+ "is_main": true
22
+ },
23
+ {
24
+ "id": "531CE4594248FAF91B1164B05BFB152C",
25
+ "size": 40,
26
+ "is_main": false
27
+ }
28
+ ]
29
+ },
30
+ "image": {
31
+ "id": "15287F3524A6D41E0A03E951D64960E3",
32
+ "name": "w2012r2datacenter64iso"
33
+ },
34
+ "dvd": {
35
+ "id": "15287F3524A6D41E0A03E951D64960E3",
36
+ "name": "w2012r2datacenter64iso"
37
+ },
38
+ "snapshot": {
39
+ "id": "B198CE46BDE59DDCD15C352EF10EB0EA",
40
+ "creation_date": "2015-05-07T10:49:22+00:00"
41
+ },
42
+ "ips": [
43
+ {
44
+ "id": "D609028BC090EE05665072C721EA4A7A",
45
+ "ip": "10.4.141.43",
46
+ "type": "IPV4",
47
+ "reverse_dns": null,
48
+ "firewall_policy": null,
49
+ "load_balancers": []
50
+ }
51
+ ],
52
+ "alerts": [],
53
+ "monitoring_policy": null,
54
+ "private_networks": null
55
+ }
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "id": "C72CF0A681B0CCE7EC624DD194D585C6",
4
+ "name": "My Server",
5
+ "rights": "RW"
6
+ },
7
+ {
8
+ "id": "4ECD9D188EB457317B2CF8F07885E7B4",
9
+ "name": "My Server 2",
10
+ "rights": "R"
11
+ }
12
+ ]
@@ -0,0 +1,55 @@
1
+ require_relative '../lib/oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ class TestDvd < Minitest::Test
5
+ def setup
6
+
7
+ OneAndOne.start('TEST-API-KEY')
8
+ @dvd = OneAndOne::Dvd.new(test: true)
9
+
10
+ end
11
+
12
+
13
+ def test_list
14
+
15
+ # Read in mock JSON
16
+ file = File.read('mock-api/list-dvds.json')
17
+ data = JSON.parse(file)
18
+
19
+ # Create stub and perform call
20
+ Excon.stub({:method => :get, :path => '/v1/dvd_isos'},
21
+ {:body => JSON.generate(data), :status => 200})
22
+
23
+ response = @dvd.list
24
+
25
+ # Assertions
26
+ assert_equal response[0]['id'], data[0]['id']
27
+
28
+ # Clear out stubs
29
+ Excon.stubs.clear
30
+
31
+ end
32
+
33
+
34
+ def test_get
35
+
36
+ # Read in mock JSON
37
+ file = File.read('mock-api/get-dvd.json')
38
+ data = JSON.parse(file)
39
+
40
+ # Create stub and perform call
41
+ Excon.stub({:method => :get, :path => "/v1/dvd_isos/#{data['id']}"},
42
+ {:body => JSON.generate(data), :status => 200})
43
+
44
+ response = @dvd.get(dvd_id: data['id'])
45
+
46
+ # Assertions
47
+ assert_equal response['id'], data['id']
48
+
49
+ # Clear out stubs
50
+ Excon.stubs.clear
51
+
52
+ end
53
+
54
+
55
+ end
@@ -0,0 +1,309 @@
1
+ require_relative '../lib/oneandone'
2
+ require 'minitest/autorun'
3
+
4
+ class TestFirewall < Minitest::Test
5
+ def setup
6
+
7
+ OneAndOne.start('TEST-API-KEY')
8
+ @firewall = OneAndOne::Firewall.new(test: true)
9
+
10
+ end
11
+
12
+
13
+ def test_list
14
+
15
+ # Read in mock JSON
16
+ file = File.read('mock-api/list-firewalls.json')
17
+ data = JSON.parse(file)
18
+
19
+ # Create stub and perform call
20
+ Excon.stub({:method => :get, :path => '/v1/firewall_policies'},
21
+ {:body => JSON.generate(data), :status => 200})
22
+
23
+ response = @firewall.list
24
+
25
+ # Assertions
26
+ assert_equal response[0]['id'], data[0]['id']
27
+
28
+ # Clear out stubs
29
+ Excon.stubs.clear
30
+
31
+ end
32
+
33
+
34
+ def test_create
35
+
36
+ # Read in mock JSON
37
+ file = File.read('mock-api/create-fp.json')
38
+ data = JSON.parse(file)
39
+
40
+ # Create stub and perform call
41
+ Excon.stub({:method => :post, :path => '/v1/firewall_policies'},
42
+ {:body => JSON.generate(data), :status => 202})
43
+
44
+ rule1 = {
45
+ 'protocol' => 'TCP',
46
+ 'port_from' => 80,
47
+ 'port_to' => 80,
48
+ 'source' => '0.0.0.0'
49
+ }
50
+
51
+ rules = [rule1]
52
+
53
+ response = @firewall.create(name: 'Test', description: 'Test Desc',
54
+ rules: rules)
55
+
56
+ # Assertions
57
+ assert_equal response['id'], data['id']
58
+
59
+ # Clear out stubs
60
+ Excon.stubs.clear
61
+
62
+ end
63
+
64
+
65
+ def test_get
66
+
67
+ # Read in mock JSON
68
+ file = File.read('mock-api/get-firewall.json')
69
+ data = JSON.parse(file)
70
+
71
+ # Create stub and perform call
72
+ Excon.stub({:method => :get, :path => "/v1/firewall_policies/#{data['id']}"},
73
+ {:body => JSON.generate(data), :status => 200})
74
+
75
+ response = @firewall.get(firewall_id: data['id'])
76
+
77
+ # Assertions
78
+ assert_equal response['id'], data['id']
79
+
80
+ # Clear out stubs
81
+ Excon.stubs.clear
82
+
83
+ end
84
+
85
+
86
+ def test_modify
87
+
88
+ # Read in mock JSON
89
+ file = File.read('mock-api/modify-fp.json')
90
+ data = JSON.parse(file)
91
+
92
+ # Create stub and perform call
93
+ Excon.stub({:method => :put, :path => "/v1/firewall_policies/#{data['id']}"},
94
+ {:body => JSON.generate(data), :status => 202})
95
+
96
+ response = @firewall.modify(firewall_id: data['id'], name: 'New Name')
97
+
98
+ # Assertions
99
+ assert_equal response['id'], data['id']
100
+
101
+ # Clear out stubs
102
+ Excon.stubs.clear
103
+
104
+ end
105
+
106
+
107
+ def test_delete
108
+
109
+ # Read in mock JSON
110
+ file = File.read('mock-api/remove-firewall-policy.json')
111
+ data = JSON.parse(file)
112
+
113
+ # Create stub and perform call
114
+ Excon.stub({:method => :delete, :path => "/v1/firewall_policies/#{data['id']}"},
115
+ {:body => JSON.generate(data), :status => 202})
116
+
117
+ response = @firewall.delete(firewall_id: data['id'])
118
+
119
+ # Assertions
120
+ assert_equal response['state'], 'REMOVING'
121
+
122
+ # Clear out stubs
123
+ Excon.stubs.clear
124
+
125
+ end
126
+
127
+
128
+ def test_ips
129
+
130
+ # Read in mock JSON
131
+ file = File.read('mock-api/list-server-ips-fp.json')
132
+ data = JSON.parse(file)
133
+
134
+ # Create stub and perform call
135
+ Excon.stub({:method => :get, :path => "/v1/firewall_policies/FIREWALL-ID/server_ips"},
136
+ {:body => JSON.generate(data), :status => 200})
137
+
138
+ response = @firewall.ips(firewall_id: 'FIREWALL-ID')
139
+
140
+ # Assertions
141
+ assert_equal response[0]['id'], data[0]['id']
142
+
143
+ # Clear out stubs
144
+ Excon.stubs.clear
145
+
146
+ end
147
+
148
+
149
+ def test_ip
150
+
151
+ # Read in mock JSON
152
+ file = File.read('mock-api/get-server-ip-fp.json')
153
+ data = JSON.parse(file)
154
+
155
+ # Create stub and perform call
156
+ Excon.stub({:method => :get, :path => "/v1/firewall_policies/FIREWALL-ID/server_ips/#{data['id']}"},
157
+ {:body => JSON.generate(data), :status => 200})
158
+
159
+ response = @firewall.ip(firewall_id: 'FIREWALL-ID', ip_id: data['id'])
160
+
161
+ # Assertions
162
+ assert_equal response['id'], data['id']
163
+
164
+ # Clear out stubs
165
+ Excon.stubs.clear
166
+
167
+ end
168
+
169
+
170
+ def test_add_ips
171
+
172
+ # Read in mock JSON
173
+ file = File.read('mock-api/assign-ip-fp.json')
174
+ data = JSON.parse(file)
175
+
176
+ # Create stub and perform call
177
+ Excon.stub({:method => :post, :path => "/v1/firewall_policies/#{data['id']}/server_ips"},
178
+ {:body => JSON.generate(data), :status => 202})
179
+
180
+ ip1 = '<IP-ID>'
181
+
182
+ ips = [ip1]
183
+
184
+ response = @firewall.add_ips(firewall_id: data['id'], ips: ips)
185
+
186
+ # Assertions
187
+ assert_equal response['server_ips'][0]['id'], data['server_ips'][0]['id']
188
+
189
+ # Clear out stubs
190
+ Excon.stubs.clear
191
+
192
+ end
193
+
194
+
195
+ def test_remove_ip
196
+
197
+ # Read in mock JSON
198
+ file = File.read('mock-api/remove-ip-fp.json')
199
+ data = JSON.parse(file)
200
+
201
+ # Create stub and perform call
202
+ Excon.stub({:method => :delete, :path => "/v1/firewall_policies/#{data['id']}/server_ips/IP-ID"},
203
+ {:body => JSON.generate(data), :status => 202})
204
+
205
+ response = @firewall.remove_ip(firewall_id: data['id'], ip_id: 'IP-ID')
206
+
207
+ # Assertions
208
+ assert_equal response['server_ips'].length, 0
209
+
210
+ # Clear out stubs
211
+ Excon.stubs.clear
212
+
213
+ end
214
+
215
+
216
+ def test_rules
217
+
218
+ # Read in mock JSON
219
+ file = File.read('mock-api/list-fp-rules.json')
220
+ data = JSON.parse(file)
221
+
222
+ # Create stub and perform call
223
+ Excon.stub({:method => :get, :path => "/v1/firewall_policies/FIREWALL-ID/rules"},
224
+ {:body => JSON.generate(data), :status => 200})
225
+
226
+ response = @firewall.rules(firewall_id: 'FIREWALL-ID')
227
+
228
+ # Assertions
229
+ assert_equal response[0]['id'], data[0]['id']
230
+
231
+ # Clear out stubs
232
+ Excon.stubs.clear
233
+
234
+ end
235
+
236
+
237
+ def test_rule
238
+
239
+ # Read in mock JSON
240
+ file = File.read('mock-api/get-fp-rule.json')
241
+ data = JSON.parse(file)
242
+
243
+ # Create stub and perform call
244
+ Excon.stub({:method => :get, :path => "/v1/firewall_policies/FIREWALL-ID/rules/#{data['id']}"},
245
+ {:body => JSON.generate(data), :status => 200})
246
+
247
+ response = @firewall.rule(firewall_id: 'FIREWALL-ID', rule_id: data['id'])
248
+
249
+ # Assertions
250
+ assert_equal response['id'], data['id']
251
+
252
+ # Clear out stubs
253
+ Excon.stubs.clear
254
+
255
+ end
256
+
257
+
258
+ def test_add_rules
259
+
260
+ # Read in mock JSON
261
+ file = File.read('mock-api/add-rule-fp.json')
262
+ data = JSON.parse(file)
263
+
264
+ # Create stub and perform call
265
+ Excon.stub({:method => :post, :path => "/v1/firewall_policies/#{data['id']}/rules"},
266
+ {:body => JSON.generate(data), :status => 202})
267
+
268
+ rule2 = {
269
+ 'protocol' => 'TCP',
270
+ 'port_from' => 90,
271
+ 'port_to' => 90,
272
+ 'source' => '0.0.0.0'
273
+ }
274
+
275
+ rules = [rule2]
276
+
277
+ response = @firewall.add_rules(firewall_id: data['id'], rules: rules)
278
+
279
+ # Assertions
280
+ assert_equal response['rules'][1]['id'], data['rules'][1]['id']
281
+
282
+ # Clear out stubs
283
+ Excon.stubs.clear
284
+
285
+ end
286
+
287
+
288
+ def test_remove_rule
289
+
290
+ # Read in mock JSON
291
+ file = File.read('mock-api/delete-rule-fp.json')
292
+ data = JSON.parse(file)
293
+
294
+ # Create stub and perform call
295
+ Excon.stub({:method => :delete, :path => "/v1/firewall_policies/#{data['id']}/rules/RULE-ID"},
296
+ {:body => JSON.generate(data), :status => 202})
297
+
298
+ response = @firewall.remove_rule(firewall_id: data['id'], rule_id: 'RULE-ID')
299
+
300
+ # Assertions
301
+ assert_equal response['rules'].length, 2
302
+
303
+ # Clear out stubs
304
+ Excon.stubs.clear
305
+
306
+ end
307
+
308
+
309
+ end