module documentation

Remote API base resources library.

Class OpcodeAttributes Acts as a structure containing the per-method attribute names.
Class OpcodeResource Base class for opcode-based RAPI resources.
Class ResourceBase Generic class for resources.
Function BuildUriList Builds a URI list as used by index resources.
Function CheckParameter Check and return the value for a given parameter.
Function CheckType Abort request if value type doesn't match expected type.
Function FeedbackFn Feedback logging function for jobs.
Function FillOpcode Fills an opcode with body parameters.
Function GetHandler Undocumented
Function GetHandlerAccess Returns the access rights for a method on a handler.
Function GetResourceOpcodes Returns all opcodes used by a resource.
Function HandleItemQueryErrors Converts errors when querying a single item.
Function InspectParams Inspects a dictionary of params, looking for forbidden values.
Function MapBulkFields Map value to field name in to one dictionary.
Function MapFields Maps two lists into one dictionary.
Function ProduceForbiddenParamDict Turns a list of parameter names and possibly values into a dictionary.
Constant ALL_VALUES_FORBIDDEN Undocumented
Constant OPCODE_ATTRS Undocumented
Class _MetaOpcodeResource Meta class for RAPI resources.
Function _BuildOpcodeAttributes Builds list of attributes used for per-handler opcodes.
Constant _DEFAULT Undocumented
Constant _SUPPORTED_METHODS Undocumented
def BuildUriList(ids, uri_format, uri_fields=('name', 'uri')):

Builds a URI list as used by index resources.

Parameters
idslist of ids as strings
uri_formatformat to be applied for URI
uri_fieldsoptional parameter for field IDs
def CheckParameter(data, name, default=_DEFAULT, exptype=_DEFAULT):

Check and return the value for a given parameter.

If no default value was given and the parameter doesn't exist in the input data, an error is raise.

Parameters
data:dictDictionary containing input data
name:stringParameter name
defaultDefault value (can be None)
exptypeExpected type (can be None)
def CheckType(value, exptype, descr):

Abort request if value type doesn't match expected type.

Parameters
valueValue
exptype:typeExpected type
descr:stringDescription of value
Returns
Value (allows inline usage)
def FeedbackFn(msg):

Feedback logging function for jobs.

We don't have a stdout for printing log messages, so log them to the http log at least.

Parameters
msgthe message
def FillOpcode(opcls, body, static, rename=None):

Fills an opcode with body parameters.

Parameter types are checked.

Parameters
opcls:opcodes.OpCodeOpcode class
body:dictBody parameters as received from client
static:dictStatic parameters which can't be modified by client
rename:dictRenamed parameters, key as old name, value as new name
Returns
Opcode object
def GetHandler(get_fn, aliases):

Undocumented

def GetHandlerAccess(handler, method):

Returns the access rights for a method on a handler.

Parameters
handler:ResourceBaseUndocumented
method:stringUndocumented
Returns
string or NoneUndocumented
def GetResourceOpcodes(cls):

Returns all opcodes used by a resource.

def HandleItemQueryErrors(fn, *args, **kwargs):

Converts errors when querying a single item.

def InspectParams(params_dict, forbidden_params, rename_dict):

Inspects a dictionary of params, looking for forbidden values.

Parameters
params_dict:dict of string to anythingA dictionary of supplied parameters
forbidden_params:dict of string to string or list of anyThe forbidden parameters, with a list of forbidden values or the constant ALL_VALUES_FORBIDDEN signifying that all values are forbidden
rename_dict:None or dict of string to stringThe list of parameter renamings used by the method
Raises
http.HttpForbiddenIf a forbidden param has been set
def MapBulkFields(itemslist, fields):

Map value to field name in to one dictionary.

Parameters
itemslista list of items values
fieldsa list of items names
Returns
a list of mapped dictionaries
def MapFields(names, data):

Maps two lists into one dictionary.

Example:

    >>> MapFields(["a", "b"], ["foo", 123])
    {'a': 'foo', 'b': 123}
Parameters
namesfield names (list of strings)
datafield data (list)
def ProduceForbiddenParamDict(class_name, method_name, param_list):

Turns a list of parameter names and possibly values into a dictionary.

Parameters
class_name:stringThe name of the handler class
method_name:stringThe name of the HTTP method
param_list:list of string or tuple of (string, list of any)A list of forbidden parameters, specified in the RAPI handler class
Returns
The dictionary of forbidden param names to values or ALL_VALUES_FORBIDDEN
ALL_VALUES_FORBIDDEN: str =

Undocumented

Value
'all_values_forbidden'
OPCODE_ATTRS =

Undocumented

Value
_BuildOpcodeAttributes()
def _BuildOpcodeAttributes():

Builds list of attributes used for per-handler opcodes.

_DEFAULT =

Undocumented

Value
object()