Allow PATCHing nodes.
This commit is contained in:
@@ -9,13 +9,14 @@ from .resource import Post
|
||||
from .resource import Update
|
||||
from .resource import Delete
|
||||
from .resource import Replace
|
||||
from .resource import Patch
|
||||
from .exceptions import ResourceNotFound
|
||||
|
||||
from . import utils
|
||||
from .api import Api
|
||||
|
||||
|
||||
class Node(List, Find, Create, Post, Update, Delete, Replace):
|
||||
class Node(List, Find, Create, Post, Update, Delete, Replace, Patch):
|
||||
"""Node class wrapping the REST nodes endpoint
|
||||
"""
|
||||
path = "nodes"
|
||||
|
||||
@@ -385,3 +385,20 @@ class Post(Resource):
|
||||
return cls(new_attributes, api=self.api)"""
|
||||
self.merge(new_attributes)
|
||||
return self.success()
|
||||
|
||||
|
||||
class Patch(Resource):
|
||||
def patch(self, patch, api=None):
|
||||
"""Patch a resource.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> node = Node.find('12345')
|
||||
>>> node.patch({'op': 'upvote'})
|
||||
"""
|
||||
|
||||
api = api or self.api
|
||||
url = utils.join_url(self.path, self._id)
|
||||
|
||||
result = api.patch(url, patch)
|
||||
return Resource(result)
|
||||
|
||||
Reference in New Issue
Block a user