lita-aws 0.1.0 → 0.1.1

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: 0bd224dc01c114fb7d28b90fd62755a9780d410c
4
- data.tar.gz: c9eb9e31b8563d325d4abd736d6f4bf281b55cfd
3
+ metadata.gz: c75caabc9cd62d2a88b6696149d25e6b07c890d6
4
+ data.tar.gz: 2990a58e788f53f522e1aaadff8f3842c16b72f8
5
5
  SHA512:
6
- metadata.gz: 1b5f4d79182d7c4611048318bbfe96a782b08c0c61175dbd42618c4f8b51123a980efb4c135739fadb68e787184e791553bfec778dde923d169df8a8f213c9b1
7
- data.tar.gz: 2504901197409855be053edd14d29c0ea3c8b801c12a1d0ce7e635fc8ac3b4954c6f488b78cf6858e5b9f943c18d31a6c86ba896ff5508f29db3da12a7b0558a
6
+ metadata.gz: 43ce2007c124cbeb3c9c693db5cf91a81e3c1d81a5afd605f9031a8b3a0ddb716c732e3b83a37161dc86565d36091381c41b3d5208f59a7797ef760a4f88a908
7
+ data.tar.gz: 8429f13e8ec42c4ea4605ff480d49452b57ccf438fdc540a7ad6ded992e7ca5c27e18d36c4da38893e5529e49955e8c26f418faa3141b0aad7aa08d00353e5c8
data/README.md CHANGED
@@ -59,7 +59,7 @@ Example:
59
59
  (lita) aws account-id --profile 5fpro
60
60
  ```
61
61
 
62
- #### Execute as aws-cli.
62
+ # Execute as aws-cli
63
63
 
64
64
  ```
65
65
  (lita) aws-cli ec2 describe-instances --page-size 10 --profile {profile_name}
@@ -74,9 +74,15 @@ aws ec2 describe-instances --page-size 10 --profile {profile_name}
74
74
  and return json.
75
75
 
76
76
 
77
+ ## Customized commands usage
78
+
79
+ - `lita-aws` provide customized commands for re-composing json data and formatting output to human-readable response. All of these customized command will use `aws ` as command prefix.
80
+
81
+ - Here is the exmaple to get cloudwatch data:
82
+
77
83
  #### Get cloudwatch metric data.
78
84
 
79
- - lita-aws provide gem-owned command for re-composing json data and formatting output for bot response. All of these customized command will use `aws ` as prefix, here is the exmaple to get cloudwatch data.
85
+ - Get EC2 instance memory utilization from Cloudwatch.
80
86
 
81
87
  ```
82
88
  (lita) aws ec2-memutil {Instance ID} --ago 2d --cal Average --period 300s --profile {profile_name}
@@ -105,7 +111,7 @@ options:
105
111
  - period: `300s` means each data contains 300 seconds.
106
112
  - cal: `Averages` means each period data will calculate its average as output value. To see more values http://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html and find `--statistics`.
107
113
 
108
- #### More customized commands
114
+ ## More customized commands
109
115
 
110
116
  ```
111
117
  (lita) help aws
@@ -6,6 +6,8 @@ module LitaAws
6
6
 
7
7
  def exec_cli(cmd, opts = {})
8
8
  cmd_postfix = opts.to_a.map { |e| "--#{e.first} #{e.last}"}.join(' ')
9
+ cmd = cmd.gsub(';', '')
10
+ cmd_postfix = cmd_postfix.gsub(';', '')
9
11
  `aws #{cmd} #{cmd_postfix}`
10
12
  end
11
13
 
@@ -17,5 +19,6 @@ module LitaAws
17
19
  # TODO: debug here
18
20
  response.reply(text)
19
21
  end
22
+
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module LitaAws
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -10,7 +10,7 @@ module Lita
10
10
  results = profiles.inject({}) do |h, e|
11
11
  h.merge(e => attrs.inject({}) do |hh, ee|
12
12
  profile = e == 'default' ? '' : "--profile #{e}"
13
- hh.merge(ee => `aws configure get #{ee} #{profile}`.gsub("\n", ''))
13
+ hh.merge(ee => exec_cli("configure get #{ee} #{profile}").gsub("\n", ''))
14
14
  end)
15
15
  end
16
16
  lines = results.to_a.inject([]) { |a, e| a + ["#{e[0]}: #{e[1].values.join(', ')}"] }
@@ -22,7 +22,7 @@ module Lita
22
22
  name, @region, @aws_access_key_id, @aws_secret_access_key = response.matches.first
23
23
  cmd_postfix = name == 'default' ? '' : "--profile #{name}"
24
24
  ['region', 'aws_access_key_id', 'aws_secret_access_key'].each do |attr|
25
- `aws configure set #{attr} #{instance_variable_get("@#{attr}")} #{cmd_postfix}`
25
+ exec_cli("configure set #{attr} #{instance_variable_get("@#{attr}")} #{cmd_postfix}")
26
26
  end
27
27
  response.reply("Set profile #{name}:\n region: #{@region}\n aws_access_key_id: #{@aws_access_key_id}\n aws_secret_access_key: #{@aws_secret_access_key}")
28
28
  end
@@ -1,17 +1,18 @@
1
1
  module Lita
2
2
  module Handlers
3
3
  class Aws < Handler
4
+ include ::LitaAws::Base
4
5
 
5
6
  help = { 'aws [service] help' => 'Get command options help of [service].' }
6
7
  route(/aws (.+) help$/, help: help) do |response|
7
8
  service = response.matches[0][0]
8
- text = `aws #{service} help|cat`
9
+ text = exec_cli("#{service} help|cat")
9
10
  response.reply(text.gsub("\n\n", "\n"))
10
11
  end
11
12
 
12
13
  help = { 'aws-cli [command]' => 'Execute aws-cli.' }
13
14
  route(/aws\-cli (.+)$/, help: help) do |response|
14
- response.reply(`aws #{response.matches.first[0]}`)
15
+ response.reply(exec_cli(response.matches.first[0]))
15
16
  end
16
17
 
17
18
  Lita.register_handler(self)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - marsz