from rest_framework import viewsets, status
from rest_framework.decorators import action
from rest_framework.response import Response
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
from Models.RolUsuario import RolUsuario
from .serializers import RolUsuarioSerializer

class RolUsuarioViewSet(viewsets.ViewSet):
    @swagger_auto_schema(
        operation_description="Lista todos los roles de usuario.",
        responses={200: RolUsuarioSerializer(many=True)}
    )
    @action(detail=False, methods=['get'], url_path='roles')
    def list_roles(self, request):
        roles = RolUsuario.objects.all()
        serializer = RolUsuarioSerializer(roles, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)