class TypesEchoAction(Action): request_schema = fields.Dictionary( { 'an_int': fields.Integer(), 'a_float': fields.Float(), 'a_bool': fields.Boolean(), 'a_bytes': fields.ByteString(), 'a_string': fields.UnicodeString(), 'a_datetime': fields.DateTime(), 'a_date': fields.Date(), 'a_time': fields.Time(), 'a_list': fields.List(fields.Anything(), max_length=0), 'a_dict': fields.Nullable(fields.Dictionary({})), }, optional_keys=( 'an_int', 'a_float', 'a_bool', 'a_bytes', 'a_string', 'a_datetime', 'a_date', 'a_time', 'a_list', 'a_dict', ), ) response_schema = fields.Dictionary( {'r_{}'.format(k): v for k, v in six.iteritems(request_schema.contents)}, optional_keys=('r_{}'.format(k) for k in request_schema.optional_keys), ) def run(self, request): return {'r_{}'.format(k): v for k, v in six.iteritems(request.body)}
class GetDatetimeAction(Action): response_schema = fields.Dictionary( {'current_datetime': fields.DateTime()}) def run(self, request): return {'current_datetime': datetime.datetime.now()}