Source code for codegrade.models.login_login_link_data
"""The module that defines the ``LoginLoginLinkData`` model.
SPDX-License-Identifier: AGPL-3.0-only OR BSD-3-Clause-Clear
"""
from __future__ import annotations
import typing as t
from dataclasses import dataclass, field
import cg_request_args as rqa
from ..utils import to_dict
[docs]
@dataclass
class LoginLoginLinkData:
"""Input data required for the `Login Link::Login` operation."""
#: Set to true to log in even when an active isolated session exists, which
#: will terminate that session.
confirm_session_termination: bool = False
raw_data: t.Optional[t.Dict[str, t.Any]] = field(init=False, repr=False)
data_parser: t.ClassVar[t.Any] = rqa.Lazy(
lambda: rqa.FixedMapping(
rqa.DefaultArgument(
"confirm_session_termination",
rqa.SimpleValue.bool,
doc="Set to true to log in even when an active isolated session exists, which will terminate that session.",
default=lambda: False,
),
).use_readable_describe(True)
)
def to_dict(self) -> t.Dict[str, t.Any]:
res: t.Dict[str, t.Any] = {
"confirm_session_termination": to_dict(
self.confirm_session_termination
),
}
return res
@classmethod
def from_dict(
cls: t.Type[LoginLoginLinkData], d: t.Dict[str, t.Any]
) -> LoginLoginLinkData:
parsed = cls.data_parser.try_parse(d)
res = cls(
confirm_session_termination=parsed.confirm_session_termination,
)
res.raw_data = d
return res