<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_connected_devices(self, **kwargs):
 """List connected devices. Example usage, listing all registered devices in the catalog: .. code-block:: python filters = { 'created_at': {'$gte': datetime.datetime(2017,01,01), '$lte': datetime.datetime(2017,12,31) } } devices = api.list_connected_devices(order='asc', filters=filters) for idx, device in enumerate(devices):
 print(device) ## Other example filters # Directly connected devices (not via gateways):
 filters = { 'host_gateway': {'$eq': ''}, 'device_type': {'$eq': ''} } # Devices connected via gateways: filters = { 'host_gateway': {'$neq': ''} } # Gateway devices: filters = { 'device_type': {'$eq': 'MBED_GW'} } :param int limit: The number of devices to retrieve. :param str order: The ordering direction, ascending (asc) or descending (desc) :param str after: Get devices after/starting at given `device_id` :param filters: Dictionary of filters to apply. :returns: a list of connected :py:class:`Device` objects. :rtype: PaginatedResponse """

        # TODO(pick one of these)
        filter_or_filters = 'filter' if 'filter' in kwargs else 'filters'
        kwargs.setdefault(filter_or_filters, {}).setdefault('state', {'$eq': 'registered'})
        kwargs = self._verify_sort_options(kwargs)
        kwargs = self._verify_filters(kwargs, Device, True)
        api = self._get_api(device_directory.DefaultApi)
        return PaginatedResponse(api.device_list, lwrap_type=Device, **kwargs)