mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-07-02 18:10:33 -05:00
adding master api project
This commit is contained in:
1
Master/master/schema/__init__.py
Normal file
1
Master/master/schema/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
29
Master/master/schema/instanceschema.py
Normal file
29
Master/master/schema/instanceschema.py
Normal file
@ -0,0 +1,29 @@
|
||||
from marshmallow import Schema, fields, post_load, validate
|
||||
from master.models.instancemodel import InstanceModel
|
||||
from master.schema.serverschema import ServerSchema
|
||||
|
||||
class InstanceSchema(Schema):
|
||||
id = fields.String(
|
||||
required=True
|
||||
)
|
||||
version = fields.Float(
|
||||
required=True,
|
||||
validate=validate.Range(1.0, 10.0, 'invalid version number')
|
||||
)
|
||||
servers = fields.Nested(
|
||||
ServerSchema,
|
||||
many=True,
|
||||
validate=validate.Length(0, 32, 'invalid server count')
|
||||
)
|
||||
uptime = fields.Int(
|
||||
required=True,
|
||||
validate=validate.Range(0, 2147483647, 'invalid uptime')
|
||||
)
|
||||
last_heartbeat = fields.Int(
|
||||
required=False
|
||||
)
|
||||
|
||||
@post_load
|
||||
def make_instance(self, data):
|
||||
return InstanceModel(**data)
|
||||
|
40
Master/master/schema/serverschema.py
Normal file
40
Master/master/schema/serverschema.py
Normal file
@ -0,0 +1,40 @@
|
||||
from marshmallow import Schema, fields, post_load, validate
|
||||
from master.models.servermodel import ServerModel
|
||||
|
||||
class ServerSchema(Schema):
|
||||
id = fields.Int(
|
||||
required=True,
|
||||
validate=validate.Range(1, 2147483647, 'invalid id')
|
||||
)
|
||||
port = fields.Int(
|
||||
required=True,
|
||||
validate=validate.Range(1, 665535, 'invalid port')
|
||||
)
|
||||
game = fields.String(
|
||||
required=True,
|
||||
validate=validate.Length(1, 8, 'invalid game name')
|
||||
)
|
||||
hostname = fields.String(
|
||||
required=True,
|
||||
validate=validate.Length(1, 48, 'invalid hostname')
|
||||
)
|
||||
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,
|
||||
validate=validate.Length(1, 32, 'invalid map name')
|
||||
)
|
||||
gametype = fields.String(
|
||||
required=True,
|
||||
validate=validate.Length(1, 16, 'invalid gametype')
|
||||
)
|
||||
|
||||
@post_load
|
||||
def make_instance(self, data):
|
||||
return ServerModel(**data)
|
Reference in New Issue
Block a user