# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
from typing import Any, Optional

from . import autonat_pb2 as autonat__pb2

GRPC_GENERATED_VERSION = "1.71.0"
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower

    _version_not_supported = first_version_is_lower(
        GRPC_VERSION, GRPC_GENERATED_VERSION
    )
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f"The grpc package installed is at version {GRPC_VERSION},"
        + f" but the generated code in autonat_pb2_grpc.py depends on"
        + f" grpcio>={GRPC_GENERATED_VERSION}."
        + f" Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}"
        + f" or downgrade your generated code using grpcio-tools<={GRPC_VERSION}."
    )


class AutoNATStub:
    """AutoNAT service definition"""

    def __init__(self, channel: grpc.Channel) -> None:
        """
        Initialize the AutoNAT stub.

        Args:
        ----
        channel (grpc.Channel): The gRPC channel instance that facilitates
            communication for the AutoNAT service, providing the underlying
            transport mechanism for RPC calls.

        """
        self.Dial = channel.unary_unary(
            "/autonat.pb.AutoNAT/Dial",
            request_serializer=autonat__pb2.Message.SerializeToString,
            response_deserializer=autonat__pb2.Message.FromString,
            _registered_method=True,
        )


class AutoNATServicer:
    """AutoNAT service definition"""

    def Dial(self, request: Any, context: Any) -> Any:
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details("Method not implemented!")
        raise NotImplementedError("Method not implemented!")


def add_AutoNATServicer_to_server(servicer: AutoNATServicer, server: Any) -> None:
    rpc_method_handlers = {
        "Dial": grpc.unary_unary_rpc_method_handler(
            servicer.Dial,
            request_deserializer=autonat__pb2.Message.FromString,
            response_serializer=autonat__pb2.Message.SerializeToString,
        ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
        "autonat.pb.AutoNAT", rpc_method_handlers
    )
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers("autonat.pb.AutoNAT", rpc_method_handlers)


# This class is part of an EXPERIMENTAL API.
class AutoNAT:
    """AutoNAT service definition"""

    @staticmethod
    def Dial(
        request: Any,
        target: str,
        options: tuple[Any, ...] = (),
        channel_credentials: Any | None = None,
        call_credentials: Any | None = None,
        insecure: bool = False,
        compression: Any | None = None,
        wait_for_ready: bool | None = None,
        timeout: float | None = None,
        metadata: list[tuple[str, str]] | None = None,
    ) -> Any:
        channel = grpc.secure_channel(target, channel_credentials) if channel_credentials else grpc.insecure_channel(target)
        return channel.unary_unary(
            "/autonat.pb.AutoNAT/Dial",
            request_serializer=autonat__pb2.Message.SerializeToString,
            response_deserializer=autonat__pb2.Message.FromString,
            _registered_method=True,
        )(
            request,
            timeout=timeout,
            metadata=metadata,
            wait_for_ready=wait_for_ready,
        )
