package api import ( "net/http" "time" "github.com/google/uuid" "git.zb-server.de/ZB-Server/uptimesebi/internal/check" ) // sessionStarted is the answer of requests that sign in. var sessionStarted = obj{"status": "", "csrf_token": ""} // paged adds the cursors of a paged list to its response. func paged(o obj) obj { o["next_cursor"], o["prev_cursor"] = "", "" return o } // endpoints documents every route under /api/v1, in the order the docs // show them. var endpoints = []endpoint{ // Account {method: "POST", path: "/api/v1/auth/signup", tag: "Account", summary: "Create an account", public: true, description: "Depending on the installation, sign-up is open, limited to the first user, or closed. Where addresses are confirmed, answers `{\"status\": \"verification_sent\"}` and mails a link; the account signs in after confirming. Otherwise starts a session, and `org_name`/`org_slug`, if given, create a first organization. One account per mailbox (+suffixes and Gmail dots count as the same address); a client address may create only a few accounts a day (`429 signup_limit`).", req: signupRequest{}, resp: sessionStarted}, {method: "POST", path: "/api/v1/auth/verify", tag: "Account", summary: "Confirm an email address with the mailed token", public: true, description: "Signs the account in. Tokens are valid for 24 hours and once; `410 verification_expired` otherwise.", req: verifyRequest{}, resp: sessionStarted}, {method: "POST", path: "/api/v1/auth/verify/resend", tag: "Account", summary: "Mail a new confirmation link", public: true, description: "Answers the same whether or not an unconfirmed account with that address exists.", req: resendRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/orgs", tag: "Account", summary: "Create an organization", sessionOnly: true, description: "The account owns it, and it becomes the active organization. Limited per account by the platform (`422 org_limit`).", req: createOrgRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "slug": "", "redirect": ""}}, {method: "POST", path: "/api/v1/auth/login", tag: "Account", summary: "Sign in with email and password", public: true, description: "Answers `{\"status\": \"totp_required\"}` when the account has two-factor authentication; continue with /auth/login/totp.", req: loginRequest{}, resp: sessionStarted}, {method: "POST", path: "/api/v1/auth/login/totp", tag: "Account", summary: "Complete sign-in with a TOTP or recovery code", public: true, req: secondFactorRequest{}, resp: sessionStarted}, {method: "POST", path: "/api/v1/auth/logout", tag: "Account", summary: "Sign out", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/me", tag: "Account", summary: "The signed-in user and their organizations", resp: meView{}}, {method: "DELETE", path: "/api/v1/me/identities/:provider", tag: "Account", summary: "Unlink a platform identity provider from the account", sessionOnly: true, description: "Refused with `409 last_sign_in` when it is the account's only way to sign in.", status: http.StatusNoContent}, {method: "POST", path: "/api/v1/me/org", tag: "Account", summary: "Switch the active organization", sessionOnly: true, req: switchOrgRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/locale", tag: "Account", summary: "Set the interface language", public: true, req: localeRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/me/totp/setup", tag: "Account", summary: "Start setting up two-factor authentication", sessionOnly: true, resp: obj{"secret": "", "otpauth_url": "", "qr": ""}}, {method: "POST", path: "/api/v1/me/totp/enable", tag: "Account", summary: "Enable two-factor authentication", sessionOnly: true, description: "Returns single-use recovery codes, shown only this once.", req: totpRequest{}, resp: obj{"recovery_codes": []string{}}}, {method: "POST", path: "/api/v1/me/totp/disable", tag: "Account", summary: "Disable two-factor authentication", sessionOnly: true, req: reauthRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/me/totp/recovery-codes", tag: "Account", summary: "Replace the recovery codes", sessionOnly: true, req: reauthRequest{}, resp: obj{"recovery_codes": []string{}}}, {method: "GET", path: "/api/v1/me/audit", tag: "Account", summary: "Sign-ins and security changes of the account", description: "Paged, newest first.", resp: paged(obj{"events": []auditEventView{}})}, {method: "GET", path: "/api/v1/me/export", tag: "Account", summary: "Export all personal data (GDPR Art. 15, 20)", description: "`?format=pdf` returns a PDF instead of JSON.", resp: accountExport{}}, {method: "POST", path: "/api/v1/me/delete", tag: "Account", summary: "Delete the account (GDPR Art. 17)", sessionOnly: true, description: "Organizations the user is the last owner of are deleted with the account, with all their monitors, even when they have other members; organizations with further owners are left. Open to suspended accounts and to those that have not accepted the terms.", req: deletionRequest{}, resp: obj{"status": ""}}, {method: "POST", path: "/api/v1/consent", tag: "Account", summary: "Accept the platform's privacy policy and terms", sessionOnly: true, description: "`versions` are the versions shown, e.g. `privacy:12,terms:14`; `409 consent_outdated` when a document changed meanwhile. Until an account accepted the current versions, other requests of its sessions get `403 consent_required`.", req: consentRequest{}, resp: obj{"redirect": ""}}, {method: "POST", path: "/api/v1/markdown/preview", tag: "Account", summary: "Render Markdown as pages will show it", req: previewRequest{}, resp: obj{"html": ""}}, {method: "POST", path: "/api/v1/invitations/:token/accept", tag: "Account", summary: "Accept an invitation with the signed-in account", sessionOnly: true, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/invitations/:token/signup", tag: "Account", summary: "Create an account through an invitation", public: true, req: inviteSignupRequest{}, resp: sessionStarted}, // Monitors {method: "GET", path: "/api/v1/org/monitors", tag: "Monitors", summary: "List monitors with their latest results", description: "Paged by name. Only monitors the caller may read, so a page may hold fewer; header values and heartbeat tokens only for those who may change the monitor.", perm: "monitors.read", resp: paged(obj{"monitors": []monitorView{}})}, {method: "POST", path: "/api/v1/org/monitors", tag: "Monitors", summary: "Create a monitor", description: "`type` is one of http, json, prometheus, tcp, tls, dns, icmp, postgres, mysql, mssql, mongodb, redis, mqtt, kafka, rabbitmq, grpc, smtp, radius, snmp, steam, minecraft, docker, heartbeat or alertmanager (GET /api/v1/org/check-types lists those offered); `config` depends on it (see HTTPConfig, JSONConfig, PrometheusConfig, DNSConfig, TLSConfig, DBConfig, BrokerConfig, GRPCConfig, SMTPConfig, RADIUSConfig, SNMPConfig, GameConfig, DockerConfig, HeartbeatConfig, AlertmanagerConfig). Passwords, RADIUS secrets and SNMP communities are stored encrypted and never returned: `secrets_set` names those set, and an update that leaves one empty keeps it. Heartbeat and alertmanager monitors take neither target nor regions; heartbeats return their `ping_url`. Omit `alert_group_ids` to assign the default alert group; an empty array disables notifications.", perm: "monitors.write", req: monitorRequest{}, status: http.StatusCreated, resp: monitorView{}}, {method: "PUT", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Change a monitor", perm: "monitors.write", description: "Omitting alert_group_ids preserves existing assignments; an empty array removes all alert groups.", req: monitorRequest{}, resp: monitorView{}}, {method: "DELETE", path: "/api/v1/org/monitors/:id", tag: "Monitors", summary: "Delete a monitor and its history", perm: "monitors.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/monitors/:id/evidence", tag: "Monitors", summary: "What checkers saw: captured responses", description: "Paged, newest first.", perm: "monitors.write", resp: paged(obj{"evidence": []evidenceSummary{}})}, {method: "GET", path: "/api/v1/org/monitors/:id/results", tag: "Monitors", summary: "A monitor's check results", description: "Paged, newest first, back to the end of raw result retention.", resp: paged(obj{"results": []resultView{}})}, {method: "GET", path: "/api/v1/org/monitors/:id/evidence/:evidence", tag: "Monitors", summary: "One captured response", description: "Redirect chain with headers, timing, certificate and the first 32 KiB of the body.", perm: "monitors.write", resp: obj{"id": uuid.UUID{}, "region": "", "checker_id": uuid.UUID{}, "time": time.Time{}, "ok": false, "status_code": new(int32), "error": new(string), "evidence": check.Evidence{}}}, {method: "GET", path: "/api/v1/org/checkers/:id", tag: "Monitors", summary: "What a checker instance is doing", description: "Platform checkers serve every organization; other organizations' work appears only as a count. `recent` is paged, newest first; a page may hold fewer results than `limit` when some belong to monitors you cannot read.", resp: checkerActivity{}}, {method: "GET", path: "/api/v1/org/limits", tag: "Organization", summary: "Limits in effect for the organization and its usage", description: "0 means unlimited. Creating beyond a limit gives 422 monitor_limit, status_page_limit, region_limit or platform_region_limit.", resp: usageView{}}, {method: "GET", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Monitor types this installation offers", resp: obj{"types": []string{}}}, {method: "PUT", path: "/api/v1/org/check-types", tag: "Monitors", summary: "Choose the monitor types offered to members", description: "Out of the types the platform offers; types left out are not offered for new monitors or type changes, existing monitors keep running.", perm: "org.manage", sessionOnly: true, req: checkTypesRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/groups", tag: "Monitors", summary: "List monitor groups", resp: obj{"groups": []groupView{}}}, {method: "POST", path: "/api/v1/org/groups", tag: "Monitors", summary: "Create a group", perm: "monitors.write", req: groupRequest{}, status: http.StatusCreated, resp: groupView{}}, {method: "PUT", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Rename or move a group", perm: "monitors.write", req: groupRequest{}, resp: groupView{}}, {method: "DELETE", path: "/api/v1/org/groups/:id", tag: "Monitors", summary: "Delete a group; its content moves up", perm: "monitors.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "List maintenance windows", perm: "monitors.read", description: "Paged, latest start first. Only windows the caller may read, so a page may hold fewer.", resp: paged(obj{"maintenance": []maintenanceView{}})}, {method: "POST", path: "/api/v1/org/maintenance", tag: "Monitors", summary: "Plan maintenance", description: "During maintenance, failures open no incidents and send no notifications.", perm: "monitors.write", req: maintenanceRequest{}, status: http.StatusCreated, resp: maintenanceView{}}, {method: "PUT", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Change maintenance", perm: "monitors.write", req: maintenanceRequest{}, resp: maintenanceView{}}, {method: "DELETE", path: "/api/v1/org/maintenance/:id", tag: "Monitors", summary: "Delete maintenance", perm: "monitors.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/alertmanager/alerts", tag: "Monitors", summary: "Alerts Alertmanager reports as firing", description: "Paged, newest first. With the alertmanager monitors each alert holds down; alerts no monitor follows have none.", perm: "monitors.read", resp: paged(obj{"alerts": []alertView{}})}, {method: "GET", path: "/api/v1/org/alertmanager/receivers", tag: "Monitors", summary: "List Alertmanager receivers", perm: "org.manage", resp: obj{"receivers": []receiverView{}}}, {method: "POST", path: "/api/v1/org/alertmanager/receivers", tag: "Monitors", summary: "Create a receiver URL for Alertmanager's webhook", description: "The URL is returned only this once. Alertmanager may also send its token as `Authorization: Bearer` to `/am`.", perm: "org.manage", sessionOnly: true, req: receiverRequest{}, status: http.StatusCreated, resp: obj{"receiver": receiverView{}, "url": ""}}, {method: "DELETE", path: "/api/v1/org/alertmanager/receivers/:id", tag: "Monitors", summary: "Delete a receiver", perm: "org.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/incidents", tag: "Monitors", summary: "List incidents", perm: "incidents.read", description: "Paged, newest first. `monitor_id` limits them to one monitor.", resp: paged(obj{"incidents": []incidentView{}})}, {method: "GET", path: "/api/v1/org/incidents/:id", tag: "Monitors", summary: "An incident with its updates", perm: "incidents.read", description: "`status` is `resolved` once the monitor recovered, otherwise the status of the latest update (`investigating`, `identified`, `monitoring`, `resolved`), empty before the first. Updates newest first, internal notes included.", resp: incidentDetailView{}}, {method: "PATCH", path: "/api/v1/org/incidents/:id", tag: "Monitors", summary: "Name an incident", perm: "incidents.write", description: "The title status pages show; empty shows the monitor's name.", req: incidentTitleRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/org/incidents/:id/updates", tag: "Monitors", summary: "Post an update with a status", perm: "incidents.write", description: "`status` is a built-in status or the `id` of one of the organization's own. `message` is Markdown. `public` (default true) shows it on status pages; false keeps it an internal note. The update's status becomes the incident's.", req: incidentUpdateRequest{}, resp: incidentUpdateView{}, status: http.StatusCreated}, {method: "DELETE", path: "/api/v1/org/incidents/:id/updates/:update", tag: "Monitors", summary: "Delete an update", perm: "incidents.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/incident-statuses", tag: "Monitors", summary: "List the organization's own incident statuses", perm: "incidents.read", resp: obj{"statuses": []incidentStatusView{}}}, {method: "POST", path: "/api/v1/org/incident-statuses", tag: "Monitors", summary: "Add an incident status with a color", perm: "org.manage", description: "`color` is `#rrggbb`. Updates use it by its `id` as `status`.", req: incidentStatusRequest{}, resp: incidentStatusView{}, status: http.StatusCreated}, {method: "PUT", path: "/api/v1/org/incident-statuses/:id", tag: "Monitors", summary: "Rename or recolor an incident status", perm: "org.manage", description: "Applies to the history of incidents that used it too.", req: incidentStatusRequest{}, status: http.StatusNoContent}, {method: "DELETE", path: "/api/v1/org/incident-statuses/:id", tag: "Monitors", summary: "Delete an unused incident status", perm: "org.manage", description: "`409 status_in_use` while updates use it.", status: http.StatusNoContent}, // Status pages {method: "GET", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "List status pages", resp: obj{"pages": []statusPageView{}}}, {method: "POST", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "Create a status page", perm: "statuspages.write", req: statusPageRequest{}, status: http.StatusCreated, resp: statusPageView{}}, {method: "PUT", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Change a status page", perm: "statuspages.write", req: statusPageRequest{}, resp: statusPageView{}}, {method: "DELETE", path: "/api/v1/org/statuspages/:id", tag: "Status pages", summary: "Delete a status page", perm: "statuspages.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/statuspages/:id/groups", tag: "Status pages", summary: "List status page groups", perm: "statuspages.read", resp: obj{"groups": []pageGroupView{}}}, {method: "POST", path: "/api/v1/org/statuspages/:id/groups", tag: "Status pages", summary: "Create a status page group", perm: "statuspages.write", req: pageGroupRequest{}, status: http.StatusCreated, resp: pageGroupView{}}, {method: "PUT", path: "/api/v1/org/statuspages/:id/groups/:group_id", tag: "Status pages", summary: "Rename, move or reorder a status page group", perm: "statuspages.write", req: pageGroupRequest{}, resp: pageGroupView{}}, {method: "DELETE", path: "/api/v1/org/statuspages/:id/groups/:group_id", tag: "Status pages", summary: "Delete a status page group", perm: "statuspages.write", description: "Child groups and monitors move up to the deleted group's parent.", status: http.StatusNoContent}, {method: "POST", path: "/api/v1/org/statuspages/:id/groups/import", tag: "Status pages", summary: "Import monitor groups into a status page", perm: "statuspages.write", description: "Copies the organization's monitor group tree for the page's monitors and maps them into the imported groups.", resp: obj{"groups": []pageGroupView{}}}, {method: "PUT", path: "/api/v1/org/statuspages/:id/monitors", tag: "Status pages", summary: "Set the monitors shown", perm: "statuspages.write", description: "Assigns monitors to optional nested groups via `group_id`. Legacy `section` names are mapped to top-level groups.", req: pageMonitorsRequest{}, status: http.StatusNoContent}, {method: "PUT", path: "/api/v1/org/statuspages/:id/domain", tag: "Status pages", summary: "Set a custom domain", perm: "statuspages.write", description: "Verify it with a TXT record before it is served.", req: domainRequest{}, resp: statusPageView{}}, {method: "POST", path: "/api/v1/org/statuspages/:id/domain/verify", tag: "Status pages", summary: "Verify the custom domain", perm: "statuspages.write", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/statuspages/:id/export", tag: "Status pages", summary: "Export the page as a single HTML file", perm: "statuspages.read", media: "text/html"}, // Alerting {method: "GET", path: "/api/v1/org/alert-groups", tag: "Alerting", summary: "List alert groups and their channels", perm: "notifications.read", resp: obj{"alert_groups": []alertGroupView{}}}, {method: "POST", path: "/api/v1/org/alert-groups", tag: "Alerting", summary: "Create an alert group", perm: "notifications.write", description: "Optional `quiet_hours` suppress notifications from this group during recurring local time windows (`start`/`end` as `HH:MM`, `start > end` wraps overnight, `00:00`–`00:00` or `24:00` covers the full day, empty `weekdays` means every day).", req: alertGroupRequest{}, status: http.StatusCreated, resp: alertGroupView{}}, {method: "PUT", path: "/api/v1/org/alert-groups/:id", tag: "Alerting", summary: "Update an alert group, its channels and quiet hours", perm: "notifications.write", description: "Omitting `quiet_hours` preserves existing quiet hours; an empty array removes them.", req: alertGroupRequest{}, resp: alertGroupView{}}, {method: "DELETE", path: "/api/v1/org/alert-groups/:id", tag: "Alerting", summary: "Delete an alert group", perm: "notifications.write", description: "The default group cannot be deleted. Deleting other groups removes their monitor assignments; no fallback group is assigned.", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/channels", tag: "Alerting", summary: "List notification channels", perm: "notifications.read", resp: obj{"channels": []channelView{}, "email_available": false}}, {method: "POST", path: "/api/v1/org/channels", tag: "Alerting", summary: "Create a channel", description: "`type` is webhook (`url`), email (`to`, `locale`) or one of slack, discord, teams, googlechat, mattermost, rocketchat, telegram, matrix, ntfy, gotify, pushover, pushbullet, signal, pagerduty, opsgenie, apprise with their `settings`. Secret settings are stored encrypted and never returned; on update, leaving one empty keeps it. Webhook channels return their signing secret once. New channels join the default alert group.", perm: "notifications.write", req: channelRequest{}, status: http.StatusCreated, resp: obj{"channel": channelView{}, "signing_secret": ""}}, {method: "PUT", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Change a channel", perm: "notifications.write", req: channelRequest{}, resp: obj{"channel": channelView{}, "signing_secret": ""}}, {method: "DELETE", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Delete a channel", perm: "notifications.write", status: http.StatusNoContent}, {method: "POST", path: "/api/v1/org/channels/:id/test", tag: "Alerting", summary: "Send a test notification", perm: "notifications.write", status: http.StatusNoContent}, // Organization {method: "PUT", path: "/api/v1/org/policy", tag: "Organization", summary: "Set sign-in and token policies", perm: "org.manage", sessionOnly: true, req: policyRequest{}, resp: obj{"require_totp": false, "require_sso": false, "api_token_max_days": new(int32)}}, {method: "GET", path: "/api/v1/org/members", tag: "Organization", summary: "List members and their roles", perm: "members.read", description: "Paged by email.", resp: paged(obj{"members": []memberView{}})}, {method: "DELETE", path: "/api/v1/org/members/:user", tag: "Organization", summary: "Remove a member", perm: "members.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "PUT", path: "/api/v1/org/members/:user/owner", tag: "Organization", summary: "Make a member an owner, or step down", sessionOnly: true, perm: "owner", description: "Only owners decide. `{\"owner\": false}` on oneself steps down; handing over is making someone else owner first. The last owner cannot step down (`409 last_owner`). A former owner without roles becomes Admin.", req: ownerRequest{}, status: http.StatusNoContent}, {method: "POST", path: "/api/v1/org/members/:user/roles", tag: "Organization", summary: "Assign a role, optionally limited to a group or status page", description: "Nobody can grant permissions they do not hold.", perm: "members.manage", sessionOnly: true, req: assignRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}}}, {method: "DELETE", path: "/api/v1/org/assignments/:id", tag: "Organization", summary: "Remove a role assignment", perm: "members.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/invitations", tag: "Organization", summary: "List pending invitations", perm: "members.read", resp: obj{"invitations": []invitationView{}}}, {method: "POST", path: "/api/v1/org/invitations", tag: "Organization", summary: "Invite someone", perm: "members.manage", sessionOnly: true, req: inviteRequest{}, status: http.StatusCreated, resp: obj{"url": ""}}, {method: "DELETE", path: "/api/v1/org/invitations/:id", tag: "Organization", summary: "Withdraw an invitation", perm: "members.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/roles", tag: "Organization", summary: "List roles and all permissions", perm: "members.read", resp: obj{"roles": []roleView{}, "permissions": []string{}}}, {method: "POST", path: "/api/v1/org/roles", tag: "Organization", summary: "Create a custom role", perm: "roles.manage", sessionOnly: true, req: roleRequest{}, status: http.StatusCreated, resp: roleView{}}, {method: "PUT", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Change a custom role", perm: "roles.manage", sessionOnly: true, req: roleRequest{}, resp: roleView{}}, {method: "DELETE", path: "/api/v1/org/roles/:id", tag: "Organization", summary: "Delete an unused custom role", perm: "roles.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/tokens", tag: "Organization", summary: "List API tokens", description: "Members see their own tokens; with tokens.manage, all of the organization.", resp: obj{"tokens": []tokenView{}}}, {method: "POST", path: "/api/v1/org/tokens", tag: "Organization", summary: "Create an API token", sessionOnly: true, description: "The token is returned only this once. Its permissions are capped by the creator's.", req: createTokenRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": "", "prefix": "", "permissions": []string{}}}, {method: "DELETE", path: "/api/v1/org/tokens/:id", tag: "Organization", summary: "Revoke an API token", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/sso", tag: "Organization", summary: "List single sign-on providers", perm: "org.manage", resp: obj{"providers": []ssoProviderView{}, "redirect_url": ""}}, {method: "POST", path: "/api/v1/org/sso", tag: "Organization", summary: "Add an OpenID Connect provider", perm: "org.manage", sessionOnly: true, req: ssoProviderRequest{}, status: http.StatusCreated, resp: ssoProviderView{}}, {method: "PUT", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Change a provider", perm: "org.manage", sessionOnly: true, req: ssoProviderRequest{}, resp: ssoProviderView{}}, {method: "DELETE", path: "/api/v1/org/sso/:id", tag: "Organization", summary: "Remove a provider", perm: "org.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/regions", tag: "Organization", summary: "Regions available to the organization", resp: obj{"regions": []regionView{}}}, {method: "POST", path: "/api/v1/org/regions", tag: "Organization", summary: "Create an own region", perm: "org.manage", sessionOnly: true, req: regionRequest{}, status: http.StatusCreated, resp: regionView{}}, {method: "DELETE", path: "/api/v1/org/regions/:id", tag: "Organization", summary: "Delete an own region", perm: "org.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/agents", tag: "Organization", summary: "List own checkers and status page servers", perm: "org.manage", resp: obj{"agents": []agentView{}}}, {method: "POST", path: "/api/v1/org/agents", tag: "Organization", summary: "Create an agent token", perm: "org.manage", sessionOnly: true, description: "The token is returned only this once.", req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}}, {method: "PATCH", path: "/api/v1/org/agents/:id", tag: "Organization", summary: "Let a checker check private addresses or not", description: "Applies from the checker's next poll.", perm: "org.manage", sessionOnly: true, req: agentUpdate{}, status: http.StatusNoContent}, {method: "DELETE", path: "/api/v1/org/agents/:id", tag: "Organization", summary: "Revoke an agent", perm: "org.manage", sessionOnly: true, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/legal", tag: "Organization", summary: "Legal notice and privacy policy of the status pages", perm: "org.manage", resp: obj{"documents": []legalView{}}}, {method: "PUT", path: "/api/v1/org/legal/:kind", tag: "Organization", summary: "Set the legal notice (imprint) or privacy policy", description: "Markdown or a link; a link wins. Both empty removes the document.", perm: "org.manage", req: legalRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/org/audit", tag: "Organization", summary: "The organization's audit log", perm: "audit.read", description: "Paged, newest first.", resp: paged(obj{"events": []auditEventView{}})}, {method: "GET", path: "/api/v1/org/export", tag: "Organization", summary: "Export the organization's data", perm: "org.manage", sessionOnly: true, description: "`?format=pdf` returns a PDF instead of JSON.", resp: orgExport{}}, {method: "POST", path: "/api/v1/org/delete", tag: "Organization", summary: "Delete the organization with all its data", sessionOnly: true, description: "Owner only, confirmed with the organization's slug and the owner's password.", req: orgDeletionRequest{}, resp: obj{"status": ""}}, // Platform {method: "GET", path: "/api/v1/admin/audit", tag: "Platform", summary: "Platform audit log", perm: "platform admin", description: "Paged, newest first.", resp: paged(obj{"events": []auditEventView{}})}, {method: "GET", path: "/api/v1/admin/legal", tag: "Platform", summary: "Platform legal notice and privacy policy", perm: "platform admin", resp: obj{"documents": []legalView{}}}, {method: "PUT", path: "/api/v1/admin/legal/:kind", tag: "Platform", summary: "Set a platform legal document", perm: "platform admin", req: legalRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Check types and whether they are offered", perm: "platform admin", resp: obj{"types": []checkTypeView{}}}, {method: "PUT", path: "/api/v1/admin/check-types", tag: "Platform", summary: "Choose the check types offered for new monitors", description: "Types left out are switched off: not offered for new monitors or type changes; existing monitors keep running.", perm: "platform admin", req: checkTypesRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Whether platform checkers may check private addresses", perm: "platform admin", resp: checkerNetwork{}}, {method: "PUT", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Let platform checkers check private addresses or not", description: "Unset, they may on self-hosted installations and may not in the cloud edition. Applies from each checker's next poll.", perm: "platform admin", req: checkerNetwork{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/identity-providers", tag: "Platform", summary: "Identity providers for signing up and in", description: "With the callback URL to register at each provider. Secrets are never returned.", perm: "platform admin", resp: obj{"providers": []idpView{}, "callback_url": ""}}, {method: "POST", path: "/api/v1/admin/identity-providers", tag: "Platform", summary: "Add an identity provider", description: "`kind` oidc takes the issuer, which is checked by discovery; github takes the GitHub server (empty for github.com). Accounts are linked by subject, never by email: an existing account with the provider's email is not taken over.", perm: "platform admin", req: idpRequest{}, status: http.StatusCreated, resp: idpView{}}, {method: "PUT", path: "/api/v1/admin/identity-providers/:id", tag: "Platform", summary: "Change an identity provider", description: "An empty client secret keeps the stored one; the kind cannot change.", perm: "platform admin", req: idpRequest{}, resp: idpView{}}, {method: "DELETE", path: "/api/v1/admin/identity-providers/:id", tag: "Platform", summary: "Remove an identity provider", description: "Refused with `409 idp_in_use` while accounts can sign in only through it; disable it instead.", perm: "platform admin", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/limits", tag: "Platform", summary: "Default limits of organizations and accounts", perm: "platform admin", resp: Limits{}}, {method: "PUT", path: "/api/v1/admin/limits", tag: "Platform", summary: "Set the default limits", description: "0 means unlimited. Defaults apply at once to every organization and account without an override of its own. Lowering a limit below current usage keeps everything; only new monitors, status pages, regions or organizations are refused.", perm: "platform admin", req: limitsRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/orgs", tag: "Platform", summary: "Organizations with usage, limits and owner", description: "Paged, newest first. `q` searches name, slug and owner email.", perm: "platform admin", resp: paged(obj{"orgs": []adminOrg{}})}, {method: "PUT", path: "/api/v1/admin/orgs/:id/limits", tag: "Platform", summary: "Override an organization's limits", description: "null follows the platform default, 0 means unlimited.", perm: "platform admin", req: orgLimitsView{}, status: http.StatusNoContent}, {method: "PUT", path: "/api/v1/admin/users/:id/limits", tag: "Platform", summary: "Override how many organizations an account may own", description: "null follows the platform default, 0 means unlimited.", perm: "platform admin", req: userLimitsRequest{}, status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/status-pages", tag: "Platform", summary: "Public and suspended status pages with organization and owner", description: "Paged, newest first. `q` searches title, slug, domain, organization and owner email.", perm: "platform admin", resp: paged(obj{"status_pages": []moderatedPage{}})}, {method: "PUT", path: "/api/v1/admin/status-pages/:id/suspension", tag: "Platform", summary: "Suspend or reinstate a status page", description: "A suspended page is not served; status page servers drop it when they next ask for it.", perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, {method: "DELETE", path: "/api/v1/admin/status-pages/:id", tag: "Platform", summary: "Delete a status page", perm: "platform admin", status: http.StatusNoContent}, {method: "PUT", path: "/api/v1/admin/orgs/:id/suspension", tag: "Platform", summary: "Suspend or reinstate an organization", description: "A suspended organization's monitors are not checked, its status pages are not served, heartbeats and Alertmanager webhooks are refused, and its members and API tokens get 403 org_suspended.", perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, {method: "DELETE", path: "/api/v1/admin/orgs/:id", tag: "Platform", summary: "Delete an organization with all its data", perm: "platform admin", status: http.StatusNoContent}, {method: "PUT", path: "/api/v1/admin/users/:id/suspension", tag: "Platform", summary: "Suspend or reinstate an account", description: "A suspended account is signed out everywhere and cannot use its API tokens; signing in again only lets it export or delete its data. Platform admins cannot be suspended.", perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, {method: "DELETE", path: "/api/v1/admin/users/:id", tag: "Platform", summary: "Delete an account", description: "Organizations the account is the last owner of are deleted with it. Platform admins cannot be deleted.", perm: "platform admin", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/regions", tag: "Platform", summary: "List platform regions", perm: "platform admin", resp: obj{"regions": []regionView{}}}, {method: "POST", path: "/api/v1/admin/regions", tag: "Platform", summary: "Create a platform region", perm: "platform admin", req: regionRequest{}, status: http.StatusCreated, resp: regionView{}}, {method: "DELETE", path: "/api/v1/admin/regions/:id", tag: "Platform", summary: "Delete a platform region", perm: "platform admin", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/agents", tag: "Platform", summary: "List platform agents", perm: "platform admin", resp: obj{"agents": []agentView{}}}, {method: "POST", path: "/api/v1/admin/agents", tag: "Platform", summary: "Create a platform agent token", perm: "platform admin", req: agentRequest{}, status: http.StatusCreated, resp: obj{"id": uuid.UUID{}, "token": ""}}, {method: "DELETE", path: "/api/v1/admin/agents/:id", tag: "Platform", summary: "Revoke a platform agent", perm: "platform admin", status: http.StatusNoContent}, }