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
@@ -1,6 +1,7 @@
1
1
  module Brightbox
2
2
  class ServerGroup < Api
3
3
  def self.require_account?; true; end
4
+
4
5
  def self.all
5
6
  conn.server_groups
6
7
  end
@@ -18,14 +19,14 @@ module Brightbox
18
19
  end
19
20
 
20
21
  def firewall_policy
21
- FirewallPolicy.all.detect do |policy|
22
- policy.server_group_id == self.id
22
+ FirewallPolicy.all.find do |policy|
23
+ policy.server_group_id == id
23
24
  end
24
25
  end
25
26
 
26
27
  def update(options)
27
28
  self.class.conn.update_server_group(id, options)
28
- self.reload
29
+ reload
29
30
  self
30
31
  end
31
32
 
@@ -45,7 +46,7 @@ module Brightbox
45
46
  end
46
47
 
47
48
  def server_ids
48
- attributes[:server_ids].map{|id| id.is_a?(Hash) ? id['id'] : id }
49
+ attributes[:server_ids].map { |id| id.is_a?(Hash) ? id['id'] : id }
49
50
  end
50
51
 
51
52
  def server_count
@@ -55,6 +56,5 @@ module Brightbox
55
56
  def server_string
56
57
  server_ids.respond_to?(:join) ? server_ids.join(" ") : ""
57
58
  end
58
-
59
59
  end
60
60
  end
@@ -1,8 +1,9 @@
1
1
  module Brightbox
2
2
  class Server < Api
3
3
  def self.require_account?; true; end
4
- def self.create_servers(count,options)
5
- (0...count).map {|i| create(options) }
4
+
5
+ def self.create_servers(count, options)
6
+ (0...count).map { |i| create(options) }
6
7
  end
7
8
 
8
9
  def self.create(options)
@@ -21,9 +22,9 @@ module Brightbox
21
22
  [:id, :status, :type, :zone, :created_on, :image_id, :cloud_ip_ids, :name]
22
23
  end
23
24
 
24
- def update options
25
+ def update(options)
25
26
  self.class.conn.update_server id, options
26
- self.reload
27
+ reload
27
28
  self
28
29
  end
29
30
 
@@ -39,20 +40,20 @@ module Brightbox
39
40
  a = fog_model.attributes
40
41
  a[:image] = image_id
41
42
  a[:created_at] = created_at
42
- a[:created_on] = fog_model.created_at.strftime("%Y-%m-%d")
43
+ a[:created_on] = created_on
43
44
  a[:type] = server_type['handle']
44
45
  a[:status] = fog_model.state
45
46
  a[:zone] = zone && zone['handle']
46
47
  a[:hostname] = id
47
48
  a[:public_hostname] = "public.#{fqdn}" unless cloud_ips.empty?
48
- a[:ipv6_hostname] = ipv6_fqdn if interfaces.any? {|i| i['ipv6_address'] }
49
+ a[:ipv6_hostname] = ipv6_fqdn if interfaces.any? { |i| i['ipv6_address'] }
49
50
  a
50
51
  end
51
52
 
52
53
  def to_row
53
54
  o = attributes
54
- o[:cloud_ip_ids] = cloud_ips.collect { |i| i['id'] }
55
- o[:ips] = interfaces.collect { |i| i['ipv4_address'] }.join(', ')
55
+ o[:cloud_ip_ids] = cloud_ips.map { |i| i['id'] }
56
+ o[:ips] = interfaces.map { |i| i['ipv4_address'] }.join(', ')
56
57
  o
57
58
  end
58
59
 
@@ -64,5 +65,4 @@ module Brightbox
64
65
  "ipv6.#{fqdn}"
65
66
  end
66
67
  end
67
-
68
68
  end
@@ -1,7 +1,6 @@
1
1
  require 'hirb'
2
2
 
3
3
  module Brightbox
4
-
5
4
  # Hack to set ascii art table cell width due to limitations in Hirb
6
5
  class Hirb::Helpers::Table
7
6
  remove_const :BORDER_LENGTH
@@ -11,9 +10,9 @@ module Brightbox
11
10
  # Remove most of the ascii art table output
12
11
  class SimpleTable < Hirb::Helpers::Table
