def validate_post(self): parser = RequestParser() parser.add_argument('roleId', type=str, required=True, help='The id of the role to add to the system.') return parser.parse_args()
def validate_put(self): parser = RequestParser() parser.add_argument('status', type=str, required=True, help='The status for the API.') return parser.parse_args()
def validate_post(self): logger.debug("validating message payload.") parser = RequestParser() parser.add_argument('message', type=str, required=False, help="The message to send to the actor.") args = parser.parse_args() # if a special 'message' object isn't passed, use entire POST payload as message if not args.get('message'): logger.debug("POST body did not have a message field.") json_data = request.get_json() if json_data: logger.debug("message was JSON data.") args['message'] = json_data args['_abaco_Content-Type'] = 'application/json' else: logger.debug("message was NOT JSON data.") # try to get data for mime types not recognized by flask. flask creates a python string for these try: args['message'] = json.loads(request.data) except TypeError: logger.debug("message POST body could not be serialized. args: {}".format(args)) raise DAOError('message POST body could not be serialized. Pass JSON data or use the message attribute.') args['_abaco_Content-Type'] = 'str' else: # the special message object is a string logger.debug("POST body has a message field. Setting _abaco_Content-type to 'str'.") args['_abaco_Content-Type'] = 'str' return args
def validate_post(self): logger.debug("validating message payload.") parser = RequestParser() parser.add_argument('message', type=str, required=False, help="The message to send to the actor.") args = parser.parse_args() # if a special 'message' object isn't passed, use entire POST payload as message if not args.get('message'): logger.debug("POST body did not have a message field.") # first check for binary data: if request.headers.get( 'Content-Type') == 'application/octet-stream': # ensure not sending too much data length = request.headers.get('Content-Length') if not length: raise ResourceError( "Content Length required for application/octet-stream." ) try: int(length) except Exception: raise ResourceError("Content Length must be an integer.") if int(length) > int(Config.get('web', 'max_content_length')): raise ResourceError( "Message exceeds max content length of: {}".format( Config.get('web', 'max_content_length'))) logger.debug( "using get_data, setting content type to application/octet-stream." ) args['message'] = request.get_data() args['_abaco_Content_Type'] = 'application/octet-stream' return args json_data = request.get_json() if json_data: logger.debug("message was JSON data.") args['message'] = json_data args['_abaco_Content_Type'] = 'application/json' else: logger.debug("message was NOT JSON data.") # try to get data for mime types not recognized by flask. flask creates a python string for these try: args['message'] = json.loads(request.data) except TypeError: logger.debug( "message POST body could not be serialized. args: {}". format(args)) raise DAOError( 'message POST body could not be serialized. Pass JSON data or use the message attribute.' ) args['_abaco_Content_Type'] = 'str' else: # the special message object is a string logger.debug( "POST body has a message field. Setting _abaco_Content_type to 'str'." ) args['_abaco_Content_Type'] = 'str' return args
def validate_post(self): parser = RequestParser() parser.add_argument( 'accountId', type=str, required=True, help='The id of the service account to add to the role.') return parser.parse_args()
def validate_post(self): parser = RequestParser() parser.add_argument('user', type=str, required=True, help="User owning the permission.") parser.add_argument('level', type=str, required=True, help="Level of the permission: {}".format(PERMISSION_LEVELS)) args = parser.parse_args() if not args['level'] in PERMISSION_LEVELS: raise ResourceError("Invalid permission level: {}. \ The valid values are {}".format(args['level'], PERMISSION_LEVELS)) return args
def validate_post(self): parser = RequestParser() parser.add_argument('num', type=int, help="Number of workers to start (default is 1).") try: args = parser.parse_args() except BadRequest as e: msg = 'Unable to process the JSON description.' if hasattr(e, 'data'): msg = e.data.get('message') raise DAOError("Invalid POST: {}".format(msg)) return args
def validate_post(self): parser = RequestParser() parser.add_argument('accountId', type=str, required=True, help='The id for the service account.') parser.add_argument('password', type=str, required=True, help='The password for the service account.') return parser.parse_args()
def validate_post(self): parser = RequestParser() parser.add_argument('state', type=str, required=True, help="Set the state for this actor.") try: args = parser.parse_args() except BadRequest as e: msg = 'Unable to process the JSON description.' if hasattr(e, 'data'): msg = e.data.get('message') raise DAOError("Invalid actor state description: {}".format(msg)) return args
def validate_post(self): parser = RequestParser() parser.add_argument('runtime', type=str, required=True, help="Runtime, in milliseconds, of the execution.") parser.add_argument('cpu', type=str, required=True, help="CPU usage, in user jiffies, of the execution.") parser.add_argument('io', type=str, required=True, help="Block I/O usage, in number of 512-byte sectors read from and written to, by the execution.") # Accounting for memory is quite hard -- probably easier to cap all containers at a fixed amount or perhaps have # a graduated list of cap sized (e.g. small, medium and large). # parser.add_argument('mem', type=str, required=True, help="Memory usage, , of the execution.") args = parser.parse_args() for k,v in args.items(): try: int(v) except ValueError: raise ResourceError(message="Argument {} must be an integer.".format(k)) return args
def validate_post(self): parser = RequestParser() parser.add_argument('user', type=str, required=True, help="User owning the permission.") parser.add_argument('level', type=str, required=True, help="Level of the permission: {}".format(PERMISSION_LEVELS)) try: args = parser.parse_args() except BadRequest as e: msg = 'Unable to process the JSON description.' if hasattr(e, 'data'): msg = e.data.get('message') raise DAOError("Invalid permissions description: {}".format(msg)) if not args['level'] in PERMISSION_LEVELS: raise ResourceError("Invalid permission level: {}. \ The valid values are {}".format(args['level'], PERMISSION_LEVELS)) return args
def validate_post(self): parser = RequestParser() parser.add_argument('num', type=int, help="Number of workers to start (default is 1).") args = parser.parse_args() return args
def validate_post(self): parser = RequestParser() parser.add_argument('state', type=str, required=True, help="Set the state for this actor.") args = parser.parse_args() return args