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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f4f61295cd73ab6c5843c161f1506d96bda783c
4
+ data.tar.gz: 12585e2d0d0d113fd454f7ceed40f954d28c6748
5
+ SHA512:
6
+ metadata.gz: 78c11a5c45b3f4399932c8ebdfcd3acd7847627234d9ce7926e36b93b8d41da09438329655ca13796247558609e6c1e620179a6d4d81b05dcef972ecbca2a854
7
+ data.tar.gz: 302d321a1ab57d06cd45682f8ddff2a1701cd7688e3acbd7a5b7b78adf4113252efd1f5a1698e10e7d53faf7d2f1051d4e7daa065182ec43ced35924d8f6cf35
@@ -0,0 +1,2 @@
1
+
2
+ .DS_Store
Binary file
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "1and1"
7
+ spec.version = "1.1"
8
+ spec.authors = ["Tyler Burkhardt (stackpointcloud.com)"]
9
+ spec.email = "tyler@stackpointcloud.com"
10
+ spec.summary = "Official 1&1 SDK for Ruby"
11
+ spec.description = "The 1&1 SDK for Ruby provides integration with the 1&1 cloud environment over the available REST API."
12
+ spec.homepage = "https://github.com/StackPointCloud/oneandone-cloudserver-sdk-ruby"
13
+ spec.license = "Apache 2.0"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_runtime_dependency "excon", "~> 0.44"
19
+ spec.add_runtime_dependency "json", "~> 1.8"
20
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in 1and1.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2016 1&1 Internet SE
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,499 @@
1
+ # 1&1 Ruby SDK
2
+
3
+ The 1&1 Ruby SDK is a Ruby gem used for interacting with the 1&1 platform over the REST API.
4
+
5
+ This guide will show you how to programmatically use the 1&1 library to perform common management tasks also available through the 1&1 Control Panel.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Getting Started](#getting-started)
11
+ * [Installation](#installation)
12
+ * [Authentication](#authentication)
13
+ - [Operations](#operations)
14
+ - [Using the Module](#using-the-module)
15
+ - [Creating a Server](#creating-a-server)
16
+ - [Creating a Server with SSH Key Access](#creating-a-server-with-ssh-key-access)
17
+ - [Creating a Firewall Policy](#creating-a-firewall-policy)
18
+ - [Creating a Load Balancer](#creating-a-load-balancer)
19
+ - [Creating a Monitoring Policy](#creating-a-monitoring-policy)
20
+ - [Updating Server Cores, Memory, and Disk](#updating-server-cores,-memory,-and-disk)
21
+ - [Listing Servers, Images, Shared Storages, and More](#listing-servers,-images,-shared-storages,-and-more )
22
+ - [Example App](#example-app)
23
+
24
+
25
+ ## Overview
26
+
27
+ The Ruby Client Library wraps the latest version of the 1&1 REST API. All API operations are performed over SSL and authenticated using your 1&1 API Token. The API can be accessed within an instance running in 1&1 or directly over the Internet from any application that can send an HTTPS request and receive an HTTPS response.
28
+
29
+
30
+ ## Getting Started
31
+
32
+ Before you begin you will need to have signed-up for a 1&1 account. The credentials you setup during sign-up will be used to authenticate against the API.
33
+
34
+
35
+ ### Installation
36
+
37
+ You can install the latest stable version using:
38
+
39
+ `$ gem install 1and1`
40
+
41
+
42
+ ### Authentication
43
+
44
+ Connecting to 1&1 is handled by first setting up your authentication. Start your application by initializing the module with your API token.
45
+
46
+ ```
47
+ require 'oneandone'
48
+
49
+ OneAndOne.start('<API-TOKEN>')
50
+ ```
51
+
52
+
53
+ ## Operations
54
+
55
+ ### Using the Module
56
+
57
+ Official 1&amp;1 REST API Documentation: <a href='https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html' target='_blank'>https://cloudpanel-api.1and1.com/documentation/v1/#</a>
58
+
59
+ The following examples are meant to give you a general overview of some of the things you can do with the 1&amp;1 Ruby SDK. For a detailed list of all methods and functionality, please visit the <a href='docs/reference.md'>reference.md</a> file.
60
+
61
+
62
+
63
+
64
+ ### Creating a Server
65
+
66
+ ```
67
+ require 'oneandone'
68
+
69
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
70
+
71
+
72
+ # Instantiate Server Object
73
+ server = OneAndOne::Server.new
74
+
75
+ # Create HDD's
76
+ hdd1 = {
77
+ 'size' => 120,
78
+ 'is_main' => true
79
+ }
80
+
81
+ hdds = [hdd1]
82
+
83
+ # Perform Request
84
+ response = server.create(name: 'Example Server',
85
+ vcore: 1,
86
+ cores_per_processor: 1,
87
+ ram: 1,
88
+ appliance_id: '<IMAGE-ID>',
89
+ hdds: hdds)
90
+
91
+ puts JSON.pretty_generate(response)
92
+ ```
93
+
94
+
95
+ ### Creating a Server with SSH Key Access
96
+
97
+ ```
98
+ require 'oneandone'
99
+
100
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
101
+
102
+
103
+ # Instantiate Server Object
104
+ server = OneAndOne::Server.new
105
+
106
+ # Create HDD's
107
+ hdd1 = {
108
+ 'size' => 120,
109
+ 'is_main' => true
110
+ }
111
+
112
+ hdds = [hdd1]
113
+
114
+ # Assign your public key to a variable
115
+ pub_key = '<PUB-KEY>'
116
+
117
+ # Perform Request
118
+ response = server.create(name: 'Example Server',
119
+ vcore: 1,
120
+ cores_per_processor: 1,
121
+ ram: 1,
122
+ appliance_id: '<IMAGE-ID>',
123
+ hdds: hdds,
124
+ rsa_key: pub_key)
125
+
126
+ puts JSON.pretty_generate(response)
127
+ ```
128
+ **Note:** You may then SSH into your server by executing the following command in terminal
129
+
130
+ `ssh –i <path_to_private_key_file> root@SERVER_IP`
131
+
132
+
133
+ ### Creating a Firewall Policy
134
+
135
+ ```
136
+ require 'oneandone'
137
+
138
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
139
+
140
+
141
+ # Instantiate Firewall Object
142
+ firewall = OneAndOne::Firewall.new
143
+
144
+ # Create Rules
145
+ rule1 = {
146
+ 'protocol' => 'TCP',
147
+ 'port_from' => 80,
148
+ 'port_to' => 80,
149
+ 'source' => '0.0.0.0'
150
+ }
151
+
152
+ rules = [rule1]
153
+
154
+ # Perform Request
155
+ response = firewall.create(name: 'Test Firewall',
156
+ description: 'Example Desc',
157
+ rules: rules)
158
+
159
+ puts JSON.pretty_generate(response)
160
+ ```
161
+
162
+
163
+ ### Creating a Load Balancer
164
+
165
+ ```
166
+ require 'oneandone'
167
+
168
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
169
+
170
+
171
+ # Instantiate Load Balancer Object
172
+ load_balancer = OneAndOne::LoadBalancer.new
173
+
174
+ # Create Rules
175
+ rule1 = {
176
+ 'protocol' => 'TCP',
177
+ 'port_balancer' => 80,
178
+ 'port_server' => 80,
179
+ 'source' => '0.0.0.0'
180
+ }
181
+
182
+ rules = [rule1]
183
+
184
+ # Perform Request
185
+ response = load_balancer.create(name: 'Test LB',
186
+ description: 'Example Desc',
187
+ health_check_test: 'TCP',
188
+ health_check_interval: 40,
189
+ persistence: true,
190
+ persistence_time: 1200,
191
+ method: 'ROUND_ROBIN',
192
+ rules: rules)
193
+
194
+ puts JSON.pretty_generate(response)
195
+ ```
196
+
197
+
198
+ ### Creating a Monitoring Policy
199
+
200
+ ```
201
+ require 'oneandone'
202
+
203
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
204
+
205
+
206
+ # Instantiate Monitoring Policy Object
207
+ monitoring_policy = OneAndOne::MonitoringPolicy.new
208
+
209
+ # Create Threshold Limits
210
+ thresholds = {
211
+ 'cpu' => {
212
+ 'warning' => {
213
+ 'value' => 90,
214
+ 'alert' => false
215
+ },
216
+ 'critical' => {
217
+ 'value' => 95,
218
+ 'alert' => false
219
+ }
220
+ },
221
+ 'ram' => {
222
+ 'warning' => {
223
+ 'value' => 90,
224
+ 'alert' => false
225
+ },
226
+ 'critical' => {
227
+ 'value' => 95,
228
+ 'alert' => false
229
+ }
230
+ },
231
+ 'disk' => {
232
+ 'warning' => {
233
+ 'value' => 90,
234
+ 'alert' => false
235
+ },
236
+ 'critical' => {
237
+ 'value' => 95,
238
+ 'alert' => false
239
+ }
240
+ },
241
+ 'transfer' => {
242
+ 'warning' => {
243
+ 'value' => 1000,
244
+ 'alert' => false
245
+ },
246
+ 'critical' => {
247
+ 'value' => 2000,
248
+ 'alert' => false
249
+ }
250
+ },
251
+ 'internal_ping' => {
252
+ 'warning' => {
253
+ 'value' => 50,
254
+ 'alert' => false
255
+ },
256
+ 'critical' => {
257
+ 'value' => 100,
258
+ 'alert' => false
259
+ }
260
+ }
261
+ }
262
+
263
+ # Create Ports
264
+ port1 = {
265
+ 'protocol' => 'TCP',
266
+ 'port' => 80,
267
+ 'alert_if' => 'NOT_RESPONDING',
268
+ 'email_notification' => true
269
+ }
270
+
271
+ ports = [port1]
272
+
273
+ # Create Processes
274
+ process1 = {
275
+ 'process' => 'test',
276
+ 'alert_if' => 'NOT_RUNNING',
277
+ 'email_notification' => true
278
+ }
279
+
280
+ processes = [process1]
281
+
282
+ # Perform Request
283
+ response = monitoring_policy.create(name: 'Test Monitoring Policy',
284
+ email: 'test@example.com',
285
+ agent: true,
286
+ thresholds: thresholds,
287
+ ports: ports,
288
+ processes: processes)
289
+
290
+ puts JSON.pretty_generate(response)
291
+ ```
292
+
293
+ Then, add a server or two:
294
+ ```
295
+ # Add Servers
296
+ server1 = '<SERVER-ID>'
297
+ server2 = '<SERVER-ID>'
298
+
299
+ servers = [server1, server2]
300
+
301
+ # Perform Request
302
+ response = monitoring_policy.add_servers(servers: servers)
303
+
304
+ puts JSON.pretty_generate(response)
305
+ ```
306
+
307
+
308
+ ### Updating Server Cores, Memory, and Disk
309
+
310
+ 1&amp;1 allows users to dynamically update cores, memory, and disk independently of each other. This removes the restriction of needing to upgrade to the next size up to receive an increase in memory. You can now simply increase the instances memory keeping your costs in-line with your resource needs.
311
+
312
+ The following code illustrates how you can update cores and memory:
313
+ ```
314
+ require 'oneandone'
315
+
316
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
317
+
318
+
319
+ # Instantiate Server Object
320
+ server = OneAndOne::Server.new
321
+
322
+ # Perform Request
323
+ response = server.modify_hardware(server_id: '<SERVER-ID>',
324
+ vcore: 2,
325
+ ram: 6)
326
+
327
+ puts JSON.pretty_generate(response)
328
+ ```
329
+
330
+ This is how you would update a server disk's size:
331
+ ```
332
+ require 'oneandone'
333
+
334
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
335
+
336
+
337
+ # Instantiate Server Object
338
+ server = OneAndOne::Server.new
339
+
340
+ # Perform Request
341
+ response = server.modify_hdd(server_id: '<SERVER-ID>',
342
+ hdd_id: '<HDD-ID>',
343
+ size: 140)
344
+
345
+ puts JSON.pretty_generate(response)
346
+ ```
347
+
348
+
349
+ ### Listing Servers, Images, Shared Storages, and More
350
+
351
+ Generating a list of resources is fairly straight forward. Every class in the module comes equipped with a `list` method. You may pass optional query parameters to help filter your results. By default, these parameters are all set to `nil`.
352
+
353
+ **Here are the parameters available to you:**
354
+
355
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-`page` (integer): Allows to the use of pagination. Indicate which page to start on.
356
+
357
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-`per_page` (integer): Number of items per page.
358
+
359
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-`sort` (string): `sort='name'` retrieves a list of elements sorted alphabetically. `sort='creation_date'` retrieves a list of elements sorted by their creation date in descending order.
360
+
361
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-`q` (string): `q` is for query. Use this parameter to return only the items that match your search query.
362
+
363
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-`fields` (string): Returns only the parameters requested. (i.e. fields='id, name, description, hardware.ram')
364
+
365
+
366
+ **Here are a few examples of how you would list resources:**
367
+ ```
368
+ require 'oneandone'
369
+
370
+ OneAndOne.start('<API-TOKEN>') # Init module with API Key
371
+
372
+
373
+ # List all servers on your account
374
+ server = OneAndOne::Server.new
375
+
376
+ response = server.list
377
+
378
+
379
+ # List all servers whose name contains "My"
380
+ server = OneAndOne::Server.new
381
+
382
+ response = server.list(q: 'My')
383
+
384
+
385
+ # List all images on your account
386
+ image = OneAndOne::Image.new
387
+
388
+ response = image.list
389
+ ```
390
+
391
+
392
+
393
+ ## Example App
394
+
395
+ This simple app creates a load balancer, firewall policy, and server. It then adds the load balancer and firewall policy to the server's initial IP address. You can access a server's initial IP by using the `first_ip` attribute on the Server class object, as seen in the example below.
396
+
397
+ The source code for the Example App can be found <a href='examples/example_app.rb'>here</a>.
398
+ ```
399
+ require 'oneandone'
400
+
401
+ OneAndOne.start('<API-TOKEN>') # Init module with API key
402
+
403
+
404
+
405
+ ### Create load balancer
406
+ load_balancer = OneAndOne::LoadBalancer.new
407
+
408
+ rule1 = {
409
+ 'protocol' => 'TCP',
410
+ 'port_balancer' => 80,
411
+ 'port_server' => 80,
412
+ 'source' => '0.0.0.0'
413
+ }
414
+
415
+ rules = [rule1]
416
+
417
+ lb1 = load_balancer.create(name: 'Example App LB', description: 'Example Desc',
418
+ health_check_test: 'TCP', health_check_interval: 40, persistence: true,
419
+ persistence_time: 1200, method: 'ROUND_ROBIN', rules: rules)
420
+
421
+ # Wait for load balancer to deploy
422
+ puts "\nCreating load balancer...\n"
423
+ puts load_balancer.wait_for
424
+
425
+
426
+
427
+ ### Create firewall policy
428
+ firewall = OneAndOne::Firewall.new
429
+
430
+ rule1 = {
431
+ 'protocol' => 'TCP',
432
+ 'port_from' => 80,
433
+ 'port_to' => 80,
434
+ 'source' => '0.0.0.0'
435
+ }
436
+
437
+ rules = [rule1]
438
+
439
+ fp1 = firewall.create(name: 'Example App Firewall', description: 'Example Desc',
440
+ rules: rules)
441
+
442
+ # Wait for firewall policy to deploy
443
+ puts "\nCreating firewall policy...\n"
444
+ puts firewall.wait_for
445
+
446
+
447
+
448
+ ### Create a server
449
+ server = OneAndOne::Server.new
450
+
451
+ server1 = server.create(name: 'Example App Server',
452
+ fixed_instance_id: '65929629F35BBFBA63022008F773F3EB',
453
+ appliance_id: '6C902E5899CC6F7ED18595EBEB542EE1',
454
+ datacenter_id: '5091F6D8CBFEF9C26ACE957C652D5D49')
455
+
456
+ # Wait for server to deploy
457
+ puts "\nCreating server...\n"
458
+ puts server.wait_for
459
+
460
+
461
+
462
+ ### Add the load balancer to the server's initial IP
463
+ response = server.add_load_balancer(ip_id: server.first_ip['id'],
464
+ load_balancer_id: load_balancer.id)
465
+
466
+ # Wait for load balancer to be added
467
+ puts "\nAdding load balancer to server IP...\n"
468
+ puts server.wait_for
469
+
470
+
471
+
472
+ ### Add the firewall policy to the server's initial IP
473
+ response = server.add_firewall(ip_id: server.first_ip['id'],
474
+ firewall_id: firewall.id)
475
+
476
+ # Wait for firewall policy to be added
477
+ puts "\nAdding firewall policy to server IP...\n"
478
+ puts server.wait_for
479
+ puts "\nEverything looks good!"
480
+
481
+
482
+
483
+ ### Cleanup
484
+ puts "\nLet's clean up the mess we just made.\n"
485
+
486
+ puts "\nDeleting server...\n"
487
+ server.delete
488
+ puts "Success!\n"
489
+
490
+ puts "\nDeleting firewall policy...\n"
491
+ firewall.delete
492
+ puts "Success!\n"
493
+
494
+ puts "\nDeleting load balancer...\n"
495
+ load_balancer.delete
496
+ puts "Success!\n"
497
+
498
+ puts "\nAll done!\n"
499
+ ```