# Path: baroque/entities/eventtype.py
# class EventType:
#     """The type of an event, describing its semantics and content.
# 
#     Args:
#         jsonschema (str): the JSON schema string describing the content of the
#          events having this type
#         description (str, optional): the description of this event type
#         owner (str, optional): the owner of this event type
# 
#     """
# 
#     def __init__(self, jsonschema, description=None, owner=None):
#         assert jsonschema is not None
#         assert isinstance(jsonschema, str)
#         self.jsonschema = jsonschema
#         self.owner = owner
#         self.description = description
#         self.tags = set()
# 
#     @staticmethod
#     def validate(evt, evttype):
#         """Validates the content of an event against the JSON schema of its type.
# 
#         Args:
#             evt (:obj:`baroque.entities.event.Event`): the event to be validated
#             evttype (:obj:`baroque.entities.eventtype.EventType`): the type of
#             the event that needs to be validated
# 
#         Returns:
#             ``True`` if validation is OK, ``False`` otherwise
# 
#         """
#         try:
#             assert evt.type == evttype
#             check(loads(evt.json()), loads(evttype.jsonschema))
#             return True
#         except (AssertionError, ValidationError):
#             return False
# 
#     def json(self):
#         """Dumps this object to a JSON string.
# 
#         Returns:
#             str
# 
#         """
#         data = dict(jsonschema=self.jsonschema, owner=self.owner,
#                     description=self.description, tags=list(self.tags))
#         return dumps(data)
# 
#     def md5(self):
#         """Returns the MD5 hash of this object.
# 
#         Returns:
#             str
# 
#         """
#         m = hashlib.md5()
#         m.update(self.json().encode('utf-8'))
#         return m.hexdigest()
# 
#     def __repr__(self):
#         return '<{}.{} - description: {}>'.format(
#             __name__,
#             self.__class__.__name__,
#             self.description or 'None'
#         )
# 
# Path: baroque/utils/timestamp.py
# TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
# def utc_now():
# def stringify(timestamp):


import uuid
import hashlib
from json import dumps
from .eventtype import EventType
from baroque.utils import timestamp as ts
        self.owner = owner
        self.status = EventStatus.UNPUBLISHED
        self.description = description
        self.payload = payload
        self.tags = set()
        self.timestamp = None
        self.touch()

    def set_published(self):
        """Sets the status of this event to published."""
        self.status = EventStatus.PUBLISHED

    def set_unpublished(self):
        """Sets the status of this event to unpublished."""
        self.status = EventStatus.UNPUBLISHED

    def touch(self):
        """Sets the current time as timestamp of this event"""
        self.timestamp = ts.utc_now()

    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id, type=self.type.json(),
                    owner=self.owner, status=self.status,
                    description=self.description, payload=self.payload,

# Path: baroque/entities/eventtype.py
# class EventType:
#     """The type of an event, describing its semantics and content.
# 
#     Args:
#         jsonschema (str): the JSON schema string describing the content of the
#          events having this type
#         description (str, optional): the description of this event type
#         owner (str, optional): the owner of this event type
# 
#     """
# 
#     def __init__(self, jsonschema, description=None, owner=None):
#         assert jsonschema is not None
#         assert isinstance(jsonschema, str)
#         self.jsonschema = jsonschema
#         self.owner = owner
#         self.description = description
#         self.tags = set()
# 
#     @staticmethod
#     def validate(evt, evttype):
#         """Validates the content of an event against the JSON schema of its type.
# 
#         Args:
#             evt (:obj:`baroque.entities.event.Event`): the event to be validated
#             evttype (:obj:`baroque.entities.eventtype.EventType`): the type of
#             the event that needs to be validated
# 
#         Returns:
#             ``True`` if validation is OK, ``False`` otherwise
# 
#         """
#         try:
#             assert evt.type == evttype
#             check(loads(evt.json()), loads(evttype.jsonschema))
#             return True
#         except (AssertionError, ValidationError):
#             return False
# 
#     def json(self):
#         """Dumps this object to a JSON string.
# 
#         Returns:
#             str
# 
#         """
#         data = dict(jsonschema=self.jsonschema, owner=self.owner,
#                     description=self.description, tags=list(self.tags))
#         return dumps(data)
# 
#     def md5(self):
#         """Returns the MD5 hash of this object.
# 
#         Returns:
#             str
# 
#         """
#         m = hashlib.md5()
#         m.update(self.json().encode('utf-8'))
#         return m.hexdigest()
# 
#     def __repr__(self):
#         return '<{}.{} - description: {}>'.format(
#             __name__,
#             self.__class__.__name__,
#             self.description or 'None'
#         )
# 
# Path: baroque/utils/timestamp.py
# TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
# def utc_now():
# def stringify(timestamp):


# Path: baroque/entities/event.py
import uuid
import hashlib
from json import dumps
from .eventtype import EventType
from baroque.utils import timestamp as ts

        self.owner = owner
        self.status = EventStatus.UNPUBLISHED
        self.description = description
        self.payload = payload
        self.tags = set()
        self.timestamp = None
        self.touch()

    def set_published(self):
        """Sets the status of this event to published."""
        self.status = EventStatus.PUBLISHED

    def set_unpublished(self):
        """Sets the status of this event to unpublished."""
        self.status = EventStatus.UNPUBLISHED

    def touch(self):
        """Sets the current time as timestamp of this event"""
        self.timestamp = ts.utc_now()

    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id, type=self.type.json(),
                    owner=self.owner, status=self.status,
                    description=self.description, payload=self.payload,

                    tags=list(self.tags), timestamp=ts.stringify(self.timestamp))