brightbox-cli 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +18 -0
  4. data/Gemfile.lock +18 -19
  5. data/bin/_brightbox-bash-completer +42 -0
  6. data/brightbox-cli.gemspec +5 -5
  7. data/lib/brightbox-cli/accounts.rb +1 -3
  8. data/lib/brightbox-cli/api.rb +27 -8
  9. data/lib/brightbox-cli/cloud_ips.rb +11 -15
  10. data/lib/brightbox-cli/collaborating_account.rb +23 -26
  11. data/lib/brightbox-cli/collaboration.rb +1 -1
  12. data/lib/brightbox-cli/commands/{accounts-accept-invite.rb → accounts/accept-invite.rb} +2 -3
  13. data/lib/brightbox-cli/commands/{accounts-default.rb → accounts/default.rb} +1 -3
  14. data/lib/brightbox-cli/commands/{accounts-list.rb → accounts/list.rb} +1 -1
  15. data/lib/brightbox-cli/commands/{accounts-remove.rb → accounts/remove.rb} +1 -2
  16. data/lib/brightbox-cli/commands/{accounts-reset-ftp-password.rb → accounts/reset-ftp-password.rb} +10 -5
  17. data/lib/brightbox-cli/commands/{accounts-show.rb → accounts/show.rb} +14 -6
  18. data/lib/brightbox-cli/commands/{cloudips-create.rb → cloudips/create.rb} +4 -4
  19. data/lib/brightbox-cli/commands/{cloudips-destroy.rb → cloudips/destroy.rb} +1 -1
  20. data/lib/brightbox-cli/commands/{cloudips-list.rb → cloudips/list.rb} +2 -10
  21. data/lib/brightbox-cli/commands/{cloudips-map.rb → cloudips/map.rb} +2 -8
  22. data/lib/brightbox-cli/commands/{cloudips-show.rb → cloudips/show.rb} +13 -3
  23. data/lib/brightbox-cli/commands/{cloudips-unmap.rb → cloudips/unmap.rb} +1 -1
  24. data/lib/brightbox-cli/commands/{cloudips-update.rb → cloudips/update.rb} +5 -6
  25. data/lib/brightbox-cli/commands/collaborations.rb +3 -9
  26. data/lib/brightbox-cli/commands/{config-client-add.rb → config/client-add.rb} +2 -2
  27. data/lib/brightbox-cli/commands/{config-client-default.rb → config/client-default.rb} +1 -1
  28. data/lib/brightbox-cli/commands/{config-client-list.rb → config/client-list.rb} +3 -3
  29. data/lib/brightbox-cli/commands/{config-client-remove.rb → config/client-remove.rb} +4 -1
  30. data/lib/brightbox-cli/commands/{config-user-add.rb → config/user-add.rb} +1 -1
  31. data/lib/brightbox-cli/commands/{firewall-policies-apply.rb → firewall/policies-apply.rb} +3 -4
  32. data/lib/brightbox-cli/commands/{firewall-policies-create.rb → firewall/policies-create.rb} +3 -4
  33. data/lib/brightbox-cli/commands/{firewall-policies-destroy.rb → firewall/policies-destroy.rb} +2 -3
  34. data/lib/brightbox-cli/commands/{firewall-policies-list.rb → firewall/policies-list.rb} +2 -9
  35. data/lib/brightbox-cli/commands/{firewall-policies-remove.rb → firewall/policies-remove.rb} +2 -3
  36. data/lib/brightbox-cli/commands/{firewall-policies-show.rb → firewall/policies-show.rb} +11 -3
  37. data/lib/brightbox-cli/commands/{firewall-policies-update.rb → firewall/policies-update.rb} +3 -3
  38. data/lib/brightbox-cli/commands/{firewall-rules-create.rb → firewall/rules-create.rb} +4 -4
  39. data/lib/brightbox-cli/commands/{firewall-rules-destroy.rb → firewall/rules-destroy.rb} +2 -4
  40. data/lib/brightbox-cli/commands/{firewall-rules-list.rb → firewall/rules-list.rb} +2 -2
  41. data/lib/brightbox-cli/commands/{firewall-rules-show.rb → firewall/rules-show.rb} +10 -4
  42. data/lib/brightbox-cli/commands/{firewall-rules-update.rb → firewall/rules-update.rb} +3 -3
  43. data/lib/brightbox-cli/commands/{groups-add-server.rb → groups/add-server.rb} +2 -2
  44. data/lib/brightbox-cli/commands/{groups-create.rb → groups/create.rb} +3 -3
  45. data/lib/brightbox-cli/commands/{groups-destroy.rb → groups/destroy.rb} +2 -2
  46. data/lib/brightbox-cli/commands/groups/list.rb +14 -0
  47. data/lib/brightbox-cli/commands/{groups-move_servers.rb → groups/move_servers.rb} +1 -2
  48. data/lib/brightbox-cli/commands/{groups-remove-servers.rb → groups/remove-servers.rb} +1 -1
  49. data/lib/brightbox-cli/commands/{groups-show.rb → groups/show.rb} +1 -1
  50. data/lib/brightbox-cli/commands/{groups-update.rb → groups/update.rb} +5 -10
  51. data/lib/brightbox-cli/commands/{images-destroy.rb → images/destroy.rb} +2 -2
  52. data/lib/brightbox-cli/commands/{images-list.rb → images/list.rb} +2 -10
  53. data/lib/brightbox-cli/commands/{images-register.rb → images/register.rb} +6 -6
  54. data/lib/brightbox-cli/commands/{images-show.rb → images/show.rb} +2 -11
  55. data/lib/brightbox-cli/commands/{images-update.rb → images/update.rb} +8 -8
  56. data/lib/brightbox-cli/commands/{lbs-add-nodes.rb → lbs/add-nodes.rb} +2 -2
  57. data/lib/brightbox-cli/commands/{lbs-create.rb → lbs/create.rb} +16 -10
  58. data/lib/brightbox-cli/commands/{lbs-destroy.rb → lbs/destroy.rb} +1 -1
  59. data/lib/brightbox-cli/commands/{lbs-list.rb → lbs/list.rb} +2 -10
  60. data/lib/brightbox-cli/commands/{lbs-remove-nodes.rb → lbs/remove-nodes.rb} +2 -2
  61. data/lib/brightbox-cli/commands/{lbs-show.rb → lbs/show.rb} +4 -7
  62. data/lib/brightbox-cli/commands/{lbs-update.rb → lbs/update.rb} +16 -10
  63. data/lib/brightbox-cli/commands/{servers-activate-console.rb → servers/activate-console.rb} +3 -3
  64. data/lib/brightbox-cli/commands/{servers-create.rb → servers/create.rb} +4 -4
  65. data/lib/brightbox-cli/commands/{servers-destroy.rb → servers/destroy.rb} +2 -2
  66. data/lib/brightbox-cli/commands/{servers-list.rb → servers/list.rb} +7 -8
  67. data/lib/brightbox-cli/commands/{servers-show.rb → servers/show.rb} +1 -6
  68. data/lib/brightbox-cli/commands/{servers-shutdown.rb → servers/shutdown.rb} +1 -1
  69. data/lib/brightbox-cli/commands/{servers-snapshot.rb → servers/snapshot.rb} +1 -1
  70. data/lib/brightbox-cli/commands/{servers-start.rb → servers/start.rb} +1 -1
  71. data/lib/brightbox-cli/commands/{servers-stop.rb → servers/stop.rb} +1 -1
  72. data/lib/brightbox-cli/commands/{servers-update.rb → servers/update.rb} +2 -2
  73. data/lib/brightbox-cli/commands/sql/instances_create.rb +66 -0
  74. data/lib/brightbox-cli/commands/sql/instances_destroy.rb +28 -0
  75. data/lib/brightbox-cli/commands/sql/instances_list.rb +27 -0
  76. data/lib/brightbox-cli/commands/sql/instances_reset_password.rb +33 -0
  77. data/lib/brightbox-cli/commands/sql/instances_show.rb +26 -0
  78. data/lib/brightbox-cli/commands/sql/instances_snapshot.rb +25 -0
  79. data/lib/brightbox-cli/commands/sql/instances_update.rb +45 -0
  80. data/lib/brightbox-cli/commands/sql/snapshots_destroy.rb +31 -0
  81. data/lib/brightbox-cli/commands/sql/snapshots_list.rb +25 -0
  82. data/lib/brightbox-cli/commands/sql/snapshots_show.rb +26 -0
  83. data/lib/brightbox-cli/commands/sql/snapshots_update.rb +37 -0
  84. data/lib/brightbox-cli/commands/sql/types.rb +53 -0
  85. data/lib/brightbox-cli/commands/types.rb +1 -1
  86. data/lib/brightbox-cli/commands/users/list.rb +17 -0
  87. data/lib/brightbox-cli/commands/{users-show.rb → users/show.rb} +5 -13
  88. data/lib/brightbox-cli/commands/{users-update.rb → users/update.rb} +3 -3
  89. data/lib/brightbox-cli/config.rb +4 -7
  90. data/lib/brightbox-cli/config/accounts.rb +3 -6
  91. data/lib/brightbox-cli/config/api_client.rb +12 -4
  92. data/lib/brightbox-cli/config/authentication_tokens.rb +8 -14
  93. data/lib/brightbox-cli/config/clients.rb +6 -7
  94. data/lib/brightbox-cli/config/section_name_deduplicator.rb +4 -5
  95. data/lib/brightbox-cli/config/sections.rb +7 -10
  96. data/lib/brightbox-cli/config/user_application.rb +15 -7
  97. data/lib/brightbox-cli/connection_manager.rb +1 -2
  98. data/lib/brightbox-cli/database_server.rb +100 -0
  99. data/lib/brightbox-cli/database_snapshot.rb +36 -0
  100. data/lib/brightbox-cli/database_type.rb +44 -0
  101. data/lib/brightbox-cli/detailed_server.rb +8 -7
  102. data/lib/brightbox-cli/error_parser.rb +8 -4
  103. data/lib/brightbox-cli/firewall_rule.rb +5 -5
  104. data/lib/brightbox-cli/firewall_rules.rb +2 -3
  105. data/lib/brightbox-cli/gli_global_hooks.rb +7 -7
  106. data/lib/brightbox-cli/images.rb +13 -14
  107. data/lib/brightbox-cli/legacy/args_adjuster.rb +5 -6
  108. data/lib/brightbox-cli/load_balancers.rb +10 -13
  109. data/lib/brightbox-cli/logging.rb +3 -3
  110. data/lib/brightbox-cli/nilable_hash.rb +1 -1
  111. data/lib/brightbox-cli/ruby_core_ext.rb +1 -2
  112. data/lib/brightbox-cli/server_groups.rb +5 -5
  113. data/lib/brightbox-cli/servers.rb +9 -9
  114. data/lib/brightbox-cli/tables.rb +24 -25
  115. data/lib/brightbox-cli/types.rb +6 -5
  116. data/lib/brightbox-cli/user_collaboration.rb +2 -3
  117. data/lib/brightbox-cli/users.rb +3 -3
  118. data/lib/brightbox-cli/version.rb +1 -1
  119. data/lib/brightbox_cli.rb +10 -2
  120. data/locales/en.yml +205 -0
  121. data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_a_collection_of_Accounts.yml +10 -10
  122. data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_resources_on_the_same_connection.yml +4 -4
  123. data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_client/returns_a_collection_of_Accounts.yml +8 -8
  124. data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_client/returns_resources_on_the_same_connection.yml +4 -4
  125. data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_changes_to_the_config_file.yml +4 -4
  126. data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_the_default_account.yml +4 -4
  127. data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_the_new_client_as_the_default.yml +4 -4
  128. data/spec/cassettes/Brightbox_BBConfig/_find_or_set_default_account/when_client_is_not_authenticated/does_not_raise_an_error.yml +176 -176
  129. data/spec/cassettes/Brightbox_BBConfig/_find_or_set_default_account/when_client_may_access_one_account/updates_the_setting.yml +176 -176
  130. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_config_in_use_is_not_the_default/uses_correct_credentials.yml +2 -2
  131. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_a_cached_refresh_token/caches_the_new_tokens.yml +2 -2
  132. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_an_expired_refresh_token/caches_the_new_tokens.yml +4 -4
  133. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_no_tokens/caches_the_new_tokens.yml +2 -2
  134. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_no_tokens/prompts_user_to_retry_command.yml +2 -2
  135. data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_an_API_client_with_no_tokens/caches_a_new_access_token.yml +2 -2
  136. data/spec/cassettes/Brightbox_CloudIP/_find_all_/when_a_Cloud_IP_exists/returns_a_suitable.yml +28 -28
  137. data/spec/cassettes/Brightbox_FirewallPolicy/_apply_to/should_apply_firewall_policy.yml +24 -24
  138. data/spec/cassettes/Brightbox_FirewallPolicy/_create/should_create_firewall_policy.yml +24 -24
  139. data/spec/cassettes/Brightbox_FirewallPolicy/_destroy/should_destroy_firewall_policy.yml +28 -28
  140. data/spec/cassettes/Brightbox_FirewallPolicy/_find_all_/when_a_policy_exists/should_list_firewall_policy.yml +24 -24
  141. data/spec/cassettes/Brightbox_FirewallPolicy/_find_or_call/when_a_policy_exists/should_show_firewall_policy.yml +20 -20
  142. data/spec/cassettes/Brightbox_FirewallRule/_create/when_policy_exists/creates_the_rule_successfully.yml +24 -24
  143. data/spec/cassettes/Brightbox_FirewallRule/_destroy/when_rule_exists/destroys_a_rule.yml +20 -20
  144. data/spec/cassettes/Brightbox_FirewallRule/_find/when_rule_exists/can_display_the_result.yml +24 -24
  145. data/spec/cassettes/Brightbox_FirewallRule/_from_policy/when_policy_exists_with_a_rule/lists_all_rules.yml +32 -32
  146. data/spec/cassettes/Brightbox_Server/_destroy/when_server_exists/should_work.yml +20 -20
  147. data/spec/cassettes/Brightbox_Server/_find_all_/when_a_server_exists/should_print_server_list.yml +28 -28
  148. data/spec/cassettes/Brightbox_Server/_show/when_server_exists/shows_detailed_attributes_of_a_server.yml +32 -32
  149. data/spec/cassettes/Brightbox_Server/_shutdown/should_work.yml +32 -32
  150. data/spec/cassettes/Brightbox_Server/_start/should_work.yml +44 -44
  151. data/spec/cassettes/Brightbox_Server/_stop/should_work.yml +32 -32
  152. data/spec/cassettes/Brightbox_Server/_update/when_passing_new_group_membership/should_update_with_group.yml +40 -40
  153. data/spec/cassettes/Brightbox_ServerGroup/_find_all_/when_a_group_exists/list_server_groups.yml +24 -24
  154. data/spec/cassettes/Firewall_policies/update/when_the_policy_does_not_exist/prints_error_to_STDERR.yml +6 -6
  155. data/spec/cassettes/brightbox_accounts/list/_when_access_token_expired_/does_not_report_invalid_token_errors.yml +18 -18
  156. data/spec/cassettes/brightbox_accounts/list/_when_both_tokens_expired_/does_not_report_invalid_token_errors.yml +18 -18
  157. data/spec/cassettes/brightbox_accounts/list/_when_invalid_tokens_/does_not_report_invalid_token_errors.yml +18 -18
  158. data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_/does_not_report_invalid_token_errors.yml +16 -16
  159. data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_/reports_they_were_updated.yml +14 -14
  160. data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_and_password_incorrect_/does_not_report_invalid_token_errors.yml +14 -14
  161. data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_and_password_incorrect_/reports_unable_to_authenticate.yml +12 -12
  162. data/spec/cassettes/brightbox_accounts/list/does_not_error.yml +6 -6
  163. data/spec/cassettes/brightbox_cloudips/map/when_destination_is_a_server_ID/passes_the_interface_identifier_to_the_API.yml +542 -0
  164. data/spec/cassettes/brightbox_cloudips/map/when_destination_is_another_value/passes_the_identifier_to_the_API.yml +317 -0
  165. data/spec/cassettes/brightbox_config/client_add/when_adding_a_new_client/does_not_error.yml +154 -154
  166. data/spec/cassettes/brightbox_config/client_add/when_adding_a_new_client/sets_up_the_config.yml +154 -154
  167. data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/does_not_change_the_default_client.yml +154 -154
  168. data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/does_not_error.yml +154 -154
  169. data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/sets_this_as_the_default_client.yml +154 -154
  170. data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/sets_up_the_config.yml +154 -154
  171. data/spec/cassettes/brightbox_config/user_add/when_NO_config_file_on_disk/sets_up_the_config.yml +10 -10
  172. data/spec/cassettes/brightbox_config/user_add/when_a_default_client_is_already_set/does_not_change_the_default_client.yml +4 -4
  173. data/spec/cassettes/brightbox_config/user_add/when_application_details_in_config/does_not_error.yml +4 -4
  174. data/spec/cassettes/brightbox_config/user_add/when_application_details_in_config/sets_up_the_config.yml +4 -4
  175. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/display_an_warning_about_preselected_default.yml +4 -4
  176. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/does_not_error.yml +4 -4
  177. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/selects_the_active_account_for_the_default.yml +4 -4
  178. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/sets_up_the_config.yml +4 -4
  179. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/display_an_warning_about_preselected_default.yml +4 -4
  180. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/does_not_error.yml +4 -4
  181. data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/sets_up_the_config.yml +4 -4
  182. data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/does_not_error.yml +4 -4
  183. data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/does_not_prompt_to_rerun_the_command.yml +4 -4
  184. data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/requests_access_tokens.yml +4 -4
  185. data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/sets_this_as_the_default_client.yml +4 -4
  186. data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/sets_up_the_config.yml +10 -10
  187. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/does_not_error.yml +4 -4
  188. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/does_not_prompt_to_rerun_the_command.yml +4 -4
  189. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/requests_access_tokens.yml +4 -4
  190. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/sets_up_the_config.yml +6 -6
  191. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/does_not_error.yml +4 -4
  192. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/requests_access_tokens.yml +4 -4
  193. data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/sets_up_the_config.yml +4 -4
  194. data/spec/cassettes/brightbox_database-servers/create/--allow-access_10_0_0_0/correctly_sends_API_parameters.yml +93 -0
  195. data/spec/cassettes/brightbox_database-servers/create/--allow-access_srv-12345_grp-12345/correctly_sends_API_parameters.yml +93 -0
  196. data/spec/cassettes/brightbox_database-servers/create/--engine_mysql/correctly_sends_API_parameters.yml +93 -0
  197. data/spec/cassettes/brightbox_database-servers/create/--engine_mysql_--engine-version_5_6/correctly_sends_API_parameters.yml +93 -0
  198. data/spec/cassettes/brightbox_database-servers/create/without_arguments/reports_the_new_admin_password.yml +93 -0
  199. data/spec/cassettes/brightbox_database-servers/create/without_arguments/reports_the_new_admin_username.yml +93 -0
  200. data/spec/cassettes/brightbox_database-servers/snapshot/when_database_server_active/correctly_sends_API_parameters.yml +181 -0
  201. data/spec/cassettes/brightbox_database-servers/snapshot/when_database_server_can_not_be_snapshotted/reports_an_error_to_the_user.yml +91 -0
  202. data/spec/cassettes/brightbox_database-snapshots/list/when_resources_are_available/does_not_output_to_stderr.yml +93 -0
  203. data/spec/cassettes/brightbox_database-snapshots/list/when_resources_are_available/outputs_table_details_to_stdout.yml +93 -0
  204. data/spec/cassettes/brightbox_database-snapshots/show/when_resource_exists/does_not_output_to_stderr.yml +93 -0
  205. data/spec/commands/accounts/list_spec.rb +1 -1
  206. data/spec/commands/cloudips/map_spec.rb +23 -4
  207. data/spec/commands/config/user_add_spec.rb +1 -1
  208. data/spec/commands/sql/instances/create_spec.rb +69 -0
  209. data/spec/commands/sql/instances/snapshot_spec.rb +36 -0
  210. data/spec/commands/sql/snapshots/list_spec.rb +29 -0
  211. data/spec/commands/sql/snapshots/show_spec.rb +29 -0
  212. data/spec/commands/sql/types/list_spec.rb +18 -0
  213. data/spec/spec_helper.rb +1 -3
  214. data/spec/support/vcr.rb +1 -1
  215. data/spec/unit/brightbox/api/conn_spec.rb +1 -1
  216. data/spec/unit/brightbox/bb_config/add_section_spec.rb +1 -1
  217. data/spec/unit/brightbox/bb_config/renew_tokens_spec.rb +1 -1
  218. data/spec/unit/brightbox/database_server_spec.rb +9 -0
  219. data/spec/unit/brightbox/database_snapshot_spec.rb +9 -0
  220. data/spec/unit/brightbox/database_type_spec.rb +9 -0
  221. data/spec/unit/brightbox/firewall_policy/create_spec.rb +1 -1
  222. data/spec/unit/brightbox/firewall_policy/destroy_spec.rb +1 -1
  223. data/spec/unit/brightbox/firewall_rule/create_spec.rb +1 -1
  224. data/spec/unit/brightbox/firewall_rule/destroy_spec.rb +1 -1
  225. data/spec/unit/brightbox/firewall_rule/find_spec.rb +1 -1
  226. data/spec/unit/brightbox/firewall_rule/from_policy_spec.rb +1 -1
  227. data/spec/unit/brightbox/server/destroy_spec.rb +1 -1
  228. data/spec/unit/brightbox/server/find_or_call_spec.rb +1 -1
  229. data/spec/unit/brightbox/server/shutdown_spec.rb +1 -1
  230. data/spec/unit/brightbox/server/start_spec.rb +1 -1
  231. data/spec/unit/brightbox/server/stop_spec.rb +1 -1
  232. data/spec/unit/brightbox/server/update_spec.rb +1 -1
  233. data/spec/unit/brightbox/server_group/find_spec.rb +1 -1
  234. data/spec/unit/brightbox/user_collaboration/get_for_account_spec.rb +3 -3
  235. metadata +160 -115
  236. data/lib/brightbox-cli/commands/groups-list.rb +0 -21
  237. data/lib/brightbox-cli/commands/users-list.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0678676cc55013c6898bee325427d0c02bb2fe54
