Add PUT, PATCH and POST method to base resource

Change-Id: I0e5bc1a79fe1be73b900a4cecce9a73f12a20d80
This commit is contained in:
Lin Yang 2019-09-10 15:09:50 -07:00
parent 20780a2e0b
commit 4c755bec26
1 changed files with 24 additions and 0 deletions

View File

@ -120,6 +120,18 @@ class ResourceBase(base.ResourceBase):
description = base.Field("Description") description = base.Field("Description")
"""The resource description""" """The resource description"""
def post(self, data):
"""Issue HTTP POST request to this resource"""
self._conn.post(self.path, data=data)
def patch(self, data):
"""Issue HTTP PATCH request to this resource"""
self._conn.patch(self.path, data=data)
def put(self, data):
"""Issue HTTP PUT request to this resource"""
self._conn.put(self.path, data=data)
def delete(self): def delete(self):
"""Delete this resource""" """Delete this resource"""
self._conn.delete(self._path) self._conn.delete(self._path)
@ -133,6 +145,18 @@ class ResourceCollectionBase(base.ResourceCollectionBase):
description = base.Field("Description") description = base.Field("Description")
"""The resource collection description""" """The resource collection description"""
def post(self, data):
"""Issue HTTP POST request to this resource"""
self._conn.post(self.path, data=data)
def patch(self, data):
"""Issue HTTP PATCH request to this resource"""
self._conn.patch(self.path, data=data)
def put(self, data):
"""Issue HTTP PUT request to this resource"""
self._conn.put(self.path, data=data)
def delete(self): def delete(self):
"""Delete this resource collection""" """Delete this resource collection"""
self._conn.delete(self._path) self._conn.delete(self._path)