ctfy.sdk.admin_resources.competition_invites
client.admin.competition_invites — private-competition
participation allowlist (admin).
1"""``client.admin.competition_invites`` — private-competition 2participation allowlist (admin).""" 3 4from __future__ import annotations 5 6import builtins 7 8from ctfy.sdk._helpers import _extract_items, _raise_for_status 9from ctfy.sdk.base import BaseHttpClient 10from ctfy.server.models import CompetitionInviteInfo 11 12 13class AdminCompetitionInvitesResource: 14 """Invite / revoke users on a private competition's participation 15 allowlist. Managed by any competition admin (global or per-comp).""" 16 17 def __init__(self, http: BaseHttpClient) -> None: 18 self._http = http 19 20 def list( 21 self, competition_id: str, offset: int = 0, limit: int = 50 22 ) -> builtins.list[CompetitionInviteInfo]: 23 """Everyone invited to participate in one competition.""" 24 resp = self._http.request( 25 "GET", 26 f"/admin/competitions/{competition_id}/invites", 27 params={"offset": offset, "limit": limit}, 28 ) 29 _raise_for_status(resp) 30 return _extract_items(resp.json(), CompetitionInviteInfo) 31 32 def invite( 33 self, competition_id: str, *, user_id: str = "", email: str = "" 34 ) -> CompetitionInviteInfo: 35 """Invite a user to participate. Identify the target by 36 ``user_id`` or ``email`` (the server accepts either). The user 37 must already have an account.""" 38 resp = self._http.request( 39 "POST", 40 f"/admin/competitions/{competition_id}/invites", 41 json={"user_id": user_id, "email": email}, 42 ) 43 _raise_for_status(resp) 44 return CompetitionInviteInfo.model_validate(resp.json()) 45 46 def revoke(self, competition_id: str, user_id: str) -> None: 47 """Remove a user from the participation allowlist.""" 48 resp = self._http.request( 49 "DELETE", f"/admin/competitions/{competition_id}/invites/{user_id}" 50 ) 51 _raise_for_status(resp)
class
AdminCompetitionInvitesResource:
14class AdminCompetitionInvitesResource: 15 """Invite / revoke users on a private competition's participation 16 allowlist. Managed by any competition admin (global or per-comp).""" 17 18 def __init__(self, http: BaseHttpClient) -> None: 19 self._http = http 20 21 def list( 22 self, competition_id: str, offset: int = 0, limit: int = 50 23 ) -> builtins.list[CompetitionInviteInfo]: 24 """Everyone invited to participate in one competition.""" 25 resp = self._http.request( 26 "GET", 27 f"/admin/competitions/{competition_id}/invites", 28 params={"offset": offset, "limit": limit}, 29 ) 30 _raise_for_status(resp) 31 return _extract_items(resp.json(), CompetitionInviteInfo) 32 33 def invite( 34 self, competition_id: str, *, user_id: str = "", email: str = "" 35 ) -> CompetitionInviteInfo: 36 """Invite a user to participate. Identify the target by 37 ``user_id`` or ``email`` (the server accepts either). The user 38 must already have an account.""" 39 resp = self._http.request( 40 "POST", 41 f"/admin/competitions/{competition_id}/invites", 42 json={"user_id": user_id, "email": email}, 43 ) 44 _raise_for_status(resp) 45 return CompetitionInviteInfo.model_validate(resp.json()) 46 47 def revoke(self, competition_id: str, user_id: str) -> None: 48 """Remove a user from the participation allowlist.""" 49 resp = self._http.request( 50 "DELETE", f"/admin/competitions/{competition_id}/invites/{user_id}" 51 ) 52 _raise_for_status(resp)
Invite / revoke users on a private competition's participation allowlist. Managed by any competition admin (global or per-comp).
def
list( self, competition_id: str, offset: int = 0, limit: int = 50) -> list[ctfy.server.models.CompetitionInviteInfo]:
21 def list( 22 self, competition_id: str, offset: int = 0, limit: int = 50 23 ) -> builtins.list[CompetitionInviteInfo]: 24 """Everyone invited to participate in one competition.""" 25 resp = self._http.request( 26 "GET", 27 f"/admin/competitions/{competition_id}/invites", 28 params={"offset": offset, "limit": limit}, 29 ) 30 _raise_for_status(resp) 31 return _extract_items(resp.json(), CompetitionInviteInfo)
Everyone invited to participate in one competition.
def
invite( self, competition_id: str, *, user_id: str = '', email: str = '') -> ctfy.server.models.CompetitionInviteInfo:
33 def invite( 34 self, competition_id: str, *, user_id: str = "", email: str = "" 35 ) -> CompetitionInviteInfo: 36 """Invite a user to participate. Identify the target by 37 ``user_id`` or ``email`` (the server accepts either). The user 38 must already have an account.""" 39 resp = self._http.request( 40 "POST", 41 f"/admin/competitions/{competition_id}/invites", 42 json={"user_id": user_id, "email": email}, 43 ) 44 _raise_for_status(resp) 45 return CompetitionInviteInfo.model_validate(resp.json())
Invite a user to participate. Identify the target by
user_id or email (the server accepts either). The user
must already have an account.
def
revoke(self, competition_id: str, user_id: str) -> None:
47 def revoke(self, competition_id: str, user_id: str) -> None: 48 """Remove a user from the participation allowlist.""" 49 resp = self._http.request( 50 "DELETE", f"/admin/competitions/{competition_id}/invites/{user_id}" 51 ) 52 _raise_for_status(resp)
Remove a user from the participation allowlist.