4
- data.tar.gz: b5239144c91e70eefd0af9b738a93e951da60412
3
+ metadata.gz: 73df8b7f77b6cece4674c53c522638a9133c2589
4
+ data.tar.gz: 9c520fe03b2f3600b5cb2994410bbd4e5751ed66
5
5
  SHA512:
6
- metadata.gz: c686363ed9d54106512b609ea7bb999fae4cdb2acdf59cbe52fb8f187d8c7b0e14746f9940b1840bffff964b257be3b76b0c3ac0810bfe329a4d6699e7657157
7
- data.tar.gz: 124cf8b8199b53f2eb08039b296a4fe396c8f7e1b1b718457b6845638e06010890c2493b4c31109970c194137a558d96312add6ff5c0d037449352daef346045
6
+ metadata.gz: e640fa3bf32d12fd90f5419dfce32d30b0a9308c3785532f9d7d6e225a3cf5ac78dec8340a362fc31ab762a0b2aec56d43ba1625f45ec5b0f9370d16739a4552
7
+ data.tar.gz: 26f3462157989d251640ff7480f947516479f386862a738ab7e23aecc978ad275875c58761e71b26a7ffe9870a95a686cc10aa0b520943c8f325d1d24eb7074d
data/.travis.yml CHANGED
@@ -5,4 +5,5 @@ rvm:
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0.0
8
+ - 2.1.0
8
9
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ ### v1.2.0 / 2014-03-10
2
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v1.1.0...v1.2.0)
3
+
4
+ Enhancements:
5
+
6
+ * Adds support for Cloud SQL instances to the CLI.
7
+ * Uses modular `fog-brightbox` gem to cut down on unnecessary dependencies
8
+ included using full `fog` gem.
9
+ * Can view more details related to SSL certificates on load balancers.
10
+ * Rely on API output to check which resources can have Cloud IPs mapped.
11
+ * `json` gem is no longer a hard dependency. If faster versions are available
12
+ they should be detected automatically.
13
+
14
+ Bug Fixes:
15
+
16
+ * `brightbox images show` and `brightbox lbs show` no longer error when
17
+ identifiers are not passed but display all resources like other commands.
18
+ * Help instructions for option arguments are correct following GLI update.
data/Gemfile.lock CHANGED
@@ -1,15 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightbox-cli (1.1.0)
5
- excon
6
- fog (~> 1.17.0)
7
- gli (~> 2.8)
4
+ brightbox-cli (1.2.0)
5
+ fog-brightbox
6
+ gli (~> 2.9)
8
7
  highline (~> 1.6)
