Exemplo n.º 1
0
    def post(
        self,
        request,
        *args,
        **kwargs,
    ):
        try:
            r = ConsumerService.create()
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_201_CREATED,
            data=r,
        )
Exemplo n.º 2
0
    def delete(
        self,
        request,
        name,
        *args,
        **kwargs,
    ):
        try:
            ConsumerService.revoke(name)
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_204_NO_CONTENT,
        )
Exemplo n.º 3
0
    def get(
        self,
        request,
        *args,
        **kwargs,
    ):
        try:
            r = ConsumerService.get_all(request, )
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_200_OK,
            data=r,
        )
Exemplo n.º 4
0
    def patch(
        self,
        request,
        name,
        *args,
        **kwargs,
    ):
        try:
            r = ConsumerService.update(name)
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_200_OK,
            data=r,
        )
Exemplo n.º 5
0
    def post(
            self,
            request,
            *args,
            **kwargs,
    ):
        try:
            response_data = FileService.upload_file(
                request,
            )
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_201_CREATED,
            data=response_data,
        )
Exemplo n.º 6
0
    def delete(
            self,
            request,
            file_id,
            *args,
            **kwargs,
    ):
        try:
            FileService.delete_file(
                request,
                file_id,
            )
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return response(
            request,
            status=status.HTTP_204_NO_CONTENT,
        )
Exemplo n.º 7
0
    def get(
            self,
            request,
            file_id,
            *args,
            **kwargs,
    ):
        try:
            response_data = FileService.download_file(
                request,
                file_id,
            )
        except exceptions.APIException as e:
            return response(request, error=e.detail, status=e.status_code)

        return serve(
            request,
            response_data[0],
            response_data[1],
        )