13
12
  def render_table_header
14
- title_row = ' ' + @fields.map {|f|
13
+ title_row = ' ' + @fields.map do |f|
15
14
  format_cell(@headers[f], @field_lengths[f])
16
- }.join(' ')
15
+ end.join(' ')
17
16
  ["", title_row, render_border]
18
17
  end
19
18
 
@@ -22,30 +21,30 @@ module Brightbox
22
21
  end
23
22
 
24
23
  def render_border
25
- '-' + @fields.map {|f| '-' * @field_lengths[f] }.join('--') + '-'
24
+ '-' + @fields.map { |f| '-' * @field_lengths[f] }.join('--') + '-'
26
25
  end
27
26
 
28
27
  def render_rows
29
28
  @rows.map do |row|
30
- row = ' ' + @fields.map {|f|
29
+ row = ' ' + @fields.map do |f|
31
30
  format_cell(row[f], @field_lengths[f])
32
- }.join(' ')
31
+ end.join(' ')
33
32
  end
34
33
  end
35
34
 
36
- def enforce_field_constraints
37
- max_fields.each {|k,max| @field_lengths[k] = max if @field_lengths[k].to_i > max }
38
- # Never shrink the id field
39
- @field_lengths[:id] = IDENTIFIER_SIZE if @field_lengths[:id]
40
- end
41
-
35
+ def enforce_field_constraints
36
+ max_fields.each do |k, max|
37
+ @field_lengths[k] = max if @field_lengths[k].to_i > max
38
+ end
39
+ # Never shrink the id field
40
+ @field_lengths[:id] = IDENTIFIER_SIZE if @field_lengths[:id]
41
+ end
42
42
  end
43
43
 
44
44
  # Vertical table for "show" views
45
45
  class ShowTable < Hirb::Helpers::Table
46
-
47
- def self.render(rows, options={})
48
- new(rows, {:escape_special_chars=>false, :resize=>false}.merge(options)).render
46
+ def self.render(rows, options = {})
47
+ new(rows, { :escape_special_chars => false, :resize => false }.merge(options)).render
49
48
  end
50
49
 
51
50
  def setup_field_lengths
@@ -53,40 +52,40 @@ module Brightbox
53
52
  end
54
53
 
55
54
  def render_header; []; end
55
+
56
56
  def render_footer; []; end
57
57
 
58
58
  def render_rows
59
- longest_header = Hirb::String.size @headers.values.sort_by {|e| Hirb::String.size(e) }.last
59
+ longest_header = Hirb::String.size @headers.values.sort_by { |e| Hirb::String.size(e) }.last
60
60
  @rows.map do |row|
61
- fields = @fields.map {|f|
61
+ fields = @fields.map do |f|
62
62
  "#{Hirb::String.rjust(@headers[f], longest_header)}: #{row[f]}"
63
- }
63
+ end
64
64
  fields << "" if @rows.size > 1
65
65
  fields.compact.join("\n")
66
66
  end
67
67
  end
68
68
  end
69
69
 
70
-
71
70
  # Print nice ascii tables (or tab separated lists, depending on mode)
72
71
  # Has lots of magic.
73
72
  def render_table(rows, options = {})
74
73
  options = { :description => false }.merge options
75
74
  # Figure out the fields from the :model option
76
- if options[:model] and options[:fields].nil?
75
+ if options[:model] && options[:fields].nil?
77
76
  options[:fields] = options[:model].default_field_order
78
77
  end
79
78
  # Figure out the fields from the first row
80
- if options[:fields].nil? and rows.first.class.respond_to?(:default_field_order)
79
+ if options[:fields].nil? && rows.first.class.respond_to?(:default_field_order)
81
80
  options[:fields] = rows.first.class.default_field_order
82
81
  end
83
82
  # Call to_row on all the rows
84
- rows = rows.collect do |row|
83
+ rows = rows.map do |row|
85
84
  row.respond_to?(:to_row) ? row.to_row : row
86
85
  end
87
86
  # Call render_cell on all the cells
88
87
  rows.each do |row|
89
- # FIXME default Api subclasses do not respond to #keys so specialising
88
+ # FIXME: default Api subclasses do not respond to #keys so specialising
90
89
  # #to_row is required to not break the following