9
8
  hirb (~> 0.6)
10
- json
9
+ i18n
11
10
  mime-types (~> 1.25)
12
- nokogiri (~> 1.5.0)
11
+ multi_json
13
12
 
14
13
  GEM
15
14
  remote: https://rubygems.org/
@@ -17,32 +16,33 @@ GEM
17
16
  builder (3.2.2)
18
17
  coderay (1.0.9)
19
18
  diff-lcs (1.2.4)
20
- excon (0.27.6)
21
- fog (1.17.0)
19
+ excon (0.31.0)
20
+ fog-brightbox (0.0.1)
21
+ fog-core
22
+ fog-json
23
+ fog-core (1.21.0)
22
24
  builder
23
- excon (~> 0.27.0)
25
+ excon (~> 0.31.0)
24
26
  formatador (~> 0.2.0)
25
27
  mime-types
26
- multi_json (~> 1.0)
27
28
  net-scp (~> 1.1)
28
29
  net-ssh (>= 2.1.3)
29
- nokogiri (~> 1.5)
30
- ruby-hmac
30
+ fog-json (1.0.0)
31
+ multi_json (~> 1.0)
31
32
  formatador (0.2.4)
32
- gli (2.8.1)
33
+ gli (2.9.0)
33
34
  highline (1.6.20)
