# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_core/utils/time_functions.py
# class TimeFunctions:
#     @staticmethod
#     def get_timestamp():
#         # We remove the microsecond part of the timestamp here since mongoengine can not handle it correctly and test cases fail due to the lost precision
#         return datetime.now(utc).replace(microsecond=0)
# 
# Path: mass_flask_core/models/analysis_system.py
# class AnalysisSystem(db.Document):
#     identifier_name = StringField(min_length=3, max_length=50, unique=True, required=True)
#     verbose_name = StringField(max_length=200, required=True)
#     information_text = StringField()
#     tag_filter_expression = StringField(max_length=400, required=True, default='')
# 
#     meta = {
#         'ordering': ['identifier_name'],
#         'indexes': ['identifier_name']
#     }
# 
#     def __repr__(self):
#         return '[AnalysisSystem] {}'.format(self.identifier_name)
# 
#     def __str__(self):
#         return self.__repr__()
# 
# Path: mass_flask_core/models/tlp_level.py
# class TLPLevelField(IntField):
#     TLP_LEVEL_WHITE = 0  # Access without login
#     TLP_LEVEL_GREEN = 1  # Access with login
#     TLP_LEVEL_AMBER = 2  # Access only for especially authorized users of same group
#     TLP_LEVEL_RED = 3    # Access only for explicitly mentioned users/groups
# 
#     def __init__(self, *args, **kwargs):
#         kwargs['choices'] = [
#             TLPLevelField.TLP_LEVEL_WHITE,
#             TLPLevelField.TLP_LEVEL_GREEN,
#             TLPLevelField.TLP_LEVEL_AMBER,
#             TLPLevelField.TLP_LEVEL_RED
#         ]
#         super(TLPLevelField, self).__init__(*args, **kwargs)


from uuid import uuid4
from flask_modular_auth import AbstractAuthEntity
from mass_flask_config.app import db
from mongoengine import StringField, DateTimeField, ReferenceField
from mass_flask_core.utils import TimeFunctions
from .analysis_system import AnalysisSystem
from .tlp_level import TLPLevelField
import datetime


def _gen_uuid():
    return str(uuid4())


class AnalysisSystemInstance(db.Document, AbstractAuthEntity):
    @property
    def is_authenticated(self):
        return True

    def get_roles(self):
        return ['analysis_system_instance']

    @property
    def max_tlp_level(self):

# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_core/utils/time_functions.py
# class TimeFunctions:
#     @staticmethod
#     def get_timestamp():
#         # We remove the microsecond part of the timestamp here since mongoengine can not handle it correctly and test cases fail due to the lost precision
#         return datetime.now(utc).replace(microsecond=0)
# 
# Path: mass_flask_core/models/analysis_system.py
# class AnalysisSystem(db.Document):
#     identifier_name = StringField(min_length=3, max_length=50, unique=True, required=True)
#     verbose_name = StringField(max_length=200, required=True)
#     information_text = StringField()
#     tag_filter_expression = StringField(max_length=400, required=True, default='')
# 
#     meta = {
#         'ordering': ['identifier_name'],
#         'indexes': ['identifier_name']
#     }
# 
#     def __repr__(self):
#         return '[AnalysisSystem] {}'.format(self.identifier_name)
# 
#     def __str__(self):
#         return self.__repr__()
# 
# Path: mass_flask_core/models/tlp_level.py
# class TLPLevelField(IntField):
#     TLP_LEVEL_WHITE = 0  # Access without login
#     TLP_LEVEL_GREEN = 1  # Access with login
#     TLP_LEVEL_AMBER = 2  # Access only for especially authorized users of same group
#     TLP_LEVEL_RED = 3    # Access only for explicitly mentioned users/groups
# 
#     def __init__(self, *args, **kwargs):
#         kwargs['choices'] = [
#             TLPLevelField.TLP_LEVEL_WHITE,
#             TLPLevelField.TLP_LEVEL_GREEN,
#             TLPLevelField.TLP_LEVEL_AMBER,
#             TLPLevelField.TLP_LEVEL_RED
#         ]
#         super(TLPLevelField, self).__init__(*args, **kwargs)


# Path: mass_flask_core/models/analysis_system_instance.py
from uuid import uuid4
from flask_modular_auth import AbstractAuthEntity
from mass_flask_config.app import db
from mongoengine import StringField, DateTimeField, ReferenceField
from mass_flask_core.utils import TimeFunctions
from .analysis_system import AnalysisSystem
from .tlp_level import TLPLevelField
import datetime



def _gen_uuid():
    return str(uuid4())


class AnalysisSystemInstance(db.Document, AbstractAuthEntity):
    @property
    def is_authenticated(self):
        return True

    def get_roles(self):
        return ['analysis_system_instance']

    @property
    def max_tlp_level(self):

        return TLPLevelField.TLP_LEVEL_WHITE