summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-07-21 01:02:08 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-21 01:02:08 +0000
commit53825a386d6b7edd47754db41113bedfacc34432 (patch)
tree0323eb096af3e18614abb10d0c8c006223d2861e /api
parentdf77b6585cb54d2e4691b946ea1bc9cca637c108 (diff)
parent7ea08628579d2e8e50e748ae1bf337687235ca62 (diff)
Merge "Add API(v2) to create project"
Diffstat (limited to 'api')
-rw-r--r--api/resources/v2/projects.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/api/resources/v2/projects.py b/api/resources/v2/projects.py
new file mode 100644
index 000000000..e787cc333
--- /dev/null
+++ b/api/resources/v2/projects.py
@@ -0,0 +1,33 @@
+import uuid
+
+from datetime import datetime
+
+from api import ApiResource
+from api.database.v2.handlers import V2ProjectHandler
+from yardstick.common.utils import result_handler
+from yardstick.common import constants as consts
+
+
+class V2Projects(ApiResource):
+
+ def post(self):
+ return self._dispatch_post()
+
+ def create_project(self, args):
+ try:
+ name = args['name']
+ except KeyError:
+ return result_handler(consts.API_ERROR, 'name must be provided')
+
+ project_id = str(uuid.uuid4())
+ create_time = datetime.now()
+ project_handler = V2ProjectHandler()
+
+ project_init_data = {
+ 'uuid': project_id,
+ 'name': name,
+ 'time': create_time
+ }
+ project_handler.insert(project_init_data)
+
+ return result_handler(consts.API_SUCCESS, {'uuid': project_id})