Skip to content

Commit 248acdb

Browse files
toothstonembuechse
andauthored
Align documentation and code for /status endpoint (#1182)
Signed-off-by: Friedrich Zahn <friedrich.zahn@alasca.cloud> Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> Co-authored-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent b57f427 commit 248acdb

2 files changed

Lines changed: 5 additions & 17 deletions

File tree

compliance-monitor/README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,14 @@ The final field is the desired state; the other fields are used to determine the
183183
(within one report, version and check uniquely determine a result; the scope is given here as well
184184
in case reports at some point contain multiple scopes).
185185

186-
### GET /status/{subject}
186+
### GET /status
187187

188-
Returns the current status of the subject. Use the `Accept` header to select desired content type:
189-
190-
- `text/html` (default): a snippet of HTML suitable for the end user;
191-
- `image/png`: a PNG image of a badge;
192-
- `application/json`: a short summary in JSON format.
188+
Returns the current status of all subjects in JSON format.
193189

194190
Query parameters:
195191

192+
- `subject` (optional): restrict subject
196193
- `scopeuuid` (optional): restrict scope
197-
- `version` (optional): restrict version
198-
- `privileged_view` (optional `0` or `1`, default `0`): request privileged view (see below)
199-
200-
If the privileged view is requested, then this request needs to be authenticated (via basic auth),
201-
either for the same subject or for some account with role `read_any`. This view will immediately
202-
show any non-pass result, whereas otherwise, such a result needs to be verified manually.
203194

204195
### GET /metrics/{subject}
205196

compliance-monitor/monitor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,18 +548,15 @@ def convert_result_rows_to_dict2(
548548
@app.get("/status")
549549
async def get_status(
550550
request: Request,
551-
account: Annotated[Optional[tuple[str, str]], Depends(auth)],
552551
conn: Annotated[connection, Depends(get_conn)],
553-
subject: str = None, scopeuuid: str = None, version: str = None,
552+
subject: str = None, scopeuuid: str = None,
554553
):
555-
check_role(account, subject, ROLES['read_any'])
556-
# note: text/html will be the default, but let's start with json to get the logic right
557554
accept = request.headers['accept']
558555
if 'application/json' not in accept and '*/*' not in accept:
559556
# see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406
560557
raise HTTPException(status_code=406, detail="client needs to accept application/json")
561558
with conn.cursor() as cur:
562-
rows2 = db_get_relevant_results2(cur, subject, scopeuuid, version, approved_only=False)
559+
rows2 = db_get_relevant_results2(cur, subject, scopeuuid, approved_only=False)
563560
return convert_result_rows_to_dict2(rows2, get_scopes(), include_report=True)
564561

565562

0 commit comments

Comments
 (0)