From fc11314eda6103d5055062c3035536c93784ea4c Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Thu, 5 Oct 2017 13:07:23 +0200 Subject: Change to flask_restplus --- archivist/server/prefix.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 archivist/server/prefix.py (limited to 'archivist/server/prefix.py') diff --git a/archivist/server/prefix.py b/archivist/server/prefix.py new file mode 100644 index 0000000..f2a747f --- /dev/null +++ b/archivist/server/prefix.py @@ -0,0 +1,25 @@ +from flask_restplus import Resource, fields, Namespace, marshal_with_field + +from .. import model as m + +api = Namespace('prefix', description = 'Operations on prefixes') + +prefix = api.model('Prefix', { + 'name' : fields.String(required=True), + 'description' : fields.String, + 'virtual' : fields.Boolean +}) + +@api.route('/') +class PrefixList(Resource): + @api.marshal_list_with(prefix) + def get(self): + """List all available non-virtual prefixes.""" + return list(m.Prefix.select().where(~m.Prefix.virtual).dicts().iterator()) + +@api.route('/all') +class PrefixListAll(Resource): + @api.marshal_list_with(prefix) + def get(self): + """List all available prefixes, including virtual.""" + return list(m.Prefix.select().dicts().iterator()) -- cgit v1.2.3-54-g00ecf