from mesh.standard import Resource
from scheme.fields import *

from tap.constants import STATUSES
from tap.structures import PermissionStructure


__all__ = ('ResourceRegistry',)


class ResourceRegistry(Resource):
    """Resource registry resource"""
    name = 'resourceregistry'
    requests = 'create delete get put query update'
    version = 1

    class schema:
        id = Token(segments=4, oncreate=True) #bundle:resource:method:subject
        method = Token(nonempty=True, operators='equal')
        path = Text(nonempty=True, operators='equal in')
        status = Enumeration(
                STATUSES, nonnull=True, default='active', operators='equal')
        permissions = Sequence(
                PermissionStructure.clone(), deferred=True, readonly=True)
