Class: CF::UAA::ClientCli

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

Constant Summary collapse

CLIENT_SCHEMA =
{
    :name => 'string',
    :scope => 'list',
    :authorized_grant_types => 'list',
    :authorities => 'list',
    :access_token_validity => 'seconds',
    :refresh_token_validity => 'seconds',
    :redirect_uri => 'list',
    :autoapprove => 'list',
    :'signup_redirect_url' => 'url'
}

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

#client_info(defaults) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/uaa/cli/client_reg.rb', line 35

def client_info(defaults)
  info = {client_id: defaults[:client_id] || opts[:client_id]}
  info[:client_secret] = opts[:secret] if opts[:secret]
  del_attrs = Util.arglist(opts[:del_attrs], [])
  CLIENT_SCHEMA.each_with_object(info) do |(k, p), info|
    next if del_attrs.include?(k)
    default = Util.strlist(defaults[k])
    if opts.key?(k)
      info[k] = opts[k].nil? || opts[k].empty? ? default : opts[k]
    else
      info[k] = opts[:interact] ?
        info[k] = askd("#{k.to_s.gsub('_', ' ')} (#{p})", default): default
    end
    if k == :autoapprove && (info[k] == 'true' || info[k] == 'false')
      info[k] = !!(info[k] == 'true')
    else
      info[k] = Util.arglist(info[k]) if p == 'list'
      info.delete(k) unless info[k]
    end
  end
end