34
35
  hirb (0.7.1)
35
- json (1.8.1)
36
+ i18n (0.6.9)
36
37
  metaclass (0.0.1)
37
38
  method_source (0.8.1)
38
- mime-types (1.25)
39
+ mime-types (1.25.1)
39
40
  mocha (0.14.0)
40
41
  metaclass (~> 0.0.1)
41
- multi_json (1.8.2)
42
+ multi_json (1.9.0)
42
43
  net-scp (1.1.2)
43
44
  net-ssh (>= 2.6.5)
44
- net-ssh (2.7.0)
45
- nokogiri (1.5.10)
45
+ net-ssh (2.8.0)
46
46
  pry (0.9.12.2)
47
47
  coderay (~> 1.0.5)
48
48
  method_source (~> 0.8)
@@ -56,7 +56,6 @@ GEM
56
56
  rspec-expectations (2.14.0)
57
57
  diff-lcs (>= 1.1.3, < 2.0)
58
58
  rspec-mocks (2.14.1)
59
- ruby-hmac (0.4.0)
60
59
  slop (3.4.5)
61
60
  vcr (2.5.0)
62
61
 
@@ -420,6 +420,48 @@ SPEC = { "brightbox" =>
420
420
  "start" => find_identifiers("srv-"),
421
421
  "stop" => find_identifiers("srv-")
422
422
  },
