Skip to content

Commit 8525485

Browse files
feat: add status page list and info commands (#19)
Add a new `status-page` (alias `sp`) command group with two subcommands: - `list`: displays all status pages with ID, title, and URL - `info <page-id>`: shows page details and attached components grouped by component group, using the GetStatusPageContent RPC URL resolves to custom domain when available, otherwise slug.openstatus.dev.
1 parent 63eefef commit 8525485

9 files changed

Lines changed: 859 additions & 23 deletions

File tree

docs/openstatus-docs.md

Lines changed: 118 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22

33
## CLI interface - openstatus
44

5-
OpenStatus is a command line interface for managing your monitors and triggering your synthetics tests. Please report any issues at https://github.com/openstatusHQ/cli/issues/new.
5+
OpenStatus CLI lets you manage your status pages and uptime monitors from the command line. Report and track incidents, define monitors as code, and run on-demand checks. Get started: openstatus login Save your API token openstatus status-report create Report an incident openstatus status-report list View active incidents openstatus monitors apply Sync monitors from config openstatus monitors list List your monitors openstatus run Run synthetic tests https://docs.openstatus.dev | https://github.com/openstatusHQ/cli/issues/new.
66

7-
This is OpenStatus Command Line Interface, the OpenStatus.dev CLI.
7+
Manage status pages, monitors, and incidents from the terminal.
88

99
Usage:
1010

1111
```bash
12-
$ openstatus [COMMAND] [COMMAND FLAGS] [ARGUMENTS...]
12+
$ openstatus [GLOBAL FLAGS] [COMMAND] [COMMAND FLAGS] [ARGUMENTS...]
1313
```
1414

15-
### `monitors` command
15+
Global flags:
16+
17+
| Name | Description | Default value | Environment variables |
18+
|------------------|---------------------------|:-------------:|:---------------------:|
19+
| `--json` | Output results as JSON | `false` | *none* |
20+
| `--no-color` | Disable colored output | `false` | *none* |
21+
| `--quiet` (`-q`) | Suppress non-error output | `false` | *none* |
22+
| `--debug` | Enable debug output | `false` | *none* |
23+
24+
### `monitors` command (aliases: `m`)
1625

1726
Manage your monitors.
1827

@@ -26,9 +35,11 @@ $ openstatus [GLOBAL FLAGS] monitors [ARGUMENTS...]
2635

2736
Create or update monitors.
2837

29-
> openstatus monitors apply [options]
38+
> openstatus monitors apply
39+
> openstatus monitors apply --config custom.yaml -y
40+
> openstatus monitors apply --dry-run
3041
31-
Creates or updates monitors according to the OpenStatus configuration file.
42+
Creates or updates monitors according to the OpenStatus configuration file. Compares your openstatus.yaml with the current state and applies changes.
3243

3344
Usage:
3445

@@ -43,12 +54,14 @@ The following flags are supported:
4354
| `--config="…"` (`-c`) | The configuration file containing monitor information | `openstatus.yaml` | *none* |
4455
| `--access-token="…"` (`-t`) | OpenStatus API Access Token | | `OPENSTATUS_API_TOKEN` |
4556
| `--auto-accept` (`-y`) | Automatically accept the prompt | `false` | *none* |
57+
| `--dry-run` (`-n`) | Show what would be changed without applying | `false` | *none* |
4658

4759
### `monitors create` subcommand
4860

49-
Create monitors (beta).
61+
Create monitors.
5062

51-
> openstatus monitors create [options]
63+
> openstatus monitors create
64+
> openstatus monitors create --config custom.yaml -y
5265
5366
Create the monitors defined in the openstatus.yaml file.
5467

@@ -70,7 +83,8 @@ The following flags are supported:
7083

7184
Delete a monitor.
7285

73-
> openstatus monitors delete [MonitorID] [options]
86+
> openstatus monitors delete <MonitorID>
87+
> openstatus monitors delete 12345 -y
7488
7589
Usage:
7690

@@ -89,7 +103,8 @@ The following flags are supported:
89103

90104
Import all your monitors.
91105

92-
> openstatus monitors import [options]
106+
> openstatus monitors import
107+
> openstatus monitors import --output monitors.yaml
93108
94109
Import all your monitors from your workspace to a YAML file; it will also create a lock file to manage your monitors with 'apply'.
95110

@@ -110,9 +125,10 @@ The following flags are supported:
110125

111126
Get a monitor information.
112127

113-
> openstatus monitors info [MonitorID]
128+
> openstatus monitors info <MonitorID>
129+
> openstatus monitors info 12345
114130
115-
Fetch the monitor information. The monitor information includes details such as name, description, endpoint, method, frequency, locations, active status, public status, timeout, degraded after, and body. The body is truncated to 40 characters.
131+
Fetch the monitor information. The monitor information includes details such as name, description, endpoint, method, frequency, locations, active status, public status, timeout, degraded after, and body.
116132

117133
Usage:
118134

@@ -130,9 +146,10 @@ The following flags are supported:
130146

131147
List all monitors.
132148

133-
> openstatus monitors list [options]
149+
> openstatus monitors list
150+
> openstatus monitors list --all
134151
135-
List all monitors. The list shows all your monitors attached to your workspace. It displays the ID, name, and URL of each monitor.
152+
List all monitors. The list shows all your monitors attached to your workspace. It displays the ID, name, URL, and kind of each monitor.
136153

137154
Usage:
138155

@@ -151,7 +168,8 @@ The following flags are supported:
151168

152169
Trigger a monitor execution.
153170

154-
> openstatus monitors trigger [MonitorId] [options]
171+
> openstatus monitors trigger <MonitorID>
172+
> openstatus monitors trigger 12345
155173
156174
Trigger a monitor execution on demand. This command allows you to launch your tests on demand.
157175

@@ -181,7 +199,8 @@ $ openstatus [GLOBAL FLAGS] status-report [ARGUMENTS...]
181199

182200
List all status reports.
183201

184-
> openstatus status-report list [options]
202+
> openstatus status-report list
203+
> openstatus status-report list --status investigating --limit 10
185204
186205
Usage:
187206

@@ -202,6 +221,7 @@ The following flags are supported:
202221
Get status report details.
203222

204223
> openstatus status-report info <ReportID>
224+
> openstatus status-report info 12345
205225
206226
Usage:
207227

@@ -265,6 +285,7 @@ The following flags are supported:
265285
Delete a status report.
266286

267287
> openstatus status-report delete <ReportID>
288+
> openstatus status-report delete 12345 -y
268289
269290
Usage:
270291

@@ -301,13 +322,63 @@ The following flags are supported:
301322
| `--date="…"` | Date for the update (RFC 3339 format, defaults to now) | | *none* |
302323
| `--notify` | Notify subscribers about this update | `false` | *none* |
303324

325+
### `status-page` command (aliases: `sp`)
326+
327+
Manage status pages.
328+
329+
Usage:
330+
331+
```bash
332+
$ openstatus [GLOBAL FLAGS] status-page [ARGUMENTS...]
333+
```
334+
335+
### `status-page list` subcommand
336+
337+
List all status pages.
338+
339+
> openstatus status-page list
340+
> openstatus status-page list --limit 10
341+
342+
Usage:
343+
344+
```bash
345+
$ openstatus [GLOBAL FLAGS] status-page list [COMMAND FLAGS] [ARGUMENTS...]
346+
```
347+
348+
The following flags are supported:
349+
350+
| Name | Description | Default value | Environment variables |
351+
|-----------------------------|-------------------------------------------|:-------------:|:----------------------:|
352+
| `--access-token="…"` (`-t`) | OpenStatus API Access Token | | `OPENSTATUS_API_TOKEN` |
353+
| `--limit="…"` | Maximum number of pages to return (1-100) | `0` | *none* |
354+
355+
### `status-page info` subcommand
356+
357+
Get status page details.
358+
359+
> openstatus status-page info <PageID>
360+
> openstatus status-page info 12345
361+
362+
Usage:
363+
364+
```bash
365+
$ openstatus [GLOBAL FLAGS] status-page info [COMMAND FLAGS] [ARGUMENTS...]
366+
```
367+
368+
The following flags are supported:
369+
370+
| Name | Description | Default value | Environment variables |
371+
|-----------------------------|-----------------------------|:-------------:|:----------------------:|
372+
| `--access-token="…"` (`-t`) | OpenStatus API Access Token | | `OPENSTATUS_API_TOKEN` |
373+
304374
### `run` command (aliases: `r`)
305375

306-
Run your synthetics tests.
376+
Run your uptime tests.
307377

308-
> openstatus run [options]
378+
> openstatus run
379+
> openstatus run --config custom-config.yaml
309380
310-
Run the synthetic tests defined in the config.openstatus.yaml. The config file should be in the following format: tests: ids: - monitor-id-1 - monitor-id-2.
381+
Run the uptime tests defined in the config.openstatus.yaml. The config file should be in the following format: tests: ids: - monitor-id-1 - monitor-id-2.
311382

312383
Usage:
313384

@@ -326,9 +397,9 @@ The following flags are supported:
326397

327398
Get your workspace information.
328399

329-
> openstatus whoami [options]
400+
> openstatus whoami
330401
331-
Get your current workspace information, display the workspace name, slug, and plan.
402+
Get your current workspace information. Displays the workspace name, slug, and plan.
332403

333404
Usage:
334405

@@ -341,3 +412,29 @@ The following flags are supported:
341412
| Name | Description | Default value | Environment variables |
342413
|-----------------------------|-----------------------------|:-------------:|:----------------------:|
343414
| `--access-token="…"` (`-t`) | OpenStatus API Access Token | | `OPENSTATUS_API_TOKEN` |
415+
416+
### `login` command
417+
418+
Save your API token.
419+
420+
> openstatus login
421+
422+
Saves your OpenStatus API token for use in subsequent commands. Get your API token from the OpenStatus dashboard.
423+
424+
Usage:
425+
426+
```bash
427+
$ openstatus [GLOBAL FLAGS] login [ARGUMENTS...]
428+
```
429+
430+
### `logout` command
431+
432+
Remove saved API token.
433+
434+
> openstatus logout
435+
436+
Usage:
437+
438+
```bash
439+
$ openstatus [GLOBAL FLAGS] logout [ARGUMENTS...]
440+
```

internal/cmd/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/openstatusHQ/cli/internal/login"
1111
"github.com/openstatusHQ/cli/internal/monitors"
1212
"github.com/openstatusHQ/cli/internal/run"
13+
"github.com/openstatusHQ/cli/internal/statuspage"
1314
"github.com/openstatusHQ/cli/internal/statusreport"
1415
"github.com/openstatusHQ/cli/internal/whoami"
1516
"github.com/urfave/cli/v3"
@@ -64,6 +65,7 @@ https://docs.openstatus.dev | https://github.com/openstatusHQ/cli/issues/new`,
6465
Commands: []*cli.Command{
6566
monitors.MonitorsCmd(),
6667
statusreport.StatusReportCmd(),
68+
statuspage.StatusPageCmd(),
6769
run.RunCmd(),
6870
whoami.WhoamiCmd(),
6971
login.LoginCmd(),

internal/cmd/app_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ func Test_NewApp(t *testing.T) {
3232
t.Run("Has expected commands", func(t *testing.T) {
3333
app := cmd.NewApp()
3434

35-
if len(app.Commands) != 6 {
36-
t.Errorf("Expected 6 commands, got %d", len(app.Commands))
35+
if len(app.Commands) != 7 {
36+
t.Errorf("Expected 7 commands, got %d", len(app.Commands))
3737
}
3838

3939
expectedCommands := map[string]bool{
4040
"monitors": false,
4141
"status-report": false,
42+
"status-page": false,
4243
"run": false,
4344
"whoami": false,
4445
"login": false,

internal/statuspage/statuspage.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package statuspage
2+
3+
import (
4+
"net/http"
5+
6+
status_pagev1 "buf.build/gen/go/openstatus/api/protocolbuffers/go/openstatus/status_page/v1"
7+
"buf.build/gen/go/openstatus/api/connectrpc/gosimple/openstatus/status_page/v1/status_pagev1connect"
8+
"connectrpc.com/connect"
9+
"github.com/openstatusHQ/cli/internal/api"
10+
"github.com/urfave/cli/v3"
11+
)
12+
13+
func NewStatusPageClient(apiKey string) status_pagev1connect.StatusPageServiceClient {
14+
return status_pagev1connect.NewStatusPageServiceClient(
15+
api.DefaultHTTPClient,
16+
api.ConnectBaseURL,
17+
connect.WithInterceptors(api.NewAuthInterceptor(apiKey)),
18+
connect.WithProtoJSON(),
19+
)
20+
}
21+
22+
func NewStatusPageClientWithHTTPClient(httpClient *http.Client, apiKey string) status_pagev1connect.StatusPageServiceClient {
23+
return status_pagev1connect.NewStatusPageServiceClient(
24+
httpClient,
25+
api.ConnectBaseURL,
26+
connect.WithInterceptors(api.NewAuthInterceptor(apiKey)),
27+
connect.WithProtoJSON(),
28+
)
29+
}
30+
31+
func accessTypeToString(a status_pagev1.PageAccessType) string {
32+
switch a {
33+
case status_pagev1.PageAccessType_PAGE_ACCESS_TYPE_PUBLIC:
34+
return "public"
35+
case status_pagev1.PageAccessType_PAGE_ACCESS_TYPE_PASSWORD_PROTECTED:
36+
return "password-protected"
37+
case status_pagev1.PageAccessType_PAGE_ACCESS_TYPE_AUTHENTICATED:
38+
return "authenticated"
39+
default:
40+
return "unknown"
41+
}
42+
}
43+
44+
func themeToString(t status_pagev1.PageTheme) string {
45+
switch t {
46+
case status_pagev1.PageTheme_PAGE_THEME_SYSTEM:
47+
return "system"
48+
case status_pagev1.PageTheme_PAGE_THEME_LIGHT:
49+
return "light"
50+
case status_pagev1.PageTheme_PAGE_THEME_DARK:
51+
return "dark"
52+
default:
53+
return "unknown"
54+
}
55+
}
56+
57+
func componentTypeToString(t status_pagev1.PageComponentType) string {
58+
switch t {
59+
case status_pagev1.PageComponentType_PAGE_COMPONENT_TYPE_MONITOR:
60+
return "monitor"
61+
case status_pagev1.PageComponentType_PAGE_COMPONENT_TYPE_STATIC:
62+
return "static"
63+
default:
64+
return "unknown"
65+
}
66+
}
67+
68+
func StatusPageCmd() *cli.Command {
69+
return &cli.Command{
70+
Name: "status-page",
71+
Aliases: []string{"sp"},
72+
Usage: "Manage status pages",
73+
Commands: []*cli.Command{
74+
GetStatusPageListCmd(),
75+
GetStatusPageInfoCmd(),
76+
},
77+
}
78+
}

0 commit comments

Comments
 (0)