def get(self, request, *args, **kwargs): """ Returns a list of vip request with details by ids ou dict """ if not kwargs.get('obj_ids'): obj_model = facade.get_vip_request_by_search(self.search) vips_requests = obj_model['query_set'] only_main_property = False else: vip_request_ids = kwargs['obj_ids'].split(';') vips_requests = facade.get_vip_request_by_ids(vip_request_ids) obj_model = None only_main_property = True # serializer vips serializer_vips = VipRequestV3Serializer( vips_requests, many=True, fields=self.fields, include=self.include, exclude=self.exclude, kind='details' ) # prepare serializer with customized properties response = render_to_json( serializer_vips, main_property='vips', obj_model=obj_model, request=request, only_main_property=only_main_property ) return Response(response, status=status.HTTP_200_OK)
def post(self, request, *args, **kwargs): """ Creates list of vip request in equipments :url /api/v3/vip-request/deploy/<vip_request_ids>/ :param vip_request_ids=<vip_request_ids> """ vip_request_ids = kwargs['obj_ids'].split(';') vips = facade.get_vip_request_by_ids(vip_request_ids) vip_serializer = VipRequestV3Serializer( vips, many=True, include=('ports__identifier',)) locks_list = create_lock(vip_serializer.data, LOCK_VIP) try: response = facade.create_real_vip_request( vip_serializer.data, request.user) except Exception, exception: log.error(exception) raise api_exceptions.NetworkAPIException(exception)
def get(self, request, *args, **kwargs): """ Returns a list of vip request by ids ou dict """ try: if not kwargs.get('vip_request_ids'): obj_model = facade.get_vip_request_by_search(self.search) vips_requests = obj_model['query_set'] only_main_property = False else: vip_request_ids = kwargs['vip_request_ids'].split(';') vips_requests = facade.get_vip_request_by_ids(vip_request_ids) obj_model = None # serializer vips only_main_property = True serializer_vips = VipRequestV3Serializer(vips_requests, many=True, fields=self.fields, include=self.include, exclude=self.exclude, kind=self.kind) # prepare serializer with customized properties response = render_to_json(serializer_vips, main_property='vips', obj_model=obj_model, request=request, only_main_property=only_main_property) return CustomResponse(response, status=status.HTTP_200_OK, request=request) except Exception, exception: log.error(exception) raise api_exceptions.NetworkAPIException(exception)