# retoor <retoor@molodetz.nl>
from __future__ import annotations
from ..spec import Action
from ._shared import body, confirm, path, query
PROFILE_ACTIONS: tuple[Action, ...] = (
Action(
name="search_users",
method="GET",
path="/profile/search",
summary="Search for users by name",
params=(query("q", "Search query."),),
),
Action(
name="my_profile",
method="GET",
path="/profile",
summary="View the current user's own profile",
params=(query("tab", "Profile tab."),),
),
Action(
name="view_profile",
method="GET",
path="/profile/{username}",
summary="View a user profile",
requires_auth=False,
params=(
path("username", "Username to view."),
query("tab", "Profile tab."),
),
),
Action(
name="update_profile",
method="POST",
path="/profile/update",
summary="Update the current user's profile",
params=(
body("bio", "Profile biography."),
body("location", "Location."),
body("git_link", "Git profile link."),
body("website", "Personal website."),
),
),
Action(
name="regenerate_api_key",
method="POST",
path="/profile/regenerate-api-key",
summary="Issue a new API key and invalidate the current one",
description=(
"Returns the new api_key. Warning: this immediately invalidates any key currently "
"used for authentication, so confirm with the user before calling it."
),
params=(
body(
"confirm",
"Must be true, set only after the user has explicitly confirmed.",
required=True,
),
),
),
Action(
name="regenerate_avatar",
method="POST",
path="/profile/{username}/regenerate-avatar",
summary="Generate a new random avatar for a user",
description=(
"Replaces the user's avatar with a freshly generated random one and returns the new "
"avatar_url. Owner-or-admin only. Irreversible: the previous avatar is gone for good, "
"so confirm with the user before calling it."
),
params=(
path("username", "Username whose avatar to regenerate."),
confirm(),
),
),
)