Add more features to circle editor

- Manage members
- Update name

(Normally, I’d fix this up into the initial implementation
commit, but things happened in between and the rebase would be
painful.)
This commit is contained in:
Jonas Schäfer
2021-01-21 17:35:42 +01:00
parent ff870ae71e
commit e18b733017
6 changed files with 200 additions and 35 deletions

View File

@@ -108,7 +108,7 @@ class AdminGroupInfo:
return cls(
id_=data["id"],
name=data["name"],
members=data["members"],
members=data.get("members", []),
)
@@ -924,7 +924,47 @@ class ProsodyClient:
new_name: typing.Optional[str] = None,
session: aiohttp.ClientSession,
) -> AdminGroupInfo:
pass
payload = {}
if new_name is not None:
payload["name"] = new_name
async with session.put(
self._admin_v1_endpoint(
"/groups/{}".format(id_)
),
json=payload,
) as resp:
self._raise_error_from_response(resp)
@autosession
async def add_group_member(
self,
id_: str,
localpart: str,
*,
session: aiohttp.ClientSession,
) -> None:
async with session.put(
self._admin_v1_endpoint(
"/groups/{}/members/{}".format(id_, localpart)
),
) as resp:
self._raise_error_from_response(resp)
@autosession
async def remove_group_member(
self,
id_: str,
localpart: str,
*,
session: aiohttp.ClientSession,
) -> None:
async with session.delete(
self._admin_v1_endpoint(
"/groups/{}/members/{}".format(id_, localpart)
),
) as resp:
self._raise_error_from_response(resp)
@autosession
async def delete_group(