misp-fixevent-webhook/models.py

28 lines
938 B
Python
Raw Normal View History

2025-02-13 16:41:25 -03:00
from sqlalchemy import Column, Integer, String, UniqueConstraint, Date, DateTime
from sqlalchemy.orm import declarative_base
from datetime import datetime, timezone
# Crear la base declarativa
Base = declarative_base()
# Se define modelo de eventos modificados al procesar
class ModificadosEv(Base):
__tablename__ = "modificados_ev"
id = Column(Integer, primary_key=True, autoincrement=True)
evento_uuid = Column(String, nullable=False)
publicado_fecha = Column(DateTime, nullable=False)
attribute_count = Column(Integer, nullable=False)
__table_args__ = (
UniqueConstraint('evento_uuid', 'attribute_count', name='ev_attr'),
)
def to_dict(self):
return {
"id": self.id,
"evento_uuid": self.evento_uuid,
"publicado_fecha": self.publicado_fecha, # Se mantendrá como datetime
"attribute_count": self.attribute_count
}