nexo-schemas 0.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nexo/schemas/__init__.py +0 -0
- nexo/schemas/application.py +292 -0
- nexo/schemas/connection.py +134 -0
- nexo/schemas/data.py +27 -0
- nexo/schemas/document.py +237 -0
- nexo/schemas/error/__init__.py +476 -0
- nexo/schemas/error/constants.py +50 -0
- nexo/schemas/error/descriptor.py +354 -0
- nexo/schemas/error/enums.py +40 -0
- nexo/schemas/error/metadata.py +15 -0
- nexo/schemas/error/spec.py +312 -0
- nexo/schemas/exception/__init__.py +0 -0
- nexo/schemas/exception/exc.py +911 -0
- nexo/schemas/exception/factory.py +1928 -0
- nexo/schemas/exception/handlers.py +110 -0
- nexo/schemas/google.py +14 -0
- nexo/schemas/key/__init__.py +0 -0
- nexo/schemas/key/rsa.py +131 -0
- nexo/schemas/metadata.py +21 -0
- nexo/schemas/mixins/__init__.py +0 -0
- nexo/schemas/mixins/filter.py +140 -0
- nexo/schemas/mixins/general.py +65 -0
- nexo/schemas/mixins/hierarchy.py +19 -0
- nexo/schemas/mixins/identity.py +387 -0
- nexo/schemas/mixins/parameter.py +50 -0
- nexo/schemas/mixins/service.py +40 -0
- nexo/schemas/mixins/sort.py +111 -0
- nexo/schemas/mixins/timestamp.py +192 -0
- nexo/schemas/model.py +240 -0
- nexo/schemas/operation/__init__.py +0 -0
- nexo/schemas/operation/action/__init__.py +9 -0
- nexo/schemas/operation/action/base.py +14 -0
- nexo/schemas/operation/action/resource.py +371 -0
- nexo/schemas/operation/action/status.py +8 -0
- nexo/schemas/operation/action/system.py +6 -0
- nexo/schemas/operation/action/websocket.py +6 -0
- nexo/schemas/operation/base.py +289 -0
- nexo/schemas/operation/constants.py +18 -0
- nexo/schemas/operation/context.py +68 -0
- nexo/schemas/operation/dependency.py +26 -0
- nexo/schemas/operation/enums.py +168 -0
- nexo/schemas/operation/extractor.py +36 -0
- nexo/schemas/operation/mixins.py +53 -0
- nexo/schemas/operation/request.py +1066 -0
- nexo/schemas/operation/resource.py +839 -0
- nexo/schemas/operation/system.py +55 -0
- nexo/schemas/operation/websocket.py +55 -0
- nexo/schemas/pagination.py +67 -0
- nexo/schemas/parameter.py +60 -0
- nexo/schemas/payload.py +116 -0
- nexo/schemas/resource.py +64 -0
- nexo/schemas/response.py +1041 -0
- nexo/schemas/security/__init__.py +0 -0
- nexo/schemas/security/api_key.py +63 -0
- nexo/schemas/security/authentication.py +848 -0
- nexo/schemas/security/authorization.py +922 -0
- nexo/schemas/security/enums.py +32 -0
- nexo/schemas/security/impersonation.py +179 -0
- nexo/schemas/security/token.py +402 -0
- nexo/schemas/security/types.py +17 -0
- nexo/schemas/success/__init__.py +0 -0
- nexo/schemas/success/descriptor.py +100 -0
- nexo/schemas/success/enums.py +23 -0
- nexo/schemas/user_agent.py +46 -0
- nexo_schemas-0.0.16.dist-info/METADATA +87 -0
- nexo_schemas-0.0.16.dist-info/RECORD +69 -0
- nexo_schemas-0.0.16.dist-info/WHEEL +5 -0
- nexo_schemas-0.0.16.dist-info/licenses/LICENSE +21 -0
- nexo_schemas-0.0.16.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from typing import Annotated, ClassVar, Generic, Self, TypeVar
|
|
4
|
+
from nexo.types.datetime import OptDatetime, OptDatetimeT
|
|
5
|
+
from nexo.types.float import OptFloatT
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FromTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
9
|
+
from_date: OptDatetimeT = Field(..., description="From date")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ToTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
13
|
+
to_date: OptDatetimeT = Field(..., description="To date")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StartTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
17
|
+
started_at: OptDatetimeT = Field(..., description="started_at timestamp")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class FinishTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
21
|
+
finished_at: OptDatetimeT = Field(..., description="finished_at timestamp")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ExecutionTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
25
|
+
executed_at: OptDatetimeT = Field(..., description="executed_at timestamp")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CompletionTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
29
|
+
completed_at: OptDatetimeT = Field(..., description="completed_at timestamp")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class CreationTimestamp(BaseModel):
|
|
33
|
+
created_at: datetime = Field(..., description="created_at timestamp")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class UpdateTimestamp(BaseModel):
|
|
37
|
+
updated_at: datetime = Field(..., description="updated_at timestamp")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class LifecycleTimestamp(
|
|
41
|
+
UpdateTimestamp,
|
|
42
|
+
CreationTimestamp,
|
|
43
|
+
):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class DeletionTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
48
|
+
deleted_at: OptDatetimeT = Field(..., description="deleted_at timestamp")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class RestorationTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
52
|
+
restored_at: OptDatetimeT = Field(..., description="restored_at timestamp")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class DeactivationTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
56
|
+
deactivated_at: OptDatetimeT = Field(..., description="deactivated_at timestamp")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ActivationTimestamp(BaseModel, Generic[OptDatetimeT]):
|
|
60
|
+
activated_at: OptDatetimeT = Field(..., description="activated_at timestamp")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
DeletionTimestampT = TypeVar("DeletionTimestampT", bound=OptDatetime)
|
|
64
|
+
RestorationTimestampT = TypeVar("RestorationTimestampT", bound=OptDatetime)
|
|
65
|
+
DeactivationTimestampT = TypeVar("DeactivationTimestampT", bound=OptDatetime)
|
|
66
|
+
ActivationTimestampT = TypeVar("ActivationTimestampT", bound=OptDatetime)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class StatusTimestamp(
|
|
70
|
+
ActivationTimestamp[ActivationTimestampT],
|
|
71
|
+
DeactivationTimestamp[DeactivationTimestampT],
|
|
72
|
+
RestorationTimestamp[RestorationTimestampT],
|
|
73
|
+
DeletionTimestamp[DeletionTimestampT],
|
|
74
|
+
Generic[
|
|
75
|
+
DeletionTimestampT,
|
|
76
|
+
RestorationTimestampT,
|
|
77
|
+
DeactivationTimestampT,
|
|
78
|
+
ActivationTimestampT,
|
|
79
|
+
],
|
|
80
|
+
):
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class DataStatusTimestamp(
|
|
85
|
+
StatusTimestamp[
|
|
86
|
+
OptDatetime,
|
|
87
|
+
OptDatetime,
|
|
88
|
+
OptDatetime,
|
|
89
|
+
datetime,
|
|
90
|
+
],
|
|
91
|
+
):
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class DataTimestamp(
|
|
96
|
+
DataStatusTimestamp,
|
|
97
|
+
LifecycleTimestamp,
|
|
98
|
+
):
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class Duration(BaseModel, Generic[OptFloatT]):
|
|
103
|
+
duration: OptFloatT = Field(..., description="Duration")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class InferenceDuration(BaseModel, Generic[OptFloatT]):
|
|
107
|
+
inference_duration: OptFloatT = Field(..., description="Inference duration")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class Uptime(BaseModel):
|
|
111
|
+
_SECONDS_IN_MINUTE: ClassVar[int] = 60
|
|
112
|
+
_SECONDS_IN_HOUR: ClassVar[int] = 3600
|
|
113
|
+
_SECONDS_IN_DAY: ClassVar[int] = 86400
|
|
114
|
+
_SECONDS_IN_MONTH: ClassVar[int] = 30 * _SECONDS_IN_DAY
|
|
115
|
+
|
|
116
|
+
raw: Annotated[float, Field(0.0, description="Raw", ge=0.0)] = 0
|
|
117
|
+
month: Annotated[int, Field(0, description="Month", ge=0)] = 0
|
|
118
|
+
day: Annotated[int, Field(0, description="Day", ge=0)] = 0
|
|
119
|
+
hour: Annotated[int, Field(0, description="Hour", ge=0)] = 0
|
|
120
|
+
minute: Annotated[int, Field(0, description="Minute", ge=0)] = 0
|
|
121
|
+
second: Annotated[int, Field(0, description="Second", ge=0)] = 0
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
def from_raw(cls, raw: float = 0) -> Self:
|
|
125
|
+
sec = int(raw)
|
|
126
|
+
|
|
127
|
+
month = sec // cls._SECONDS_IN_MONTH
|
|
128
|
+
sec %= cls._SECONDS_IN_MONTH
|
|
129
|
+
|
|
130
|
+
day = sec // cls._SECONDS_IN_DAY
|
|
131
|
+
sec %= cls._SECONDS_IN_DAY
|
|
132
|
+
|
|
133
|
+
hour = sec // cls._SECONDS_IN_HOUR
|
|
134
|
+
sec %= cls._SECONDS_IN_HOUR
|
|
135
|
+
|
|
136
|
+
minute = sec // cls._SECONDS_IN_MINUTE
|
|
137
|
+
sec %= cls._SECONDS_IN_MINUTE
|
|
138
|
+
|
|
139
|
+
second = sec
|
|
140
|
+
|
|
141
|
+
return cls(
|
|
142
|
+
raw=raw,
|
|
143
|
+
month=month,
|
|
144
|
+
day=day,
|
|
145
|
+
hour=hour,
|
|
146
|
+
minute=minute,
|
|
147
|
+
second=second,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
@classmethod
|
|
151
|
+
def from_timedelta(cls, timedelta: timedelta) -> Self:
|
|
152
|
+
raw = timedelta.total_seconds()
|
|
153
|
+
return cls.from_raw(raw=raw)
|
|
154
|
+
|
|
155
|
+
def stringify(self, long: bool = False, skip_zero: bool = True) -> str:
|
|
156
|
+
"""
|
|
157
|
+
Convert uptime into a human-readable string.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
long: If True → "3 months 2 days".
|
|
161
|
+
If False → "3M 2D".
|
|
162
|
+
skip_zero: If True → omit fields with zero value.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
A formatted uptime string.
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
parts = [
|
|
169
|
+
("Month", self.month, "Mo"),
|
|
170
|
+
("Day", self.day, "D"),
|
|
171
|
+
("Hour", self.hour, "H"),
|
|
172
|
+
("Minute", self.minute, "Mi"),
|
|
173
|
+
("Second", self.second, "S"),
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
output = []
|
|
177
|
+
|
|
178
|
+
for name, value, short in parts:
|
|
179
|
+
if skip_zero and value == 0:
|
|
180
|
+
continue
|
|
181
|
+
|
|
182
|
+
if long:
|
|
183
|
+
label = name if value == 1 else name + "s"
|
|
184
|
+
output.append(f"{value} {label}")
|
|
185
|
+
else:
|
|
186
|
+
output.append(f"{value}{short}")
|
|
187
|
+
|
|
188
|
+
return " ".join(output) if output else "0S"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class UptimeMixin(BaseModel):
|
|
192
|
+
uptime: Annotated[Uptime, Field(Uptime(), description="Uptime")] = Uptime()
|
nexo/schemas/model.py
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from sqlalchemy import func
|
|
3
|
+
from sqlalchemy.dialects.postgresql import UUID as PostgresUUID
|
|
4
|
+
from sqlalchemy.orm import Mapped, declared_attr, mapped_column
|
|
5
|
+
from sqlalchemy.types import Integer, Enum, DateTime
|
|
6
|
+
from uuid import UUID as PythonUUID, uuid4
|
|
7
|
+
from nexo.enums.status import DataStatus as DataStatusEnum
|
|
8
|
+
from nexo.types.datetime import OptDatetime
|
|
9
|
+
from nexo.types.integer import OptInt
|
|
10
|
+
from nexo.types.uuid import OptUUID
|
|
11
|
+
from nexo.utils.formatter import CaseFormatter
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TableName:
|
|
15
|
+
@declared_attr.directive
|
|
16
|
+
def __tablename__(cls) -> str:
|
|
17
|
+
return CaseFormatter.to_snake(cls.__name__) # type: ignore
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Int ID
|
|
21
|
+
class IntId:
|
|
22
|
+
id: Mapped[int] = mapped_column(name="id", type_=Integer, nullable=False)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class OptIntId:
|
|
26
|
+
id: Mapped[OptInt] = mapped_column(name="id", type_=Integer)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class IntParentId:
|
|
30
|
+
parent_id: Mapped[int] = mapped_column(
|
|
31
|
+
name="parent_id", type_=Integer, nullable=False
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class OptIntParentId:
|
|
36
|
+
parent_id: Mapped[OptInt] = mapped_column(name="parent_id", type_=Integer)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class IntOrganizationId:
|
|
40
|
+
organization_id: Mapped[int] = mapped_column(
|
|
41
|
+
name="organization_id", type_=Integer, nullable=False
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class OptIntOrganizationId:
|
|
46
|
+
organization_id: Mapped[OptInt] = mapped_column(
|
|
47
|
+
name="organization_id", type_=Integer
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class IntSourceId:
|
|
52
|
+
source_id: Mapped[int] = mapped_column(
|
|
53
|
+
name="source_id", type_=Integer, nullable=False
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class OptIntSourceId:
|
|
58
|
+
source_id: Mapped[OptInt] = mapped_column(name="source_id", type_=Integer)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class IntTargetId:
|
|
62
|
+
target_id: Mapped[int] = mapped_column(
|
|
63
|
+
name="target_id", type_=Integer, nullable=False
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class OptIntTargetId:
|
|
68
|
+
target_id: Mapped[OptInt] = mapped_column(name="target_id", type_=Integer)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class IntUserId:
|
|
72
|
+
user_id: Mapped[int] = mapped_column(name="user_id", type_=Integer, nullable=False)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class OptIntUserId:
|
|
76
|
+
user_id: Mapped[OptInt] = mapped_column(name="user_id", type_=Integer)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# UUID ID
|
|
80
|
+
class UUIDId:
|
|
81
|
+
id: Mapped[int] = mapped_column(
|
|
82
|
+
name="id", type_=PostgresUUID(as_uuid=True), default=uuid4, nullable=False
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class OptUUIDId:
|
|
87
|
+
id: Mapped[OptUUID] = mapped_column(name="id", type_=PostgresUUID(as_uuid=True))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class UUIDParentId:
|
|
91
|
+
parent_id: Mapped[int] = mapped_column(
|
|
92
|
+
name="parent_id",
|
|
93
|
+
type_=PostgresUUID(as_uuid=True),
|
|
94
|
+
default=uuid4,
|
|
95
|
+
nullable=False,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class OptUUIDParentId:
|
|
100
|
+
parent_id: Mapped[OptUUID] = mapped_column(
|
|
101
|
+
name="parent_id", type_=PostgresUUID(as_uuid=True)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class UUIDOrganizationId:
|
|
106
|
+
organization_id: Mapped[int] = mapped_column(
|
|
107
|
+
name="organization_id",
|
|
108
|
+
type_=PostgresUUID(as_uuid=True),
|
|
109
|
+
default=uuid4,
|
|
110
|
+
nullable=False,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class OptUUIDOrganizationId:
|
|
115
|
+
organization_id: Mapped[OptUUID] = mapped_column(
|
|
116
|
+
name="organization_id", type_=PostgresUUID(as_uuid=True)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class UUIDSourceId:
|
|
121
|
+
source_id: Mapped[int] = mapped_column(
|
|
122
|
+
name="source_id",
|
|
123
|
+
type_=PostgresUUID(as_uuid=True),
|
|
124
|
+
default=uuid4,
|
|
125
|
+
nullable=False,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class OptUUIDSourceId:
|
|
130
|
+
source_id: Mapped[OptUUID] = mapped_column(
|
|
131
|
+
name="source_id", type_=PostgresUUID(as_uuid=True)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class UUIDTargetId:
|
|
136
|
+
target_id: Mapped[int] = mapped_column(
|
|
137
|
+
name="target_id",
|
|
138
|
+
type_=PostgresUUID(as_uuid=True),
|
|
139
|
+
default=uuid4,
|
|
140
|
+
nullable=False,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class OptUUIDTargetId:
|
|
145
|
+
target_id: Mapped[OptUUID] = mapped_column(
|
|
146
|
+
name="target_id", type_=PostgresUUID(as_uuid=True)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class UUIDUserId:
|
|
151
|
+
user_id: Mapped[int] = mapped_column(
|
|
152
|
+
name="user_id", type_=PostgresUUID(as_uuid=True), default=uuid4, nullable=False
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class OptUUIDUserId:
|
|
157
|
+
user_id: Mapped[OptUUID] = mapped_column(
|
|
158
|
+
name="user_id", type_=PostgresUUID(as_uuid=True)
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# Identifier
|
|
163
|
+
class DataIdentifier:
|
|
164
|
+
id: Mapped[int] = mapped_column(name="id", type_=Integer, primary_key=True)
|
|
165
|
+
uuid: Mapped[PythonUUID] = mapped_column(
|
|
166
|
+
name="uuid",
|
|
167
|
+
type_=PostgresUUID(as_uuid=True),
|
|
168
|
+
default=uuid4,
|
|
169
|
+
unique=True,
|
|
170
|
+
nullable=False,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class CreationTimestamp:
|
|
175
|
+
created_at: Mapped[datetime] = mapped_column(
|
|
176
|
+
name="created_at",
|
|
177
|
+
type_=DateTime(timezone=True),
|
|
178
|
+
server_default=func.now(),
|
|
179
|
+
nullable=False,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class UpdateTimestamp:
|
|
184
|
+
updated_at: Mapped[datetime] = mapped_column(
|
|
185
|
+
name="updated_at",
|
|
186
|
+
type_=DateTime(timezone=True),
|
|
187
|
+
server_default=func.now(),
|
|
188
|
+
onupdate=func.now(),
|
|
189
|
+
nullable=False,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class LifecyleTimestamp(UpdateTimestamp, CreationTimestamp):
|
|
194
|
+
pass
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class DeletionTimestamp:
|
|
198
|
+
deleted_at: Mapped[OptDatetime] = mapped_column(
|
|
199
|
+
name="deleted_at", type_=DateTime(timezone=True)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class RestorationTimestamp:
|
|
204
|
+
restored_at: Mapped[OptDatetime] = mapped_column(
|
|
205
|
+
name="restored_at", type_=DateTime(timezone=True)
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class DeactivationTimestamp:
|
|
210
|
+
deactivated_at: Mapped[OptDatetime] = mapped_column(
|
|
211
|
+
name="deactivated_at", type_=DateTime(timezone=True)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class ActivationTimestamp:
|
|
216
|
+
activated_at: Mapped[datetime] = mapped_column(
|
|
217
|
+
name="activated_at",
|
|
218
|
+
type_=DateTime(timezone=True),
|
|
219
|
+
server_default=func.now(),
|
|
220
|
+
nullable=False,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class StatusTimestamp(
|
|
225
|
+
ActivationTimestamp, DeactivationTimestamp, RestorationTimestamp, DeletionTimestamp
|
|
226
|
+
):
|
|
227
|
+
pass
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class DataTimestamp(StatusTimestamp, LifecyleTimestamp):
|
|
231
|
+
pass
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class DataStatus:
|
|
235
|
+
status: Mapped[DataStatusEnum] = mapped_column(
|
|
236
|
+
name="status",
|
|
237
|
+
type_=Enum(DataStatusEnum, name="statustype", create_constraints=True),
|
|
238
|
+
default=DataStatusEnum.ACTIVE,
|
|
239
|
+
nullable=False,
|
|
240
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Generic
|
|
3
|
+
from nexo.types.dict import OptStrToAnyDict
|
|
4
|
+
from nexo.types.enum import StrEnumT
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BaseOperationAction(BaseModel, Generic[StrEnumT]):
|
|
8
|
+
type: Annotated[StrEnumT, Field(..., description="Action's type")]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SimpleOperationAction(BaseOperationAction[StrEnumT], Generic[StrEnumT]):
|
|
12
|
+
details: Annotated[OptStrToAnyDict, Field(None, description="Action's details")] = (
|
|
13
|
+
None
|
|
14
|
+
)
|