Change endpoints/common to use a data interface
This commit is contained in:
parent
aecec02b6c
commit
f976ffbdc7
4 changed files with 67 additions and 12 deletions
29
endpoints/common_models_interface.py
Normal file
29
endpoints/common_models_interface.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from abc import ABCMeta, abstractmethod
|
||||
from collections import namedtuple
|
||||
|
||||
from six import add_metaclass
|
||||
|
||||
|
||||
class User(namedtuple('User', ['uuid', 'username', 'email', 'given_name', 'family_name', 'company'])):
|
||||
"""
|
||||
User represents a user.
|
||||
"""
|
||||
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class EndpointsCommonDataInterface(object):
|
||||
"""
|
||||
Interface that represents all data store interactions required by the common endpoints lib.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_user(self, user_uuid):
|
||||
"""
|
||||
Returns the User matching the given uuid, if any or None if none.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_namespace_uuid(self, namespace_name):
|
||||
"""
|
||||
Returns the uuid of the Namespace with the given name, if any.
|
||||
"""
|
Reference in a new issue