<commit_before>module Nexpose
  require 'json'
  # Configuration structure for password policies.
  class PasswordPolicy < APIObject
    attr_accessor :policy_name
    attr_accessor :min_length
    attr_accessor :max_length
    attr_accessor :capitals
    attr_accessor :digits
    attr_accessor :special_chars
    attr_accessor :expiryDays

    def initialize(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiry:)
      @policy_name = policy_name.to_s
      @min_length = min_length.to_i
      @max_length = max_length.to_i
      @special_chars = special_chars.to_i
      @capitals = capitals.to_i
      @digits = digits.to_i
      @expiryDays = expiry.to_i
    end

    def self.from_hash(hash)
      new(policy_name: hash[:policyName],
          min_length: hash[:minLength],
          max_length: hash[:maxLength],
          special_chars: hash[:specialChars],
          capitals: hash[:capitals],
          digits: hash[:digits],
          expiryDays: hash[:expiryDays])
    end

    def to_h
      {
          policyName: @policy_name,
          minLength: @min_length,
          maxLength: @max_length,
          specialChars: @special_chars,
          capitals: @capitals,
          digits: @digits,
          expiryDays: @expiryDays
      }
    end

    def to_json
      JSON.generate(to_h)
    end

    def save(nsc)
      params = to_json
      AJAX.post(nsc, '/api/2.1/password_policy/', params, AJAX::CONTENT_TYPE::JSON)
    end

    def self.load(nsc)
      uri = '/api/2.1/password_policy/'
      resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON)
      hash = JSON.parse(resp, symbolize_names: true)
      self.from_hash(hash)
    end
  end
end
<commit_msg>NEX-43814 - renaming expiry to expiry_days<commit_after>module Nexpose
  require 'json'
  # Configuration structure for password policies.
  class PasswordPolicy < APIObject
    attr_accessor :policy_name
    attr_accessor :min_length
    attr_accessor :max_length
    attr_accessor :capitals
    attr_accessor :digits
    attr_accessor :special_chars
    attr_accessor :expiry_days

    def initialize(policy_name:, min_length:, max_length:, special_chars:, capitals:, digits:, expiry_days:)
      @policy_name = policy_name.to_s
      @min_length = min_length.to_i
      @max_length = max_length.to_i
      @special_chars = special_chars.to_i
      @capitals = capitals.to_i
      @digits = digits.to_i
      @expiry_days = expiry_days.to_i
    end

    def self.from_hash(hash)
      new(policy_name: hash[:policyName],
          min_length: hash[:minLength],
          max_length: hash[:maxLength],
          special_chars: hash[:specialChars],
          capitals: hash[:capitals],
          digits: hash[:digits],
          expiry_days: hash[:expiryDays])
    end

    def to_h
      {
          policyName: @policy_name,
          minLength: @min_length,
          maxLength: @max_length,
          specialChars: @special_chars,
          capitals: @capitals,
          digits: @digits,
          expiryDays: @expiry_days
      }
    end

    def to_json
      JSON.generate(to_h)
    end

    def save(nsc)
      params = to_json
      AJAX.post(nsc, '/api/2.1/password_policy/', params, AJAX::CONTENT_TYPE::JSON)
    end

    def self.load(nsc)
      uri = '/api/2.1/password_policy/'
      resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON)
      hash = JSON.parse(resp, symbolize_names: true)
      self.from_hash(hash)
    end
  end
end

{'fraction_non_alphanumeric': 0.09609261939218523, 'fraction_numerical': 0.0037626628075253256, 'mean_word_length': 2.6150627615062763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4015314', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1148, 'n_words': 228}