Exemplo n.º 1
0
def get(session, jobid):
    """Retrieves details about a grid job.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        jobid (str): The job's identifying string.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #
    url = '/'.join([session.base_url(), 'grid/job', urlencode(jobid)])
    r = requests.get(url)
    return fulfill202(session, r)
Exemplo n.º 2
0
def post(session, jobid, vtrq_id, workspace_name):
    """Posts information about a grid job.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        jobid (str): The job's identifying string.
        vtrq_id (int): The vTRQ of the worksapce name.
        workspace_name (str): The PeerCache workspace employed by the job.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #
    url = '/'.join([session.base_url(), 'grid/job', urlencode(jobid)])
    r = requests.post(url,
                      json={
                          'workspace_name': workspace_name,
                          'vtrq_id': vtrq_id
                      })
    return fulfill202(session, r)
Exemplo n.º 3
0
def get(session, vtrqid, path):
    """Retrieves a workspace specification.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        vtrqid (int): ID of the vTRQ.
        path (str): Fully-qualified workspace name.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #  validate vtrqid is an int
    #  validate path is a string and is absolute
    #
    url = '/'.join([session.base_url(),
                    'vtrq',
                    'workspaces',
                    str(vtrqid),
                    urlencode(path)])
    r = requests.get(url)
    return fulfill202(session, r)
Exemplo n.º 4
0
def list(session, vtrqid, path):
    """Returns names of the child nodes of a vtrq path.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        vtrqid (int): ID of the vTRQ.
        path (str): Fully-qualified namespace path.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #  validate vtrqid is an int
    #  validate path is a string and is absolute
    url = '/'.join([session.base_url(),
                    'vtrq',
                    'namespace',
                    str(vtrqid),
                    urlencode(path),
                    'children'])
    r = requests.get(url, timeout=5.0)
    return fulfill202(session, r)
Exemplo n.º 5
0
def delete(session, vtrqid, path, recursive):
    """Removes a namespace node.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        vtrqid (int): ID of the vTRQ.
        path (str): Fully-qualified namespace path.
        recursive (bool): When True, a subtree will removed.  Otherwise, only leafs will be removed.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #  validate vtrqid is an int
    #  validate path is a string and is absolute
    url = '/'.join([session.base_url(),
                    'vtrq',
                    'namespace',
                    str(vtrqid),
                    urlencode(path)])
    r = requests.delete(url, params={'recursive': recursive})
    return fulfill202(session, r)
Exemplo n.º 6
0
def mkdir(session, vtrqid, mode, parents, path):
    """Creates a directory on the vtrq.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        vtrqid (int): ID of the vTRQ.
        path (str): Fully-qualified namespace path.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #  validate vtrqid is an int
    #  validate path is a string and is absolute
    #  validate recursive is boolean
    url = '/'.join([session.base_url(),
                    'vtrq',
                    'namespace',
                    str(vtrqid),
                    urlencode(path),
                    'mkdir'])
    r = requests.post(url, params={'mode': mode, 'parents': parents})
    return fulfill202(session, r)
Exemplo n.º 7
0
def list(session, vtrqid, path):
    """Returns the names at a workspace path.

    The names may represent workspaces or nodes of the hierarchy.

    Args:
        session (:class:`~velstor.restapi.Session`): Provides security information.
        vtrqid (int): ID of the vTRQ.
        path (str): Fully-qualified workspace path.

    Returns:
        The return value of :func:`~velstor.restapi.fulfill202.fulfill202`
    """
    #  validate vtrqid is an int
    #  validate path is a string and is absolute
    #
    url = '/'.join([session.base_url(),
                    'vtrq',
                    'workspaces',
                    str(vtrqid),
                    urlencode(path),
                    'children'])
    r = requests.get(url)
    return fulfill202(session, r)
Exemplo n.º 8
0
def test_urlencode_slash():
    assert (libutil.urlencode('/path/to/nowhere').lower() ==
            '%2fpath%2fto%2fnowhere')