Class: OopsGenie::OopsGenieAlert

Inherits:
Object
  • Object
show all
Defined in:
lib/oops_genie/oops_genie_alert.rb

Overview

configuration object to hold details of an OpsGenie Alert

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, message) ⇒ OopsGenieAlert

Returns a new instance of OopsGenieAlert.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/oops_genie/oops_genie_alert.rb', line 9

def initialize(api_key, message)
  @api_key = api_key
  @message = message
  @alias = nil
  @actions = nil
  @tags = nil
  @details = { description: message }
  @entity = nil
  @priority = nil
  @responders = nil
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def actions
  @actions
end

#aliasObject

Returns the value of attribute alias.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def alias
  @alias
end

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def api_key
  @api_key
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def description
  @description
end

#detailsObject

Returns the value of attribute details.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def details
  @details
end

#entityObject

Returns the value of attribute entity.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def entity
  @entity
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def message
  @message
end

#priorityObject

Returns the value of attribute priority.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def priority
  @priority
end

#respondersObject

Returns the value of attribute responders.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def responders
  @responders
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/oops_genie/oops_genie_alert.rb', line 6

def tags
  @tags
end

Instance Method Details

#alert_hashObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/oops_genie/oops_genie_alert.rb', line 21

def alert_hash
  attrs = {}
  instance_variables.each do |var|
    str = var.to_s.gsub /^@/, ''
    if respond_to? "#{str}="
      attrs[str.to_sym] = instance_variable_get var
    end
  end
  attrs
end

#send_alertObject



32
33
34
35
36
# File 'lib/oops_genie/oops_genie_alert.rb', line 32

def send_alert
  og_client = OopsGenie::OopsGenieClient.new(@api_key)
  response = og_client.send_alert(self)
  puts response
end