ey-pro-cli 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +94 -0
  5. data/README.md +1 -0
  6. data/bin/ey-pro +5 -0
  7. data/ey-pro-cli.gemspec +40 -0
  8. data/lib/ey_pro_cli.rb +100 -0
  9. data/lib/ey_pro_cli/version.rb +3 -0
  10. data/lib/vendor/core/ey-core.rb +58 -0
  11. data/lib/vendor/core/ey-core/associations.rb +155 -0
  12. data/lib/vendor/core/ey-core/cli.rb +107 -0
  13. data/lib/vendor/core/ey-core/client.rb +764 -0
  14. data/lib/vendor/core/ey-core/collection.rb +131 -0
  15. data/lib/vendor/core/ey-core/collections/account_cancellations.rb +6 -0
  16. data/lib/vendor/core/ey-core/collections/account_referrals.rb +10 -0
  17. data/lib/vendor/core/ey-core/collections/accounts.rb +8 -0
  18. data/lib/vendor/core/ey-core/collections/addon_attachments.rb +17 -0
  19. data/lib/vendor/core/ey-core/collections/addons.rb +16 -0
  20. data/lib/vendor/core/ey-core/collections/addresses.rb +9 -0
  21. data/lib/vendor/core/ey-core/collections/alerts.rb +9 -0
  22. data/lib/vendor/core/ey-core/collections/application_archives.rb +9 -0
  23. data/lib/vendor/core/ey-core/collections/application_deployments.rb +9 -0
  24. data/lib/vendor/core/ey-core/collections/applications.rb +9 -0
  25. data/lib/vendor/core/ey-core/collections/backup_files.rb +9 -0
  26. data/lib/vendor/core/ey-core/collections/backups.rb +9 -0
  27. data/lib/vendor/core/ey-core/collections/cluster_components.rb +9 -0
  28. data/lib/vendor/core/ey-core/collections/cluster_updates.rb +9 -0
  29. data/lib/vendor/core/ey-core/collections/clusters.rb +9 -0
  30. data/lib/vendor/core/ey-core/collections/component_actions.rb +9 -0
  31. data/lib/vendor/core/ey-core/collections/components.rb +9 -0
  32. data/lib/vendor/core/ey-core/collections/connectors.rb +9 -0
  33. data/lib/vendor/core/ey-core/collections/contacts.rb +9 -0
  34. data/lib/vendor/core/ey-core/collections/costs.rb +8 -0
  35. data/lib/vendor/core/ey-core/collections/database_plan_usages.rb +7 -0
  36. data/lib/vendor/core/ey-core/collections/database_server_revisions.rb +7 -0
  37. data/lib/vendor/core/ey-core/collections/database_server_snapshots.rb +17 -0
  38. data/lib/vendor/core/ey-core/collections/database_server_usages.rb +7 -0
  39. data/lib/vendor/core/ey-core/collections/database_servers.rb +9 -0
  40. data/lib/vendor/core/ey-core/collections/database_services.rb +9 -0
  41. data/lib/vendor/core/ey-core/collections/environment_plan_usages.rb +7 -0
  42. data/lib/vendor/core/ey-core/collections/environments.rb +15 -0
  43. data/lib/vendor/core/ey-core/collections/features.rb +9 -0
  44. data/lib/vendor/core/ey-core/collections/firewall_rules.rb +9 -0
  45. data/lib/vendor/core/ey-core/collections/firewalls.rb +9 -0
  46. data/lib/vendor/core/ey-core/collections/gems.rb +6 -0
  47. data/lib/vendor/core/ey-core/collections/keypair_deployments.rb +9 -0
  48. data/lib/vendor/core/ey-core/collections/keypairs.rb +9 -0
  49. data/lib/vendor/core/ey-core/collections/legacy_alerts.rb +9 -0
  50. data/lib/vendor/core/ey-core/collections/load_balancer_nodes.rb +9 -0
  51. data/lib/vendor/core/ey-core/collections/load_balancer_services.rb +9 -0
  52. data/lib/vendor/core/ey-core/collections/load_balancers.rb +16 -0
  53. data/lib/vendor/core/ey-core/collections/logical_databases.rb +16 -0
  54. data/lib/vendor/core/ey-core/collections/logs.rb +9 -0
  55. data/lib/vendor/core/ey-core/collections/memberships.rb +9 -0
  56. data/lib/vendor/core/ey-core/collections/messages.rb +9 -0
  57. data/lib/vendor/core/ey-core/collections/plan_usages.rb +7 -0
  58. data/lib/vendor/core/ey-core/collections/provider_locations.rb +13 -0
  59. data/lib/vendor/core/ey-core/collections/providers.rb +15 -0
  60. data/lib/vendor/core/ey-core/collections/requests.rb +10 -0
  61. data/lib/vendor/core/ey-core/collections/server_events.rb +9 -0
  62. data/lib/vendor/core/ey-core/collections/server_usages.rb +7 -0
  63. data/lib/vendor/core/ey-core/collections/servers.rb +9 -0
  64. data/lib/vendor/core/ey-core/collections/slot_components.rb +9 -0
  65. data/lib/vendor/core/ey-core/collections/slots.rb +30 -0
  66. data/lib/vendor/core/ey-core/collections/ssl_certificates.rb +9 -0
  67. data/lib/vendor/core/ey-core/collections/storage_users.rb +10 -0
  68. data/lib/vendor/core/ey-core/collections/storages.rb +9 -0
  69. data/lib/vendor/core/ey-core/collections/tasks.rb +9 -0
  70. data/lib/vendor/core/ey-core/collections/tokens.rb +8 -0
  71. data/lib/vendor/core/ey-core/collections/untracked_servers.rb +9 -0
  72. data/lib/vendor/core/ey-core/collections/users.rb +12 -0
  73. data/lib/vendor/core/ey-core/collections/volumes.rb +9 -0
  74. data/lib/vendor/core/ey-core/logger.rb +31 -0
  75. data/lib/vendor/core/ey-core/memory_cache.rb +17 -0
  76. data/lib/vendor/core/ey-core/mock/helper.rb +102 -0
  77. data/lib/vendor/core/ey-core/mock/params.rb +31 -0
  78. data/lib/vendor/core/ey-core/mock/resources.rb +120 -0
  79. data/lib/vendor/core/ey-core/mock/searching.rb +111 -0
  80. data/lib/vendor/core/ey-core/mock/util.rb +19 -0
  81. data/lib/vendor/core/ey-core/model.rb +39 -0
  82. data/lib/vendor/core/ey-core/models/account.rb +63 -0
  83. data/lib/vendor/core/ey-core/models/account_cancellation.rb +6 -0
  84. data/lib/vendor/core/ey-core/models/account_referral.rb +8 -0
  85. data/lib/vendor/core/ey-core/models/account_trial.rb +15 -0
  86. data/lib/vendor/core/ey-core/models/addon.rb +45 -0
  87. data/lib/vendor/core/ey-core/models/addon_attachment.rb +36 -0
  88. data/lib/vendor/core/ey-core/models/address.rb +46 -0
  89. data/lib/vendor/core/ey-core/models/alert.rb +88 -0
  90. data/lib/vendor/core/ey-core/models/application.rb +32 -0
  91. data/lib/vendor/core/ey-core/models/application_archive.rb +67 -0
  92. data/lib/vendor/core/ey-core/models/application_deployment.rb +18 -0
  93. data/lib/vendor/core/ey-core/models/backup.rb +36 -0
  94. data/lib/vendor/core/ey-core/models/backup_file.rb +52 -0
  95. data/lib/vendor/core/ey-core/models/billing.rb +27 -0
  96. data/lib/vendor/core/ey-core/models/cluster.rb +80 -0
  97. data/lib/vendor/core/ey-core/models/cluster_component.rb +62 -0
  98. data/lib/vendor/core/ey-core/models/cluster_update.rb +32 -0
  99. data/lib/vendor/core/ey-core/models/component.rb +11 -0
  100. data/lib/vendor/core/ey-core/models/component_action.rb +29 -0
  101. data/lib/vendor/core/ey-core/models/connector.rb +34 -0
  102. data/lib/vendor/core/ey-core/models/contact.rb +14 -0
  103. data/lib/vendor/core/ey-core/models/cost.rb +16 -0
  104. data/lib/vendor/core/ey-core/models/database_plan_usage.rb +10 -0
  105. data/lib/vendor/core/ey-core/models/database_server.rb +56 -0
  106. data/lib/vendor/core/ey-core/models/database_server_revision.rb +10 -0
  107. data/lib/vendor/core/ey-core/models/database_server_snapshot.rb +16 -0
  108. data/lib/vendor/core/ey-core/models/database_server_usage.rb +15 -0
  109. data/lib/vendor/core/ey-core/models/database_service.rb +53 -0
  110. data/lib/vendor/core/ey-core/models/environment.rb +68 -0
  111. data/lib/vendor/core/ey-core/models/environment_plan_usage.rb +10 -0
  112. data/lib/vendor/core/ey-core/models/feature.rb +33 -0
  113. data/lib/vendor/core/ey-core/models/firewall.rb +45 -0
  114. data/lib/vendor/core/ey-core/models/firewall_rule.rb +41 -0
  115. data/lib/vendor/core/ey-core/models/gem.rb +5 -0
  116. data/lib/vendor/core/ey-core/models/keypair.rb +38 -0
  117. data/lib/vendor/core/ey-core/models/keypair_deployment.rb +26 -0
  118. data/lib/vendor/core/ey-core/models/legacy_alert.rb +12 -0
  119. data/lib/vendor/core/ey-core/models/load_balancer.rb +43 -0
  120. data/lib/vendor/core/ey-core/models/load_balancer_node.rb +17 -0
  121. data/lib/vendor/core/ey-core/models/load_balancer_service.rb +22 -0
  122. data/lib/vendor/core/ey-core/models/log.rb +33 -0
  123. data/lib/vendor/core/ey-core/models/logical_database.rb +40 -0
  124. data/lib/vendor/core/ey-core/models/membership.rb +42 -0
  125. data/lib/vendor/core/ey-core/models/message.rb +27 -0
  126. data/lib/vendor/core/ey-core/models/metadata.rb +15 -0
  127. data/lib/vendor/core/ey-core/models/plan_usage.rb +14 -0
  128. data/lib/vendor/core/ey-core/models/provider.rb +59 -0
  129. data/lib/vendor/core/ey-core/models/provider_location.rb +11 -0
  130. data/lib/vendor/core/ey-core/models/request.rb +89 -0
  131. data/lib/vendor/core/ey-core/models/server.rb +69 -0
  132. data/lib/vendor/core/ey-core/models/server_event.rb +11 -0
  133. data/lib/vendor/core/ey-core/models/server_usage.rb +13 -0
  134. data/lib/vendor/core/ey-core/models/slot.rb +64 -0
  135. data/lib/vendor/core/ey-core/models/slot_component.rb +28 -0
  136. data/lib/vendor/core/ey-core/models/ssl_certificate.rb +44 -0
  137. data/lib/vendor/core/ey-core/models/storage.rb +38 -0
  138. data/lib/vendor/core/ey-core/models/storage_user.rb +44 -0
  139. data/lib/vendor/core/ey-core/models/task.rb +35 -0
  140. data/lib/vendor/core/ey-core/models/token.rb +20 -0
  141. data/lib/vendor/core/ey-core/models/untracked_server.rb +45 -0
  142. data/lib/vendor/core/ey-core/models/user.rb +35 -0
  143. data/lib/vendor/core/ey-core/models/volume.rb +20 -0
  144. data/lib/vendor/core/ey-core/request_failure.rb +11 -0
  145. data/lib/vendor/core/ey-core/requests/attach_address.rb +53 -0
  146. data/lib/vendor/core/ey-core/requests/authorized_channel.rb +22 -0
  147. data/lib/vendor/core/ey-core/requests/bootstrap_logical_database.rb +80 -0
  148. data/lib/vendor/core/ey-core/requests/cancel_account.rb +33 -0
  149. data/lib/vendor/core/ey-core/requests/create_account.rb +33 -0
  150. data/lib/vendor/core/ey-core/requests/create_addon.rb +35 -0
  151. data/lib/vendor/core/ey-core/requests/create_address.rb +53 -0
  152. data/lib/vendor/core/ey-core/requests/create_alert.rb +60 -0
  153. data/lib/vendor/core/ey-core/requests/create_application.rb +55 -0
  154. data/lib/vendor/core/ey-core/requests/create_application_archive.rb +44 -0
  155. data/lib/vendor/core/ey-core/requests/create_backup.rb +46 -0
  156. data/lib/vendor/core/ey-core/requests/create_backup_file.rb +52 -0
  157. data/lib/vendor/core/ey-core/requests/create_cluster.rb +98 -0
  158. data/lib/vendor/core/ey-core/requests/create_cluster_component.rb +57 -0
  159. data/lib/vendor/core/ey-core/requests/create_cluster_update.rb +208 -0
  160. data/lib/vendor/core/ey-core/requests/create_connector.rb +46 -0
  161. data/lib/vendor/core/ey-core/requests/create_database_server.rb +72 -0
  162. data/lib/vendor/core/ey-core/requests/create_database_service.rb +57 -0
  163. data/lib/vendor/core/ey-core/requests/create_environment.rb +57 -0
  164. data/lib/vendor/core/ey-core/requests/create_firewall.rb +62 -0
  165. data/lib/vendor/core/ey-core/requests/create_firewall_rule.rb +60 -0
  166. data/lib/vendor/core/ey-core/requests/create_keypair.rb +42 -0
  167. data/lib/vendor/core/ey-core/requests/create_keypair_deployment.rb +36 -0
  168. data/lib/vendor/core/ey-core/requests/create_load_balancer.rb +62 -0
  169. data/lib/vendor/core/ey-core/requests/create_log.rb +53 -0
  170. data/lib/vendor/core/ey-core/requests/create_logical_database.rb +56 -0
  171. data/lib/vendor/core/ey-core/requests/create_membership.rb +33 -0
  172. data/lib/vendor/core/ey-core/requests/create_message.rb +35 -0
  173. data/lib/vendor/core/ey-core/requests/create_provider.rb +90 -0
  174. data/lib/vendor/core/ey-core/requests/create_slots.rb +100 -0
  175. data/lib/vendor/core/ey-core/requests/create_ssl_certificate.rb +83 -0
  176. data/lib/vendor/core/ey-core/requests/create_storage.rb +64 -0
  177. data/lib/vendor/core/ey-core/requests/create_storage_user.rb +64 -0
  178. data/lib/vendor/core/ey-core/requests/create_task.rb +55 -0
  179. data/lib/vendor/core/ey-core/requests/create_token.rb +24 -0
  180. data/lib/vendor/core/ey-core/requests/create_untracked_server.rb +39 -0
  181. data/lib/vendor/core/ey-core/requests/create_user.rb +48 -0
  182. data/lib/vendor/core/ey-core/requests/destroy_addon.rb +24 -0
  183. data/lib/vendor/core/ey-core/requests/destroy_cluster.rb +30 -0
  184. data/lib/vendor/core/ey-core/requests/destroy_database_server.rb +41 -0
  185. data/lib/vendor/core/ey-core/requests/destroy_database_service.rb +57 -0
  186. data/lib/vendor/core/ey-core/requests/destroy_environment.rb +43 -0
  187. data/lib/vendor/core/ey-core/requests/destroy_firewall.rb +41 -0
  188. data/lib/vendor/core/ey-core/requests/destroy_firewall_rule.rb +41 -0
  189. data/lib/vendor/core/ey-core/requests/destroy_load_balancer.rb +30 -0
  190. data/lib/vendor/core/ey-core/requests/destroy_logical_database.rb +41 -0
  191. data/lib/vendor/core/ey-core/requests/destroy_provider.rb +34 -0
  192. data/lib/vendor/core/ey-core/requests/destroy_server.rb +46 -0
  193. data/lib/vendor/core/ey-core/requests/destroy_ssl_certificate.rb +28 -0
  194. data/lib/vendor/core/ey-core/requests/destroy_storage.rb +33 -0
  195. data/lib/vendor/core/ey-core/requests/destroy_storage_user.rb +38 -0
  196. data/lib/vendor/core/ey-core/requests/destroy_user.rb +29 -0
  197. data/lib/vendor/core/ey-core/requests/detach_address.rb +48 -0
  198. data/lib/vendor/core/ey-core/requests/disable_feature.rb +30 -0
  199. data/lib/vendor/core/ey-core/requests/discover_database_server.rb +66 -0
  200. data/lib/vendor/core/ey-core/requests/discover_database_server_snapshots.rb +69 -0
  201. data/lib/vendor/core/ey-core/requests/discover_provider_location.rb +57 -0
  202. data/lib/vendor/core/ey-core/requests/download_file.rb +25 -0
  203. data/lib/vendor/core/ey-core/requests/enable_feature.rb +35 -0
  204. data/lib/vendor/core/ey-core/requests/finish_backup.rb +26 -0
  205. data/lib/vendor/core/ey-core/requests/get_account.rb +29 -0
  206. data/lib/vendor/core/ey-core/requests/get_account_cancellation.rb +21 -0
  207. data/lib/vendor/core/ey-core/requests/get_account_referrals.rb +28 -0
  208. data/lib/vendor/core/ey-core/requests/get_account_trial.rb +31 -0
  209. data/lib/vendor/core/ey-core/requests/get_accounts.rb +42 -0
  210. data/lib/vendor/core/ey-core/requests/get_addon.rb +25 -0
  211. data/lib/vendor/core/ey-core/requests/get_addon_attachment.rb +33 -0
  212. data/lib/vendor/core/ey-core/requests/get_addon_attachments.rb +42 -0
  213. data/lib/vendor/core/ey-core/requests/get_addons.rb +24 -0
  214. data/lib/vendor/core/ey-core/requests/get_address.rb +25 -0
  215. data/lib/vendor/core/ey-core/requests/get_addresses.rb +27 -0
  216. data/lib/vendor/core/ey-core/requests/get_alert.rb +21 -0
  217. data/lib/vendor/core/ey-core/requests/get_alerting_environments.rb +37 -0
  218. data/lib/vendor/core/ey-core/requests/get_alerts.rb +40 -0
  219. data/lib/vendor/core/ey-core/requests/get_application.rb +21 -0
  220. data/lib/vendor/core/ey-core/requests/get_application_archive.rb +32 -0
  221. data/lib/vendor/core/ey-core/requests/get_application_archives.rb +29 -0
  222. data/lib/vendor/core/ey-core/requests/get_application_deployment.rb +21 -0
  223. data/lib/vendor/core/ey-core/requests/get_application_deployments.rb +28 -0
  224. data/lib/vendor/core/ey-core/requests/get_applications.rb +28 -0
  225. data/lib/vendor/core/ey-core/requests/get_backup.rb +21 -0
  226. data/lib/vendor/core/ey-core/requests/get_backup_file.rb +21 -0
  227. data/lib/vendor/core/ey-core/requests/get_backup_files.rb +28 -0
  228. data/lib/vendor/core/ey-core/requests/get_backups.rb +27 -0
  229. data/lib/vendor/core/ey-core/requests/get_billing.rb +24 -0
  230. data/lib/vendor/core/ey-core/requests/get_cluster.rb +21 -0
  231. data/lib/vendor/core/ey-core/requests/get_cluster_component.rb +21 -0
  232. data/lib/vendor/core/ey-core/requests/get_cluster_components.rb +28 -0
  233. data/lib/vendor/core/ey-core/requests/get_cluster_update.rb +21 -0
  234. data/lib/vendor/core/ey-core/requests/get_cluster_updates.rb +26 -0
  235. data/lib/vendor/core/ey-core/requests/get_clusters.rb +35 -0
  236. data/lib/vendor/core/ey-core/requests/get_component.rb +21 -0
  237. data/lib/vendor/core/ey-core/requests/get_component_action.rb +21 -0
  238. data/lib/vendor/core/ey-core/requests/get_component_actions.rb +29 -0
  239. data/lib/vendor/core/ey-core/requests/get_components.rb +29 -0
  240. data/lib/vendor/core/ey-core/requests/get_connector.rb +21 -0
  241. data/lib/vendor/core/ey-core/requests/get_connectors.rb +37 -0
  242. data/lib/vendor/core/ey-core/requests/get_contacts.rb +34 -0
  243. data/lib/vendor/core/ey-core/requests/get_costs.rb +25 -0
  244. data/lib/vendor/core/ey-core/requests/get_current_user.rb +19 -0
  245. data/lib/vendor/core/ey-core/requests/get_database_plan_usages.rb +24 -0
  246. data/lib/vendor/core/ey-core/requests/get_database_server.rb +21 -0
  247. data/lib/vendor/core/ey-core/requests/get_database_server_revisions.rb +27 -0
  248. data/lib/vendor/core/ey-core/requests/get_database_server_snapshot.rb +20 -0
  249. data/lib/vendor/core/ey-core/requests/get_database_server_snapshots.rb +34 -0
  250. data/lib/vendor/core/ey-core/requests/get_database_server_usages.rb +24 -0
  251. data/lib/vendor/core/ey-core/requests/get_database_servers.rb +30 -0
  252. data/lib/vendor/core/ey-core/requests/get_database_servers_firewalls.rb +30 -0
  253. data/lib/vendor/core/ey-core/requests/get_database_service.rb +20 -0
  254. data/lib/vendor/core/ey-core/requests/get_database_services.rb +55 -0
  255. data/lib/vendor/core/ey-core/requests/get_environment.rb +21 -0
  256. data/lib/vendor/core/ey-core/requests/get_environment_database_services.rb +21 -0
  257. data/lib/vendor/core/ey-core/requests/get_environment_logical_databases.rb +20 -0
  258. data/lib/vendor/core/ey-core/requests/get_environment_plan_usages.rb +24 -0
  259. data/lib/vendor/core/ey-core/requests/get_environments.rb +29 -0
  260. data/lib/vendor/core/ey-core/requests/get_feature.rb +21 -0
  261. data/lib/vendor/core/ey-core/requests/get_features.rb +28 -0
  262. data/lib/vendor/core/ey-core/requests/get_firewall.rb +21 -0
  263. data/lib/vendor/core/ey-core/requests/get_firewall_rule.rb +21 -0
  264. data/lib/vendor/core/ey-core/requests/get_firewall_rules.rb +29 -0
  265. data/lib/vendor/core/ey-core/requests/get_firewalls.rb +45 -0
  266. data/lib/vendor/core/ey-core/requests/get_gem.rb +24 -0
  267. data/lib/vendor/core/ey-core/requests/get_keypair.rb +21 -0
  268. data/lib/vendor/core/ey-core/requests/get_keypair_deployment.rb +21 -0
  269. data/lib/vendor/core/ey-core/requests/get_keypair_deployments.rb +29 -0
  270. data/lib/vendor/core/ey-core/requests/get_keypairs.rb +34 -0
  271. data/lib/vendor/core/ey-core/requests/get_legacy_alert.rb +21 -0
  272. data/lib/vendor/core/ey-core/requests/get_legacy_alerts.rb +29 -0
  273. data/lib/vendor/core/ey-core/requests/get_load_balancer.rb +21 -0
  274. data/lib/vendor/core/ey-core/requests/get_load_balancer_node.rb +21 -0
  275. data/lib/vendor/core/ey-core/requests/get_load_balancer_nodes.rb +30 -0
  276. data/lib/vendor/core/ey-core/requests/get_load_balancer_service.rb +21 -0
  277. data/lib/vendor/core/ey-core/requests/get_load_balancer_services.rb +30 -0
  278. data/lib/vendor/core/ey-core/requests/get_load_balancers.rb +29 -0
  279. data/lib/vendor/core/ey-core/requests/get_log.rb +21 -0
  280. data/lib/vendor/core/ey-core/requests/get_logical_database.rb +23 -0
  281. data/lib/vendor/core/ey-core/requests/get_logical_databases.rb +43 -0
  282. data/lib/vendor/core/ey-core/requests/get_logs.rb +37 -0
  283. data/lib/vendor/core/ey-core/requests/get_membership.rb +21 -0
  284. data/lib/vendor/core/ey-core/requests/get_message.rb +28 -0
  285. data/lib/vendor/core/ey-core/requests/get_messages.rb +27 -0
  286. data/lib/vendor/core/ey-core/requests/get_metadata.rb +26 -0
  287. data/lib/vendor/core/ey-core/requests/get_operational_contact.rb +21 -0
  288. data/lib/vendor/core/ey-core/requests/get_operational_contacts.rb +20 -0
  289. data/lib/vendor/core/ey-core/requests/get_plan_usages.rb +24 -0
  290. data/lib/vendor/core/ey-core/requests/get_possible_provider_locations.rb +19 -0
  291. data/lib/vendor/core/ey-core/requests/get_provider.rb +21 -0
  292. data/lib/vendor/core/ey-core/requests/get_provider_location.rb +29 -0
  293. data/lib/vendor/core/ey-core/requests/get_provider_locations.rb +28 -0
  294. data/lib/vendor/core/ey-core/requests/get_providers.rb +28 -0
  295. data/lib/vendor/core/ey-core/requests/get_request.rb +71 -0
  296. data/lib/vendor/core/ey-core/requests/get_requests.rb +29 -0
  297. data/lib/vendor/core/ey-core/requests/get_server.rb +34 -0
  298. data/lib/vendor/core/ey-core/requests/get_server_event.rb +20 -0
  299. data/lib/vendor/core/ey-core/requests/get_server_events.rb +28 -0
  300. data/lib/vendor/core/ey-core/requests/get_server_usages.rb +24 -0
  301. data/lib/vendor/core/ey-core/requests/get_servers.rb +25 -0
  302. data/lib/vendor/core/ey-core/requests/get_slot.rb +21 -0
  303. data/lib/vendor/core/ey-core/requests/get_slot_component.rb +21 -0
  304. data/lib/vendor/core/ey-core/requests/get_slot_components.rb +36 -0
  305. data/lib/vendor/core/ey-core/requests/get_slots.rb +28 -0
  306. data/lib/vendor/core/ey-core/requests/get_ssl_certificate.rb +23 -0
  307. data/lib/vendor/core/ey-core/requests/get_ssl_certificates.rb +28 -0
  308. data/lib/vendor/core/ey-core/requests/get_storage.rb +21 -0
  309. data/lib/vendor/core/ey-core/requests/get_storage_user.rb +21 -0
  310. data/lib/vendor/core/ey-core/requests/get_storage_users.rb +28 -0
  311. data/lib/vendor/core/ey-core/requests/get_storages.rb +28 -0
  312. data/lib/vendor/core/ey-core/requests/get_task.rb +21 -0
  313. data/lib/vendor/core/ey-core/requests/get_tasks.rb +28 -0
  314. data/lib/vendor/core/ey-core/requests/get_untracked_server.rb +18 -0
  315. data/lib/vendor/core/ey-core/requests/get_untracked_servers.rb +24 -0
  316. data/lib/vendor/core/ey-core/requests/get_user.rb +21 -0
  317. data/lib/vendor/core/ey-core/requests/get_users.rb +42 -0
  318. data/lib/vendor/core/ey-core/requests/get_volume.rb +21 -0
  319. data/lib/vendor/core/ey-core/requests/get_volumes.rb +28 -0
  320. data/lib/vendor/core/ey-core/requests/reboot_server.rb +39 -0
  321. data/lib/vendor/core/ey-core/requests/request_callback.rb +24 -0
  322. data/lib/vendor/core/ey-core/requests/run_cluster_application_action.rb +28 -0
  323. data/lib/vendor/core/ey-core/requests/run_cluster_component_action.rb +181 -0
  324. data/lib/vendor/core/ey-core/requests/run_environment_application_action.rb +29 -0
  325. data/lib/vendor/core/ey-core/requests/signup.rb +60 -0
  326. data/lib/vendor/core/ey-core/requests/update_addon.rb +28 -0
  327. data/lib/vendor/core/ey-core/requests/update_addon_attachment.rb +63 -0
  328. data/lib/vendor/core/ey-core/requests/update_alert.rb +32 -0
  329. data/lib/vendor/core/ey-core/requests/update_application_archive.rb +23 -0
  330. data/lib/vendor/core/ey-core/requests/update_billing.rb +26 -0
  331. data/lib/vendor/core/ey-core/requests/update_cluster.rb +33 -0
  332. data/lib/vendor/core/ey-core/requests/update_cluster_component.rb +29 -0
  333. data/lib/vendor/core/ey-core/requests/update_connector.rb +32 -0
  334. data/lib/vendor/core/ey-core/requests/update_membership.rb +29 -0
  335. data/lib/vendor/core/ey-core/requests/update_server.rb +29 -0
  336. data/lib/vendor/core/ey-core/requests/update_slot.rb +37 -0
  337. data/lib/vendor/core/ey-core/requests/update_slot_component.rb +29 -0
  338. data/lib/vendor/core/ey-core/requests/update_ssl_certificate.rb +25 -0
  339. data/lib/vendor/core/ey-core/requests/update_untracked_server.rb +24 -0
  340. data/lib/vendor/core/ey-core/requests/upload_file.rb +44 -0
  341. data/lib/vendor/core/ey-core/response.rb +55 -0
  342. data/lib/vendor/core/ey-core/response_cache.rb +29 -0
  343. data/lib/vendor/core/ey-core/subscribable.rb +49 -0
  344. data/lib/vendor/core/ey-core/token_authentication.rb +13 -0
  345. data/lib/vendor/core/ey-core/version.rb +5 -0
  346. metadata +577 -0
