예제 #1
0
def get_task_group(base_url, token):
    """List All Task Groups
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
        
        Returns:
                list -- all task groups in yout account
        """
    print('GetTaskGroups:')
    url = 'api/taskgroup'
    response = util.request_t_get(base_url, url, token)
    groups = []
    if 'error' in response:
        if response['error'] == 'success':
            groups = response['data']
            for taskgroup in groups:
                print('%s\t%s' %
                      (taskgroup['taskGroupId'], taskgroup['taskGroupName']))
        else:
            print(response['error_Description'])
    else:
        print(response)

    return groups
예제 #2
0
def get_task_by_group_id(base_url, token, groupId):
    """List All Tasks in a Group
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                groupId {int} -- a task group id
        
        Returns:
                list -- all tasks in a group
        """
    print('GetTasks:')
    url = 'api/task?taskgroupId=' + str(groupId)
    response = util.request_t_get(base_url, url, token)
    if 'error' in response:
        if response['error'] == 'success':
            tasks = response['data']
            for task in tasks:
                print('%s\t%s' % (task['taskId'], task['taskName']))
        else:
            print(response['error_Description'])
    else:
        print(response)

    return tasks
예제 #3
0
def get_task_group(base_url, token):
        """List All Task Groups
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
        
        Returns:
                list -- all task groups in yout account
        """
        print('GetTaskGroups:')
        url = 'api/taskgroup'
        response = util.request_t_get(base_url, url, token)
        groups = []
        if 'error' in response:
                if response['error'] == 'success':
                        groups = response['data']
                        for taskgroup in groups:
                                print('%s\t%s'%(taskgroup['taskGroupId'],taskgroup['taskGroupName']))
                else:
                        print(response['error_Description'])
        else:
                print(response)
                
        return groups
예제 #4
0
def get_task_by_group_id(base_url, token, groupId):
        """List All Tasks in a Group
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                groupId {int} -- a task group id
        
        Returns:
                list -- all tasks in a group
        """
        print('GetTasks:')
        url = 'api/task?taskgroupId=' + str(groupId)
        response = util.request_t_get(base_url, url, token)
        if 'error' in response:
                if response['error'] == 'success':
                        tasks = response['data']
                        for task in tasks:
                                print('%s\t%s'%(task['taskId'],task['taskName']))
                else:
                        print(response['error_Description'])
        else:
                print(response)

        return tasks
예제 #5
0
def get_data_by_offset(base_url, token, task_id, offset=0, size=10):
    """Get task data by data offset

        To get data, parameters such as offset, size and task ID are all required in the request. 
        Offset should default to 0 (offset=0), and size∈[1,1000] for making the initial request. 
        The offset returned (could be any value greater than 0) should be used for making the next request. 
        For example, if a task has 1000 data rows, using parameter: offset = 0, size = 100 will return 
        the first 100 rows of data and the offset X (X can be any random number greater than or equal to 100). 
        When making the second request, user should use the offset returned from the first request, offset = X, size = 100 
        to get the next 100 rows of data (row 101 to 200) as well as the new offset to use for the request follows.
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                task_id {string} -- task id of a task from our platform
        
        Keyword Arguments:
                offset {int} -- an offset from last data request, should remains 0 if is the first request (default: {0})
                size {int} -- data row size for the request (default: {10})
        
        Returns:
                json -- task dataList and relevant information:
                         {
                                "data": {
                                "offset": 4,
                                "total": 100000,
                                "restTotal": 99996,
                                "dataList": [
                                {
                                        "state": "Texas",
                                        "city": "Plano"
                                },
                                {
                                        "state": "Texas",
                                        "city": "Houston"
                                },
                                ...
                                ]
                                },
                                "error": "success",
                                "error_Description": "Action Success"
                        }
        """
    print('GetTaskDataByOffset:')
    url = 'api/allData/getDataOfTaskByOffset?taskId=%s&offset=%s&size=%s' % (
        task_id, offset, size)
    task_data_result = util.request_t_get(base_url, url, token)
    util.show_task_data(task_data_result)
    return task_data_result
