Sha256: 4c49bc6f37860b780a298f282e6e6fbf400461fc02508ae8b373b3b9a6399d97

Contents?: true

Size: 1.47 KB

Versions: 53

Compression:

Stored size: 1.47 KB

Contents

module HammerCLIForeman
  class SSHKeys < HammerCLIForeman::Command
    resource :ssh_keys
    command_name "ssh-keys"
    desc _("Manage SSH Keys sources")

    class ListCommand < HammerCLIForeman::ListCommand
      output do
        field :id, _("Id")
        field :name, _("Name")
        field :fingerprint, _("Fingerprint")
        field :length, _("Length")
        field :created_at, _("Created at"), Fields::Date
      end

      build_options
    end

    class CreateCommand < HammerCLIForeman::CreateCommand
      command_name "add"

      option "--key-file", "KEY_FILE", _("Path to a SSH public key"),
             :format => HammerCLI::Options::Normalizers::File.new

      def request_params
        params = super
        # FIXME: Until #20986 is fixed we need to map the 'user_id' to a correct location manually
        params['user_id'] ||= params['ssh_key']['user_id']
        params['ssh_key']['key'] ||= options['option_key_file']
        params
      end

      success_message _("SSH Key %{name} added.")
      failure_message _("Could not add SSH Key")

      build_options
    end

    class InfoCommand < HammerCLIForeman::InfoCommand
      output ListCommand.output_definition do
        field :key, _("Public Key")
      end

      build_options
    end

    class DeleteCommand < HammerCLIForeman::DeleteCommand
      success_message _("SSH Key deleted.")
      failure_message _("Could not delete the SSH Key")

      build_options
    end

    autoload_subcommands
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.13.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.12.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.10.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.9.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.8.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.7.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.5.1 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.6.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.5.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.4.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.3.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.2.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.5.2 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.1.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-3.0.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.5.1 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.5.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.3.2 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.4.0 lib/hammer_cli_foreman/ssh_keys.rb
hammer_cli_foreman-2.3.1 lib/hammer_cli_foreman/ssh_keys.rb