implement spaceapid integration into API
All checks were successful
Build Container / Build Container (push) Successful in 4m38s
All checks were successful
Build Container / Build Container (push) Successful in 4m38s
This commit is contained in:
parent
394b423b8e
commit
ecd6c2c48f
6 changed files with 129 additions and 2 deletions
28
api/src/dooris_api/spaceapi.py
Normal file
28
api/src/dooris_api/spaceapi.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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"))
|
||||
|
||||
Loading…
Reference in a new issue