# Path: marathon/models/base.py
# class MarathonResource(MarathonObject):
# 
#     """Base Marathon resource."""
# 
#     def __repr__(self):
#         if 'id' in list(vars(self).keys()):
#             return f"{self.__class__.__name__}::{self.id}"
#         else:
#             return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json())
# 
#     def __eq__(self, other):
#         try:
#             return self.__dict__ == other.__dict__
#         except Exception:
#             return False
# 
#     def __hash__(self):
#         # Technically this class shouldn't be hashable because it often
#         # contains mutable fields, but in practice this class is used more
#         # like a record or namedtuple.
#         return hash(self.to_json())
# 
#     def __str__(self):
#         return f"{self.__class__.__name__}::" + str(self.__dict__)
# 
# class MarathonObject:
#     """Base Marathon object."""
# 
#     def __repr__(self):
#         return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json(minimal=False))
# 
#     def __eq__(self, other):
#         try:
#             return self.__dict__ == other.__dict__
#         except Exception:
#             return False
# 
#     def __hash__(self):
#         # Technically this class shouldn't be hashable because it often
#         # contains mutable fields, but in practice this class is used more
#         # like a record or namedtuple.
#         return hash(self.to_json())
# 
#     def json_repr(self, minimal=False):
#         """Construct a JSON-friendly representation of the object.
# 
#         :param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
# 
#         :rtype: dict
#         """
#         if minimal:
#             return {to_camel_case(k): v for k, v in vars(self).items() if (v or v is False or v == 0)}
#         else:
#             return {to_camel_case(k): v for k, v in vars(self).items()}
# 
#     @classmethod
#     def from_json(cls, attributes):
#         """Construct an object from a parsed response.
# 
#         :param dict attributes: object attributes from parsed response
#         """
#         return cls(**{to_snake_case(k): v for k, v in attributes.items()})
# 
#     def to_json(self, minimal=True):
#         """Encode an object as a JSON string.
# 
#         :param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
# 
#         :rtype: str
#         """
#         if minimal:
#             return json.dumps(self.json_repr(minimal=True), cls=MarathonMinimalJsonEncoder, sort_keys=True)
#         else:
#             return json.dumps(self.json_repr(), cls=MarathonJsonEncoder, sort_keys=True)
# 
# Path: marathon/util.py
# def to_datetime(timestamp):
#     if (timestamp is None or isinstance(timestamp, datetime.datetime)):
#         return timestamp
#     else:
#         for fmt in DATETIME_FORMATS:
#             try:
#                 return datetime.datetime.strptime(timestamp, fmt).replace(tzinfo=datetime.timezone.utc)
#             except ValueError:
#                 pass
#         raise ValueError(f'Unrecognized datetime format: {timestamp}')


