def post(self, rule, requester_user):
        """
        Create a new rule.

        Handles requests:
            POST /rules/
        """
        rbac_utils = get_rbac_backend().get_utils_class()

        permission_type = PermissionType.RULE_CREATE
        rbac_utils.assert_user_has_resource_api_permission(
            user_db=requester_user, resource_api=rule, permission_type=permission_type
        )

        if not requester_user:
            requester_user = UserDB(name=cfg.CONF.system_user.user)

        # Validate that the authenticated user is admin if user query param is provided
        user = requester_user.name
        rbac_utils.assert_user_is_admin_if_user_query_param_is_provided(
            user_db=requester_user, user=user
        )

        if not hasattr(rule, "context"):
            rule.context = dict()

        rule.context["user"] = user

        try:
            rule_db = RuleAPI.to_model(rule)
            LOG.debug("/rules/ POST verified RuleAPI and formulated RuleDB=%s", rule_db)

            # Check referenced trigger and action permissions
            # Note: This needs to happen after "to_model" call since to_model performs some
            # validation (trigger exists, etc.)
            rbac_utils.assert_user_has_rule_trigger_and_action_permission(
                user_db=requester_user, rule_api=rule
            )

            rule_db = Rule.add_or_update(rule_db)
            # After the rule has been added modify the ref_count. This way a failure to add
            # the rule due to violated constraints will have no impact on ref_count.
            increment_trigger_ref_count(rule_api=rule)
        except (ValidationError, ValueError) as e:
            LOG.exception("Validation failed for rule data=%s.", rule)
            abort(http_client.BAD_REQUEST, six.text_type(e))
            return
        except (ValueValidationException, jsonschema.ValidationError) as e:
            LOG.exception("Validation failed for rule data=%s.", rule)
            abort(http_client.BAD_REQUEST, six.text_type(e))
            return
        except TriggerDoesNotExistException:
            msg = (
                'Trigger "%s" defined in the rule does not exist in system or it\'s missing '
                'required "parameters" attribute' % (rule.trigger["type"])
            )
            LOG.exception(msg)
            abort(http_client.BAD_REQUEST, msg)
            return

        extra = {"rule_db": rule_db}
        LOG.audit("Rule created. Rule.id=%s" % (rule_db.id), extra=extra)
        rule_api = RuleAPI.from_model(rule_db)

        return Response(json=rule_api, status=exc.HTTPCreated.code)

        Create a new rule.

        Handles requests:
            POST /rules/
        
st2api/st2api/controllers/v1/rules.py