ctfy.sdk.resources.activities

client.activities — platform activity log + histogram.

 1"""``client.activities`` — platform activity log + histogram."""
 2
 3from __future__ import annotations
 4
 5import builtins
 6from typing import Any
 7
 8from ctfy.sdk._helpers import _raise_for_status
 9from ctfy.sdk.base import BaseHttpClient
10from ctfy.server.models import Activity, ActivityTimeseries
11
12
13class ActivitiesResource:
14    """The public activity feed and its bucketed timeseries."""
15
16    def __init__(self, http: BaseHttpClient) -> None:
17        self._http = http
18
19    def list(
20        self,
21        team_id: str = "",
22        challenge_id: str = "",
23        event: str = "",
24        competition_id: str = "",
25        offset: int = 0,
26        limit: int = 100,
27    ) -> builtins.list[Activity]:
28        """Get platform activity log.
29
30        ``competition_id`` narrows to rows credited to that
31        competition's teams.
32        """
33        params: dict[str, Any] = {"offset": offset, "limit": limit}
34        if team_id:
35            params["team_id"] = team_id
36        if challenge_id:
37            params["challenge_id"] = challenge_id
38        if event:
39            params["event"] = event
40        if competition_id:
41            params["competition_id"] = competition_id
42        resp = self._http.request("GET", "/activities", params=params)
43        _raise_for_status(resp)
44        return [Activity.model_validate(a) for a in resp.json()["items"]]
45
46    def timeseries(
47        self,
48        *,
49        team_id: str = "",
50        challenge_id: str = "",
51        event: str = "",
52        window: int = 86400,
53        bucket: int = 3600,
54    ) -> ActivityTimeseries:
55        """Bucketed activity-event counts (the histogram on the activity
56        page). ``window`` + ``bucket`` are in seconds."""
57        params: dict[str, Any] = {"window": window, "bucket": bucket}
58        if team_id:
59            params["team_id"] = team_id
60        if challenge_id:
61            params["challenge_id"] = challenge_id
62        if event:
63            params["event"] = event
64        resp = self._http.request("GET", "/activities/timeseries", params=params)
65        _raise_for_status(resp)
66        return ActivityTimeseries.model_validate(resp.json())
class ActivitiesResource:
14class ActivitiesResource:
15    """The public activity feed and its bucketed timeseries."""
16
17    def __init__(self, http: BaseHttpClient) -> None:
18        self._http = http
19
20    def list(
21        self,
22        team_id: str = "",
23        challenge_id: str = "",
24        event: str = "",
25        competition_id: str = "",
26        offset: int = 0,
27        limit: int = 100,
28    ) -> builtins.list[Activity]:
29        """Get platform activity log.
30
31        ``competition_id`` narrows to rows credited to that
32        competition's teams.
33        """
34        params: dict[str, Any] = {"offset": offset, "limit": limit}
35        if team_id:
36            params["team_id"] = team_id
37        if challenge_id:
38            params["challenge_id"] = challenge_id
39        if event:
40            params["event"] = event
41        if competition_id:
42            params["competition_id"] = competition_id
43        resp = self._http.request("GET", "/activities", params=params)
44        _raise_for_status(resp)
45        return [Activity.model_validate(a) for a in resp.json()["items"]]
46
47    def timeseries(
48        self,
49        *,
50        team_id: str = "",
51        challenge_id: str = "",
52        event: str = "",
53        window: int = 86400,
54        bucket: int = 3600,
55    ) -> ActivityTimeseries:
56        """Bucketed activity-event counts (the histogram on the activity
57        page). ``window`` + ``bucket`` are in seconds."""
58        params: dict[str, Any] = {"window": window, "bucket": bucket}
59        if team_id:
60            params["team_id"] = team_id
61        if challenge_id:
62            params["challenge_id"] = challenge_id
63        if event:
64            params["event"] = event
65        resp = self._http.request("GET", "/activities/timeseries", params=params)
66        _raise_for_status(resp)
67        return ActivityTimeseries.model_validate(resp.json())

The public activity feed and its bucketed timeseries.

ActivitiesResource(http: ctfy.sdk.base.BaseHttpClient)
17    def __init__(self, http: BaseHttpClient) -> None:
18        self._http = http
def list( self, team_id: str = '', challenge_id: str = '', event: str = '', competition_id: str = '', offset: int = 0, limit: int = 100) -> list[ctfy.server.models.Activity]:
20    def list(
21        self,
22        team_id: str = "",
23        challenge_id: str = "",
24        event: str = "",
25        competition_id: str = "",
26        offset: int = 0,
27        limit: int = 100,
28    ) -> builtins.list[Activity]:
29        """Get platform activity log.
30
31        ``competition_id`` narrows to rows credited to that
32        competition's teams.
33        """
34        params: dict[str, Any] = {"offset": offset, "limit": limit}
35        if team_id:
36            params["team_id"] = team_id
37        if challenge_id:
38            params["challenge_id"] = challenge_id
39        if event:
40            params["event"] = event
41        if competition_id:
42            params["competition_id"] = competition_id
43        resp = self._http.request("GET", "/activities", params=params)
44        _raise_for_status(resp)
45        return [Activity.model_validate(a) for a in resp.json()["items"]]

Get platform activity log.

competition_id narrows to rows credited to that competition's teams.

def timeseries( self, *, team_id: str = '', challenge_id: str = '', event: str = '', window: int = 86400, bucket: int = 3600) -> ctfy.server.models.ActivityTimeseries:
47    def timeseries(
48        self,
49        *,
50        team_id: str = "",
51        challenge_id: str = "",
52        event: str = "",
53        window: int = 86400,
54        bucket: int = 3600,
55    ) -> ActivityTimeseries:
56        """Bucketed activity-event counts (the histogram on the activity
57        page). ``window`` + ``bucket`` are in seconds."""
58        params: dict[str, Any] = {"window": window, "bucket": bucket}
59        if team_id:
60            params["team_id"] = team_id
61        if challenge_id:
62            params["challenge_id"] = challenge_id
63        if event:
64            params["event"] = event
65        resp = self._http.request("GET", "/activities/timeseries", params=params)
66        _raise_for_status(resp)
67        return ActivityTimeseries.model_validate(resp.json())

Bucketed activity-event counts (the histogram on the activity page). window + bucket are in seconds.