ctfy.sdk.resources.changelog

client.changelog — the public "What's New" feed.

 1"""``client.changelog`` — the public "What's New" feed."""
 2
 3from __future__ import annotations
 4
 5from ctfy.sdk._helpers import _raise_for_status
 6from ctfy.sdk.base import BaseHttpClient
 7from ctfy.server.models import (
 8    ChangelogLatestResponse,
 9    ChangelogListResponse,
10    ChangelogSeenResponse,
11)
12
13
14class ChangelogResource:
15    """Read what shipped, and clear your own "What's New" marker.
16
17    The list needs no bearer — a changelog is read by people deciding
18    whether to run the platform — but ``latest`` answers a *per-caller*
19    question, so an authenticated client gets ``unseen`` and an anonymous
20    one gets ``False``.
21    """
22
23    def __init__(self, http: BaseHttpClient) -> None:
24        self._http = http
25
26    def list(self, page: int = 1, page_size: int = 20) -> ChangelogListResponse:
27        """Published entries, newest first. Drafts are never returned."""
28        resp = self._http.request(
29            "GET", "/changelog", params={"page": page, "page_size": page_size}
30        )
31        _raise_for_status(resp)
32        return ChangelogListResponse.model_validate(resp.json())
33
34    def latest(self) -> ChangelogLatestResponse:
35        """The newest publish time, plus whether it post-dates this
36        caller's last visit. Cheap enough to poll for a nav badge."""
37        resp = self._http.request("GET", "/changelog/latest")
38        _raise_for_status(resp)
39        return ChangelogLatestResponse.model_validate(resp.json())
40
41    def mark_seen(self) -> ChangelogSeenResponse:
42        """Stamp "read up to now" — clears the badge for this account."""
43        resp = self._http.request("POST", "/changelog/mark-seen")
44        _raise_for_status(resp)
45        return ChangelogSeenResponse.model_validate(resp.json())
class ChangelogResource:
15class ChangelogResource:
16    """Read what shipped, and clear your own "What's New" marker.
17
18    The list needs no bearer — a changelog is read by people deciding
19    whether to run the platform — but ``latest`` answers a *per-caller*
20    question, so an authenticated client gets ``unseen`` and an anonymous
21    one gets ``False``.
22    """
23
24    def __init__(self, http: BaseHttpClient) -> None:
25        self._http = http
26
27    def list(self, page: int = 1, page_size: int = 20) -> ChangelogListResponse:
28        """Published entries, newest first. Drafts are never returned."""
29        resp = self._http.request(
30            "GET", "/changelog", params={"page": page, "page_size": page_size}
31        )
32        _raise_for_status(resp)
33        return ChangelogListResponse.model_validate(resp.json())
34
35    def latest(self) -> ChangelogLatestResponse:
36        """The newest publish time, plus whether it post-dates this
37        caller's last visit. Cheap enough to poll for a nav badge."""
38        resp = self._http.request("GET", "/changelog/latest")
39        _raise_for_status(resp)
40        return ChangelogLatestResponse.model_validate(resp.json())
41
42    def mark_seen(self) -> ChangelogSeenResponse:
43        """Stamp "read up to now" — clears the badge for this account."""
44        resp = self._http.request("POST", "/changelog/mark-seen")
45        _raise_for_status(resp)
46        return ChangelogSeenResponse.model_validate(resp.json())

Read what shipped, and clear your own "What's New" marker.

The list needs no bearer — a changelog is read by people deciding whether to run the platform — but latest answers a per-caller question, so an authenticated client gets unseen and an anonymous one gets False.

ChangelogResource(http: ctfy.sdk.base.BaseHttpClient)
24    def __init__(self, http: BaseHttpClient) -> None:
25        self._http = http
def list( self, page: int = 1, page_size: int = 20) -> ctfy.server.models.ChangelogListResponse:
27    def list(self, page: int = 1, page_size: int = 20) -> ChangelogListResponse:
28        """Published entries, newest first. Drafts are never returned."""
29        resp = self._http.request(
30            "GET", "/changelog", params={"page": page, "page_size": page_size}
31        )
32        _raise_for_status(resp)
33        return ChangelogListResponse.model_validate(resp.json())

Published entries, newest first. Drafts are never returned.

def latest(self) -> ctfy.server.models.ChangelogLatestResponse:
35    def latest(self) -> ChangelogLatestResponse:
36        """The newest publish time, plus whether it post-dates this
37        caller's last visit. Cheap enough to poll for a nav badge."""
38        resp = self._http.request("GET", "/changelog/latest")
39        _raise_for_status(resp)
40        return ChangelogLatestResponse.model_validate(resp.json())

The newest publish time, plus whether it post-dates this caller's last visit. Cheap enough to poll for a nav badge.

def mark_seen(self) -> ctfy.server.models.ChangelogSeenResponse:
42    def mark_seen(self) -> ChangelogSeenResponse:
43        """Stamp "read up to now" — clears the badge for this account."""
44        resp = self._http.request("POST", "/changelog/mark-seen")
45        _raise_for_status(resp)
46        return ChangelogSeenResponse.model_validate(resp.json())

Stamp "read up to now" — clears the badge for this account.