Source code for codegrade.models.assignment_terminal_settings_enabled_as_json

"""The module that defines the ``AssignmentTerminalSettingsEnabledAsJSON`` 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(kw_only=True) class AssignmentTerminalSettingsEnabledAsJSON: """The terminal is enabled for the assignment.""" #: The tag for this data. tag: t.Literal["enabled"] #: Whether the terminal's VM gets outbound network access. allow_internet: bool #: Whether files placed by AutoTest Upload Files steps stay readable from #: the terminal session. allow_uploaded_files: bool 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.RequiredArgument( "tag", rqa.StringEnum("enabled"), doc="The tag for this data.", ), rqa.RequiredArgument( "allow_internet", rqa.SimpleValue.bool, doc="Whether the terminal's VM gets outbound network access.", ), rqa.RequiredArgument( "allow_uploaded_files", rqa.SimpleValue.bool, doc="Whether files placed by AutoTest Upload Files steps stay readable from the terminal session.", ), ) ) def to_dict(self) -> t.Dict[str, t.Any]: res: t.Dict[str, t.Any] = { "tag": to_dict(self.tag), "allow_internet": to_dict(self.allow_internet), "allow_uploaded_files": to_dict(self.allow_uploaded_files), } return res @classmethod def from_dict( cls: t.Type[AssignmentTerminalSettingsEnabledAsJSON], d: t.Dict[str, t.Any], ) -> AssignmentTerminalSettingsEnabledAsJSON: parsed = cls.data_parser.try_parse(d) res = cls( tag=parsed.tag, allow_internet=parsed.allow_internet, allow_uploaded_files=parsed.allow_uploaded_files, ) res.raw_data = d return res