(self, request)
| 831 | responses={201: PluginRepoSerializer, 400: inline_serializer(name="RepoAddError", fields={"error": serializers.CharField()})}, |
| 832 | ) |
| 833 | def post(self, request): |
| 834 | serializer = PluginRepoSerializer(data=request.data) |
| 835 | serializer.is_valid(raise_exception=True) |
| 836 | repo = serializer.save(name="") |
| 837 | # Fetch manifest and validate + save |
| 838 | try: |
| 839 | key_text = repo.public_key if not repo.is_official else None |
| 840 | data, verified = _fetch_manifest(repo.url, public_key_text=key_text) |
| 841 | except Exception as e: |
| 842 | logger.warning("Initial manifest fetch failed for %s: %s", repo.url, e) |
| 843 | repo.delete() |
| 844 | return Response( |
| 845 | {"error": "Failed to fetch manifest. Check the URL and try again."}, |
| 846 | status=status.HTTP_400_BAD_REQUEST, |
| 847 | ) |
| 848 | err = _save_fetched_manifest_to_repo(repo, data, verified) |
| 849 | if err: |
| 850 | repo.delete() |
| 851 | return Response({"error": err}, status=status.HTTP_400_BAD_REQUEST) |
| 852 | return Response( |
| 853 | PluginRepoSerializer(repo).data, status=status.HTTP_201_CREATED |
| 854 | ) |
| 855 | |
| 856 | |
| 857 | class PluginRepoPreviewAPIView(PluginAuthMixin, APIView): |
nothing calls this directly
no test coverage detected