Update a project

This commit is contained in:
Julien Duponchelle committed 2015-01-23 16:13:58 +01:00
1 parent abc885049f
commit 0e76527ce2
4 files changed
+55 -2

No files matched your search

+21 -1
View File
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ..web.route import Route
from ..schemas.project import PROJECT_OBJECT_SCHEMA, PROJECT_CREATE_SCHEMA
from ..schemas.project import PROJECT_OBJECT_SCHEMA, PROJECT_CREATE_SCHEMA, PROJECT_UPDATE_SCHEMA
from ..modules.project_manager import ProjectManager
from aiohttp.web import HTTPConflict
@@ -39,6 +39,26 @@ class ProjectHandler:
)
response.json(p)
@classmethod
@Route.put(
r"/project/{uuid}",
description="Update a project",
parameters={
"uuid": "Project instance UUID",
},
status_codes={
200: "Project updated",
404: "Project instance doesn't exist"
},
output=PROJECT_OBJECT_SCHEMA,
input=PROJECT_UPDATE_SCHEMA)
def update(request, response):
pm = ProjectManager.instance()
project = pm.get_project(request.match_info["uuid"])
project.temporary = request.json.get("temporary", project.temporary)
response.json(project)
@classmethod
@Route.post(
r"/project/{uuid}/commit",
+10
View File
@@ -76,6 +76,16 @@ class Project:
return self._vms
@property
def temporary(self):
return self._temporary
@temporary.setter
def temporary(self, temporary):
self._temporary = temporary
def vm_working_directory(self, vm):
"""
Return a working directory for a specific VM.
+14 -1
View File
@@ -41,9 +41,22 @@ PROJECT_CREATE_SCHEMA = {
"additionalProperties": False,
}
PROJECT_UPDATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to update a Project instance",
"type": "object",
"properties": {
"temporary": {
"description": "If project is a temporary project",
"type": "boolean"
},
},
"additionalProperties": False,
}
PROJECT_OBJECT_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to create a new Project instance",
"description": "Project instance",
"type": "object",
"properties": {
"location": {