Example #1
0
class BanList(Collection):
    """A list of banned ids and their reason"""
    _fields = {'id': Field([NotNull()]), 'ban_reason': Field([NotNull()])}

    _validation = {
        'on_save': True,
    }

    _properties = {
        'keyOptions': {
            'allowUserKeys': True,
        }
    }

    def add_user(self, _id: int, reason: str) -> Optional[Document]:
        """Add a Chat to the DB or return an existing one.

        Args:
            _id: The id of the User
            reason: The ban reason

        Returns: The chat Document

        """
        data = {'_key': _id, 'id': _id, 'reason': reason}

        try:
            doc = self.createDocument(data)
            doc.save()
            return doc
        except CreationError:
            return None
Example #2
0
class questions(Collection):
    _fields = {
        "question": Field(),
        "answer": Field(),
        "wrong_answers": Field()

    }
Example #3
0
class Classes(Collection):
    _fields = {
        "course": Field(),
        "name": Field(),
        "credits": Field(),
        "code": Field(),
        "semester": Field()
    }
Example #4
0
class Leis(COL.Collection):
    _validation = {
        'on_save': True,
        'on_set': True,
        'allow_foreign_fields': True
    }
    _fields = {
        'texto': Field(validators=[VAL.NotNull()]),
        'identificador': Field()
    }
Example #5
0
class NetworkConnection(Edges):
    _fields = {
        "_name": Field(),
        "UtcTime": Field(),
        "EventRecordID": Field(),
        "User": Field(),
        "DestinationPort": Field(),
        "DestinationIp": Field(),
        "SourceIp": Field(),
        "SourcePort": Field(),
        "Protocol": Field(),
        "Computer": Field()  # For shardening
    }
Example #6
0
class Chats(Collection):
    """A Collection containing Telegram Chats"""
    _fields = {
        'id': Field([NotNull(), Int()]),
        'tags': Field([NotNull()]),
        'named_tags': Field([NotNull()])
    }

    _validation = {'on_save': True, 'allow_foreign_fields': True}

    _properties = {"keyOptions": {"allowUserKeys": True}}

    def add_chat(self, chat_id: int) -> Optional[Document]:
        """Add a Chat to the DB or return an existing one.

        Args:
            chat_id: The id of the chat

        Returns: The chat Document

        """
        data = {
            '_key': str(chat_id),
            'id': chat_id,
            'tags': [],
            'named_tags': {}
        }
        try:
            doc = self.createDocument(data)
            doc.save()
            return doc
        except CreationError:
            return None

    def get_chat(self, chat_id: int) -> Document:
        """Return a Chat document

        Args:
            chat_id: The id of the chat

        Returns: The chat Document

        """
        try:
            return self[chat_id]
        except DocumentNotFoundError:
            return self.add_chat(chat_id)
Example #7
0
class CreateNewProcess(Edges):
    _fields = {
        "_name": Field(),
        "UtcTime": Field(),
        "EventRecordID": Field(),
        "CurrentDirectory": Field(),
        "User": Field(),
        "CommandLine": Field(),
        "Hashes": Field(),
        "Computer": Field()  # For shardening
    }
Example #8
0
class SysmonProcess(Collection):
    _fields = {
        "_name": Field(),
        "Image": Field(),
        "ProcessId": Field(),
        "ProcessGuid": Field(),
        "User": Field(),
        "ProcessName": Field(),
        "LogonGuid": Field(),
        "Computer": Field()  # For shardening
    }
Example #9
0
class ProcessAccessed(Edges):
    _fields = {
        "_name": Field(),
        "UtcTime": Field(),
        "EventRecordID": Field(),
        "User": Field(),
        "CallTrace": Field(),
        "TargetImage": Field(),
        "Computer": Field()  # For shardening
    }
Example #10
0
class RegistryEvent(Edges):
    _fields = {
        "_name": Field(),
        "UtcTime": Field(),
        "EventRecordID": Field(),
        "User": Field(),
        "EventType": Field(),
        "Computer": Field()  # For shardening
    }
Example #11
0
class AutobahnBlacklist(Collection):
    """Base class for all types of Blacklists."""
    _fields = {
        'string': Field([NotNull()]),
    }

    _validation = {
        'on_save': True,
    }

    _properties = {
        'keyOptions': {
            'allowUserKeys': False,
            'type': 'autoincrement',
            'offset': '1'
        }
    }

    def add_string(self, string: str) -> Optional[Document]:
        """Add a Chat to the DB or return an existing one.

        Args:
            string: The id of the chat

        Returns: The chat Document

        """
        data = {'string': string}

        try:
            doc = self.createDocument(data)
            doc.save()
            return doc
        except CreationError:
            return None

    def get_all(self) -> Dict[str, str]:
        """Get all strings in the Blacklist."""
        return {doc['string']: doc['_key'] for doc in self.fetchAll()}
Example #12
0
class RegistryObject(Collection):
    _fields = {
        "_name": Field(),
        "Path": Field(),
        "Computer": Field()  # For shardening
    }
Example #13
0
class Users(Collection):
    _fields = {'uname': Field(), 'status': Field(), 'likes': Field()}
Example #14
0
class Members(Edges):

    _fields = {
        'joinDate': Field(validators=[VAL.NotNull(), validation.String_val()]),
        'position': Field(validators=[VAL.NotNull()])
    }
Example #15
0
class NetworkObject(Collection):
    _fields = {
        "_name": Field(),
        "Ip": Field(),
        "Computer": Field()  # For shardening
    }
Example #16
0
class Match(Edges):
    _fields = {'strength': Field()}
Example #17
0
class Response(Collection):
    _fields = {'code': Field()}
Example #18
0
class Users(Collection):
    _fields = {"username": Field()}
Example #19
0
class Friends(Edges):
    _fields = {
        'friend': Field(validators=[VAL.NotNull(), validation.Boolean_val()])
    }
Example #20
0
class contains(Edges):
    _fields = {
        "correct_answer_count":Field(),
        "wrong_answer_count":Field()
    }
Example #21
0
class HasSeen(Edges):
    _fields = {"date": Field()}
Example #22
0
class Question(Collection):
    _fields = {'code': Field()}
Example #23
0
class Seasons(Collection):
    _fields = {
        "number": Field(),
        "description": Field(),
    }
Example #24
0
class Series(Collection):
    _fields = {"title": Field(), "genre": Field()}
Example #25
0
class Relacao(Edges):
    _fields = {"tipo": Field()}
Example #26
0
class Requirements(Edges):
    _fields = {"label": Field()}
Example #27
0
class Episodes(Collection):
    _fields = {
        "number": Field(),
        "description": Field(),
    }
Example #28
0
class Users(Collection):
    _fields = {'uname': Field()}
Example #29
0
class revisions(Collection):
    _fields = {
        "date": Field()
    }
Example #30
0
class Follows(Edges):
    _fields = {"start_date": Field()}