Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gremlinapi/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
9 changes: 9 additions & 0 deletions tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading