# retoor <retoor@molodetz.nl>
from __future__ import annotations
from ..spec import Action
from ._shared import body, confirm, path
MOLOUPTIME_ACTIONS: tuple[Action, ...] = (
Action(
name="monitor_create",
method="POST",
path="/monitors/checks",
summary="Create a new uptime monitor check",
description=(
"Creates an uptime monitoring check. type is one of 'http', 'dns', or 'port'. "
"For HTTP checks, target must be a public URL. For DNS checks, target is a hostname."
" For port checks, target is a hostname and port is required."
),
params=(
body("name", "Human-readable name for the check.", required=True),
body("check_type", "Type of check: 'http', 'dns', or 'port'.", required=True),
body("target", "The URL, hostname, or address to check.", required=True),
body("interval_seconds", "Seconds between checks (min 10, default 60)."),
body("description", "Optional description for the check."),
),
requires_auth=True,
),
Action(
name="monitor_list",
method="GET",
path="/monitors/checks",
summary="List your uptime monitors",
description="Returns all monitor checks for the current user (or all checks for admins).",
requires_auth=True,
read_only=True,
),
Action(
name="monitor_detail",
method="GET",
path="/monitors/checks/{check_uid}",
summary="Get details of a monitor check",
description="Returns the check details including all check items.",
params=(path("check_uid", "UID of the monitor check"),),
requires_auth=True,
read_only=True,
),
Action(
name="monitor_delete",
method="DELETE",
path="/monitors/checks/{check_uid}",
summary="Delete a monitor check",
description="Soft-deletes a monitor check and all its items.",
params=(
path("check_uid", "UID of the monitor check"),
confirm(),
),
requires_auth=True,
),
Action(
name="monitor_toggle",
method="POST",
path="/monitors/checks/{check_uid}/toggle",
summary="Enable or disable a monitor check",
description="Toggles the enabled state of a monitor check on/off.",
params=(path("check_uid", "UID of the monitor check"),),
requires_auth=True,
),
Action(
name="monitor_groups_list",
method="GET",
path="/monitors/groups",
summary="List monitor groups",
description="Returns all monitor groups for the current user.",
requires_auth=True,
read_only=True,
),
Action(
name="monitor_group_create",
method="POST",
path="/monitors/groups",
summary="Create a monitor group",
description="Creates a group for organizing monitor checks.",
params=(
body("name", "Group name.", required=True),
body("description", "Optional group description."),
),
requires_auth=True,
),
Action(
name="monitor_admin_stats",
method="GET",
path="/monitors/admin/stats",
summary="Admin: view cross-user monitor statistics",
description="Returns aggregate statistics about all monitors (admin only).",
requires_auth=True,
requires_admin=True,
read_only=True,
),
Action(
name="monitor_escalation_policies",
method="GET",
path="/monitors/escalation-policies",
summary="List escalation policies",
description="Returns escalation policies for the current user.",
requires_auth=True,
read_only=True,
),
)
__all__ = ["MOLOUPTIME_ACTIONS"]