Sha256: f4bbceb57f78e4a58e18e5930780d02af4b09e5ae38c485e6f98c36c6f3f0235

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require "aws-sdk-lakeformation"
require "swa/cli/base_command"
require "swa/cli/collection_behaviour"
require "swa/cli/item_behaviour"
require "swa/lake_formation/resource_info"

module Swa
  module CLI

    class LakeFormationCommand < BaseCommand

      subcommand ["permissions"], "Show permissions" do

        self.description = <<-EOF
          List permissions.
        EOF

        include CollectionBehaviour

        private

        def collection
          query_for(:list_permissions, :principal_resource_permissions, Swa::LakeFormation::Permission)
        end

      end

      protected

      def lf_client
        ::Aws::LakeFormation::Client.new(aws_config)
      end

      def query_for(query_method, response_key, model)
        records = lf_client.public_send(query_method).public_send(response_key)
        model.list(records)
      end

      subcommand ["resources"], "Show resources" do

        self.description = <<-EOF
          List resources.
        EOF

        include CollectionBehaviour

        private

        def collection
          query_for(:list_resources, :resource_info_list, Swa::LakeFormation::ResourceInfo)
        end

      end

      protected

      def lf_client
        ::Aws::LakeFormation::Client.new(aws_config)
      end

      def query_for(query_method, response_key, model)
        records = lf_client.public_send(query_method).public_send(response_key)
        model.list(records)
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swa-0.8.0 lib/swa/cli/lake_formation_command.rb