ctfy.sdk.admin_resources.competition_admins
client.admin.competition_admins — per-competition admin grants (admin).
1"""``client.admin.competition_admins`` — per-competition admin grants (admin).""" 2 3from __future__ import annotations 4 5import builtins 6 7from ctfy.sdk._helpers import _extract_items, _raise_for_status 8from ctfy.sdk.base import BaseHttpClient 9from ctfy.server.models import CompetitionAdminInfo 10 11 12class AdminCompetitionAdminsResource: 13 """Grant / revoke the per-competition admin role.""" 14 15 def __init__(self, http: BaseHttpClient) -> None: 16 self._http = http 17 18 def list( 19 self, competition_id: str, offset: int = 0, limit: int = 50 20 ) -> builtins.list[CompetitionAdminInfo]: 21 """Users granted admin on one competition.""" 22 resp = self._http.request( 23 "GET", 24 f"/admin/competitions/{competition_id}/admins", 25 params={"offset": offset, "limit": limit}, 26 ) 27 _raise_for_status(resp) 28 return _extract_items(resp.json(), CompetitionAdminInfo) 29 30 def grant( 31 self, competition_id: str, *, user_id: str = "", email: str = "" 32 ) -> CompetitionAdminInfo: 33 """Grant per-competition admin. Identify the target by 34 ``user_id`` or ``email`` (the server accepts either).""" 35 resp = self._http.request( 36 "POST", 37 f"/admin/competitions/{competition_id}/admins", 38 json={"user_id": user_id, "email": email}, 39 ) 40 _raise_for_status(resp) 41 return CompetitionAdminInfo.model_validate(resp.json()) 42 43 def revoke(self, competition_id: str, user_id: str) -> None: 44 """Revoke a user's per-competition admin grant.""" 45 resp = self._http.request( 46 "DELETE", f"/admin/competitions/{competition_id}/admins/{user_id}" 47 ) 48 _raise_for_status(resp)
class
AdminCompetitionAdminsResource:
13class AdminCompetitionAdminsResource: 14 """Grant / revoke the per-competition admin role.""" 15 16 def __init__(self, http: BaseHttpClient) -> None: 17 self._http = http 18 19 def list( 20 self, competition_id: str, offset: int = 0, limit: int = 50 21 ) -> builtins.list[CompetitionAdminInfo]: 22 """Users granted admin on one competition.""" 23 resp = self._http.request( 24 "GET", 25 f"/admin/competitions/{competition_id}/admins", 26 params={"offset": offset, "limit": limit}, 27 ) 28 _raise_for_status(resp) 29 return _extract_items(resp.json(), CompetitionAdminInfo) 30 31 def grant( 32 self, competition_id: str, *, user_id: str = "", email: str = "" 33 ) -> CompetitionAdminInfo: 34 """Grant per-competition admin. Identify the target by 35 ``user_id`` or ``email`` (the server accepts either).""" 36 resp = self._http.request( 37 "POST", 38 f"/admin/competitions/{competition_id}/admins", 39 json={"user_id": user_id, "email": email}, 40 ) 41 _raise_for_status(resp) 42 return CompetitionAdminInfo.model_validate(resp.json()) 43 44 def revoke(self, competition_id: str, user_id: str) -> None: 45 """Revoke a user's per-competition admin grant.""" 46 resp = self._http.request( 47 "DELETE", f"/admin/competitions/{competition_id}/admins/{user_id}" 48 ) 49 _raise_for_status(resp)
Grant / revoke the per-competition admin role.
def
list( self, competition_id: str, offset: int = 0, limit: int = 50) -> list[ctfy.server.models.CompetitionAdminInfo]:
19 def list( 20 self, competition_id: str, offset: int = 0, limit: int = 50 21 ) -> builtins.list[CompetitionAdminInfo]: 22 """Users granted admin on one competition.""" 23 resp = self._http.request( 24 "GET", 25 f"/admin/competitions/{competition_id}/admins", 26 params={"offset": offset, "limit": limit}, 27 ) 28 _raise_for_status(resp) 29 return _extract_items(resp.json(), CompetitionAdminInfo)
Users granted admin on one competition.
def
grant( self, competition_id: str, *, user_id: str = '', email: str = '') -> ctfy.server.models.CompetitionAdminInfo:
31 def grant( 32 self, competition_id: str, *, user_id: str = "", email: str = "" 33 ) -> CompetitionAdminInfo: 34 """Grant per-competition admin. Identify the target by 35 ``user_id`` or ``email`` (the server accepts either).""" 36 resp = self._http.request( 37 "POST", 38 f"/admin/competitions/{competition_id}/admins", 39 json={"user_id": user_id, "email": email}, 40 ) 41 _raise_for_status(resp) 42 return CompetitionAdminInfo.model_validate(resp.json())
Grant per-competition admin. Identify the target by
user_id or email (the server accepts either).
def
revoke(self, competition_id: str, user_id: str) -> None:
44 def revoke(self, competition_id: str, user_id: str) -> None: 45 """Revoke a user's per-competition admin grant.""" 46 resp = self._http.request( 47 "DELETE", f"/admin/competitions/{competition_id}/admins/{user_id}" 48 ) 49 _raise_for_status(resp)
Revoke a user's per-competition admin grant.