def post(self, request, *args, **kwargs): form = ClearGatewayValidator(data=request.data) if not form.is_valid(): return Response(console_response(code=1, ret_msg=get_serializer_error( form.errors)), status=status.HTTP_200_OK) payload = { "owner": form.validated_data.get("owner"), "zone": form.validated_data.get("zone"), "router_id": form.validated_data.get("router_id") } resp = RouterService.clear_gateway(payload) return Response(resp)
def _run_query(self): """ self._record_total = self._module.objects.all().count() filter_data = self._module.objects.filter(self._search_query) self._record_filtered = filter_data.count() return filter_data """ self._search_query() _resp = RouterService.describe_router(self._zone, self._owner, self._subnet_name, self._network_name) _ret_list = [] if _resp is None: self._record_total = self._record_filtered = 0 return [] _ret_list = _resp["ret_set"] self._record_filtered = self._record_total = _resp.get( "total_count") or 100 return _ret_list
def post(self, request, *args, **kwargs): form = CreateRouterValidator(data=request.data) if not form.is_valid(): return Response(console_response(code=1, ret_msg=get_serializer_error( form.errors)), status=status.HTTP_200_OK) payload = { "owner": form.validated_data.get("owner"), "zone": form.validated_data.get("zone"), "name": form.validated_data.get("name"), "enable_snat": form.validated_data.get("enable_snat"), "enable_gateway": form.validated_data.get("enable_gateway"), "subnet_list": form.validated_data.get("subnet_list") } resp = RouterService.create_router(payload) return Response(resp)
def post(self, request, *args, **kwargs): form = DescribeRouterValidator(data=request.data) if not form.is_valid(): return Response(console_response(code=1, ret_msg=get_serializer_error( form.errors)), status=status.HTTP_200_OK) payload = { "owner": form.validated_data.get("owner"), "zone": form.validated_data.get("zone"), "subnet_id": form.validated_data.get("subnet_id"), "router_id": form.validated_data.get("router_id") } resp = RouterService.describe_router(payload) if resp.get("code"): return Response(resp) output_list = resp.get('ret_set') handle = HandleList() return Response(handle.handle(request, output_list))