<commit_before>class ExtManagementSystem < ApplicationRecord
  include CustomActionsMixin
  include SupportsFeatureMixin

  def self.types
    leaf_subclasses.collect(&:ems_type)
  end

  def self.supported_types
    supported_subclasses.collect(&:ems_type)
  end

  def self.leaf_subclasses
    descendants.select { |d| d.subclasses.empty? }
  end

  def self.supported_subclasses
    subclasses.flat_map do |s|
      s.subclasses.empty? ? s : s.supported_subclasses
    end
  end

  def self.supported_types_and_descriptions_hash
    supported_subclasses.each_with_object({}) do |klass, hash|
      if Vmdb::PermissionStores.instance.supported_ems_type?(klass.ems_type)
        hash[klass.ems_type] = klass.description
      end
    end
  end

  def self.api_allowed_attributes
    %w[]
  end

  belongs_to :provider
  has_many :child_managers, :class_name => 'ExtManagementSystem', :foreign_key => 'parent_ems_id'

  belongs_to :tenant
  has_many :endpoints, :as => :resource, :dependent => :destroy, :autosave => true<commit_msg>Add method to list supported providers for create<commit_after>class ExtManagementSystem < ApplicationRecord
  include CustomActionsMixin
  include SupportsFeatureMixin

  def self.types
    leaf_subclasses.collect(&:ems_type)
  end

  def self.supported_types
    supported_subclasses.collect(&:ems_type)
  end

  def self.leaf_subclasses
    descendants.select { |d| d.subclasses.empty? }
  end

  def self.supported_subclasses
    subclasses.flat_map do |s|
      s.subclasses.empty? ? s : s.supported_subclasses
    end
  end

  def self.supported_types_and_descriptions_hash
    supported_subclasses.each_with_object({}) do |klass, hash|
      if Vmdb::PermissionStores.instance.supported_ems_type?(klass.ems_type)
        hash[klass.ems_type] = klass.description
      end
    end
  end

  def self.api_allowed_attributes
    %w[]
  end

  def self.supported_types_for_create
    leaf_subclasses.select(&:supported_for_create?)
  end

  def self.supported_for_create?
    !reflections.include?("parent_manager")
  end

  belongs_to :provider
  has_many :child_managers, :class_name => 'ExtManagementSystem', :foreign_key => 'parent_ems_id'

  belongs_to :tenant
  has_many :endpoints, :as => :resource, :dependent => :destroy, :autosave => true
{'fraction_non_alphanumeric': 0.08672798948751642, 'fraction_numerical': 0.0, 'mean_word_length': 4.238532110091743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3499978', 'n_tokens_mistral': 744, 'n_tokens_neox': 737, 'n_words': 146}