423
+ "sql" => {
424
+ "instances" => {
425
+ "create" => {
426
+ "-n=" => "--name=",
427
+ "--name" => true,
428
+ "-d=" => "--description",
429
+ "--description" => true,
430
+ "-t" => "--type",
431
+ "--type" => true,
432
+ "--allow-access" => true,
433
+ "--snapshot" => find_identifiers("dbi-")
434
+ },
435
+ "destroy" => find_identifiers("dbs-"),
436
+ "list" => find_identifiers("dbs-"),
437
+ "reset_password" => find_identifiers("dbs-"),
438
+ "show" => find_identifiers("dbs-"),
439
+ "snapshot" => find_identifiers("dbs-"),
440
+ "update" => {
441
+ "-n=" => "--name=",
442
+ "--name" => true,
443
+ "-d=" => "--description",
444
+ "--description" => true,
445
+ "--allow-access" => true,
446
+ :include => find_identifiers("dbs-")
447
+ },
448
+ },
449
+ "snapshots" => {
450
+ "destroy" => find_identifiers("dbi-"),
451
+ "list" => find_identifiers("dbi-"),
452
+ "update" => {
453
+ "-n=" => "--name=",
454
+ "--name" => true,
455
+ "-d=" => "--description",
456
+ "--description" => true,
457
+ :include => find_identifiers("dbi-")
458
+ },
459
+ },
460
+ "types" => {
461
+ "list" => find_identifiers("dbt-"),
462
+ "show" => find_identifiers("dbt-")
463
+ },
464
+ },
423
465
  "types" =>
