/usr/share/pyshared/txaws/server/call.py is in python-txaws 0.2.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from uuid import uuid4
from txaws.version import ec2_api as ec2_api_version
from txaws.server.exception import APIError
class Call(object):
"""Hold information about a single API call initiated by an HTTP request.
@param raw_params: The raw parameters for the action to be executed, the
format is a dictionary mapping parameter names to parameter values,
like C{{'ParamName': param_value}}.
@param principal: The principal issuing this API L{Call}.
@param action: The action to be performed.
@ivar id: A unique identifier for the API call.
@ivar principal: The principal performing the call.
@ivar args: An L{Arguments} object holding parameters extracted from the
raw parameters according to a L{Schema}, it will be available after
calling the C{parse} method.
@ivar rest: Extra parameters not included in the given arguments schema,
it will be available after calling the L{parse} method.
@ivar version: The version of the API call. Defaults to 2009-11-30.
"""
def __init__(self, raw_params=None, principal=None, action=None,
version=None, id=None):
if id is None:
id = str(uuid4())
self.id = id
self._raw_params = {}
if raw_params is not None:
self._raw_params.update(raw_params)
self.action = action
if version is None:
version = ec2_api_version
self.version = version
self.principal = principal
def parse(self, schema, strict=True):
"""Update C{args} and C{rest}, parsing the raw request arguments.
@param schema: The L{Schema} the parameters must be extracted with.
@param strict: If C{True} an error is raised if parameters not included
in the schema are found, otherwise the extra parameters will be
saved in the C{rest} attribute.
"""
self.args, self.rest = schema.extract(self._raw_params)
if strict and self.rest:
raise APIError(400, "UnknownParameter",
"The parameter %s is not "
"recognized" % self.rest.keys()[0])
def get_raw_params(self):
"""Return a C{dict} holding the raw API call paramaters.
The format of the dictionary is C{{'ParamName': param_value}}.
"""
return self._raw_params.copy()
|