Ejemplo n.º 1
0
def create_scheduler(date, time, repeat, retry_count, retry_task, tasks):
    '''
    :param date: required if repeat is 'none'
    :param time: '2014-11-11'
    :param repeat: "none" or "mon", "tue", "wed", "thu", "fri", "sat", "sun"
    :param retry_count: retry totals
    :param retry_task: "all" or "failed"
    :param tasks: 
        struct => {
        "did": "did1",
        "product_key": "xxx",
            "attrs": {
            "attr1": val,
            "attr2": val
            }
        }
    '''
    request_body = {
        "time": time,
        "repeat": repeat,
        "task": tasks,
        "retry_count": retry_count,
        "retry_task": retry_task
    }
    if date:
        request_body['date'] = date
    url = render_url('/scheduler')
    logging.debug(url)
    logging.debug(request_body)
    return Request("POST", url, data=request_body)
Ejemplo n.º 2
0
def create_user_by_auth_data(auth_data):
    '''
    :param auth_data: struct => {'src':'baidu|sina|qq', 'uid':'2346677','token':'pnktnjyb996sj4p156gjtp4im'}
    :type: dict
    '''
    request_body = {'authData': auth_data}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 3
0
def create_scheduler(date, time, repeat, retry_count, retry_task, tasks):
    '''
    :param date: required if repeat is 'none'
    :param time: '2014-11-11'
    :param repeat: "none" or "mon", "tue", "wed", "thu", "fri", "sat", "sun"
    :param retry_count: retry totals
    :param retry_task: "all" or "failed"
    :param tasks: 
        struct => {
        "did": "did1",
        "product_key": "xxx",
            "attrs": {
            "attr1": val,
            "attr2": val
            }
        }
    '''
    request_body = {
        "time": time,
        "repeat": repeat,
        "task": tasks,
        "retry_count": retry_count,
        "retry_task": retry_task
        }
    if date:
        request_body['date'] = date
    url = render_url('/scheduler')
    logging.debug(url)
    logging.debug(request_body)
    return Request("POST", url, data=request_body)
Ejemplo n.º 4
0
def create_user_by_auth_data(auth_data):
    '''
    :param auth_data: struct => {'src':'baidu|sina|qq', 'uid':'2346677','token':'pnktnjyb996sj4p156gjtp4im'}
    :type: dict
    '''
    request_body = {'authData': auth_data}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 5
0
def update_phone_pwd_code(phone, pwd, code):
    request_body = {
        "phone": str(phone),
        "password": str(pwd),
        "code": str(pwd)
        }
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 6
0
def update_phone_pwd_code(phone, pwd, code):
    request_body = {
        "phone": str(phone),
        "password": str(pwd),
        "code": str(pwd)
    }
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 7
0
def password_reset_with(phone, code, new_pwd):
    request_body = {
        "phone": phone,
        "code": code,
        "new_pwd": new_pwd
        }
    return Request("PUT", render_url('/reset_password'), data=request_body)
Ejemplo n.º 8
0
def fetch_scheduler(skip=None, limit=None):
    '''
    :param limit: (optional)
    :param skip: (optional)
    '''
    request_body = {'limit': limit, 'skip': skip}
    url = render_url('/scheduler')
    return Request("GET", url, params=request_body)
Ejemplo n.º 9
0
def fetch_scheduler(skip=None, limit=None):
    '''
    :param limit: (optional)
    :param skip: (optional)
    '''
    request_body = {'limit':limit, 'skip':skip}
    url = render_url('/scheduler')
    return Request("GET", url, params=request_body)
Ejemplo n.º 10
0
def unbind_devices(devices):
    data_devices = []
    for did, passcode in devices:
        device = {'did': None, 'passcode': None}
        device['did'] = did
        device['passcode'] = passcode
        data_devices.append(device)
    request_body = {'devices': data_devices}
    return Request("DELETE", render_url('/bindings'), data=request_body)
Ejemplo n.º 11
0
def unbind_devices(devices):
    data_devices = []
    for did, passcode in devices:
        device = {'did': None, 'passcode': None}
        device['did'] = did
        device['passcode'] = passcode
        data_devices.append(device)
    request_body = {'devices':data_devices}
    return Request("DELETE", render_url('/bindings'), data=request_body)
