Skip to content

schemas

UserCreate

Bases: BaseUserCreate

Schema for User creation.

Attributes:

Name Type Description
username Optional[str]
Source code in fractal_server/app/schemas/user.py
86
87
88
89
90
91
92
93
94
95
96
97
98
class UserCreate(schemas.BaseUserCreate):
    """
    Schema for `User` creation.

    Attributes:
        username:
    """

    username: Optional[str]

    # Validators

    _username = validator("username", allow_reuse=True)(valstr("username"))

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class UserGroupCreate(BaseModel, extra=Extra.forbid):
    """
    Schema for `UserGroup` creation

    Attributes:
        name: Group name
    """

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

    @validator("viewer_paths")
    def viewer_paths_validator(cls, value):
        for i, path in enumerate(value):
            value[i] = val_absolute_path(f"viewer_paths[{i}]")(path)
        value = val_unique_list("viewer_paths")(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 datetime

Creation timestamp

user_ids Optional[list[int]]

IDs of users of this group

Source code in fractal_server/app/schemas/user_group.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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: datetime
    user_ids: Optional[list[int]] = None
    viewer_paths: list[str]

UserGroupUpdate

Bases: BaseModel

Schema for UserGroup update

Source code in fractal_server/app/schemas/user_group.py
59
60
61
62
63
64
65
66
67
68
69
70
71
class UserGroupUpdate(BaseModel, extra=Extra.forbid):
    """
    Schema for `UserGroup` update
    """

    viewer_paths: Optional[list[str]] = None

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

UserRead

Bases: BaseUser[int]

Schema for User read from database.

Attributes:

Name Type Description
username Optional[str]
Source code in fractal_server/app/schemas/user.py
36
37
38
39
40
41
42
43
44
45
46
class UserRead(schemas.BaseUser[int]):
    """
    Schema for `User` read from database.

    Attributes:
        username:
    """

    username: Optional[str]
    group_ids_names: Optional[list[tuple[int, str]]] = None
    oauth_accounts: list[OAuthAccountRead]

UserSettingsRead

Bases: BaseModel

Schema reserved for superusers

Source code in fractal_server/app/schemas/user_settings.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class UserSettingsRead(BaseModel):
    """
    Schema reserved for superusers
    """

    id: int
    ssh_host: Optional[str] = None
    ssh_username: Optional[str] = None
    ssh_private_key_path: Optional[str] = None
    ssh_tasks_dir: Optional[str] = None
    ssh_jobs_dir: Optional[str] = None
    slurm_user: Optional[str] = None
    slurm_accounts: list[str]
    project_dir: Optional[str] = None

UserSettingsUpdate

Bases: BaseModel

Schema reserved for superusers

Source code in fractal_server/app/schemas/user_settings.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class UserSettingsUpdate(BaseModel, extra=Extra.forbid):
    """
    Schema reserved for superusers
    """

    ssh_host: Optional[str] = None
    ssh_username: Optional[str] = None
    ssh_private_key_path: Optional[str] = None
    ssh_tasks_dir: Optional[str] = None
    ssh_jobs_dir: Optional[str] = None
    slurm_user: Optional[str] = None
    slurm_accounts: Optional[list[StrictStr]] = None
    project_dir: Optional[str] = None

    _ssh_host = validator("ssh_host", allow_reuse=True)(
        valstr("ssh_host", accept_none=True)
    )
    _ssh_username = validator("ssh_username", allow_reuse=True)(
        valstr("ssh_username", accept_none=True)
    )
    _ssh_private_key_path = validator(
        "ssh_private_key_path", allow_reuse=True
    )(val_absolute_path("ssh_private_key_path", accept_none=True))

    _ssh_tasks_dir = validator("ssh_tasks_dir", allow_reuse=True)(
        val_absolute_path("ssh_tasks_dir", accept_none=True)
    )
    _ssh_jobs_dir = validator("ssh_jobs_dir", allow_reuse=True)(
        val_absolute_path("ssh_jobs_dir", accept_none=True)
    )

    _slurm_user = validator("slurm_user", allow_reuse=True)(
        valstr("slurm_user", accept_none=True)
    )

    @validator("slurm_accounts")
    def slurm_accounts_validator(cls, value):
        if value is None:
            return value
        for i, item in enumerate(value):
            value[i] = valstr(f"slurm_accounts[{i}]")(item)
        return val_unique_list("slurm_accounts")(value)

    @validator("project_dir")
    def project_dir_validator(cls, value):
        if value is None:
            return None
        validate_cmd(value)
        return val_absolute_path("project_dir")(value)

UserUpdate

Bases: BaseUserUpdate

Schema for User update.

Attributes:

Name Type Description
username Optional[str]
Source code in fractal_server/app/schemas/user.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class UserUpdate(schemas.BaseUserUpdate, extra=Extra.forbid):
    """
    Schema for `User` update.

    Attributes:
        username:
    """

    username: Optional[str]

    # Validators
    _username = validator("username", allow_reuse=True)(valstr("username"))

    @validator(
        "is_active",
        "is_verified",
        "is_superuser",
        "email",
        "password",
        always=False,
    )
    def cant_set_none(cls, v, field):
        if v is None:
            raise ValueError(f"Cannot set {field.name}=None")
        return v

UserUpdateGroups

Bases: BaseModel

Schema for POST /auth/users/{user_id}/set-groups/

Source code in fractal_server/app/schemas/user.py
101
102
103
104
105
106
107
108
109
110
111
class UserUpdateGroups(BaseModel, extra=Extra.forbid):
    """
    Schema for `POST /auth/users/{user_id}/set-groups/`

    """

    group_ids: list[int] = Field(min_items=1)

    _group_ids = validator("group_ids", allow_reuse=True)(
        val_unique_list("group_ids")
    )