|
|
@@ -22,6 +22,8 @@ async def _probe(key: str, api: ServiceAPI) -> dict:
|
|
|
|
|
|
@router.get('/credentials')
|
|
|
async def get_credentials_status():
|
|
|
+ # deliberately a fresh instance: a probe through the singleton would read
|
|
|
+ # its warm calendar cache and report ok without touching the service
|
|
|
api = ServiceAPI()
|
|
|
keys = services()
|
|
|
results = await asyncio.gather(*[_probe(k, api) for k in keys])
|
|
|
@@ -30,7 +32,7 @@ async def get_credentials_status():
|
|
|
|
|
|
@router.get('/credentials/{service}')
|
|
|
async def get_credential_status(service: str):
|
|
|
- api = ServiceAPI()
|
|
|
+ api = ServiceAPI() # fresh instance — see get_credentials_status
|
|
|
if service not in api._clients:
|
|
|
return check_credentials(service)
|
|
|
return await _probe(service, api)
|
|
|
@@ -41,7 +43,7 @@ async def post_credentials_refresh(body: dict = Body(default={})):
|
|
|
"""Trigger automatic credential refresh for one service (body: {service: key}) or all services."""
|
|
|
service = (body or {}).get('service')
|
|
|
keys = [service] if service else services()
|
|
|
- api = ServiceAPI()
|
|
|
+ api = ServiceAPI.get()
|
|
|
|
|
|
async def _refresh(key: str) -> None:
|
|
|
try:
|
|
|
@@ -56,4 +58,5 @@ async def post_credentials_refresh(body: dict = Body(default={})):
|
|
|
@router.put('/credentials/{service}', status_code=204)
|
|
|
async def put_credentials(service: str, credentials: dict[str, str] = Body(...)):
|
|
|
set_credentials(service, credentials)
|
|
|
+ ServiceAPI.get().reload_client(service)
|
|
|
asyncio.create_task(probe_once())
|