<commit_before>
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..',
                                   'puppet_x', 'sensu', 'boolean_property.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..',
                                   'puppet_x', 'sensu', 'to_type.rb'))

Puppet::Type.newtype(:sensu_client_config) do
  @doc = "Manages Sensu client config"

  def initialize(*args)
    super *args

    if c = catalog
      self[:notify] = [
        'Service[sensu-client]',
      ].select { |ref| c.resource(ref) }
    end
  end

  ensurable do
    newvalue(:present) do
      provider.create
    end

    newvalue(:absent) do
      provider.destroy
    end

    defaultto :present
  end

  newparam(:name) do
    desc "The name of the host"
  end

  newproperty(:client_name) do
    desc ""
  end

  newproperty(:address) do
    desc ""
  end

  newproperty(:subscriptions, :array_matching => :all) do
    desc ""
    def insync?(is)
      is.sort == should.sort
    end
  end

  newproperty(:redact, :array_matching => :all) do
    desc "An array of strings that should be redacted in the sensu client config"
    newvalues(/.*/, :absent)
    def insync?(is)
      return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array)
      is == should
    end
  end

  newproperty(:socket) do
    desc "A set of attributes that configure the Sensu client socket."<commit_msg>Fix potential issue for client subscriptions parameter, as redact in #834<commit_after>
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..',
                                   'puppet_x', 'sensu', 'boolean_property.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..',
                                   'puppet_x', 'sensu', 'to_type.rb'))

Puppet::Type.newtype(:sensu_client_config) do
  @doc = "Manages Sensu client config"

  def initialize(*args)
    super *args

    if c = catalog
      self[:notify] = [
        'Service[sensu-client]',
      ].select { |ref| c.resource(ref) }
    end
  end

  ensurable do
    newvalue(:present) do
      provider.create
    end

    newvalue(:absent) do
      provider.destroy
    end

    defaultto :present
  end

  newparam(:name) do
    desc "The name of the host"
  end

  newproperty(:client_name) do
    desc ""
  end

  newproperty(:address) do
    desc ""
  end

  newproperty(:subscriptions, :array_matching => :all) do
    desc ""
    newvalues(/.*/, :absent)
    def insync?(is)
      return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array)
      is == should
    end
  end

  newproperty(:redact, :array_matching => :all) do
    desc "An array of strings that should be redacted in the sensu client config"
    newvalues(/.*/, :absent)
    def insync?(is)
      return is.sort == should.sort if is.is_a?(Array) && should.is_a?(Array)
      is == should
    end
  end

  newproperty(:socket) do
    desc "A set of attributes that configure the Sensu client socket."
{'fraction_non_alphanumeric': 0.12746079412746078, 'fraction_numerical': 0.001001001001001001, 'mean_word_length': 2.5187793427230045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '115550', 'n_tokens_mistral': 1005, 'n_tokens_neox': 970, 'n_words': 253}