-
-
Notifications
You must be signed in to change notification settings - Fork 453
/
Copy pathschemas.py
47 lines (36 loc) · 1.18 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from extendable_pydantic import StrictExtendableBaseModel
class CrossConnectGroup(StrictExtendableBaseModel):
id: int
name: str
comment: str | None = None
@classmethod
def from_group(cls, group):
return cls.model_construct(
id=group.id,
name=group.full_name,
comment=group.comment or None,
)
class SyncResponse(StrictExtendableBaseModel):
groups: list[CrossConnectGroup]
@classmethod
def from_groups(cls, groups):
return cls.model_construct(
groups=[CrossConnectGroup.from_group(group) for group in groups]
)
class AccessRequest(StrictExtendableBaseModel, extra="ignore"):
id: int
name: str
login: str
email: str
lang: str
groups: list[int]
redirect_url: str = None
class AccessResponse(StrictExtendableBaseModel):
client_id: int
token: str
@classmethod
def from_params(cls, token, client_id):
return cls.model_construct(token=token, client_id=client_id)