Skip to content

Commit 86ecfdf

Browse files
christophelecsigmavirus24
authored andcommitted
Added user deletion + cleaned a bit the other funcs
1 parent 46fa7f4 commit 86ecfdf

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

github3/users.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,8 @@ def revoke_impersonation(self):
448448
:returns: bool -- True if successful, False otherwise
449449
"""
450450
url = self._build_url('admin', 'users', self.id, 'authorizations')
451-
response = self._delete(url)
452451

453-
return self._boolean(response, 204, 403)
452+
return self._boolean(self._delete(url), 204, 403)
454453

455454
@requires_auth
456455
def promote(self):
@@ -461,9 +460,8 @@ def promote(self):
461460
:returns: bool -- True if successful, False otherwise
462461
"""
463462
url = self._build_url('site_admin', base_url=self._api)
464-
response = self._put(url)
465463

466-
return self._boolean(response, 204, 403)
464+
return self._boolean(self._put(url), 204, 403)
467465

468466
@requires_auth
469467
def demote(self):
@@ -476,9 +474,8 @@ def demote(self):
476474
:returns: bool -- True if successful, False otherwise
477475
"""
478476
url = self._build_url('site_admin', base_url=self._api)
479-
response = self._delete(url)
480477

481-
return self._boolean(response, 204, 403)
478+
return self._boolean(self._delete(url), 204, 403)
482479

483480
@requires_auth
484481
def suspend(self):
@@ -491,9 +488,8 @@ def suspend(self):
491488
:returns: bool -- True if successful, False otherwise
492489
"""
493490
url = self._build_url('suspended', base_url=self._api)
494-
response = self._put(url)
495491

496-
return self._boolean(response, 204, 403)
492+
return self._boolean(self._put(url), 204, 403)
497493

498494
@requires_auth
499495
def unsuspend(self):
@@ -506,7 +502,16 @@ def unsuspend(self):
506502
:returns: bool -- True if successful, False otherwise
507503
"""
508504
url = self._build_url('suspended', base_url=self._api)
509-
response = self._delete(url)
510505

511-
return self._boolean(response, 204, 403)
506+
return self._boolean(self._delete(url), 204, 403)
512507

508+
@requires_auth
509+
def delete(self):
510+
"""Delete the user. Per GitHub API documentation, it is often preferable to suspend the user.
511+
512+
This is only available for admins of a GitHub Enterprise instance.
513+
514+
:returns: bool -- True if successful, False otherwise
515+
"""
516+
url = self._build_url('admin', 'users', self.id)
517+
return self._boolean(self._delete(url), 204, 403)

0 commit comments

Comments
 (0)