# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: glitterchain/index/dataset.proto, glitterchain/index/genesis.proto, glitterchain/index/index.proto, glitterchain/index/params.proto, glitterchain/index/query.proto, glitterchain/index/tx.proto
# plugin: python-betterproto
# This file has been @generated

from dataclasses import dataclass
from datetime import datetime
from typing import (
    TYPE_CHECKING,
    Dict,
    List,
    Optional,
)

import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase

from ...cosmos.base.query import v1beta1 as __cosmos_base_query_v1_beta1__


if TYPE_CHECKING:
    import grpclib.server
    from betterproto.grpc.grpclib_client import MetadataLike
    from grpclib.metadata import Deadline


class ServiceStatus(betterproto.Enum):
    Service_Status_Unset = 0
    Service_Status_Start = 1
    Service_Status_Stop = 2
    Service_Status_Delete = 3


@dataclass(eq=False, repr=False)
class Table(betterproto.Message):
    table_name: str = betterproto.string_field(1)
    description: str = betterproto.string_field(2)
    update_time: datetime = betterproto.message_field(3)


@dataclass(eq=False, repr=False)
class Cpdt(betterproto.Message):
    """consumer pledge dataset token"""

    dataset_name: str = betterproto.string_field(1)
    consumer_address: str = betterproto.string_field(2)
    amount: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class Dataset(betterproto.Message):
    dataset_name: str = betterproto.string_field(1)
    work_status: "ServiceStatus" = betterproto.enum_field(2)
    owner_address: str = betterproto.string_field(3)
    expiration_time: datetime = betterproto.message_field(4)
    hosts: str = betterproto.string_field(5)
    manage_addresses: str = betterproto.string_field(6)
    tables: List["Table"] = betterproto.message_field(7)
    sum_cpdt: str = betterproto.string_field(8)
    description: str = betterproto.string_field(9)
    update_time: datetime = betterproto.message_field(10)


@dataclass(eq=False, repr=False)
class DatasetExpiration(betterproto.Message):
    dataset_names: List[str] = betterproto.string_field(1)
    expiration_time: datetime = betterproto.message_field(11)


@dataclass(eq=False, repr=False)
class ColumnMeta(betterproto.Message):
    """ColumnDesc"""

    name: str = betterproto.string_field(1)
    type: str = betterproto.string_field(2)
    comment: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class TableDesc(betterproto.Message):
    """TableDesc"""

    table_name: str = betterproto.string_field(1)
    engine: str = betterproto.string_field(2)
    comment: str = betterproto.string_field(3)
    columns: List["ColumnMeta"] = betterproto.message_field(4)


@dataclass(eq=False, repr=False)
class Website(betterproto.Message):
    """Website"""

    github: str = betterproto.string_field(1)
    discord: str = betterproto.string_field(2)
    telegram: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class App(betterproto.Message):
    """App"""

    img: str = betterproto.string_field(1)
    name: str = betterproto.string_field(2)
    website: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class DatasetDesc(betterproto.Message):
    """DatasetDesc"""

    description: str = betterproto.string_field(1)
    cover_img: str = betterproto.string_field(2)
    cid: str = betterproto.string_field(3)
    website: "Website" = betterproto.message_field(4)
    app: List["App"] = betterproto.message_field(5)
    storage: str = betterproto.string_field(6)
    row_cnt: int = betterproto.int64_field(7)


@dataclass(eq=False, repr=False)
class EditTableRequest(betterproto.Message):
    from_address: str = betterproto.string_field(1)
    dataset_name: str = betterproto.string_field(2)
    table_name: str = betterproto.string_field(3)
    description: str = betterproto.string_field(5)


