diff options
author | 2025-07-16 10:00:10 +0100 | |
---|---|---|
committer | 2025-07-16 10:00:10 +0100 | |
commit | a6ac8a024cd0fc7ac5e17d7bb1b9ec4692e322d9 (patch) | |
tree | c01cf0b2990d520e0f1215c0e63897797eb99689 /arthur/apis/github/orgs.py | |
parent | Fix mistakes from my inferior brain (#327) (diff) |
Add new endpoints for removing organisation members
Diffstat (limited to 'arthur/apis/github/orgs.py')
-rw-r--r-- | arthur/apis/github/orgs.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/arthur/apis/github/orgs.py b/arthur/apis/github/orgs.py new file mode 100644 index 0000000..55039c8 --- /dev/null +++ b/arthur/apis/github/orgs.py @@ -0,0 +1,25 @@ +import aiohttp + +from arthur.apis.github import GitHubError, HEADERS, HTTP_403, HTTP_404 +from arthur.config import CONFIG + + +async def remove_org_member(username: str) -> None: + """Remove a user from the GitHub organisation.""" + async with aiohttp.ClientSession() as session: + endpoint = f"https://api.github.com/orgs/{CONFIG.github_org}/members/{username}" + + async with session.delete(endpoint, headers=HEADERS) as resp: + try: + resp.raise_for_status() + return await resp.json() + except aiohttp.ClientResponseError as e: + if e.status == HTTP_404: + msg = f"Team or user not found in the org: {e.message}" + raise GitHubError(msg) + if e.status == HTTP_403: + msg = f"Forbidden: {e.message}" + raise GitHubError(msg) + + msg = f"Unexpected error: {e.message}" + raise GitHubError(msg) |