summaryrefslogtreecommitdiff
path: root/archivist/server/tag.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2017-10-05 18:05:21 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2017-10-05 18:05:21 +0200
commit9994319ea5c86bad2f88ab737b9b82dfae43cd6a (patch)
tree92943c5ef789d3be375f630e74040535d01cc37e /archivist/server/tag.py
parent975b647a3274f299df7260b6597aa88be90a7bb8 (diff)
downloadarchivist-9994319ea5c86bad2f88ab737b9b82dfae43cd6a.tar.gz
archivist-9994319ea5c86bad2f88ab737b9b82dfae43cd6a.tar.bz2
archivist-9994319ea5c86bad2f88ab737b9b82dfae43cd6a.zip
Webservice to create a new tag
Diffstat (limited to '')
-rw-r--r--archivist/server/tag.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/archivist/server/tag.py b/archivist/server/tag.py
index 96fafcd..8142cd1 100644
--- a/archivist/server/tag.py
+++ b/archivist/server/tag.py
@@ -1,6 +1,8 @@
+from flask import request
from flask_restplus import Resource, fields, Namespace
from .. import model as m
+from .. import bl
api = Namespace('tag', description = 'Operations on tags')
@@ -17,3 +19,15 @@ class TagList(Resource):
def get(self):
"""List all available tags."""
return list(m.Tag.select().where(~m.Tag.default).dicts().iterator())
+
+ @api.expect(tag, validate=True)
+ @api.response(201, "Tag created")
+ @api.response(409, "Tag already exists")
+ def put(self):
+ """Create a new tag."""
+ data = request.get_json()
+ tag, created = bl.PrefixTag(**data).create()
+ if created:
+ return '',201
+ else:
+ return '',409