swa 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38d68962033d474157c7cadb13472a7caa52b276
4
- data.tar.gz: f0b954064b850223718f06d2310269ce81534099
3
+ metadata.gz: 518a3bd32a4bf016d2001f1c218a11075bcb439f
4
+ data.tar.gz: 14cef26fd503b59396ae9eeb2eb950cd3823ff30
5
5
  SHA512:
6
- metadata.gz: aac97d88b50058e49ce713e83628986e84e6756b5ca2f4a9804d9ee2fb81bfdb4e5199e3ced6395dbc86fb090bae020577c009f62b9057b6dbe46628f4c9800d
7
- data.tar.gz: b909e0ff69d22933101c0a9e20eb4f580e6589a31992ecfb88e20cc71ccf109321ba2edb292e3da23eb3825494979406cd2f9a85bf20e28405f957389034f3f6
6
+ metadata.gz: 677537cc4f3c0acb8f93569eb27950b3b76db266b5dfe4a6233ca5990d97f09583a7725c5219a2bddb18d7c29dd8496d42965ffc9f565c81b6b81355e697c77a
7
+ data.tar.gz: 26d882e959cbd567c9533d2e97144aeeea21cae0e42ca3770f93b908e2cda20d2d815f9d17c45fa99ae9c34040b6c0bb9001128f6ef15a852c97682232b5c9b0
@@ -19,6 +19,14 @@ module Swa
19
19
 
20
20
  end
21
21
 
22
+ target.subcommand ["ids"], "Just print ids" do
23
+ def execute
24
+ collection.each do |i|
25
+ puts i.id
26
+ end
27
+ end
28
+ end
29
+
22
30
  target.subcommand ["data", "d"], "Full details" do
23
31
 
24
32
  parameter "[QUERY]", "JMESPath expression"
@@ -302,12 +302,34 @@ module Swa
302
302
  EOF
303
303
 
304
304
  option "--owned-by", "OWNER", "with specified owner", :default => "self"
305
+ option ["--volume", "--of"], "VOLUME-ID", "for specified volume"
306
+
307
+ option ["--started-after", "--after"], "WHEN", "earliest start-time"
308
+ option ["--started-before", "--before"], "WHEN", "latest start-time"
305
309
 
306
310
  include TagFilterOptions
307
311
  include CollectionBehaviour
308
312
 
309
313
  private
310
314
 
315
+ def volume=(volume_id)
316
+ add_filter("volume-id", volume_id)
317
+ end
318
+
319
+ def started_after=(datetime_string)
320
+ min_start_time = parse_datetime(datetime_string).max
321
+ selector.add do |image|
322
+ image.start_time > min_start_time
323
+ end
324
+ end
325
+
326
+ def started_before=(datetime_string)
327
+ max_start_time = parse_datetime(datetime_string).min
328
+ selector.add do |image|
329
+ image.start_time < max_start_time
330
+ end
331
+ end
332
+
311
333
  def snapshots
312
334
  query_options[:owner_ids] = [owned_by]
313
335
  query_for(:snapshots, Swa::EC2::Snapshot)
@@ -0,0 +1,53 @@
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/elb/load_balancer"
6
+
7
+ module Swa
8
+ module CLI
9
+
10
+ class ElbCommand < BaseCommand
11
+
12
+ subcommand ["load-balancer", "lb"], "Show load-balancer" do
13
+
14
+ parameter "NAME", "ELB name"
15
+
16
+ include ItemBehaviour
17
+
18
+ private
19
+
20
+ def item
21
+ results = describe_load_balancers(:load_balancer_names => [name])
22
+ signal_error "No such ELB '#{name}'" unless results.any?
23
+ Swa::ELB::LoadBalancer.new(results.first)
24
+ end
25
+
26
+ end
27
+
28
+ subcommand ["load-balancers", "lbs"], "Show load-balancers" do
29
+
30
+ include CollectionBehaviour
31
+
32
+ private
33
+
34
+ def collection
35
+ Swa::ELB::LoadBalancer.list(describe_load_balancers)
36
+ end
37
+
38
+ end
39
+
40
+ protected
41
+
42
+ def elb_client
43
+ ::Aws::ElasticLoadBalancing::Client.new(aws_config)
44
+ end
45
+
46
+ def describe_load_balancers(options = {})
47
+ elb_client.describe_load_balancers(options).load_balancer_descriptions
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -1,6 +1,7 @@
1
1
  require "swa/cli/base_command"
