Class: EPC::Command::ShowRoleCommand
- Inherits:
-
ShowCommand
- Object
- BaseCommand
- ShowCommand
- EPC::Command::ShowRoleCommand
- Defined in:
- lib/epc/command/role/show_role_command.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
#go, inherited, #initialize, required_options
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Instance Method Details
#execute(role = nil, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/epc/command/role/show_role_command.rb', line 4 def execute(role = nil, *args) @showable_translations = { :groups => :user_groups } role_id = retrieve_identifier_for("Role", role) status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{role_id}?include=users,user_groups,grants") @showables = args[1..-1].map(&:to_sym) rescue [] unless status.successful? say("Request failed: [#{response[:message]}]") return 1 end role_table = EPC::TabularOutputter.new([response], [:id, :name]) users_table = EPC::TabularOutputter.new(response[:users], [:id, :name]) user_groups_table = EPC::TabularOutputter.new(response[:user_groups], [:id, :name]) grants_table = EPC::TabularOutputter.new(response[:grants], [:id, :action, :secured_type, :secured_id]) @response = response if @showables.blank? say("Role:") say(role_table.print) say("\n") end if show? :users say("Users:") say(users_table.print) say("\n") end if show? :groups say("User groups:") say(user_groups_table.print) say("\n") end if show? :grants say("Grants:") say(grants_table.print) say("\n") end return status end |