"""Also called ChangeLogonStatus in HQ code and ChangePasswordStatus in AuditActions"""
from __future__ import annotations
import base64
from dataclasses import dataclass
from lxml import objectify # type: ignore
from q2_sdk.tools.utils import to_bool
from .base import BaseAuthRequest, BaseAuthResponse
[docs]
@dataclass
class Request(BaseAuthRequest):
"""
Shape that comes in from HQ when logon status changes from locked/unlocked. To invoke in the sandboxes:
Run ``q2 db unlock_user`` from the CLI.
.. code-block:: xml
<HQ request="ChangeStatus" messageID="{0}">
<LoginId>2</LoginId>
<Locked>True</Locked>
<UserPrimaryCIF>MDcyMTIwMTA=</UserPrimaryCIF>
<CustomerPrimaryCIF>MDcyMTIwMTA=</CustomerPrimaryCIF>
<isLogon>True</isLogon>
<IsPrelogonSession>False</IsPrelogonSession>
<SessionId>shb3cnukdl32c54nodvyxcsj</SessionId>
</HQ>
"""
raw: objectify.Element
login_id: int
locked: bool
user_primary_cif: str
customer_primary_cif: str
is_logon: bool
is_prelogon_session: bool
session_id: str
@staticmethod
def from_xml(xml: objectify.Element) -> Request:
login_id = int(xml.LoginId.text)
locked = to_bool(xml.Locked.text)
user_primary_cif = base64.b64decode(xml.UserPrimaryCIF.text).decode()
customer_primary_cif = base64.b64decode(xml.CustomerPrimaryCIF.text).decode()
is_logon = to_bool(xml.isLogon.text)
is_prelogon_session = to_bool(xml.IsPrelogonSession.text)
session_id = xml.SessionId.text
return Request(
xml,
login_id,
locked,
user_primary_cif,
customer_primary_cif,
is_logon,
is_prelogon_session,
session_id,
)
[docs]
@dataclass
class Response(BaseAuthResponse): ...