Module: AwsCleaner::Notify

Defined in:
lib/aws-cleaner.rb

Class Method Summary collapse

Class Method Details

.notify_chat(msg, config) ⇒ Object

generic chat notification method



134
135
136
137
138
139
140
# File 'lib/aws-cleaner.rb', line 134

def self.notify_chat(msg, config)
  if config[:hipchat][:enable]
    notify_hipchat(msg, config)
  elsif config[:slack][:enable]
    notify_slack(msg, config)
  end
end

.notify_hipchat(msg, config) ⇒ Object

notify hipchat



115
116
117
118
119
120
121
122
# File 'lib/aws-cleaner.rb', line 115

def self.notify_hipchat(msg, config)
  hipchat = HipChat::Client.new(
    config[:hipchat][:api_token],
    api_version: 'v2'
  )
  room = config[:hipchat][:room]
  hipchat[room].send('AWS Cleaner', msg)
end

.notify_slack(msg, config) ⇒ Object

notify slack



125
126
127
128
129
130
131
# File 'lib/aws-cleaner.rb', line 125

def self.notify_slack(msg, config)
  slack = Slack::Poster.new(config[:slack][:webhook_url])
  slack.channel = config[:slack][:channel]
  slack.username = config[:slack][:username] ||= 'aws-cleaner'
  slack.icon_emoji = config[:slack][:icon_emoji] ||= nil
  slack.send_message(msg)
end