Class: CF::UAA::UserCli

Inherits:
CommonCli show all
Defined in:
lib/uaa/cli/user.rb

Constant Summary collapse

USER_INFO_OPTS =
[:origin, :givenName, :familyName, :emails, :phoneNumbers]

Instance Method Summary collapse

Methods inherited from CommonCli

#askd, #auth_header, #clientid, #clientname, #clientsecret, #complain, #debug?, #handle_request, #passcode, #scim_common_list, #scim_get_helper, #scim_get_object, #scim_get_user_object, #scim_request, #trace?, #update_target_info, #username, #userpwd, #verified_pwd

Methods inherited from Topic

#add_command, #ask, #ask_pwd, commands, define_option, desc, #gripe, #help_col_start, #initialize, #opt_help, #opt_strs, option_defs, #opts, #pp, #print_tree, #say, #say_cmd_helper, #say_command_help, #say_commands, #say_definition, #say_help, #terminal_columns, topic

Constructor Details

This class inherits a constructor from CF::UAA::Topic

Instance Method Details

#change_activation(ua, name, activate) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/uaa/cli/user.rb', line 126

def change_activation(ua, name, activate)
  info = ua.get(:user, ua.id(:user, username(name)))

  required_info = ['id', 'username', 'name', 'emails', 'meta'].inject({}) do |res, required_param|
    res[required_param] = info[required_param]
    res
  end

  required_info['active'] = activate
  ua.patch(:user, required_info)
end

#user_opts(info = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/uaa/cli/user.rb', line 29

def user_opts(info = {})
  [:emails, :phoneNumbers].each do |o|
    next unless opts[o]
    info[o] = Util.arglist(opts[o]).each_with_object([]) { |v, a| a << {:value => v} }
  end
  n = [:givenName, :familyName].each_with_object({}) { |o, n| n[o] = opts[o] if opts[o] }
  info[:name] = n unless n.empty?
  info[:origin] = opts[:origin] if opts[:origin]
  info
end