Source code for q2_sdk.hq.models.external_auth.change_login

from __future__ import annotations
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 login is changed. Two ways to invoke in the sandboxes: Ensure Customer/CanChangeLoginName UserPropertyData is set to True, then it will be available in settings -> Security Preference -> Change Login ID. Run ``q2 db change_user_logon_name`` from the CLI. .. code-block:: xml <HQ request="ChangeLogin" messageID="{0}"> <UserId>2</UserId> <LoginId>3</LoginId> <Login>LoginName</Login> <NewLogin>NewLoginName</NewLogin> <CSRLogin>CSRLoginName</CSRLogin> <isLogon>True</isLogon> </HQ> """ raw: objectify.Element user_id: int login_id: int current_login_name: str new_login_name: str is_logon: bool @staticmethod def from_xml(xml: objectify.Element) -> Request: user_id = int(xml.UserId.text) login_id = int(xml.LoginId.text) current_login_name = xml.Login.text new_login_name = xml.NewLogin.text is_logon = to_bool(xml.isLogon.text) return Request( xml, user_id, login_id, current_login_name, new_login_name, is_logon, )
[docs] @dataclass class Response(BaseAuthResponse): """ .. code-block:: xml <Q2Bridge request="ChangeLogin" messageID="messageID"> <Status>"Success"/"Error"</Status> <HQErrorReturnCode>{0}</HQErrorReturnCode> <StatusDescription>{0}</StatusDescription> <EndUserMessage>{0}</EndUserMessage> </Q2Bridge> """
[docs] @classmethod def get_failure(cls, exception_message: str): """Same as basic get_failure but with a customizable exception_message""" resp = cls(cls._get_standard_auth_failure_fields()) resp.add_response_field("exception_message", exception_message) return resp