paradrop.lib.api package¶
Submodules¶
paradrop.lib.api.pdapi module¶
-
exception
PDAPIError
(etype, msg)[source]¶ Bases:
exceptions.Exception
Exception class related to ParaDrop API calls.
-
getErrorToken
()[source]¶ Generates a random string which is used to match client issues with log output.
paradrop.lib.api.pdrest module¶
-
ALL
(regex)¶
-
APIDecorator
(admin=False, permission=None, requiredArgs=[], optionalArgs=[])[source]¶ The decorator for the API functions to make the API functions focus on their job. This decorator do the following things:
- Set HTTP header
- Get some common values like ip, tictoc
- Do the preprocess
- Extract arguments from HTTP body and put them into APIPackage
- Get devid if token is shown and put devid into APIPackage
- Check admin authorization if devid is shown and admin argument is set to be true
- Do the failprocess if fails. Do the postProcess if success
This decorator will pass an APIPackage to an API function and the API function is supposed to put return value into the API package Arguments:
- admin: if the function needs admin authority to call
- requiredArgs: the required arguments for this API, this wrapper will parse the required args from HTTP body and check if they exist in the body.
- optionalArgs: the optional arguments for this API, the args will be parsed from HTTP body
- permission: choose from None, “AP Owner”, “Chute Owner”
- TODO:
- 1.Permission
- multiple permission/multiple level of permission??
- More permissions: such as Vnet Owner, Group Owner
-
class
APIPackage
(request)[source]¶ This is a class that wrap up the input and return value of API The input arguments will be in the inputArgs as a dict Result is True means the API return success Result is False means the API return failure Result is None means the API return NOT_YET_DONE
-
DELETE
(regex)¶
-
GET
(regex)¶
-
POST
(regex)¶
-
PUT
(regex)¶