Ejemplo n.º 12
0
def retrieve_device_histroy_data(did, start_ts=1349032093, end_ts=1349032093, entity=1, attr="temp", limit=20, skip=0):
    request_body = {'start_ts': start_ts,
                    'end_ts': end_ts,
                    'entity': entity,
                    'attr': attr,
                    'limit': limit,
                    'skip': skip
                    }
    url = render_url('/devdata/' + str(did))
    return Request("GET", url, params=request_body)
Ejemplo n.º 13
0
def remote_control_device(did, raw):
    '''
    :param did: did
    :type did: String

    :param raw: struct => [<byte>, <byte>, ...]
    :type raw: list
    '''
    request_body = {'raw': raw}
    url = render_url('/control/' + str(did))
    return Request("POST", url, data=request_body)
Ejemplo n.º 14
0
def retrieve_product_histroy_data(product_key, did=None, start_ts=1349032093, end_ts=1349032093, entity=1, attr="temp", limit=20, skip=0):
    request_body = {
        'product_key': product_key,
        'did':did,
        'start_ts': start_ts,
        'end_ts': end_ts,
        'entity': entity,
        'attr': attr,
        'limit': limit,
        'skip': skip
        }
    url = render_url('/devdata')
    return Request("GET", url, params=request_body)
Ejemplo n.º 15
0
def remote_control_device(did, raw):
    '''
    :param did: did
    :type did: String

    :param raw: struct => [<byte>, <byte>, ...]
    :type raw: list
    '''
    request_body = {
        'raw': raw
        }
    url = render_url('/control/' + str(did))
    return Request("POST", url, data=request_body)
Ejemplo n.º 16
0
def bind_devices(devices):
    '''
    :param devices: struct = > [('did', 'passcode', 'remark(optional)', ...]
    '''
    data_devices = []
    for d in devices:
        device = {'did': None, 'passcode': None}
        device['did'] = d[0]
        device['passcode'] = d[1]
        try:
            device['remark'] = d[2]
        except IndexError:
            pass
        data_devices.append(device)
    request_body = {'devices': data_devices}
    return Request("POST", render_url('/bindings'), data=request_body)
Ejemplo n.º 17
0
def bind_devices(devices):
    '''
    :param devices: struct = > [('did', 'passcode', 'remark(optional)', ...]
    '''
    data_devices = []
    for d in devices:
        device = {'did': None, 'passcode': None}
        device['did'] = d[0]
        device['passcode'] = d[1]
        try:
            device['remark'] = d[2]
        except IndexError:
            pass
        data_devices.append(device)
    request_body = {'devices':data_devices}
    return Request("POST", render_url('/bindings'), data=request_body)
Ejemplo n.º 18
0
def retrieve_device_histroy_data(did,
                                 start_ts=1349032093,
                                 end_ts=1349032093,
                                 entity=1,
                                 attr="temp",
                                 limit=20,
                                 skip=0):
    request_body = {
        'start_ts': start_ts,
        'end_ts': end_ts,
        'entity': entity,
        'attr': attr,
        'limit': limit,
        'skip': skip
    }
    url = render_url('/devdata/' + str(did))
    return Request("GET", url, params=request_body)
Ejemplo n.º 19
0
def retrieve_product_histroy_data(product_key,
                                  did=None,
                                  start_ts=1349032093,
                                  end_ts=1349032093,
                                  entity=1,
                                  attr="temp",
                                  limit=20,
                                  skip=0):
    request_body = {
        'product_key': product_key,
        'did': did,
        'start_ts': start_ts,
        'end_ts': end_ts,
        'entity': entity,
        'attr': attr,
        'limit': limit,
        'skip': skip
    }
    url = render_url('/devdata')
    return Request("GET", url, params=request_body)
Ejemplo n.º 20
0
def password_reset(email):
    request_body = {
        "email": email
        }
    return Request("POST", render_url('/reset_password'), data=request_body)
Ejemplo n.º 21
0
def update_phone_code(phone, code):
    request_body = {
        "phone": str(phone),
        "code": str(code)
        }
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 22
0
def password_reset(email):
    request_body = {"email": email}
    return Request("POST", render_url('/reset_password'), data=request_body)
Ejemplo n.º 23
0
def query_device(product_key, mac):
    request_body = {
        'product_key': product_key,
        'mac':mac
        }
    return Request("GET", render_url('/devices'), params=request_body)
Ejemplo n.º 24
0
def update_email(email):
    request_body = {"email": str(email)}
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 25
0
def get_bound_devices(limit=20, skip=0):
    request_body = {
        'limit': limit,
        'skip': skip
        }
    return Request("GET", render_url('/bindings'), params=request_body)