@dataclass(eq=False, repr=False)
class EditTableResponse(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class CreateDatasetRequest(betterproto.Message):
    from_address: str = betterproto.string_field(1)
    dataset_name: str = betterproto.string_field(2)
    work_status: "ServiceStatus" = betterproto.enum_field(3)
    hosts: str = betterproto.string_field(4)
    manage_addresses: str = betterproto.string_field(5)
    description: str = betterproto.string_field(7)
    duration: int = betterproto.int64_field(8)


@dataclass(eq=False, repr=False)
class CreateDatasetResponse(betterproto.Message):
    expiration_time: datetime = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class EditDatasetRequest(betterproto.Message):
    from_address: str = betterproto.string_field(1)
    dataset_name: str = betterproto.string_field(2)
    work_status: "ServiceStatus" = betterproto.enum_field(3)
    hosts: str = betterproto.string_field(4)
    manage_addresses: str = betterproto.string_field(5)
    description: str = betterproto.string_field(7)


@dataclass(eq=False, repr=False)
class EditDatasetResponse(betterproto.Message):
    pass


@dataclass(eq=False, repr=False)
class RenewalDatasetRequest(betterproto.Message):
    from_address: str = betterproto.string_field(1)
    dataset_name: str = betterproto.string_field(2)
    duration: int = betterproto.int64_field(3)


@dataclass(eq=False, repr=False)
class RenewalDatasetResponse(betterproto.Message):
    expiration_time: datetime = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class Params(betterproto.Message):
    """Params defines the parameters for the module."""

    fee_per_dataset_per_second: str = betterproto.string_field(1)
    grace_period: int = betterproto.int64_field(2)


@dataclass(eq=False, repr=False)
class QueryParamsRequest(betterproto.Message):
    """QueryParamsRequest is request type for the Query/Params RPC method."""

    pass


@dataclass(eq=False, repr=False)
class QueryParamsResponse(betterproto.Message):
    """
    QueryParamsResponse is response type for the Query/Params RPC method.
    """

    params: "Params" = betterproto.message_field(1)
    """params holds all the parameters of this module."""


@dataclass(eq=False, repr=False)
class QueryDatesetRequest(betterproto.Message):
    dataset_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class QueryDatesetResponse(betterproto.Message):
    dateset: "Dataset" = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class QueryDatasetExpirationsRequest(betterproto.Message):
    pagination: "__cosmos_base_query_v1_beta1__.PageRequest" = (
        betterproto.message_field(1)
    )


@dataclass(eq=False, repr=False)
class QueryDatasetExpirationsResponse(betterproto.Message):
    datasets: List["DatasetExpiration"] = betterproto.message_field(1)
    pagination: "__cosmos_base_query_v1_beta1__.PageResponse" = (
        betterproto.message_field(2)
    )


@dataclass(eq=False, repr=False)
class QueryDatesetsRequest(betterproto.Message):
    pagination: "__cosmos_base_query_v1_beta1__.PageRequest" = (
        betterproto.message_field(1)
    )


@dataclass(eq=False, repr=False)
class QueryDatesetsResponse(betterproto.Message):
    datasets: List["Dataset"] = betterproto.message_field(1)
    pagination: "__cosmos_base_query_v1_beta1__.PageResponse" = (
        betterproto.message_field(2)
    )


@dataclass(eq=False, repr=False)
class QueryCpdtRequest(betterproto.Message):
    dataset_name: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class QueryCpdtResponse(betterproto.Message):
    cpd_ts: List["Cpdt"] = betterproto.message_field(1)


@dataclass(eq=False, repr=False)
class QueryCpdTsRequest(betterproto.Message):
    pagination: "__cosmos_base_query_v1_beta1__.PageRequest" = (
        betterproto.message_field(1)
    )


@dataclass(eq=False, repr=False)
class QueryCpdTsResponse(betterproto.Message):
    cpd_ts: List["Cpdt"] = betterproto.message_field(1)
    pagination: "__cosmos_base_query_v1_beta1__.PageResponse" = (
        betterproto.message_field(2)
    )


@dataclass(eq=False, repr=False)
class GenesisState(betterproto.Message):
    """GenesisState defines the index module's genesis state."""

    params: "Params" = betterproto.message_field(1)
    datasets: List["Dataset"] = betterproto.message_field(2)
    cpd_ts: List["Cpdt"] = betterproto.message_field(3)


class MsgStub(betterproto.ServiceStub):
    async def create_dataset(
        self,
        create_dataset_request: "CreateDatasetRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "CreateDatasetResponse":
        return await self._unary_unary(
            "/glitterchain.index.Msg/CreateDataset",
            create_dataset_request,
            CreateDatasetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def edit_dataset(
        self,
        edit_dataset_request: "EditDatasetRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "EditDatasetResponse":
        return await self._unary_unary(
            "/glitterchain.index.Msg/EditDataset",
            edit_dataset_request,
            EditDatasetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def renewal_dataset(
        self,
        renewal_dataset_request: "RenewalDatasetRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "RenewalDatasetResponse":
        return await self._unary_unary(
            "/glitterchain.index.Msg/RenewalDataset",
            renewal_dataset_request,
            RenewalDatasetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def edit_table(
        self,
        edit_table_request: "EditTableRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "EditTableResponse":
        return await self._unary_unary(
            "/glitterchain.index.Msg/EditTable",
            edit_table_request,
            EditTableResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class QueryStub(betterproto.ServiceStub):
    async def params(
        self,
        query_params_request: "QueryParamsRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryParamsResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/Params",
            query_params_request,
            QueryParamsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def query_dateset(
        self,
        query_dateset_request: "QueryDatesetRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryDatesetResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/QueryDateset",
            query_dateset_request,
            QueryDatesetResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def query_datesets(
        self,
        query_datesets_request: "QueryDatesetsRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryDatesetsResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/QueryDatesets",
            query_datesets_request,
            QueryDatesetsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def query_dataset_expirations(
        self,
        query_dataset_expirations_request: "QueryDatasetExpirationsRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryDatasetExpirationsResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/QueryDatasetExpirations",
            query_dataset_expirations_request,
            QueryDatasetExpirationsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def query_cpdt(
        self,
        query_cpdt_request: "QueryCpdtRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryCpdtResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/QueryCPDT",
            query_cpdt_request,
            QueryCpdtResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def query_cpd_ts(
        self,
        query_cpd_ts_request: "QueryCpdTsRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "QueryCpdTsResponse":
        return await self._unary_unary(
            "/glitterchain.index.Query/QueryCPDTs",
            query_cpd_ts_request,
            QueryCpdTsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class MsgBase(ServiceBase):
    async def create_dataset(
        self, create_dataset_request: "CreateDatasetRequest"
    ) -> "CreateDatasetResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def edit_dataset(
        self, edit_dataset_request: "EditDatasetRequest"
    ) -> "EditDatasetResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def renewal_dataset(
        self, renewal_dataset_request: "RenewalDatasetRequest"
    ) -> "RenewalDatasetResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def edit_table(
        self, edit_table_request: "EditTableRequest"
    ) -> "EditTableResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_create_dataset(
        self,
        stream: "grpclib.server.Stream[CreateDatasetRequest, CreateDatasetResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.create_dataset(request)
        await stream.send_message(response)

    async def __rpc_edit_dataset(
        self, stream: "grpclib.server.Stream[EditDatasetRequest, EditDatasetResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.edit_dataset(request)
        await stream.send_message(response)

    async def __rpc_renewal_dataset(
        self,
        stream: "grpclib.server.Stream[RenewalDatasetRequest, RenewalDatasetResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.renewal_dataset(request)
        await stream.send_message(response)

    async def __rpc_edit_table(
        self, stream: "grpclib.server.Stream[EditTableRequest, EditTableResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.edit_table(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/glitterchain.index.Msg/CreateDataset": grpclib.const.Handler(
                self.__rpc_create_dataset,
                grpclib.const.Cardinality.UNARY_UNARY,
                CreateDatasetRequest,
                CreateDatasetResponse,
            ),
            "/glitterchain.index.Msg/EditDataset": grpclib.const.Handler(
                self.__rpc_edit_dataset,
                grpclib.const.Cardinality.UNARY_UNARY,
                EditDatasetRequest,
                EditDatasetResponse,
            ),
            "/glitterchain.index.Msg/RenewalDataset": grpclib.const.Handler(
                self.__rpc_renewal_dataset,
                grpclib.const.Cardinality.UNARY_UNARY,
                RenewalDatasetRequest,
                RenewalDatasetResponse,
            ),
            "/glitterchain.index.Msg/EditTable": grpclib.const.Handler(
                self.__rpc_edit_table,
                grpclib.const.Cardinality.UNARY_UNARY,
                EditTableRequest,
                EditTableResponse,
            ),
        }


class QueryBase(ServiceBase):
    async def params(
        self, query_params_request: "QueryParamsRequest"
    ) -> "QueryParamsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def query_dateset(
        self, query_dateset_request: "QueryDatesetRequest"
    ) -> "QueryDatesetResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def query_datesets(
        self, query_datesets_request: "QueryDatesetsRequest"
    ) -> "QueryDatesetsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def query_dataset_expirations(
        self, query_dataset_expirations_request: "QueryDatasetExpirationsRequest"
    ) -> "QueryDatasetExpirationsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def query_cpdt(
        self, query_cpdt_request: "QueryCpdtRequest"
    ) -> "QueryCpdtResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def query_cpd_ts(
        self, query_cpd_ts_request: "QueryCpdTsRequest"
    ) -> "QueryCpdTsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_params(
        self, stream: "grpclib.server.Stream[QueryParamsRequest, QueryParamsResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.params(request)
        await stream.send_message(response)

    async def __rpc_query_dateset(
        self, stream: "grpclib.server.Stream[QueryDatesetRequest, QueryDatesetResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.query_dateset(request)
        await stream.send_message(response)

    async def __rpc_query_datesets(
        self,
        stream: "grpclib.server.Stream[QueryDatesetsRequest, QueryDatesetsResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.query_datesets(request)
        await stream.send_message(response)

    async def __rpc_query_dataset_expirations(
        self,
        stream: "grpclib.server.Stream[QueryDatasetExpirationsRequest, QueryDatasetExpirationsResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.query_dataset_expirations(request)
        await stream.send_message(response)

    async def __rpc_query_cpdt(
        self, stream: "grpclib.server.Stream[QueryCpdtRequest, QueryCpdtResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.query_cpdt(request)
        await stream.send_message(response)

    async def __rpc_query_cpd_ts(
        self, stream: "grpclib.server.Stream[QueryCpdTsRequest, QueryCpdTsResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.query_cpd_ts(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/glitterchain.index.Query/Params": grpclib.const.Handler(
                self.__rpc_params,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryParamsRequest,
                QueryParamsResponse,
            ),
            "/glitterchain.index.Query/QueryDateset": grpclib.const.Handler(
                self.__rpc_query_dateset,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryDatesetRequest,
                QueryDatesetResponse,
            ),
            "/glitterchain.index.Query/QueryDatesets": grpclib.const.Handler(
                self.__rpc_query_datesets,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryDatesetsRequest,
                QueryDatesetsResponse,
            ),
            "/glitterchain.index.Query/QueryDatasetExpirations": grpclib.const.Handler(
                self.__rpc_query_dataset_expirations,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryDatasetExpirationsRequest,
                QueryDatasetExpirationsResponse,
            ),
            "/glitterchain.index.Query/QueryCPDT": grpclib.const.Handler(
                self.__rpc_query_cpdt,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryCpdtRequest,
                QueryCpdtResponse,
            ),
            "/glitterchain.index.Query/QueryCPDTs": grpclib.const.Handler(
                self.__rpc_query_cpd_ts,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryCpdTsRequest,
                QueryCpdTsResponse,
            ),
        }
