Full API Documentation¶
Utils for making requests to the API.
- class polympics.clients.AppClient(credentials: Optional[polympics.types.Credentials] = None, base_url: str = 'http://127.0.0.1:8000')¶
Client that adds endpoints only available to apps.
- async create_callback(event: polympics.types.EventType, url: str, secret: str) polympics.types.Callback ¶
Register a callback for this app for a given event.
- async create_session(account: polympics.types.Account) polympics.types.Session ¶
Create a user authentication session.
- async delete_callback(event: polympics.types.EventType)¶
Delete the callback registered for this app for a given event.
- async get_callback(event: polympics.types.EventType) polympics.types.Callback ¶
Get the callback registered for this app for a given event.
- async get_callbacks() dict ¶
Get all callbacks registered for this app.
Returns a dict of event type to callback URL.
- async get_self() polympics.types.App ¶
Get metadata on the authenticated app.
- async reset_token() polympics.types.AppCredentials ¶
Reset the authenticated app’s token.
- class polympics.clients.UnauthenticatedClient(credentials: Optional[polympics.types.Credentials] = None, base_url: str = 'http://127.0.0.1:8000')¶
A client for making un-, user- or app-authenticated requests.
- async check_signups() bool ¶
Check if signups are currently open.
- async close()¶
Close the connection.
- async discord_authenticate(token: str) polympics.types.Session ¶
Create a session from a Discord user token.
- async get_account(id: int) polympics.types.Account ¶
Get an account by Discord ID.
- async get_award(award_id: int) polympics.types.Award ¶
Get an award by ID.
- async get_client() aiohttp.client.ClientSession ¶
Get the aiohttp client session, or create one.
- async get_team(team_id: int) polympics.types.Team ¶
Get a team by ID.
- async handle_response(response: aiohttp.client_reqrep.ClientResponse, data_type: Any = <class 'dict'>) Any ¶
Process a response from the API.
- list_accounts(search: Optional[str] = None, team: Optional[polympics.types.Team] = None) polympics.pagination.Paginator ¶
Get a paginator of accounts matching a query.
- list_teams(search: Optional[str] = None) polympics.pagination.Paginator ¶
Get a paginator of teams, optionally with a search query.
- async request(method: str, path: str, response_type: Any = <class 'dict'>, **kwargs: dict) Any ¶
Make a request to the API.
- async update_account(account: polympics.types.Account, name: Optional[str] = None, discriminator: Optional[int] = None, avatar_url: Optional[str] = None, team: Optional[polympics.types.Team] = None, grant_permissions: Optional[polympics.types.Permissions] = None, revoke_permissions: Optional[polympics.types.Permissions] = None, discord_token: Optional[str] = None) polympics.types.Account ¶
Edit an account.
- class polympics.clients.UserClient(credentials: Optional[polympics.types.Credentials] = None, base_url: str = 'http://127.0.0.1:8000')¶
Client that adds endpoints only available to users.
- async get_self() polympics.types.Account ¶
Get the account our credentials authenticate us for.
- async reset_token() polympics.types.Session ¶
Reset the session token.
Dataclasses to represent the various types returned by the API.
- class polympics.types.Account(id: int, name: str, discriminator: str, created_at: datetime.datetime, permissions: polympics.types.Permissions, awards: list, avatar_url: Optional[str] = None, team: Optional[polympics.types.Team] = None)¶
An account returned by the API.
- classmethod from_dict(data: dict)¶
Ensure the Discord ID is an int.
- class polympics.types.AccountTeamUpdateEvent(account: polympics.types.Account, team: Optional[polympics.types.Team])¶
An event for when an account’s team is changed.
- class polympics.types.App(username: str, name: str)¶
Metadata for an app.
- class polympics.types.AppCredentials(username: str, name: str, password: str)¶
Credentials and data for an app.
- class polympics.types.Award(id: int, title: str, image_url: str, awardees: Optional[list] = None, team: Optional[polympics.types.Team] = None)¶
An award returned by the API.
- class polympics.types.Callback(id: int, url: str, event: polympics.types.EventType)¶
A callback returned by the API.
- exception polympics.types.ClientError(code: int, detail: str)¶
A different client-resolvable error.
- class polympics.types.Credentials(username: str, password: str)¶
Credentials for a user session or app.
- exception polympics.types.DataError(code: int, issues: list)¶
An error present in the data passed to the server.
- class polympics.types.EventType(value)¶
An event type for a callback.
- class polympics.types.Permissions(manage_permissions: bool = False, manage_account_teams: bool = False, manage_account_details: bool = False, manage_teams: bool = False, authenticate_users: bool = False, manage_own_team: bool = False, manage_awards: bool = False)¶
Permissions, returned as bit flags by the API.
- classmethod from_int(value: int) polympics.types.Permissions ¶
Parse permissions from a series of bit flags.
- to_int() int ¶
Turn the permissions into a series of bit flags.
- property values: list¶
Get the permissions as a list of bools.
- exception polympics.types.PolympicsError(code: int)¶
An error returned by the API.
- exception polympics.types.ServerError(code: int)¶
An error on the server-side.
- class polympics.types.Session(username: str, password: str, expires_at: datetime.datetime)¶
Credentials and data for a user auth session.
- class polympics.types.Team(id: int, name: str, created_at: datetime.datetime, member_count: int, awards: list)¶
A team returned by the API.
Tool to handle pagination.