2015-08-02 00:29:34 +02:00
|
|
|
"""
|
|
|
|
.. module: lemur.sources.models
|
|
|
|
:platform: unix
|
|
|
|
:copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
|
|
|
|
:license: Apache, see LICENSE for more details.
|
|
|
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
|
|
|
"""
|
2016-07-12 17:40:49 +02:00
|
|
|
from sqlalchemy.orm import relationship
|
2016-12-01 00:11:17 +01:00
|
|
|
from sqlalchemy import Column, Integer, String, Text, Boolean
|
2015-08-02 00:29:34 +02:00
|
|
|
from sqlalchemy_utils import JSONType
|
|
|
|
from lemur.database import db
|
|
|
|
|
|
|
|
from lemur.plugins.base import plugins
|
2016-12-01 00:11:17 +01:00
|
|
|
from sqlalchemy_utils import ArrowType
|
2015-08-02 00:29:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Source(db.Model):
|
|
|
|
__tablename__ = 'sources'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
label = Column(String(32))
|
|
|
|
options = Column(JSONType)
|
|
|
|
description = Column(Text())
|
|
|
|
plugin_name = Column(String(32))
|
2015-08-02 03:31:38 +02:00
|
|
|
active = Column(Boolean, default=True)
|
2016-12-01 00:11:17 +01:00
|
|
|
last_run = Column(ArrowType)
|
2016-07-12 17:40:49 +02:00
|
|
|
endpoints = relationship("Endpoint", back_populates="source")
|
2015-08-02 00:29:34 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def plugin(self):
|
2016-07-12 17:40:49 +02:00
|
|
|
return plugins.get(self.plugin_name)
|
2016-11-16 18:30:54 +01:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "Source(label={label})".format(label=self.label)
|