summaryrefslogtreecommitdiff
path: root/archivist/server/tag.py
diff options
context:
space:
mode:
Diffstat (limited to 'archivist/server/tag.py')
-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