Beispiel #1
0
 def delete(self, request, app_id, rule_id, *args, **kwargs):
     rule = domain_service.get_http_rule_by_id(self.team.tenant_id, rule_id)
     if not rule:
         raise ErrNotFoundDomain
     domain_service.unbind_httpdomain(self.team, self.region_name, rule_id)
     re = HTTPGatewayRuleSerializer(data=model_to_dict(rule))
     re.is_valid()
     return Response(re.data, status=status.HTTP_200_OK)
    def delete(self, request, *args, **kwargs):
        """
       删除策略

        """
        try:
            service_id = request.data.get("service_id", None)
            http_rule_id = request.data.get("http_rule_id", None)

            if not http_rule_id or not service_id:
                return Response(general_message(400, "params error", "参数错误"),
                                status=400)

            service = service_repo.get_service_by_service_id(service_id)
            if not service:
                return Response(general_message(400, "not service", "服务不存在"),
                                status=400)
            # 解绑域名
            code, msg = domain_service.unbind_httpdomain(
                self.tenant, service, http_rule_id)
            if code != 200:
                return Response(general_message(code, "delete domain error",
                                                msg),
                                status=code)
            result = general_message(200, "success", "策略删除成功")
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result, status=result["code"])