Fix admin API gaps for users, exchange checks, and parser logs
This commit is contained in:
@@ -78,6 +78,48 @@ class ExchangeConnectionListCreateView(APIView):
|
||||
return api_created_response(output.data)
|
||||
|
||||
|
||||
class ExchangeConnectionTestView(APIView):
|
||||
"""API проверки подключения к внешней БД без сохранения."""
|
||||
|
||||
permission_classes = [IsAdminUser]
|
||||
|
||||
@swagger_auto_schema(
|
||||
tags=[EXCHANGE_TAG],
|
||||
operation_summary="Проверить подключение",
|
||||
operation_description=(
|
||||
"Проверяет подключение и структуру целевой БД без сохранения "
|
||||
"настроек подключения."
|
||||
),
|
||||
request_body=ExchangeConnectionCreateSerializer,
|
||||
responses={
|
||||
200: openapi.Response(
|
||||
description="Проверка успешна",
|
||||
schema=openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
"status": openapi.Schema(type=openapi.TYPE_STRING),
|
||||
"message": openapi.Schema(type=openapi.TYPE_STRING),
|
||||
},
|
||||
),
|
||||
),
|
||||
400: CommonResponses.BAD_REQUEST,
|
||||
**ErrorResponses.ADMIN,
|
||||
},
|
||||
)
|
||||
def post(self, request):
|
||||
serializer = ExchangeConnectionCreateSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
try:
|
||||
result = ExchangeConnectionService.test_connection_payload(
|
||||
**serializer.validated_data
|
||||
)
|
||||
except ExchangeServiceError as exc:
|
||||
raise ValidationError({"connection": str(exc)}) from exc
|
||||
|
||||
return api_response(result, status_code=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class ExchangeCopyDataView(APIView):
|
||||
"""API запуска копирования данных в целевую БД."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user