424
466
  {
425
467
  "list" => find_server_types,
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "gli", "~> 2.8"
23
- s.add_dependency "fog", "~> 1.17.0"
24
- s.add_dependency "nokogiri", "~> 1.5.0" # 1.5.x last versions with 1.8.7 support
22
+ s.add_dependency "gli", "~> 2.9"
23
+ s.add_dependency "fog-brightbox"
24
+ s.add_dependency "multi_json"
25
25
  s.add_dependency "mime-types", "~> 1.25"
26
- s.add_dependency "excon"
27
- s.add_dependency "json"
26
+
27
+ s.add_dependency "i18n"
28
28
 
29
29
  s.add_dependency('hirb','~> 0.6')
30
30
  s.add_dependency('highline', '~> 1.6')
@@ -1,6 +1,5 @@
1
1
  module Brightbox
2
2
  class Account < Api
3
-
4
3
  def ram_free
5
4
  [ram_limit.to_i - ram_used.to_i, 0].max
6
5
  end
@@ -32,7 +31,7 @@ module Brightbox
32
31
  a = conn.account
33
32
  end
34
33
 
35
- if a and a.id == id
34
+ if a && a.id == id
36
35
  a
37
36
  else
38
37
  nil
@@ -46,6 +45,5 @@ module Brightbox
46
45
  def to_s
47
46
  @id
48
47
  end
49
-
50
48
  end
51
49
  end
@@ -40,19 +40,19 @@ module Brightbox
40
40
  # @return [String] the 'name' of the class
41
41
  #
42
42
  def self.klass_name
43
- name.split("::").last()
43
+ name.split("::").last
44
44
  end
45
45
 
46
46
  def initialize(m = nil)
47
47
  if m.is_a? String
48
48
  @id = m
49
- elsif m.respond_to? :attributes and m.respond_to? :id
49
+ elsif m.respond_to?(:attributes) && m.respond_to?(:id)
50
50
  @fog_model = m
51
51
  @id = m.id
52
52
  else
53
53
  raise InvalidArguments, "Can't initialize #{self.class} with #{m.inspect}"
54
54
  end
55
- $config.cache_id @id
55
+ $config.cache_id(@id) if $config.respond_to?(:cache_id)
56
56
  end
57
57
 
58
58
  def fog_model
@@ -69,6 +69,20 @@ module Brightbox
69
69
  @id
70
70
  end
71
71
 
72
+ # Will return everything unless a subset has been passed in
73
+ #
74
+ # @param [Array<String>] identifiers series of values to call to call
75
+ #
76
+ def self.find_all_or_warn(identifiers)
77
+ if identifiers.empty?
78
+ find(:all)
79
+ else
80
+ find_or_call(identifiers) do |identifier|
81
+ warn "Could not find anything with ID #{identifier}"
82
+ end
83
+ end
84
+ end
85
+
72
86
  # General finder to return instances based on identifiers or all.
73
87
  #
74
88
  # @param args [Array<Object>, Object] Search settings. Passing +:all+
@@ -84,7 +98,7 @@ module Brightbox
84
98
  #
85
99
  def self.find(args = :all, options = {})
86
100
  raise InvalidArguments, "find(nil)" if args.nil?
87
- raise InvalidArguments, "find([])" if args.respond_to?(:empty?) and args.empty?
101
+ raise InvalidArguments, "find([])" if args.respond_to?(:empty?) && args.empty?
88
102
  options = {
89
103
  :order => :created_at,
90
104
  }.merge options
@@ -97,8 +111,8 @@ module Brightbox
97
111
  elsif args.is_a? String
98
112
  object = cached_get(args.to_s)
99
113
  raise NotFound, "Couldn't find '#{args.to_s}'" if object.nil?
100
- elsif args.respond_to? :collect
101
- objects = args.collect do |arg|
114
+ elsif args.respond_to? :map
115
+ objects = args.map do |arg|
102
116
  o = cached_get(arg.to_s)
103
117
  raise NotFound, "Couldn't find '#{arg.to_s}'" if o.nil?
104
118
  o
@@ -108,9 +122,9 @@ module Brightbox
108
122
  end
109
123
  if objects
110
124
  # wrap in our objects
111
- objects.collect! { |o| new(o) }
125
+ objects.map! { |o| new(o) }
112
126
  # Sort
113
- objects.sort! do |a,b|
127
+ objects.sort! do |a, b|
114
128
  sort_method = options[:order]
115
129
  begin
116
130
  a.send(sort_method) <=> b.send(sort_method)
@@ -171,5 +185,10 @@ module Brightbox
171
185
  end
172
186
  end
173
187
 
188
+ # Displays creation date in ISO 8601 Complete date format
189
+ #
190
+ def created_on
191
+ fog_model.created_at.strftime("%Y-%m-%d")
192
+ end
174
193
  end
175
194
  end
@@ -1,7 +1,8 @@
1
1
  module Brightbox
2
2
  class CloudIP < Api
3
3
  def self.require_account?; true; end
4
- def self.get id
4
+
5
+ def self.get(id)
5
6
  conn.cloud_ips.get id
6
7
  end
7
8
 
@@ -24,21 +25,15 @@ module Brightbox
24
25
 
25
26
  def self.format_translators_for_api(translators)
26
27
  translators.split(",").map do |t|
27
- incoming,outgoing,protocol = t.split(":")
28
+ incoming, outgoing, protocol = t.split(":")
28
29
  raise "translator #{t} is invalid" if incoming.nil? || outgoing.nil? || protocol.nil?
29
- {:incoming => incoming, :outgoing => outgoing, :protocol => protocol}
30
+ { :incoming => incoming, :outgoing => outgoing, :protocol => protocol }
30
31
  end
31
32
  end
32
33
 
33
34
  def attributes
34
35
  a = fog_model.attributes
35
- if(lb_id = a[:load_balancer] || a["load_balancer"])
36
- a[:destination] = lb_id
37
- elsif(server_group_id = a[:server_group] || a["server_group"])
38
- a[:destination] = server_group
39
- else
40
- a[:destination] = a[:server_id]
41
- end
36
+ a[:destination] = destination_id
42
37
  a
43
38
  end
44
39
 
@@ -54,7 +49,9 @@ module Brightbox
54
49
 
55
50
  def translators(raw_attributes)
56
51
  if translators = (raw_attributes[:port_translators] || raw_attributes['port_translators'])
57
- translators.map {|t| [t['incoming'],t['outgoing'],t['protocol']].join(":") }
52
+ translators.map do |t|
53
+ [t['incoming'], t['outgoing'], t['protocol']].join(":")
54
+ end
58
55
  else
59
56
  nil
60
57
  end
@@ -64,8 +61,8 @@ module Brightbox
64
61
  [:id, :status, :public_ip, :destination, :reverse_dns, :name]
65
62
  end
66
63
 
67
- def <=>(b)
68
- self.status <=> b.status
64
+ def <=>(other)
65
+ status <=> other.status
69
66
  end
70
67
 
71
68
  def update(options)
@@ -87,9 +84,8 @@ module Brightbox
87
84
  end
88
85
 
89
86
  self.class.conn.update_cloud_ip(id, params)
90
- self.reload
87
+ reload
91
88
  self
92
89
  end
93
-
94
90
  end
95
91
  end
@@ -1,40 +1,37 @@
1
1
  module Brightbox
2
-
3
2
  # A Collaborating account combines all of a users own accounts and those that
4
3
  # they have access to via an open collaboration.
5
4
  #
6
5
  class CollaboratingAccount < Account
7
6
  def self.all
8
- begin
9
- accounts = conn.accounts.all
10
- collaborations = conn.user_collaborations.all
11
-
12
- accepted_collaborations = collaborations.select do |col|
13
- col.status == "accepted"
14
- end
7
+ accounts = conn.accounts.all
8
+ collaborations = conn.user_collaborations.all
15
9
 
16
- pending_collaborations = collaborations.select do |col|
17
- col.status == "pending"
18
- end
10
+ accepted_collaborations = collaborations.select do |col|
11
+ col.status == "accepted"
12
+ end
19
13
 
20
- col_accounts = []
14
+ pending_collaborations = collaborations.select do |col|
15
+ col.status == "pending"
16
+ end
21
17
 
22
- accepted_collaboration_ids = accepted_collaborations.map(&:account_id)
23
- accounts.each do |acc|
24
- if accepted_collaboration_ids.include?(acc.id)
25
- collab = accepted_collaborations.detect {|col| col.account_id == acc.id }
26
- col_accounts << new(acc, collab)
27
- else
28
- col_accounts << new(acc)
29
- end
30
- end
18
+ col_accounts = []
31
19
 
32
- pending_collaborations.each do |col|
33
- col_accounts << new(col)
20
+ accepted_collaboration_ids = accepted_collaborations.map(&:account_id)
21
+ accounts.each do |acc|
22
+ if accepted_collaboration_ids.include?(acc.id)
23
+ collab = accepted_collaborations.find { |col| col.account_id == acc.id }
24
+ col_accounts << new(acc, collab)
25
+ else
26
+ col_accounts << new(acc)
34
27
  end
28
+ end
35
29
 
36
- col_accounts
30
+ pending_collaborations.each do |col|
31
+ col_accounts << new(col)
37
32
  end
33
+
34
+ col_accounts
38
35
  end
39
36
 
40
37
  # Simpler initialiser than the superclass.
@@ -98,7 +95,7 @@ module Brightbox
98
95
 
99
96
  def ram_free
100
97
  if account?
101
- [ram_limit.to_i - ram_used.to_i, 0].max
98
+ [ram_limit.to_i - ram_used.to_i, 0].max
102
99
  else
103
100
  ""
104
101
  end
@@ -139,7 +136,7 @@ module Brightbox
139
136
  [:id, :cloud_ips_limit, :lb_limit, :ram_limit, :ram_used, :ram_free, :role, :name]
140
137
  end
141
138
 
142
- private
139
+ private
143
140
 
144
141
  # A collaboration has access to the accounts details by nesting
145
142
  def acc_details(key)
@@ -7,7 +7,7 @@ module Brightbox
7
7
  def self.require_account?; true; end
8
8
 
9
9
  def self.invite(email, role)
10
- options = {:email => email, :role => role}
10
+ options = { :email => email, :role => role }
11
11
  data = conn.create_collaboration(options)
12
12
  model = Fog::Compute::Brightbox::Collaboration.new(data)
13
13
  new(model)