@@ -0,0 +1,107 @@
1
+ require 'optparse'
2
+ require 'ostruct'
3
+ require 'ey-core'
4
+ require 'awesome_print'
5
+
6
+ Cistern.formatter = Cistern::Formatter::AwesomePrint
7
+
8
+ class Ey::Core::Cli
9
+
10
+ def self.stdout
11
+ @stdout ||= STDOUT
12
+ end
13
+
14
+ def self.say(*args)
15
+ self.stdout.puts(*args)
16
+ end
17
+
18
+ attr_reader :options, :action, :resource, :client
19
+
20
+ def initialize(args=ARGV)
21
+ @action, @options = parse(args)
22
+ end
23
+
24
+ def parse(args)
25
+ options = {}
26
+
27
+ action, resource_name, resource_id = OptionParser.new do |opts|
28
+ opts.banner = "Usage: ey-core ACTION RESOURCE RESOURCE_ID [options]"
29
+
30
+ opts.separator ""
31
+ opts.separator "Specific options:"
32
+
33
+ opts.on("-t", "--token [TOKEN]",
34
+ "Use specific token. Defaults to core url entry in ~/.ey-core yaml file") do |token|
35
+ options[:token] = token
36
+ end
37
+
38
+ opts.on("-u", "--url [URL]",
39
+ "Use specific core URL. Defaults to 'https://api.engineyard.com'") do |url|
40
+ options[:url] = url
41
+ end
42
+
43
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
44
+ options[:logger] = v ? Logger.new(STDOUT) : Logger.new(nil)
45
+ end
46
+
47
+ opts.separator ""
48
+ opts.separator "Common options:"
49
+
50
+ # No argument, shows at tail. This will print an options summary.
51
+ # Try it and see!
52
+ opts.on_tail("-h", "--help", "Show this message") do
53
+ puts opts
54
+ exit
55
+ end
56
+
57
+ # Another typical switch to print the version.
58
+ opts.on_tail("--version", "Show version") do
59
+ puts Ey::Core::VERSION
60
+ exit
61
+ end
62
+ end.parse!(args)
63
+
64
+ set_client(options)
65
+
66
+ set_resource(action, resource_name, resource_id)
67
+
68
+ [action, (options.to_hash || {})]
69
+ end
70
+
71
+ def run
72
+ public_send(action)
73
+ end
74
+
75
+ def show
76
+ Ey::Core::Cli.say(resource.ai)
77
+ end
78
+
79
+ def destroy
80
+ response = resource.destroy!
81
+
82
+ if response.is_a?(Ey::Core::Client::Request)
83
+ response.wait_for!(response.service.timeout, response.service.poll_interval) do |request|
84
+ Ey::Core::Cli.say "Waiting ... #{Time.now}"
85
+ Ey::Core::Cli.say(response.ai) unless request.ready?
86
+ request.ready?
87
+ end
88
+ end
89
+
90
+ Ey::Core::Cli.say(response.ai)
91
+ end
92
+
93
+ def set_client(options)
94
+ @client ||= Ey::Core::Client.new(options)
95
+ end
96
+
97
+ def set_resource(action, resource_name, resource_id)
98
+ action || raise(ArgumentError.new("Missing action"))
99
+ Ey::Core::Client.models.find { |m,_| m.to_s == resource_name } || raise(ArgumentError.new("Unknown resource: #{resource_name}"))
100
+ %w[show destroy].include?(action) || raise(ArgumentError.new("Unknown action: #{action}"))
101
+
102
+ # TODO: irregular inflections and all that
103
+ collection = "#{resource_name.to_s}s"
104
+
105
+ @resource = client.public_send(collection).get!(resource_id)
106
+ end
107
+ end # class Ey::Core::Cli
@@ -0,0 +1,764 @@
1
+ class Ey::Core::Client < Cistern::Service
2
+ collection_path "ey-core/collections"
3
+ model_path "ey-core/models"
4
+ request_path "ey-core/requests"
5
+
6
+ collection :accounts
7
+ collection :account_cancellations
8
+ collection :account_referrals
9
+ collection :addons
10
+ collection :addon_attachments
11
+ collection :addresses
12
+ collection :alerts
13
+ collection :applications
14
+ collection :application_archives
15
+ collection :application_deployments
16
+ collection :backup_files
17
+ collection :backups
18
+ collection :cluster_components
19
+ collection :cluster_updates
20
+ collection :clusters
21
+ collection :component_actions
22
+ collection :components
23
+ collection :connectors
24
+ collection :costs
25
+ collection :database_server_revisions
26
+ collection :database_server_snapshots
27
+ collection :database_servers
28
+ collection :database_services
29
+ collection :database_server_usages
30
+ collection :database_plan_usages
31
+ collection :environments
32
+ collection :environment_plan_usages
33
+ collection :firewalls
34
+ collection :firewall_rules
35
+ collection :features
36
+ collection :gems
37
+ collection :keypairs
38
+ collection :keypair_deployments
39
+ collection :legacy_alerts
40
+ collection :load_balancers
41
+ collection :load_balancer_services
42
+ collection :load_balancer_nodes
43
+ collection :logical_databases
44
+ collection :logs
45
+ collection :memberships
46
+ collection :messages
47
+ collection :contacts
48
+ collection :plan_usages
49
+ collection :providers
50
+ collection :provider_locations
51
+ collection :requests
52
+ collection :servers
53
+ collection :server_events
54
+ collection :server_usages
55
+ collection :slots
56
+ collection :slot_components
57
+ collection :ssl_certificates
58
+ collection :storage_users
59
+ collection :storages
60
+ collection :tasks
61
+ collection :tokens
62
+ collection :untracked_servers
63
+ collection :users
64
+ collection :volumes
65
+
66
+ model :account
67
+ model :account_referral
68
+ model :account_trial
69
+ model :alert
70
+ model :billing
71
+ model :account_cancellation
72
+ model :addon
73
+ model :addon_attachment
74
+ model :address
75
+ model :legacy_alert
76
+ model :application
77
+ model :application_archive
78
+ model :application_deployment
79
+ model :backup
80
+ model :backup_file
81
+ model :cluster
82
+ model :cluster_component
83
+ model :cluster_update
84
+ model :component
85
+ model :component_action
86
+ model :connector
87
+ model :cost
88
+ model :database_server
89
+ model :database_server_snapshot
90
+ model :database_server_revision
91
+ model :database_service
92
+ model :database_server_usage
93
+ model :database_plan_usage
94
+ model :environment
95
+ model :environment_plan_usage
96
+ model :feature
97
+ model :firewall
98
+ model :firewall_rule
99
+ model :gem
100
+ model :keypair
101
+ model :keypair_deployment
102
+ model :load_balancer
103
+ model :load_balancer_service
104
+ model :load_balancer_node
105
+ model :log
106
+ model :logical_database
107
+ model :membership
108
+ model :message
109
+ model :metadata
110
+ model :contact
111
+ model :plan_usage
112
+ model :provider
113
+ model :provider_location
114
+ model :request
115
+ model :server
116
+ model :server_event
117
+ model :server_usage
118
+ model :slot
119
+ model :slot_component
120
+ model :ssl_certificate
121
+ model :storage
122
+ model :storage_user
123
+ model :task
124
+ model :token
125
+ model :untracked_server
126
+ model :user
127
+ model :volume
128
+
129
+ request :attach_address
130
+ request :authorized_channel
131
+ request :bootstrap_logical_database
132
+ request :cancel_account
133
+ request :create_account
134
+ request :create_addon
135
+ request :create_address
136
+ request :create_alert
137
+ request :create_application
138
+ request :create_application_archive
139
+ request :create_backup
140
+ request :create_backup_file
141
+ request :create_cluster
142
+ request :create_cluster_component
143
+ request :create_cluster_update
144
+ request :create_connector
145
+ request :create_database_server
146
+ request :create_database_service
147
+ request :create_environment
148
+ request :create_firewall
149
+ request :create_firewall_rule
150
+ request :create_keypair
151
+ request :create_keypair_deployment
152
+ request :create_load_balancer
153
+ request :create_log
154
+ request :create_logical_database
155
+ request :create_membership
156
+ request :create_message
157
+ request :create_provider
158
+ request :create_slots
159
+ request :create_ssl_certificate
160
+ request :create_storage
161
+ request :create_storage_user
162
+ request :create_task
163
+ request :create_token
164
+ request :create_untracked_server
165
+ request :create_user
166
+ request :detach_address
167
+ request :destroy_addon
168
+ request :destroy_cluster
169
+ request :destroy_environment
170
+ request :destroy_database_service
171
+ request :destroy_database_server
172
+ request :destroy_firewall
173
+ request :destroy_user
174
+ request :destroy_firewall_rule
175
+ request :destroy_load_balancer
176
+ request :destroy_logical_database
177
+ request :destroy_provider
178
+ request :destroy_server
179
+ request :destroy_ssl_certificate
180
+ request :destroy_storage
181
+ request :destroy_storage_user
182
+ request :disable_feature
183
+ request :discover_database_server
184
+ request :discover_database_server_snapshots
185
+ request :discover_provider_location
186
+ request :download_file
187
+ request :enable_feature
188
+ request :finish_backup
189
+ request :get_account
190
+ request :get_account_cancellation
191
+ request :get_account_trial
192
+ request :get_accounts
193
+ request :get_account_referrals
194
+ request :get_addon
195
+ request :get_addon_attachment
196
+ request :get_addon_attachments
197
+ request :get_addons
198
+ request :get_address
199
+ request :get_addresses
200
+ request :get_alert
201
+ request :get_alerting_environments
202
+ request :get_alerts
203
+ request :get_application
204
+ request :get_application_archive
205
+ request :get_application_archives
206
+ request :get_application_deployment
207
+ request :get_application_deployments
208
+ request :get_applications
209
+ request :get_backup
210
+ request :get_backup_file
211
+ request :get_backup_files
212
+ request :get_backups
213
+ request :get_billing
214
+ request :get_cluster
215
+ request :get_cluster_component
216
+ request :get_cluster_components
217
+ request :get_cluster_update
218
+ request :get_cluster_updates
219
+ request :get_clusters
220
+ request :get_component
221
+ request :get_component_action
222
+ request :get_component_actions
223
+ request :get_components
224
+ request :get_connector
225
+ request :get_connectors
226
+ request :get_contacts
227
+ request :get_costs
228
+ request :get_current_user
229
+ request :get_database_server
230
+ request :get_database_server_revisions
231
+ request :get_database_server_snapshot
232
+ request :get_legacy_alert
233
+ request :get_legacy_alerts
234
+ request :get_database_server_snapshots
235
+ request :get_database_servers
236
+ request :get_database_servers_firewalls
237
+ request :get_database_service
238
+ request :get_database_services
239
+ request :get_database_server_usages
240
+ request :get_database_plan_usages
241
+ request :get_environment
242
+ request :get_environment_database_services
243
+ request :get_environment_logical_databases
244
+ request :get_environment_plan_usages
245
+ request :get_environments
246
+ request :get_feature
247
+ request :get_features
248
+ request :get_firewall
249
+ request :get_firewalls
250
+ request :get_firewall_rule
251
+ request :get_firewall_rules
252
+ request :get_gem
253
+ request :get_keypair
254
+ request :get_keypairs
255
+ request :get_keypair_deployment
256
+ request :get_keypair_deployments
257
+ request :get_load_balancer
258
+ request :get_load_balancers
259
+ request :get_load_balancer_service
260
+ request :get_load_balancer_services
261
+ request :get_load_balancer_node
262
+ request :get_load_balancer_nodes
263
+ request :get_log
264
+ request :get_logical_database
265
+ request :get_logs
266
+ request :get_logical_databases
267
+ request :get_membership
268
+ request :get_message
269
+ request :get_messages
270
+ request :get_metadata
271
+ request :get_plan_usages
272
+ request :get_possible_provider_locations
273
+ request :get_provider
274
+ request :get_providers
275
+ request :get_provider_location
276
+ request :get_provider_locations
277
+ request :get_request
278
+ request :get_requests
279
+ request :get_server
280
+ request :get_server_usages
281
+ request :get_servers
282
+ request :get_server_event
283
+ request :get_server_events
284
+ request :get_slot
285
+ request :get_slot_component
286
+ request :get_slot_components
287
+ request :get_slots
288
+ request :get_ssl_certificate
289
+ request :get_ssl_certificates
290
+ request :get_storage
291
+ request :get_storages
292
+ request :get_storage_user
293
+ request :get_storage_users
294
+ request :get_task
295
+ request :get_tasks
296
+ request :get_untracked_server
297
+ request :get_untracked_servers
298
+ request :get_user
299
+ request :get_users
300
+ request :get_volumes
301
+ request :request_callback
302
+ request :run_cluster_application_action
303
+ request :reboot_server
304
+ request :run_cluster_component_action
305
+ request :run_environment_application_action
306
+ request :signup
307
+ request :update_addon
308
+ request :update_addon_attachment
309
+ request :update_alert
310
+ request :update_application_archive
311
+ request :update_billing
312
+ request :update_cluster
313
+ request :update_cluster_component
314
+ request :update_connector
315
+ request :update_membership
316
+ request :update_server
317
+ request :update_slot
318
+ request :update_slot_component
319
+ request :update_ssl_certificate
320
+ request :update_untracked_server
321
+ request :upload_file
322
+
323
+ recognizes :token, :url, :logger, :adapter, :builder, :connection_options, :auth_id, :auth_key, :cache
324
+
325
+ module Shared
326
+ attr_reader :authentication, :url, :cache
327
+
328
+ def setup(options)
329
+ token_dotfile = begin
330
+ YAML.load_file(File.expand_path("~/.ey-core"))
331
+ rescue Errno::ENOENT
332
+ {}
333
+ end
334
+
335
+ resolved_url = options[:url] || ENV["CORE_URL"] || "https://api.engineyard.com/"
336
+ @url = File.join(resolved_url, "/") # trailing slash # consistency # hash tag you're welcome
337
+ @cache = if options[:cache] == true
338
+ Ey::Core::MemoryCache
339
+ else options[:cache]
340
+ end
341
+ @token = options[:token] || token_dotfile[@url] || token_dotfile[@url.gsub(/\/$/, "")] # matching with or without trailing slash
342
+
343
+ # For HMAC
344
+ @auth_id = options[:auth_id]
345
+ @auth_key = options[:auth_key]
346
+
347
+ if !@auth_id && !@auth_key && !@token
348
+ raise "Missing token. Use Ey::Core::Client.new(token: mytoken) or add \"'#{@url}': mytoken\" to your ~/.ey-core file" unless @token
349
+ elsif options[:token] || (@token && !@auth_id) # token was explicitly provided
350
+ @authentication = :token
351
+ else
352
+ @authentication = :hmac
353
+ @token = nil
354
+ end
355
+
356
+ @logger = options[:logger] || Logger.new(nil)
357
+ end
358
+
359
+ # strong parameter emulation
360
+ def require_parameters(_params, *_requirements)
361
+ params = Cistern::Hash.stringify_keys(_params)
362
+ requirements = _requirements.map(&:to_s)
363
+
364
+ requirements.each do |requirement|
365
+ unless !params[requirement].nil?
366
+ if self.class == Ey::Core::Client::Real
367
+ raise ArgumentError, "param is missing or the value is empty: #{requirement}"
368
+ else
369
+ response(
370
+ :status => 400,
371
+ :body => "param is missing or the value is empty: #{requirement}")
372
+ end
373
+ end
374
+ end
375
+ values = params.values_at(*requirements)
376
+ values.size == 1 ? values.first : values
377
+ end
378
+
379
+ def require_arguments(_params, *_requirements)
380
+ params = Cistern::Hash.stringify_keys(_params)
381
+ requirements = _requirements.map(&:to_s)
382
+
383
+ values = requirements.map do |requirement|
384
+ if params[requirement].nil?
385
+ raise ArgumentError, "argument is missing or the value is empty: #{requirement}"
386
+ end
387
+ params[requirement]
388
+ end
389
+ [params, *values]
390
+ end
391
+
392
+ def require_argument(_params, *_requirements)
393
+ params = Cistern::Hash.stringify_keys(_params)
394
+ requirements = _requirements.map(&:to_s)
395
+
396
+ values = params.values_at(*requirements)
397
+ values.all?(&:nil?) && raise(ArgumentError.new("argument is missing or the value is empty: #{requirement}"))
398
+ values.size == 1 ? values.first : values
399
+ end
400
+
401
+ def require_argument!(_params, *_requirements)
402
+ params = Cistern::Hash.stringify_keys(_params)
403
+ requirements = _requirements.map(&:to_s)
404
+
405
+ values = params.values_at(*requirements)
406
+ values.all?(&:nil?) && raise(ArgumentError.new("argument is missing or the value is empty: #{requirement}"))
407
+ requirements.each { |r| params.delete(r) }
408
+ values.size == 1 ? values.first : values
409
+ end
410
+
411
+ def url_for(path)
412
+ File.join(@url.to_s, path.to_s)
413
+ end
414
+ end
415
+
416
+ class Real
417
+ include Shared
418
+
419
+ def initialize(options={})
420
+ setup(options)
421
+ adapter = options[:adapter] || Faraday.default_adapter
422
+ connection_options = options[:connection_options] || {}
423
+
424
+ @connection = Faraday.new({url: @url}.merge(connection_options)) do |builder|
425
+ # response
426
+ builder.response :json, content_type: /json/
427
+
428
+ builder.use Ey::Core::ResponseCache, cache: @cache if @cache
429
+
430
+ # request
431
+ builder.request :multipart
432
+ builder.request :json
433
+
434
+ # request
435
+ builder.request :retry,
436
+ :max => 5,
437
+ :interval => 1,
438
+ :interval_randomness => 0.05,
439
+ :backoff_factor => 2
440
+
441
+ if @token
442
+ builder.use Ey::Core::TokenAuthentication, @token
443
+ else
444
+ builder.use :hmac, @auth_id, @auth_key
445
+ end
446
+
447
+ builder.use Ey::Core::Logger, @logger
448
+
449
+ if options[:builder]
450
+ options[:builder].call(builder)
451
+ end
452
+
453
+ builder.adapter(*adapter)
454
+ end
455
+ end
456
+
457
+ def request(options={})
458
+ method = options[:method] || :get
459
+ url = options[:url] || File.join(@url, options[:path] || "/")
460
+ #@todo query is a band-aid
461
+ query = options[:query] || {}
462
+ params = query.merge(options[:params] || {})
463
+ body = options[:body]
464
+ headers = options[:headers] || {}
465
+
466
+ default_content_type = if !body && !params.empty?
467
+ "application/x-www-form-urlencoded"
468
+ else
469
+ "application/json"
470
+ end
471
+ headers = {
472
+ "Content-Type" => default_content_type,
473
+ "Accept" => accept_type,
474
+ }.merge(headers)
475
+
476
+ response = @connection.send(method) do |req|
477
+ req.url(url)
478
+ req.headers.merge!(headers)
479
+ req.params.merge!(params)
480
+ req.body = body
481
+ end
482
+
483
+ Ey::Core::Response.new(
484
+ :status => response.status,
485
+ :headers => response.headers,
486
+ :body => response.body,
487
+ :request => {
488
+ :method => method,
489
+ :url => url,
490
+ :headers => headers,
491
+ :body => body,
492
+ :params => params,
493
+ }
494
+ ).raise!
495
+ end
496
+
497
+ def accept_type
498
+ "application/vnd.engineyard.v2+json"
499
+ end
500
+
501
+ def reset!
502
+ request(method: :post, path: "/client/reset")
503
+ rescue Ey::Core::Response::NotFound # allow me to test against something real where this route doesn't exist
504
+ nil
505
+ end
506
+
507
+ end # Real
508
+
509
+ class Mock
510
+ include Shared
511
+
512
+ include Ey::Core::Mock::Params
513
+ include Ey::Core::Mock::Resources
514
+ include Ey::Core::Mock::Searching
515
+ include Ey::Core::Mock::Util
516
+ include Ey::Core::Mock::Helper
517
+ extend Ey::Core::Mock::Util
518
+
519
+ def self.for(type, options={})
520
+ case type
521
+ when :server
522
+ client = Ey::Core::Client::Mock.for(:user)
523
+ server_options = options[:server] || {}
524
+
525
+ account_name = server_options.fetch(:account_name, SecureRandom.hex(4))
526
+ location = server_options.fetch(:location, "us-west-2")
527
+ cluster_name = server_options.fetch(:cluster_name, SecureRandom.hex(4))
528
+ environment_name = server_options.fetch(:environment_name, SecureRandom.hex(4))
529
+
530
+ account = client.accounts.create!(name: account_name)
531
+
532
+ provider = account.providers.create!(type: :aws)
533
+ environment = account.environments.create!(name: environment_name)
534
+ cluster = client.clusters.create!(environment: environment, location: location, provider: provider, name: cluster_name)
535
+ cluster.slots.create!
536
+ cluster.cluster_updates.create!.resource!
537
+ cluster.slots.first.server
538
+ when :user
539
+ user = Ey::Core::Client::Mock.for(:consumer).users.create!(
540
+ {
541
+ :name => "#{SecureRandom.hex(3)} #{SecureRandom.hex(3)}",
542
+ :email => "#{SecureRandom.hex(8)}@example.org",
543
+ }.merge(options[:user] || {})
544
+ )
545
+ Ey::Core::Client.new(token: user.token)
546
+ when :consumer
547
+ Ey::Core::Client.new({auth_id: SecureRandom.hex(8), auth_key: SecureRandom.hex(16)}.merge(options[:consumer] || {}))
548
+ end
549
+ end
550
+
551
+ def self.data
552
+ @data ||= Hash.new do |h,k|
553
+ h[k] = begin
554
+ cc_id = self.uuid
555
+ dc_id = self.uuid
556
+ app_id = self.uuid
557
+ deis_id = self.uuid
558
+ components = {
559
+ cc_id => {
560
+ "created_at" => Time.now.to_s,
561
+ "deleted_at" => nil,
562
+ "id" => cc_id,
563
+ "name" => "cluster_cookbooks",
564
+ "updated_at" => Time.now.to_s,
565
+ "uri" => "git://github.com/engineyard/cluster_cookbooks.git",
566
+ },
567
+ dc_id => {
568
+ "created_at" => Time.now.to_s,
569
+ "deleted_at" => nil,
570
+ "id" => dc_id,
571
+ "name" => "default_cookbooks",
572
+ "updated_at" => Time.now.to_s,
573
+ "uri" => "git://github.com/engineyard/cloud_cookbooks.git",
574
+ },
575
+ app_id => {
576
+ "created_at" => Time.now.to_s,
577
+ "deleted_at" => nil,
578
+ "id" => app_id,
579
+ "name" => "default_deployer",
580
+ "updated_at" => Time.now.to_s,
581
+ "uri" => "git://github.com/engineyard/engineyard-serverside.git",
582
+ },
583
+ deis_id => {
584
+ "created_at" => Time.now.to_s,
585
+ "deleted_at" => nil,
586
+ "id" => deis_id,
587
+ "name" => "deis",
588
+ "updated_at" => Time.now.to_s,
589
+ "uri" => "git://github.com/deis/deis.git",
590
+ }
591
+ }
592
+ possible_provider_locations = {
593
+ "azure" => [{"id"=>"East US", "name"=>"East US"}, {"id"=>"North Europe", "name"=>"North Europe"}, {"id"=>"West Europe", "name"=>"West Europe"}, {"id"=>"West US", "name"=>"West US"}, {"id"=>"Japan East", "name"=>"Japan East"}],
594
+ "aws" => [{"id"=>"us-east-1", "name"=>"Eastern United States"}, {"id"=>"us-west-1", "name"=>"Western US (Northern CA)"}, {"id"=>"us-west-2", "name"=>"Western US (Oregon)"}, {"id"=>"sa-east-1", "name"=>"South America"}, {"id"=>"eu-west-1", "name"=>"Europe"}, {"id"=>"ap-southeast-1", "name"=>"Singapore"}, {"id"=>"ap-southeast-2", "name"=>"Australia"}, {"id"=>"ap-northeast-1", "name"=>"Japan"}]
595
+ }
596
+ {
597
+ :accounts => {},
598
+ :account_referrals => {},
599
+ :addons => {},
600
+ :addresses => {},
601
+ :alerts => {},
602
+ :applications => {},
603
+ :application_archives => {},
604
+ :application_deployments => {},
605
+ :backup_files => {},
606
+ :backups => {},
607
+ :billing => {},
608
+ :cluster_components => {},
609
+ :cluster_updates => {},
610
+ :clusters => {},
611
+ :cluster_firewalls => [],
612
+ :component_actions => {},
613
+ :components => components,
614
+ :connectors => {},
615
+ :contacts => {},
616
+ :contact_assignments => [],
617
+ :costs => [],
618
+ :database_server_firewalls => [],
619
+ :database_server_revisions => {},
620
+ :database_server_snapshots => {},
621
+ :database_servers => {},
622
+ :database_services => {},
623
+ :database_server_usages => Hash.new { |h1,k1| h1[k1] = {} },
624
+ :database_plan_usages => Hash.new { |h1,k1| h1[k1] = {} },
625
+ :environment_plan_usages => Hash.new { |h1,k1| h1[k1] = {} },
626
+ :deleted => Hash.new {|x,y| x[y] = {}},
627
+ :environments => {},
628
+ :features => {},
629
+ :firewalls => {},
630
+ :firewall_rules => {},
631
+ :keypairs => {},
632
+ :keypair_deployments => {},
633
+ :legacy_alerts => {},
634
+ :load_balancers => {},
635
+ :load_balancer_services => {},
636
+ :load_balancer_nodes => {},
637
+ :logs => {},
638
+ :logical_databases => {},
639
+ :memberships => {},
640
+ :messages => {},
641
+ :plan_usages => Hash.new { |h1,k1| h1[k1] = {} },
642
+ :possible_provider_locations => possible_provider_locations,
643
+ :projects => {},
644
+ :providers => {},
645
+ :provider_locations => {},
646
+ :requests => {},
647
+ :servers => {},
648
+ :server_events => {},
649
+ :server_usages => Hash.new { |h1,k1| h1[k1] = {} },
650
+ :slots => {},
651
+ :slot_components => {},
652
+ :ssl_certificates => {},
653
+ :storages => {},
654
+ :storage_users => {},
655
+ :tasks => {},
656
+ :temp_files => {},
657
+ :untracked_servers => {},
658
+ :users => {},
659
+ :volumes => {},
660
+ }
661
+ end
662
+ end
663
+ end
664
+
665
+ class << self
666
+ attr_accessor :delay
667
+ end
668
+
669
+ def self.reset!
670
+ @data = nil
671
+ @serial_id = 1
672
+ @delay = 1
673
+ end
674
+
675
+ def delay
676
+ self.class.delay
677
+ end
678
+
679
+ def data
680
+ self.class.data[self.url]
681
+ end
682
+
683
+ attr_reader :current_server
684
+
685
+ def initialize(options={})
686
+ setup(options)
687
+ @url = options[:url] || "https://api.engineyard.com"
688
+
689
+ if authentication == :token
690
+ if server = self.data[:servers].values.find { |s| s["token"] == options[:token] }
691
+ @current_server = server
692
+ else
693
+ @current_user ||= begin
694
+ _,found = self.data[:users].detect{|k,v| v["token"] == options[:token]}
695
+ found
696
+ end
697
+
698
+ # FIXME(rs) get rid of this and the implicit Josh Lane creation entirely
699
+ @current_user ||= begin
700
+ _,found = self.data[:users].detect{|k,v| v["email"] == "jlane@engineyard.com"}
701
+ found
702
+ end
703
+
704
+ unless @current_user
705
+ user = Ey::Core::Client.new({
706
+ :url => @url,
707
+ :auth_id => SecureRandom.hex(8),
708
+ :auth_key => SecureRandom.hex(16),
709
+ }).users.create!({
710
+ :email => "jlane@engineyard.com",
711
+ :name => "Joshua Lane",
712
+ })
713
+
714
+ if options[:token]
715
+ self.data[:users][user.id]["token"] = options[:token]
716
+ end
717
+
718
+ @current_user = self.data[:users][user.id]
719
+ end
720
+ end
721
+ end
722
+ end
723
+
724
+ # Lazily re-seeds data after reset
725
+ # @return [Hash] current user response
726
+ def current_user
727
+ if @current_user
728
+ self.data[:users][@current_user["id"]] ||= @current_user
729
+
730
+ @current_user
731
+ end
732
+ end
733
+
734
+ def response(options={})
735
+ status = options[:status] || 200
736
+ body = options[:body]
737
+ headers = {
738
+ "Content-Type" => "application/json; charset=utf-8"
739
+ }.merge(options[:headers] || {})
740
+
741
+
742
+ @logger.debug "MOCKED RESPONSE: #{status}"
743
+ @logger.debug('response') { headers.map { |k, v| "#{k}: #{v.inspect}" }.join("\n") }
744
+ @logger.debug caller[0]
745
+ @logger.debug('response.body') { body }
746
+ @logger.debug ''
747
+
748
+ Ey::Core::Response.new(
749
+ :status => status,
750
+ :headers => headers,
751
+ :body => body,
752
+ :request => {
753
+ :method => :mocked,
754
+ :url => caller[1],
755
+ }
756
+ ).raise!
757
+ end
758
+
759
+ def serial_id
760
+ @@serial_id ||= 0
761
+ @@serial_id += 1
762
+ end
763
+ end # Mock
764
+ end # Ey::Core::Client