lemur/lemur/dns_providers/models.py

42 lines
1.4 KiB
Python
Raw Normal View History

2018-05-29 19:22:52 +02:00
from sqlalchemy import Column, Integer, String, text, Text
2018-04-11 01:04:07 +02:00
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy.orm import relationship
2018-04-11 01:04:07 +02:00
from sqlalchemy_utils import ArrowType
from lemur.database import db
2018-04-27 20:18:41 +02:00
from lemur.plugins.base import plugins
2018-05-07 18:58:24 +02:00
from lemur.utils import Vault
2018-04-11 01:04:07 +02:00
class DnsProvider(db.Model):
2019-05-16 16:57:02 +02:00
__tablename__ = "dns_providers"
id = Column(Integer(), primary_key=True)
2018-04-12 00:56:00 +02:00
name = Column(String(length=256), unique=True, nullable=True)
2018-05-29 19:22:52 +02:00
description = Column(Text(), nullable=True)
2018-04-12 00:56:00 +02:00
provider_type = Column(String(length=256), nullable=True)
2018-05-07 18:58:24 +02:00
credentials = Column(Vault, nullable=True)
2018-04-12 00:56:00 +02:00
api_endpoint = Column(String(length=256), nullable=True)
2019-05-16 16:57:02 +02:00
date_created = Column(ArrowType(), server_default=text("now()"), nullable=False)
2018-04-12 00:56:00 +02:00
status = Column(String(length=128), nullable=True)
options = Column(JSON, nullable=True)
domains = Column(JSON, nullable=True)
2019-05-16 16:57:02 +02:00
certificates = relationship(
"Certificate",
backref="dns_provider",
foreign_keys="Certificate.dns_provider_id",
lazy="dynamic",
)
2018-04-27 20:18:41 +02:00
def __init__(self, name, description, provider_type, credentials):
self.name = name
self.description = description
self.provider_type = provider_type
self.credentials = credentials
@property
def plugin(self):
return plugins.get(self.plugin_name)
def __repr__(self):
return "DnsProvider(name={name})".format(name=self.name)