예제 #1
0
    def _validate_deletion(self, ident, entry):
        rulesets = AllRulesets()
        rulesets.load()
        matched_rulesets = SearchedRulesets(rulesets, {
            "rule_predefined_condition": ident
        }).get_rulesets()

        if matched_rulesets:
            raise MKUserError(
                "_delete",
                _("You can not delete this %s because it is <a href=\"%s\">in use</a>.") %
                (self._mode_type.name_singular(), self._search_url(ident)))
예제 #2
0
def list_rulesets(param):
    """Search rule sets"""
    user.need_permission("wato.rulesets")
    all_sets = FolderRulesets(
        param["folder"]) if param.get("folder") else AllRulesets()
    all_sets.load()

    def _get_search_options(params):
        # We remove 'folder' because that has already been handled at the start of the endpoint.
        options = dict(params)
        if "folder" in options:
            del options["folder"]
        return options

    if search_options := _get_search_options(param):
        all_sets = SearchedRulesets(all_sets, search_options)