add schema_version

This commit is contained in:
Cayo Puigdefabregas 2022-04-08 11:10:03 +02:00
parent cd6e079aee
commit 545a1013e9
2 changed files with 34 additions and 27 deletions

View File

@ -1,39 +1,49 @@
from distutils.version import StrictVersion from distutils.version import StrictVersion
from itertools import chain from itertools import chain
from typing import Set from typing import Set
from decouple import config
from decouple import config
from teal.auth import TokenAuth from teal.auth import TokenAuth
from teal.config import Config from teal.config import Config
from teal.enums import Currency from teal.enums import Currency
from teal.utils import import_resource from teal.utils import import_resource
from ereuse_devicehub.resources import action, agent, deliverynote, inventory, \ from ereuse_devicehub.resources import (
lot, tag, user action,
agent,
deliverynote,
inventory,
lot,
tag,
user,
)
from ereuse_devicehub.resources.device import definitions from ereuse_devicehub.resources.device import definitions
from ereuse_devicehub.resources.documents import documents from ereuse_devicehub.resources.documents import documents
from ereuse_devicehub.resources.tradedocument import definitions as tradedocument
from ereuse_devicehub.resources.enums import PriceSoftware from ereuse_devicehub.resources.enums import PriceSoftware
from ereuse_devicehub.resources.versions import versions
from ereuse_devicehub.resources.licences import licences from ereuse_devicehub.resources.licences import licences
from ereuse_devicehub.resources.metric import definitions as metric_def from ereuse_devicehub.resources.metric import definitions as metric_def
from ereuse_devicehub.resources.tradedocument import definitions as tradedocument
from ereuse_devicehub.resources.versions import versions
class DevicehubConfig(Config): class DevicehubConfig(Config):
RESOURCE_DEFINITIONS = set(chain(import_resource(definitions), RESOURCE_DEFINITIONS = set(
import_resource(action), chain(
import_resource(user), import_resource(definitions),
import_resource(tag), import_resource(action),
import_resource(agent), import_resource(user),
import_resource(lot), import_resource(tag),
import_resource(deliverynote), import_resource(agent),
import_resource(documents), import_resource(lot),
import_resource(tradedocument), import_resource(deliverynote),
import_resource(inventory), import_resource(documents),
import_resource(versions), import_resource(tradedocument),
import_resource(licences), import_resource(inventory),
import_resource(metric_def), import_resource(versions),
),) import_resource(licences),
import_resource(metric_def),
),
)
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str] PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
SECRET_KEY = config('SECRET_KEY') SECRET_KEY = config('SECRET_KEY')
DB_USER = config('DB_USER', 'dhub') DB_USER = config('DB_USER', 'dhub')
@ -48,12 +58,12 @@ class DevicehubConfig(Config):
db=DB_DATABASE, db=DB_DATABASE,
) # type: str ) # type: str
SCHEMA = config('SCHEMA', 'dbtest') SCHEMA = config('SCHEMA', 'dbtest')
HOST = config('HOST', 'localhost') HOST = config('HOST', 'localhost')
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
"""The minimum version of ereuse.org workbench that this devicehub """The minimum version of ereuse.org workbench that this devicehub
accepts. we recommend not changing this value. accepts. we recommend not changing this value.
""" """
WORKBENCH_LITE = ["2022.03.00"] WORKBENCH_LITE = ["V1"]
TMP_SNAPSHOTS = config('TMP_SNAPSHOTS', '/tmp/snapshots') TMP_SNAPSHOTS = config('TMP_SNAPSHOTS', '/tmp/snapshots')
TMP_LIVES = config('TMP_LIVES', '/tmp/lives') TMP_LIVES = config('TMP_LIVES', '/tmp/lives')
@ -61,11 +71,7 @@ class DevicehubConfig(Config):
"""This var is for save a snapshots in json format when fail something""" """This var is for save a snapshots in json format when fail something"""
API_DOC_CONFIG_TITLE = 'Devicehub' API_DOC_CONFIG_TITLE = 'Devicehub'
API_DOC_CONFIG_VERSION = '0.2' API_DOC_CONFIG_VERSION = '0.2'
API_DOC_CONFIG_COMPONENTS = { API_DOC_CONFIG_COMPONENTS = {'securitySchemes': {'bearerAuth': TokenAuth.API_DOCS}}
'securitySchemes': {
'bearerAuth': TokenAuth.API_DOCS
}
}
API_DOC_CLASS_DISCRIMINATOR = 'type' API_DOC_CLASS_DISCRIMINATOR = 'type'
PRICE_SOFTWARE = PriceSoftware.Ereuse PRICE_SOFTWARE = PriceSoftware.Ereuse

View File

@ -1,10 +1,11 @@
{ {
"timestamp": "2022-03-31T19:09:57.167164", "timestamp": "2022-03-31T19:09:57.167164",
"type": "Snapshot", "type": "Snapshot",
"uuid": "cdecaf47-6e32-4ccb-b689-95c064d8c513", "uuid": "cdecaf47-6e32-4ccb-b689-95c064d8c514",
"wbid": "MLKO1Y0R55XZM051WQ5KJM01RY44Q", "wbid": "MLKO1Y0R55XZM051WQ5KJM01RY44Q",
"software": "Workbench", "software": "Workbench",
"version": "2022.03.00", "version": "2022.03.00",
"schema_version": "V1",
"data": { "data": {
"lshw": { "lshw": {
"id": "__", "id": "__",