From b9dad7f87c8c5dc6e5045a084e44c52b2b0ffe0e Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Mon, 27 Feb 2023 10:40:44 +0100 Subject: [PATCH] implemented deserializer --- app/orm.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/orm.py b/app/orm.py index c78ca95..d7f5570 100644 --- a/app/orm.py +++ b/app/orm.py @@ -32,6 +32,16 @@ class Origin(Base): 'os_version': self.os_version, } + @staticmethod + def deserialize(j) -> "Origin": + return Origin( + origin_ref=j.get('origin_ref'), + hostname=j.get('hostname'), + guest_driver_version=j.get('guest_driver_version'), + os_platform=j.get('os_platform'), + os_version=j.get('os_version'), + ) + @staticmethod def create_statement(engine: Engine): from sqlalchemy.schema import CreateTable @@ -95,6 +105,17 @@ class Lease(Base): 'lease_renewal': lease_renewal.isoformat(), } + @staticmethod + def deserialize(j) -> "Lease": + return Lease( + lease_ref=j.get('lease_ref'), + origin_ref=j.get('origin_ref'), + lease_created=j.get('lease_created'), + lease_expires=j.get('lease_expires'), + lease_updated=j.get('lease_updated'), + lease_renewal=j.get('lease_renewal'), + ) + @staticmethod def create_statement(engine: Engine): from sqlalchemy.schema import CreateTable