Add preliminary implementation to load DeviceMetadata from data.
This commit is contained in:
parent
27ae736f11
commit
73771be70d
@ -7,6 +7,7 @@ from typing import Optional, List, Any
|
|||||||
# iottb modules
|
# iottb modules
|
||||||
from iottb.definitions import ReturnCodes, DEVICE_METADATA_FILE
|
from iottb.definitions import ReturnCodes, DEVICE_METADATA_FILE
|
||||||
from iottb.logger import logger
|
from iottb.logger import logger
|
||||||
|
|
||||||
# 3rd party libs
|
# 3rd party libs
|
||||||
|
|
||||||
IMMUTABLE_FIELDS = {"device_name", "device_short_name", "device_id", "date_created"}
|
IMMUTABLE_FIELDS = {"device_name", "device_short_name", "device_id", "date_created"}
|
||||||
@ -62,10 +63,10 @@ class DeviceMetadata:
|
|||||||
json.dump(metadata, file)
|
json.dump(metadata, file)
|
||||||
return ReturnCodes.SUCCESS
|
return ReturnCodes.SUCCESS
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, metadata_json):
|
def from_json(cls, metadata_json):
|
||||||
pass
|
if isinstance(metadata_json, dict):
|
||||||
|
return DeviceMetadata(**metadata_json)
|
||||||
|
|
||||||
def to_json(self, indent=2):
|
def to_json(self, indent=2):
|
||||||
# TODO: atm almost exact copy as in CaptureMetadata
|
# TODO: atm almost exact copy as in CaptureMetadata
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user