# retoor <retoor@molodetz.nl>
from __future__ import annotations
from ..spec import Action
from ._shared import ATTACHMENTS, body, confirm, path, query
GIST_ACTIONS: tuple[Action, ...] = (
Action(
name="list_gists",
method="GET",
path="/gists",
summary="List gists",
requires_auth=False,
params=(
query("language", "Filter by language."),
query("user_uid", "Filter by owner uid."),
query("search", "Search gist title, description, and author username."),
query("before", "Pagination cursor."),
),
),
Action(
name="view_gist",
method="GET",
path="/gists/{gist_slug}",
summary="View a gist by slug",
requires_auth=False,
params=(
path(
"gist_slug",
"Exact gist slug copied from a /gists/... link in a listing response; do not build it from the title.",
),
),
),
Action(
name="create_gist",
method="POST",
path="/gists/create",
summary="Create a gist",
params=(
body("title", "Gist title.", required=True),
body("source_code", "Gist source code.", required=True),
body("description", "Gist description."),
body("language", "Programming language."),
body("attachment_uids", ATTACHMENTS),
),
),
Action(
name="edit_gist",
method="POST",
path="/gists/edit/{gist_slug}",
summary="Edit a gist",
params=(
path(
"gist_slug",
"Exact gist slug copied from a /gists/... link in a listing response; do not build it from the title.",
),
body("title", "Gist title.", required=True),
body("source_code", "Gist source code.", required=True),
body("description", "Gist description."),
body("language", "Programming language."),
),
),
Action(
name="delete_gist",
method="POST",
path="/gists/delete/{gist_slug}",
summary="Delete a gist (your own, or any gist when you are an administrator). Soft delete, confirmation required",
params=(
path(
"gist_slug",
"Exact gist slug copied from a /gists/... link in a listing response; do not build it from the title.",
),
confirm(),
),
),
)