Class: CF::UAA::ClientCli

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

Constant Summary collapse

CLIENT_SCHEMA =
{ scope: "list", authorized_grant_types: "list",
authorities: "list", access_token_validity: "seconds",
refresh_token_validity: "seconds", redirect_uri: "list",
autoapprove: "list" }

Instance Method Summary collapse

Methods inherited from CommonCli

#askd, #auth_header, #clientname, #clientsecret, #complain, #debug?, #handle_request, #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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cli/client_reg.rb', line 28

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