<commit_before>
Puppet::Type.type(:zabbix_trigger).provide(:ruby) do
  desc "zabbix trigger provider"
  confine :feature => :zabbixapi

  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../../lib/ruby/")
  require "zabbix"
  require 'pp'

  def exists?
    zbx.client.api_request(
      :method => "trigger.exists",
      :params => {
        :expression => resource[:expression],
      })
  end
  
  def create
    extend Zabbix
    zbx.triggers.create(
      :description => resource[:description],
      :expression => resource[:expression],
      :comments => resource[:comments],
      :priority => resource[:priority],
      :status => resource[:status],
      :type => resource[:type],
      :url => resource[:url]
    )
  end
  
  def destroy
    extend Zabbix
    #When destroying we have to find the trigger by description and expression and then destroy by id
    result = zbx.client.api_request(
      :method => "trigger.get",
      :params => {
        :filter => {:description => resource[:description]},
        :output => "extend",
        :expandExpression => "data"
      }
    )
    trigger_ids = []
    result.each { |trigger| trigger_ids.push(trigger["triggerid"]) if trigger["expression"] == data[:expression] }
    zbx.triggers.delete(
      trigger_ids
    )
  end
end
<commit_msg>missing include Zabbix<commit_after>
Puppet::Type.type(:zabbix_trigger).provide(:ruby) do
  desc "zabbix trigger provider"
  confine :feature => :zabbixapi

  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../../../lib/ruby/")
  require "zabbix"
  require 'pp'

  def exists?
    extend Zabbix
    zbx.client.api_request(
      :method => "trigger.exists",
      :params => {
        :expression => resource[:expression],
      })
  end
  
  def create
    extend Zabbix
    zbx.triggers.create(
      :description => resource[:description],
      :expression => resource[:expression],
      :comments => resource[:comments],
      :priority => resource[:priority],
      :status => resource[:status],
      :type => resource[:type],
      :url => resource[:url]
    )
  end
  
  def destroy
    extend Zabbix
    #When destroying we have to find the trigger by description and expression and then destroy by id
    result = zbx.client.api_request(
      :method => "trigger.get",
      :params => {
        :filter => {:description => resource[:description]},
        :output => "extend",
        :expandExpression => "data"
      }
    )
    trigger_ids = []
    result.each { |trigger| trigger_ids.push(trigger["triggerid"]) if trigger["expression"] == data[:expression] }
    zbx.triggers.delete(
      trigger_ids
    )
  end
end

{'fraction_non_alphanumeric': 0.14733660748016622, 'fraction_numerical': 0.0, 'mean_word_length': 2.810071942446043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7309092', 'n_tokens_mistral': 805, 'n_tokens_neox': 784, 'n_words': 180}