diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ab092..ab4f6fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,22 @@ Notable changes, newest first. Release notes on GitHub list every commit; this file collects what users and scripts need to know. -## Unreleased +## 0.24.0 (2026-11-05) + +### New + +- Norcube Monitor status page subscribers: `monitor status-pages subscribers + list | delete`, with pages named by id or exact slug. Addresses are personal + data, so these commands need the `monitor.statuspages` scope on a CI token, + even to list. A token without it exits 5 and says so. The API's subscriber + count and CSV export have no commands yet; `nrc api` reaches them. +- `--notify` on `monitor status-pages incidents create` and `incidents updates + create` emails the update to the page's subscribers. +- `--auto-post` on `monitor status-pages create` and `update` lets a page post + confirmed critical monitor incidents by itself. It is optional on `create` + and off unless you ask for it. +- `monitor status-pages get` shows whether a page posts automatically, and + `incidents get` shows when a post was written by the system. ### Changes @@ -11,6 +26,14 @@ this file collects what users and scripts need to know. `-o text` column changes. Norcube Monitor's status page domain and logo endpoints, DomainRadar's expiry alert settings and Billing's plan features are in the clients but have no commands yet; `nrc api` reaches them. +- Refreshed the Norcube Monitor client and spec for status page subscribers and + automatic posts. + +### Changes for scripts + +- `monitor status-pages incidents` JSON and YAML: posted incidents gain + `autoPosted` and `autoManaged`, and their updates `notifySubscribers`. +- `monitor status-pages` page JSON and YAML: `settings` gains `autoPost`. ## 0.23.0 (2026-11-05) diff --git a/docs/DESIGN.md b/docs/DESIGN.md index d67e851..9bb6df5 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -728,7 +728,7 @@ flag; [CHANGELOG.md](../CHANGELOG.md) says when each arrived. | `langsync` | `init`, `sync`, `pull`; `namespaces list | create | update | delete`; `terms list | add | update | delete | import`, `terms import status`; `translations get | set | suggest | translate-missing`; `languages list | add | remove | create | delete`; `prompts list | get | create | update | delete`; `glossary get`, `glossary items list | get | create | translate | delete`, `glossary languages attach`; `api-keys list | create | revoke`; `audit list` | | `domainradar` | `check`; `bulk create | list | get | results | watch | export | cancel | delete`; `saved list | add | remove`; `watchers list | get | create | update | delete`; `hits list | get`; `names generate | list | get | results | check | delete` | | `billing` | `status`; `subscriptions list`; `usage estimate | metrics`; `invoices list | download`; `budget get | set` | -| `monitor` | `status` (`--fail-on`); `monitors list | get | create | update | delete | pause | resume | run` (`--wait`), `monitors bulk pause | resume | delete`, `monitors results list`, `monitors status-changes list`, `monitors stats get`, `monitors availability get`, `monitors certificate get`, `monitors alerts get | set`; `incidents list | get | acknowledge | summary`; `channels list | get | create | update | delete | test | verify`, `channels deliveries list`; `status-pages list | get | create | update | delete | publish | unpublish | preview-link`, `status-pages layout get | set`, `status-pages incidents list | get | create | update`, `status-pages incidents updates create` | +| `monitor` | `status` (`--fail-on`); `monitors list | get | create | update | delete | pause | resume | run` (`--wait`), `monitors bulk pause | resume | delete`, `monitors results list`, `monitors status-changes list`, `monitors stats get`, `monitors availability get`, `monitors certificate get`, `monitors alerts get | set`; `incidents list | get | acknowledge | summary`; `channels list | get | create | update | delete | test | verify`, `channels deliveries list`; `status-pages list | get | create | update | delete | publish | unpublish | preview-link`, `status-pages layout get | set`, `status-pages incidents list | get | create | update`, `status-pages incidents updates create`, `status-pages subscribers list | delete` | | PromptHub | No command group; `nrc api prompthub ...` | | CMS | None (CMS has no public API) | @@ -740,9 +740,10 @@ now), `backup.verify` (restore tests), `domainradar.check`, monitor's check now), `monitor.write` (manage monitors, alert routing, acknowledge incidents), `monitor.channels` (manage alert channels, test sends and verification codes; not included in `monitor.write`, because -channels hold credentials and sends cost money), `monitor.statuspages` (manage status pages and post -incidents on them; not included in any other scope, because everything it -changes is public). +channels hold credentials and sends cost money), `monitor.statuspages` (manage status pages, post +incidents on them and manage their subscribers; not included in any other +scope, because what it changes is public and subscribers' addresses are +personal data). Installation channels: Homebrew cask (with `nrc`), `.deb` / `.rpm` / `.apk`, `install.sh`, release archives (darwin and linux amd64/arm64, @@ -791,6 +792,8 @@ changelog, and the owner's decisions in the planning sessions of | 2026-11-04 | Status pages in the CLI. Pages are named by id or exact slug; a page's posted incidents are a nested resource (`status-pages incidents`), and an update on one is `status-pages incidents updates create` rather than a new verb, by the rule of the Norcube Monitor entry above. `create` marks every setting required and fills in none: a page is public communication, and the backend has no defaults either. `layout set` refuses a document without both lists, since it replaces the layout as a whole. `unpublish` confirms (old addresses are given up); `publish` and posting don't, so an incident pipeline stays one command, and their help says they go public. `preview-link` is a `read`: it changes nothing, though the API asks for `monitor.statuspages` | Owner's brief. Rejected: `incidents post`, a synonym for creating an update; the dashboard's defaults on `create`, as `monitors create` has, because a required setting on a public page should be a choice | owner | | 2026-11-04 | `nrc commands`: the whole command tree as one versioned, offline document; what the tree cannot reveal is declared with annotations (`effect`, flag enums, service), never inferred from verbs | Agents should not crawl dozens of `--help` pages. Prior art: `kubectl api-resources` / `explain` (verbs per resource, offline schema), `aws ... --generate-cli-skeleton` (machine-readable input), cobra's doc generation (`tools/gendocs` already walks the tree). Global flags listed once rather than on every command, to keep the document small; a verb-based guess of the effect was rejected because domain verbs like `check`, `suggest` or `init` don't say whether they change anything | owner | | 2026-11-04 | PulseCheck is renamed Norcube Monitor before its first release, every technical name included: command group `monitor` (`nrc monitor monitors list`), registry key, OAuth audience and generated package `monitor`, scopes `monitor.read`, `monitor.check`, `monitor.write`, `monitor.channels`, endpoint `https://monitor.api.norcube.com/app/v1`, `NORCUBE_MONITOR_URL`. No `pulsecheck` alias or `cmdutil.Renamed` entry | The old name was never in a release, so no script, config file or token depends on it and P10 has nothing to keep; the backend renamed its service, audience and scopes in the same change. Rejected: keeping `pulsecheck` as a hidden alias, which would be a second name for one thing (P13) with no user to serve | owner | +| 2026-11-05 | Status page subscribers in the CLI: `status-pages subscribers list` and `delete`. A subscriber is named by id only. `delete ` completes the page but not the subscriber, because completion candidates are cached on disk and addresses have no place there. The CLI words the scope refusal itself: the API's sentence is shared with the page's other writes and speaks of changing pages, which misleads on a list | Owner's brief. The API's `count` and `export` have no commands yet; `nrc api` reaches them | owner | +| 2026-11-05 | `--auto-post` is the one page setting `create` doesn't require: the flag came after 0.23.0, so requiring it would break scripts that create pages, and the API keeps it off unless asked. `--notify` is sent only when given, and exists only on writes that add an update | Compatibility rule P10; owner's brief | owner | --- @@ -866,7 +869,7 @@ it with the same guarantees as every other product. The steps, in order: | Step | State | | --- | --- | | 1 Audience | `monitor` exists in Norcube Auth (sign-in audience list, CI token exchange) | -| 2 Scopes | `monitor.read`, `monitor.check`, `monitor.write`, `monitor.channels`, `monitor.statuspages` in the CI token catalog (and so the CLI sign-in catalog), with IAM actions; channel changes and sends only with `monitor.channels`, status page changes and posts only with `monitor.statuspages`, neither of which `monitor.write` includes; not on the MCP consent screen until the MCP redesign | +| 2 Scopes | `monitor.read`, `monitor.check`, `monitor.write`, `monitor.channels`, `monitor.statuspages` in the CI token catalog (and so the CLI sign-in catalog), with IAM actions; channel changes and sends only with `monitor.channels`, status page changes, posts and subscribers only with `monitor.statuspages`, neither of which `monitor.write` includes; not on the MCP consent screen until the MCP redesign | | 3 Enforcement | Default-closed route table (`internal/routers/app/scopes.go`) after the token middleware, coverage and matrix tests, and IAM refusing a scoped request the table never checked | | 4 Contract | Every operation has a verb-noun `@Id`, `@Security Bearer`, 401/403 problems and `x-norcube-scopes`; the status route is tagged `Status` and excluded here | | 5 to 10 CLI | Registry entry, hand-kept tables, client, `nrc monitor` commands, completion, command and golden tests | diff --git a/internal/api/monitor/monitor.gen.go b/internal/api/monitor/monitor.gen.go index 2e1d553..963eb47 100644 --- a/internal/api/monitor/monitor.gen.go +++ b/internal/api/monitor/monitor.gen.go @@ -1224,6 +1224,21 @@ func (e DtoPublicStatusGroupStatus) Valid() bool { } } +// Defines values for DtoPublicStatusIncidentFixedTitle. +const ( + AutoTitle DtoPublicStatusIncidentFixedTitle = "auto_title" +) + +// Valid indicates whether the value is a known member of the DtoPublicStatusIncidentFixedTitle enum. +func (e DtoPublicStatusIncidentFixedTitle) Valid() bool { + switch e { + case AutoTitle: + return true + default: + return false + } +} + // Defines values for DtoPublicStatusIncidentImpact. const ( DtoPublicStatusIncidentImpactCritical DtoPublicStatusIncidentImpact = "critical" @@ -1296,6 +1311,27 @@ func (e DtoPublicStatusPageIndicator) Valid() bool { } } +// Defines values for DtoPublicStatusUpdateFixedText. +const ( + AutoOpened DtoPublicStatusUpdateFixedText = "auto_opened" + AutoResolved DtoPublicStatusUpdateFixedText = "auto_resolved" + AutoSuperseded DtoPublicStatusUpdateFixedText = "auto_superseded" +) + +// Valid indicates whether the value is a known member of the DtoPublicStatusUpdateFixedText enum. +func (e DtoPublicStatusUpdateFixedText) Valid() bool { + switch e { + case AutoOpened: + return true + case AutoResolved: + return true + case AutoSuperseded: + return true + default: + return false + } +} + // Defines values for DtoPublicStatusUpdateStatus. const ( DtoPublicStatusUpdateStatusIdentified DtoPublicStatusUpdateStatus = "identified" @@ -1722,6 +1758,60 @@ func (e DtoStatusPageSettingsUpdateUptimeDays) Valid() bool { } } +// Defines values for DtoStatusPageSubscriberLocale. +const ( + Cs DtoStatusPageSubscriberLocale = "cs" + De DtoStatusPageSubscriberLocale = "de" + En DtoStatusPageSubscriberLocale = "en" + Es DtoStatusPageSubscriberLocale = "es" + Fr DtoStatusPageSubscriberLocale = "fr" + It DtoStatusPageSubscriberLocale = "it" + Pl DtoStatusPageSubscriberLocale = "pl" + ZhCN DtoStatusPageSubscriberLocale = "zh-CN" +) + +// Valid indicates whether the value is a known member of the DtoStatusPageSubscriberLocale enum. +func (e DtoStatusPageSubscriberLocale) Valid() bool { + switch e { + case Cs: + return true + case De: + return true + case En: + return true + case Es: + return true + case Fr: + return true + case It: + return true + case Pl: + return true + case ZhCN: + return true + default: + return false + } +} + +// Defines values for DtoStatusPageSubscriberStatus. +const ( + DtoStatusPageSubscriberStatusConfirmed DtoStatusPageSubscriberStatus = "confirmed" + DtoStatusPageSubscriberStatusPending DtoStatusPageSubscriberStatus = "pending" +) + +// Valid indicates whether the value is a known member of the DtoStatusPageSubscriberStatus enum. +func (e DtoStatusPageSubscriberStatus) Valid() bool { + switch e { + case DtoStatusPageSubscriberStatusConfirmed: + return true + case DtoStatusPageSubscriberStatusPending: + return true + default: + return false + } +} + // Defines values for ValidationRule. const ( RuleDependsOn ValidationRule = "dependsOn" @@ -1955,25 +2045,25 @@ func (e ListMonitorsParamsSort) Valid() bool { // Defines values for ListMonitorsParamsStatus. const ( - ListMonitorsParamsStatusCritical ListMonitorsParamsStatus = "critical" - ListMonitorsParamsStatusOk ListMonitorsParamsStatus = "ok" - ListMonitorsParamsStatusPaused ListMonitorsParamsStatus = "paused" - ListMonitorsParamsStatusPending ListMonitorsParamsStatus = "pending" - ListMonitorsParamsStatusWarning ListMonitorsParamsStatus = "warning" + Critical ListMonitorsParamsStatus = "critical" + Ok ListMonitorsParamsStatus = "ok" + Paused ListMonitorsParamsStatus = "paused" + Pending ListMonitorsParamsStatus = "pending" + Warning ListMonitorsParamsStatus = "warning" ) // Valid indicates whether the value is a known member of the ListMonitorsParamsStatus enum. func (e ListMonitorsParamsStatus) Valid() bool { switch e { - case ListMonitorsParamsStatusCritical: + case Critical: return true - case ListMonitorsParamsStatusOk: + case Ok: return true - case ListMonitorsParamsStatusPaused: + case Paused: return true - case ListMonitorsParamsStatusPending: + case Pending: return true - case ListMonitorsParamsStatusWarning: + case Warning: return true default: return false @@ -3028,16 +3118,24 @@ type DtoPublicStatusHistory struct { // DtoPublicStatusIncident defines model for dto.PublicStatusIncident. type DtoPublicStatusIncident struct { - Components []DtoPublicStatusAffected `json:"components"` - Id openapi_types.UUID `json:"id"` - Impact DtoPublicStatusIncidentImpact `json:"impact"` - ResolvedAt *string `json:"resolvedAt,omitempty"` - StartedAt string `json:"startedAt"` - Status DtoPublicStatusIncidentStatus `json:"status"` - Title string `json:"title"` - Updates []DtoPublicStatusUpdate `json:"updates"` + Components []DtoPublicStatusAffected `json:"components"` + + // FixedTitle FixedTitle is the code of a fixed wording the renderer translates; Title holds + // its English. Absent on anything a person wrote. + FixedTitle *DtoPublicStatusIncidentFixedTitle `json:"fixedTitle,omitempty"` + Id openapi_types.UUID `json:"id"` + Impact DtoPublicStatusIncidentImpact `json:"impact"` + ResolvedAt *string `json:"resolvedAt,omitempty"` + StartedAt string `json:"startedAt"` + Status DtoPublicStatusIncidentStatus `json:"status"` + Title string `json:"title"` + Updates []DtoPublicStatusUpdate `json:"updates"` } +// DtoPublicStatusIncidentFixedTitle FixedTitle is the code of a fixed wording the renderer translates; Title holds +// its English. Absent on anything a person wrote. +type DtoPublicStatusIncidentFixedTitle string + // DtoPublicStatusIncidentImpact defines model for DtoPublicStatusIncident.Impact. type DtoPublicStatusIncidentImpact string @@ -3097,12 +3195,20 @@ type DtoPublicStatusPreview struct { // DtoPublicStatusUpdate defines model for dto.PublicStatusUpdate. type DtoPublicStatusUpdate struct { - Body string `json:"body"` - CreatedAt string `json:"createdAt"` - Id openapi_types.UUID `json:"id"` - Status DtoPublicStatusUpdateStatus `json:"status"` + Body string `json:"body"` + CreatedAt string `json:"createdAt"` + + // FixedText FixedText is the code of a fixed wording the renderer translates; Body holds + // its English. Absent on anything a person wrote. + FixedText *DtoPublicStatusUpdateFixedText `json:"fixedText,omitempty"` + Id openapi_types.UUID `json:"id"` + Status DtoPublicStatusUpdateStatus `json:"status"` } +// DtoPublicStatusUpdateFixedText FixedText is the code of a fixed wording the renderer translates; Body holds +// its English. Absent on anything a person wrote. +type DtoPublicStatusUpdateFixedText string + // DtoPublicStatusUpdateStatus defines model for DtoPublicStatusUpdate.Status. type DtoPublicStatusUpdateStatus string @@ -3318,6 +3424,12 @@ type DtoStatusPageGroup struct { // DtoStatusPageIncident defines model for dto.StatusPageIncident. type DtoStatusPageIncident struct { + // AutoManaged AutoManaged: the system still runs it and resolves it by itself. A person's + // update or edit ends that for good. + AutoManaged bool `json:"autoManaged"` + + // AutoPosted AutoPosted: the system wrote this post, in fixed wording. + AutoPosted bool `json:"autoPosted"` Components []DtoStatusPageAffected `json:"components"` CreatedAt string `json:"createdAt"` Id openapi_types.UUID `json:"id"` @@ -3349,6 +3461,9 @@ type DtoStatusPageIncidentCreate struct { // your navigation, never published). MonitorIncidentIds *[]openapi_types.UUID `json:"monitorIncidentIds,omitempty"` + // Notify Notify mails this update to the page's subscribers. A draft page tells nobody. + Notify *bool `json:"notify,omitempty"` + // StartedAt StartedAt defaults to now. StartedAt *string `json:"startedAt,omitempty"` Status DtoStatusPageIncidentCreateStatus `json:"status"` @@ -3363,10 +3478,14 @@ type DtoStatusPageIncidentCreateStatus string // DtoStatusPageIncidentEntry defines model for dto.StatusPageIncidentEntry. type DtoStatusPageIncidentEntry struct { - Body string `json:"body"` - CreatedAt string `json:"createdAt"` - Id openapi_types.UUID `json:"id"` - Status DtoStatusPageIncidentEntryStatus `json:"status"` + Body string `json:"body"` + CreatedAt string `json:"createdAt"` + Id openapi_types.UUID `json:"id"` + + // NotifySubscribers NotifySubscribers: whoever posted this update asked to mail it to the page's + // subscribers. A draft page tells nobody, whatever this says. + NotifySubscribers bool `json:"notifySubscribers"` + Status DtoStatusPageIncidentEntryStatus `json:"status"` } // DtoStatusPageIncidentEntryStatus defines model for DtoStatusPageIncidentEntry.Status. @@ -3377,8 +3496,11 @@ type DtoStatusPageIncidentPost struct { Body string `json:"body"` // Components Components, when given, replaces the affected components. - Components *[]DtoStatusPageAffected `json:"components,omitempty"` - Status DtoStatusPageIncidentPostStatus `json:"status"` + Components *[]DtoStatusPageAffected `json:"components,omitempty"` + + // Notify Notify mails this update to the page's subscribers. A draft page tells nobody. + Notify *bool `json:"notify,omitempty"` + Status DtoStatusPageIncidentPostStatus `json:"status"` } // DtoStatusPageIncidentPostStatus defines model for DtoStatusPageIncidentPost.Status. @@ -3425,6 +3547,10 @@ type DtoStatusPagePreviewLink struct { // DtoStatusPageSettings defines model for dto.StatusPageSettings. type DtoStatusPageSettings struct { + // AutoPost AutoPost posts a confirmed critical monitor incident on the page by itself, in + // fixed wording, and resolves it when the incident ends. Off unless asked for. + AutoPost *bool `json:"autoPost,omitempty"` + // HistoryDays HistoryDays is how far back resolved incidents stay on the page. HistoryDays int `json:"historyDays"` @@ -3446,6 +3572,7 @@ type DtoStatusPageSettingsUptimeDays int // DtoStatusPageSettingsUpdate defines model for dto.StatusPageSettingsUpdate. type DtoStatusPageSettingsUpdate struct { + AutoPost *bool `json:"autoPost,omitempty"` HistoryDays *int `json:"historyDays,omitempty"` SearchIndexing *bool `json:"searchIndexing,omitempty"` ShowResponseTime *bool `json:"showResponseTime,omitempty"` @@ -3458,6 +3585,34 @@ type DtoStatusPageSettingsUpdate struct { // DtoStatusPageSettingsUpdateUptimeDays defines model for DtoStatusPageSettingsUpdate.UptimeDays. type DtoStatusPageSettingsUpdateUptimeDays int +// DtoStatusPageSubscriber defines model for dto.StatusPageSubscriber. +type DtoStatusPageSubscriber struct { + // ComponentIds ComponentIDs are the components it wants to hear about. Empty: all of them. + ComponentIds []string `json:"componentIds"` + ConfirmedAt *string `json:"confirmedAt,omitempty"` + CreatedAt string `json:"createdAt"` + Email string `json:"email"` + Id openapi_types.UUID `json:"id"` + + // Locale Locale is the language its mail comes in. + Locale DtoStatusPageSubscriberLocale `json:"locale"` + + // Status Status: pending until the address confirms. A pending one is removed after 7 days. + Status DtoStatusPageSubscriberStatus `json:"status"` +} + +// DtoStatusPageSubscriberLocale Locale is the language its mail comes in. +type DtoStatusPageSubscriberLocale string + +// DtoStatusPageSubscriberStatus Status: pending until the address confirms. A pending one is removed after 7 days. +type DtoStatusPageSubscriberStatus string + +// DtoStatusPageSubscriberCount defines model for dto.StatusPageSubscriberCount. +type DtoStatusPageSubscriberCount struct { + Confirmed int `json:"confirmed"` + Pending int `json:"pending"` +} + // DtoStatusPageUpdate defines model for dto.StatusPageUpdate. type DtoStatusPageUpdate struct { Description *string `json:"description,omitempty"` @@ -3719,6 +3874,12 @@ type ListStatusPageIncidentsParams struct { // ListStatusPageIncidentsParamsStatus defines parameters for ListStatusPageIncidents. type ListStatusPageIncidentsParamsStatus string +// ListStatusPageSubscribersParams defines parameters for ListStatusPageSubscribers. +type ListStatusPageSubscribersParams struct { + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` +} + // CreateAlertChannelJSONRequestBody defines body for CreateAlertChannel for application/json ContentType. type CreateAlertChannelJSONRequestBody = DtoAlertChannelCreate @@ -4017,6 +4178,18 @@ type ClientInterface interface { // PublishStatusPage request PublishStatusPage(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListStatusPageSubscribers request + ListStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, params *ListStatusPageSubscribersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CountStatusPageSubscribers request + CountStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ExportStatusPageSubscribers request + ExportStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteStatusPageSubscriber request + DeleteStatusPageSubscriber(ctx context.Context, id openapi_types.UUID, subscriberId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // UnpublishStatusPage request UnpublishStatusPage(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) } @@ -4801,6 +4974,54 @@ func (c *Client) PublishStatusPage(ctx context.Context, id openapi_types.UUID, r return c.Client.Do(req) } +func (c *Client) ListStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, params *ListStatusPageSubscribersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListStatusPageSubscribersRequest(c.Server, id, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CountStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCountStatusPageSubscribersRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ExportStatusPageSubscribers(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewExportStatusPageSubscribersRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteStatusPageSubscriber(ctx context.Context, id openapi_types.UUID, subscriberId openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteStatusPageSubscriberRequest(c.Server, id, subscriberId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) UnpublishStatusPage(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUnpublishStatusPageRequest(c.Server, id) if err != nil { @@ -7244,8 +7465,8 @@ func NewPublishStatusPageRequest(server string, id openapi_types.UUID) (*http.Re return req, nil } -// NewUnpublishStatusPageRequest generates requests for UnpublishStatusPage -func NewUnpublishStatusPageRequest(server string, id openapi_types.UUID) (*http.Request, error) { +// NewListStatusPageSubscribersRequest generates requests for ListStatusPageSubscribers +func NewListStatusPageSubscribersRequest(server string, id openapi_types.UUID, params *ListStatusPageSubscribersParams) (*http.Request, error) { var err error var pathParam0 string @@ -7260,7 +7481,7 @@ func NewUnpublishStatusPageRequest(server string, id openapi_types.UUID) (*http. return nil, err } - operationPath := fmt.Sprintf("/status-pages/%s/unpublish", pathParam0) + operationPath := fmt.Sprintf("/status-pages/%s/subscribers", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7270,7 +7491,46 @@ func NewUnpublishStatusPageRequest(server string, id openapi_types.UUID) (*http. return nil, err } - req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) if err != nil { return nil, err } @@ -7278,75 +7538,218 @@ func NewUnpublishStatusPageRequest(server string, id openapi_types.UUID) (*http. return req, nil } -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err - } +// NewCountStatusPageSubscribersRequest generates requests for CountStatusPageSubscribers +func NewCountStatusPageSubscribersRequest(server string, id openapi_types.UUID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: "uuid"}) + if err != nil { + return nil, err } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err - } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return nil -} -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} + operationPath := fmt.Sprintf("/status-pages/%s/subscribers/count", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) + queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } - return &ClientWithResponses{client}, nil -} -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err } + + return req, nil } -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // ListAlertChannelsWithResponse request - ListAlertChannelsWithResponse(ctx context.Context, params *ListAlertChannelsParams, reqEditors ...RequestEditorFn) (*ListAlertChannelsResponse, error) +// NewExportStatusPageSubscribersRequest generates requests for ExportStatusPageSubscribers +func NewExportStatusPageSubscribersRequest(server string, id openapi_types.UUID) (*http.Request, error) { + var err error - // CreateAlertChannelWithBodyWithResponse request with any body - CreateAlertChannelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAlertChannelResponse, error) + var pathParam0 string - CreateAlertChannelWithResponse(ctx context.Context, body CreateAlertChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAlertChannelResponse, error) + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: "uuid"}) + if err != nil { + return nil, err + } - // DeleteAlertChannelWithResponse request - DeleteAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAlertChannelResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // GetAlertChannelWithResponse request - GetAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAlertChannelResponse, error) + operationPath := fmt.Sprintf("/status-pages/%s/subscribers/export", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // UpdateAlertChannelWithBodyWithResponse request with any body - UpdateAlertChannelWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAlertChannelResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - UpdateAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateAlertChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAlertChannelResponse, error) + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } - // ListAlertChannelDeliveriesWithResponse request - ListAlertChannelDeliveriesWithResponse(ctx context.Context, id openapi_types.UUID, params *ListAlertChannelDeliveriesParams, reqEditors ...RequestEditorFn) (*ListAlertChannelDeliveriesResponse, error) + return req, nil +} - // TestAlertChannelWithResponse request - TestAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*TestAlertChannelResponse, error) +// NewDeleteStatusPageSubscriberRequest generates requests for DeleteStatusPageSubscriber +func NewDeleteStatusPageSubscriberRequest(server string, id openapi_types.UUID, subscriberId openapi_types.UUID) (*http.Request, error) { + var err error - // SendAlertChannelVerificationWithResponse request + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: "uuid"}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "subscriberId", subscriberId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: "uuid"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/status-pages/%s/subscribers/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUnpublishStatusPageRequest generates requests for UnpublishStatusPage +func NewUnpublishStatusPageRequest(server string, id openapi_types.UUID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: "uuid"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/status-pages/%s/unpublish", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // ListAlertChannelsWithResponse request + ListAlertChannelsWithResponse(ctx context.Context, params *ListAlertChannelsParams, reqEditors ...RequestEditorFn) (*ListAlertChannelsResponse, error) + + // CreateAlertChannelWithBodyWithResponse request with any body + CreateAlertChannelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAlertChannelResponse, error) + + CreateAlertChannelWithResponse(ctx context.Context, body CreateAlertChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAlertChannelResponse, error) + + // DeleteAlertChannelWithResponse request + DeleteAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAlertChannelResponse, error) + + // GetAlertChannelWithResponse request + GetAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAlertChannelResponse, error) + + // UpdateAlertChannelWithBodyWithResponse request with any body + UpdateAlertChannelWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAlertChannelResponse, error) + + UpdateAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateAlertChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAlertChannelResponse, error) + + // ListAlertChannelDeliveriesWithResponse request + ListAlertChannelDeliveriesWithResponse(ctx context.Context, id openapi_types.UUID, params *ListAlertChannelDeliveriesParams, reqEditors ...RequestEditorFn) (*ListAlertChannelDeliveriesResponse, error) + + // TestAlertChannelWithResponse request + TestAlertChannelWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*TestAlertChannelResponse, error) + + // SendAlertChannelVerificationWithResponse request SendAlertChannelVerificationWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*SendAlertChannelVerificationResponse, error) // ConfirmAlertChannelVerificationWithBodyWithResponse request with any body @@ -7501,6 +7904,18 @@ type ClientWithResponsesInterface interface { // PublishStatusPageWithResponse request PublishStatusPageWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*PublishStatusPageResponse, error) + // ListStatusPageSubscribersWithResponse request + ListStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, params *ListStatusPageSubscribersParams, reqEditors ...RequestEditorFn) (*ListStatusPageSubscribersResponse, error) + + // CountStatusPageSubscribersWithResponse request + CountStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*CountStatusPageSubscribersResponse, error) + + // ExportStatusPageSubscribersWithResponse request + ExportStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStatusPageSubscribersResponse, error) + + // DeleteStatusPageSubscriberWithResponse request + DeleteStatusPageSubscriberWithResponse(ctx context.Context, id openapi_types.UUID, subscriberId openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteStatusPageSubscriberResponse, error) + // UnpublishStatusPageWithResponse request UnpublishStatusPageWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*UnpublishStatusPageResponse, error) } @@ -9221,6 +9636,137 @@ func (r PublishStatusPageResponse) ContentType() string { return "" } +type ListStatusPageSubscribersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Cursors ResponseAPIResponsePaginationCursors `json:"cursors"` + List []DtoStatusPageSubscriber `json:"list"` + Meta ResponseAPIResponsePaginationMeta `json:"meta"` + } + JSON401 *ResponseProblem + JSON403 *ResponseProblem + JSON404 *ResponseProblem +} + +// Status returns HTTPResponse.Status +func (r ListStatusPageSubscribersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListStatusPageSubscribersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListStatusPageSubscribersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type CountStatusPageSubscribersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DtoStatusPageSubscriberCount + JSON401 *ResponseProblem + JSON403 *ResponseProblem + JSON404 *ResponseProblem +} + +// Status returns HTTPResponse.Status +func (r CountStatusPageSubscribersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CountStatusPageSubscribersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CountStatusPageSubscribersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ExportStatusPageSubscribersResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ExportStatusPageSubscribersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ExportStatusPageSubscribersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ExportStatusPageSubscribersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type DeleteStatusPageSubscriberResponse struct { + Body []byte + HTTPResponse *http.Response + JSON401 *ResponseProblem + JSON403 *ResponseProblem + JSON404 *ResponseProblem +} + +// Status returns HTTPResponse.Status +func (r DeleteStatusPageSubscriberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteStatusPageSubscriberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteStatusPageSubscriberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type UnpublishStatusPageResponse struct { Body []byte HTTPResponse *http.Response @@ -9824,6 +10370,42 @@ func (c *ClientWithResponses) PublishStatusPageWithResponse(ctx context.Context, return ParsePublishStatusPageResponse(rsp) } +// ListStatusPageSubscribersWithResponse request returning *ListStatusPageSubscribersResponse +func (c *ClientWithResponses) ListStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, params *ListStatusPageSubscribersParams, reqEditors ...RequestEditorFn) (*ListStatusPageSubscribersResponse, error) { + rsp, err := c.ListStatusPageSubscribers(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListStatusPageSubscribersResponse(rsp) +} + +// CountStatusPageSubscribersWithResponse request returning *CountStatusPageSubscribersResponse +func (c *ClientWithResponses) CountStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*CountStatusPageSubscribersResponse, error) { + rsp, err := c.CountStatusPageSubscribers(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseCountStatusPageSubscribersResponse(rsp) +} + +// ExportStatusPageSubscribersWithResponse request returning *ExportStatusPageSubscribersResponse +func (c *ClientWithResponses) ExportStatusPageSubscribersWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStatusPageSubscribersResponse, error) { + rsp, err := c.ExportStatusPageSubscribers(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseExportStatusPageSubscribersResponse(rsp) +} + +// DeleteStatusPageSubscriberWithResponse request returning *DeleteStatusPageSubscriberResponse +func (c *ClientWithResponses) DeleteStatusPageSubscriberWithResponse(ctx context.Context, id openapi_types.UUID, subscriberId openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteStatusPageSubscriberResponse, error) { + rsp, err := c.DeleteStatusPageSubscriber(ctx, id, subscriberId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteStatusPageSubscriberResponse(rsp) +} + // UnpublishStatusPageWithResponse request returning *UnpublishStatusPageResponse func (c *ClientWithResponses) UnpublishStatusPageWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*UnpublishStatusPageResponse, error) { rsp, err := c.UnpublishStatusPage(ctx, id, reqEditors...) @@ -12453,6 +13035,160 @@ func ParsePublishStatusPageResponse(rsp *http.Response) (*PublishStatusPageRespo return response, nil } +// ParseListStatusPageSubscribersResponse parses an HTTP response from a ListStatusPageSubscribersWithResponse call +func ParseListStatusPageSubscribersResponse(rsp *http.Response) (*ListStatusPageSubscribersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListStatusPageSubscribersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Cursors ResponseAPIResponsePaginationCursors `json:"cursors"` + List []DtoStatusPageSubscriber `json:"list"` + Meta ResponseAPIResponsePaginationMeta `json:"meta"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseCountStatusPageSubscribersResponse parses an HTTP response from a CountStatusPageSubscribersWithResponse call +func ParseCountStatusPageSubscribersResponse(rsp *http.Response) (*CountStatusPageSubscribersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CountStatusPageSubscribersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DtoStatusPageSubscriberCount + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseExportStatusPageSubscribersResponse parses an HTTP response from a ExportStatusPageSubscribersWithResponse call +func ParseExportStatusPageSubscribersResponse(rsp *http.Response) (*ExportStatusPageSubscribersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ExportStatusPageSubscribersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseDeleteStatusPageSubscriberResponse parses an HTTP response from a DeleteStatusPageSubscriberWithResponse call +func ParseDeleteStatusPageSubscriberResponse(rsp *http.Response) (*DeleteStatusPageSubscriberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteStatusPageSubscriberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ResponseProblem + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + // ParseUnpublishStatusPageResponse parses an HTTP response from a UnpublishStatusPageWithResponse call func ParseUnpublishStatusPageResponse(rsp *http.Response) (*UnpublishStatusPageResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/internal/cli/monitor/cmd.go b/internal/cli/monitor/cmd.go index 161a214..55fd403 100644 --- a/internal/cli/monitor/cmd.go +++ b/internal/cli/monitor/cmd.go @@ -70,8 +70,8 @@ fails it when the check finds the monitor down. CI tokens need a Norcube Monitor scope: monitor.read (everything that reads), monitor.check (run checks), monitor.write (manage monitors and incidents), monitor.channels (manage alert channels) or -monitor.statuspages (manage status pages and post on them). monitor.write -includes neither of the last two.`, +monitor.statuspages (manage status pages, post on them and manage their +subscribers). monitor.write includes neither of the last two.`, } cmd.AddCommand( newStatusCmd(d), diff --git a/internal/cli/monitor/completion.go b/internal/cli/monitor/completion.go index 3b6290b..a7c8df2 100644 --- a/internal/cli/monitor/completion.go +++ b/internal/cli/monitor/completion.go @@ -44,6 +44,10 @@ func registerCompletions(root *cobra.Command, d deps) { c.ValidArgsFunction = completion.Func(completePages, 1, pageCandidates(d)) case " ": c.ValidArgsFunction = postArgCompletion(d) + case " ": + // Only the page: completion candidates are cached on disk, and + // subscribers' addresses have no place there. + c.ValidArgsFunction = completion.Func(completePages, 1, pageCandidates(d)) } for _, sub := range c.Commands() { walk(sub) diff --git a/internal/cli/monitor/format.go b/internal/cli/monitor/format.go index 3e50108..bde98c1 100644 --- a/internal/cli/monitor/format.go +++ b/internal/cli/monitor/format.go @@ -516,6 +516,7 @@ func statusPageObject(p monitor.DtoStatusPage) output.Object { {Name: "Uptime percent", Value: yesNo(s.ShowUptimePercent)}, {Name: "Response time", Value: yesNo(s.ShowResponseTime)}, {Name: "Search indexing", Value: yesNo(s.SearchIndexing)}, + {Name: "Automatic posts", Value: yesNo(cmdutil.Deref(s.AutoPost))}, {Name: "Created", Value: output.WhenString(p.CreatedAt)}, {Name: "Updated", Value: output.WhenString(p.UpdatedAt)}, }} @@ -559,6 +560,30 @@ func statusPageLayoutObject(l monitor.DtoStatusPageLayout) output.Object { return output.Object{Value: l, Fields: fields, Text: []string{strconv.Itoa(count), strconv.Itoa(len(l.Groups))}} } +// ---------- subscribers ---------- + +// subscriberComponents says what a subscriber follows: an empty list means +// every component of the page. +func subscriberComponents(s monitor.DtoStatusPageSubscriber) string { + if len(s.ComponentIds) == 0 { + return "all" + } + return strconv.Itoa(len(s.ComponentIds)) +} + +func subscriberTable(items []monitor.DtoStatusPageSubscriber) output.Table[monitor.DtoStatusPageSubscriber] { + return output.Table[monitor.DtoStatusPageSubscriber]{ + Headers: []string{"ID", "EMAIL", "STATUS", "LOCALE", "COMPONENTS", "CREATED", "CONFIRMED"}, + Rows: func(s monitor.DtoStatusPageSubscriber) []string { + return []string{ + s.Id.String(), s.Email, string(s.Status), string(s.Locale), subscriberComponents(s), + output.WhenString(s.CreatedAt), output.WhenString(cmdutil.Deref(s.ConfirmedAt)), + } + }, + Items: items, + } +} + // ---------- posted incidents ---------- func postRow(i monitor.DtoStatusPageIncident) []string { @@ -590,7 +615,7 @@ func postObject(p monitor.DtoStatusPage, i monitor.DtoStatusPageIncident) output for _, u := range i.Updates { updates = append(updates, stamp(u.CreatedAt)+" "+string(u.Status)+": "+u.Body) } - return output.Object{Value: i, Text: postRow(i), Fields: []output.Field{ + fields := []output.Field{ {Name: "ID", Value: i.Id.String()}, {Name: "Title", Value: i.Title}, {Name: "Status", Value: string(i.Status)}, @@ -601,5 +626,13 @@ func postObject(p monitor.DtoStatusPage, i monitor.DtoStatusPageIncident) output {Name: "Components", Value: orNone(components)}, {Name: "Monitor incidents", Value: orNone(i.MonitorIncidentIds)}, {Name: "Updates", Value: orNone(updates)}, - }} + } + if i.AutoPosted { + who := "yes, a person has taken it over" + if i.AutoManaged { + who = "yes, and the system still runs it" + } + fields = append(fields, output.Field{Name: "Posted automatically", Value: who}) + } + return output.Object{Value: i, Text: postRow(i), Fields: fields} } diff --git a/internal/cli/monitor/statuspage_incidents.go b/internal/cli/monitor/statuspage_incidents.go index a859de4..6429bce 100644 --- a/internal/cli/monitor/statuspage_incidents.go +++ b/internal/cli/monitor/statuspage_incidents.go @@ -22,6 +22,8 @@ var ( affectedStatuses = []string{"operational", "degraded_performance", "partial_outage", "major_outage"} ) +const notifyFlagHelp = "Email this update to the page's subscribers; a page that isn't published emails nobody" + const componentFlagHelp = `An affected component and the status the page shows it in while the incident is open, as "=" (repeatable): operational, degraded_performance, partial_outage or major_outage` func newStatusPageIncidentsCmd(d deps) *cobra.Command { @@ -37,7 +39,11 @@ never published. While a post is open, the status it gives an affected component wins over what the component's monitor says. A post with status resolved moves to the page's history. On a published page everything here is public within a -minute.`, +minute. + +A page with --auto-post also posts by itself. A person's correction or update +on such a post takes it over for good: the system leaves it alone from then +on, and it ends when you end it.`, } cmd.AddCommand(newPostListCmd(d), newPostGetCmd(d), newPostCreateCmd(d), newPostUpdateCmd(d), newPostUpdatesCmd(d)) return cmd @@ -160,6 +166,7 @@ func newPostCreateCmd(d deps) *cobra.Command { startedAt string components []string monitorIncidents []string + notify bool ) cmd := &cobra.Command{ Use: "create ", @@ -171,9 +178,10 @@ overall status while it is open, and --component sets what the page shows for the components it affects. --monitor-incident links the monitor incidents the post is about, for your -own navigation; the links are never published.`, +own navigation; the links are never published. --notify also emails the first +update to the page's subscribers.`, Example: ` norcube monitor status-pages incidents create acme --title "Elevated API errors" --status investigating --impact minor --message "We are looking into it." - norcube monitor status-pages incidents create acme --title "Checkout is down" --status identified --impact major --message-file update.txt --component "Checkout=major_outage" --started-at 20m`, + norcube monitor status-pages incidents create acme --title "Checkout is down" --status identified --impact major --message-file update.txt --component "Checkout=major_outage" --started-at 20m --notify`, Args: cobra.ExactArgs(1), RunE: cmdutil.Run(func(cmd *cobra.Command, args []string) (any, error) { if err := oneOf("--status", status, postStatuses); err != nil { @@ -209,6 +217,9 @@ own navigation; the links are never published.`, if len(links) > 0 { body.MonitorIncidentIds = &links } + if cmd.Flags().Changed("notify") { + body.Notify = ¬ify + } c, err := d.client(cmd) if err != nil { return nil, err @@ -231,7 +242,7 @@ own navigation; the links are never published.`, if res.JSON201 == nil { return nil, apiError(res.HTTPResponse, res.Body) } - return postDone(p, *res.JSON201, "Posted incident"), nil + return postDone(p, *res.JSON201, "Posted incident", notify), nil }), } cmd.Flags().StringVar(&title, "title", "", "The incident's public title") @@ -241,6 +252,7 @@ own navigation; the links are never published.`, cmd.Flags().StringVar(&startedAt, "started-at", "", "When it began, if not now: an RFC 3339 timestamp, a date or an age (20m, 2h)") cmd.Flags().StringArrayVar(&components, "component", nil, componentFlagHelp) cmd.Flags().StringSliceVar(&monitorIncidents, "monitor-incident", nil, "Id of a monitor incident this post is about (repeat or comma-separate); never published") + cmd.Flags().BoolVar(¬ify, "notify", false, notifyFlagHelp) cmdutil.FlagEnum(cmd, "status", postStatuses...) cmdutil.FlagEnum(cmd, "impact", postImpacts...) for _, name := range []string{"title", "status", "impact"} { @@ -337,7 +349,7 @@ correction is public within a minute.`, if res.JSON200 == nil { return nil, apiError(res.HTTPResponse, res.Body) } - return postDone(p, *res.JSON200, "Corrected incident"), nil + return postDone(p, *res.JSON200, "Corrected incident", false), nil }), } cmd.Flags().StringVar(&title, "title", "", "New public title") @@ -370,6 +382,7 @@ func newPostUpdateCreateCmd(d deps) *cobra.Command { status string components []string noComponents bool + notify bool ) cmd := &cobra.Command{ Use: "create ", @@ -378,9 +391,10 @@ func newPostUpdateCreateCmd(d deps) *cobra.Command { Long: `Adds an update to an open post. Its status becomes the post's; resolved ends the post and moves it to the page's history, after which it takes no more updates (post a new incident instead). On a published page the update is -public within a minute. --component replaces the affected components.`, +public within a minute. --component replaces the affected components, and +--notify also emails the update to the page's subscribers.`, Example: ` norcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status monitoring --message "A fix is rolling out." - norcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status resolved --message "All clear."`, + norcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status resolved --message "All clear." --notify`, Args: cobra.ExactArgs(2), RunE: cmdutil.Run(func(cmd *cobra.Command, args []string) (any, error) { incidentID, err := idArg("posted incident", args[1]) @@ -402,6 +416,9 @@ public within a minute. --component replaces the affected components.`, if noComponents { body.Components = &[]monitor.DtoStatusPageAffected{} } + if cmd.Flags().Changed("notify") { + body.Notify = ¬ify + } c, err := d.client(cmd) if err != nil { return nil, err @@ -424,13 +441,14 @@ public within a minute. --component replaces the affected components.`, if res.JSON201 == nil { return nil, apiError(res.HTTPResponse, res.Body) } - return postDone(p, *res.JSON201, "Posted an update on incident"), nil + return postDone(p, *res.JSON201, "Posted an update on incident", notify), nil }), } cmd.Flags().StringVar(&status, "status", "", "Where it stands now: investigating, identified, monitoring or resolved") addMessageFlags(cmd, &msg, "The update's text") cmd.Flags().StringArrayVar(&components, "component", nil, componentFlagHelp) cmd.Flags().BoolVar(&noComponents, "no-components", false, "Remove every affected component") + cmd.Flags().BoolVar(¬ify, "notify", false, notifyFlagHelp) cmd.MarkFlagsMutuallyExclusive("component", "no-components") cmdutil.FlagEnum(cmd, "status", postStatuses...) _ = cmd.MarkFlagRequired("status") @@ -438,14 +456,20 @@ public within a minute. --component replaces the affected components.`, } // postDone is the result of a write on a post: the API's resource, and a -// line saying who can see it now. -func postDone(p monitor.DtoStatusPage, inc monitor.DtoStatusPageIncident, verb string) output.Done { +// line saying who can see it now and whether subscribers hear of it. +func postDone(p monitor.DtoStatusPage, inc monitor.DtoStatusPageIncident, verb string, notify bool) output.Done { msg := fmt.Sprintf("%s %q on %s. ", verb, inc.Title, p.Slug) if p.Published { msg += "Public within a minute at " + postURL(p, inc.Id) + "." } else { msg += "The page isn't published, so only preview links show it." } + switch { + case notify && p.Published: + msg += " Subscribers get it by email." + case notify: + msg += " No email goes out from a page that isn't published." + } return output.Done{Message: msg, Value: inc, Fields: []output.Field{{Value: inc.Id.String()}, {Value: string(inc.Status)}}} } diff --git a/internal/cli/monitor/statuspage_subscribers.go b/internal/cli/monitor/statuspage_subscribers.go new file mode 100644 index 0000000..ce4bb11 --- /dev/null +++ b/internal/cli/monitor/statuspage_subscribers.go @@ -0,0 +1,149 @@ +package monitor + +import ( + "context" + "errors" + "fmt" + "net/http" + + "github.com/spf13/cobra" + + "github.com/norcubeplatform/cli/internal/api/monitor" + "github.com/norcubeplatform/cli/internal/clierr" + "github.com/norcubeplatform/cli/internal/cmdutil" + "github.com/norcubeplatform/cli/internal/output" +) + +func newStatusPageSubscribersCmd(d deps) *cobra.Command { + cmd := &cobra.Command{ + Use: "subscribers", + Aliases: []string{"subscriber"}, + Short: "See and delete the people who get a status page's email updates", + Long: `Subscribers are people who asked for email updates through the form on a +status page. An address stays pending until it confirms from the mail it +gets, and is removed if it hasn't after 7 days; only a confirmed address +gets updates. Every mail sent counts as an email notification in your +Norcube Monitor usage. + +Updates reach subscribers when you post with --notify ("incidents create", +"incidents updates create") and when the page's --auto-post posts for you. + +Addresses are personal data. Listing or deleting them takes the +monitor:ManageStatusPageSubscribers permission and, on a CI token, the +monitor.statuspages scope: no other scope reaches them, not even one that +reads the page itself.`, + } + cmd.AddCommand(newSubscriberListCmd(d), newSubscriberDeleteCmd(d)) + return cmd +} + +func newSubscriberListCmd(d deps) *cobra.Command { + var pf cmdutil.PageFlags + cmd := &cobra.Command{ + Use: "list ", + Annotations: cmdutil.Reads(), + Short: "List a status page's subscribers, newest first", + Long: `Lists confirmed and pending subscribers. COMPONENTS is "all", or how many +of the page's components the subscriber follows; -o json has their ids. + +The output holds personal data, so keep it out of build logs and other places +many people can read.`, + Example: ` norcube monitor status-pages subscribers list acme + norcube monitor status-pages subscribers list acme --all-pages -o json --query "[?status=='confirmed'].email"`, + Args: cobra.ExactArgs(1), + RunE: cmdutil.Run(func(cmd *cobra.Command, args []string) (any, error) { + c, err := d.client(cmd) + if err != nil { + return nil, err + } + id, err := statusPageID(cmd.Context(), c, args[0]) + if err != nil { + return nil, err + } + page, err := cmdutil.Paginate(cmd.Context(), pf, func(ctx context.Context, cursor string, size int) ([]monitor.DtoStatusPageSubscriber, string, error) { + p := monitor.ListStatusPageSubscribersParams{Limit: &size} + if cursor != "" { + p.Cursor = &cursor + } + res, err := c.API.ListStatusPageSubscribersWithResponse(ctx, id, &p) + if err != nil { + return nil, "", err + } + if res.JSON200 == nil { + return nil, "", subscriberError(res.HTTPResponse, res.Body) + } + return res.JSON200.List, nextCursor(res.JSON200.Cursors), nil + }) + if err != nil { + return nil, err + } + return nil, page.Print(cmd, subscriberTable(page.Items)) + }), + } + cmdutil.AddPageFlags(cmd, &pf, defaultPageSize, maxItems) + return cmd +} + +func newSubscriberDeleteCmd(d deps) *cobra.Command { + var yes bool + cmd := &cobra.Command{ + Use: "delete ", + Annotations: cmdutil.Writes(), + Short: "Delete a subscriber and any mail queued for them", + Long: `Deletes the subscriber by id ("subscribers list" shows it) and any mail +queued for them. Their address isn't kept, so they can subscribe again.`, + Example: ` norcube monitor status-pages subscribers delete acme 3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 + norcube monitor status-pages subscribers delete acme 3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 --yes`, + Args: cobra.ExactArgs(2), + RunE: cmdutil.Run(func(cmd *cobra.Command, args []string) (any, error) { + subscriberID, err := idArg("subscriber", args[1]) + if err != nil { + return nil, err + } + c, err := d.client(cmd) + if err != nil { + return nil, err + } + id, err := statusPageID(cmd.Context(), c, args[0]) + if err != nil { + return nil, err + } + if ok, err := cmdutil.Confirm(fmt.Sprintf("Delete subscriber %s from status page %s, with any mail queued for them?", subscriberID, args[0]), yes); err != nil || !ok { + return nil, cmdutil.Cancelled(cmd, err) + } + res, err := c.API.DeleteStatusPageSubscriberWithResponse(cmd.Context(), id, subscriberID) + if err != nil { + return nil, err + } + if res.StatusCode() != http.StatusNoContent { + return nil, subscriberError(res.HTTPResponse, res.Body) + } + return output.Done{ + Message: fmt.Sprintf("Deleted subscriber %s from status page %s.", subscriberID, args[0]), + Value: deleted{ID: subscriberID.String(), Deleted: true}, + Fields: []output.Field{{Value: subscriberID.String()}}, + }, nil + }), + } + cmd.Flags().BoolVar(&yes, "yes", false, "Don't ask for confirmation") + return cmd +} + +// subscriberError renders a refused subscriber request. The API's scope +// refusal is shared with the page's other writes and speaks of changing pages, +// which misleads on a list, so this one names what was refused. The code and +// exit code stay those of any other scope refusal. +func subscriberError(resp *http.Response, body []byte) error { + err := apiError(resp, body) + var e *clierr.Error + if !errors.As(err, &e) { + return err + } + switch e.Code { + case clierr.CodeInsufficientScope: + e.Message = "This token can't list or delete a status page's subscribers: their addresses are personal data, and it needs the monitor.statuspages scope." + case clierr.CodePermissionDenied: + e.Hint = "Addresses are personal data: this takes the monitor:ManageStatusPageSubscribers permission in your organization." + } + return err +} diff --git a/internal/cli/monitor/statuspages.go b/internal/cli/monitor/statuspages.go index 7367673..8d6231a 100644 --- a/internal/cli/monitor/statuspages.go +++ b/internal/cli/monitor/statuspages.go @@ -27,7 +27,7 @@ func newStatusPagesCmd(d deps) *cobra.Command { cmd := &cobra.Command{ Use: "status-pages", Aliases: []string{"status-page"}, - Short: "Manage public status pages, their layout and the incidents posted on them", + Short: "Manage public status pages, their layout, posted incidents and subscribers", Long: `A status page is a public page that shows chosen monitors and manual rows as components, under names you pick; a monitor's own name and target are never shown. A page starts unpublished: set its layout, check it with a @@ -35,14 +35,15 @@ preview link, then publish it. Changes to a published page, and incidents posted on it, are public within a minute. Pages are named by their id or exact slug. Any Norcube Monitor scope reads -them; a CI token changes them or posts on them only with the -monitor.statuspages scope, which no other scope includes, because -everything it changes is public.`, +them; a CI token changes them, posts on them or reaches their subscribers +only with the monitor.statuspages scope, which no other scope includes, +because what it changes is public and subscribers' addresses are personal +data.`, } cmd.AddCommand( newStatusPageListCmd(d), newStatusPageGetCmd(d), newStatusPageCreateCmd(d), newStatusPageUpdateCmd(d), newStatusPageDeleteCmd(d), newStatusPagePublishCmd(d), newStatusPageUnpublishCmd(d), newStatusPagePreviewLinkCmd(d), - newStatusPageLayoutCmd(d), newStatusPageIncidentsCmd(d), + newStatusPageLayoutCmd(d), newStatusPageIncidentsCmd(d), newStatusPageSubscribersCmd(d), ) return cmd } @@ -128,7 +129,7 @@ type statusPageFlags struct { slug, description, timeZone string uptimeDays, historyDays int bars, percent, response bool - indexing bool + indexing, autoPost bool } func addStatusPageFlags(cmd *cobra.Command, f *statusPageFlags) { @@ -142,6 +143,7 @@ func addStatusPageFlags(cmd *cobra.Command, f *statusPageFlags) { fl.BoolVar(&f.percent, "show-uptime-percent", false, "Show each component's uptime percentage (--show-uptime-percent=false hides it)") fl.BoolVar(&f.response, "show-response-time", false, "Show each component's average response time (--show-response-time=false hides it)") fl.BoolVar(&f.indexing, "search-indexing", false, "Let search engines index the page (--search-indexing=false asks them to leave it out)") + fl.BoolVar(&f.autoPost, "auto-post", false, "Post confirmed critical monitor incidents on the page by itself and email subscribers (--auto-post=false turns it off)") cmdutil.FlagEnum(cmd, "uptime-days", statusPageUptimeDays...) } @@ -167,7 +169,12 @@ func newStatusPageCreateCmd(d deps) *cobra.Command { Long: `Creates a page that nobody can see yet: set what it shows with "layout set", check it with "preview-link", then "publish" it. Every setting is required: the page's public face is your choice, so nothing is filled in -for you. A boolean takes =false to turn it off. +for you. A boolean takes =false to turn it off. The one exception is +--auto-post, which is off unless you ask for it. + +--auto-post lets the page post by itself: a monitor incident that stays +critical for 3 minutes is posted in fixed wording and emailed to subscribers, +and the post resolves when the incident does. A warning is never posted. Your organization's limit sets how many pages it can have, published or not.`, Example: ` norcube monitor status-pages create "Acme status" --slug acme --time-zone Europe/Prague --uptime-days 90 --history-days 90 --show-uptime-bars --show-uptime-percent --show-response-time=false --search-indexing`, @@ -189,6 +196,9 @@ Your organization's limit sets how many pages it can have, published or not.`, SearchIndexing: f.indexing, }, } + if cmd.Flags().Changed("auto-post") { + body.Settings.AutoPost = &f.autoPost + } if f.description != "" { body.Description = &f.description } @@ -232,10 +242,14 @@ a minute. --slug moves the page to a new address. The old address of a published page redirects to the new one for 30 days, and no other organization can -take it meanwhile; unpublishing or deleting the page gives it up.`, +take it meanwhile; unpublishing or deleting the page gives it up. + +--auto-post=false stops new automatic posts; one already open still ends by +itself when its monitors recover.`, Example: ` norcube monitor status-pages update acme --name "Acme Inc. status" norcube monitor status-pages update acme --slug acme-inc - norcube monitor status-pages update acme --uptime-days 30 --show-response-time`, + norcube monitor status-pages update acme --uptime-days 30 --show-response-time + norcube monitor status-pages update acme --auto-post`, Args: cobra.ExactArgs(1), RunE: cmdutil.Run(func(cmd *cobra.Command, args []string) (any, error) { if err := checkStatusPageFlags(cmd, f); err != nil { @@ -313,6 +327,9 @@ func statusPageUpdateBody(cmd *cobra.Command, f statusPageFlags, name string) (m if set("search-indexing") { s.SearchIndexing, settings = &f.indexing, true } + if set("auto-post") { + s.AutoPost, settings = &f.autoPost, true + } if settings { body.Settings, changed = &s, true } diff --git a/internal/cli/monitor_test.go b/internal/cli/monitor_test.go index 62ea693..807ff6a 100644 --- a/internal/cli/monitor_test.go +++ b/internal/cli/monitor_test.go @@ -35,6 +35,7 @@ const ( spDesk = "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6f" spGroup = "c3d4e5f6-a7b8-4c9d-8e1f-2a3b4c5d6e70" spPost = "8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f" + spSub = "3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9" spPostURL = "https://acme.norcubestatus.com/incidents/" + spPost ) @@ -77,7 +78,7 @@ var ( ) var ( - spSettingsJSON = `"settings":{"timeZone":"Europe/Prague","uptimeDays":90,"showUptimeBars":true,"showUptimePercent":true,"showResponseTime":false,"historyDays":90,"searchIndexing":true}` + spSettingsJSON = `"settings":{"timeZone":"Europe/Prague","uptimeDays":90,"showUptimeBars":true,"showUptimePercent":true,"showResponseTime":false,"historyDays":90,"searchIndexing":true,"autoPost":false}` spAcmeJSON = `{"id":"` + spAcme + `","slug":"acme","name":"Acme status","description":"Our services","url":"https://acme.norcubestatus.com","published":true,"publishedAt":"2026-11-02T09:00:00Z",` + spSettingsJSON + `,"createdAt":"2026-11-01T09:00:00Z","updatedAt":"2026-11-02T09:00:00Z"}` spDraftJSON = `{"id":"` + spDraft + `","slug":"draft-page","name":"Draft","description":"","url":"https://draft-page.norcubestatus.com","published":false,` + @@ -88,6 +89,8 @@ var ( "components":[{"componentId":"` + spSite + `","status":"partial_outage"}],"monitorIncidentIds":["` + monInc + `"], "updates":[{"id":"d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f70","status":"investigating","body":"We are looking into it.","createdAt":"2026-11-03T08:05:00Z"}], "createdAt":"2026-11-03T08:05:00Z","updatedAt":"2026-11-03T08:05:00Z"}` + spSubConfirmedJSON = `{"id":"` + spSub + `","email":"jan@example.com","locale":"cs","status":"confirmed","componentIds":[],"createdAt":"2026-11-03T09:00:00Z","confirmedAt":"2026-11-03T09:05:00Z"}` + spSubPendingJSON = `{"id":"e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a81","email":"eva@example.com","locale":"en","status":"pending","componentIds":["` + spSite + `","` + spDesk + `"],"createdAt":"2026-11-04T09:00:00Z"}` ) func monList(items ...string) string { @@ -132,6 +135,7 @@ func init() { "GET /status-pages/" + spAcme + "/layout": spLayoutJSON, "GET /status-pages/" + spAcme + "/incidents": monList(spPostJSON), "GET /status-pages/" + spAcme + "/incidents/" + spPost: spPostJSON, + "GET /status-pages/" + spAcme + "/subscribers": monList(spSubConfirmedJSON, spSubPendingJSON), } { goldenData[k] = v } @@ -163,6 +167,7 @@ func TestGoldenMonitor(t *testing.T) { {"monitor-status-pages-layout-get", []string{"monitor", "status-pages", "layout", "get", spAcme}}, {"monitor-status-pages-incidents-list", []string{"monitor", "status-pages", "incidents", "list", spAcme}}, {"monitor-status-pages-incidents-get", []string{"monitor", "status-pages", "incidents", "get", spAcme, spPost}}, + {"monitor-status-pages-subscribers-list", []string{"monitor", "status-pages", "subscribers", "list", "acme"}}, } for _, c := range commands { for format, ext := range goldenFormats { @@ -676,6 +681,10 @@ func TestMonitorCompletion(t *testing.T) { {[]string{"monitor", "status-pages", "incidents", "get", "acme", "8c"}, spPost}, {[]string{"monitor", "status-pages", "incidents", "updates", "create", "acme", "8c"}, spPost}, {[]string{"monitor", "status-pages", "create", "x", "--uptime-days", ""}, "30,60,90"}, + {[]string{"monitor", "status-pages", "subscribers", "list", "ac"}, "acme"}, + {[]string{"monitor", "status-pages", "subscribers", "delete", "ac"}, "acme"}, + // Addresses stay out of the on-disk completion cache. + {[]string{"monitor", "status-pages", "subscribers", "delete", "acme", ""}, ""}, } for _, c := range cases { got, _ := complete(t, c.args...) @@ -762,6 +771,15 @@ func TestMonitorStatusPageCreate(t *testing.T) { t.Errorf("body %s, want %s", got, want) } + // --auto-post is the one setting create doesn't require, and goes only when given. + rec = recorder{} + if _, stderr, err := run(t, append([]string{"monitor", "status-pages", "create", "Draft", "--auto-post"}, settings...)...); err != nil { + t.Fatalf("%v\n%s", err, stderr) + } + if got := fmt.Sprint(rec.only(t).body["settings"]); !strings.Contains(got, "autoPost:true") { + t.Errorf("settings %s", got) + } + rec = recorder{} cases := []struct { name string @@ -816,6 +834,8 @@ func TestMonitorStatusPageWrites(t *testing.T) { }{ {"update slug and setting", []string{"update", "acme", "--slug", "acme-inc", "--show-uptime-bars=false", "--history-days", "7"}, "PATCH /status-pages/" + spAcme, 200, spAcmeJSON, "", "map[settings:map[historyDays:7 showUptimeBars:false] slug:acme-inc]", "Public within a minute at https://acme.norcubestatus.com."}, + {"auto-post on", []string{"update", "acme", "--auto-post"}, "PATCH /status-pages/" + spAcme, 200, spAcmeJSON, "", "map[settings:map[autoPost:true]]", "Updated status page acme"}, + {"auto-post off", []string{"update", "acme", "--auto-post=false"}, "PATCH /status-pages/" + spAcme, 200, spAcmeJSON, "", "map[settings:map[autoPost:false]]", "Updated status page acme"}, {"update name only", []string{"update", spDraft, "--name", " New "}, "PATCH /status-pages/" + spDraft, 200, spDraftJSON, "", "map[name:New]", "Updated status page draft-page"}, {"publish", []string{"publish", "acme"}, "POST /status-pages/" + spAcme + "/publish", 200, spAcmeJSON, "", "", "public within a minute at https://acme.norcubestatus.com"}, @@ -975,6 +995,34 @@ func TestMonitorStatusPageIncidentCreate(t *testing.T) { t.Errorf("%v %q", err, out) } + // --notify is sent only when given, and the line says who hears of it. + var notified recorder + goldenHandlers(t, map[string]http.HandlerFunc{ + "POST /status-pages/" + spAcme + "/incidents": notified.handler(201, spPostJSON), + "POST /status-pages/" + spDraft + "/incidents": notified.handler(201, spPostJSON), + }) + out, _, err = run(t, "monitor", "status-pages", "incidents", "create", "acme", "--title", "T", "--status", "resolved", "--impact", "none", "--message", "m", "--notify") + if err != nil || !strings.Contains(out, "Subscribers get it by email") { + t.Errorf("%v %q", err, out) + } + if got := notified.only(t).body["notify"]; got != true { + t.Errorf("notify %v", got) + } + notified = recorder{} + out, _, err = run(t, "monitor", "status-pages", "incidents", "create", spDraft, "--title", "T", "--status", "resolved", "--impact", "none", "--message", "m", "--notify") + if err != nil || !strings.Contains(out, "No email goes out") { + t.Errorf("%v %q", err, out) + } + notified = recorder{} + out, _, err = run(t, "monitor", "status-pages", "incidents", "create", "acme", "--title", "T", "--status", "resolved", "--impact", "none", "--message", "m") + if err != nil || strings.Contains(out, "email") { + t.Errorf("%v %q", err, out) + } + if _, sent := notified.only(t).body["notify"]; sent { + t.Error("notify sent without --notify") + } + goldenHandlers(t, map[string]http.HandlerFunc{"POST /status-pages/" + spAcme + "/incidents": rec.handler(201, spPostJSON)}) + // Mistakes never reach the API. rec = recorder{} base := []string{"monitor", "status-pages", "incidents", "create", "acme"} @@ -1023,6 +1071,8 @@ func TestMonitorStatusPageIncidentUpdates(t *testing.T) { "PATCH " + route, 200, "map[components:[] monitorIncidentIds:[]]"}, {"post an update", []string{"updates", "create", "acme", spPost, "--status", "monitoring", "--message", "A fix is rolling out."}, "POST " + route + "/updates", 201, "map[body:A fix is rolling out. status:monitoring]"}, + {"post an update and email it", []string{"updates", "create", "acme", spPost, "--status", "monitoring", "--message", "m", "--notify"}, + "POST " + route + "/updates", 201, "map[body:m notify:true status:monitoring]"}, {"resolve, clearing components", []string{"updates", "create", "acme", spPost, "--status", "resolved", "--message", "All clear.", "--no-components"}, "POST " + route + "/updates", 201, "map[body:All clear. components:[] status:resolved]"}, } @@ -1046,6 +1096,10 @@ func TestMonitorStatusPageIncidentUpdates(t *testing.T) { if _, _, err := run(t, "monitor", "status-pages", "incidents", "update", "acme", spPost); err == nil || exitOf(err) != clierr.ExitUsage { t.Errorf("nothing to change: %v", err) } + // Corrections take no --notify: the API has no such field on them. + if _, _, err := run(t, "monitor", "status-pages", "incidents", "update", "acme", spPost, "--title", "T", "--notify"); err == nil || exitOf(err) != clierr.ExitUsage { + t.Errorf("update --notify: %v", err) + } if _, _, err := run(t, "monitor", "status-pages", "incidents", "get", "acme", "nope"); err == nil || exitOf(err) != clierr.ExitUsage { t.Errorf("an incident is named by id: %v", err) } @@ -1086,3 +1140,136 @@ func TestMonitorStatusPageHelpSaysWhatGoesPublic(t *testing.T) { } } } + +// --all-pages follows the API's cursor, and a page is named by slug or id. +func TestMonitorStatusPageSubscriberList(t *testing.T) { + goldenEnv(t) + var ( + mu sync.Mutex + queries []string + ) + goldenHandlers(t, map[string]http.HandlerFunc{"GET /status-pages/" + spAcme + "/subscribers": func(w http.ResponseWriter, r *http.Request) { + mu.Lock() + queries = append(queries, r.URL.RawQuery) + mu.Unlock() + if r.URL.Query().Get("cursor") == "" { + fmt.Fprint(w, `{"list":[`+spSubConfirmedJSON+`],"cursors":{"next":"abc"},"meta":{}}`) + return + } + fmt.Fprint(w, monList(spSubPendingJSON)) + }}) + for _, page := range []string{"acme", spAcme} { + mu.Lock() + queries = nil + mu.Unlock() + out, stderr, err := run(t, "monitor", "status-pages", "subscribers", "list", page, "--all-pages", "-o", "json", "--query", "[].email") + if err != nil { + t.Fatalf("%v\n%s", err, stderr) + } + if !strings.Contains(out, "jan@example.com") || !strings.Contains(out, "eva@example.com") { + t.Errorf("%s, stdout: %s", page, out) + } + mu.Lock() + if len(queries) != 2 || !strings.Contains(queries[1], "cursor=abc") { + t.Errorf("%s, queries: %v", page, queries) + } + mu.Unlock() + } +} + +func TestMonitorStatusPageSubscriberDelete(t *testing.T) { + goldenEnv(t) + var rec recorder + route := "DELETE /status-pages/" + spAcme + "/subscribers/" + spSub + goldenHandlers(t, map[string]http.HandlerFunc{route: rec.handler(204, "")}) + base := []string{"monitor", "status-pages", "subscribers", "delete", "acme"} + + // Without a terminal it asks for --yes and sends nothing; so do mistakes. + _, _, err := run(t, append(append([]string{}, base...), spSub)...) + if err == nil || exitOf(err) != clierr.ExitUsage || !strings.Contains(err.Error(), "--yes") { + t.Errorf("without --yes: %v", err) + } + _, _, err = run(t, append(append([]string{}, base...), "jan@example.com", "--yes")...) + if err == nil || exitOf(err) != clierr.ExitUsage || !strings.Contains(err.Error(), "subscriber id") { + t.Errorf("not an id: %v", err) + } + if rec.count() != 0 { + t.Fatalf("%d requests were sent", rec.count()) + } + + out, stderr, err := run(t, append(append([]string{}, base...), spSub, "--yes", "-o", "json")...) + if err != nil { + t.Fatalf("%v\n%s", err, stderr) + } + if !strings.Contains(out, `"deleted": true`) || !strings.Contains(out, spSub) { + t.Errorf("stdout: %s", out) + } + if rec.count() != 1 { + t.Errorf("%d requests", rec.count()) + } + + // A subscriber that isn't there exits 3. + goldenHandlers(t, map[string]http.HandlerFunc{route: (&recorder{}).handler(404, + `{"title":"Not Found","status":404,"detail":"Subscriber not found.","code":"NOT_FOUND"}`)}) + _, _, err = run(t, append(append([]string{}, base...), spSub, "--yes")...) + if e := Describe(err); e.Code != clierr.CodeNotFound || e.ExitCode() != clierr.ExitNotFound { + t.Errorf("not found: %+v", e) + } +} + +// Addresses are personal data: a token without monitor.statuspages exits 5 and +// is told what was refused and why, on the read as on the delete, and a person +// without the permission is told which one it takes. +func TestMonitorStatusPageSubscriberRefusals(t *testing.T) { + goldenEnv(t) + listRoute := "GET /status-pages/" + spAcme + "/subscribers" + deleteRoute := "DELETE /status-pages/" + spAcme + "/subscribers/" + spSub + scope := `{"title":"Forbidden","status":403,"detail":"This token can't change status pages or post on them: it needs the monitor.statuspages scope.","code":"FORBIDDEN","reason":"INSUFFICIENT_SCOPE"}` + iam := `{"title":"Forbidden","status":403,"detail":"You don't have access to this in Norcube Monitor.","code":"FORBIDDEN"}` + commands := map[string][]string{ + "list": {"monitor", "status-pages", "subscribers", "list", "acme"}, + "delete": {"monitor", "status-pages", "subscribers", "delete", "acme", spSub, "--yes"}, + } + for name, args := range commands { + goldenHandlers(t, map[string]http.HandlerFunc{listRoute: (&recorder{}).handler(403, scope), deleteRoute: (&recorder{}).handler(403, scope)}) + _, _, err := run(t, args...) + e := Describe(err) + if e.Code != clierr.CodeInsufficientScope || e.ExitCode() != clierr.ExitAccess || + !strings.Contains(e.Message, "monitor.statuspages") || !strings.Contains(e.Message, "personal data") || strings.Contains(e.Message, "post on them") { + t.Errorf("%s, scope: %+v", name, e) + } + + goldenHandlers(t, map[string]http.HandlerFunc{listRoute: (&recorder{}).handler(403, iam), deleteRoute: (&recorder{}).handler(403, iam)}) + _, _, err = run(t, args...) + e = Describe(err) + if e.Code != clierr.CodePermissionDenied || e.ExitCode() != clierr.ExitAccess || !strings.Contains(e.Hint, "monitor:ManageStatusPageSubscribers") { + t.Errorf("%s, permission: %+v", name, e) + } + } +} + +// A post the system wrote says so, and whether it still runs it; a person's +// post shows no such line. +func TestMonitorStatusPageAutoPostShown(t *testing.T) { + goldenEnv(t) + route := "GET /status-pages/" + spAcme + "/incidents/" + spPost + auto := func(managed string) string { + return strings.Replace(spPostJSON, `"statusPageId"`, `"autoPosted":true,"autoManaged":`+managed+`,"statusPageId"`, 1) + } + args := []string{"monitor", "status-pages", "incidents", "get", "acme", spPost, "-o", "table"} + for managed, want := range map[string]string{"true": "the system still runs it", "false": "a person has taken it over"} { + goldenHandlers(t, map[string]http.HandlerFunc{route: (&recorder{}).handler(200, auto(managed))}) + out, stderr, err := run(t, args...) + if err != nil { + t.Fatalf("%v\n%s", err, stderr) + } + if !strings.Contains(out, "Posted automatically") || !strings.Contains(out, want) { + t.Errorf("autoManaged %s: %s", managed, out) + } + } + goldenHandlers(t, map[string]http.HandlerFunc{route: (&recorder{}).handler(200, spPostJSON)}) + out, _, err := run(t, args...) + if err != nil || strings.Contains(out, "Posted automatically") { + t.Errorf("%v %q", err, out) + } +} diff --git a/internal/cli/testdata/golden/commands-monitor.json b/internal/cli/testdata/golden/commands-monitor.json index aca2d55..32a614e 100644 --- a/internal/cli/testdata/golden/commands-monitor.json +++ b/internal/cli/testdata/golden/commands-monitor.json @@ -129,7 +129,7 @@ ], "name": "monitor", "short": "Monitor uptime, SSL certificates and domain expiry, and manage incidents and alerts", - "long": "Norcube Monitor checks your sites, certificates and domains on a schedule\nfrom Norcube's servers. A monitor is an HTTP check (optionally with a\nkeyword), an SSL certificate check or a domain expiry check. Problems\nconfirmed by consecutive checks open incidents, which alert through your\nalert channels (email, webhook, Slack, Discord, SMS). Status pages show\nchosen monitors to the public.\n\nMonitors and channels are named by their id or, where a command says so,\nby their exact name. Checks count towards your Norcube Monitor usage, on a\nschedule and when you run one now.\n\nIn CI, \"monitor status --fail-on critical\" fails the job while a\ncritical incident is open, and \"monitor monitors run \u003cmonitor\u003e --wait\"\nfails it when the check finds the monitor down. CI tokens need a\nNorcube Monitor scope: monitor.read (everything that reads),\nmonitor.check (run checks), monitor.write (manage monitors and\nincidents), monitor.channels (manage alert channels) or\nmonitor.statuspages (manage status pages and post on them). monitor.write\nincludes neither of the last two.", + "long": "Norcube Monitor checks your sites, certificates and domains on a schedule\nfrom Norcube's servers. A monitor is an HTTP check (optionally with a\nkeyword), an SSL certificate check or a domain expiry check. Problems\nconfirmed by consecutive checks open incidents, which alert through your\nalert channels (email, webhook, Slack, Discord, SMS). Status pages show\nchosen monitors to the public.\n\nMonitors and channels are named by their id or, where a command says so,\nby their exact name. Checks count towards your Norcube Monitor usage, on a\nschedule and when you run one now.\n\nIn CI, \"monitor status --fail-on critical\" fails the job while a\ncritical incident is open, and \"monitor monitors run \u003cmonitor\u003e --wait\"\nfails it when the check finds the monitor down. CI tokens need a\nNorcube Monitor scope: monitor.read (everything that reads),\nmonitor.check (run checks), monitor.write (manage monitors and\nincidents), monitor.channels (manage alert channels) or\nmonitor.statuspages (manage status pages, post on them and manage their\nsubscribers). monitor.write includes neither of the last two.", "usage": "norcube monitor \u003ccommand\u003e", "group": true, "service": { @@ -2705,8 +2705,8 @@ "aliases": [ "status-page" ], - "short": "Manage public status pages, their layout and the incidents posted on them", - "long": "A status page is a public page that shows chosen monitors and manual rows\nas components, under names you pick; a monitor's own name and target are\nnever shown. A page starts unpublished: set its layout, check it with a\npreview link, then publish it. Changes to a published page, and incidents\nposted on it, are public within a minute.\n\nPages are named by their id or exact slug. Any Norcube Monitor scope reads\nthem; a CI token changes them or posts on them only with the\nmonitor.statuspages scope, which no other scope includes, because\neverything it changes is public.", + "short": "Manage public status pages, their layout, posted incidents and subscribers", + "long": "A status page is a public page that shows chosen monitors and manual rows\nas components, under names you pick; a monitor's own name and target are\nnever shown. A page starts unpublished: set its layout, check it with a\npreview link, then publish it. Changes to a published page, and incidents\nposted on it, are public within a minute.\n\nPages are named by their id or exact slug. Any Norcube Monitor scope reads\nthem; a CI token changes them, posts on them or reaches their subscribers\nonly with the monitor.statuspages scope, which no other scope includes,\nbecause what it changes is public and subscribers' addresses are personal\ndata.", "usage": "norcube monitor status-pages \u003ccommand\u003e", "group": true, "service": { @@ -2728,7 +2728,7 @@ ], "name": "create", "short": "Create a status page, unpublished", - "long": "Creates a page that nobody can see yet: set what it shows with \"layout\nset\", check it with \"preview-link\", then \"publish\" it. Every setting is\nrequired: the page's public face is your choice, so nothing is filled in\nfor you. A boolean takes =false to turn it off.\n\nYour organization's limit sets how many pages it can have, published or not.", + "long": "Creates a page that nobody can see yet: set what it shows with \"layout\nset\", check it with \"preview-link\", then \"publish\" it. Every setting is\nrequired: the page's public face is your choice, so nothing is filled in\nfor you. A boolean takes =false to turn it off. The one exception is\n--auto-post, which is off unless you ask for it.\n\n--auto-post lets the page post by itself: a monitor incident that stays\ncritical for 3 minutes is posted in fixed wording and emailed to subscribers,\nand the post resolves when the incident does. A warning is never posted.\n\nYour organization's limit sets how many pages it can have, published or not.", "usage": "norcube monitor status-pages create \u003cname\u003e [flags]", "args": "\u003cname\u003e", "example": "norcube monitor status-pages create \"Acme status\" --slug acme --time-zone Europe/Prague --uptime-days 90 --history-days 90 --show-uptime-bars --show-uptime-percent --show-response-time=false --search-indexing", @@ -2749,6 +2749,14 @@ "text" ], "flags": [ + { + "name": "auto-post", + "type": "bool", + "default": "false", + "description": "Post confirmed critical monitor incidents on the page by itself and email subscribers (--auto-post=false turns it off)", + "required": false, + "repeatable": false + }, { "name": "description", "type": "string", @@ -2907,7 +2915,7 @@ "incident" ], "short": "Post incidents on a status page and keep them updated", - "long": "A posted incident is what you tell the public: a title, an impact and a\nseries of updates. It is separate from a monitor's own incidents, which stay\ninternal; a post may link to them for your navigation, but those links are\nnever published.\n\nWhile a post is open, the status it gives an affected component wins over\nwhat the component's monitor says. A post with status resolved moves to the\npage's history. On a published page everything here is public within a\nminute.", + "long": "A posted incident is what you tell the public: a title, an impact and a\nseries of updates. It is separate from a monitor's own incidents, which stay\ninternal; a post may link to them for your navigation, but those links are\nnever published.\n\nWhile a post is open, the status it gives an affected component wins over\nwhat the component's monitor says. A post with status resolved moves to the\npage's history. On a published page everything here is public within a\nminute.\n\nA page with --auto-post also posts by itself. A person's correction or update\non such a post takes it over for good: the system leaves it alone from then\non, and it ends when you end it.", "usage": "norcube monitor status-pages incidents \u003ccommand\u003e", "group": true, "service": { @@ -2930,10 +2938,10 @@ ], "name": "create", "short": "Post an incident on a status page; public within a minute on a published page", - "long": "Posts an incident with its first update. On a published page it is public\nwithin a minute: write it for your customers. It counts toward the page's\noverall status while it is open, and --component sets what the page shows\nfor the components it affects.\n\n--monitor-incident links the monitor incidents the post is about, for your\nown navigation; the links are never published.", + "long": "Posts an incident with its first update. On a published page it is public\nwithin a minute: write it for your customers. It counts toward the page's\noverall status while it is open, and --component sets what the page shows\nfor the components it affects.\n\n--monitor-incident links the monitor incidents the post is about, for your\nown navigation; the links are never published. --notify also emails the first\nupdate to the page's subscribers.", "usage": "norcube monitor status-pages incidents create \u003cpage\u003e [flags]", "args": "\u003cpage\u003e", - "example": "norcube monitor status-pages incidents create acme --title \"Elevated API errors\" --status investigating --impact minor --message \"We are looking into it.\"\nnorcube monitor status-pages incidents create acme --title \"Checkout is down\" --status identified --impact major --message-file update.txt --component \"Checkout=major_outage\" --started-at 20m", + "example": "norcube monitor status-pages incidents create acme --title \"Elevated API errors\" --status investigating --impact minor --message \"We are looking into it.\"\nnorcube monitor status-pages incidents create acme --title \"Checkout is down\" --status identified --impact major --message-file update.txt --component \"Checkout=major_outage\" --started-at 20m --notify", "group": false, "service": { "key": "monitor", @@ -2992,6 +3000,14 @@ "required": false, "repeatable": true }, + { + "name": "notify", + "type": "bool", + "default": "false", + "description": "Email this update to the page's subscribers; a page that isn't published emails nobody", + "required": false, + "repeatable": false + }, { "name": "started-at", "type": "string", @@ -3258,10 +3274,10 @@ ], "name": "create", "short": "Post an update on an incident; public within a minute on a published page", - "long": "Adds an update to an open post. Its status becomes the post's; resolved ends\nthe post and moves it to the page's history, after which it takes no more\nupdates (post a new incident instead). On a published page the update is\npublic within a minute. --component replaces the affected components.", + "long": "Adds an update to an open post. Its status becomes the post's; resolved ends\nthe post and moves it to the page's history, after which it takes no more\nupdates (post a new incident instead). On a published page the update is\npublic within a minute. --component replaces the affected components, and\n--notify also emails the update to the page's subscribers.", "usage": "norcube monitor status-pages incidents updates create \u003cpage\u003e \u003cincident\u003e [flags]", "args": "\u003cpage\u003e \u003cincident\u003e", - "example": "norcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status monitoring --message \"A fix is rolling out.\"\nnorcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status resolved --message \"All clear.\"", + "example": "norcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status monitoring --message \"A fix is rolling out.\"\nnorcube monitor status-pages incidents updates create acme 8c7d6e5f-4a3b-4c2d-9e1f-0a1b2c3d4e5f --status resolved --message \"All clear.\" --notify", "group": false, "service": { "key": "monitor", @@ -3308,6 +3324,14 @@ "required": false, "repeatable": false }, + { + "name": "notify", + "type": "bool", + "default": "false", + "description": "Email this update to the page's subscribers; a page that isn't published emails nobody", + "required": false, + "repeatable": false + }, { "name": "status", "type": "string", @@ -3556,6 +3580,144 @@ ], "flags": [] }, + { + "command": "norcube monitor status-pages subscribers", + "path": [ + "monitor", + "status-pages", + "subscribers" + ], + "name": "subscribers", + "aliases": [ + "subscriber" + ], + "short": "See and delete the people who get a status page's email updates", + "long": "Subscribers are people who asked for email updates through the form on a\nstatus page. An address stays pending until it confirms from the mail it\ngets, and is removed if it hasn't after 7 days; only a confirmed address\ngets updates. Every mail sent counts as an email notification in your\nNorcube Monitor usage.\n\nUpdates reach subscribers when you post with --notify (\"incidents create\",\n\"incidents updates create\") and when the page's --auto-post posts for you.\n\nAddresses are personal data. Listing or deleting them takes the\nmonitor:ManageStatusPageSubscribers permission and, on a CI token, the\nmonitor.statuspages scope: no other scope reaches them, not even one that\nreads the page itself.", + "usage": "norcube monitor status-pages subscribers \u003ccommand\u003e", + "group": true, + "service": { + "key": "monitor", + "name": "Monitor", + "audience": "monitor" + }, + "confirm": false, + "wait": false, + "paginated": false, + "flags": [] + }, + { + "command": "norcube monitor status-pages subscribers delete", + "path": [ + "monitor", + "status-pages", + "subscribers", + "delete" + ], + "name": "delete", + "short": "Delete a subscriber and any mail queued for them", + "long": "Deletes the subscriber by id (\"subscribers list\" shows it) and any mail\nqueued for them. Their address isn't kept, so they can subscribe again.", + "usage": "norcube monitor status-pages subscribers delete \u003cpage\u003e \u003csubscriber\u003e [flags]", + "args": "\u003cpage\u003e \u003csubscriber\u003e", + "example": "norcube monitor status-pages subscribers delete acme 3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9\nnorcube monitor status-pages subscribers delete acme 3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 --yes", + "group": false, + "service": { + "key": "monitor", + "name": "Monitor", + "audience": "monitor" + }, + "effect": "write", + "confirm": true, + "wait": false, + "paginated": false, + "outputFormats": [ + "table", + "json", + "yaml", + "text" + ], + "flags": [ + { + "name": "yes", + "type": "bool", + "default": "false", + "description": "Don't ask for confirmation", + "required": false, + "repeatable": false + } + ] + }, + { + "command": "norcube monitor status-pages subscribers list", + "path": [ + "monitor", + "status-pages", + "subscribers", + "list" + ], + "name": "list", + "short": "List a status page's subscribers, newest first", + "long": "Lists confirmed and pending subscribers. COMPONENTS is \"all\", or how many\nof the page's components the subscriber follows; -o json has their ids.\n\nThe output holds personal data, so keep it out of build logs and other places\nmany people can read.", + "usage": "norcube monitor status-pages subscribers list \u003cpage\u003e [flags]", + "args": "\u003cpage\u003e", + "example": "norcube monitor status-pages subscribers list acme\nnorcube monitor status-pages subscribers list acme --all-pages -o json --query \"[?status=='confirmed'].email\"", + "group": false, + "service": { + "key": "monitor", + "name": "Monitor", + "audience": "monitor" + }, + "effect": "read", + "confirm": false, + "wait": false, + "paginated": true, + "outputFormats": [ + "table", + "json", + "yaml", + "text" + ], + "flags": [ + { + "name": "all-pages", + "type": "bool", + "default": "false", + "description": "Follow cursors until every page is fetched (capped by --max-items)", + "required": false, + "repeatable": false + }, + { + "name": "cursor", + "type": "string", + "description": "Continue from the cursor a previous page printed", + "required": false, + "repeatable": false + }, + { + "name": "limit", + "type": "int", + "default": "0", + "description": "Same as --page-size", + "required": false, + "repeatable": false + }, + { + "name": "max-items", + "type": "int", + "default": "0", + "description": "Cap for --all-pages (0 = 10000)", + "required": false, + "repeatable": false + }, + { + "name": "page-size", + "type": "int", + "default": "0", + "description": "Items per request (0 = 50)", + "required": false, + "repeatable": false + } + ] + }, { "command": "norcube monitor status-pages unpublish", "path": [ @@ -3605,10 +3767,10 @@ ], "name": "update", "short": "Change a status page's address, texts or settings", - "long": "Changes only what you pass. On a published page the change is public within\na minute.\n\n--slug moves the page to a new address. The old address of a published\npage redirects to the new one for 30 days, and no other organization can\ntake it meanwhile; unpublishing or deleting the page gives it up.", + "long": "Changes only what you pass. On a published page the change is public within\na minute.\n\n--slug moves the page to a new address. The old address of a published\npage redirects to the new one for 30 days, and no other organization can\ntake it meanwhile; unpublishing or deleting the page gives it up.\n\n--auto-post=false stops new automatic posts; one already open still ends by\nitself when its monitors recover.", "usage": "norcube monitor status-pages update \u003cpage\u003e [flags]", "args": "\u003cpage\u003e", - "example": "norcube monitor status-pages update acme --name \"Acme Inc. status\"\nnorcube monitor status-pages update acme --slug acme-inc\nnorcube monitor status-pages update acme --uptime-days 30 --show-response-time", + "example": "norcube monitor status-pages update acme --name \"Acme Inc. status\"\nnorcube monitor status-pages update acme --slug acme-inc\nnorcube monitor status-pages update acme --uptime-days 30 --show-response-time\nnorcube monitor status-pages update acme --auto-post", "group": false, "service": { "key": "monitor", @@ -3626,6 +3788,14 @@ "text" ], "flags": [ + { + "name": "auto-post", + "type": "bool", + "default": "false", + "description": "Post confirmed critical monitor incidents on the page by itself and email subscribers (--auto-post=false turns it off)", + "required": false, + "repeatable": false + }, { "name": "description", "type": "string", diff --git a/internal/cli/testdata/golden/monitor-status-pages-get.json b/internal/cli/testdata/golden/monitor-status-pages-get.json index 2955050..3017d44 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-get.json +++ b/internal/cli/testdata/golden/monitor-status-pages-get.json @@ -6,6 +6,7 @@ "published": true, "publishedAt": "2026-11-02T09:00:00Z", "settings": { + "autoPost": false, "historyDays": 90, "searchIndexing": true, "showResponseTime": false, diff --git a/internal/cli/testdata/golden/monitor-status-pages-get.txt b/internal/cli/testdata/golden/monitor-status-pages-get.txt index 79ee498..3dcad80 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-get.txt +++ b/internal/cli/testdata/golden/monitor-status-pages-get.txt @@ -12,5 +12,6 @@ Uptime bars: yes Uptime percent: yes Response time: no Search indexing: yes +Automatic posts: no Created: 2026-11-01 11:00 Updated: 2026-11-02 11:00 diff --git a/internal/cli/testdata/golden/monitor-status-pages-get.yaml b/internal/cli/testdata/golden/monitor-status-pages-get.yaml index cde3a6b..41f766d 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-get.yaml +++ b/internal/cli/testdata/golden/monitor-status-pages-get.yaml @@ -5,6 +5,7 @@ name: Acme status published: true publishedAt: "2026-11-02T09:00:00Z" settings: + autoPost: false historyDays: 90 searchIndexing: true showResponseTime: false diff --git a/internal/cli/testdata/golden/monitor-status-pages-incidents-get.json b/internal/cli/testdata/golden/monitor-status-pages-incidents-get.json index 8b06c36..e288ae0 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-incidents-get.json +++ b/internal/cli/testdata/golden/monitor-status-pages-incidents-get.json @@ -1,4 +1,6 @@ { + "autoManaged": false, + "autoPosted": false, "components": [ { "componentId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e", @@ -21,6 +23,7 @@ "body": "We are looking into it.", "createdAt": "2026-11-03T08:05:00Z", "id": "d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f70", + "notifySubscribers": false, "status": "investigating" } ] diff --git a/internal/cli/testdata/golden/monitor-status-pages-incidents-get.yaml b/internal/cli/testdata/golden/monitor-status-pages-incidents-get.yaml index 5b8429d..509a89d 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-incidents-get.yaml +++ b/internal/cli/testdata/golden/monitor-status-pages-incidents-get.yaml @@ -1,3 +1,5 @@ +autoManaged: false +autoPosted: false components: - componentId: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e status: partial_outage @@ -15,4 +17,5 @@ updates: - body: We are looking into it. createdAt: "2026-11-03T08:05:00Z" id: d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f70 + notifySubscribers: false status: investigating diff --git a/internal/cli/testdata/golden/monitor-status-pages-incidents-list.json b/internal/cli/testdata/golden/monitor-status-pages-incidents-list.json index 477c200..4f606ca 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-incidents-list.json +++ b/internal/cli/testdata/golden/monitor-status-pages-incidents-list.json @@ -1,5 +1,7 @@ [ { + "autoManaged": false, + "autoPosted": false, "components": [ { "componentId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e", @@ -22,6 +24,7 @@ "body": "We are looking into it.", "createdAt": "2026-11-03T08:05:00Z", "id": "d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f70", + "notifySubscribers": false, "status": "investigating" } ] diff --git a/internal/cli/testdata/golden/monitor-status-pages-incidents-list.yaml b/internal/cli/testdata/golden/monitor-status-pages-incidents-list.yaml index f20656b..742272c 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-incidents-list.yaml +++ b/internal/cli/testdata/golden/monitor-status-pages-incidents-list.yaml @@ -1,4 +1,6 @@ -- components: +- autoManaged: false + autoPosted: false + components: - componentId: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e status: partial_outage createdAt: "2026-11-03T08:05:00Z" @@ -15,4 +17,5 @@ - body: We are looking into it. createdAt: "2026-11-03T08:05:00Z" id: d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f70 + notifySubscribers: false status: investigating diff --git a/internal/cli/testdata/golden/monitor-status-pages-list.json b/internal/cli/testdata/golden/monitor-status-pages-list.json index 17de7c5..b89a583 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-list.json +++ b/internal/cli/testdata/golden/monitor-status-pages-list.json @@ -7,6 +7,7 @@ "published": true, "publishedAt": "2026-11-02T09:00:00Z", "settings": { + "autoPost": false, "historyDays": 90, "searchIndexing": true, "showResponseTime": false, @@ -26,6 +27,7 @@ "name": "Draft", "published": false, "settings": { + "autoPost": false, "historyDays": 90, "searchIndexing": true, "showResponseTime": false, diff --git a/internal/cli/testdata/golden/monitor-status-pages-list.yaml b/internal/cli/testdata/golden/monitor-status-pages-list.yaml index 2c5f23a..f0e24dd 100644 --- a/internal/cli/testdata/golden/monitor-status-pages-list.yaml +++ b/internal/cli/testdata/golden/monitor-status-pages-list.yaml @@ -5,6 +5,7 @@ published: true publishedAt: "2026-11-02T09:00:00Z" settings: + autoPost: false historyDays: 90 searchIndexing: true showResponseTime: false @@ -21,6 +22,7 @@ name: Draft published: false settings: + autoPost: false historyDays: 90 searchIndexing: true showResponseTime: false diff --git a/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.json b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.json new file mode 100644 index 0000000..886788a --- /dev/null +++ b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.json @@ -0,0 +1,22 @@ +[ + { + "componentIds": [], + "confirmedAt": "2026-11-03T09:05:00Z", + "createdAt": "2026-11-03T09:00:00Z", + "email": "jan@example.com", + "id": "3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9", + "locale": "cs", + "status": "confirmed" + }, + { + "componentIds": [ + "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e", + "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6f" + ], + "createdAt": "2026-11-04T09:00:00Z", + "email": "eva@example.com", + "id": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a81", + "locale": "en", + "status": "pending" + } +] diff --git a/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.tsv b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.tsv new file mode 100644 index 0000000..2049d2a --- /dev/null +++ b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.tsv @@ -0,0 +1,2 @@ +3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 jan@example.com confirmed cs all 2026-11-03T09:00:00Z 2026-11-03T09:05:00Z +e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a81 eva@example.com pending en 2 2026-11-04T09:00:00Z diff --git a/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.txt b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.txt new file mode 100644 index 0000000..51d5c20 --- /dev/null +++ b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.txt @@ -0,0 +1,3 @@ +ID EMAIL STATUS LOCALE COMPONENTS CREATED CONFIRMED +3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 jan@example.com confirmed cs all 2026-11-03 11:00 2026-11-03 11:05 +e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a81 eva@example.com pending en 2 2026-11-04 11:00 — diff --git a/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.yaml b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.yaml new file mode 100644 index 0000000..6ddcef1 --- /dev/null +++ b/internal/cli/testdata/golden/monitor-status-pages-subscribers-list.yaml @@ -0,0 +1,15 @@ +- componentIds: [] + confirmedAt: "2026-11-03T09:05:00Z" + createdAt: "2026-11-03T09:00:00Z" + email: jan@example.com + id: 3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9 + locale: cs + status: confirmed +- componentIds: + - a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5e + - b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6f + createdAt: "2026-11-04T09:00:00Z" + email: eva@example.com + id: e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a81 + locale: en + status: pending diff --git a/specs/monitor.openapi.json b/specs/monitor.openapi.json index 8f27000..3ee32c1 100644 --- a/specs/monitor.openapi.json +++ b/specs/monitor.openapi.json @@ -2460,6 +2460,13 @@ }, "type": "array" }, + "fixedTitle": { + "description": "FixedTitle is the code of a fixed wording the renderer translates; Title holds\nits English. Absent on anything a person wrote.", + "enum": [ + "auto_title" + ], + "type": "string" + }, "id": { "format": "uuid", "type": "string" @@ -2641,6 +2648,15 @@ "createdAt": { "type": "string" }, + "fixedText": { + "description": "FixedText is the code of a fixed wording the renderer translates; Body holds\nits English. Absent on anything a person wrote.", + "enum": [ + "auto_opened", + "auto_resolved", + "auto_superseded" + ], + "type": "string" + }, "id": { "format": "uuid", "type": "string" @@ -3172,6 +3188,14 @@ }, "dto.StatusPageIncident": { "properties": { + "autoManaged": { + "description": "AutoManaged: the system still runs it and resolves it by itself. A person's\nupdate or edit ends that for good.", + "type": "boolean" + }, + "autoPosted": { + "description": "AutoPosted: the system wrote this post, in fixed wording.", + "type": "boolean" + }, "components": { "items": { "$ref": "#/components/schemas/dto.StatusPageAffected" @@ -3233,6 +3257,8 @@ } }, "required": [ + "autoManaged", + "autoPosted", "components", "createdAt", "id", @@ -3279,6 +3305,10 @@ }, "type": "array" }, + "notify": { + "description": "Notify mails this update to the page's subscribers. A draft page tells nobody.", + "type": "boolean" + }, "startedAt": { "description": "StartedAt defaults to now.", "type": "string" @@ -3319,6 +3349,10 @@ "format": "uuid", "type": "string" }, + "notifySubscribers": { + "description": "NotifySubscribers: whoever posted this update asked to mail it to the page's\nsubscribers. A draft page tells nobody, whatever this says.", + "type": "boolean" + }, "status": { "enum": [ "investigating", @@ -3333,6 +3367,7 @@ "body", "createdAt", "id", + "notifySubscribers", "status" ], "type": "object" @@ -3351,6 +3386,10 @@ }, "type": "array" }, + "notify": { + "description": "Notify mails this update to the page's subscribers. A draft page tells nobody.", + "type": "boolean" + }, "status": { "enum": [ "investigating", @@ -3468,6 +3507,10 @@ }, "dto.StatusPageSettings": { "properties": { + "autoPost": { + "description": "AutoPost posts a confirmed critical monitor incident on the page by itself, in\nfixed wording, and resolves it when the incident ends. Off unless asked for.", + "type": "boolean" + }, "historyDays": { "description": "HistoryDays is how far back resolved incidents stay on the page.", "example": 90, @@ -3517,6 +3560,9 @@ }, "dto.StatusPageSettingsUpdate": { "properties": { + "autoPost": { + "type": "boolean" + }, "historyDays": { "maximum": 365, "minimum": 7, @@ -3549,6 +3595,80 @@ }, "type": "object" }, + "dto.StatusPageSubscriber": { + "properties": { + "componentIds": { + "description": "ComponentIDs are the components it wants to hear about. Empty: all of them.", + "items": { + "type": "string" + }, + "type": "array" + }, + "confirmedAt": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "email": { + "example": "jan@example.com", + "type": "string" + }, + "id": { + "format": "uuid", + "type": "string" + }, + "locale": { + "description": "Locale is the language its mail comes in.", + "enum": [ + "en", + "de", + "fr", + "it", + "es", + "pl", + "cs", + "zh-CN" + ], + "example": "en", + "type": "string" + }, + "status": { + "description": "Status: pending until the address confirms. A pending one is removed after 7 days.", + "enum": [ + "pending", + "confirmed" + ], + "type": "string" + } + }, + "required": [ + "componentIds", + "createdAt", + "email", + "id", + "locale", + "status" + ], + "type": "object" + }, + "dto.StatusPageSubscriberCount": { + "properties": { + "confirmed": { + "example": 120, + "type": "integer" + }, + "pending": { + "example": 3, + "type": "integer" + } + }, + "required": [ + "confirmed", + "pending" + ], + "type": "object" + }, "dto.StatusPageUpdate": { "properties": { "description": { @@ -7258,7 +7378,7 @@ ] }, "post": { - "description": "Posts an incident with its first update. Public as soon as it is posted (within a minute) when the page is published. While it is open, the components it names show the status it gives them.", + "description": "Posts an incident with its first update. Public as soon as it is posted (within a minute) when the page is published. While it is open, the components it names show the status it gives them. With notify, the update is mailed to the page's subscribers; a draft page tells nobody.", "operationId": "createStatusPageIncident", "parameters": [ { @@ -8231,6 +8351,312 @@ ] } }, + "/status-pages/{id}/subscribers": { + "get": { + "description": "The page's email subscribers, newest first, confirmed and pending. Addresses are personal data, so this needs its own permission and the monitor.statuspages scope.", + "operationId": "listStatusPageSubscribers", + "parameters": [ + { + "description": "Status page ID", + "in": "path", + "name": "id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "in": "query", + "name": "cursor", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "limit", + "schema": { + "maximum": 100, + "minimum": 1, + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/response.APIResponseWithPagination" + }, + { + "properties": { + "list": { + "items": { + "$ref": "#/components/schemas/dto.StatusPageSubscriber" + }, + "type": "array" + } + }, + "type": "object" + } + ] + } + } + }, + "description": "OK" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Missing, invalid or expired token (UNAUTHORIZED)" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "No permission for this (FORBIDDEN), or the token's scopes don't allow this (reason INSUFFICIENT_SCOPE)" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Not Found" + } + }, + "summary": "List a status page's subscribers", + "tags": [ + "Status pages" + ], + "x-norcube-scopes": [ + "monitor.statuspages" + ] + } + }, + "/status-pages/{id}/subscribers/count": { + "get": { + "description": "How many subscribers the page has. Holds no addresses, so any Monitor scope may read it.", + "operationId": "countStatusPageSubscribers", + "parameters": [ + { + "description": "Status page ID", + "in": "path", + "name": "id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/dto.StatusPageSubscriberCount" + } + } + }, + "description": "OK" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Missing, invalid or expired token (UNAUTHORIZED)" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "No permission for this (FORBIDDEN), or the token's scopes don't allow this (reason INSUFFICIENT_SCOPE)" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Not Found" + } + }, + "summary": "Count a status page's subscribers", + "tags": [ + "Status pages" + ], + "x-norcube-scopes": [ + "monitor.read", + "monitor.check", + "monitor.write", + "monitor.channels", + "monitor.statuspages" + ] + } + }, + "/status-pages/{id}/subscribers/export": { + "get": { + "description": "All the page's subscribers as CSV: email, status, locale, components, createdAt, confirmedAt. Recorded in the audit log.", + "operationId": "exportStatusPageSubscribers", + "parameters": [ + { + "description": "Status page ID", + "in": "path", + "name": "id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/csv": { + "schema": { + "type": "string" + } + } + }, + "description": "CSV" + }, + "401": { + "content": { + "text/csv": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Missing, invalid or expired token (UNAUTHORIZED)" + }, + "403": { + "content": { + "text/csv": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "No permission for this (FORBIDDEN), or the token's scopes don't allow this (reason INSUFFICIENT_SCOPE)" + }, + "404": { + "content": { + "text/csv": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Not Found" + } + }, + "summary": "Export a status page's subscribers", + "tags": [ + "Status pages" + ], + "x-norcube-scopes": [ + "monitor.statuspages" + ] + } + }, + "/status-pages/{id}/subscribers/{subscriberId}": { + "delete": { + "description": "Deletes the subscriber and any mail queued for it. Their address isn't kept, so they can subscribe again.", + "operationId": "deleteStatusPageSubscriber", + "parameters": [ + { + "description": "Status page ID", + "in": "path", + "name": "id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + }, + { + "description": "Subscriber ID", + "in": "path", + "name": "subscriberId", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Missing, invalid or expired token (UNAUTHORIZED)" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "No permission for this (FORBIDDEN), or the token's scopes don't allow this (reason INSUFFICIENT_SCOPE)" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/response.Problem" + } + } + }, + "description": "Not Found" + } + }, + "summary": "Remove a status page's subscriber", + "tags": [ + "Status pages" + ], + "x-norcube-scopes": [ + "monitor.statuspages" + ] + } + }, "/status-pages/{id}/unpublish": { "post": { "description": "Takes the page offline; its address answers 404 within a minute. Everything on it stays, and publishing brings it back.",