synched enum fields to lower case like yaml
This commit is contained in:
parent
06e9c9b8ae
commit
e88f3fa1de
@ -943,6 +943,7 @@ components:
|
|||||||
OperationType:
|
OperationType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
- undefined
|
||||||
- insert
|
- insert
|
||||||
- update
|
- update
|
||||||
- delete
|
- delete
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
from dataclasses import field, dataclass
|
from dataclasses import field, dataclass
|
||||||
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
||||||
|
from marshmallow.fields import Field
|
||||||
from marshmallow_enum import EnumField
|
from marshmallow_enum import EnumField
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
||||||
@ -26,15 +27,32 @@ class Berth(Schema):
|
|||||||
deleted: bool
|
deleted: bool
|
||||||
|
|
||||||
class Operation(IntEnum):
|
class Operation(IntEnum):
|
||||||
UNDEFINED = 0
|
undefined = 0
|
||||||
INSERT = 1
|
insert = 1
|
||||||
UPDATE = 2
|
update = 2
|
||||||
DELETE = 3
|
delete = 3
|
||||||
|
|
||||||
class ObjectType(IntEnum):
|
class ObjectType(IntEnum):
|
||||||
UNDEFINED = 0
|
undefined = 0
|
||||||
SHIPCALL = 1
|
shipcall = 1
|
||||||
TIMES = 2
|
times = 2
|
||||||
|
|
||||||
|
class EvaluationType(IntEnum):
|
||||||
|
undefined = 0
|
||||||
|
green = 1
|
||||||
|
yellow = 2
|
||||||
|
red = 3
|
||||||
|
|
||||||
|
class NotificationType(IntEnum):
|
||||||
|
undefined = 0
|
||||||
|
email = 1
|
||||||
|
push = 2
|
||||||
|
|
||||||
|
class ShipcallType(IntEnum):
|
||||||
|
undefined = 0
|
||||||
|
arrival = 1
|
||||||
|
departure = 2
|
||||||
|
shifting = 3
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class History:
|
class History:
|
||||||
@ -53,8 +71,8 @@ class History:
|
|||||||
shipcall_id: int
|
shipcall_id: int
|
||||||
timestamp: datetime
|
timestamp: datetime
|
||||||
eta: datetime
|
eta: datetime
|
||||||
type: EnumField(ObjectType)
|
type: ObjectType
|
||||||
operation: EnumField(Operation)
|
operation: Operation
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_query_row(self, id, participant_id, shipcall_id, timestamp, eta, type, operation):
|
def from_query_row(self, id, participant_id, shipcall_id, timestamp, eta, type, operation):
|
||||||
return self(id, participant_id, shipcall_id, timestamp, eta, ObjectType(type), Operation(operation))
|
return self(id, participant_id, shipcall_id, timestamp, eta, ObjectType(type), Operation(operation))
|
||||||
@ -71,7 +89,7 @@ class Notification:
|
|||||||
id: int
|
id: int
|
||||||
shipcall_id: int
|
shipcall_id: int
|
||||||
level: int
|
level: int
|
||||||
type: int
|
type: NotificationType
|
||||||
message: str
|
message: str
|
||||||
created: datetime
|
created: datetime
|
||||||
modified: datetime
|
modified: datetime
|
||||||
@ -103,7 +121,7 @@ class ShipcallSchema(Schema):
|
|||||||
|
|
||||||
id = fields.Int()
|
id = fields.Int()
|
||||||
ship_id = fields.Int()
|
ship_id = fields.Int()
|
||||||
type = fields.Int()
|
type = EnumField(ShipcallType, by_value=True, required=True)
|
||||||
eta = fields.DateTime(Required = False, allow_none=True)
|
eta = fields.DateTime(Required = False, allow_none=True)
|
||||||
voyage = fields.Str(allow_none=True, metadata={'Required':False}) # Solving: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'Required': False}
|
voyage = fields.Str(allow_none=True, metadata={'Required':False}) # Solving: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'Required': False}
|
||||||
etd = fields.DateTime(Required = False, allow_none=True)
|
etd = fields.DateTime(Required = False, allow_none=True)
|
||||||
@ -124,7 +142,7 @@ class ShipcallSchema(Schema):
|
|||||||
anchored = fields.Bool(Required = False, allow_none=True)
|
anchored = fields.Bool(Required = False, allow_none=True)
|
||||||
moored_lock = fields.Bool(Required = False, allow_none=True)
|
moored_lock = fields.Bool(Required = False, allow_none=True)
|
||||||
canceled = fields.Bool(Required = False, allow_none=True)
|
canceled = fields.Bool(Required = False, allow_none=True)
|
||||||
evaluation = fields.Int(Required = False, allow_none=True)
|
evaluation = EnumField(EvaluationType, required=False, allow_none=True, by_value=True)
|
||||||
evaluation_message = fields.Str(allow_none=True, metadata={'Required':False}) # Solving: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'Required': False}
|
evaluation_message = fields.Str(allow_none=True, metadata={'Required':False}) # Solving: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'Required': False}
|
||||||
evaluation_time = fields.DateTime(Required = False, allow_none=True)
|
evaluation_time = fields.DateTime(Required = False, allow_none=True)
|
||||||
evaluation_notifications_sent = fields.Bool(Required = False, allow_none=True)
|
evaluation_notifications_sent = fields.Bool(Required = False, allow_none=True)
|
||||||
@ -142,6 +160,7 @@ class Participant_Assignment:
|
|||||||
participant_id: int
|
participant_id: int
|
||||||
type: int # a variant would be to use the IntFlag type (with appropriate serialization)
|
type: int # a variant would be to use the IntFlag type (with appropriate serialization)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Shipcall:
|
class Shipcall:
|
||||||
|
|
||||||
@ -168,7 +187,7 @@ class Shipcall:
|
|||||||
anchored: bool
|
anchored: bool
|
||||||
moored_lock: bool
|
moored_lock: bool
|
||||||
canceled: bool
|
canceled: bool
|
||||||
evaluation: int
|
evaluation: str
|
||||||
evaluation_message: str
|
evaluation_message: str
|
||||||
evaluation_time: datetime
|
evaluation_time: datetime
|
||||||
evaluation_notifications_sent: bool
|
evaluation_notifications_sent: bool
|
||||||
|
|||||||
Reference in New Issue
Block a user