2
2
  require "swa/cli/cloud_formation_command"
3
3
  require "swa/cli/ec2_command"
4
+ require "swa/cli/elb_command"
4
5
  require "swa/cli/iam_command"
5
6
  require "swa/cli/kms_command"
6
7
  require "swa/cli/s3_command"
@@ -12,6 +13,7 @@ module Swa
12
13
 
13
14
  subcommand ["cf", "cloudformation"], "CloudFormation stuff", CloudFormationCommand
14
15
  subcommand "ec2", "EC2 stuff", Ec2Command
16
+ subcommand "elb", "elb stuff", ElbCommand
15
17
  subcommand "iam", "IAM stuff", IamCommand
16
18
  subcommand "kms", "KMS stuff", KmsCommand
17
19
  subcommand "s3", "S3 stuff", S3Command
@@ -7,6 +7,10 @@ module Swa
7
7
 
8
8
  class Stack < Resource
9
9
 
10
+ def id
11
+ name
12
+ end
13
+
10
14
  def summary
11
15
  [
12
16
  pad(name, 44),
@@ -8,6 +8,10 @@ module Swa
8
8
 
9
9
  include TaggedResource
10
10
 
11
+ def id
12
+ ami.image_id
13
+ end
14
+
11
15
  def summary
12
16
  [
13
17
  field(ami, :image_id),
@@ -9,6 +9,10 @@ module Swa
9
9
 
10
10
  include TaggedResource
11
11
 
12
+ def id
13
+ i.instance_id
14
+ end
15
+
12
16
  def summary
13
17
  [
14
18
  field(i, :instance_id),
@@ -5,6 +5,10 @@ module Swa
5
5
 
6
6
  class KeyPair < Resource
7
7
 
8
+ def id
9
+ name
10
+ end
11
+
8
12
  def summary
9
13
  [
10
14
  pad(name, 44),
@@ -6,6 +6,10 @@ module Swa
6
6
 
7
7
  class SecurityGroup < Resource
8
8
 
9
+ def id
10
+ sg.group_id
11
+ end
12
+
9
13
  def summary
10
14
  [
11
15
  field(sg, :group_id),
@@ -8,17 +8,26 @@ module Swa
8
8
 
9
9
  include TaggedResource
10
10
 
11
+ def id
12
+ s.snapshot_id
13
+ end
14
+
11
15
  def summary
12
16
  [
13
17
  field(s, :snapshot_id),
14
18
  field(s, :volume_id),
15
- sprintf("%5d", s.volume_size),
16
- s.start_time.iso8601,
17
- rpad(s.progress, 4),
18
- quoted(s.description)
19
+ sprintf("%5d", volume_size),
20
+ start_time.iso8601,
21
+ rpad(progress, 4),
22
+ quoted(description)
19
23
  ].join(" ")
20
24
  end
21
25
 
26
+ delegate :description
27
+ delegate :progress
28
+ delegate :start_time
29
+ delegate :volume_size
30
+
22
31
  delegate :delete
23
32
 
24
33
  private
@@ -8,6 +8,10 @@ module Swa
8
8
 
9
9
  include TaggedResource
10
10
 
11
+ def id
12
+ subnet.subnet_id
13
+ end
14
+
11
15
  def summary
12
16
  [
13
17
  field(subnet, :subnet_id),
@@ -8,6 +8,10 @@ module Swa
8
8
 
9
9
  include TaggedResource
10
10
 
11
+ def id
12
+ v.volume_id
13
+ end
14
+
11
15
  def summary
12
16
  [
13
17
  field(v, :volume_id),
@@ -8,6 +8,10 @@ module Swa
8
8
 
9
9
  include TaggedResource
10
10
 
11
+ def id
12
+ vpc.vpc_id
13
+ end
14
+
11
15
  def summary
12
16
  [
13
17
  field(vpc, :vpc_id),
@@ -0,0 +1,24 @@
1
+ require "swa/record"
2
+
3
+ module Swa
4
+ module ELB
5
+
6
+ class LoadBalancer < Record
7
+
8
+ def summary
9
+ [
10
+ pad(name, 36),
11
+ scheme
12
+ ].join(" ")
13
+ end
14
+
15
+ def name
16
+ aws_record.load_balancer_name
17
+ end
18
+
19
+ delegate :scheme
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -5,8 +5,18 @@ module Swa
5
5
 
6
6
  class Group < Resource
7
7
 
8
+ def id
9
+ group.group_id
10
+ end
11
+
12
+ def name
13
+ group.group_name
14
+ end
15
+
16
+ delegate :arn
17
+
8
18
  def summary
9
- group.arn
19
+ arn
10
20
  end
11
21
 
12
22
  private
@@ -6,6 +6,10 @@ module Swa
6
6
 
7
7
  class Policy < Resource
8
8
 
9
+ def id
10
+ policy.policy_id
11
+ end
12
+
9
13
  def summary
10
14
  [
11
15
  pad(policy.arn, 60),
@@ -5,6 +5,10 @@ module Swa
5
5
 
6
6
  class Role < Resource
7
7
 
8
+ def id
9
+ role.role_id
10
+ end
11
+
8
12
  def summary
9
13
  role.name
10
14
  end
@@ -5,6 +5,10 @@ module Swa
5
5
 
6
6
  class User < Resource
7
7
 
8
+ def id
9
+ user.user_id
10
+ end
11
+
8
12
  def summary
9
13
  user.name
10
14
  end
@@ -5,6 +5,10 @@ module Swa
5
5
 
6
6
  class Alias < Record
7
7
 
8
+ def id
9
+ name
10
+ end
11
+
8
12
  def summary
9
13
  [
10
14
  pad(name, 36),
@@ -19,6 +19,12 @@ module Swa
19
19
  camelize_keys(aws_record.to_h)
20
20
  end
21
21
 
22
+ extend Forwardable
23
+
24
+ def self.delegate(*methods)
25
+ def_delegators :aws_record, *methods
26
+ end
27
+
22
28
  private
23
29
 
24
30
  attr_reader :aws_record
@@ -6,10 +6,16 @@ module Swa
6
6
 
7
7
  class Bucket < Resource
8
8
 
9
+ def id
10
+ name
11
+ end
12
+
9
13
  def summary
10
- bucket.name
14
+ name
11
15
  end
12
16
 
17
+ delegate :name
18
+
13
19
  def uri
14
20
  "s3://#{bucket.name}"
15
21
  end
@@ -1,3 +1,3 @@
1
1
  module Swa
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
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.6.0
4
+ version: 0.6.1
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-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,6 +145,7 @@ files:
145
145
  - lib/swa/cli/collection_behaviour.rb
146
146
  - lib/swa/cli/data_output.rb
147
147
  - lib/swa/cli/ec2_command.rb
148
+ - lib/swa/cli/elb_command.rb
148
149
  - lib/swa/cli/filter_options.rb
149
150
  - lib/swa/cli/iam_command.rb
150
151
  - lib/swa/cli/item_behaviour.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/swa/ec2/tagged_resource.rb
165
166
  - lib/swa/ec2/volume.rb
166
167
  - lib/swa/ec2/vpc.rb
168
+ - lib/swa/elb/load_balancer.rb
167
169
  - lib/swa/iam/group.rb
168
170
  - lib/swa/iam/policy.rb
169
171
  - lib/swa/iam/role.rb
@@ -197,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
199
  version: '0'
198
200
  requirements: []
199
201
  rubyforge_project:
200
- rubygems_version: 2.5.1
202
+ rubygems_version: 2.6.7
201
203
  signing_key:
202
204
  specification_version: 4
203
205
  summary: AWS, backwards