vultr 0.4.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +38 -0
  3. data/.standard.yml +1 -0
  4. data/Appraisals +8 -0
  5. data/CHANGELOG.md +9 -0
  6. data/Gemfile +6 -10
  7. data/README.md +307 -137
  8. data/Rakefile +10 -6
  9. data/bin/console +21 -0
  10. data/bin/setup +8 -0
  11. data/bin/test +6 -0
  12. data/gemfiles/faraday_1.gemfile +12 -0
  13. data/gemfiles/faraday_1.gemfile.lock +102 -0
  14. data/gemfiles/faraday_2.gemfile +11 -0
  15. data/gemfiles/faraday_2.gemfile.lock +82 -0
  16. data/lib/vultr/client.rb +111 -0
  17. data/lib/vultr/collection.rb +22 -0
  18. data/lib/vultr/error.rb +4 -0
  19. data/lib/vultr/middleware.rb +32 -0
  20. data/lib/vultr/object.rb +19 -0
  21. data/lib/vultr/objects/account.rb +4 -0
  22. data/lib/vultr/objects/application.rb +4 -0
  23. data/lib/vultr/objects/backup.rb +4 -0
  24. data/lib/vultr/objects/bare_metal.rb +4 -0
  25. data/lib/vultr/objects/block_storage.rb +4 -0
  26. data/lib/vultr/objects/domain.rb +4 -0
  27. data/lib/vultr/objects/firewall_group.rb +4 -0
  28. data/lib/vultr/objects/instance.rb +4 -0
  29. data/lib/vultr/objects/iso.rb +4 -0
  30. data/lib/vultr/objects/kubernetes_cluster.rb +4 -0
  31. data/lib/vultr/objects/load_balancer.rb +4 -0
  32. data/lib/vultr/objects/object_storage.rb +4 -0
  33. data/lib/vultr/objects/operating_system.rb +4 -0
  34. data/lib/vultr/objects/plan.rb +4 -0
  35. data/lib/vultr/objects/private_network.rb +4 -0
  36. data/lib/vultr/objects/region.rb +4 -0
  37. data/lib/vultr/objects/reserved_ip.rb +4 -0
  38. data/lib/vultr/objects/snapshot.rb +4 -0
  39. data/lib/vultr/objects/ssh_key.rb +4 -0
  40. data/lib/vultr/objects/startup_script.rb +4 -0
  41. data/lib/vultr/objects/user.rb +4 -0
  42. data/lib/vultr/resource.rb +52 -0
  43. data/lib/vultr/resources/account.rb +7 -0
  44. data/lib/vultr/resources/applications.rb +8 -0
  45. data/lib/vultr/resources/backups.rb +12 -0
  46. data/lib/vultr/resources/bare_metal.rb +79 -0
  47. data/lib/vultr/resources/block_storage.rb +32 -0
  48. data/lib/vultr/resources/dns.rb +58 -0
  49. data/lib/vultr/resources/firewall.rb +42 -0
  50. data/lib/vultr/resources/instances.rb +145 -0
  51. data/lib/vultr/resources/iso.rb +25 -0
  52. data/lib/vultr/resources/kubernetes.rb +61 -0
  53. data/lib/vultr/resources/load_balancers.rb +50 -0
  54. data/lib/vultr/resources/object_storage.rb +33 -0
  55. data/lib/vultr/resources/operating_systems.rb +8 -0
  56. data/lib/vultr/resources/plans.rb +13 -0
  57. data/lib/vultr/resources/private_networks.rb +24 -0
  58. data/lib/vultr/resources/regions.rb +12 -0
  59. data/lib/vultr/resources/reserved_ips.rb +32 -0
  60. data/lib/vultr/resources/snapshots.rb +28 -0
  61. data/lib/vultr/resources/ssh_keys.rb +24 -0
  62. data/lib/vultr/resources/startup_scripts.rb +24 -0
  63. data/lib/vultr/resources/users.rb +24 -0
  64. data/lib/vultr/version.rb +1 -8
  65. data/lib/vultr.rb +58 -887
  66. data/test/fixtures/account/info.json +11 -0
  67. data/test/fixtures/applications/list.json +29 -0
  68. data/test/fixtures/backups/list.json +18 -0
  69. data/test/fixtures/backups/retrieve.json +9 -0
  70. data/test/fixtures/bare_metals/bandwidth.json +12 -0
  71. data/test/fixtures/bare_metals/create.json +26 -0
  72. data/test/fixtures/bare_metals/list.json +36 -0
  73. data/test/fixtures/bare_metals/list_ipv4.json +18 -0
  74. data/test/fixtures/bare_metals/list_ipv6.json +17 -0
  75. data/test/fixtures/bare_metals/reinstall.json +25 -0
  76. data/test/fixtures/bare_metals/retrieve.json +26 -0
  77. data/test/fixtures/bare_metals/update.json +26 -0
  78. data/test/fixtures/bare_metals/upgrades.json +47 -0
  79. data/test/fixtures/bare_metals/user_data.json +5 -0
  80. data/test/fixtures/bare_metals/vnc.json +5 -0
  81. data/test/fixtures/block_storage/attach.json +4 -0
  82. data/test/fixtures/block_storage/create.json +13 -0
  83. data/test/fixtures/block_storage/detach.json +4 -0
  84. data/test/fixtures/block_storage/list.json +22 -0
  85. data/test/fixtures/block_storage/retrieve.json +13 -0
  86. data/test/fixtures/domains/create.json +6 -0
  87. data/test/fixtures/domains/dnssec.json +7 -0
  88. data/test/fixtures/domains/list.json +15 -0
  89. data/test/fixtures/domains/record.json +10 -0
  90. data/test/fixtures/domains/records.json +19 -0
  91. data/test/fixtures/domains/retrieve.json +6 -0
  92. data/test/fixtures/domains/soa.json +6 -0
  93. data/test/fixtures/firewall/create.json +11 -0
  94. data/test/fixtures/firewall/create_rule.json +9 -0
  95. data/test/fixtures/firewall/delete.json +1 -0
  96. data/test/fixtures/firewall/delete_rule.json +1 -0
  97. data/test/fixtures/firewall/list.json +20 -0
  98. data/test/fixtures/firewall/list_rules.json +22 -0
  99. data/test/fixtures/firewall/retrieve.json +11 -0
  100. data/test/fixtures/firewall/retrieve_rule.json +13 -0
  101. data/test/fixtures/firewall/update.json +1 -0
  102. data/test/fixtures/instances/attach_iso.json +6 -0
  103. data/test/fixtures/instances/attach_private_network.json +1 -0
  104. data/test/fixtures/instances/backup_schedule.json +10 -0
  105. data/test/fixtures/instances/bandwidth.json +12 -0
  106. data/test/fixtures/instances/create.json +36 -0
  107. data/test/fixtures/instances/create_ipv4_reverse.json +1 -0
  108. data/test/fixtures/instances/create_ipv6_reverse.json +1 -0
  109. data/test/fixtures/instances/delete.json +1 -0
  110. data/test/fixtures/instances/delete_ipv4.json +1 -0
  111. data/test/fixtures/instances/delete_ipv6.json +1 -0
  112. data/test/fixtures/instances/detach_iso.json +5 -0
  113. data/test/fixtures/instances/detach_private_network.json +1 -0
  114. data/test/fixtures/instances/halt.json +1 -0
  115. data/test/fixtures/instances/halt_instances.json +1 -0
  116. data/test/fixtures/instances/ipv4.json +9 -0
  117. data/test/fixtures/instances/ipv6_reverse.json +15 -0
  118. data/test/fixtures/instances/iso.json +6 -0
  119. data/test/fixtures/instances/list.json +44 -0
  120. data/test/fixtures/instances/list_ipv4.json +32 -0
  121. data/test/fixtures/instances/list_ipv6.json +17 -0
  122. data/test/fixtures/instances/list_private_networks.json +16 -0
  123. data/test/fixtures/instances/neighbors.json +6 -0
  124. data/test/fixtures/instances/reboot.json +1 -0
  125. data/test/fixtures/instances/reboot_instances.json +1 -0
  126. data/test/fixtures/instances/reinstall.json +35 -0
  127. data/test/fixtures/instances/restore.json +7 -0
  128. data/test/fixtures/instances/retrieve.json +35 -0
  129. data/test/fixtures/instances/set_backup_schedule.json +1 -0
  130. data/test/fixtures/instances/set_default_reverse_dns_entry.json +1 -0
  131. data/test/fixtures/instances/start.json +1 -0
  132. data/test/fixtures/instances/start_instances.json +1 -0
  133. data/test/fixtures/instances/update.json +1 -0
  134. data/test/fixtures/instances/upgrades.json +55 -0
  135. data/test/fixtures/instances/user_data.json +5 -0
  136. data/test/fixtures/isos/create.json +8 -0
  137. data/test/fixtures/isos/list.json +20 -0
  138. data/test/fixtures/isos/list_public.json +17 -0
  139. data/test/fixtures/isos/retrieve.json +11 -0
  140. data/test/fixtures/kubernetes/config.json +3 -0
  141. data/test/fixtures/kubernetes/create.json +39 -0
  142. data/test/fixtures/kubernetes/create_node_pool.json +25 -0
  143. data/test/fixtures/kubernetes/list.json +85 -0
  144. data/test/fixtures/kubernetes/list_node_pools.json +56 -0
  145. data/test/fixtures/kubernetes/list_resources.json +26 -0
  146. data/test/fixtures/kubernetes/retrieve.json +39 -0
  147. data/test/fixtures/kubernetes/retrieve_node_pool.json +25 -0
  148. data/test/fixtures/kubernetes/update_node_pool.json +19 -0
  149. data/test/fixtures/load_balancers/create.json +48 -0
  150. data/test/fixtures/load_balancers/create_forwarding_rule.json +1 -0
  151. data/test/fixtures/load_balancers/delete.json +1 -0
  152. data/test/fixtures/load_balancers/delete_forwarding_rule.json +1 -0
  153. data/test/fixtures/load_balancers/list.json +57 -0
  154. data/test/fixtures/load_balancers/list_firewall_rules.json +17 -0
  155. data/test/fixtures/load_balancers/list_forwarding_rules.json +18 -0
  156. data/test/fixtures/load_balancers/retrieve.json +48 -0
  157. data/test/fixtures/load_balancers/retrieve_firewall_rule.json +8 -0
  158. data/test/fixtures/load_balancers/retrieve_forwarding_rule.json +9 -0
  159. data/test/fixtures/load_balancers/update.json +1 -0
  160. data/test/fixtures/object_storage/create.json +14 -0
  161. data/test/fixtures/object_storage/delete.json +1 -0
  162. data/test/fixtures/object_storage/list.json +22 -0
  163. data/test/fixtures/object_storage/list_clusters.json +17 -0
  164. data/test/fixtures/object_storage/regenerate_keys.json +7 -0
  165. data/test/fixtures/object_storage/retrieve.json +13 -0
  166. data/test/fixtures/object_storage/update.json +1 -0
  167. data/test/fixtures/operating_systems/list.json +17 -0
  168. data/test/fixtures/plans/list.json +22 -0
  169. data/test/fixtures/plans/list_metal.json +24 -0
  170. data/test/fixtures/private_networks/create.json +10 -0
  171. data/test/fixtures/private_networks/delete.json +1 -0
  172. data/test/fixtures/private_networks/list.json +19 -0
  173. data/test/fixtures/private_networks/retrieve.json +10 -0
  174. data/test/fixtures/private_networks/update.json +1 -0
  175. data/test/fixtures/regions/list.json +20 -0
  176. data/test/fixtures/regions/list_availability.json +24 -0
  177. data/test/fixtures/reserved_ips/attach.json +1 -0
  178. data/test/fixtures/reserved_ips/convert.json +11 -0
  179. data/test/fixtures/reserved_ips/create.json +11 -0
  180. data/test/fixtures/reserved_ips/delete.json +1 -0
  181. data/test/fixtures/reserved_ips/detach.json +1 -0
  182. data/test/fixtures/reserved_ips/list.json +29 -0
  183. data/test/fixtures/reserved_ips/retrieve.json +11 -0
  184. data/test/fixtures/snapshots/create.json +11 -0
  185. data/test/fixtures/snapshots/create_from_url.json +11 -0
  186. data/test/fixtures/snapshots/delete.json +1 -0
  187. data/test/fixtures/snapshots/list.json +20 -0
  188. data/test/fixtures/snapshots/retrieve.json +11 -0
  189. data/test/fixtures/snapshots/update.json +1 -0
  190. data/test/fixtures/ssh_keys/create.json +8 -0
  191. data/test/fixtures/ssh_keys/delete.json +1 -0
  192. data/test/fixtures/ssh_keys/list.json +17 -0
  193. data/test/fixtures/ssh_keys/retrieve.json +8 -0
  194. data/test/fixtures/ssh_keys/update.json +1 -0
  195. data/test/fixtures/startup_scripts/create.json +10 -0
  196. data/test/fixtures/startup_scripts/delete.json +1 -0
  197. data/test/fixtures/startup_scripts/list.json +18 -0
  198. data/test/fixtures/startup_scripts/retrieve.json +10 -0
  199. data/test/fixtures/startup_scripts/update.json +1 -0
  200. data/test/fixtures/users/create.json +9 -0
  201. data/test/fixtures/users/delete.json +1 -0
  202. data/test/fixtures/users/list.json +29 -0
  203. data/test/fixtures/users/retrieve.json +20 -0
  204. data/test/fixtures/users/update.json +1 -0
  205. data/test/test_helper.rb +18 -5
  206. data/test/vultr/client_test.rb +8 -0
  207. data/test/vultr/object_test.rb +21 -0
  208. data/test/vultr/resources/account_test.rb +12 -0
  209. data/test/vultr/resources/applications_test.rb +15 -0
  210. data/test/vultr/resources/backups_test.rb +24 -0
  211. data/test/vultr/resources/bare_metal_test.rb +267 -0
  212. data/test/vultr/resources/block_storage_test.rb +85 -0
  213. data/test/vultr/resources/dns_test.rb +134 -0
  214. data/test/vultr/resources/firewall_test.rb +88 -0
  215. data/test/vultr/resources/instances_test.rb +325 -0
  216. data/test/vultr/resources/iso_test.rb +58 -0
  217. data/test/vultr/resources/kubernetes_test.rb +185 -0
  218. data/test/vultr/resources/load_balancers_test.rb +110 -0
  219. data/test/vultr/resources/object_storage_test.rb +71 -0
  220. data/test/vultr/resources/operating_systems_test.rb +15 -0
  221. data/test/vultr/resources/plans_test.rb +25 -0
  222. data/test/vultr/resources/private_networks_test.rb +50 -0
  223. data/test/vultr/resources/regions_test.rb +26 -0
  224. data/test/vultr/resources/reserved_ips_test.rb +67 -0
  225. data/test/vultr/resources/snapshots_test.rb +60 -0
  226. data/test/vultr/resources/ssh_keys_test.rb +50 -0
  227. data/test/vultr/resources/startup_scripts_test.rb +50 -0
  228. data/test/vultr/resources/users_test.rb +50 -0
  229. data/vultr.gemspec +15 -17
  230. metadata +237 -54
  231. data/.travis.yml +0 -26
  232. data/test/vultr/vultr_account_test.rb +0 -29
  233. data/test/vultr/vultr_app_test.rb +0 -26
  234. data/test/vultr/vultr_backup_test.rb +0 -22
  235. data/test/vultr/vultr_iso_test.rb +0 -27
  236. data/test/vultr/vultr_os_test.rb +0 -21
  237. data/test/vultr/vultr_plan_test.rb +0 -22
  238. data/test/vultr/vultr_region_test.rb +0 -33
  239. data/test/vultr/vultr_snapshot_test.rb +0 -30
  240. data/test/vultr/vultr_sshkey_test.rb +0 -50
  241. data/test/vultr/vultr_startupscript_test.rb +0 -53
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SnapshotsResourceTest < Minitest::Test
6
+ def test_list
7
+ stub = stub_request("snapshots", response: stub_response(fixture: "snapshots/list"))
8
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
9
+ snapshots = client.snapshots.list
10
+
11
+ assert_equal Vultr::Collection, snapshots.class
12
+ assert_equal Vultr::Snapshot, snapshots.data.first.class
13
+ assert_equal 1, snapshots.total
14
+ end
15
+
16
+ def test_create
17
+ body = {instance_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60", description: "Example Snapshot"}
18
+ stub = stub_request("snapshots", method: :post, body: body, response: stub_response(fixture: "snapshots/create", status: 201))
19
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
20
+ snapshot = client.snapshots.create(**body)
21
+
22
+ assert_equal Vultr::Snapshot, snapshot.class
23
+ assert_equal "Example Snapshot", snapshot.description
24
+ end
25
+
26
+ def test_retrieve
27
+ snapshot_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
28
+ stub = stub_request("snapshots/#{snapshot_id}", response: stub_response(fixture: "snapshots/retrieve"))
29
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
30
+ snapshot = client.snapshots.retrieve(snapshot_id: snapshot_id)
31
+
32
+ assert_equal Vultr::Snapshot, snapshot.class
33
+ assert_equal "Example Snapshot", snapshot.description
34
+ end
35
+
36
+ def test_create_from_url
37
+ body = {url: "http://example.com/disk_image.raw"}
38
+ stub = stub_request("snapshots/create-from-url", method: :post, body: body, response: stub_response(fixture: "snapshots/create_from_url"))
39
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
40
+ snapshot = client.snapshots.create_from_url(body[:url])
41
+
42
+ assert_equal Vultr::Snapshot, snapshot.class
43
+ assert_equal "Example Snapshot", snapshot.description
44
+ end
45
+
46
+ def test_update
47
+ snapshot_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
48
+ body = {description: "Changed"}
49
+ stub = stub_request("snapshots/#{snapshot_id}", method: :put, body: body, response: stub_response(fixture: "snapshots/update"))
50
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
51
+ assert client.snapshots.update(snapshot_id: snapshot_id, **body)
52
+ end
53
+
54
+ def test_delete
55
+ snapshot_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
56
+ stub = stub_request("snapshots/#{snapshot_id}", method: :delete, response: stub_response(fixture: "snapshots/delete"))
57
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
58
+ assert client.snapshots.delete(snapshot_id: snapshot_id)
59
+ end
60
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SshKeysResourceTest < Minitest::Test
6
+ def test_list
7
+ stub = stub_request("ssh-keys", response: stub_response(fixture: "ssh_keys/list"))
8
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
9
+ ssh_keys = client.ssh_keys.list
10
+
11
+ assert_equal Vultr::Collection, ssh_keys.class
12
+ assert_equal Vultr::SshKey, ssh_keys.data.first.class
13
+ assert_equal 1, ssh_keys.total
14
+ end
15
+
16
+ def test_create
17
+ body = {name: "Example SSH Key", ssh_key: "ssh-rsa AA... user@example.com"}
18
+ stub = stub_request("ssh-keys", method: :post, body: body, response: stub_response(fixture: "ssh_keys/create", status: 201))
19
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
20
+ ssh_key = client.ssh_keys.create(**body)
21
+
22
+ assert_equal Vultr::SshKey, ssh_key.class
23
+ assert_equal "Example SSH Key", ssh_key.name
24
+ end
25
+
26
+ def test_restrieve
27
+ ssh_key_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
28
+ stub = stub_request("ssh-keys/#{ssh_key_id}", response: stub_response(fixture: "ssh_keys/retrieve"))
29
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
30
+ ssh_key = client.ssh_keys.retrieve(ssh_key_id: ssh_key_id)
31
+
32
+ assert_equal Vultr::SshKey, ssh_key.class
33
+ assert_equal "Example SSH Key", ssh_key.name
34
+ end
35
+
36
+ def test_update
37
+ ssh_key_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
38
+ body = {name: "Changed"}
39
+ stub = stub_request("ssh-keys/#{ssh_key_id}", method: :patch, body: body, response: stub_response(fixture: "ssh_keys/update"))
40
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
41
+ assert client.ssh_keys.update(ssh_key_id: ssh_key_id, **body)
42
+ end
43
+
44
+ def test_delete
45
+ ssh_key_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
46
+ stub = stub_request("ssh-keys/#{ssh_key_id}", method: :delete, response: stub_response(fixture: "ssh_keys/delete"))
47
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
48
+ assert client.ssh_keys.delete(ssh_key_id: ssh_key_id)
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class StartupScriptsResourceTest < Minitest::Test
6
+ def test_list
7
+ stub = stub_request("startup-scripts", response: stub_response(fixture: "startup_scripts/list"))
8
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
9
+ startup_scripts = client.startup_scripts.list
10
+
11
+ assert_equal Vultr::Collection, startup_scripts.class
12
+ assert_equal Vultr::StartupScript, startup_scripts.data.first.class
13
+ assert_equal 1, startup_scripts.total
14
+ end
15
+
16
+ def test_create
17
+ body = {name: "Example Startup Script", type: "pxe", script: "QmFzZTY0IEV4YW1wbGUgRGF0YQ=="}
18
+ stub = stub_request("startup-scripts", method: :post, body: body, response: stub_response(fixture: "startup_scripts/create", status: 201))
19
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
20
+ startup_script = client.startup_scripts.create(**body)
21
+
22
+ assert_equal Vultr::StartupScript, startup_script.class
23
+ assert_equal "Example Startup Script", startup_script.name
24
+ end
25
+
26
+ def test_restrieve
27
+ startup_script_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
28
+ stub = stub_request("startup-scripts/#{startup_script_id}", response: stub_response(fixture: "startup_scripts/retrieve"))
29
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
30
+ startup_script = client.startup_scripts.retrieve(startup_script_id: startup_script_id)
31
+
32
+ assert_equal Vultr::StartupScript, startup_script.class
33
+ assert_equal "Example Startup Script", startup_script.name
34
+ end
35
+
36
+ def test_update
37
+ startup_script_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
38
+ body = {name: "Changed"}
39
+ stub = stub_request("startup-scripts/#{startup_script_id}", method: :patch, body: body, response: stub_response(fixture: "startup_scripts/update"))
40
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
41
+ assert client.startup_scripts.update(startup_script_id: startup_script_id, **body)
42
+ end
43
+
44
+ def test_delete
45
+ startup_script_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
46
+ stub = stub_request("startup-scripts/#{startup_script_id}", method: :delete, response: stub_response(fixture: "startup_scripts/delete"))
47
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
48
+ assert client.startup_scripts.delete(startup_script_id: startup_script_id)
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UsersResourceTest < Minitest::Test
6
+ def test_list
7
+ stub = stub_request("users", response: stub_response(fixture: "users/list"))
8
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
9
+ users = client.users.list
10
+
11
+ assert_equal Vultr::Collection, users.class
12
+ assert_equal Vultr::User, users.data.first.class
13
+ assert_equal 1, users.total
14
+ end
15
+
16
+ def test_create
17
+ body = {name: "Test user", email: "user@example.com", password: "password"}
18
+ stub = stub_request("users", method: :post, body: body, response: stub_response(fixture: "users/create", status: 201))
19
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
20
+ user = client.users.create(**body)
21
+
22
+ assert_equal Vultr::User, user.class
23
+ assert_equal "user@example.com", user.email
24
+ end
25
+
26
+ def test_retrieve
27
+ user_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
28
+ stub = stub_request("users/#{user_id}", response: stub_response(fixture: "users/retrieve"))
29
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
30
+ user = client.users.retrieve(user_id: user_id)
31
+
32
+ assert_equal Vultr::User, user.class
33
+ assert_equal "user@example.com", user.email
34
+ end
35
+
36
+ def test_update
37
+ user_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
38
+ body = {name: "Changed"}
39
+ stub = stub_request("users/#{user_id}", method: :patch, body: body, response: stub_response(fixture: "users/update"))
40
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
41
+ assert client.users.update(user_id: user_id, **body)
42
+ end
43
+
44
+ def test_delete
45
+ user_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
46
+ stub = stub_request("users/#{user_id}", method: :delete, response: stub_response(fixture: "users/delete"))
47
+ client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
48
+ assert client.users.delete(user_id: user_id)
49
+ end
50
+ end
data/vultr.gemspec CHANGED
@@ -1,26 +1,24 @@
1
1
  # Run `rake vultr.gemspec` to update the gemspec.
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'vultr/version'
5
+ require "vultr/version"
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = 'vultr'
9
- s.version = Vultr::VERSION::STRING
10
- s.authors = ['Gao Jiangmiao']
11
- s.email = ['tolbkni@gmail.com']
12
- s.summary = %q{Ruby bindings for VULTR API.}
13
- s.description = %q{Ruby bindings for VULTR API. VULTR APIs can be found here: https://www.vultr.com/api/}
14
- s.homepage = 'https://github.com/tolbkni/vultr.rb'
15
- s.license = 'MIT'
8
+ s.name = "vultr"
9
+ s.version = Vultr::VERSION
10
+ s.authors = ["Gao Jiangmiao", "Chris Oliver"]
11
+ s.email = ["tolbkni@gmail.com", "excid3@gmail.com"]
12
+ s.summary = "Ruby bindings for VULTR API."
13
+ s.description = "Ruby bindings for VULTR API. VULTR APIs can be found here: https://www.vultr.com/api/"
14
+ s.homepage = "https://github.com/tolbkni/vultr.rb"
15
+ s.license = "MIT"
16
16
 
17
- s.files = `git ls-files -z`.split("\x0")
18
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
- s.require_paths = ['lib']
17
+ s.files = `git ls-files -z`.split("\x0")
18
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
21
20
 
22
- s.required_ruby_version = '>= 1.9'
21
+ s.required_ruby_version = ">= 3.0"
23
22
 
24
- s.add_dependency 'faraday', '>= 0.12.0', '< 1.0'
25
- s.add_dependency 'faraday_middleware', '>= 0.12.0', '< 1.0'
23
+ s.add_dependency "faraday", ">= 1.0", "< 3.0"
26
24
  end
metadata CHANGED
@@ -1,88 +1,282 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vultr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gao Jiangmiao
8
- autorequire:
8
+ - Chris Oliver
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-10-09 00:00:00.000000000 Z
12
+ date: 2024-05-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: faraday
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.12.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '1.0'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.12.0
30
- - - "<"
31
19
  - !ruby/object:Gem::Version
32
20
  version: '1.0'
33
- - !ruby/object:Gem::Dependency
34
- name: faraday_middleware
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 0.12.0
40
21
  - - "<"
41
22
  - !ruby/object:Gem::Version
42
- version: '1.0'
23
+ version: '3.0'
43
24
  type: :runtime
44
25
  prerelease: false
45
26
  version_requirements: !ruby/object:Gem::Requirement
46
27
  requirements:
47
28
  - - ">="
48
29
  - !ruby/object:Gem::Version
49
- version: 0.12.0
30
+ version: '1.0'
50
31
  - - "<"
51
32
  - !ruby/object:Gem::Version
52
- version: '1.0'
33
+ version: '3.0'
53
34
  description: 'Ruby bindings for VULTR API. VULTR APIs can be found here: https://www.vultr.com/api/'
54
35
  email:
55
36
  - tolbkni@gmail.com
56
- executables: []
37
+ - excid3@gmail.com
38
+ executables:
39
+ - console
40
+ - setup
41
+ - test
57
42
  extensions: []
58
43
  extra_rdoc_files: []
59
44
  files:
45
+ - ".github/workflows/ci.yml"
60
46
  - ".gitignore"
61
- - ".travis.yml"
47
+ - ".standard.yml"
48
+ - Appraisals
62
49
  - CHANGELOG.md
63
50
  - Gemfile
64
51
  - LICENSE.txt
65
52
  - README.md
66
53
  - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - bin/test
57
+ - gemfiles/faraday_1.gemfile
58
+ - gemfiles/faraday_1.gemfile.lock
59
+ - gemfiles/faraday_2.gemfile
60
+ - gemfiles/faraday_2.gemfile.lock
67
61
  - lib/vultr.rb
62
+ - lib/vultr/client.rb
63
+ - lib/vultr/collection.rb
64
+ - lib/vultr/error.rb
65
+ - lib/vultr/middleware.rb
66
+ - lib/vultr/object.rb
67
+ - lib/vultr/objects/account.rb
68
+ - lib/vultr/objects/application.rb
69
+ - lib/vultr/objects/backup.rb
70
+ - lib/vultr/objects/bare_metal.rb
71
+ - lib/vultr/objects/block_storage.rb
72
+ - lib/vultr/objects/domain.rb
73
+ - lib/vultr/objects/firewall_group.rb
74
+ - lib/vultr/objects/instance.rb
75
+ - lib/vultr/objects/iso.rb
76
+ - lib/vultr/objects/kubernetes_cluster.rb
77
+ - lib/vultr/objects/load_balancer.rb
78
+ - lib/vultr/objects/object_storage.rb
79
+ - lib/vultr/objects/operating_system.rb
80
+ - lib/vultr/objects/plan.rb
81
+ - lib/vultr/objects/private_network.rb
82
+ - lib/vultr/objects/region.rb
83
+ - lib/vultr/objects/reserved_ip.rb
84
+ - lib/vultr/objects/snapshot.rb
85
+ - lib/vultr/objects/ssh_key.rb
86
+ - lib/vultr/objects/startup_script.rb
87
+ - lib/vultr/objects/user.rb
88
+ - lib/vultr/resource.rb
89
+ - lib/vultr/resources/account.rb
90
+ - lib/vultr/resources/applications.rb
91
+ - lib/vultr/resources/backups.rb
92
+ - lib/vultr/resources/bare_metal.rb
93
+ - lib/vultr/resources/block_storage.rb
94
+ - lib/vultr/resources/dns.rb
95
+ - lib/vultr/resources/firewall.rb
96
+ - lib/vultr/resources/instances.rb
97
+ - lib/vultr/resources/iso.rb
98
+ - lib/vultr/resources/kubernetes.rb
99
+ - lib/vultr/resources/load_balancers.rb
100
+ - lib/vultr/resources/object_storage.rb
101
+ - lib/vultr/resources/operating_systems.rb
102
+ - lib/vultr/resources/plans.rb
103
+ - lib/vultr/resources/private_networks.rb
104
+ - lib/vultr/resources/regions.rb
105
+ - lib/vultr/resources/reserved_ips.rb
106
+ - lib/vultr/resources/snapshots.rb
107
+ - lib/vultr/resources/ssh_keys.rb
108
+ - lib/vultr/resources/startup_scripts.rb
109
+ - lib/vultr/resources/users.rb
68
110
  - lib/vultr/version.rb
111
+ - test/fixtures/account/info.json
112
+ - test/fixtures/applications/list.json
113
+ - test/fixtures/backups/list.json
114
+ - test/fixtures/backups/retrieve.json
115
+ - test/fixtures/bare_metals/bandwidth.json
116
+ - test/fixtures/bare_metals/create.json
117
+ - test/fixtures/bare_metals/list.json
118
+ - test/fixtures/bare_metals/list_ipv4.json
119
+ - test/fixtures/bare_metals/list_ipv6.json
120
+ - test/fixtures/bare_metals/reinstall.json
121
+ - test/fixtures/bare_metals/retrieve.json
122
+ - test/fixtures/bare_metals/update.json
123
+ - test/fixtures/bare_metals/upgrades.json
124
+ - test/fixtures/bare_metals/user_data.json
125
+ - test/fixtures/bare_metals/vnc.json
126
+ - test/fixtures/block_storage/attach.json
127
+ - test/fixtures/block_storage/create.json
128
+ - test/fixtures/block_storage/detach.json
129
+ - test/fixtures/block_storage/list.json
130
+ - test/fixtures/block_storage/retrieve.json
131
+ - test/fixtures/domains/create.json
132
+ - test/fixtures/domains/dnssec.json
133
+ - test/fixtures/domains/list.json
134
+ - test/fixtures/domains/record.json
135
+ - test/fixtures/domains/records.json
136
+ - test/fixtures/domains/retrieve.json
137
+ - test/fixtures/domains/soa.json
138
+ - test/fixtures/firewall/create.json
139
+ - test/fixtures/firewall/create_rule.json
140
+ - test/fixtures/firewall/delete.json
141
+ - test/fixtures/firewall/delete_rule.json
142
+ - test/fixtures/firewall/list.json
143
+ - test/fixtures/firewall/list_rules.json
144
+ - test/fixtures/firewall/retrieve.json
145
+ - test/fixtures/firewall/retrieve_rule.json
146
+ - test/fixtures/firewall/update.json
147
+ - test/fixtures/instances/attach_iso.json
148
+ - test/fixtures/instances/attach_private_network.json
149
+ - test/fixtures/instances/backup_schedule.json
150
+ - test/fixtures/instances/bandwidth.json
151
+ - test/fixtures/instances/create.json
152
+ - test/fixtures/instances/create_ipv4_reverse.json
153
+ - test/fixtures/instances/create_ipv6_reverse.json
154
+ - test/fixtures/instances/delete.json
155
+ - test/fixtures/instances/delete_ipv4.json
156
+ - test/fixtures/instances/delete_ipv6.json
157
+ - test/fixtures/instances/detach_iso.json
158
+ - test/fixtures/instances/detach_private_network.json
159
+ - test/fixtures/instances/halt.json
160
+ - test/fixtures/instances/halt_instances.json
161
+ - test/fixtures/instances/ipv4.json
162
+ - test/fixtures/instances/ipv6_reverse.json
163
+ - test/fixtures/instances/iso.json
164
+ - test/fixtures/instances/list.json
165
+ - test/fixtures/instances/list_ipv4.json
166
+ - test/fixtures/instances/list_ipv6.json
167
+ - test/fixtures/instances/list_private_networks.json
168
+ - test/fixtures/instances/neighbors.json
169
+ - test/fixtures/instances/reboot.json
170
+ - test/fixtures/instances/reboot_instances.json
171
+ - test/fixtures/instances/reinstall.json
172
+ - test/fixtures/instances/restore.json
173
+ - test/fixtures/instances/retrieve.json
174
+ - test/fixtures/instances/set_backup_schedule.json
175
+ - test/fixtures/instances/set_default_reverse_dns_entry.json
176
+ - test/fixtures/instances/start.json
177
+ - test/fixtures/instances/start_instances.json
178
+ - test/fixtures/instances/update.json
179
+ - test/fixtures/instances/upgrades.json
180
+ - test/fixtures/instances/user_data.json
181
+ - test/fixtures/isos/create.json
182
+ - test/fixtures/isos/list.json
183
+ - test/fixtures/isos/list_public.json
184
+ - test/fixtures/isos/retrieve.json
185
+ - test/fixtures/kubernetes/config.json
186
+ - test/fixtures/kubernetes/create.json
187
+ - test/fixtures/kubernetes/create_node_pool.json
188
+ - test/fixtures/kubernetes/list.json
189
+ - test/fixtures/kubernetes/list_node_pools.json
190
+ - test/fixtures/kubernetes/list_resources.json
191
+ - test/fixtures/kubernetes/retrieve.json
192
+ - test/fixtures/kubernetes/retrieve_node_pool.json
193
+ - test/fixtures/kubernetes/update_node_pool.json
194
+ - test/fixtures/load_balancers/create.json
195
+ - test/fixtures/load_balancers/create_forwarding_rule.json
196
+ - test/fixtures/load_balancers/delete.json
197
+ - test/fixtures/load_balancers/delete_forwarding_rule.json
198
+ - test/fixtures/load_balancers/list.json
199
+ - test/fixtures/load_balancers/list_firewall_rules.json
200
+ - test/fixtures/load_balancers/list_forwarding_rules.json
201
+ - test/fixtures/load_balancers/retrieve.json
202
+ - test/fixtures/load_balancers/retrieve_firewall_rule.json
203
+ - test/fixtures/load_balancers/retrieve_forwarding_rule.json
204
+ - test/fixtures/load_balancers/update.json
205
+ - test/fixtures/object_storage/create.json
206
+ - test/fixtures/object_storage/delete.json
207
+ - test/fixtures/object_storage/list.json
208
+ - test/fixtures/object_storage/list_clusters.json
209
+ - test/fixtures/object_storage/regenerate_keys.json
210
+ - test/fixtures/object_storage/retrieve.json
211
+ - test/fixtures/object_storage/update.json
212
+ - test/fixtures/operating_systems/list.json
213
+ - test/fixtures/plans/list.json
214
+ - test/fixtures/plans/list_metal.json
215
+ - test/fixtures/private_networks/create.json
216
+ - test/fixtures/private_networks/delete.json
217
+ - test/fixtures/private_networks/list.json
218
+ - test/fixtures/private_networks/retrieve.json
219
+ - test/fixtures/private_networks/update.json
220
+ - test/fixtures/regions/list.json
221
+ - test/fixtures/regions/list_availability.json
222
+ - test/fixtures/reserved_ips/attach.json
223
+ - test/fixtures/reserved_ips/convert.json
224
+ - test/fixtures/reserved_ips/create.json
225
+ - test/fixtures/reserved_ips/delete.json
226
+ - test/fixtures/reserved_ips/detach.json
227
+ - test/fixtures/reserved_ips/list.json
228
+ - test/fixtures/reserved_ips/retrieve.json
229
+ - test/fixtures/snapshots/create.json
230
+ - test/fixtures/snapshots/create_from_url.json
231
+ - test/fixtures/snapshots/delete.json
232
+ - test/fixtures/snapshots/list.json
233
+ - test/fixtures/snapshots/retrieve.json
234
+ - test/fixtures/snapshots/update.json
235
+ - test/fixtures/ssh_keys/create.json
236
+ - test/fixtures/ssh_keys/delete.json
237
+ - test/fixtures/ssh_keys/list.json
238
+ - test/fixtures/ssh_keys/retrieve.json
239
+ - test/fixtures/ssh_keys/update.json
240
+ - test/fixtures/startup_scripts/create.json
241
+ - test/fixtures/startup_scripts/delete.json
242
+ - test/fixtures/startup_scripts/list.json
243
+ - test/fixtures/startup_scripts/retrieve.json
244
+ - test/fixtures/startup_scripts/update.json
245
+ - test/fixtures/users/create.json
246
+ - test/fixtures/users/delete.json
247
+ - test/fixtures/users/list.json
248
+ - test/fixtures/users/retrieve.json
249
+ - test/fixtures/users/update.json
69
250
  - test/test_helper.rb
70
- - test/vultr/vultr_account_test.rb
71
- - test/vultr/vultr_app_test.rb
72
- - test/vultr/vultr_backup_test.rb
73
- - test/vultr/vultr_iso_test.rb
74
- - test/vultr/vultr_os_test.rb
75
- - test/vultr/vultr_plan_test.rb
76
- - test/vultr/vultr_region_test.rb
77
- - test/vultr/vultr_snapshot_test.rb
78
- - test/vultr/vultr_sshkey_test.rb
79
- - test/vultr/vultr_startupscript_test.rb
251
+ - test/vultr/client_test.rb
252
+ - test/vultr/object_test.rb
253
+ - test/vultr/resources/account_test.rb
254
+ - test/vultr/resources/applications_test.rb
255
+ - test/vultr/resources/backups_test.rb
256
+ - test/vultr/resources/bare_metal_test.rb
257
+ - test/vultr/resources/block_storage_test.rb
258
+ - test/vultr/resources/dns_test.rb
259
+ - test/vultr/resources/firewall_test.rb
260
+ - test/vultr/resources/instances_test.rb
261
+ - test/vultr/resources/iso_test.rb
262
+ - test/vultr/resources/kubernetes_test.rb
263
+ - test/vultr/resources/load_balancers_test.rb
264
+ - test/vultr/resources/object_storage_test.rb
265
+ - test/vultr/resources/operating_systems_test.rb
266
+ - test/vultr/resources/plans_test.rb
267
+ - test/vultr/resources/private_networks_test.rb
268
+ - test/vultr/resources/regions_test.rb
269
+ - test/vultr/resources/reserved_ips_test.rb
270
+ - test/vultr/resources/snapshots_test.rb
271
+ - test/vultr/resources/ssh_keys_test.rb
272
+ - test/vultr/resources/startup_scripts_test.rb
273
+ - test/vultr/resources/users_test.rb
80
274
  - vultr.gemspec
81
275
  homepage: https://github.com/tolbkni/vultr.rb
82
276
  licenses:
83
277
  - MIT
84
278
  metadata: {}
85
- post_install_message:
279
+ post_install_message:
86
280
  rdoc_options: []
87
281
  require_paths:
88
282
  - lib
@@ -90,26 +284,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
284
  requirements:
91
285
  - - ">="
92
286
  - !ruby/object:Gem::Version
93
- version: '1.9'
287
+ version: '3.0'
94
288
  required_rubygems_version: !ruby/object:Gem::Requirement
95
289
  requirements:
96
290
  - - ">="
97
291
  - !ruby/object:Gem::Version
98
292
  version: '0'
99
293
  requirements: []
100
- rubygems_version: 3.0.3
101
- signing_key:
294
+ rubygems_version: 3.5.10
295
+ signing_key:
102
296
  specification_version: 4
103
297
  summary: Ruby bindings for VULTR API.
104
- test_files:
105
- - test/test_helper.rb
106
- - test/vultr/vultr_account_test.rb
107
- - test/vultr/vultr_app_test.rb
108
- - test/vultr/vultr_backup_test.rb
109
- - test/vultr/vultr_iso_test.rb
110
- - test/vultr/vultr_os_test.rb
111
- - test/vultr/vultr_plan_test.rb
112
- - test/vultr/vultr_region_test.rb
113
- - test/vultr/vultr_snapshot_test.rb
114
- - test/vultr/vultr_sshkey_test.rb
115
- - test/vultr/vultr_startupscript_test.rb
298
+ test_files: []
data/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1
8
- - 2.2
9
- - 2.3
10
- - 2.4
11
- - 2.5
12
-
13
- env:
14
- matrix:
15
- - SSL=no
16
- - SSL=yes
17
- deploy:
18
- provider: rubygems
19
- api_key:
20
- secure: dtLOQS0Obgd1CyJAnX2xU0P/VWRJHUFTXY0PmnnH2y0UBkY4uMTYwGVcy1vSkT7YAK6hUUlR1cMpM4lwiw+6Da2GMX8m4uZzQCAqH7h+0q4RB0H5rVedyr6X0pNMiPyT2S2F+ZwIVevAt8oBzgR2JUBMED+b2ThzJajHdfVOxbI=
21
- gem: vultr
22
- on:
23
- tags: true
24
- repo: tolbkni/vultr.rb
25
- rvm: 2.4
26
- condition: '"$SSL" = "yes"'
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
-
3
- class VultrAccountTest < Minitest::Test
4
-
5
- # Called before every test method runs. Can be used
6
- # to set up fixture information.
7
- def setup
8
- Vultr.api_key = ENV['VULTR_API_KEY']
9
- end
10
-
11
- def test_account_info_response
12
- r = Vultr::Account.info
13
-
14
- assert r.has_key? :status
15
- assert_equal r[:status], 200
16
-
17
- assert r.has_key? :result
18
- assert r[:result].has_key? 'balance'
19
- assert r[:result].has_key? 'pending_charges'
20
- assert r[:result].has_key? 'last_payment_date'
21
- assert r[:result].has_key? 'last_payment_amount'
22
- end
23
-
24
- # Called after every test method runs. Can be used to tear
25
- # down fixture information.
26
- def teardown
27
- # Do nothing
28
- end
29
- end