Skip to content

Models

Model

Bases: BaseModel

The base model for all models

This class should not be instantiated directly

Source code in ctfdpy\models\model.py
 8
 9
10
11
12
13
14
15
16
17
class Model(BaseModel):
    """
    The base model for all models

    This class should not be instantiated directly
    """

    model_config = ConfigDict(
        extra="allow", use_enum_values=True, validate_assignment=True
    )

ResponseModel

Bases: Model

The base model for all response models

This class should not be instantiated directly

Source code in ctfdpy\models\model.py
20
21
22
23
24
25
class ResponseModel(Model, frozen=True):
    """
    The base model for all response models

    This class should not be instantiated directly
    """

CreatePayloadModel

Bases: Model

The base model for all create payload models

This class should not be instantiated directly

Source code in ctfdpy\models\model.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class CreatePayloadModel(Model, extra="forbid"):
    """
    The base model for all create payload models

    This class should not be instantiated directly
    """

    def dump_json(self, **kwargs) -> dict[str, Any]:
        """
        Dumps the model in JSON format

        Parameters
        ----------
        kwargs : dict[str, Any]
            Additional keyword arguments to pass to the model dump

        Returns
        -------
        dict[str, Any]
            The payload
        """
        return self.model_dump(mode="json", exclude_unset=True, **kwargs)

dump_json

dump_json(**kwargs) -> dict[str, Any]

Dumps the model in JSON format

Parameters:

Name Type Description Default
kwargs dict[str, Any]

Additional keyword arguments to pass to the model dump

{}

Returns:

Type Description
dict[str, Any]

The payload

Source code in ctfdpy\models\model.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def dump_json(self, **kwargs) -> dict[str, Any]:
    """
    Dumps the model in JSON format

    Parameters
    ----------
    kwargs : dict[str, Any]
        Additional keyword arguments to pass to the model dump

    Returns
    -------
    dict[str, Any]
        The payload
    """
    return self.model_dump(mode="json", exclude_unset=True, **kwargs)

UpdatePayloadModel

Bases: Model

The base model for all update payload models

This class should not be instantiated directly

Source code in ctfdpy\models\model.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class UpdatePayloadModel(Model, extra="forbid"):
    """
    The base model for all update payload models

    This class should not be instantiated directly
    """

    def dump_json(self, **kwargs) -> dict[str, Any]:
        """
        Dumps the model in JSON format

        Parameters
        ----------
        kwargs : dict[str, Any]
            Additional keyword arguments to pass to the model dump

        Returns
        -------
        dict[str, Any]
            The payload
        """
        return self.model_dump(mode="json", exclude_unset=True, **kwargs)

dump_json

dump_json(**kwargs) -> dict[str, Any]

Dumps the model in JSON format

Parameters:

Name Type Description Default
kwargs dict[str, Any]

Additional keyword arguments to pass to the model dump

{}

Returns:

Type Description
dict[str, Any]

The payload

Source code in ctfdpy\models\model.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def dump_json(self, **kwargs) -> dict[str, Any]:
    """
    Dumps the model in JSON format

    Parameters
    ----------
    kwargs : dict[str, Any]
        Additional keyword arguments to pass to the model dump

    Returns
    -------
    dict[str, Any]
        The payload
    """
    return self.model_dump(mode="json", exclude_unset=True, **kwargs)