<commit_before>action :import do
  filename = ::File.basename(new_resource.source)
  temporary_path = "#{Chef::Config[:file_cache_path]}/#{filename}"

  f = cookbook_file temporary_path do
    source new_resource.source
  end

  f.run_action(:create)

  template_xml = open(temporary_path).read

  params = {
    format: 'xml',
    source: template_xml,
    rules: {
      items: { createMissing: true },
      applications: { createMissing: true },
      graphs: { createMissing: true },
      groups: { createMissing: true },
      templateLinkage: { createMissing: true },
      templates: { createMissing: true },
      triggers: { createMissing: true }
    }
  }

  server_connection = {
    url: "http://#{new_resource.zabbix_fqdn}/api_jsonrpc.php",
    user: new_resource.login,
    password: <PASSWORD>
  }

  zabbix_api_call new_resource.name do
    action :call
    server_connection server_connection
    method 'configuration.import'
    parameters params
  end

  new_resource.updated_by_last_action(true)
end<commit_msg>Bugfix zabbix cookbook from supermarket<commit_after>action :import do
  filename = ::File.basename(new_resource.source)
  temporary_path = "#{Chef::Config[:file_cache_path]}/#{filename}"

  f = cookbook_file temporary_path do
    source new_resource.source
  end

  f.run_action(:create)

  template_xml = open(temporary_path).read

  params = {
    format: 'xml',
    source: template_xml,
    rules: {
      items: { createMissing: true },
      applications: { createMissing: true },
      graphs: { createMissing: true },
      groups: { createMissing: true },
      templateLinkage: { createMissing: true },
      templates: { createMissing: true },
      triggers: { createMissing: true }
    }
  }

  server_connection = {
    url: "http://#{new_resource.zabbix_fqdn}/api_jsonrpc.php",
    user: new_resource.login,
    password: <PASSWORD>
  }

  zabbix_part_api_call new_resource.name do
    action :call
    server_connection server_connection
    method 'configuration.import'
    parameters params
  end

  new_resource.updated_by_last_action(true)
end
{'fraction_non_alphanumeric': 0.1067174845164364, 'fraction_numerical': 0.0, 'mean_word_length': 3.5553145336225596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6342146', 'n_tokens_mistral': 663, 'n_tokens_neox': 654, 'n_words': 133}