"""``clients.*`` — ISPConfig client/customer lookups. ISPConfig's client model has two IDs you'll trip over: * ``client_id`` — primary key of the ``client`` table. * ``sys_groupid`` — the "owner group" used by sites/dns/mail records. ``sys_groupid=1`` is the admin group. For regular clients, ``sys_groupid`` is *not* equal to ``client_id``; you must look it up with :meth:`ClientsModule.get_groupid`. """ from __future__ import annotations from typing import TYPE_CHECKING, cast from .types import Client if TYPE_CHECKING: from .client import ISPConfigClient class ClientsModule: def __init__(self, client: ISPConfigClient) -> None: self._c = client def get(self, primary_id: int) -> Client: return cast(Client, self._c._call("client_get", ("primary_id", int(primary_id)))) def get_groupid(self, client_id: int) -> int: """Look up ``sys_groupid`` for a given ``client_id``.""" result = self._c._call("client_get_groupid", ("client_id", int(client_id))) return int(result) if result else 0 def get_id(self, sys_userid: int) -> int: """Reverse of :meth:`get_groupid` — client_id from a sys user id.""" result = self._c._call("client_get_id", ("sys_userid", int(sys_userid))) return int(result) if result else 0 def get_by_username(self, username: str) -> Client: return cast(Client, self._c._call("client_get_by_username", ("username", username))) def get_by_groupid(self, groupid: int) -> Client: return cast(Client, self._c._call("client_get_by_groupid", ("groupid", int(groupid)))) def get_all(self) -> list[int]: """Return every ``client_id`` the API user can see.""" result = self._c._call("client_get_all") return [int(x) for x in (result or [])]