@allow_remote_invocation
    def update_rule(self, in_data):
        try:
            rule_id = in_data['id']
        except __HOLE__:
            return {
                'error': _("Please provide an id."),
            }

        try:
            action = in_data['update_action']
        except KeyError:
            return {
                'error': _("Please provide an update_action."),
            }

        if action not in (
            self.ACTION_ACTIVATE,
            self.ACTION_DEACTIVATE,
            self.ACTION_DELETE,
        ):
            return {
                'error': _("Unrecognized update_action."),
            }

        try:
            rule = AutomaticUpdateRule.objects.get(pk=rule_id)
        except AutomaticUpdateRule.DoesNotExist:
            return {
                'error': _("Rule not found."),
            }

        if rule.domain != self.domain:
            return {
                'error': _("Rule not found."),
            }

        if action == self.ACTION_ACTIVATE:
            rule.activate()
        elif action == self.ACTION_DEACTIVATE:
            rule.activate(False)
        elif action == self.ACTION_DELETE:
            rule.soft_delete()

        return {
            'success': True,
        }
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/data_interfaces/views.py/AutomaticUpdateRuleListView.update_rule