Module libnova.common.api.Base

Expand source code
#!/usr/bin/env python
# coding: utf-8

from libnova.common import api

def get(uri, params, data):
    """Perform a GET request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.get(
        url_segment=uri,
        params=params,
        data=data
    )

def put(uri, params, data):
    """Perform a PUT request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.put(
        url_segment=uri,
        params=params,
        data=data
    )

def post(uri, params, data):
    """Perform a POST request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.post(
        url_segment=uri,
        params=params,
        data=data
    )

def delete(uri, params, data):
    """Perform a DELETE request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.delete(
        url_segment=uri,
        params=params,
        data=data
    )

if __name__ == "__main__":
    print('This file cannot be executed directly!')

Functions

def delete(uri, params, data)

Perform a DELETE request

Args

params : dict
The url-encoded parameters
data : dict
Data to be sent as multipart/form-data

Returns

dict
An API result (see documentation)
Expand source code
def delete(uri, params, data):
    """Perform a DELETE request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.delete(
        url_segment=uri,
        params=params,
        data=data
    )
def get(uri, params, data)

Perform a GET request

Args

params : dict
The url-encoded parameters
data : dict
Data to be sent as multipart/form-data

Returns

dict
An API result (see documentation)
Expand source code
def get(uri, params, data):
    """Perform a GET request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.get(
        url_segment=uri,
        params=params,
        data=data
    )
def post(uri, params, data)

Perform a POST request

Args

params : dict
The url-encoded parameters
data : dict
Data to be sent as multipart/form-data

Returns

dict
An API result (see documentation)
Expand source code
def post(uri, params, data):
    """Perform a POST request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.post(
        url_segment=uri,
        params=params,
        data=data
    )
def put(uri, params, data)

Perform a PUT request

Args

params : dict
The url-encoded parameters
data : dict
Data to be sent as multipart/form-data

Returns

dict
An API result (see documentation)
Expand source code
def put(uri, params, data):
    """Perform a PUT request

    Args:
        params (dict): The url-encoded parameters
        data (dict): Data to be sent as multipart/form-data

    Returns:
        dict: An API result (see documentation)
    """

    api_driver = api.Driver.get_instance()
    return api_driver.put(
        url_segment=uri,
        params=params,
        data=data
    )