@@ -142,15 +142,18 @@ def delete_user(
142142 self ,
143143 token : Union [str , uuid .UUID ],
144144 user_id : Union [str , uuid .UUID ],
145- password : str ,
145+ password : Optional [str ] = None ,
146+ ** kwargs : Dict [str , Any ],
146147 ) -> BugoutUser :
147148 delete_user_path = f"user/{ user_id } "
148- data = {
149- "password" : password ,
150- }
149+ data = {}
150+ if password is not None :
151+ data . update ({ "password" : password })
151152 headers = {
152153 "Authorization" : f"Bearer { token } " ,
153154 }
155+ if "headers" in kwargs .keys ():
156+ headers .update (kwargs ["headers" ])
154157 result = self ._call (
155158 method = Method .delete , path = delete_user_path , headers = headers , data = data
156159 )
@@ -166,13 +169,28 @@ def create_token(self, username: str, password: str) -> BugoutToken:
166169 result = self ._call (method = Method .post , path = create_token_path , data = data )
167170 return BugoutToken (** result )
168171
169- def revoke_token (self , token : Union [str , uuid .UUID ]) -> uuid .UUID :
172+ def create_token_restricted (self , token : Union [str , uuid .UUID ]) -> BugoutToken :
173+ create_token_path = "token/restricted"
174+ headers = {
175+ "Authorization" : f"Bearer { token } " ,
176+ }
177+ result = self ._call (method = Method .post , path = create_token_path , headers = headers )
178+ return BugoutToken (** result )
179+
180+ def revoke_token (
181+ self ,
182+ token : Union [str , uuid .UUID ],
183+ target_token : Optional [Union [str , uuid .UUID ]] = None ,
184+ ) -> uuid .UUID :
170185 revoke_token_path = "token"
171186 headers = {
172187 "Authorization" : f"Bearer { token } " ,
173188 }
189+ data = {}
190+ if target_token is not None :
191+ data .update ({"target_token" : target_token })
174192 result = self ._call (
175- method = Method .delete , path = revoke_token_path , headers = headers
193+ method = Method .delete , path = revoke_token_path , headers = headers , data = data
176194 )
177195 return result
178196
0 commit comments