Class: God::Contacts::Sns

Inherits:
Contact
  • Object
show all
Defined in:
lib/god-sns-contact.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.access_key_idObject

Returns the value of attribute access_key_id.



20
21
22
# File 'lib/god-sns-contact.rb', line 20

def access_key_id
  @access_key_id
end

.arnObject

Returns the value of attribute arn.



20
21
22
# File 'lib/god-sns-contact.rb', line 20

def arn
  @arn
end

.formatObject

Returns the value of attribute format.



20
21
22
# File 'lib/god-sns-contact.rb', line 20

def format
  @format
end

.secret_access_keyObject

Returns the value of attribute secret_access_key.



20
21
22
# File 'lib/god-sns-contact.rb', line 20

def secret_access_key
  @secret_access_key
end

Instance Attribute Details

#access_key_idObject

Returns the value of attribute access_key_id.



42
43
44
# File 'lib/god-sns-contact.rb', line 42

def access_key_id
  @access_key_id
end

#arnObject

Returns the value of attribute arn.



42
43
44
# File 'lib/god-sns-contact.rb', line 42

def arn
  @arn
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



42
43
44
# File 'lib/god-sns-contact.rb', line 42

def secret_access_key
  @secret_access_key
end

Instance Method Details

#notify(message, time, priority, category, host) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/god-sns-contact.rb', line 44

def notify(message, time, priority, category, host)
  
  AWS.config(:access_key_id => access_key_id, :secret_access_key => secret_access_key)
  topic = AWS::SNS::Topic.new(arn)
  
  topic.publish(Sns.format.call(message, time, priority, category, host), :subject => "God Alert")

  self.info = "sent sns update"
rescue => e
  applog(nil, :info, "failed to send sns update: #{e.message}")
  applog(nil, :debug, e.backtrace.join("\n"))
end

#valid?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/god-sns-contact.rb', line 34

def valid?
  valid = true
  valid &= complain("Attribute 'access_key_id' must be specified", self) unless arg(:access_key_id)
  valid &= complain("Attribute 'secret_access_key' must be specified", self) unless arg(:secret_access_key)
  valid &= complain("Attribute 'arn' must be specified", self) unless arg(:arn)
  valid
end