Пример #1
0
def retrieve_tasks(resource, application):
    """
    Retrieve the list of currently scheduled tasks ( resource / application pairings ) from
    mod_akrr.

    :type resource str
    :type application str

    :param resource: filter the results by the provided resource
    :param application: filter the results by the provided application
    :return: a dict representation of the mod_akrr.SCHEDULEDTASKS table
    """
    data = {
        'application': application,
        'resource': resource
    }

    try:
        akrrrestclient.get_token()
    except StandardError:
        log.error('''
                An error occured while attempting to retrieve a token
                from the REST API.
                ''')
    try:
        result = akrrrestclient.get(
            '/scheduled_tasks',
            data=data)
        if result.status_code == 200:
            log.info('Successfully Completed Task Retrieval.\n{0}', result.text)

        else:
            log.error(
                'something went wrong. {0}:{1}',
                result.status_code,
                result.text)
        return result
    except StandardError, e:
        log.error('''
                An error occured while communicating
                with the REST API.
                {0}: {1}
                ''',
                  e.args[0] if len(e.args) > 0 else '',
                  e.args[1] if len(e.args) > 1 else '')
Пример #2
0
def process_request(request):
    method = request[0]
    url = request[1]
    if method not in RESTCompleter.keywords:
        raise AssertionError("Invalid method. Please provide a valid method to continue.")
    if len(url) < 1:
        raise AssertionError("Must supply a url.")

    akrrrestclient.get_token()

    if method == "GET":
        return akrrrestclient.get(url)
    elif method == "PUT":
        return akrrrestclient.put(url)
    elif method == "POST":
        return akrrrestclient.post(url)
    elif method == "DELETE":
        return akrrrestclient.delete(url)
Пример #3
0
def process_request(request):
    method = request[0]
    url = request[1]
    if method not in RESTCompleter.keywords:
        raise AssertionError(
            "Invalid method. Please provide a valid method to continue.")
    if len(url) < 1:
        raise AssertionError("Must supply a url.")

    akrrrestclient.get_token()

    if method == 'GET':
        return akrrrestclient.get(url)
    elif method == 'PUT':
        return akrrrestclient.put(url)
    elif method == 'POST':
        return akrrrestclient.post(url)
    elif method == 'DELETE':
        return akrrrestclient.delete(url)