# Path: aiohttp_json_api/common.py
# JSONAPI = 'jsonapi'
# JSONAPI_CONTENT_TYPE = 'application/vnd.api+json'
# JSONAPI_CONTENT_TYPE_PARSED = parse_media_range(JSONAPI_CONTENT_TYPE)
# ALLOWED_MEMBER_NAME_RULE = \
#     r'[a-zA-Z0-9]([a-zA-Z0-9\-_]+[a-zA-Z0-9]|[a-zA-Z0-9]?)'
# ALLOWED_MEMBER_NAME_REGEX = re.compile('^' + ALLOWED_MEMBER_NAME_RULE + '$')
#     ASC = '+'
#     DESC = '-'
#     BEFORE_DESERIALIZATION = auto()
#     AFTER_DESERIALIZATION = auto()
#     BEFORE_SERIALIZATION = auto()
#     AFTER_SERIALIZATION = auto()
#     GET = auto()
#     POST = auto()
#     PATCH = auto()
#     DELETE = auto()
#     NEVER = auto()
#     ALWAYS = GET | POST | PATCH | DELETE
#     CREATE = POST
#     UPDATE = PATCH
#     TO_ONE = auto()
#     TO_MANY = auto()
# class SortDirection(Enum):
# class Step(Enum):
# class Event(Flag):
# class Relation(Enum):
# 
# Path: aiohttp_json_api/typings.py



import collections
import inspect
from .common import ResourceID
from .typings import ResourceIdentifier
        Get schema for type or resource class type.

        :param key: Type string or resource class.
        :return: Schema instance
        """
        return super(Registry, self).__getitem__(
            key if isinstance(key, str) or inspect.isclass(key) else type(key)
        )

    def ensure_identifier(self, obj, asdict=False) -> ResourceIdentifier:
        """
        Return the identifier object for the *resource*.

        (:class:`ResourceID <.common.ResourceID>`)

        .. code-block:: python3

            >>> registry.ensure_identifier({'type': 'something', 'id': 123})
            ResourceID(type='something', id='123')

        :arg obj:
            A two tuple ``(typename, id)``, a resource object or a resource
            document, which contains the *id* and *type* key
            ``{"type": ..., "id": ...}``.
        :arg bool asdict:
            Return ResourceID as dictionary if true
        """
        if isinstance(obj, collections.Sequence) and len(obj) == 2:
            result = ResourceID(str(obj[0]), str(obj[1]))
        elif isinstance(obj, collections.Mapping):

# Path: aiohttp_json_api/common.py
# JSONAPI = 'jsonapi'
# JSONAPI_CONTENT_TYPE = 'application/vnd.api+json'
# JSONAPI_CONTENT_TYPE_PARSED = parse_media_range(JSONAPI_CONTENT_TYPE)
# ALLOWED_MEMBER_NAME_RULE = \
#     r'[a-zA-Z0-9]([a-zA-Z0-9\-_]+[a-zA-Z0-9]|[a-zA-Z0-9]?)'
# ALLOWED_MEMBER_NAME_REGEX = re.compile('^' + ALLOWED_MEMBER_NAME_RULE + '$')
#     ASC = '+'
#     DESC = '-'
#     BEFORE_DESERIALIZATION = auto()
#     AFTER_DESERIALIZATION = auto()
#     BEFORE_SERIALIZATION = auto()
#     AFTER_SERIALIZATION = auto()
#     GET = auto()
#     POST = auto()
#     PATCH = auto()
#     DELETE = auto()
#     NEVER = auto()
#     ALWAYS = GET | POST | PATCH | DELETE
#     CREATE = POST
#     UPDATE = PATCH
#     TO_ONE = auto()
#     TO_MANY = auto()
# class SortDirection(Enum):
# class Step(Enum):
# class Event(Flag):
# class Relation(Enum):
# 
# Path: aiohttp_json_api/typings.py



# Path: aiohttp_json_api/registry.py
import collections
import inspect
from .common import ResourceID
from .typings import ResourceIdentifier

        Get schema for type or resource class type.

        :param key: Type string or resource class.
        :return: Schema instance
        """
        return super(Registry, self).__getitem__(
            key if isinstance(key, str) or inspect.isclass(key) else type(key)
        )

    def ensure_identifier(self, obj, asdict=False) -> ResourceIdentifier:
        """
        Return the identifier object for the *resource*.

        (:class:`ResourceID <.common.ResourceID>`)

        .. code-block:: python3

            >>> registry.ensure_identifier({'type': 'something', 'id': 123})
            ResourceID(type='something', id='123')

        :arg obj:
            A two tuple ``(typename, id)``, a resource object or a resource
            document, which contains the *id* and *type* key
            ``{"type": ..., "id": ...}``.
        :arg bool asdict:
            Return ResourceID as dictionary if true
        """
        if isinstance(obj, collections.Sequence) and len(obj) == 2:
            result = ResourceID(str(obj[0]), str(obj[1]))
        elif isinstance(obj, collections.Mapping):

            result = ResourceID(str(obj['type']), str(obj['id']))