Platform admins set a default for how many monitors a status page may show, and an override per organization, like the other limits. Saving a page with more gives 422 page_monitor_limit; a page beyond a lowered limit keeps its monitors but cannot grow. The page editor names the limit and the organization's usage lists it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
213 lines
5.5 KiB
Go
213 lines
5.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: orgs.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const createOrg = `-- name: CreateOrg :one
|
|
INSERT INTO orgs (id, slug, name) VALUES ($1, $2, $3)
|
|
RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page
|
|
`
|
|
|
|
type CreateOrgParams struct {
|
|
ID uuid.UUID
|
|
Slug string
|
|
Name string
|
|
}
|
|
|
|
func (q *Queries) CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, error) {
|
|
row := q.db.QueryRow(ctx, createOrg, arg.ID, arg.Slug, arg.Name)
|
|
var i Org
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.RequireTotp,
|
|
&i.RequireSso,
|
|
&i.ApiTokenMaxDays,
|
|
&i.DisabledCheckTypes,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
&i.LimitMonitors,
|
|
&i.LimitStatusPages,
|
|
&i.LimitRegionsPerMonitor,
|
|
&i.LimitOwnRegionsCount,
|
|
&i.LimitMonitorsPerPage,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteOrg = `-- name: DeleteOrg :execrows
|
|
DELETE FROM orgs WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error) {
|
|
result, err := q.db.Exec(ctx, deleteOrg, id)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|
|
|
|
const getOrg = `-- name: GetOrg :one
|
|
SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetOrg(ctx context.Context, id uuid.UUID) (Org, error) {
|
|
row := q.db.QueryRow(ctx, getOrg, id)
|
|
var i Org
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.RequireTotp,
|
|
&i.RequireSso,
|
|
&i.ApiTokenMaxDays,
|
|
&i.DisabledCheckTypes,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
&i.LimitMonitors,
|
|
&i.LimitStatusPages,
|
|
&i.LimitRegionsPerMonitor,
|
|
&i.LimitOwnRegionsCount,
|
|
&i.LimitMonitorsPerPage,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOrgBySlug = `-- name: GetOrgBySlug :one
|
|
SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs WHERE slug = $1
|
|
`
|
|
|
|
func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) {
|
|
row := q.db.QueryRow(ctx, getOrgBySlug, slug)
|
|
var i Org
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.RequireTotp,
|
|
&i.RequireSso,
|
|
&i.ApiTokenMaxDays,
|
|
&i.DisabledCheckTypes,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
&i.LimitMonitors,
|
|
&i.LimitStatusPages,
|
|
&i.LimitRegionsPerMonitor,
|
|
&i.LimitOwnRegionsCount,
|
|
&i.LimitMonitorsPerPage,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listOrgs = `-- name: ListOrgs :many
|
|
SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page FROM orgs ORDER BY name
|
|
`
|
|
|
|
func (q *Queries) ListOrgs(ctx context.Context) ([]Org, error) {
|
|
rows, err := q.db.Query(ctx, listOrgs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []Org{}
|
|
for rows.Next() {
|
|
var i Org
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.RequireTotp,
|
|
&i.RequireSso,
|
|
&i.ApiTokenMaxDays,
|
|
&i.DisabledCheckTypes,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
&i.LimitMonitors,
|
|
&i.LimitStatusPages,
|
|
&i.LimitRegionsPerMonitor,
|
|
&i.LimitOwnRegionsCount,
|
|
&i.LimitMonitorsPerPage,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const setOrgDisabledCheckTypes = `-- name: SetOrgDisabledCheckTypes :exec
|
|
UPDATE orgs SET disabled_check_types = $2, updated_at = now() WHERE id = $1
|
|
`
|
|
|
|
type SetOrgDisabledCheckTypesParams struct {
|
|
ID uuid.UUID
|
|
DisabledCheckTypes []string
|
|
}
|
|
|
|
func (q *Queries) SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabledCheckTypesParams) error {
|
|
_, err := q.db.Exec(ctx, setOrgDisabledCheckTypes, arg.ID, arg.DisabledCheckTypes)
|
|
return err
|
|
}
|
|
|
|
const updateOrgPolicy = `-- name: UpdateOrgPolicy :one
|
|
UPDATE orgs SET require_totp = $2, require_sso = $3, api_token_max_days = $4, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason, limit_monitors, limit_status_pages, limit_regions_per_monitor, limit_own_regions_count, limit_monitors_per_page
|
|
`
|
|
|
|
type UpdateOrgPolicyParams struct {
|
|
ID uuid.UUID
|
|
RequireTotp bool
|
|
RequireSso bool
|
|
ApiTokenMaxDays *int32
|
|
}
|
|
|
|
func (q *Queries) UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams) (Org, error) {
|
|
row := q.db.QueryRow(ctx, updateOrgPolicy,
|
|
arg.ID,
|
|
arg.RequireTotp,
|
|
arg.RequireSso,
|
|
arg.ApiTokenMaxDays,
|
|
)
|
|
var i Org
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.RequireTotp,
|
|
&i.RequireSso,
|
|
&i.ApiTokenMaxDays,
|
|
&i.DisabledCheckTypes,
|
|
&i.SuspendedAt,
|
|
&i.SuspendedReason,
|
|
&i.LimitMonitors,
|
|
&i.LimitStatusPages,
|
|
&i.LimitRegionsPerMonitor,
|
|
&i.LimitOwnRegionsCount,
|
|
&i.LimitMonitorsPerPage,
|
|
)
|
|
return i, err
|
|
}
|