# 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 sys
import xml.etree.ElementTree as ET
import six
from devicecloud.apibase import APIBase
from devicecloud.conditions import Attribute, Expression
from devicecloud.util import iso8601_to_dt, validate_type
from xml.sax.saxutils import escape
        APIBase.__init__(self, conn)
        self._sci = sci

    def get_devices(self, condition=None, page_size=1000):
        """Iterates over each :class:`Device` for this device cloud account

        Examples::

            # get a list of all devices
            all_devices = list(dc.devicecore.get_devices())

            # build a mapping of devices by their vendor id using a
            # dict comprehension
            devices = dc.devicecore.get_devices()  # generator object
            devs_by_vendor_id = {d.get_vendor_id(): d for d in devices}

            # iterate over all devices in 'minnesota' group and
            # print the device mac and location
            for device in dc.get_devices(group_path == 'minnesota'):
                print "%s at %s" % (device.get_mac(), device.get_location())

        :param condition: An :class:`.Expression` which defines the condition
            which must be matched on the devicecore.  If unspecified,
            an iterator over all devices will be returned.
        :param int page_size: The number of results to fetch in a
            single page.  In general, the default will suffice.
        :returns: Iterator over each :class:`~Device` in this device cloud
            account in the form of a generator object.
        """


# 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/devicecore.py
import sys
import xml.etree.ElementTree as ET
import six
from devicecloud.apibase import APIBase
from devicecloud.conditions import Attribute, Expression
from devicecloud.util import iso8601_to_dt, validate_type
from xml.sax.saxutils import escape

        APIBase.__init__(self, conn)
        self._sci = sci

    def get_devices(self, condition=None, page_size=1000):
        """Iterates over each :class:`Device` for this device cloud account

        Examples::

            # get a list of all devices
            all_devices = list(dc.devicecore.get_devices())

            # build a mapping of devices by their vendor id using a
            # dict comprehension
            devices = dc.devicecore.get_devices()  # generator object
            devs_by_vendor_id = {d.get_vendor_id(): d for d in devices}

            # iterate over all devices in 'minnesota' group and
            # print the device mac and location
            for device in dc.get_devices(group_path == 'minnesota'):
                print "%s at %s" % (device.get_mac(), device.get_location())

        :param condition: An :class:`.Expression` which defines the condition
            which must be matched on the devicecore.  If unspecified,
            an iterator over all devices will be returned.
        :param int page_size: The number of results to fetch in a
            single page.  In general, the default will suffice.
        :returns: Iterator over each :class:`~Device` in this device cloud
            account in the form of a generator object.
        """


        condition = validate_type(condition, type(None), Expression, *six.string_types)