197 lines
4.0 KiB
Python
197 lines
4.0 KiB
Python
from marshmallow import Schema, fields
|
|
from dataclasses import dataclass
|
|
import json
|
|
import datetime
|
|
|
|
def obj_dict(obj):
|
|
if isinstance(obj, datetime.datetime):
|
|
return obj.isoformat()
|
|
return obj.__dict__
|
|
|
|
@dataclass
|
|
class Berth(Schema):
|
|
id: int
|
|
name: str
|
|
participant_id: int
|
|
lock: bool
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
name = fields.String()
|
|
participant_id = fields.Int()
|
|
lock = fields.Bool()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
class Error(Schema):
|
|
message = fields.String(required=True,)
|
|
|
|
|
|
class GetVerifyInlineResp(Schema):
|
|
pass
|
|
|
|
|
|
class Notification(Schema):
|
|
|
|
id: int
|
|
times_id: int
|
|
acknowledged: bool
|
|
level: int
|
|
type: int
|
|
message: str
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
times_id = fields.Int()
|
|
acknowledged = fields.Boolean()
|
|
level = fields.Int()
|
|
type = fields.Int()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
@dataclass
|
|
class Participant(Schema):
|
|
id: int
|
|
name: str
|
|
street: str
|
|
postal_code: str
|
|
city: str
|
|
flags: int
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
name = fields.String()
|
|
street = fields.String()
|
|
postal_code = fields.String()
|
|
city = fields.String()
|
|
flags = fields.Int()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
@dataclass
|
|
class ParticipantList(Participant):
|
|
pass
|
|
|
|
class Shipcall(Schema):
|
|
id: int
|
|
ship_id: int
|
|
type: int
|
|
eta: datetime
|
|
voyage: str
|
|
etd: datetime
|
|
arrival_berth_id: int
|
|
departure_berth_id: int
|
|
tug_required: bool
|
|
pilot_required: bool
|
|
flags: int
|
|
pier_side: bool
|
|
bunkering: bool
|
|
replenishing: bool
|
|
draft: float
|
|
tidal_window_from: datetime
|
|
tidal_window_to: datetime
|
|
rain_sensitive_cargo: bool
|
|
recommended_tugs: int
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
ship_id = fields.Int()
|
|
type = fields.Int()
|
|
eta = fields.DateTime()
|
|
voyage = fields.Str()
|
|
etd = fields.DateTime()
|
|
arrival_berth_id = fields.Int()
|
|
departure_berth_id = fields.Int()
|
|
tug_required = fields.Bool()
|
|
pilot_required = fields.Bool()
|
|
flags = fields.Int()
|
|
pier_side = fields.Bool()
|
|
bunkering = fields.Bool()
|
|
replenishing = fields.Bool()
|
|
draft = fields.Float()
|
|
tidal_window_from = fields.DateTime()
|
|
tidal_window_to = fields.DateTime()
|
|
rain_sensitive_cargo = fields.Bool()
|
|
recommended_tugs = fields.Int()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
|
|
class ShipcallId(Schema):
|
|
pass
|
|
|
|
|
|
class Times(Schema):
|
|
id: int
|
|
start_planned: datetime
|
|
end_planned: datetime
|
|
duration_planned: int
|
|
start_actual: datetime
|
|
end_actual: datetime
|
|
duration_actual: int
|
|
participant_id: int
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
start_planned = fields.DateTime()
|
|
end_planned = fields.DateTime()
|
|
duration_planned = fields.Int()
|
|
start_actual = fields.DateTime()
|
|
end_actual = fields.DateTime()
|
|
duration_actual = fields.Int()
|
|
participant_id = fields.Int()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
class Ship(Schema):
|
|
id: int
|
|
name: str
|
|
imo: int
|
|
callsign: str
|
|
length: float
|
|
width: float
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
id = fields.Int()
|
|
name = fields.Str()
|
|
imo = fields.Int()
|
|
callsign = fields.Str()
|
|
length = fields.Float()
|
|
width = fields.Float()
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
class TimesId(Schema):
|
|
pass
|
|
|
|
@dataclass
|
|
class BerthList(Berth):
|
|
pass
|
|
|
|
|
|
class NotificationList(Notification):
|
|
pass
|
|
|
|
|
|
class Shipcalls(Shipcall):
|
|
pass
|
|
|
|
|
|
class TimesList(Times):
|
|
pass
|
|
|
|
class User(Schema):
|
|
id = fields.Int()
|
|
participant_id = fields.Int()
|
|
first_name = fields.String()
|
|
last_name = fields.String()
|
|
user_name = fields.String()
|
|
password_hash = fields.String()
|
|
api_key = fields.String()
|