ctfy.sdk.admin_resources.admin_invites
client.admin.admin_invites -- administrator invitations to addresses
with no account yet (super-admin, #2083).
1"""``client.admin.admin_invites`` -- administrator invitations to addresses 2with no account yet (super-admin, #2083).""" 3 4from __future__ import annotations 5 6from ctfy.core.state.models import AdminInviteKind, CompetitionGrantRole 7from ctfy.sdk._helpers import PagedList, _extract_items, _raise_for_status 8from ctfy.sdk.base import BaseHttpClient 9from ctfy.server.models import AdminInviteInfo 10 11 12class AdminAdminInvitesResource: 13 """Invite an address to be an admin; it is granted when the address is proved.""" 14 15 def __init__(self, http: BaseHttpClient) -> None: 16 self._http = http 17 18 def list( 19 self, 20 *, 21 kind: AdminInviteKind | None = None, 22 competition_id: str | None = None, 23 offset: int = 0, 24 limit: int = 50, 25 ) -> PagedList[AdminInviteInfo]: 26 """Invitations, optionally narrowed to a ``kind`` or one competition.""" 27 params: dict[str, str | int] = {"offset": offset, "limit": limit} 28 if kind is not None: 29 params["kind"] = kind 30 if competition_id is not None: 31 params["competition_id"] = competition_id 32 resp = self._http.request("GET", "/admin/admin-invites", params=params) 33 _raise_for_status(resp) 34 return _extract_items(resp.json(), AdminInviteInfo) 35 36 def send( 37 self, 38 email: str, 39 kind: AdminInviteKind, 40 *, 41 competition_id: str = "", 42 role: CompetitionGrantRole = "admin", 43 expires_in_days: int = 14, 44 ) -> AdminInviteInfo: 45 """Invite ``email``. The grant arrives when that address is proved 46 (OAuth, emailed sign-in code, verification code) before the 47 invitation expires; password registration proves nothing.""" 48 resp = self._http.request( 49 "POST", 50 "/admin/admin-invites", 51 json={ 52 "email": email, 53 "kind": kind, 54 "competition_id": competition_id, 55 "role": role, 56 "expires_in_days": expires_in_days, 57 }, 58 ) 59 _raise_for_status(resp) 60 return AdminInviteInfo.model_validate(resp.json()) 61 62 def revoke(self, invite_id: str) -> None: 63 """Withdraw an invitation that has not been claimed.""" 64 resp = self._http.request("DELETE", f"/admin/admin-invites/{invite_id}") 65 _raise_for_status(resp)
class
AdminAdminInvitesResource:
13class AdminAdminInvitesResource: 14 """Invite an address to be an admin; it is granted when the address is proved.""" 15 16 def __init__(self, http: BaseHttpClient) -> None: 17 self._http = http 18 19 def list( 20 self, 21 *, 22 kind: AdminInviteKind | None = None, 23 competition_id: str | None = None, 24 offset: int = 0, 25 limit: int = 50, 26 ) -> PagedList[AdminInviteInfo]: 27 """Invitations, optionally narrowed to a ``kind`` or one competition.""" 28 params: dict[str, str | int] = {"offset": offset, "limit": limit} 29 if kind is not None: 30 params["kind"] = kind 31 if competition_id is not None: 32 params["competition_id"] = competition_id 33 resp = self._http.request("GET", "/admin/admin-invites", params=params) 34 _raise_for_status(resp) 35 return _extract_items(resp.json(), AdminInviteInfo) 36 37 def send( 38 self, 39 email: str, 40 kind: AdminInviteKind, 41 *, 42 competition_id: str = "", 43 role: CompetitionGrantRole = "admin", 44 expires_in_days: int = 14, 45 ) -> AdminInviteInfo: 46 """Invite ``email``. The grant arrives when that address is proved 47 (OAuth, emailed sign-in code, verification code) before the 48 invitation expires; password registration proves nothing.""" 49 resp = self._http.request( 50 "POST", 51 "/admin/admin-invites", 52 json={ 53 "email": email, 54 "kind": kind, 55 "competition_id": competition_id, 56 "role": role, 57 "expires_in_days": expires_in_days, 58 }, 59 ) 60 _raise_for_status(resp) 61 return AdminInviteInfo.model_validate(resp.json()) 62 63 def revoke(self, invite_id: str) -> None: 64 """Withdraw an invitation that has not been claimed.""" 65 resp = self._http.request("DELETE", f"/admin/admin-invites/{invite_id}") 66 _raise_for_status(resp)
Invite an address to be an admin; it is granted when the address is proved.
def
list( self, *, kind: Optional[Literal['platform_admin', 'competition_admin', 'authoring_reviewer']] = None, competition_id: str | None = None, offset: int = 0, limit: int = 50) -> ctfy.sdk._helpers.PagedList[ctfy.server.models.AdminInviteInfo]:
19 def list( 20 self, 21 *, 22 kind: AdminInviteKind | None = None, 23 competition_id: str | None = None, 24 offset: int = 0, 25 limit: int = 50, 26 ) -> PagedList[AdminInviteInfo]: 27 """Invitations, optionally narrowed to a ``kind`` or one competition.""" 28 params: dict[str, str | int] = {"offset": offset, "limit": limit} 29 if kind is not None: 30 params["kind"] = kind 31 if competition_id is not None: 32 params["competition_id"] = competition_id 33 resp = self._http.request("GET", "/admin/admin-invites", params=params) 34 _raise_for_status(resp) 35 return _extract_items(resp.json(), AdminInviteInfo)
Invitations, optionally narrowed to a kind or one competition.
def
send( self, email: str, kind: Literal['platform_admin', 'competition_admin', 'authoring_reviewer'], *, competition_id: str = '', role: Literal['admin', 'reviewer'] = 'admin', expires_in_days: int = 14) -> ctfy.server.models.AdminInviteInfo:
37 def send( 38 self, 39 email: str, 40 kind: AdminInviteKind, 41 *, 42 competition_id: str = "", 43 role: CompetitionGrantRole = "admin", 44 expires_in_days: int = 14, 45 ) -> AdminInviteInfo: 46 """Invite ``email``. The grant arrives when that address is proved 47 (OAuth, emailed sign-in code, verification code) before the 48 invitation expires; password registration proves nothing.""" 49 resp = self._http.request( 50 "POST", 51 "/admin/admin-invites", 52 json={ 53 "email": email, 54 "kind": kind, 55 "competition_id": competition_id, 56 "role": role, 57 "expires_in_days": expires_in_days, 58 }, 59 ) 60 _raise_for_status(resp) 61 return AdminInviteInfo.model_validate(resp.json())
Invite email. The grant arrives when that address is proved
(OAuth, emailed sign-in code, verification code) before the
invitation expires; password registration proves nothing.