from graphene_django.views import GraphQLView
from .graphql_middleware import M2MNoAuthMiddleware, PublicNoAuthMiddleware, BillingJWTMiddleware


class PublicGraphQLView(GraphQLView):
    """GraphQL view for public operations (no authentication)."""

    def __init__(self, *args, **kwargs):
        kwargs['middleware'] = [PublicNoAuthMiddleware()]
        super().__init__(*args, **kwargs)


class M2MGraphQLView(GraphQLView):
    """GraphQL view for M2M (machine-to-machine) operations.
    No authentication required - used by internal services (Temporal, etc.)
    """

    def __init__(self, *args, **kwargs):
        kwargs['middleware'] = [M2MNoAuthMiddleware()]
        super().__init__(*args, **kwargs)


class TeamGraphQLView(GraphQLView):
    """GraphQL view for team-level operations.
    Requires Access token with teams:member scope.
    """

    def __init__(self, *args, **kwargs):
        kwargs['middleware'] = [BillingJWTMiddleware()]
        super().__init__(*args, **kwargs)
