The admin panel lists every published status page, and every suspended page, organization or account, with the organization and owner behind it, searchable by title, address, organization or email. Each can be suspended with a reason, reinstated, or deleted. A suspended page is not served; status page servers drop it when they next ask. A suspended organization's monitors leave the schedule, its pages go offline, heartbeat pings and Alertmanager webhooks are no longer recorded, and its members and API tokens get 403 org_suspended; the console explains why. Reinstating restarts heartbeat waits so they do not fire at once. A suspended account is signed out everywhere and can neither sign in nor use its tokens; only someone who knows the password learns of the suspension. Platform admins cannot be suspended or deleted. Account deletion shares its logic with the GDPR erasure, including the refusal while the account owns shared organizations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
554 lines
14 KiB
Go
554 lines
14 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: status_pages.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const addStatusPageMonitor = `-- name: AddStatusPageMonitor :exec
|
|
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, group_id, label, position)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`
|
|
|
|
type AddStatusPageMonitorParams struct {
|
|
PageID uuid.UUID
|
|
MonitorID uuid.UUID
|
|
OrgID uuid.UUID
|
|
Section string
|
|
GroupID *uuid.UUID
|
|
Label string
|
|
Position int32
|
|
}
|
|
|
|
func (q *Queries) AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMonitorParams) error {
|
|
_, err := q.db.Exec(ctx, addStatusPageMonitor,
|
|
arg.PageID,
|
|
arg.MonitorID,
|
|
arg.OrgID,
|
|
arg.Section,
|
|
arg.GroupID,
|
|
arg.Label,
|
|
arg.Position,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const clearStatusPageGroups = `-- name: ClearStatusPageGroups :exec
|
|
DELETE FROM status_page_groups WHERE page_id = $1
|
|
`
|
|
|
|
func (q *Queries) ClearStatusPageGroups(ctx context.Context, pageID uuid.UUID) error {
|
|
_, err := q.db.Exec(ctx, clearStatusPageGroups, pageID)
|
|
return err
|
|
}
|
|
|
|
const clearStatusPageMonitors = `-- name: ClearStatusPageMonitors :exec
|
|
DELETE FROM status_page_monitors WHERE page_id = $1
|
|
`
|
|
|
|
func (q *Queries) ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID) error {
|
|
_, err := q.db.Exec(ctx, clearStatusPageMonitors, pageID)
|
|
return err
|
|
}
|
|
|
|
const createStatusPage = `-- name: CreateStatusPage :one
|
|
INSERT INTO status_pages (org_id, slug, title, description, published, show_component_details, domain_token, theme)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason
|
|
`
|
|
|
|
type CreateStatusPageParams struct {
|
|
OrgID uuid.UUID
|
|
Slug string
|
|
Title string
|
|
Description string
|
|
Published bool
|
|
ShowComponentDetails bool
|
|
DomainToken string
|
|
Theme []byte
|
|
}
|
|
|
|
func (q *Queries) CreateStatusPage(ctx context.Context, arg CreateStatusPageParams) (StatusPage, error) {
|
|
row := q.db.QueryRow(ctx, createStatusPage,
|
|
arg.OrgID,
|
|
arg.Slug,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Published,
|
|
arg.ShowComponentDetails,
|
|
arg.DomainToken,
|
|
arg.Theme,
|
|
)
|
|
var i StatusPage
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createStatusPageGroup = `-- name: CreateStatusPageGroup :one
|
|
INSERT INTO status_page_groups (page_id, org_id, parent_id, name, position)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING id, page_id, org_id, parent_id, name, position, created_at, updated_at
|
|
`
|
|
|
|
type CreateStatusPageGroupParams struct {
|
|
PageID uuid.UUID
|
|
OrgID uuid.UUID
|
|
ParentID *uuid.UUID
|
|
Name string
|
|
Position int32
|
|
}
|
|
|
|
func (q *Queries) CreateStatusPageGroup(ctx context.Context, arg CreateStatusPageGroupParams) (StatusPageGroup, error) {
|
|
row := q.db.QueryRow(ctx, createStatusPageGroup,
|
|
arg.PageID,
|
|
arg.OrgID,
|
|
arg.ParentID,
|
|
arg.Name,
|
|
arg.Position,
|
|
)
|
|
var i StatusPageGroup
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PageID,
|
|
&i.OrgID,
|
|
&i.ParentID,
|
|
&i.Name,
|
|
&i.Position,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteStatusPage = `-- name: DeleteStatusPage :execrows
|
|
DELETE FROM status_pages WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteStatusPage(ctx context.Context, id uuid.UUID) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteStatusPage, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const deleteStatusPageGroup = `-- name: DeleteStatusPageGroup :execrows
|
|
DELETE FROM status_page_groups WHERE id = $1 AND page_id = $2
|
|
`
|
|
|
|
type DeleteStatusPageGroupParams struct {
|
|
ID uuid.UUID
|
|
PageID uuid.UUID
|
|
}
|
|
|
|
func (q *Queries) DeleteStatusPageGroup(ctx context.Context, arg DeleteStatusPageGroupParams) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteStatusPageGroup, arg.ID, arg.PageID)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const findPublishedPage = `-- name: FindPublishedPage :one
|
|
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages
|
|
WHERE published AND suspended_at IS NULL
|
|
AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL)
|
|
AND (($1::citext IS NOT NULL AND custom_domain = $1 AND domain_verified_at IS NOT NULL)
|
|
OR ($2::citext IS NOT NULL AND slug = $2))
|
|
`
|
|
|
|
type FindPublishedPageParams struct {
|
|
Host *string
|
|
Slug *string
|
|
}
|
|
|
|
// System scope: resolves a request to a page by verified custom domain or
|
|
// by slug.
|
|
func (q *Queries) FindPublishedPage(ctx context.Context, arg FindPublishedPageParams) (StatusPage, error) {
|
|
row := q.db.QueryRow(ctx, findPublishedPage, arg.Host, arg.Slug)
|
|
var i StatusPage
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getStatusPage = `-- name: GetStatusPage :one
|
|
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage, error) {
|
|
row := q.db.QueryRow(ctx, getStatusPage, id)
|
|
var i StatusPage
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listStatusPageGroups = `-- name: ListStatusPageGroups :many
|
|
SELECT id, page_id, org_id, parent_id, name, position, created_at, updated_at FROM status_page_groups
|
|
WHERE page_id = $1
|
|
ORDER BY position, name, id
|
|
`
|
|
|
|
func (q *Queries) ListStatusPageGroups(ctx context.Context, pageID uuid.UUID) ([]StatusPageGroup, error) {
|
|
rows, err := q.db.Query(ctx, listStatusPageGroups, pageID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []StatusPageGroup{}
|
|
for rows.Next() {
|
|
var i StatusPageGroup
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.PageID,
|
|
&i.OrgID,
|
|
&i.ParentID,
|
|
&i.Name,
|
|
&i.Position,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listStatusPages = `-- name: ListStatusPages :many
|
|
SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages ORDER BY title
|
|
`
|
|
|
|
func (q *Queries) ListStatusPages(ctx context.Context) ([]StatusPage, error) {
|
|
rows, err := q.db.Query(ctx, listStatusPages)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []StatusPage{}
|
|
for rows.Next() {
|
|
var i StatusPage
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const markDomainVerified = `-- name: MarkDomainVerified :exec
|
|
UPDATE status_pages SET domain_verified_at = now() WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) MarkDomainVerified(ctx context.Context, id uuid.UUID) error {
|
|
_, err := q.db.Exec(ctx, markDomainVerified, id)
|
|
return err
|
|
}
|
|
|
|
const reparentStatusPageGroupChildren = `-- name: ReparentStatusPageGroupChildren :exec
|
|
UPDATE status_page_groups SET parent_id = $3, updated_at = now()
|
|
WHERE page_id = $1 AND parent_id = $2
|
|
`
|
|
|
|
type ReparentStatusPageGroupChildrenParams struct {
|
|
PageID uuid.UUID
|
|
ParentID *uuid.UUID
|
|
ParentID_2 *uuid.UUID
|
|
}
|
|
|
|
func (q *Queries) ReparentStatusPageGroupChildren(ctx context.Context, arg ReparentStatusPageGroupChildrenParams) error {
|
|
_, err := q.db.Exec(ctx, reparentStatusPageGroupChildren, arg.PageID, arg.ParentID, arg.ParentID_2)
|
|
return err
|
|
}
|
|
|
|
const reparentStatusPageGroupMonitors = `-- name: ReparentStatusPageGroupMonitors :exec
|
|
UPDATE status_page_monitors SET group_id = $3
|
|
WHERE page_id = $1 AND group_id = $2
|
|
`
|
|
|
|
type ReparentStatusPageGroupMonitorsParams struct {
|
|
PageID uuid.UUID
|
|
GroupID *uuid.UUID
|
|
GroupID_2 *uuid.UUID
|
|
}
|
|
|
|
func (q *Queries) ReparentStatusPageGroupMonitors(ctx context.Context, arg ReparentStatusPageGroupMonitorsParams) error {
|
|
_, err := q.db.Exec(ctx, reparentStatusPageGroupMonitors, arg.PageID, arg.GroupID, arg.GroupID_2)
|
|
return err
|
|
}
|
|
|
|
const setStatusPageDomain = `-- name: SetStatusPageDomain :one
|
|
UPDATE status_pages SET
|
|
custom_domain = $1,
|
|
domain_verified_at = CASE WHEN custom_domain IS NOT DISTINCT FROM $1 THEN domain_verified_at END,
|
|
updated_at = now()
|
|
WHERE id = $2
|
|
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason
|
|
`
|
|
|
|
type SetStatusPageDomainParams struct {
|
|
CustomDomain *string
|
|
ID uuid.UUID
|
|
}
|
|
|
|
// Changing the domain drops a previous verification.
|
|
func (q *Queries) SetStatusPageDomain(ctx context.Context, arg SetStatusPageDomainParams) (StatusPage, error) {
|
|
row := q.db.QueryRow(ctx, setStatusPageDomain, arg.CustomDomain, arg.ID)
|
|
var i StatusPage
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setStatusPageMonitorGroup = `-- name: SetStatusPageMonitorGroup :exec
|
|
UPDATE status_page_monitors SET group_id = $3, section = $4
|
|
WHERE page_id = $1 AND monitor_id = $2
|
|
`
|
|
|
|
type SetStatusPageMonitorGroupParams struct {
|
|
PageID uuid.UUID
|
|
MonitorID uuid.UUID
|
|
GroupID *uuid.UUID
|
|
Section string
|
|
}
|
|
|
|
func (q *Queries) SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error {
|
|
_, err := q.db.Exec(ctx, setStatusPageMonitorGroup,
|
|
arg.PageID,
|
|
arg.MonitorID,
|
|
arg.GroupID,
|
|
arg.Section,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const statusPageMonitors = `-- name: StatusPageMonitors :many
|
|
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
|
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
|
FROM status_page_monitors spm
|
|
JOIN monitors m ON m.id = spm.monitor_id
|
|
WHERE spm.page_id = $1
|
|
ORDER BY spm.position, m.name
|
|
`
|
|
|
|
type StatusPageMonitorsRow struct {
|
|
MonitorID uuid.UUID
|
|
Section string
|
|
GroupID *uuid.UUID
|
|
Label string
|
|
Position int32
|
|
MonitorName string
|
|
Enabled bool
|
|
MonitorGroupID *uuid.UUID
|
|
}
|
|
|
|
func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error) {
|
|
rows, err := q.db.Query(ctx, statusPageMonitors, pageID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []StatusPageMonitorsRow{}
|
|
for rows.Next() {
|
|
var i StatusPageMonitorsRow
|
|
if err := rows.Scan(
|
|
&i.MonitorID,
|
|
&i.Section,
|
|
&i.GroupID,
|
|
&i.Label,
|
|
&i.Position,
|
|
&i.MonitorName,
|
|
&i.Enabled,
|
|
&i.MonitorGroupID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateStatusPage = `-- name: UpdateStatusPage :one
|
|
UPDATE status_pages
|
|
SET slug = $2,
|
|
title = $3,
|
|
description = $4,
|
|
published = $5,
|
|
show_component_details = $6,
|
|
theme = $7,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason
|
|
`
|
|
|
|
type UpdateStatusPageParams struct {
|
|
ID uuid.UUID
|
|
Slug string
|
|
Title string
|
|
Description string
|
|
Published bool
|
|
ShowComponentDetails bool
|
|
Theme []byte
|
|
}
|
|
|
|
func (q *Queries) UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error) {
|
|
row := q.db.QueryRow(ctx, updateStatusPage,
|
|
arg.ID,
|
|
arg.Slug,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Published,
|
|
arg.ShowComponentDetails,
|
|
arg.Theme,
|
|
)
|
|
var i StatusPage
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Published,
|
|
&i.CustomDomain,
|
|
&i.DomainToken,
|
|
&i.DomainVerifiedAt,
|
|
&i.Theme,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ShowComponentDetails,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateStatusPageGroup = `-- name: UpdateStatusPageGroup :one
|
|
UPDATE status_page_groups
|
|
SET name = $3, parent_id = $4, position = $5, updated_at = now()
|
|
WHERE id = $1 AND page_id = $2
|
|
RETURNING id, page_id, org_id, parent_id, name, position, created_at, updated_at
|
|
`
|
|
|
|
type UpdateStatusPageGroupParams struct {
|
|
ID uuid.UUID
|
|
PageID uuid.UUID
|
|
Name string
|
|
ParentID *uuid.UUID
|
|
Position int32
|
|
}
|
|
|
|
func (q *Queries) UpdateStatusPageGroup(ctx context.Context, arg UpdateStatusPageGroupParams) (StatusPageGroup, error) {
|
|
row := q.db.QueryRow(ctx, updateStatusPageGroup,
|
|
arg.ID,
|
|
arg.PageID,
|
|
arg.Name,
|
|
arg.ParentID,
|
|
arg.Position,
|
|
)
|
|
var i StatusPageGroup
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PageID,
|
|
&i.OrgID,
|
|
&i.ParentID,
|
|
&i.Name,
|
|
&i.Position,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|