Sha256: e316b25e93456dc1c0c99f48e6c3676b211505cf3c63551ab60c741562ebcee0
Contents?: true
Size: 1.28 KB
Versions: 8
Compression:
Stored size: 1.28 KB
Contents
class ZabbixApi class Triggers def initialize(options = {}) @client = Client.new(options) @options = options end def create(data) result = @client.api_request(:method => "trigger.create", :params => [data]) result.empty? ? nil : result['triggerids'][0].to_i end def add(data) create(data) end def delete(data) result = @client.api_request(:method => "trigger.delete", :params => [data]) result.empty? ? nil : result['triggerids'][0].to_i end def destroy(data) delete(data) end def update(data) result = @client.api_request(:method => "trigger.update", :params => data) result.empty? ? nil : result['triggerids'][0].to_i end def create_or_update(data) triggerid = get_id(:description => data[:description], :templateid => data[:templateid]) triggerid ? update(data.merge(:triggerid => triggerid)) : create(data) end def get_full_data(data) @client.api_request(:method => "trigger.get", :params => {:filter => data, :output => "extend"}) end def get_id(data) result = get_full_data(data) triggerid = nil result.each { |template| triggerid = template['triggerid'].to_i if template['name'] == data[:name] } triggerid end end end
Version data entries
8 entries across 8 versions & 1 rubygems