Пример #1
0
    def run_api_endpoint_callback(self, request, pk):
        access_log = self.get_object(request, pk)
        if not access_log:
            raise Http404("No access_log found")

        if access_log.api_endpoint:
            if access_log.api_endpoint.callbacks.exists():
                callbacks.run_api_endpoint_callbacks(access_log.api_endpoint)
                messages.add_message(request, messages.INFO,
                                     'Api endpoint {} callbacks were run'.format(access_log.api_endpoint))
            else:
                messages.add_message(request, messages.INFO,
                                     'No callbacks for api endpoint {}'.format(access_log.api_endpoint))

        return redirect(reverse("admin:mock_api_accesslog_change", args=(pk,)))
Пример #2
0
    def run_api_endpoint_callback(self, request, pk):
        access_log = self.get_object(request, pk)
        if not access_log:
            raise Http404("No access_log found")

        if access_log.api_endpoint:
            if access_log.api_endpoint.callbacks.exists():
                callbacks.run_api_endpoint_callbacks(access_log.api_endpoint)
                messages.add_message(request, messages.INFO,
                                     'Api endpoint {} callbacks were run'.format(access_log.api_endpoint))
            else:
                messages.add_message(request, messages.INFO,
                                     'No callbacks for api endpoint {}'.format(access_log.api_endpoint))

        return redirect(reverse("admin:mock_api_accesslog_change", args=(pk,)))
Пример #3
0
    def get(self, request):
        try:
            logger.debug("Processing request %s %s", request.method, request.path_info)

            self.api_endpoint = ApiEndpoint.objects.get(path=request.path_info, method=request.method)
            logger.debug("Found api endpoint %s", self.api_endpoint)

            response = self.response_resolver_class(self.api_endpoint).resolve(request)
            logger.debug("Found response %s", response)

            callbacks.run_api_endpoint_callbacks(self.api_endpoint)

            return Response(status=response.status_code, data=response.get_content())
        except (ApiEndpoint.DoesNotExist, MatchingResponseNotFound):
            logger.error("No api endpoint found for %s %s", request.method, request.path_info)
            return Response(status=status.HTTP_501_NOT_IMPLEMENTED)
Пример #4
0
    def get(self, request):
        try:
            logger.debug("Processing request %s %s", request.method,
                         request.path_info)

            self.api_endpoint = ApiEndpoint.objects.get(path=request.path_info,
                                                        method=request.method)
            logger.debug("Found api endpoint %s", self.api_endpoint)

            response = self.response_resolver_class(
                self.api_endpoint).resolve(request)
            logger.debug("Found response %s", response)

            callbacks.run_api_endpoint_callbacks(self.api_endpoint)

            return Response(status=response.status_code,
                            data=response.get_content())
        except (ApiEndpoint.DoesNotExist, MatchingResponseNotFound):
            logger.error("No api endpoint found for %s %s", request.method,
                         request.path_info)
            return Response(status=status.HTTP_501_NOT_IMPLEMENTED)