From 36dbf4a77814c7c45798864f21d561991a13fa2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 31 May 2019 14:19:24 +0200 Subject: [PATCH] Allow PATCHing users This is used to set the username from the settings view. --- pillarsdk/users.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pillarsdk/users.py b/pillarsdk/users.py index edfe297..4c14d59 100755 --- a/pillarsdk/users.py +++ b/pillarsdk/users.py @@ -4,11 +4,12 @@ from .resource import List from .resource import Find from .resource import Create from .resource import Post +from .resource import Patch from .resource import Update from .resource import Delete -class User(List, Find, Create, Post, Update, Delete): +class User(List, Find, Create, Post, Update, Delete, Patch): """User class wrapping the REST nodes endpoint """ path = "users" @@ -30,3 +31,10 @@ class User(List, Find, Create, Post, Update, Delete): """Returns info about the current user, identified by auth token.""" return cls.find_from_endpoint('/users/me', params=params, api=api) + + def set_username(self, new_username: str, api): + """PATCH the user to set the new username.""" + + self.username = new_username + return self.patch({'op': 'set-username', 'username': new_username}, + api=api)