Skip to content

user_group

UserGroupCreate

Bases: BaseModel

Schema for UserGroup creation

Attributes:

Name Type Description
name str

Group name

Source code in fractal_server/app/schemas/user_group.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class UserGroupCreate(BaseModel):
    """
    Schema for `UserGroup` creation

    Attributes:
        name: Group name
    """

    model_config = ConfigDict(extra="forbid")

    name: str
    viewer_paths: list[str] = Field(default_factory=list)

    @field_validator("viewer_paths")
    @classmethod
    def viewer_paths_validator(cls, value):
        for i, path in enumerate(value):
            value[i] = val_absolute_path(f"viewer_paths[{i}]")(cls, path)
        value = val_unique_list("viewer_paths")(cls, value)
        return value

UserGroupRead

Bases: BaseModel

Schema for UserGroup read

NOTE: user_ids does not correspond to a column of the UserGroup table, but it is rather computed dynamically in relevant endpoints.

Attributes:

Name Type Description
id int

Group ID

name str

Group name

timestamp_created AwareDatetime

Creation timestamp

user_ids Optional[list[int]]

IDs of users of this group

Source code in fractal_server/app/schemas/user_group.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class UserGroupRead(BaseModel):
    """
    Schema for `UserGroup` read

    NOTE: `user_ids` does not correspond to a column of the `UserGroup` table,
    but it is rather computed dynamically in relevant endpoints.

    Attributes:
        id: Group ID
        name: Group name
        timestamp_created: Creation timestamp
        user_ids: IDs of users of this group
    """

    id: int
    name: str
    timestamp_created: AwareDatetime
    user_ids: Optional[list[int]] = None
    viewer_paths: list[str]

    @field_serializer("timestamp_created")
    def serialize_datetime(v: datetime) -> str:
        return v.isoformat()

UserGroupUpdate

Bases: BaseModel

Schema for UserGroup update

Source code in fractal_server/app/schemas/user_group.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class UserGroupUpdate(BaseModel):
    """
    Schema for `UserGroup` update
    """

    model_config = ConfigDict(extra="forbid")

    viewer_paths: Optional[list[str]] = None

    @field_validator("viewer_paths")
    @classmethod
    def viewer_paths_validator(cls, value):
        if value is None:
            raise ValueError("Cannot set `viewer_paths=None`.")
        for i, path in enumerate(value):
            value[i] = val_absolute_path(f"viewer_paths[{i}]")(cls, path)
        value = val_unique_list("viewer_paths")(cls, value)
        return value