Browse Source

Add PUT, PATCH and POST method to base resource

Change-Id: I0e5bc1a79fe1be73b900a4cecce9a73f12a20d80
tags/1.2.0
Lin Yang 6 days ago
parent
commit
4c755bec26
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      rsd_lib/base.py

+ 24
- 0
rsd_lib/base.py View File

@@ -120,6 +120,18 @@ class ResourceBase(base.ResourceBase):
120 120
     description = base.Field("Description")
121 121
     """The resource description"""
122 122
 
123
+    def post(self, data):
124
+        """Issue HTTP POST request to this resource"""
125
+        self._conn.post(self.path, data=data)
126
+
127
+    def patch(self, data):
128
+        """Issue HTTP PATCH request to this resource"""
129
+        self._conn.patch(self.path, data=data)
130
+
131
+    def put(self, data):
132
+        """Issue HTTP PUT request to this resource"""
133
+        self._conn.put(self.path, data=data)
134
+
123 135
     def delete(self):
124 136
         """Delete this resource"""
125 137
         self._conn.delete(self._path)
@@ -133,6 +145,18 @@ class ResourceCollectionBase(base.ResourceCollectionBase):
133 145
     description = base.Field("Description")
134 146
     """The resource collection description"""
135 147
 
148
+    def post(self, data):
149
+        """Issue HTTP POST request to this resource"""
150
+        self._conn.post(self.path, data=data)
151
+
152
+    def patch(self, data):
153
+        """Issue HTTP PATCH request to this resource"""
154
+        self._conn.patch(self.path, data=data)
155
+
156
+    def put(self, data):
157
+        """Issue HTTP PUT request to this resource"""
158
+        self._conn.put(self.path, data=data)
159
+
136 160
     def delete(self):
137 161
         """Delete this resource collection"""
138 162
         self._conn.delete(self._path)

Loading…
Cancel
Save