# Path: sevenbridges/errors.py
# class ReadOnlyPropertyError(SbgError):
#     def __init__(self, message):
#         super().__init__(
#             code=-1, status=-1, message=message
#         )
# 
# class ValidationError(SbgError):
#     def __init__(self, message):
#         super().__init__(
#             code=-1, status=-1, message=message
#         )


from uuid import UUID
from datetime import datetime
from sevenbridges.errors import ReadOnlyPropertyError, ValidationError


# noinspection PyProtectedMember
class CompoundField(Field):
    def __init__(self, cls, read_only, name=None, validator=None):
        super().__init__(
            name=name, read_only=read_only, validator=validator
        )
        self.cls = cls

    def __get__(self, instance, owner):
        data = instance._data[self.name]
        # empty is used for read only fields, None all for others
        if data is not Field.EMPTY and data is not None:
            return self.cls(api=instance._api, _parent=instance, **data)
        else:
            return None


# noinspection PyProtectedMember
class CompoundListField(Field):
    def __init__(self, cls, read_only, name=None):
        super().__init__(name=name, read_only=read_only)
        self.cls = cls

    def __get__(self, instance, owner):
        data = instance._data[self.name]
        # empty is used for read only fields, None for all others
        if data is not Field.EMPTY and data is not None:
            return [self.cls(api=instance._api, **item) for item in data]

# Path: sevenbridges/errors.py
# class ReadOnlyPropertyError(SbgError):
#     def __init__(self, message):
#         super().__init__(
#             code=-1, status=-1, message=message
#         )
# 
# class ValidationError(SbgError):
#     def __init__(self, message):
#         super().__init__(
#             code=-1, status=-1, message=message
#         )


# Path: sevenbridges/meta/fields.py
from uuid import UUID
from datetime import datetime
from sevenbridges.errors import ReadOnlyPropertyError, ValidationError



# noinspection PyProtectedMember
class CompoundField(Field):
    def __init__(self, cls, read_only, name=None, validator=None):
        super().__init__(
            name=name, read_only=read_only, validator=validator
        )
        self.cls = cls

    def __get__(self, instance, owner):
        data = instance._data[self.name]
        # empty is used for read only fields, None all for others
        if data is not Field.EMPTY and data is not None:
            return self.cls(api=instance._api, _parent=instance, **data)
        else:
            return None


# noinspection PyProtectedMember
class CompoundListField(Field):
    def __init__(self, cls, read_only, name=None):
        super().__init__(name=name, read_only=read_only)
        self.cls = cls

    def __get__(self, instance, owner):
        data = instance._data[self.name]
        # empty is used for read only fields, None for all others
        if data is not Field.EMPTY and data is not None:
            return [self.cls(api=instance._api, **item) for item in data]

        else: