<commit_before>class ApiController
  module VirtualTemplates
    def update_virtual_templates
      aname = parse_action_name
      if aname == 'edit' && !api_user_role_allows?(aname)
        render_normal_update :virtual_templates, update_collection(:virtual_templates, @req[:c_id])
      else
        update_generic(:virtual_templates)
      end
    end

    def create_resource_virtual_templates(_type, _id, data)
      validate_vendor_present(data)
      template_name = 'ManageIQ::Providers::' + data['vendor'].capitalize + '::CloudManager::VirtualTemplate'
      const = template_name.constantize
      template = const.new(data)
      if template.invalid?
        raise BadRequestError, "Failed to create a new virtual template - #{template.errors.full_messages.join(', ')}"
      end
      template
    end

    def edit_resource_virtual_templates(type, id, data)
      edit_resource(type, id, data)
    end

    private

    def validate_vendor_present(data)
      raise BadRequestError, 'Must specify a vendor for creating a Virtual Template' unless data['vendor']
    end
  end
end<commit_msg>removes unnecessary code to edit - will just use the generic methods; adds ability to delete<commit_after>class ApiController
  module VirtualTemplates
    def create_resource_virtual_templates(_type, _id, data)
      validate_vendor_present(data)
      template_name = 'ManageIQ::Providers::' + data['vendor'].capitalize + '::CloudManager::VirtualTemplate'
      const = template_name.constantize
      template = const.new(data)
      if template.invalid?
        raise BadRequestError, "Failed to create a new virtual template - #{template.errors.full_messages.join(', ')}"
      end
      template
    end

    private

    def validate_vendor_present(data)
      raise BadRequestError, 'Must specify a vendor for creating a Virtual Template' unless data['vendor']
    end
  end
end
{'fraction_non_alphanumeric': 0.08253968253968254, 'fraction_numerical': 0.0, 'mean_word_length': 3.7039800995024876, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3515708', 'n_tokens_mistral': 523, 'n_tokens_neox': 514, 'n_words': 139}