from rest_framework import viewsets
from api import models, serializers
import logging

class RolOperadorViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.RolOperadorSerializer
    
    def get_queryset(self):
        id_rol = self.request.query_params.get('id_rol')  # Obtener el valor del parámetro id_rol desde la solicitud
        
        if id_rol is not None:
            return models.RolOperador.objects.filter(id_rol=id_rol)
        
        return models.RolOperador.objects.all()