All checks were successful
Build Container / Build Container (push) Successful in 4m38s
28 lines
707 B
Python
28 lines
707 B
Python
import logging
|
|
from aiohttp import ClientSession, BasicAuth
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class SpaceApiClient:
|
|
"""
|
|
Client for interacting with spaceapid
|
|
|
|
ref: https://git.hamburg.ccc.de/CCCHH/spaceapid
|
|
"""
|
|
base_uri: str
|
|
http: ClientSession
|
|
|
|
def __init__(self, base_uri: str, auth: BasicAuth):
|
|
self.base_uri = base_uri
|
|
self.http = ClientSession(
|
|
base_url=base_uri,
|
|
auth=auth,
|
|
raise_for_status=True,
|
|
)
|
|
|
|
async def set_status(self, is_open: bool):
|
|
logger.info(f"Setting club status to open={is_open} via spaceapid")
|
|
await self.http.put("/state/open", data=str(is_open).encode("ASCII"))
|
|
|