Initial Commit
This commit is contained in:
0
api/app/models/common/__init__.py
Normal file
0
api/app/models/common/__init__.py
Normal file
9
api/app/models/common/base.py
Normal file
9
api/app/models/common/base.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from helpers.database import db
|
||||
|
||||
from safrs import SAFRSBase
|
||||
from safrs.api_methods import search
|
||||
|
||||
|
||||
class BaseModel(SAFRSBase, db.Model):
|
||||
__abstract__ = True
|
||||
SAFRSBase.search = search
|
||||
0
api/app/models/common/core/__init__.py
Normal file
0
api/app/models/common/core/__init__.py
Normal file
21
api/app/models/common/core/contour.py
Normal file
21
api/app/models/common/core/contour.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Column, String, Integer
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from models.common.base import BaseModel
|
||||
|
||||
|
||||
class contour(BaseModel):
|
||||
"""
|
||||
description: Technological infrastructure contours.
|
||||
"""
|
||||
__tablename__ = "tcc_contours"
|
||||
_s_collection_name = "contours"
|
||||
_s_class_name = "contours"
|
||||
exclude_rels = ["vcenter", "pcentral"]
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
|
||||
name = Column(String(64), unique=True, index=True, nullable=False)
|
||||
description = Column(String(255))
|
||||
|
||||
vcenter = relationship("vcenter", back_populates="contour")
|
||||
pcentral = relationship("pcentral", back_populates="contour")
|
||||
27
api/app/models/common/core/environment.py
Normal file
27
api/app/models/common/core/environment.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from sqlalchemy import Column, String, Integer
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from models.common.base import BaseModel
|
||||
|
||||
|
||||
class environment(BaseModel):
|
||||
"""
|
||||
description: Technological infrastructure environments.
|
||||
"""
|
||||
__tablename__ = "tcc_environments"
|
||||
_s_collection_name = "environments"
|
||||
_s_class_name = "environment"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
|
||||
name = Column(String(32), unique=True, index=True, nullable=False)
|
||||
color = Column(String(7), index=False, nullable=True)
|
||||
|
||||
cluster = relationship("cluster", back_populates="environment")
|
||||
pelement = relationship("pelement", back_populates="environment")
|
||||
|
||||
def to_dict(self):
|
||||
result = BaseModel.to_dict(self)
|
||||
|
||||
result['name'] = result['name'].upper()
|
||||
|
||||
return result
|
||||
21
api/app/models/common/core/timestamps.py
Normal file
21
api/app/models/common/core/timestamps.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, Integer, DateTime
|
||||
|
||||
from models.common.base import BaseModel
|
||||
|
||||
|
||||
class timestamp(BaseModel):
|
||||
"""
|
||||
description: Timestamps.
|
||||
"""
|
||||
__tablename__ = "tcc_timestamps"
|
||||
_s_collection_name = "timestamps"
|
||||
_s_class_name = "timestamps"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
|
||||
name = Column(String(64), unique=True, nullable=False)
|
||||
timestamp = Column(
|
||||
DateTime,
|
||||
default=datetime.utcnow,
|
||||
onupdate=datetime.utcnow
|
||||
)
|
||||
Reference in New Issue
Block a user