91
90
  row.keys.each do |k|
92
91
  row[k] = row[k].render_cell if row[k].respond_to? :render_cell
@@ -96,9 +95,9 @@ module Brightbox
96
95
  # Simple output
97
96
  rows.each do |row|
98
97
  if options[:vertical]
99
- data options[:fields].collect { |k| [k, row[k]].join("\t") }.join("\n")
98
+ data options[:fields].map { |k| [k, row[k]].join("\t") }.join("\n")
100
99
  else
101
- data options[:fields].collect { |k| row[k].is_a?(Array) ? row[k].join(',') : row[k] }.join("\t")
100
+ data options[:fields].map { |k| row[k].is_a?(Array) ? row[k].join(',') : row[k] }.join("\t")
102
101
  end
103
102
  end
104
103
  else
@@ -1,6 +1,7 @@
1
1
  module Brightbox
2
2
  class Type < Api
3
3
  def self.require_account?; true; end
4
+
4
5
  def attributes
5
6
  o = fog_model.attributes
6
7
  o[:ram] = ram
@@ -28,7 +29,7 @@ module Brightbox
28
29
  conn.flavors
29
30
  end
30
31
 
31
- def self.get id
32
+ def self.get(id)
32
33
  conn.flavors.get id
33
34
  end
34
35
 
@@ -36,11 +37,11 @@ module Brightbox
36
37
  [:id, :name, :handle, :ram, :disk, :cores]
37
38
  end
38
39
 
39
- def <=>(b)
40
- if b.is_a? Type
41
- self.ram <=> b.ram
40
+ def <=>(other)
41
+ if other.is_a? Type
42
+ ram <=> other.ram
42
43
  else
43
- self.ram <=> b
44
+ ram <=> other
44
45
  end
45
46
  end
46
47
  end
@@ -1,10 +1,9 @@
1
1
  module Brightbox
2
2
  # These are collaborations from the perspective of the invited user so all
3
- # that is expected is listing, getting details, accepting, rejecting and
3
+ # that is expected is listing, getting details, accepting, rejecting and
4
4
  # destroying them.
5
5
  #
6
6
  class UserCollaboration < Api
7
-
8
7
  def self.all
9
8
  conn.user_collaborations
10
9
  end
@@ -25,7 +24,7 @@ module Brightbox
25
24
  #
26
25
  def self.get_for_account(account_id)
27
26
  collaborations = conn.user_collaborations
28
- open_collaborations = collaborations.select {|col| ["pending", "accepted"].include?(col.status) }
27
+ open_collaborations = collaborations.select { |col| %w{pending accepted}.include?(col.status) }
29
28
  collaboration = open_collaborations.find do |col|
30
29
  col.account_id == account_id
31
30
  end
@@ -5,7 +5,7 @@ module Brightbox
5
5
  end
6
6
 
7
7
  def to_row
8
- attributes.merge({ :accounts => accounts.size })
8
+ attributes.merge(:accounts => accounts.size)
9
9
  end
10
10
 
11
11
  def self.all
@@ -14,7 +14,7 @@ module Brightbox
14
14
 
15
15
  def self.get(id)
16
16
  u = conn.users.get id
17
- (u.nil? or u.id != id) ? nil : u
17
+ u.nil? || u.id != id ? nil : u
18
18
  end
19
19
 
20
20
  def self.default_field_order
@@ -22,7 +22,7 @@ module Brightbox
22
22
  end
23
23
 
24
24
  def accounts
25
- @accounts ||= fog_model.accounts.collect { |a| Account.new(a["id"]) }
25
+ @accounts ||= fog_model.accounts.map { |a| Account.new(a["id"]) }
26
26
  end
27
27
 
28
28
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "1.1.0" unless defined?(Brightbox::VERSION)
2
+ VERSION = "1.2.0" unless defined?(Brightbox::VERSION)
3
3
  end
data/lib/brightbox_cli.rb CHANGED
@@ -20,12 +20,17 @@ Dir.glob(vendor_dir + '/*').each do |f|
20
20
  $:.unshift File.join(f, 'lib')
21
21
  end
22
22
 
