# Path: devicecloud/apibase.py
# class APIBase(object):
#     """Base class for all API Classes
# 
#     :type _conn: devicecloud.DeviceCloudConnection
#     """
#     def __init__(self, conn):
#         self._conn = conn


from devicecloud.apibase import APIBase
from xml.etree import ElementTree as ET
import six


class AsyncRequestProxy(object):
    """An object representing an asynychronous SCI request.

    Can be used for polling the status of the corresponding request.

    :ivar job_id: the ID in device cloud of the job
    :ivar response: the response to the request if completed
    :ivar completed: True if the request has completed, False otherwise; queries on read
    """
    def __init__(self, job_id, conn):
        self.job_id = job_id
        self._conn = conn
        self.response = None

    @property
    def completed(self):
        if self.response is not None:
            return True
        resp = self._conn.get('/ws/sci/{0}'.format(self.job_id))
        dom = ET.fromstring(resp.content)
        status = dom.find('.//status')
        if status is not None and status.text == 'complete':
            self.response = resp.content
            return True
        else:
            return False



# 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/sci.py
from devicecloud.apibase import APIBase
from xml.etree import ElementTree as ET
import six



class AsyncRequestProxy(object):
    """An object representing an asynychronous SCI request.

    Can be used for polling the status of the corresponding request.

    :ivar job_id: the ID in device cloud of the job
    :ivar response: the response to the request if completed
    :ivar completed: True if the request has completed, False otherwise; queries on read
    """
    def __init__(self, job_id, conn):
        self.job_id = job_id
        self._conn = conn
        self.response = None

    @property
    def completed(self):
        if self.response is not None:
            return True
        resp = self._conn.get('/ws/sci/{0}'.format(self.job_id))
        dom = ET.fromstring(resp.content)
        status = dom.find('.//status')
        if status is not None and status.text == 'complete':
            self.response = resp.content
            return True
        else:
            return False



class ServerCommandInterfaceAPI(APIBase):