class Tapjoy::LDAP::CLI::User::Delete

Manipulates data to a format usable by the API structure for user removal

Public Instance Methods

delete() click to toggle source

Make the API call to remove an LDAP user

# File lib/tapjoy/ldap/cli/user/delete.rb, line 9
def delete
  verify_arguments
  confirm unless opts[:force]
  puts Tapjoy::LDAP::API::User.destroy(opts[:username], opts[:type])
end

Private Instance Methods

confirm() click to toggle source
# File lib/tapjoy/ldap/cli/user/delete.rb, line 27
def confirm
  puts "Confirm that you want to delete user: #{opts[:username]} (yes/no)"
  print '>'
  confirm = STDIN.gets.chomp.downcase
  abort("Deletion of #{opts[:username]} aborted") unless confirm.start_with?('y')
end
opts() click to toggle source
# File lib/tapjoy/ldap/cli/user/delete.rb, line 16
def opts
  @opts ||= Optimist.options do
    # Set help message
    usage "user delete [options]"

    opt :username, 'Specify username', type: :string, required: true
    opt :force, 'Force delete'
    opt :type, 'Specfy if this is a user or service account', type: :string, default: 'user'
  end
end
verify_arguments() click to toggle source
# File lib/tapjoy/ldap/cli/user/delete.rb, line 34
def verify_arguments
  Optimist.die :type, "argument must be 'user' or 'service'" unless %w(user service).include?(opts[:type])
end