Package enomalism2 :: Module REST_library
[hide private]

Module REST_library

Library for calling REST API methods from other locations.


Status: Stable

Functions [hide private]
String
shellout(result)
Return the shellout format of the specified result.
elementtree.ElementTree
xmlout(the_dict)
Returns a simple XML representation of the input dictionary.
None
rest_loop_check()
Check if we have entered an endless REST recursion loop.
Tuple
call_rest(urlbase, args, auth="auto", method=None, **kw)
Make a REST function call.
Variables [hide private]
Dictionary errcodes = {'SUCCESS': 0, 'NO_SUCH_MACHINE': 1, 'INVALID_COMMA...
REST error codes.
Dictionary errmsgs = {}
REST error messages.
  httpcodes = {'OK': 200, 'UNAUTHORIZED': 401, 'FORBIDDEN': 403,...
  httpmsgs = {}
Function Details [hide private]

shellout(result)

 

Return the shellout format of the specified result.

Example usage:

>>> from enomalism2 import REST_library
>>> REST_library.shellout(['test'])
Parameters:
  • result (List/Tuple/Dictionary/String) - The result to shellout.
Returns: String
The shellout result.
Raises:
  • None - No exceptions are raised by this function.

Status: Stable

xmlout(the_dict)

 

Returns a simple XML representation of the input dictionary.

Example usage:

>>> from enomalism2 import REST_library
>>> REST_library.xmlout({'name':'test'})
Parameters:
  • the_dict (Ditionary) - A dictionary of JSONifiable items.
Returns: elementtree.ElementTree
A new element tree representation of the dictionary.
Raises:
  • None - No exceptions are raised by this function.

Status: Stable

rest_loop_check()

 

Check if we have entered an endless REST recursion loop. In this case, we raise an exception.

Example usage:

>>> from enomalism2 import REST_library
>>> REST_library.rest_loop_check()
Returns: None
None
Raises:
  • enomalism2.exceptions.e2_rest_recursion_error - Raised if there are too many proxy loops.

Status: Stable

call_rest(urlbase, args, auth="auto", method=None, **kw)

 

Make a REST function call.

Example usage:

>>> from enomalism2 import REST_library
>>> REST_library.call_rest('http://localhost:8080/rest/machine/', [123])
Parameters:
  • urlbase (String) - The url of the rest function.
  • args (Dictionary) - The arguments passed to the REST function.
  • auth (String) - The authentication method.
  • method (String) - The REST HTTP method.
Returns: Tuple
A tuple containing the REST response headers and the REST response data.
Raises:
  • cherrypy.HTTPError - Raised when there is no current user.

Status: Stable


Variables Details [hide private]

errcodes

REST error codes.
Type:
Dictionary
Value:
{'SUCCESS': 0, 'NO_SUCH_MACHINE': 1, 'INVALID_COMMAND': 2, 'MISSING_PA\
RAMETER': 3, 'COULD_NOT_CONNECT': 4, 'COULD_NOT_RETRIEVE': 5, 'COMMAND\
_FAILED': 6, 'RESOURCE_LOCKED': 7, 'INTERNAL_ERROR': 8, 'UNKNOWN_PARAM\
ETER': 9, 'RESOURCE_BUSY': 10, 'NAMING_CONFLICT': 11, 'RECURSION_ERROR\
': 12}

httpcodes

Value:
{'OK': 200, 'UNAUTHORIZED': 401, 'FORBIDDEN': 403, 'NOT_FOUND': 404, '\
INTERNAL_SERVER_ERROR': 500}