imaging_api.utils.xnat_token ============================ .. py:module:: imaging_api.utils.xnat_token Classes ------- .. autoapisummary:: imaging_api.utils.xnat_token.XnatTokenFactory Module Contents --------------- .. py:class:: XnatTokenFactory(url: str, username: str, password: str, expiry_hours: int = 24) Factory class for retrieving and caching XNAT authentication tokens. .. py:attribute:: url .. py:attribute:: username .. py:attribute:: password .. py:attribute:: expiry_hours :value: 24 .. py:attribute:: xnat_cookie :type: dict[str, Any] .. py:method:: get_xnat_cookie() -> str Retrieves a new XNAT authentication token if expired or not set. Caches the token for reuse. :returns: A valid XNAT session token. :rtype: str :raises HTTPException: If there is an error during the authentication process or if the token cannot be retrieved. .. py:method:: is_token_valid(token: str) -> bool Checks if a given XNAT session token is still valid. :param token: The XNAT session token to validate. :type token: str :returns: True if the token is valid, False otherwise. :rtype: bool