from .base import MarathonResource, MarathonObject
from ..util import to_datetime
    :type staged_at: datetime or str
    :param started_at: when this task was started
    :type started_at: datetime or str
    :param str version: app version with which this task was started
    :type region: str
    :param region: fault domain region support in DCOS EE
    :type zone: str
    :param zone: fault domain zone support in DCOS EE
    :type role: str
    :param role: mesos role
    """

    DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'

    def __init__(self, app_id=None, health_check_results=None, host=None, id=None, ports=None, service_ports=None,
                 slave_id=None, staged_at=None, started_at=None, version=None, ip_addresses=[], state=None, local_volumes=None,
                 region=None, zone=None, role=None):
        self.app_id = app_id
        self.health_check_results = health_check_results or []
        self.health_check_results = [
            hcr if isinstance(
                hcr, MarathonHealthCheckResult) else MarathonHealthCheckResult().from_json(hcr)
            for hcr in (health_check_results or []) if any(health_check_results)
        ]
        self.host = host
        self.id = id
        self.ports = ports or []
        self.service_ports = service_ports or []
        self.slave_id = slave_id
        self.staged_at = to_datetime(staged_at)

# Path: marathon/models/base.py
# class MarathonResource(MarathonObject):
# 
#     """Base Marathon resource."""
# 
#     def __repr__(self):
#         if 'id' in list(vars(self).keys()):
#             return f"{self.__class__.__name__}::{self.id}"
#         else:
#             return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json())
# 
#     def __eq__(self, other):
#         try:
#             return self.__dict__ == other.__dict__
#         except Exception:
#             return False
# 
#     def __hash__(self):
#         # Technically this class shouldn't be hashable because it often
#         # contains mutable fields, but in practice this class is used more
#         # like a record or namedtuple.
#         return hash(self.to_json())
# 
#     def __str__(self):
#         return f"{self.__class__.__name__}::" + str(self.__dict__)
# 
# class MarathonObject:
#     """Base Marathon object."""
# 
#     def __repr__(self):
#         return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json(minimal=False))
# 
#     def __eq__(self, other):
#         try:
#             return self.__dict__ == other.__dict__
#         except Exception:
#             return False
# 
#     def __hash__(self):
#         # Technically this class shouldn't be hashable because it often
#         # contains mutable fields, but in practice this class is used more
#         # like a record or namedtuple.
#         return hash(self.to_json())
# 
#     def json_repr(self, minimal=False):
#         """Construct a JSON-friendly representation of the object.
# 
#         :param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
# 
#         :rtype: dict
#         """
#         if minimal:
#             return {to_camel_case(k): v for k, v in vars(self).items() if (v or v is False or v == 0)}
#         else:
#             return {to_camel_case(k): v for k, v in vars(self).items()}
# 
#     @classmethod
#     def from_json(cls, attributes):
#         """Construct an object from a parsed response.
# 
#         :param dict attributes: object attributes from parsed response
#         """
#         return cls(**{to_snake_case(k): v for k, v in attributes.items()})
# 
#     def to_json(self, minimal=True):
#         """Encode an object as a JSON string.
# 
#         :param bool minimal: Construct a minimal representation of the object (ignore nulls and empty collections)
# 
#         :rtype: str
#         """
#         if minimal:
#             return json.dumps(self.json_repr(minimal=True), cls=MarathonMinimalJsonEncoder, sort_keys=True)
#         else:
#             return json.dumps(self.json_repr(), cls=MarathonJsonEncoder, sort_keys=True)
# 
# Path: marathon/util.py
# def to_datetime(timestamp):
#     if (timestamp is None or isinstance(timestamp, datetime.datetime)):
#         return timestamp
#     else:
#         for fmt in DATETIME_FORMATS:
#             try:
#                 return datetime.datetime.strptime(timestamp, fmt).replace(tzinfo=datetime.timezone.utc)
#             except ValueError:
#                 pass
#         raise ValueError(f'Unrecognized datetime format: {timestamp}')


# Path: marathon/models/task.py
from .base import MarathonResource, MarathonObject
from ..util import to_datetime

    :type staged_at: datetime or str
    :param started_at: when this task was started
    :type started_at: datetime or str
    :param str version: app version with which this task was started
    :type region: str
    :param region: fault domain region support in DCOS EE
    :type zone: str
    :param zone: fault domain zone support in DCOS EE
    :type role: str
    :param role: mesos role
    """

    DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'

    def __init__(self, app_id=None, health_check_results=None, host=None, id=None, ports=None, service_ports=None,
                 slave_id=None, staged_at=None, started_at=None, version=None, ip_addresses=[], state=None, local_volumes=None,
                 region=None, zone=None, role=None):
        self.app_id = app_id
        self.health_check_results = health_check_results or []
        self.health_check_results = [
            hcr if isinstance(
                hcr, MarathonHealthCheckResult) else MarathonHealthCheckResult().from_json(hcr)
            for hcr in (health_check_results or []) if any(health_check_results)
        ]
        self.host = host
        self.id = id
        self.ports = ports or []
        self.service_ports = service_ports or []
        self.slave_id = slave_id
        self.staged_at = to_datetime(staged_at)

        self.started_at = to_datetime(started_at)