# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: api.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import List, Optional

import betterproto
import grpclib

from . import pql


@dataclass
class ParseRequest(betterproto.Message):
    """The request message containing the statement and target sql dialect"""

    statement: str = betterproto.string_field(3)
    context: pql.ParseContext = betterproto.message_field(6)


@dataclass
class ParseResponse(betterproto.Message):
    """
    The response message containing the clause type and properties and target
    sql
    """

    parse_error: "ParseError" = betterproto.message_field(1)
    parsed_statements: List[pql.ParseStatement] = betterproto.message_field(2)


@dataclass
class ParseError(betterproto.Message):
    message: str = betterproto.string_field(1)
    position: "ParserPos" = betterproto.message_field(2)
    expected_tokens: List[str] = betterproto.string_field(3)


@dataclass
class ParserPos(betterproto.Message):
    line_number: int = betterproto.int32_field(1)
    column_number: int = betterproto.int32_field(2)
    end_line_number: int = betterproto.int32_field(3)
    end_column_number: int = betterproto.int32_field(4)


class ParserStub(betterproto.ServiceStub):
    async def parse(
        self, *, statement: str = "", context: Optional[pql.ParseContext] = None
    ) -> ParseResponse:
        request = ParseRequest()
        request.statement = statement
        if context is not None:
            request.context = context

        return await self._unary_unary(
            "/api.Parser/Parse",
            request,
            ParseResponse,
        )
