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
#client, #klass_name, #object_id, #object_type, #options, #target_id, #target_type
Instance Method Summary collapse
Methods inherited from BaseCommand
#check_options, #context_params, #context_params=, #go, include_module, inherited, #initialize, required_options, #say_err
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(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 53 54 55 |
# File 'lib/epc/command/role/show_role_command.rb', line 4 def execute(args = []) require_object @showable_translations = { :groups => :user_groups } @showables = args.map(&:to_sym) rescue [] status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{object_id}?include=users,user_groups,grants") unless status.successful? say_err("Request failed: [#{response[:message]}]") return 1 end if @options[:json].present? say response.to_json return 0 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 |