def _validate_args(self, param, safe): # TODO: need proper validation but for now pass everything args_length = len(param.args) if args_length == 1: safe.kwargs["doc_name"] = param.args[0] param.args.pop() else: raise APINotSpecified() return
def validate(self, apiobj, method, api, param, safe): # Check we have an instance if not param.args or param.args[0] not in self._instances: raise NoSuchInstance() instance = param.args.pop(0) # Check we have sub-api defined. if not param.args: raise APINotSpecified() if param.args[0] not in self._entities: raise APIMethodMismatch() # Pass validation to nested entity. entity = self._entities[param.args.pop(0)] entity.validate(apiobj, method, api, param, safe) # Now wrap the nested safe parameters into a proxy to our own get(). kwargs = dict((k, v) for k, v in safe.kwargs.iteritems()) for k in kwargs: del safe.kwargs[k] safe.kwargs["kwargs"] = kwargs safe.kwargs["entity"] = entity safe.kwargs["instance"] = instance
from WMCore.REST.Error import NoSuchInstance from WMCore.REST.Error import DatabaseError from WMCore.REST.Error import DatabaseUnavailable from WMCore.REST.Error import DatabaseConnectionError from WMCore.REST.Error import DatabaseExecutionError from WMCore.REST.Error import MissingParameter from WMCore.REST.Error import InvalidParameter from WMCore.REST.Error import MissingObject from WMCore.REST.Error import TooManyObjects from WMCore.REST.Error import ObjectAlreadyExists from WMCore.REST.Error import InvalidObject from WMCore.REST.Error import ExecutionError RESTError() NotAcceptable() UnsupportedMethod() MethodWithoutQueryString() APIMethodMismatch() APINotSpecified() NoSuchInstance() DatabaseError() DatabaseUnavailable() DatabaseConnectionError() DatabaseExecutionError() MissingParameter() InvalidParameter() MissingObject() TooManyObjects() ObjectAlreadyExists() InvalidObject() ExecutionError()