from typing import TypedDict, Literal, NotRequired, Any, Coroutine, Union

# Payload TypedDict for IDE autocomplete
class DomainControllerPayload(TypedDict, total=False):
    """
    Type hints for user/domain_controller payload fields.
    
    Use this for IDE autocomplete when building payload dicts:
        payload: DomainControllerPayload = {
            "field": "value",  # <- autocomplete shows all fields
        }
    """
    name: NotRequired[str]  # Domain controller entry name.
    ad_mode: NotRequired[Literal["none", "ds", "lds"]]  # Set Active Directory mode.
    hostname: str  # Hostname of the server to connect to.
    username: str  # User name to sign in with. Must have proper permissions for 
    password: str  # Password for specified username.
    ip_address: NotRequired[str]  # Domain controller IPv4 address.
    ip6: NotRequired[str]  # Domain controller IPv6 address.
    port: NotRequired[int]  # Port to be used for communication with the domain controller
    source_ip_address: NotRequired[str]  # FortiGate IPv4 address to be used for communication with the
    source_ip6: NotRequired[str]  # FortiGate IPv6 address to be used for communication with the
    source_port: NotRequired[int]  # Source port to be used for communication with the domain con
    interface_select_method: NotRequired[Literal["auto", "sdwan", "specify"]]  # Specify how to select outgoing interface to reach server.
    interface: str  # Specify outgoing interface to reach server.
    extra_server: NotRequired[list[dict[str, Any]]]  # Extra servers.
    domain_name: NotRequired[str]  # Domain DNS name.
    replication_port: NotRequired[int]  # Port to be used for communication with the domain controller
    ldap_server: NotRequired[list[dict[str, Any]]]  # LDAP server name(s).
    change_detection: NotRequired[Literal["enable", "disable"]]  # Enable/disable detection of a configuration change in the Ac
    change_detection_period: NotRequired[int]  # Minutes to detect a configuration change in the Active Direc
    dns_srv_lookup: NotRequired[Literal["enable", "disable"]]  # Enable/disable DNS service lookup.
    adlds_dn: str  # AD LDS distinguished name.
    adlds_ip_address: NotRequired[str]  # AD LDS IPv4 address.
    adlds_ip6: NotRequired[str]  # AD LDS IPv6 address.
    adlds_port: NotRequired[int]  # Port number of AD LDS service (default = 389).


class DomainController:
    """
    Configure domain controller entries.
    
    Path: user/domain_controller
    Category: cmdb
    Primary Key: name
    """
    
    def get(
        self,
        name: str | None = ...,
        filter: str | None = ...,
        range: list[int] | None = ...,
        sort: str | None = ...,
        format: str | None = ...,
        action: str | None = ...,
        vdom: str | bool | None = ...,
        raw_json: bool = ...,
        **kwargs: Any,
    ) -> Union[dict[str, Any], Coroutine[Any, Any, dict[str, Any]]]: ...
    
    def post(
        self,
        payload_dict: DomainControllerPayload | None = ...,
        name: str | None = ...,
        ad_mode: Literal["none", "ds", "lds"] | None = ...,
        hostname: str | None = ...,
        username: str | None = ...,
        password: str | None = ...,
        ip_address: str | None = ...,
        ip6: str | None = ...,
        port: int | None = ...,
        source_ip_address: str | None = ...,
        source_ip6: str | None = ...,
        source_port: int | None = ...,
        interface_select_method: Literal["auto", "sdwan", "specify"] | None = ...,
        interface: str | None = ...,
        extra_server: list[dict[str, Any]] | None = ...,
        domain_name: str | None = ...,
        replication_port: int | None = ...,
        ldap_server: list[dict[str, Any]] | None = ...,
        change_detection: Literal["enable", "disable"] | None = ...,
        change_detection_period: int | None = ...,
        dns_srv_lookup: Literal["enable", "disable"] | None = ...,
        vdom: str | bool | None = ...,
        raw_json: bool = ...,
        **kwargs: Any,
    ) -> Union[dict[str, Any], Coroutine[Any, Any, dict[str, Any]]]: ...
    
    def put(
        self,
        payload_dict: DomainControllerPayload | None = ...,
        name: str | None = ...,
        ad_mode: Literal["none", "ds", "lds"] | None = ...,
        hostname: str | None = ...,
        username: str | None = ...,
        password: str | None = ...,
        ip_address: str | None = ...,
        ip6: str | None = ...,
        port: int | None = ...,
        source_ip_address: str | None = ...,
        source_ip6: str | None = ...,
        source_port: int | None = ...,
        interface_select_method: Literal["auto", "sdwan", "specify"] | None = ...,
        interface: str | None = ...,
        extra_server: list[dict[str, Any]] | None = ...,
        domain_name: str | None = ...,
        replication_port: int | None = ...,
        ldap_server: list[dict[str, Any]] | None = ...,
        change_detection: Literal["enable", "disable"] | None = ...,
        change_detection_period: int | None = ...,
        dns_srv_lookup: Literal["enable", "disable"] | None = ...,
        vdom: str | bool | None = ...,
        raw_json: bool = ...,
        **kwargs: Any,
    ) -> Union[dict[str, Any], Coroutine[Any, Any, dict[str, Any]]]: ...
    
    def delete(
        self,
        name: str | None = ...,
        vdom: str | bool | None = ...,
        raw_json: bool = ...,
        **kwargs: Any,
    ) -> Union[dict[str, Any], Coroutine[Any, Any, dict[str, Any]]]: ...
    
    def exists(
        self,
        name: str,
        vdom: str | bool | None = ...,
    ) -> Union[bool, Coroutine[Any, Any, bool]]: ...
    
    def set(
        self,
        payload_dict: DomainControllerPayload | None = ...,
        vdom: str | bool | None = ...,
        **kwargs: Any,
    ) -> Union[dict[str, Any], Coroutine[Any, Any, dict[str, Any]]]: ...
    
    # Helper methods
    @staticmethod
    def help(field_name: str | None = ...) -> str: ...
    
    @staticmethod
    def fields(detailed: bool = ...) -> Union[list[str], list[dict[str, Any]]]: ...
    
    @staticmethod
    def field_info(field_name: str) -> dict[str, Any]: ...
    
    @staticmethod
    def validate_field(name: str, value: Any) -> bool: ...
    
    @staticmethod
    def required_fields() -> list[str]: ...
    
    @staticmethod
    def defaults() -> dict[str, Any]: ...
    
    @staticmethod
    def schema() -> dict[str, Any]: ...


__all__ = [
    "DomainController",
    "DomainControllerPayload",
]