Module: Sensu::Translator::Translations

Included in:
Runner
Defined in:
lib/sensu/translator/translations.rb

Instance Method Summary collapse

Instance Method Details

#translate_check(check, organization, environment) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sensu/translator/translations.rb', line 11

def translate_check(check, organization, environment)
  check[:subscriptions] = check.delete(:subscribers) || []
  if check[:standalone]
    check.delete(:standalone)
    check[:subscriptions] << "standalone"
  end
  check[:publish] = check.fetch(:publish, true)
  check[:handlers] ||= [check.fetch(:handler, "default")]
  if check[:source]
    check[:proxy_entity_id] = check.delete(:source)
  end
  v2_spec(:check, check, organization, environment)
end

#translate_extension(extension, organization, environment) ⇒ Object



39
40
41
42
43
# File 'lib/sensu/translator/translations.rb', line 39

def translate_extension(extension, organization, environment)
  puts "Sensu 1.x extension translation is not yet supported"
  puts "Unable to translate Sensu 1.x extension: #{extension}"
  nil
end

#translate_filter(filter, organization, environment) ⇒ Object



25
26
27
28
29
# File 'lib/sensu/translator/translations.rb', line 25

def translate_filter(filter, organization, environment)
  puts "Sensu 1.x filter translation is not yet supported"
  puts "Unable to translate Sensu 1.x filter: #{filter}"
  nil
end

#translate_handler(handler, organization, environment) ⇒ Object



35
36
37
# File 'lib/sensu/translator/translations.rb', line 35

def translate_handler(handler, organization, environment)
  v2_spec(:handler, handler, organization, environment)
end

#translate_mutator(mutator, organization, environment) ⇒ Object



31
32
33
# File 'lib/sensu/translator/translations.rb', line 31

def translate_mutator(mutator, organization, environment)
  v2_spec(:mutator, mutator, organization, environment)
end

#v2_spec(type, object, organization, environment) ⇒ Object



4
5
6
7
8
9
# File 'lib/sensu/translator/translations.rb', line 4

def v2_spec(type, object, organization, environment)
  {
    :type => type.to_s.capitalize,
    :spec => object.merge(:organization => organization, :environment => environment)
  }
end