From 4c755bec2677195c279e8aaef3f580c145c347d4 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Tue, 10 Sep 2019 15:09:50 -0700 Subject: [PATCH] Add PUT, PATCH and POST method to base resource Change-Id: I0e5bc1a79fe1be73b900a4cecce9a73f12a20d80 --- rsd_lib/base.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rsd_lib/base.py b/rsd_lib/base.py index dd82230..8f84e52 100644 --- a/rsd_lib/base.py +++ b/rsd_lib/base.py @@ -120,6 +120,18 @@ class ResourceBase(base.ResourceBase): description = base.Field("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): """Delete this resource""" self._conn.delete(self._path) @@ -133,6 +145,18 @@ class ResourceCollectionBase(base.ResourceCollectionBase): description = base.Field("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): """Delete this resource collection""" self._conn.delete(self._path)