# Path: devicecloud/apibase.py
# class APIBase(object):
#     """Base class for all API Classes
# 
#     :type _conn: devicecloud.DeviceCloudConnection
#     """
#     def __init__(self, conn):
#         self._conn = conn
# 
# Path: devicecloud/conditions.py
# class Attribute(object):
#     """An attribute is a piece of data on which we may perform comparisons
# 
#     Comparisons performed to attributes will in turn generate new
#     :class:`.Comparison` instances.
#     """
# 
#     def __init__(self, name):
#         self.name = name
# 
#     def __str__(self):
#         return self.name
# 
#     def __gt__(self, value):
#         return Comparison(self, '>', value)
# 
#     def __lt__(self, value):
#         return Comparison(self, '<', value)
# 
#     def __eq__(self, value):
#         return Comparison(self, '=', value)
# 
#     def like(self, value):
#         return Comparison(self, ' like ', value)
# 
# class Expression(object):
#     r"""A condition is an evaluable filter
# 
#     Examples of conditions would include the following:
#     * fdType='file'
#     * fdName like 'sample%gas'
# 
#     Conditions may also be compound.  E.g.
#     * (fdType='file' and fdName like 'sample%gas')
# 
#     """
# 
#     def __init__(self):
#         pass
# 
#     def __and__(self, rhs):
#         return Combination(self, " and ", rhs)
# 
#     def __or__(self, rhs):
#         return Combination(self, " or ", rhs)
# 
#     and_ = __and__  # alternate syntax
#     or_ = __or__  # alternate syntax
# 
#     def compile(self):
#         raise NotImplementedError("Should be implemented in subclass")
# 
# Path: devicecloud/util.py
# def iso8601_to_dt(iso8601):
#     """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object"""
#     # We could just use arrow.get() but that is more permissive than we actually want.
#     # Internal (but still public) to arrow is the actual parser where we can be
#     # a bit more specific
#     parser = DateTimeParser()
#     try:
#         arrow_dt = arrow.Arrow.fromdatetime(parser.parse_iso(iso8601))
#         return arrow_dt.to('utc').datetime
#     except ParserError as pe:
#         raise ValueError("Provided was not a valid ISO8601 string: %r" % pe)
# 
# def validate_type(input, *types):
#     """Raise TypeError if the type of ``input`` is one of the args
# 
#     If the input value is one of the types specified, just return
#     the input value.
# 
#     """
#     if not isinstance(input, types):
#         raise TypeError("Input expected to one of following types: %s" % (types, ))
#     return input


import base64
import six
from devicecloud.apibase import APIBase
from devicecloud.conditions import Attribute, Expression
from devicecloud.util import iso8601_to_dt, validate_type
        :returns: Data associated with this object or None if none exists
        :rtype: str (Python2)/bytes (Python3) or None

        """
        # NOTE: we assume that the "embed" option is used
        base64_data = self._json_data.get("fdData")
        if base64_data is None:
            return None
        else:
            # need to convert to bytes() with python 3
            return base64.decodestring(six.b(base64_data))

    def get_type(self):
        """Get the type (file/directory) of this object"""
        return self._json_data["fdType"]

    def get_last_modified_date(self):
        """Get the last modified datetime of this object"""
        return iso8601_to_dt(self._json_data["fdLastModifiedDate"])

    def get_content_type(self):
        """Get the content type of this object (or None)"""
        return self._json_data["fdContentType"]

    def get_customer_id(self):
        """Get the customer ID associated with this object"""
        return self._json_data["cstId"]

    def get_created_date(self):
        """Get the datetime this object was created"""

# Path: devicecloud/apibase.py
# class APIBase(object):
#     """Base class for all API Classes
# 
#     :type _conn: devicecloud.DeviceCloudConnection
#     """
#     def __init__(self, conn):
#         self._conn = conn
# 
# Path: devicecloud/conditions.py
# class Attribute(object):
#     """An attribute is a piece of data on which we may perform comparisons
# 
#     Comparisons performed to attributes will in turn generate new
#     :class:`.Comparison` instances.
#     """
# 
#     def __init__(self, name):
#         self.name = name
# 
#     def __str__(self):
#         return self.name
# 
#     def __gt__(self, value):
#         return Comparison(self, '>', value)
# 
#     def __lt__(self, value):
#         return Comparison(self, '<', value)
# 
#     def __eq__(self, value):
#         return Comparison(self, '=', value)
# 
#     def like(self, value):
#         return Comparison(self, ' like ', value)
# 
# class Expression(object):
#     r"""A condition is an evaluable filter
# 
#     Examples of conditions would include the following:
#     * fdType='file'
#     * fdName like 'sample%gas'
# 
#     Conditions may also be compound.  E.g.
#     * (fdType='file' and fdName like 'sample%gas')
# 
#     """
# 
#     def __init__(self):
#         pass
# 
#     def __and__(self, rhs):
#         return Combination(self, " and ", rhs)
# 
#     def __or__(self, rhs):
#         return Combination(self, " or ", rhs)
# 
#     and_ = __and__  # alternate syntax
#     or_ = __or__  # alternate syntax
# 
#     def compile(self):
#         raise NotImplementedError("Should be implemented in subclass")
# 
# Path: devicecloud/util.py
# def iso8601_to_dt(iso8601):
#     """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object"""
#     # We could just use arrow.get() but that is more permissive than we actually want.
#     # Internal (but still public) to arrow is the actual parser where we can be
#     # a bit more specific
#     parser = DateTimeParser()
#     try:
#         arrow_dt = arrow.Arrow.fromdatetime(parser.parse_iso(iso8601))
#         return arrow_dt.to('utc').datetime
#     except ParserError as pe:
#         raise ValueError("Provided was not a valid ISO8601 string: %r" % pe)
# 
# def validate_type(input, *types):
#     """Raise TypeError if the type of ``input`` is one of the args
# 
#     If the input value is one of the types specified, just return
#     the input value.
# 
#     """
#     if not isinstance(input, types):
#         raise TypeError("Input expected to one of following types: %s" % (types, ))
#     return input


# Path: devicecloud/filedata.py
import base64
import six
from devicecloud.apibase import APIBase
from devicecloud.conditions import Attribute, Expression
from devicecloud.util import iso8601_to_dt, validate_type

        :returns: Data associated with this object or None if none exists
        :rtype: str (Python2)/bytes (Python3) or None

        """
        # NOTE: we assume that the "embed" option is used
        base64_data = self._json_data.get("fdData")
        if base64_data is None:
            return None
        else:
            # need to convert to bytes() with python 3
            return base64.decodestring(six.b(base64_data))

    def get_type(self):
        """Get the type (file/directory) of this object"""
        return self._json_data["fdType"]

    def get_last_modified_date(self):
        """Get the last modified datetime of this object"""
        return iso8601_to_dt(self._json_data["fdLastModifiedDate"])

    def get_content_type(self):
        """Get the content type of this object (or None)"""
        return self._json_data["fdContentType"]

    def get_customer_id(self):
        """Get the customer ID associated with this object"""
        return self._json_data["cstId"]

    def get_created_date(self):
        """Get the datetime this object was created"""

        return iso8601_to_dt(self._json_data["fdCreatedDate"])