fog-packet 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +51 -0
  3. data/.rubocop.yml +38 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/README.md +1176 -0
  7. data/Rakefile +24 -0
  8. data/fog-packet.gemspec +24 -0
  9. data/lib/fog-packet.rb +26 -0
  10. data/lib/fog/compute/packet/compute.rb +313 -0
  11. data/lib/fog/compute/packet/models/bandwidth.rb +14 -0
  12. data/lib/fog/compute/packet/models/batch.rb +18 -0
  13. data/lib/fog/compute/packet/models/batches.rb +27 -0
  14. data/lib/fog/compute/packet/models/bgp_session.rb +35 -0
  15. data/lib/fog/compute/packet/models/bgp_sessions.rb +22 -0
  16. data/lib/fog/compute/packet/models/capacities.rb +27 -0
  17. data/lib/fog/compute/packet/models/capacity.rb +29 -0
  18. data/lib/fog/compute/packet/models/device.rb +136 -0
  19. data/lib/fog/compute/packet/models/devices.rb +22 -0
  20. data/lib/fog/compute/packet/models/email.rb +50 -0
  21. data/lib/fog/compute/packet/models/email_verification.rb +18 -0
  22. data/lib/fog/compute/packet/models/emails.rb +17 -0
  23. data/lib/fog/compute/packet/models/event.rb +23 -0
  24. data/lib/fog/compute/packet/models/events.rb +17 -0
  25. data/lib/fog/compute/packet/models/facilities.rb +17 -0
  26. data/lib/fog/compute/packet/models/facility.rb +22 -0
  27. data/lib/fog/compute/packet/models/hardware_reservation.rb +66 -0
  28. data/lib/fog/compute/packet/models/hardware_reservations.rb +22 -0
  29. data/lib/fog/compute/packet/models/invitation.rb +36 -0
  30. data/lib/fog/compute/packet/models/invitations.rb +22 -0
  31. data/lib/fog/compute/packet/models/ip.rb +60 -0
  32. data/lib/fog/compute/packet/models/ips.rb +22 -0
  33. data/lib/fog/compute/packet/models/license.rb +55 -0
  34. data/lib/fog/compute/packet/models/licenses.rb +22 -0
  35. data/lib/fog/compute/packet/models/membership.rb +38 -0
  36. data/lib/fog/compute/packet/models/memberships.rb +22 -0
  37. data/lib/fog/compute/packet/models/notification.rb +31 -0
  38. data/lib/fog/compute/packet/models/notifications.rb +22 -0
  39. data/lib/fog/compute/packet/models/operating_system.rb +23 -0
  40. data/lib/fog/compute/packet/models/operating_systems.rb +17 -0
  41. data/lib/fog/compute/packet/models/organization.rb +71 -0
  42. data/lib/fog/compute/packet/models/organizations.rb +22 -0
  43. data/lib/fog/compute/packet/models/payment_method.rb +63 -0
  44. data/lib/fog/compute/packet/models/payment_methods.rb +22 -0
  45. data/lib/fog/compute/packet/models/plan.rb +23 -0
  46. data/lib/fog/compute/packet/models/plans.rb +17 -0
  47. data/lib/fog/compute/packet/models/project.rb +47 -0
  48. data/lib/fog/compute/packet/models/projects.rb +22 -0
  49. data/lib/fog/compute/packet/models/session.rb +22 -0
  50. data/lib/fog/compute/packet/models/sessions.rb +26 -0
  51. data/lib/fog/compute/packet/models/snapshot.rb +33 -0
  52. data/lib/fog/compute/packet/models/snapshots.rb +22 -0
  53. data/lib/fog/compute/packet/models/spot_market_price.rb +15 -0
  54. data/lib/fog/compute/packet/models/spot_market_prices.rb +22 -0
  55. data/lib/fog/compute/packet/models/ssh_key.rb +51 -0
  56. data/lib/fog/compute/packet/models/ssh_keys.rb +22 -0
  57. data/lib/fog/compute/packet/models/transfer_request.rb +34 -0
  58. data/lib/fog/compute/packet/models/transfer_requests.rb +27 -0
  59. data/lib/fog/compute/packet/models/two_factor_auth.rb +18 -0
  60. data/lib/fog/compute/packet/models/user.rb +56 -0
  61. data/lib/fog/compute/packet/models/users.rb +22 -0
  62. data/lib/fog/compute/packet/models/virtual_network.rb +76 -0
  63. data/lib/fog/compute/packet/models/virtual_networks.rb +17 -0
  64. data/lib/fog/compute/packet/models/volume.rb +96 -0
  65. data/lib/fog/compute/packet/models/volumes.rb +23 -0
  66. data/lib/fog/compute/packet/models/vpn.rb +16 -0
  67. data/lib/fog/compute/packet/models/vpns.rb +27 -0
  68. data/lib/fog/compute/packet/requests/accept_invitation.rb +43 -0
  69. data/lib/fog/compute/packet/requests/accept_transfer_request.rb +26 -0
  70. data/lib/fog/compute/packet/requests/assign_ip.rb +32 -0
  71. data/lib/fog/compute/packet/requests/assign_port.rb +25 -0
  72. data/lib/fog/compute/packet/requests/attach_volume.rb +41 -0
  73. data/lib/fog/compute/packet/requests/bond_ports.rb +25 -0
  74. data/lib/fog/compute/packet/requests/create_batch.rb +43 -0
  75. data/lib/fog/compute/packet/requests/create_bgp_session.rb +37 -0
  76. data/lib/fog/compute/packet/requests/create_device.rb +212 -0
  77. data/lib/fog/compute/packet/requests/create_email.rb +38 -0
  78. data/lib/fog/compute/packet/requests/create_license.rb +46 -0
  79. data/lib/fog/compute/packet/requests/create_organization.rb +87 -0
  80. data/lib/fog/compute/packet/requests/create_payment_method.rb +63 -0
  81. data/lib/fog/compute/packet/requests/create_project.rb +72 -0
  82. data/lib/fog/compute/packet/requests/create_snapshot.rb +25 -0
  83. data/lib/fog/compute/packet/requests/create_ssh_key.rb +44 -0
  84. data/lib/fog/compute/packet/requests/create_virtual_network.rb +49 -0
  85. data/lib/fog/compute/packet/requests/create_volume.rb +70 -0
  86. data/lib/fog/compute/packet/requests/decline_invitation.rb +43 -0
  87. data/lib/fog/compute/packet/requests/decline_transfer_request.rb +26 -0
  88. data/lib/fog/compute/packet/requests/delete_bgp_session.rb +25 -0
  89. data/lib/fog/compute/packet/requests/delete_device.rb +25 -0
  90. data/lib/fog/compute/packet/requests/delete_email.rb +25 -0
  91. data/lib/fog/compute/packet/requests/delete_license.rb +25 -0
  92. data/lib/fog/compute/packet/requests/delete_membership.rb +25 -0
  93. data/lib/fog/compute/packet/requests/delete_organization.rb +25 -0
  94. data/lib/fog/compute/packet/requests/delete_payment_method.rb +25 -0
  95. data/lib/fog/compute/packet/requests/delete_project.rb +25 -0
  96. data/lib/fog/compute/packet/requests/delete_session.rb +27 -0
  97. data/lib/fog/compute/packet/requests/delete_snapshot.rb +25 -0
  98. data/lib/fog/compute/packet/requests/delete_ssh_key.rb +25 -0
  99. data/lib/fog/compute/packet/requests/delete_virtual_network.rb +25 -0
  100. data/lib/fog/compute/packet/requests/delete_volume.rb +25 -0
  101. data/lib/fog/compute/packet/requests/detach_volume.rb +36 -0
  102. data/lib/fog/compute/packet/requests/disable_two_factor_auth.rb +27 -0
  103. data/lib/fog/compute/packet/requests/disable_vpn.rb +25 -0
  104. data/lib/fog/compute/packet/requests/disbond_ports.rb +25 -0
  105. data/lib/fog/compute/packet/requests/enable_two_factor_auth.rb +26 -0
  106. data/lib/fog/compute/packet/requests/enable_vpn.rb +25 -0
  107. data/lib/fog/compute/packet/requests/get_bandwidth.rb +31 -0
  108. data/lib/fog/compute/packet/requests/get_batch.rb +38 -0
  109. data/lib/fog/compute/packet/requests/get_bgp_session.rb +37 -0
  110. data/lib/fog/compute/packet/requests/get_capacity.rb +165 -0
  111. data/lib/fog/compute/packet/requests/get_device.rb +189 -0
  112. data/lib/fog/compute/packet/requests/get_email.rb +32 -0
  113. data/lib/fog/compute/packet/requests/get_hardware_reservation.rb +193 -0
  114. data/lib/fog/compute/packet/requests/get_invitation.rb +43 -0
  115. data/lib/fog/compute/packet/requests/get_ip.rb +60 -0
  116. data/lib/fog/compute/packet/requests/get_license.rb +37 -0
  117. data/lib/fog/compute/packet/requests/get_membership.rb +40 -0
  118. data/lib/fog/compute/packet/requests/get_notification.rb +40 -0
  119. data/lib/fog/compute/packet/requests/get_organization.rb +61 -0
  120. data/lib/fog/compute/packet/requests/get_payment_method.rb +56 -0
  121. data/lib/fog/compute/packet/requests/get_project.rb +67 -0
  122. data/lib/fog/compute/packet/requests/get_ssh_key.rb +38 -0
  123. data/lib/fog/compute/packet/requests/get_transfer_request.rb +38 -0
  124. data/lib/fog/compute/packet/requests/get_user.rb +56 -0
  125. data/lib/fog/compute/packet/requests/get_volume.rb +60 -0
  126. data/lib/fog/compute/packet/requests/get_vpn.rb +29 -0
  127. data/lib/fog/compute/packet/requests/list_batches.rb +33 -0
  128. data/lib/fog/compute/packet/requests/list_bgp_sessions.rb +32 -0
  129. data/lib/fog/compute/packet/requests/list_devices.rb +33 -0
  130. data/lib/fog/compute/packet/requests/list_events.rb +33 -0
  131. data/lib/fog/compute/packet/requests/list_facilities.rb +57 -0
  132. data/lib/fog/compute/packet/requests/list_hardware_reservations.rb +216 -0
  133. data/lib/fog/compute/packet/requests/list_invitations.rb +48 -0
  134. data/lib/fog/compute/packet/requests/list_ips.rb +65 -0
  135. data/lib/fog/compute/packet/requests/list_licenses.rb +42 -0
  136. data/lib/fog/compute/packet/requests/list_memberships.rb +45 -0
  137. data/lib/fog/compute/packet/requests/list_notifications.rb +45 -0
  138. data/lib/fog/compute/packet/requests/list_operating_systems.rb +66 -0
  139. data/lib/fog/compute/packet/requests/list_organizations.rb +81 -0
  140. data/lib/fog/compute/packet/requests/list_payment_methods.rb +76 -0
  141. data/lib/fog/compute/packet/requests/list_plans.rb +92 -0
  142. data/lib/fog/compute/packet/requests/list_projects.rb +87 -0
  143. data/lib/fog/compute/packet/requests/list_sessions.rb +40 -0
  144. data/lib/fog/compute/packet/requests/list_snapshots.rb +40 -0
  145. data/lib/fog/compute/packet/requests/list_spotmarketprices.rb +173 -0
  146. data/lib/fog/compute/packet/requests/list_spotmarketprices_history.rb +42 -0
  147. data/lib/fog/compute/packet/requests/list_ssh_keys.rb +50 -0
  148. data/lib/fog/compute/packet/requests/list_transfer_requests.rb +43 -0
  149. data/lib/fog/compute/packet/requests/list_users.rb +61 -0
  150. data/lib/fog/compute/packet/requests/list_virtual_networks.rb +62 -0
  151. data/lib/fog/compute/packet/requests/list_volumes.rb +65 -0
  152. data/lib/fog/compute/packet/requests/move_hardware_reservation.rb +43 -0
  153. data/lib/fog/compute/packet/requests/poweroff_device.rb +194 -0
  154. data/lib/fog/compute/packet/requests/poweron_device.rb +194 -0
  155. data/lib/fog/compute/packet/requests/reboot_device.rb +194 -0
  156. data/lib/fog/compute/packet/requests/request_email_verification.rb +25 -0
  157. data/lib/fog/compute/packet/requests/reserve_ip.rb +37 -0
  158. data/lib/fog/compute/packet/requests/session_login.rb +25 -0
  159. data/lib/fog/compute/packet/requests/transfer_project.rb +43 -0
  160. data/lib/fog/compute/packet/requests/unassign_ip.rb +24 -0
  161. data/lib/fog/compute/packet/requests/unassign_port.rb +25 -0
  162. data/lib/fog/compute/packet/requests/update_device.rb +201 -0
  163. data/lib/fog/compute/packet/requests/update_email.rb +37 -0
  164. data/lib/fog/compute/packet/requests/update_license.rb +42 -0
  165. data/lib/fog/compute/packet/requests/update_membership.rb +43 -0
  166. data/lib/fog/compute/packet/requests/update_notification.rb +40 -0
  167. data/lib/fog/compute/packet/requests/update_organization.rb +85 -0
  168. data/lib/fog/compute/packet/requests/update_payment_method.rb +63 -0
  169. data/lib/fog/compute/packet/requests/update_project.rb +71 -0
  170. data/lib/fog/compute/packet/requests/update_ssh_key.rb +43 -0
  171. data/lib/fog/compute/packet/requests/update_user.rb +65 -0
  172. data/lib/fog/compute/packet/requests/update_volume.rb +66 -0
  173. data/lib/fog/compute/packet/requests/validate_capacity.rb +38 -0
  174. data/lib/fog/compute/packet/requests/verify_email.rb +36 -0
  175. data/tests/packet/models/test_batches.rb +45 -0
  176. data/tests/packet/models/test_bgp_sessions.rb +52 -0
  177. data/tests/packet/models/test_capacity.rb +40 -0
  178. data/tests/packet/models/test_devices.rb +93 -0
  179. data/tests/packet/models/test_email_verification.rb +25 -0
  180. data/tests/packet/models/test_emails.rb +45 -0
  181. data/tests/packet/models/test_facilities.rb +18 -0
  182. data/tests/packet/models/test_hardware_reservations.rb +38 -0
  183. data/tests/packet/models/test_invitations.rb +41 -0
  184. data/tests/packet/models/test_ips.rb +52 -0
  185. data/tests/packet/models/test_licenses.rb +56 -0
  186. data/tests/packet/models/test_memberships.rb +41 -0
  187. data/tests/packet/models/test_notifications.rb +35 -0
  188. data/tests/packet/models/test_operating_systems.rb +19 -0
  189. data/tests/packet/models/test_organizations.rb +67 -0
  190. data/tests/packet/models/test_payment_methods.rb +61 -0
  191. data/tests/packet/models/test_plans.rb +19 -0
  192. data/tests/packet/models/test_projects.rb +41 -0
  193. data/tests/packet/models/test_sessions.rb +34 -0
  194. data/tests/packet/models/test_snapshots.rb +43 -0
  195. data/tests/packet/models/test_spotmarketprices.rb +28 -0
  196. data/tests/packet/models/test_ssh_keys.rb +58 -0
  197. data/tests/packet/models/test_transfer_requests.rb +49 -0
  198. data/tests/packet/models/test_two_factor_auth.rb +29 -0
  199. data/tests/packet/models/test_users.rb +47 -0
  200. data/tests/packet/models/test_virtual_networks.rb +81 -0
  201. data/tests/packet/models/test_volumes.rb +70 -0
  202. data/tests/packet/models/test_vpns.rb +37 -0
  203. data/tests/packet/requests/test_batches.rb +45 -0
  204. data/tests/packet/requests/test_bgp_sessions.rb +64 -0
  205. data/tests/packet/requests/test_capacity.rb +40 -0
  206. data/tests/packet/requests/test_devices.rb +104 -0
  207. data/tests/packet/requests/test_email_verification.rb +25 -0
  208. data/tests/packet/requests/test_emails.rb +51 -0
  209. data/tests/packet/requests/test_facilities.rb +19 -0
  210. data/tests/packet/requests/test_hardware_reservations.rb +38 -0
  211. data/tests/packet/requests/test_invitations.rb +40 -0
  212. data/tests/packet/requests/test_ips.rb +66 -0
  213. data/tests/packet/requests/test_licenses.rb +56 -0
  214. data/tests/packet/requests/test_memberships.rb +43 -0
  215. data/tests/packet/requests/test_notifications.rb +40 -0
  216. data/tests/packet/requests/test_operating_systems.rb +19 -0
  217. data/tests/packet/requests/test_organizations.rb +64 -0
  218. data/tests/packet/requests/test_payment_methods.rb +60 -0
  219. data/tests/packet/requests/test_plans.rb +21 -0
  220. data/tests/packet/requests/test_projects.rb +40 -0
  221. data/tests/packet/requests/test_sessions.rb +34 -0
  222. data/tests/packet/requests/test_snapshots.rb +57 -0
  223. data/tests/packet/requests/test_sportmarketprices.rb +29 -0
  224. data/tests/packet/requests/test_ssh_keys.rb +60 -0
  225. data/tests/packet/requests/test_transfer_requests.rb +46 -0
  226. data/tests/packet/requests/test_two_factor_auth.rb +29 -0
  227. data/tests/packet/requests/test_users.rb +48 -0
  228. data/tests/packet/requests/test_virtual_networks.rb +100 -0
  229. data/tests/packet/requests/test_volumes.rb +95 -0
  230. data/tests/packet/requests/test_vpns.rb +38 -0
  231. data/tests/test_helper.rb +4 -0
  232. metadata +345 -0
