Sha256: 1f4fb53245d360e0138cb8675432bbc0985b02ba468f6422473149a236760df0

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'json'

module Heirloom
  module CLI
    class Authorize

      def initialize
        @opts = read_options
        @logger = HeirloomLogger.new :log_level => @opts[:level]

        exit 1 unless CLI::Shared.valid_options? :provided => @opts,
                                                 :required => [:accounts, 
                                                               :name, :id],
                                                 :logger   => @logger
        @archive = Archive.new :name   => @opts[:name],
                               :id     => @opts[:id],
                               :logger => @logger
      end

      def authorize
        @archive.authorize @opts[:accounts]
      end

      private

      def read_options
        Trollop::options do
          version Heirloom::VERSION
          banner <<-EOS

Authorize access from another AWS account to an archive.

Usage:

heirloom authorize -n NAME -i ID -a AWS_ACCOUNT1-a AWS_ACCOUNT2

Note: This will replace all current authorizations with those specified and make the archive private.

EOS
          opt :accounts, "AWS Account(s) email to authorize. Can be specified multiple times.", :type  => :string,
                                                                                                :multi => true
          opt :help, "Display Help"
          opt :id, "id of the archive to authorize.", :type => :string
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :name, "Name of archive.", :type => :string
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.3.1 lib/heirloom/cli/authorize.rb
heirloom-0.3.0 lib/heirloom/cli/authorize.rb
heirloom-0.3.0.rc1 lib/heirloom/cli/authorize.rb