From fdcb22e281edf9823fb715f97610e6936565be8d Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 13 Feb 2024 19:23:46 +0000 Subject: Add API wrapper to remove a user from a Grafana team --- arthur/apis/grafana/teams.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'arthur/apis/grafana/teams.py') 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" -- cgit v1.2.3