2018-04-18 16:46:53 -04:00
|
|
|
from marshmallow import Schema, fields, post_load, validate
|
|
|
|
from master.models.servermodel import ServerModel
|
|
|
|
|
|
|
|
class ServerSchema(Schema):
|
|
|
|
id = fields.Int(
|
|
|
|
required=True,
|
2019-02-12 21:34:29 -05:00
|
|
|
validate=validate.Range(0, 25525525525565535, 'invalid id')
|
2018-04-18 16:46:53 -04:00
|
|
|
)
|
2018-09-29 15:52:22 -04:00
|
|
|
ip = fields.Str(
|
|
|
|
required=True
|
|
|
|
)
|
2018-04-18 16:46:53 -04:00
|
|
|
port = fields.Int(
|
|
|
|
required=True,
|
2018-09-29 15:52:22 -04:00
|
|
|
validate=validate.Range(1, 65535, 'invalid port')
|
2018-04-18 16:46:53 -04:00
|
|
|
)
|
2018-12-16 22:16:56 -05:00
|
|
|
version = fields.String(
|
|
|
|
required=False,
|
|
|
|
validate=validate.Length(0, 128, 'invalid server version')
|
|
|
|
)
|
2018-04-18 16:46:53 -04:00
|
|
|
game = fields.String(
|
|
|
|
required=True,
|
2018-09-29 15:52:22 -04:00
|
|
|
validate=validate.Length(1, 5, 'invalid game name')
|
2018-04-18 16:46:53 -04:00
|
|
|
)
|
|
|
|
hostname = fields.String(
|
|
|
|
required=True,
|
2019-12-24 16:23:43 -05:00
|
|
|
validate=validate.Length(1, 128, 'invalid hostname')
|
2018-04-18 16:46:53 -04:00
|
|
|
)
|
|
|
|
clientnum = fields.Int(
|
|
|
|
required=True,
|
|
|
|
validate=validate.Range(0, 128, 'invalid clientnum')
|
|
|
|
)
|
|
|
|
maxclientnum = fields.Int(
|
|
|
|
required=True,
|
|
|
|
validate=validate.Range(1, 128, 'invalid maxclientnum')
|
|
|
|
)
|
|
|
|
map = fields.String(
|
|
|
|
required=True,
|
2019-02-12 21:34:29 -05:00
|
|
|
validate=validate.Length(0, 64, 'invalid map name')
|
2018-04-18 16:46:53 -04:00
|
|
|
)
|
|
|
|
gametype = fields.String(
|
|
|
|
required=True,
|
|
|
|
validate=validate.Length(1, 16, 'invalid gametype')
|
|
|
|
)
|
|
|
|
|
|
|
|
@post_load
|
|
|
|
def make_instance(self, data):
|
|
|
|
return ServerModel(**data)
|