23
-
24
- require "json"
23
+ require "multi_json"
25
24
  require 'date'
26
25
  require 'gli'
26
+ require "i18n"
27
27
  require "fog/brightbox/compute"
28
28
 
29
+ # I18n stuff to clean up scattered text everywhere
30
+ I18n.enforce_available_locales = false
31
+ I18n.default_locale = :en
32
+ I18n.load_path = [File.join(File.dirname(__FILE__) + "/../locales/en.yml")]
33
+
29
34
  module Brightbox
30
35
  DEFAULT_API_ENDPOINT = "https://api.gb1.brightbox.com"
31
36
 
@@ -46,6 +51,9 @@ module Brightbox
46
51
  autoload :FirewallRules, File.expand_path("../brightbox-cli/firewall_rules", __FILE__)
47
52
  autoload :Collaboration, File.expand_path("../brightbox-cli/collaboration", __FILE__)
48
53
  autoload :UserCollaboration, File.expand_path("../brightbox-cli/user_collaboration", __FILE__)
54
+ autoload :DatabaseType, File.expand_path("../brightbox-cli/database_type", __FILE__)
55
+ autoload :DatabaseServer, File.expand_path("../brightbox-cli/database_server", __FILE__)
56
+ autoload :DatabaseSnapshot, File.expand_path("../brightbox-cli/database_snapshot", __FILE__)
49
57
 
50
58
  module Config
51
59
  autoload :SectionNameDeduplicator, File.expand_path("../brightbox-cli/config/section_name_deduplicator", __FILE__)
