cwa 0.2.5 → 0.2.6

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
  SHA256:
3
- metadata.gz: e2829f3d40b0966152d43b204bf2b269d56055ffeda7561ae80fa05b5aae137b
4
- data.tar.gz: a1d09ffb821c75d33f710ef5b96034c2a809e698ca4f9e9bd5c7bcf4abd61a62
3
+ metadata.gz: 68fe5fa6a7a7028fe3a8aa3c6781ba92b95c77972bcb9b32f0ef87b7d3ffea5f
4
+ data.tar.gz: d37958cce67757b099ab293a157060d91053c83f34a563fc9743254cbdbe4fe5
5
5
  SHA512:
6
- metadata.gz: e965333fb74efe2744e5d631733028cc209c95e059ffa5c2bcfca3fe97771a80b0443d57e31e81f56fd7517657e2687747a54f8a8976211d48508eeb94e7055b
7
- data.tar.gz: 01571ed454488177e3051d807b0f65e515eb602d6cbfd59f38fea251e3a569078bfc86ea328ec3567236dfbb290d8c9f545224f5daafbfe9cb851129fa0ac387
6
+ metadata.gz: b4380bddd08abd79d38d6a5dde6b99c5af8ad93d4ab0086783c258f50accebb0c4c6abb9f649d468b1e7578ecfd60aa56bdccfc13943ec8e43191a5ef999b525
7
+ data.tar.gz: 6dc99a2dedb8a4ffabdd1a086cb5204a91c7e56c4afd20f47a5593fa220d742c52dd01b987c4027fdd6d89f4f26df36744d8edf6cd2b5e0b261160723eb21ebf
data/README.md CHANGED
@@ -19,12 +19,18 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
  ```
22
+ $ >> cwa help
22
23
  Commands:
23
24
  cwa alarms --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # show cloudwatch alms
25
+ cwa configure # create config files
24
26
  cwa disable --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # disable cloudwatch alms
25
27
  cwa enable --name ALARMNAME --regexp ALARMNAME --namespae NAMESPACE --dimensions KEY:VALUE # enable cloudwatch alms
26
28
  cwa help [COMMAND] # Describe available commands or one specific command
27
29
 
28
30
  Options:
29
31
  [--verbose], [--no-verbose]
32
+ [--profile=PROFILE]
33
+ [--region=REGION]
34
+ [--assume-role=ASSUME_ROLE]
35
+ [--output=OUTPUT]
30
36
  ```
@@ -5,6 +5,7 @@ require 'thor'
5
5
  require 'terminal-table'
6
6
  require 'colorize'
7
7
  require 'yaml'
8
+ require 'json'
8
9
  require 'fileutils'
9
10
 
10
11
  ASSUME_DIR = File.join(Dir.home, '.config', 'cwa').freeze
@@ -14,6 +15,12 @@ OUTPUT_KEYS = %i[
14
15
  namespace
15
16
  alarm_name
16
17
  actions_enabled
18
+ ].freeze
19
+
20
+ OUTPUT_KEYS_DETAIL = %i[
21
+ namespace
22
+ alarm_name
23
+ actions_enabled
17
24
  dimensions
18
25
  alarm_arn
19
26
  alarm_description
@@ -35,6 +42,7 @@ module CWA
35
42
  class_option :profile, type: :string
36
43
  class_option :region, type: :string
37
44
  class_option :assume_role, type: :string
45
+ class_option :output, type: :string
38
46
 
39
47
  desc "alarms #{OPTIONS}", 'show cloudwatch alms'
40
48
  option :name, type: :string, aliases: 'n'
@@ -47,11 +55,18 @@ module CWA
47
55
  alms = output_alms
48
56
  raise 'not alarms' if alms.empty?
49
57
 
50
- head = alms.first.keys
51
- rows = alms.map{|alm| alm.values }
52
- table = Terminal::Table.new :headings => head, :rows => rows
53
58
 
54
- puts table
59
+ case options[:output]
60
+ when 'json'
61
+ puts JSON.dump(alms)
62
+ when 'yaml'
63
+ puts YAML.dump(alms)
64
+ else
65
+ head = alms.first.keys
66
+ rows = alms.map{|alm| alm.values }
67
+ table = Terminal::Table.new :headings => head, :rows => rows
68
+ puts table
69
+ end
55
70
  end
56
71
 
57
72
  desc "enable #{OPTIONS}", 'enable cloudwatch alms'
@@ -144,10 +159,12 @@ module CWA
144
159
  def output_alms
145
160
  cwa = CWA.get(options)
146
161
  alms = cwa.alarms(options)
162
+ keys = OUTPUT_KEYS
163
+ keys = OUTPUT_KEYS_DETAIL if options[:verbose]
147
164
 
148
165
  alms.map do |alm|
149
166
  v = Hash.new
150
- OUTPUT_KEYS.each do |key|
167
+ keys.each do |key|
151
168
  v[key] = alm.method(key).call
152
169
  end
153
170
  v
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CWA
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cwa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - gen