diff options
author | 2024-02-13 19:23:46 +0000 | |
---|---|---|
committer | 2024-02-13 19:38:40 +0000 | |
commit | fdcb22e281edf9823fb715f97610e6936565be8d (patch) | |
tree | 5cfce025fe22527f3238244ed99a0bb8aeda39f8 | |
parent | Don't keep track of the set of users added to Grafana team (diff) |
Add API wrapper to remove a user from a Grafana team
-rw-r--r-- | arthur/apis/grafana/__init__.py | 9 | ||||
-rw-r--r-- | arthur/apis/grafana/teams.py | 12 |
2 files changed, 20 insertions, 1 deletions
diff --git a/arthur/apis/grafana/__init__.py b/arthur/apis/grafana/__init__.py index 9e9910b..c55b74b 100644 --- a/arthur/apis/grafana/__init__.py +++ b/arthur/apis/grafana/__init__.py @@ -1,8 +1,15 @@ -from .teams import add_user_to_team, get_all_users, list_team_members, list_teams +from .teams import ( + add_user_to_team, + get_all_users, + list_team_members, + list_teams, + remove_user_from_team, +) __all__ = ( "add_user_to_team", "get_all_users", "list_team_members", "list_teams", + "remove_user_from_team", ) diff --git a/arthur/apis/grafana/teams.py b/arthur/apis/grafana/teams.py index e641d84..5d582b5 100644 --- a/arthur/apis/grafana/teams.py +++ b/arthur/apis/grafana/teams.py @@ -35,6 +35,18 @@ async def add_user_to_team( return await response.json() +async def remove_user_from_team( + user_id: int, + team_id: int, + session: aiohttp.ClientSession, +) -> dict[str, str]: + """AdRemove a Grafana user from a team.""" + endpoint = CONFIG.grafana_url + f"/api/teams/{team_id}/members/{user_id}" + async with session.delete(endpoint, headers=AUTH_HEADER) as response: + response.raise_for_status() + return await response.json() + + async def get_all_users(session: aiohttp.ClientSession) -> list[dict[str, str]]: """Get a grafana users.""" endpoint = CONFIG.grafana_url + "/api/org/users/lookup" |