diff --git a/gremlinapi/users.py b/gremlinapi/users.py index 80e4480..5ce15e6 100644 --- a/gremlinapi/users.py +++ b/gremlinapi/users.py @@ -114,6 +114,24 @@ def deactivate_user( (resp, body) = https_client.api_call(method, endpoint, **payload) return body + @classmethod + @register_cli_action("remove_user_from_team", ("email", "body"), ("",)) + def remove_user_from_team( + cls, + https_client: Type[GremlinAPIHttpClient] = get_gremlin_httpclient(), + *args: tuple, + **kwargs: dict, + ) -> dict: + method: str = "POST" + email: str = cls._error_if_not_email(**kwargs) + team_ids: Union[list, dict] = cls._error_if_not_json_body(**kwargs) + if isinstance(team_ids, str): + team_ids = [team_ids] + endpoint: str = f"/users/{email}/teams/remove" + payload: dict = cls._payload(**{"headers": https_client.header(), "data": {"teamIds": team_ids}}) # type: ignore + (resp, body) = https_client.api_call(method, endpoint, **payload) + return body + @classmethod @register_cli_action("list_active_user", ("",), ("teamId", "pageSize")) def list_active_users( diff --git a/pyproject.toml b/pyproject.toml index 79cc569..1ac2ca0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "gremlinapi" -version = "0.19.3" +version = "0.20.0" description = "Gremlin library for Python" readme = "README.md" license = { text = "Apache 2.0" } diff --git a/tests/test_users.py b/tests/test_users.py index bb3aac8..3b270a8 100644 --- a/tests/test_users.py +++ b/tests/test_users.py @@ -46,6 +46,15 @@ def test_deactivate_user_with_decorator(self, mock_get) -> None: mock_get.return_value.json = mock_json self.assertEqual(GremlinAPIUsers.deactivate_user(**mock_users), mock_data) + @patch("requests.post") + def test_remove_user_from_team_with_decorator(self, mock_post) -> None: + mock_post.return_value = requests.Response() + mock_post.return_value.status_code = 200 + mock_post.return_value.json = mock_json + self.assertEqual( + GremlinAPIUsers.remove_user_from_team(**{**mock_users, **mock_body}), mock_data + ) + @patch("requests.get") def test_list_active_users_with_decorator(self, mock_get) -> None: mock_get.return_value = requests.Response()