Module: Zeus::AlertsInterface

Includes:
RestInterface
Included in:
APIClient
Defined in:
lib/zeus/api_client/alerts_interface.rb

Overview

Interface for dealing with alerts api calls

Instance Method Summary collapse

Instance Method Details

#create_alert(alert_data) ⇒ Zeus::APIClient::Result

create alert

Parameters:

  • alert_data (Hash)

    must contain: @param [String] alert_name name of the alert @param [String] username account username @param [String] token account token @param [String] alerts_type alert type, metrics or logs @param [String] alert_expression expression to evaluate the alert @param [String] alert_severity severity level of the alert @param [String] metric_name <TODO add description> @param [String] emails recipients to receive notifications @param [String] status if the alerts is enabled or not @param [Integer] frequency <TODO add description>

Returns:

  • (Zeus::APIClient::Result)


40
41
42
43
44
45
46
# File 'lib/zeus/api_client/alerts_interface.rb', line 40

def create_alert(alert_data)
  alert_data[:token] = @access_token
  response = post("/alerts/#{@access_token}", alert_data)
  Result.new(response)
rescue => e
  Result.new(e.response)
end

#delete_alert(alert_id) ⇒ Zeus::APIClient::Result

delete alert

Parameters:

  • alert_id (Integer)

    id of alert to be deleted

Returns:

  • (Zeus::APIClient::Result)


101
102
103
104
105
106
# File 'lib/zeus/api_client/alerts_interface.rb', line 101

def delete_alert(alert_id)
  response = delete("/alerts/#{@access_token}/#{alert_id}")
  Result.new(response)
rescue => e
  Result.new(e.response)
end

#disable_alerts(alert_id_array) ⇒ Zeus::APIClient::Result

disable alerts

Parameters:

  • alert_id_list (Array[Integer])

    list of alert ids to be disabled

Returns:

  • (Zeus::APIClient::Result)


126
127
128
129
130
131
132
133
134
# File 'lib/zeus/api_client/alerts_interface.rb', line 126

def disable_alerts(alert_id_array)
  params = { id: alert_id_array }
  begin
    response = post("/alerts/#{@access_token}/disable", params)
    Result.new(response)
  rescue => e
    Result.new(e.response)
  end
end

#enable_alerts(alert_id_array) ⇒ Zeus::APIClient::Result

enable alerts

Parameters:

  • alert_id_list (Array[Integer])

    list of alert ids to be enabled

Returns:

  • (Zeus::APIClient::Result)


112
113
114
115
116
117
118
119
120
# File 'lib/zeus/api_client/alerts_interface.rb', line 112

def enable_alerts(alert_id_array)
  params = { id: alert_id_array }
  begin
    response = post("/alerts/#{@access_token}/enable", params)
    Result.new(response)
  rescue => e
    Result.new(e.response)
  end
end

#get_alert(alert_id) ⇒ Zeus::APIClient::Result

get alert

Parameters:

  • alert_id (Integer)

    id of alert to be retrieved

Returns:

  • (Zeus::APIClient::Result)


90
91
92
93
94
95
# File 'lib/zeus/api_client/alerts_interface.rb', line 90

def get_alert(alert_id)
  response = get("/alerts/#{@access_token}/#{alert_id}")
  Result.new(response)
rescue => e
  Result.new(e.response)
end

#get_alerts(metric = nil) ⇒ Zeus::APIClient::Result

get alerts

Parameters:

  • metric (String) (defaults to: nil)

    Name of metric that alerts are associated with

Returns:

  • (Zeus::APIClient::Result)


76
77
78
79
80
81
82
83
84
# File 'lib/zeus/api_client/alerts_interface.rb', line 76

def get_alerts(metric = nil)
  params = { metric: metric }
  begin
    response = get("/alerts/#{@access_token}", params)
    Result.new(response)
  rescue => e
    Result.new(e.response)
  end
end

#modify_alert(alert_id, alert_data) ⇒ Zeus::APIClient::Result

modify alert

Parameters:

  • alert_id (Integer)

    id of the alert to be modified

  • alert_data (Hash)

    must contain: @param [String] alert_name name of the alert @param [String] username account username @param [String] token account token @param [String] alert_expression expression to evaluate the alert Optional params: @param [String] alerts_type alert type, metrics or logs @param [String] alert_severity severity level of the alert @param [String] metric_name <TODO add description> @param [String] emails recipients to receive notifications @param [String] status if the alerts is enabled or not @param [Integer] frequency <TODO add description>

Returns:

  • (Zeus::APIClient::Result)


64
65
66
67
68
69
70
# File 'lib/zeus/api_client/alerts_interface.rb', line 64

def modify_alert(alert_id, alert_data)
  alert_data[:token] = @access_token
  response = put("/alerts/#{@access_token}/#{alert_id}", alert_data)
  Result.new(response)
rescue => e
  Result.new(e.response)
end