class Lita::Handlers::AlertlogicLogManager

Alert Logic Log Manager Routes

Public Instance Methods

lm_appliance_info(response) click to toggle source
# File lib/lita/handlers/alertlogic_log_manager.rb, line 90
def lm_appliance_info(response)
  customer_id = valid_cid(response.match_data[1])
  uuid        = response.match_data[2]
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  return response.reply(t('validation.uuid')) if uuid.nil?

  url_params  = {
    customer_id: customer_id,
    api_type:    'lm',
    source_type: 'appliances'
  }

  url    = construct_api_url(url_params)
  url    = "#{url}/#{uuid}"
  params = {
    customer_id: customer_id,
    url:         url
  }

  appliance_info = pretty_json(
    parse_json(
      api_call(params)
    )
  )

  reply_text = "/code #{appliance_info}"
  response.reply(reply_text)
end
lm_appliance_list(response) click to toggle source

LM Data Definitions

# File lib/lita/handlers/alertlogic_log_manager.rb, line 68
def lm_appliance_list(response)
  customer_id   = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  appliance_list = []
  customers      = get_customer_ids(customer_id)
  return response.reply(customers) unless customers.is_a? Array
  response.reply(t('warn.standby'))

  customers.each do |cid|
    params = {
      customer_id: cid,
      type:        'lm',
      source:      'appliances'
    }
    resp = api_call(params)
    appliance_list << process_appliances(resp, cid)
  end

  reply_text = appliance_list
  response.reply(reply_text)
end
lm_hosts_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_log_manager.rb, line 119
def lm_hosts_list(response)
  customer_id = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type:        'lm',
    source:      'hosts'
  }
  resp = parse_json(
    api_call(params)
  )

  reply_text = process_lm_hosts(customer_id, resp)
  if reply_text.length == 3
    head = reply_text[0]
    tables = reply_text[1]
    summary = reply_text[2]
    response.reply(head)
    tables.each do |data, headers|
      response.reply("/code #{build_table(data, headers)}")
    end
    response.reply(summary)
  else
    response.reply(reply_text)
  end
end
lm_policies_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_log_manager.rb, line 148
def lm_policies_list(response)
  customer_id = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type:        'lm',
    source:      'policies'
  }
  resp = parse_json(
    api_call(params)
  )

  reply_text = process_lm_policies(customer_id, resp)
  response.reply(reply_text)
end
lm_sources_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_log_manager.rb, line 166
def lm_sources_list(response)
  customer_id = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type:        'lm',
    source:      'sources'
  }
  resp = parse_json(
    api_call(params)
  )

  reply_text = process_lm_sources(customer_id, resp)
  if reply_text.length == 3
    head = reply_text[0]
    tables = reply_text[1]
    summary = reply_text[2]
    response.reply(head)
    tables.each do |data, headers|
      response.reply("/code #{build_table(data, headers)}")
    end
    response.reply(summary)
  else
    response.reply(reply_text)
  end
end