class DTK::Client::Operation::Account::DeleteSshKey

Public Class Methods

execute(args = Args.new) click to toggle source
# File lib/client/operation/account/delete_ssh_key.rb, line 21
def self.execute(args = Args.new)
  name = args[:name]
  unless args[:skip_prompt]
    is_go = DTK::Client::Console.prompt_yes_no("Are you sure you want to delete SSH key '#{name}'"+"?")
    return nil unless is_go
  end
  post_body = {
    :username => name
  }
  response = rest_post("#{RoutePrefix}/delete_ssh_key", post_body)
  return response unless response.ok?

  if response.ok? && response.data(:repoman_registration_error)
    OsUtil.print("Warning: We were not able to unregister your key with remote catalog! #{response.data(:repoman_registration_error)}", :yellow)
  end

  Configurator.remove_current_user_from_direct_access

  OsUtil.print("SSH key '#{name}' removed successfully!", :yellow)
end