예제 #6
0
def get_data_by_offset(base_url, token, task_id, offset=0, size=10):
        """Get task data by data offset

        To get data, parameters such as offset, size and task ID are all required in the request. 
        Offset should default to 0 (offset=0), and size∈[1,1000] for making the initial request. 
        The offset returned (could be any value greater than 0) should be used for making the next request. 
        For example, if a task has 1000 data rows, using parameter: offset = 0, size = 100 will return 
        the first 100 rows of data and the offset X (X can be any random number greater than or equal to 100). 
        When making the second request, user should use the offset returned from the first request, offset = X, size = 100 
        to get the next 100 rows of data (row 101 to 200) as well as the new offset to use for the request follows.
        
        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                task_id {string} -- task id of a task from our platform
        
        Keyword Arguments:
                offset {int} -- an offset from last data request, should remains 0 if is the first request (default: {0})
                size {int} -- data row size for the request (default: {10})
        
        Returns:
                json -- task dataList and relevant information:
                         {
                                "data": {
                                "offset": 4,
                                "total": 100000,
                                "restTotal": 99996,
                                "dataList": [
                                {
                                        "state": "Texas",
                                        "city": "Plano"
                                },
                                {
                                        "state": "Texas",
                                        "city": "Houston"
                                },
                                ...
                                ]
                                },
                                "error": "success",
                                "error_Description": "Action Success"
                        }
        """
        print('GetTaskDataByOffset:')
        url = 'api/allData/getDataOfTaskByOffset?taskId=%s&offset=%s&size=%s'%(task_id, offset, size)
        task_data_result = util.request_t_get(base_url, url, token)
        util.show_task_data(task_data_result)
        return task_data_result
예제 #7
0
def export_not_exported_data(base_url, token, task_id):
    """Export Non-exported Data
        
        This returns non-exported data. Data will be tagged status = exporting (instead of status=exported) after the export. 
        This way, the same set of data can be exported multiple times using this method. 
        If the user has confirmed receipt of the data and wish to update data status to ‘exported’, 
        please make a status update.

        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                task_id {string} -- task id of a task from our platform
        
        Returns:
                json -- task dataList and relevant information:
                         {
                                "data": {
                                "offset": 4,
                                "total": 100000,
                                "restTotal": 99996,
                                "dataList": [
                                {
                                        "state": "Texas",
                                        "city": "Plano"
                                },
                                {
                                        "state": "Texas",
                                        "city": "Houston"
                                },
                                ...
                                ]
                                },
                                "error": "success",
                                "error_Description": "Action Success"
                        }
        """
    print('ExportNotExportedData')
    url = 'api/notExportData/getTop?taskId=' + task_id + '&size=10'
    task_data_result = util.request_t_get(base_url, url, token)
    util.show_task_data(task_data_result)
    return task_data_result
예제 #8
0
def export_not_exported_data(base_url, token, task_id):
        """Export Non-exported Data
        
        This returns non-exported data. Data will be tagged status = exporting (instead of status=exported) after the export. 
        This way, the same set of data can be exported multiple times using this method. 
        If the user has confirmed receipt of the data and wish to update data status to ‘exported’, 
        please make a status update.

        Arguments:
                base_url {string} -- base url of the api
                token {string} -- token string from a valid token entity
                task_id {string} -- task id of a task from our platform
        
        Returns:
                json -- task dataList and relevant information:
                         {
                                "data": {
                                "offset": 4,
                                "total": 100000,
                                "restTotal": 99996,
                                "dataList": [
                                {
                                        "state": "Texas",
                                        "city": "Plano"
                                },
                                {
                                        "state": "Texas",
                                        "city": "Houston"
                                },
                                ...
                                ]
                                },
                                "error": "success",
                                "error_Description": "Action Success"
                        }
        """
        print('ExportNotExportedData')
        url = 'api/notExportData/getTop?taskId=' + task_id + '&size=10'
        task_data_result = util.request_t_get(base_url, url, token)
        util.show_task_data(task_data_result)
        return task_data_result