@@ -0,0 +1,66 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_volume(volume_id, options)
7
+ device = Hash.new {}
8
+ device["description"] = options[:description] if options[:description]
9
+ device["billing_cycle"] = options[:billing_cycle] if options[:billing_cycle]
10
+ device["size"] = options[:size] if options[:size]
11
+ device["locked"] = options[:locked] if options[:locked]
12
+
13
+ request(
14
+ :expects => [200],
15
+ :method => "PUT",
16
+ :path => "/storage/" + volume_id,
17
+ :body => Fog::JSON.encode(device)
18
+ )
19
+ end
20
+ end
21
+
22
+ # Mock
23
+ class Mock
24
+ def update_volume(volume_id, options)
25
+ response = Excon::Response.new
26
+ response.status = 200
27
+ response.body = {
28
+ "id" => volume_id,
29
+ "name" => "volume-870f9650",
30
+ "description" => "test description",
31
+ "size" => options[:size],
32
+ "locked" => false,
33
+ "billing_cycle" => "hourly",
34
+ "state" => "active",
35
+ "created_at" => "2018-03-08T12:49:30Z",
36
+ "updated_at" => "2018-03-08T12:49:30.682Z",
37
+ "access" => {},
38
+ "project" => {
39
+ "href" => "/projects/93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
40
+ },
41
+ "facility" => {
42
+ "href" => "/facilities/e1e9c52e-a0bc-4117-b996-0fc94843ea09"
43
+ },
44
+ "snapshot_policies" => [],
45
+ "attachments" => [],
46
+ "snapshots" => [],
47
+ "plan" => {
48
+ "id" => "87728148-3155-4992-a730-8d1e6aca8a32",
49
+ "slug" => "storage_1",
50
+ "name" => "Standard",
51
+ "description" => "TBD",
52
+ "line" => "storage",
53
+ "specs" => {},
54
+ "available_in" => [],
55
+ "pricing" => {
56
+ "hour" => 0.000104
57
+ }
58
+ },
59
+ "href" => "/storage/870f9650-19ea-48bd-84c5-ddf97471c1c1"
60
+ }
61
+ response
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,38 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def validate_capacity(options)
7
+ cap = {
8
+ "servers" => []
9
+ }
10
+ options[:servers].each do |server|
11
+ srv = {}
12
+ srv["facility"] = server[:facility] if server[:facility]
13
+ srv["plan"] = server[:plan] if server[:plan]
14
+ srv["quantity"] = server[:quantity] if server[:quantity]
15
+
16
+ cap["servers"] << srv
17
+ end
18
+
19
+ request(
20
+ :expects => [204],
21
+ :method => "POST",
22
+ :path => "/capacity",
23
+ :body => Fog::JSON.encode(cap)
24
+ )
25
+ end
26
+ end
27
+
28
+ # Mock
29
+ class Mock
30
+ def validate_capacity(_options)
31
+ response = Excon::Response.new
32
+ response.status = 204
33
+ response
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def verify_email(token)
7
+ request(
8
+ :expects => [200],
9
+ :method => "POST",
10
+ :path => "/verify-email?token=" + token
11
+ )
12
+ end
13
+ end
14
+
15
+ # Mock
16
+ class Mock
17
+ def verify_email(_token)
18
+ response = Excon::Response.new
19
+ response.status = 200
20
+ response.body = {
21
+ "id" => "25a602c3-76b9-4de7-8b06-10d277f2a03b",
22
+ "token" => "aE5Ye1evHw5ds8CrFB9mYf7qS3JZQ6my",
23
+ "expires_at" => "2018-04-13T10:50:26Z",
24
+ "created_at" => "2018-04-12T10:50:26Z",
25
+ "updated_at" => "2018-04-12T10:50:26Z",
26
+ "user" => {
27
+ "href" => "/users/dbb25187-2f7e-4d53-a6de-d7b3e2b6d2ba"
28
+ },
29
+ "read_only" => false
30
+ }
31
+ response
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,45 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestBatches
4
+ class TestBatches < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
11
+
12
+ @project_id = "93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
13
+ end
14
+
15
+ def test_create_batch
16
+ batches = [{
17
+ :hostname => "test1",
18
+ :description => "test batch",
19
+ :plan => "baremetal_0",
20
+ :operating_system => "coreos_stable",
21
+ :facility => "ewr1",
22
+ :billing_cycle => "hourly",
23
+ :tags => ["abc"],
24
+ :quantity => 1
25
+ }]
26
+
27
+ response = @compute.batches.create(@project_id, :batches => batches)
28
+
29
+ assert !response.empty?
30
+
31
+ @@batch_id = response[0].id
32
+ end
33
+
34
+ def test_get_batch
35
+ response = @compute.batches.get(@@batch_id)
36
+
37
+ assert_equal @@batch_id, response.id
38
+ end
39
+
40
+ def test_list_batches
41
+ response = @compute.batches.all(@project_id)
42
+
43
+ assert !response.empty?
44
+ end
45
+ end
@@ -0,0 +1,52 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestBGPSessions
4
+ class TestBGPSessions < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
11
+ @project_id = "93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
12
+ end
13
+
14
+ def test_a_create_bgp_session
15
+ device = @compute.devices.create(:project_id => @project_id, :facility => "ewr1", :plan => "baremetal_0", :hostname => "test01", :operating_system => "coreos_stable")
16
+ @@device_id = device.id
17
+
18
+ device.wait_for { ready? }
19
+
20
+ # Perform Request
21
+ address_family = "ipv4"
22
+ response = @compute.bgp_sessions.create(:device_id => @@device_id, :address_family => address_family)
23
+
24
+ # Assertions
25
+ assert_equal address_family, response.address_family
26
+
27
+ @@session_id = response.id
28
+ end
29
+
30
+ def test_b_get_bgp_session
31
+ response = @compute.bgp_sessions.get(@@session_id)
32
+
33
+ assert_equal @@session_id, response.id
34
+ end
35
+
36
+ def test_d_list_bgp_sessions
37
+ response = @compute.bgp_sessions.all(@@device_id)
38
+
39
+ assert !response.empty?
40
+ end
41
+
42
+ def test_e_delete_bgp_session
43
+ session = @compute.bgp_sessions.get(@@session_id)
44
+
45
+ response = session.destroy
46
+ assert_equal true, response
47
+ end
48
+
49
+ def test_z_cleanup
50
+ @compute.delete_device(@@device_id)
51
+ end
52
+ end
@@ -0,0 +1,40 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestCapacity
4
+ class TestCapacity < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ # Establish Connection
11
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
12
+ end
13
+
14
+ def test_request_get_capacity
15
+ response = @compute.capacities.all
16
+
17
+ assert response
18
+ end
19
+
20
+ def test_request_validate_capacity
21
+ options = {
22
+ :servers => [
23
+ {
24
+ :facility => "ewr1",
25
+ :plan => "baremetal_2a",
26
+ :quantity => 1
27
+ },
28
+ {
29
+ :facility => "atl1",
30
+ :plan => "baremetal_1e",
31
+ :quantity => 1
32
+ }
33
+ ]
34
+ }
35
+
36
+ response = @compute.capacities.validate(options)
37
+
38
+ assert_equal true, response
39
+ end
40
+ end
@@ -0,0 +1,93 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestDevices
4
+ class TestDevices < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ # Establish Connection
11
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
12
+ @project_id = "93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
13
+ end
14
+
15
+ def test_a_create_device
16
+ device = @compute.devices.create(:project_id => @project_id, :facility => "ewr1", :plan => "baremetal_0", :hostname => "test01", :operating_system => "coreos_stable")
17
+
18
+ assert_equal "test01", device.hostname
19
+
20
+ @@device_id = device.id
21
+
22
+ Fog.timeout = 1200
23
+ device.wait_for { ready? }
24
+ end
25
+
26
+ def test_b_list_device
27
+ devices = @compute.devices.all(@project_id, :per_page => 1, :page => 1, :include => "project")
28
+
29
+ assert !devices.empty?
30
+ end
31
+
32
+ def test_c_get_device
33
+ device = @compute.devices.get(@@device_id)
34
+
35
+ assert_equal @@device_id, device.id
36
+ end
37
+
38
+ def test_d_update_device
39
+ device = @compute.devices.get(@@device_id)
40
+ device.hostname = "test02"
41
+ device.update
42
+
43
+ assert_equal "test02", device.hostname
44
+ end
45
+
46
+ def test_e_reboot_device
47
+ device = @compute.devices.get(@@device_id)
48
+ response = device.reboot
49
+
50
+ assert_equal true, response
51
+
52
+ device.wait_for { ready? }
53
+ end
54
+
55
+ def test_f_poweroff_device
56
+ device = @compute.devices.get(@@device_id)
57
+
58
+ response = device.stop
59
+ assert_equal true, response
60
+
61
+ device.wait_for { inactive? } unless Fog.mock?
62
+ end
63
+
64
+ def test_g_poweron_device
65
+ sleep(30) unless Fog.mock?
66
+
67
+ device = @compute.devices.get(@@device_id)
68
+
69
+ response = device.start
70
+
71
+ assert_equal true, response
72
+
73
+ device.wait_for { ready? } unless Fog.mock?
74
+ end
75
+
76
+ def test_h_get_events
77
+ events = @compute.events.all(@@device_id)
78
+
79
+ assert !events.empty?
80
+ end
81
+
82
+ def test_i_get_bandwidth
83
+ response = @compute.bandwidth.get(@@device_id, :to => "12-12-2017", :from => "11-11-2017")
84
+
85
+ assert_equal 200, response.status
86
+ end
87
+
88
+ def test_z_delete_device
89
+ device = @compute.devices.get(@@device_id)
90
+ result = device.destroy
91
+ assert_equal true, result
92
+ end
93
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestEmailVerification
4
+ class TestEmailVerification < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ # Establish Connection
11
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
12
+ end
13
+
14
+ def test_request_email_verification
15
+ response = @compute.email_verification.request("jdoe@example.net")
16
+
17
+ assert_equal true, response
18
+ end
19
+
20
+ def test_verify_email
21
+ response = @compute.email_verification.verify("token1234!")
22
+
23
+ assert_equal true, response
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ require_relative "../../test_helper.rb"
2
+
3
+ # TestEmails
4
+ class TestEmails < Minitest::Test
5
+ def self.test_order
6
+ :alpha
7
+ end
8
+
9
+ def setup
10
+ # Establish Connection
11
+ @compute = Fog::Compute::Packet.new(:packet_token => ENV["PACKET_TOKEN"])
12
+ end
13
+
14
+ def test_a_create_email
15
+ # Perform Request
16
+ email = @compute.emails.create(:address => "jdoe@example.net", :default => false)
17
+
18
+ # Assertions
19
+ @@email_id = email.id
20
+ assert_equal "jdoe@example.net", email.address
21
+ assert_equal false, email.default
22
+ end
23
+
24
+ def test_b_get_email
25
+ response = @compute.emails.get(@@email_id)
26
+
27
+ assert_equal @@email_id, response.id
28
+ end
29
+
30
+ def test_c_update_email
31
+ email = @compute.emails.get(@@email_id)
32
+
33
+ email.default = false
34
+ email.update
35
+
36
+ assert_equal @@email_id, email.id
37
+ end
38
+
39
+ def test_e_delete_email
40
+ email = @compute.emails.get(@@email_id)
41
+
42
+ response = email.destroy
43
+ assert_equal true, response
44
+ end
45
+ end