Commit 2235b558 authored by Łukasz Nowak's avatar Łukasz Nowak

Support PUT on computer.

parent b52627e3
...@@ -432,6 +432,32 @@ class InstancePublisher(GenericPublisher): ...@@ -432,6 +432,32 @@ class InstancePublisher(GenericPublisher):
self.__instance_list() self.__instance_list()
class ComputerPublisher(GenericPublisher):
@responseSupport()
@requireHeader({'Accept': 'application/json',
'Content-Type': 'application/json'})
@extractDocument('Computer')
@requireJson(dict(
partition=list,
software=list
), ['partition', 'software'])
def PUT(self):
"""Computer PUT support"""
computer = self.restrictedTraverse(self.document_url)
try:
computer.Computer_updateFromJson(self.jbody)
except Exception:
transaction.abort()
LOG('VifibRestApiV1Tool', ERROR,
'Problem while trying to update computer:', error=True)
self.REQUEST.response.setStatus(500)
self.REQUEST.response.setBody(jsonify({'error':
'There is system issue, please try again later.'}))
return self.REQUEST.response
self.REQUEST.response.setStatus(204)
return self.REQUEST.response
class VifibRestApiV1Tool(BaseTool): class VifibRestApiV1Tool(BaseTool):
"""SlapOS REST API V1 Tool""" """SlapOS REST API V1 Tool"""
...@@ -448,6 +474,12 @@ class VifibRestApiV1Tool(BaseTool): ...@@ -448,6 +474,12 @@ class VifibRestApiV1Tool(BaseTool):
"""Instance publisher""" """Instance publisher"""
return InstancePublisher().__of__(self) return InstancePublisher().__of__(self)
security.declarePublic('computer')
@ComputedAttribute
def computer(self):
"""Computer publisher"""
return ComputerPublisher().__of__(self)
security.declarePrivate('manage_afterAdd') security.declarePrivate('manage_afterAdd')
def manage_afterAdd(self, item, container) : def manage_afterAdd(self, item, container) :
"""Init permissions right after creation. """Init permissions right after creation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment