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,37 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_email(email_id, options)
7
+ project = Hash.new {}
8
+ project["address"] = options[:address] if options[:address]
9
+ project["default"] = options[:default] if options[:default]
10
+
11
+ request(
12
+ :expects => [200],
13
+ :method => "PUT",
14
+ :path => "/emails/" + email_id,
15
+ :body => Fog::JSON.encode(project)
16
+ )
17
+ end
18
+ end
19
+
20
+ # Mock
21
+ class Mock
22
+ def update_email(_email_id, _options)
23
+ response = Excon::Response.new
24
+ response.status = 200
25
+ response.body = {
26
+ "id" => "1de4d14d-1c3e-4f33-b39a-2551af108f7e",
27
+ "address" => "jdoe@example.net",
28
+ "default" => false,
29
+ "href" => "/emails/1de4d14d-1c3e-4f33-b39a-2551af108f7e"
30
+ }
31
+
32
+ response
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_license(id, options)
7
+ project = Hash.new {}
8
+ project["description"] = options[:description] if options[:description]
9
+ project["size"] = options[:size] if options[:size]
10
+
11
+ request(
12
+ :expects => [200],
13
+ :method => "PUT",
14
+ :path => "/licenses/" + id,
15
+ :body => Fog::JSON.encode(project)
16
+ )
17
+ end
18
+ end
19
+
20
+ # Mock
21
+ class Mock
22
+ def update_license(id, options)
23
+ response = Excon::Response.new
24
+ response.status = 200
25
+ response.body = {
26
+ "id" => id,
27
+ "description" => options[:description],
28
+ "license_key" => "2018-04-09T17:51:18Z",
29
+ "licensee_product" => {
30
+ "href" => "/"
31
+ },
32
+ "size" => options[:size],
33
+ "project" => {
34
+ "href" => "/"
35
+ }
36
+ }
37
+ response
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_membership(id, options)
7
+ roles = Hash.new {}
8
+ roles["roles"] = options[:roles] if options[:roles]
9
+ request(
10
+ :expects => [200],
11
+ :method => "PUT",
12
+ :path => "/memberships/" + id,
13
+ :body => Fog::JSON.encode(roles)
14
+ )
15
+ end
16
+ end
17
+
18
+ # Mock
19
+ class Mock
20
+ def update_membership(_id, _options)
21
+ response = Excon::Response.new
22
+ response.status = 200
23
+ response.body = {
24
+ "id" => "string",
25
+ "roles" => [
26
+ "string"
27
+ ],
28
+ "created_at" => "string",
29
+ "updated_at" => "string",
30
+ "project" => {
31
+ "href" => "string"
32
+ },
33
+ "user" => {
34
+ "href" => "string"
35
+ },
36
+ "href" => "string"
37
+ }
38
+ response
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_notification(id)
7
+ request(
8
+ :expects => [200],
9
+ :method => "PUT",
10
+ :path => "/notifications/" + id
11
+ )
12
+ end
13
+ end
14
+
15
+ # Mock
16
+ class Mock
17
+ def update_notification(id)
18
+ response = Excon::Response.new
19
+ response.status = 200
20
+ response.body = {
21
+ "id" => id,
22
+ "type" => "string",
23
+ "body" => "string",
24
+ "severity" => "string",
25
+ "read" => true,
26
+ "context" => "string",
27
+ "created_at" => "string",
28
+ "updated_at" => "string",
29
+ "user" => {
30
+ "href" => "string"
31
+ },
32
+ "href" => "string"
33
+ }
34
+
35
+ response
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,85 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_organization(id, options)
7
+ org = {}
8
+ org["name"] = options[:name] if options[:name]
9
+ org["description"] = options[:description] if options[:description]
10
+ org["website"] = options[:website] if options[:website]
11
+ org["twitter"] = options[:twitter] if options[:twitter]
12
+ org["logo"] = options[:logo] if options[:logo]
13
+ org["address"] = options[:address] if options[:address]
14
+ org["customdata"] = options[:customdata] if options[:customdata]
15
+
16
+ request(
17
+ :expects => [200],
18
+ :method => "PUT",
19
+ :path => "/organizations/" + id,
20
+ :body => Fog::JSON.encode(org)
21
+ )
22
+ end
23
+ end
24
+
25
+ # Mock
26
+ class Mock
27
+ def update_organization(id, options)
28
+ response = Excon::Response.new
29
+ response.status = 200
30
+ response.body = {
31
+ "id" => id,
32
+ "name" => options[:name],
33
+ "description" => options[:description],
34
+ "website" => nil,
35
+ "twitter" => nil,
36
+ "created_at" => "2018-04-25T10:01:21Z",
37
+ "updated_at" => "2018-04-25T10:01:21.134Z",
38
+ "tax_id" => nil,
39
+ "main_phone" => nil,
40
+ "billing_phone" => nil,
41
+ "credit_amount" => 0.0,
42
+ "personal" => true,
43
+ "customdata" => {},
44
+ "address" => nil,
45
+ "members" => [
46
+ {
47
+ "href" => "#2dce124f-3220-495c-907e-5bbbd4dda77c"
48
+ }
49
+ ],
50
+ "owners" => [
51
+ {
52
+ "href" => "/users/2dce124f-3220-495c-907e-5bbbd4dda77c"
53
+ }
54
+ ],
55
+ "memberships" => [
56
+ {
57
+ "href" => "/memberships/95780e18-ad65-4f0a-8895-0da65c371406"
58
+ }
59
+ ],
60
+ "primary_owner" => {
61
+ "href" => "/users/2dce124f-3220-495c-907e-5bbbd4dda77c"
62
+ },
63
+ "inbound_transfers" => [],
64
+ "payment_methods" => [],
65
+ "default_payment_method" => nil,
66
+ "account_manager" => nil,
67
+ "logo" => nil,
68
+ "logo_thumb" => nil,
69
+ "projects" => [],
70
+ "plan" => "Bronze",
71
+ "monthly_spend" => 0.0,
72
+ "current_user_abilities" => {
73
+ "admin" => true,
74
+ "billing" => true,
75
+ "collaborator" => true,
76
+ "owner" => true
77
+ },
78
+ "href" => "/organizations/a24136c3-38e8-46a9-b541-219b4d31bfb1"
79
+ }
80
+ response
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,63 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_payment_method(id, options)
7
+ payment_method = {}
8
+ payment_method["name"] = options[:name] if options[:name]
9
+ payment_method["cardholder_name"] = options[:cardholder_name] if options[:cardholder_name]
10
+ payment_method["expiration_month"] = options[:expiration_month] if options[:expiration_month]
11
+ payment_method["expiration_year"] = options[:expiration_year] if options[:expiration_year]
12
+
13
+ request(
14
+ :expects => [200],
15
+ :method => "POST",
16
+ :path => "/payment_methods/" + id,
17
+ :body => Fog::JSON.encode(payment_method)
18
+ )
19
+ end
20
+ end
21
+
22
+ # Mock
23
+ class Mock
24
+ def update_payment_method(id, options)
25
+ response = Excon::Response.new
26
+ response.status = 200
27
+ response.body = {
28
+ "id" => id,
29
+ "name" => options[:name],
30
+ "type" => "credit_card",
31
+ "default" => true,
32
+ "created_at" => "2018-02-20T03:59:06Z",
33
+ "updated_at" => "2018-02-20T03:59:13Z",
34
+ "created_by_user" => {
35
+ "href" => "/users/8f23cd1f-09e0-4539-9524-6387e4f8d44d"
36
+ },
37
+ "projects" => [
38
+ {
39
+ "href" => "/projects/93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
40
+ }
41
+ ],
42
+ "organization" => {
43
+ "href" => "/organizations/6c17df6c-8769-4d98-b01f-f2848b6489a1"
44
+ },
45
+ "card_type" => "American Express",
46
+ "expiration_month" => options[:expiration_month],
47
+ "expiration_year" => options[:expiration_year],
48
+ "last_4" => "5045",
49
+ "cardholder_name" => options["cardholder_name"],
50
+ "billing_address" => {
51
+ "street_address" => nil,
52
+ "postal_code" => "10007",
53
+ "country_code_alpha2" => "US"
54
+ },
55
+ "href" => "/payment-methods/7605f76e-17d4-4356-833c-91a273aba7f0"
56
+ }
57
+
58
+ response
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,71 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_project(project_id, options)
7
+ project = Hash.new {}
8
+ project["name"] = options[:name] if options[:name]
9
+ project["payment_method_id"] = options[:payment_method_id] if options[:payment_method_id]
10
+
11
+ request(
12
+ :expects => [200],
13
+ :method => "PUT",
14
+ :path => "/projects/" + project_id,
15
+ :body => Fog::JSON.encode(project)
16
+ )
17
+ end
18
+ end
19
+
20
+ # Mock
21
+ class Mock
22
+ def update_project(project_id, _options)
23
+ response = Excon::Response.new
24
+ response.status = 200
25
+ response.body = {
26
+ "id" => project_id,
27
+ "name" => "spc-fran-test",
28
+ "created_at" => "2018-02-28T20:29:17Z",
29
+ "updated_at" => "2018-03-06T11:19:30Z",
30
+ "network_status" => {
31
+ "sjc1" => "provisioned"
32
+ },
33
+ "max_devices" => {
34
+ "baremetal_0" => 9999,
35
+ "baremetal_1" => 9999
36
+ },
37
+ "organization" => {
38
+ "href" => "/organizations/6c17df6c-8769-4d98-b01f-f2848b6489a1"
39
+ },
40
+ "members" => [
41
+ {
42
+ "href" => "/users/1140617d-262d-4502-a3d6-771d83c930da"
43
+ },
44
+ {
45
+ "href" => "/users/2dce124f-3220-495c-907e-5bbbd4dda77c"
46
+ },
47
+ {
48
+ "href" => "/users/8f23cd1f-09e0-4539-9524-6387e4f8d44d"
49
+ },
50
+ {
51
+ "href" => "/users/9532399b-4461-4c78-bbd9-d6250e2dc723"
52
+ }
53
+ ],
54
+ "memberships" => [],
55
+ "invitations" => [],
56
+ "devices" => [],
57
+ "ssh_keys" => [
58
+ {
59
+ "href" => "/ssh-keys/c2d63645-6051-4d19-92ab-0af335d3a1d5"
60
+ }
61
+ ],
62
+ "transfers" => [],
63
+ "volumes" => [],
64
+ "href" => "/projects/93125c2a-8b78-4d4f-a3c4-7367d6b7cca8"
65
+ }
66
+ response
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_ssh_key(id, options)
7
+ sshkey = {
8
+ "label" => options[:label],
9
+ "key" => options[:key]
10
+ }
11
+
12
+ request(
13
+ :expects => [200],
14
+ :method => "PUT",
15
+ :path => "/ssh-keys/" + id,
16
+ :body => Fog::JSON.encode(sshkey)
17
+ )
18
+ end
19
+ end
20
+
21
+ # Mock
22
+ class Mock
23
+ def update_ssh_key(id, options)
24
+ response = Excon::Response.new
25
+ response.status = 200
26
+ response.body = {
27
+ "id" => id,
28
+ "label" => options[:label],
29
+ "key" => options[:key],
30
+ "fingerprint" => "0c:a9:79:a9:d7:29:49:5d:0e:43:41:bc:dc:4d:ac:78",
31
+ "created_at" => "2018-03-27T10:46:33Z",
32
+ "updated_at" => "2018-03-27T10:46:33Z",
33
+ "owner" => {
34
+ "href" => "/users/2dce124f-3220-495c-907e-5bbbd4dda77c"
35
+ },
36
+ "href" => "/ssh-keys/7722a922-d66e-4afa-bf5e-a7aec8955016"
37
+ }
38
+ response
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,65 @@
1
+ module Fog
2
+ module Compute
3
+ class Packet
4
+ # Real
5
+ class Real
6
+ def update_user(user_id, options)
7
+ project = Hash.new {}
8
+ project["first_name"] = options[:first_name] if options[:first_name]
9
+ project["last_name"] = options[:last_name] if options[:last_name]
10
+ project["phone_number"] = options[:phone_number] if options[:phone_number]
11
+ project["timezone"] = options[:timezone] if options[:timezone]
12
+ project["password"] = options[:password] if options[:password]
13
+ project["avatar"] = options[:timezone] if options[:avatar]
14
+
15
+ request(
16
+ :expects => [200],
17
+ :method => "PUT",
18
+ :path => "/users/" + user_id,
19
+ :body => Fog::JSON.encode(project)
20
+ )
21
+ end
22
+ end
23
+
24
+ # Mock
25
+ class Mock
26
+ def update_user(_user_id, _options)
27
+ response = Excon::Response.new
28
+ response.status = 200
29
+ response.body = {
30
+ "id" => "2dce124f-3220-495c-907e-5bbbd4dda77c",
31
+ "short_id" => "2dce124f",
32
+ "first_name" => "Jane",
33
+ "last_name" => "Doe",
34
+ "full_name" => "Jane Doe",
35
+ "email" => "jdoe@example.net",
36
+ "social_accounts" => {
37
+ "linkedin" => "https://example.net"
38
+ },
39
+ "created_at" => "2018-02-20T19:55:57Z",
40
+ "updated_at" => "2018-03-28T11:32:25Z",
41
+ "default_organization_id" => "602c17ec-f996-4d94-a6a8-20d6356e6c2a",
42
+ "avatar_url" => "https://www.gravatar.com/avatar/0bf989eabc6c8c214e11072b7500e4b2?d=mm",
43
+ "avatar_thumb_url" => "https://www.gravatar.com/avatar/0bf989eabc6c8c214e11072b7500e4b2?d=mm",
44
+ "timezone" => "America/New_York",
45
+ "verification_stage" => "verified",
46
+ "two_factor_auth" => "",
47
+ "max_projects" => 2,
48
+ "vpn" => false,
49
+ "last_login_at" => "2018-03-28T11:36:34Z",
50
+ "emails" => [
51
+ {
52
+ "href" => "/emails/973a189d-5dda-4b69-a038-526472a1b6d4"
53
+ }
54
+ ],
55
+ "href" => "/users/2dce124f-3220-495c-907e-5bbbd4dda77c",
56
+ "phone_number" => "+123456789012",
57
+ "restricted" => false
58
+ }
59
+
60
+ response
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end