summaryrefslogtreecommitdiff
path: root/server/szurubooru/api/snapshot_api.py
blob: 87012a2f454ae7a5c524540dbfa8506a97a3a5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from typing import Dict

from szurubooru import rest, search
from szurubooru.func import auth, snapshots

_search_executor = search.Executor(search.configs.SnapshotSearchConfig())


@rest.routes.get("/snapshots/?")
def get_snapshots(
    ctx: rest.Context, _params: Dict[str, str] = {}
) -> rest.Response:
    auth.verify_privilege(ctx.user, "snapshots:list")
    return _search_executor.execute_and_serialize(
        ctx, lambda snapshot: snapshots.serialize_snapshot(snapshot, ctx.user)
    )