data/locales/en.yml ADDED
@@ -0,0 +1,205 @@
1
+ en:
2
+ options:
3
+ description:
4
+ desc: Description
5
+ name:
6
+ desc: Name
7
+ accounts:
8
+ desc: Manage accounts
9
+ accept_invite:
10
+ desc: Accept invitation to collaborate on account
11
+ default:
12
+ desc: Set a default account
13
+ list:
14
+ desc: List accounts
15
+ remove:
16
+ desc: Refuses or removes an account collaboration
17
+ reset_ftp_password:
18
+ desc: Reset an account's FTP Library password
19
+ show:
20
+ desc: Show accounts
21
+ cloudips:
22
+ desc: Manage an account's Cloud IPs
23
+ options:
24
+ port_translators:
25
+ desc: |
26
+ Cloud IP translators. Format: in-port:out-port:protocol. Comma
27
+ separate multiple translators. Protocol can be tcp or udp.
28
+ create:
29
+ desc: Create Cloud IPs
30
+ destroy:
31
+ desc: Destroy Cloud IPs
32
+ list:
33
+ desc: List Cloud IPs
34
+ map:
35
+ desc: Map a Cloud IP
36
+ show:
37
+ desc: Show Cloud IPs
38
+ unmap:
39
+ desc: Unmap Cloud IPs
40
+ update:
41
+ desc: Update a Cloud IP
42
+ config:
43
+ desc: Manage CLI configuration settings and credentials
44
+ client_add:
45
+ desc: Add new API client details to config
46
+ client_default:
47
+ desc: Set the default API client in the config
48
+ client_list:
49
+ desc: List API clients defined in the config
50
+ client_remove:
51
+ desc: Remove an API client from config
52
+ user_add:
53
+ desc: Add new user credentials to config
54
+ firewall:
55
+ policies:
56
+ desc: Manage firewall policies
57
+ apply:
58
+ desc: Apply firewall policy to a server group
59
+ create:
60
+ desc: Create firewall policy
61
+ destroy:
62
+ desc: Destroy firewall policy
63
+ list:
64
+ desc: List firewall policies
65
+ remove:
66
+ desc: Remove a firewall policy from a server group
67
+ show:
68
+ desc: Show firewall policies
69
+ update:
70
+ desc: Update a firewall policy
71
+ rules:
72
+ desc: Manages an account's firewall rules for a policy
73
+ create:
74
+ desc: Create a firewall rule
75
+ destroy:
76
+ desc: Destroy firewall rules
77
+ list:
78
+ desc: List firewall rules
79
+ show:
80
+ desc: Show firewall rules
81
+ update:
82
+ desc: Update firewall rule
83
+ groups:
84
+ desc: Manage an account's server groups
85
+ add_servers:
86
+ desc: Add servers to a server group
87
+ create:
88
+ desc: Create a server group
89
+ destroy:
90
+ desc: Destroy a number of empty server groups
91
+ list:
92
+ desc: List server groups
93
+ move_servers:
94
+ desc: Move servers from one server group to another
95
+ remove_servers:
96
+ desc: Remove servers from a server group
97
+ show:
98
+ desc: Show server groups
99
+ update:
100
+ desc: Update a server group
101
+ images:
102
+ desc: See official and public images and manage an account's images
103
+ destroy:
104
+ desc: Destroy images
105
+ list:
106
+ desc: List images
107
+ register:
108
+ desc: Register an image in the image library
109
+ show:
110
+ desc: Show images
111
+ update:
112
+ desc: Update an image
113
+ lbs:
114
+ desc: Manage an account's load balancers
115
+ add_nodes:
116
+ desc: Add servers to a load balancer
117
+ create:
118
+ desc: Create a load balancer
119
+ long_desc: All intervals and timeouts are in milliseconds
120
+ destroy:
121
+ desc: Destroy load balancers
122
+ list:
123
+ desc: List load balancers
124
+ remove_nodes:
125
+ desc: Remove servers from a load balancer
126
+ show:
127
+ desc: Show load balancers
128
+ update:
129
+ desc: Update a load balancer
130
+ long_desc: All intervals and timeouts are in milliseconds
131
+ servers:
132
+ desc: Manage an account's servers
133
+ activate_console:
134
+ desc: Activate web consoles for a number of servers
135
+ create:
136
+ desc: Create servers
137
+ destroy:
138
+ desc: Destroy servers
139
+ show:
140
+ desc: Show servers
141
+ shutdown:
142
+ desc: Shutdown servers with equivalent of `shutdown` command
143
+ snapshot:
144
+ desc: Snapshot servers (creating new images)
145
+ start:
146
+ desc: Start servers
147
+ stop:
148
+ desc: Stop servers with equivalent of powering off
149
+ update:
150
+ desc: Update a server
151
+ sql:
152
+ desc: Manage an account's Cloud SQL instances and snapshots
153
+ instances:
154
+ desc: Manage Cloud SQL instances
155
+ options:
156
+ allow_access:
157
+ desc: Comma separated list of IPs or IDs for servers or groups to allow access
158
+ engine:
159
+ desc: The database engine to use for the SQL instance (e.g. 'mysql')
160
+ engine_version:
161
+ desc: The version of the engine to use (e.g. '5.6')
162
+ snapshot:
163
+ desc: ID of a Cloud SQL snapshot to create new instance from
164
+ type:
165
+ desc: ID of a Cloud SQL type
166
+ zone:
167
+ desc: Zone to locate the instance in
168
+ create:
169
+ desc: Create a new Cloud SQL instance
170
+ destroy:
171
+ desc: Destroy Cloud SQL instances
172
+ list:
173
+ desc: List Cloud SQL instances
174
+ reset_password:
175
+ desc: Reset the admin password of a Cloud SQL instance
176
+ show:
177
+ desc: Show details of Cloud SQL instances
178
+ snapshot:
179
+ desc: Create a new Cloud SQL snapshot from an instance
180
+ update:
181
+ desc: Update a Cloud SQL instance
182
+ snapshots:
183
+ desc: Manage Cloud SQL snapshots
184
+ list:
185
+ desc: List Cloud SQL snapshots
186
+ destroy:
187
+ desc: Destroy a number of Cloud SQL snapshots
188
+ show:
189
+ desc: Show details of Cloud SQL snapshots
190
+ update:
191
+ desc: Update a Cloud SQL snapshot's metadata
192
+ types:
193
+ desc: List the Cloud SQL types
194
+ list:
195
+ desc: List the available Cloud SQL sizes for new instances
196
+ show:
197
+ desc: Show details of Cloud SQL types
198
+ users:
199
+ desc: List the users associated with an account
200
+ list:
201
+ desc: List users
202
+ show:
203
+ desc: Show users
204
+ update:
205
+ desc: Update a user