swa 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc9fcd21e4fbd399ce0a2437fe6a054d4c41495
4
- data.tar.gz: 00ac4e5e34e55def411589f177db392db456e22c
3
+ metadata.gz: 3b8542e93e6b8679b57d7d15aa193605e3ac4a42
4
+ data.tar.gz: 999743b0934388671489d25c6c3af62621427a20
5
5
  SHA512:
6
- metadata.gz: dba4cb585a4e6761c1dc9cdfb34ed8b229d0cef5b0eb693285efde74cf92758f06d95febe86ef836a5584a598c85e3be35e561ce9004f34f1d45a86809c80649
7
- data.tar.gz: bf783e3b8ec3aa1c66a5a4722d2dede644e2d4292b27eefb5de2d39cad26ce17094b0cf094f1934e857634ab631e163a05d243d499fe4e58d1bb3c5a59ff1011
6
+ metadata.gz: 5ef747f274c1bfa947d6aa534ef380df524cd860f1dfafe1625c3589b0d0b0d247977945a059dedcd3c2bc07db6de1e1fba88b5886c49d643b7c258b9e5e61f5
7
+ data.tar.gz: 967358b2a172465734d695a5ffa8d5207980d59385bcf390870caa24641eae7943c212e489c357a10c054e74910e3325e4e88658ba79c28c538f1825edbbedd4
@@ -0,0 +1,65 @@
1
+ require "aws-sdk-resources"
2
+ require "swa/cli/base_command"
3
+ require "swa/cli/collection_behaviour"
4
+ require "swa/cli/item_behaviour"
5
+ require "swa/kms/alias"
6
+ require "swa/kms/key"
7
+
8
+ module Swa
9
+ module CLI
10
+
11
+ class KmsCommand < BaseCommand
12
+
13
+ subcommand ["aliases"], "Show aliases" do
14
+
15
+ include CollectionBehaviour
16
+
17
+ private
18
+
19
+ def collection
20
+ query_for(:list_aliases, :aliases, Swa::KMS::Alias)
21
+ end
22
+
23
+ end
24
+
25
+ subcommand ["key"], "Show key" do
26
+
27
+ parameter "ID", "key ID"
28
+
29
+ include ItemBehaviour
30
+
31
+ private
32
+
33
+ def item
34
+ Swa::KMS::Key.new(kms_client.describe_key(:key_id => id).key_metadata)
35
+ end
36
+
37
+ end
38
+
39
+ subcommand ["keys"], "Show keys" do
40
+
41
+ include CollectionBehaviour
42
+
43
+ private
44
+
45
+ def collection
46
+ query_for(:list_keys, :keys, Swa::KMS::Key)
47
+ end
48
+
49
+ end
50
+
51
+ protected
52
+
53
+ def kms_client
54
+ ::Aws::KMS::Client.new(aws_config)
55
+ end
56
+
57
+ def query_for(query_method, response_key, model)
58
+ records = kms_client.public_send(query_method).public_send(response_key)
59
+ model.list(records)
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
@@ -1,6 +1,7 @@
1
1
  require "swa/cli/base_command"
2
2
  require "swa/cli/ec2_command"
3
3
  require "swa/cli/iam_command"
4
+ require "swa/cli/kms_command"
4
5
 
5
6
  module Swa
6
7
  module CLI
@@ -9,6 +10,7 @@ module Swa
9
10
 
10
11
  subcommand "ec2", "EC2 stuff", Ec2Command
11
12
  subcommand "iam", "IAM stuff", IamCommand
13
+ subcommand "kms", "KMS stuff", KmsCommand
12
14
 
13
15
  end
14
16
 
@@ -26,7 +26,8 @@ module Swa
26
26
  end
27
27
 
28
28
  def console_output
29
- Base64.decode64(i.console_output.output)
29
+ encoded_output = i.console_output.output
30
+ Base64.decode64(encoded_output) if encoded_output
30
31
  end
31
32
 
32
33
  delegate :launch_time
@@ -6,7 +6,7 @@ module Swa
6
6
  class Role < Resource
7
7
 
8
8
  def summary
9
- role.arn
9
+ role.name
10
10
  end
11
11
 
12
12
  private
@@ -6,7 +6,7 @@ module Swa
6
6
  class User < Resource
7
7
 
8
8
  def summary
9
- user.arn
9
+ user.name
10
10
  end
11
11
 
12
12
  private
@@ -0,0 +1,26 @@
1
+ require "swa/record"
2
+
3
+ module Swa
4
+ module KMS
5
+
6
+ class Alias < Record
7
+
8
+ def summary
9
+ [
10
+ pad(name, 36),
11
+ key
12
+ ].join(" ")
13
+ end
14
+
15
+ def name
16
+ aws_record.alias_name
17
+ end
18
+
19
+ def key
20
+ aws_record.target_key_id
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require "swa/record"
2
+
3
+ module Swa
4
+ module KMS
5
+
6
+ class Key < Record
7
+
8
+ def summary
9
+ id
10
+ end
11
+
12
+ def id
13
+ aws_record.key_id
14
+ end
15
+
16
+ def name
17
+ aws_record.key_name
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ require "forwardable"
2
+ require "swa/data_presentation"
3
+
4
+ module Swa
5
+
6
+ class Record
7
+
8
+ def self.list(records)
9
+ records.lazy.map(&method(:new))
10
+ end
11
+
12
+ def initialize(aws_record)
13
+ @aws_record = aws_record
14
+ end
15
+
16
+ include DataPresentation
17
+
18
+ def data
19
+ camelize_keys(aws_record.to_h)
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :aws_record
25
+
26
+ end
27
+
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Swa
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,6 +148,7 @@ files:
148
148
  - lib/swa/cli/filter_options.rb
149
149
  - lib/swa/cli/iam_command.rb
150
150
  - lib/swa/cli/item_behaviour.rb
151
+ - lib/swa/cli/kms_command.rb
151
152
  - lib/swa/cli/main_command.rb
152
153
  - lib/swa/cli/selector.rb
153
154
  - lib/swa/cli/tag_filter_options.rb
@@ -165,6 +166,9 @@ files:
165
166
  - lib/swa/iam/policy.rb
166
167
  - lib/swa/iam/role.rb
167
168
  - lib/swa/iam/user.rb
169
+ - lib/swa/kms/alias.rb
170
+ - lib/swa/kms/key.rb
171
+ - lib/swa/record.rb
168
172
  - lib/swa/resource.rb
169
173
  - lib/swa/version.rb
170
174
  - swa.gemspec
@@ -188,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
192
  version: '0'
189
193
  requirements: []
190
194
  rubyforge_project:
191
- rubygems_version: 2.5.1
195
+ rubygems_version: 2.6.6
192
196
  signing_key:
193
197
  specification_version: 4
194
198
  summary: AWS, backwards