Ejemplo n.º 26
0
def scheduler_logs(sid):
    '''
    :param sid: scheduler id
    '''
    url = render_url('/scheduler/{0}/logs'.format(sid))
    return Request("GET", url)
Ejemplo n.º 27
0
def scheduler_logs(sid):
    '''
    :param sid: scheduler id
    '''
    url = render_url('/scheduler/{0}/logs'.format(sid))
    return Request("GET", url)
Ejemplo n.º 28
0
def del_scheduler(sid):
    '''
    :param sid: scheduler id
    '''
    url = render_url('/scheduler/{0}'.format(sid))
    return Request("DELETE", url)
Ejemplo n.º 29
0
def create_user_by_email(email, password):
    request_body = {'email': email, 'password': password}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 30
0
def create_user_by_phone(phone, password, code):
    request_body = {'phone': phone, 'password': password, 'code': code}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 31
0
def update_pwd(old_pwd, new_pwd):
    request_body = {"old_pwd": str(old_pwd), "new_pwd": str(new_pwd)}
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 32
0
def anonymous_login(phone_id):
    request_body = {'phone_id': phone_id}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 33
0
def get_bound_devices(limit=20, skip=0):
    request_body = {'limit': limit, 'skip': skip}
    return Request("GET", render_url('/bindings'), params=request_body)
Ejemplo n.º 34
0
def update_phone_code(phone, code):
    request_body = {"phone": str(phone), "code": str(code)}
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 35
0
def create_user_by_username(username, password):
    request_body = {'username': username,
                    'password': password}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 36
0
def create_user_by_phone(phone, password, code):
    request_body = {'phone': phone,
                    'password': password,
                    'code': code
                    }
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 37
0
def anonymous_login(phone_id):
    request_body = {'phone_id': phone_id}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 38
0
def device_detail(did):
    url = render_url('/devices/' + str(did))
    return Request("GET", url)
Ejemplo n.º 39
0
def update_pwd(old_pwd, new_pwd):
    request_body = {
        "old_pwd": str(old_pwd),
        "new_pwd": str(new_pwd)
        }
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 40
0
def verify_code(phone, code):
    request_body = {'phone': phone, 'code': code}
    return Request("POST", render_url('/codes'), data=request_body)
Ejemplo n.º 41
0
def password_reset_with(phone, code, new_pwd):
    request_body = {"phone": phone, "code": code, "new_pwd": new_pwd}
    return Request("PUT", render_url('/reset_password'), data=request_body)
Ejemplo n.º 42
0
def create_user_by_email(email, password):
    request_body = {'email': email,
                    'password': password}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 43
0
def device_detail(did):
    url = render_url('/devices/' + str(did))
    return Request("GET", url)
Ejemplo n.º 44
0
def verify_code(phone, code):
    request_body = {'phone': phone, 'code': code}
    return Request("POST", render_url('/codes'), data=request_body)
Ejemplo n.º 45
0
def query_device(product_key, mac):
    request_body = {'product_key': product_key, 'mac': mac}
    return Request("GET", render_url('/devices'), params=request_body)
Ejemplo n.º 46
0
def update_info(username, password):
    request_body = {'username': username, 'password': password}
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 47
0
def create_user_by_username(username, password):
    request_body = {'username': username, 'password': password}
    return Request("POST", render_url('/users'), data=request_body)
Ejemplo n.º 48
0
def update_email(email):
    request_body = {
        "email": str(email)
        }
    return Request("PUT", render_url('/users'), data=request_body)
Ejemplo n.º 49
0
def login(acc, pwd):
    request_body = {'username': acc, 'password': pwd}
    return Request("POST", render_url('/login'), data=request_body)
Ejemplo n.º 50
0
def get_code(phone):
    request_body = {'phone': phone}
    return Request("POST", render_url('/codes'), data=request_body)
Ejemplo n.º 51
0
def del_scheduler(sid):
    '''
    :param sid: scheduler id
    '''
    url = render_url('/scheduler/{0}'.format(sid))
    return Request("DELETE", url)
Ejemplo n.º 52
0
def get_code(phone):
    request_body = {'phone': phone}
    return Request("POST", render_url('/codes'), data=request_body)
Ejemplo n.º 53
0
def update_info(username, password):
    request_body = {'username': username, 'password': password}
    return Request("PUT", render_url('/users'), data=request_body)