This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/api/globalmessages_models_interface.py

54 lines
885 B
Python
Raw Normal View History

2019-11-12 16:09:47 +00:00
from abc import ABCMeta, abstractmethod
from collections import namedtuple
from six import add_metaclass
class GlobalMessage(
namedtuple('GlobalMessage', [
'uuid',
'content',
'severity',
'media_type_name',
])):
def to_dict(self):
return {
'uuid': self.uuid,
'content': self.content,
'severity': self.severity,
'media_type': self.media_type_name,
}
@add_metaclass(ABCMeta)
class GlobalMessageDataInterface(object):
"""
Data interface for globalmessages API
"""
@abstractmethod
def get_all_messages(self):
"""
Returns:
list(GlobalMessage)
"""
@abstractmethod
def create_message(self, severity, media_type_name, content):
"""
Returns:
GlobalMessage or None
"""
@abstractmethod
def delete_message(self, uuid):
"""
Returns:
void
"""