Allow PATCHing nodes.

This commit is contained in:
2016-07-28 11:28:32 +02:00
parent 50bc2e8311
commit 3c39506014
2 changed files with 19 additions and 1 deletions

View File

@@ -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"

View File

@@ -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)