@oneuptime/cli 14.0.101 → 14.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +88 -46
  2. package/build/dist/Index.js +20887 -10872
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # @oneuptime/cli
2
2
 
3
- Command-line interface for managing OneUptime resources. Supports every MCP-enabled resource (records with full CRUD operations, telemetry with list, create and count), named contexts for multiple environments, and flexible output formats.
3
+ Command-line interface for OneUptime. Every resource of the OneUptime REST API is a command, with a subcommand for every request the API takes for it: list, get, create, update, delete and count, the fields a resource has, and the dashboard's buttons such as acknowledge and resolve. People at a terminal get tables, and scripts and AI agents get JSON with `--json`.
4
4
 
5
5
  ## Installation
6
6
 
7
+ Every OneUptime serves an installer for the CLI at `/install/cli`. It asks your OneUptime for its version, and installs the CLI of the same version with npm:
8
+
9
+ ```bash
10
+ curl -fsSL https://oneuptime.com/install/cli -o install.sh
11
+ ONEUPTIME_URL=https://oneuptime.com bash install.sh
12
+ ```
13
+
14
+ On a self-hosted OneUptime, download it from your OneUptime's address, and give that address as `ONEUPTIME_URL`. Or install the CLI with npm yourself:
15
+
7
16
  ```bash
8
17
  npm install -g @oneuptime/cli
9
18
  oneuptime --version
@@ -26,14 +35,23 @@ npm install -g @oneuptime/cli@<your-oneuptime-version>
26
35
  oneuptime login <api-key> <instance-url>
27
36
  oneuptime login sk-your-api-key https://oneuptime.com
28
37
 
38
+ # Check that OneUptime takes the key, and see its project
39
+ oneuptime whoami --check
40
+
29
41
  # List incidents
30
42
  oneuptime incident list --limit 10
31
43
 
32
44
  # Get a single resource by ID
33
45
  oneuptime monitor get 550e8400-e29b-41d4-a716-446655440000
34
46
 
35
- # Create a resource
36
- oneuptime monitor create --data '{"name":"API Health","projectId":"..."}'
47
+ # Create a resource, a flag per field
48
+ oneuptime monitor create --name "API Health" --monitor-type Manual
49
+
50
+ # The fields a resource has, and the flags that set them
51
+ oneuptime monitor fields
52
+
53
+ # Acknowledge an incident, as the dashboard's button does
54
+ oneuptime incident acknowledge 550e8400-e29b-41d4-a716-446655440000
37
55
 
38
56
  # See all available resources
39
57
  oneuptime resources
@@ -75,31 +93,39 @@ oneuptime context delete old-context
75
93
  2. Environment variables: `ONEUPTIME_API_KEY` and `ONEUPTIME_URL`
76
94
  3. Current context from config file (`~/.oneuptime/config.json`)
77
95
 
96
+ `oneuptime whoami` shows what the next command will use without asking OneUptime. `oneuptime whoami --check` asks OneUptime: it shows the key's project, OneUptime's version and the CLI's, says what to install when the two differ, and exits with `2` when OneUptime refuses the key.
97
+
78
98
  ## Command Reference
79
99
 
80
100
  ### Authentication
81
101
 
82
- | Command | Description |
83
- | --------------------------------- | --------------------------------- |
84
- | `oneuptime login <api-key> <url>` | Authenticate and create a context |
85
- | `oneuptime context list` | List all contexts |
86
- | `oneuptime context use <name>` | Switch active context |
87
- | `oneuptime context current` | Show current context |
88
- | `oneuptime context delete <name>` | Remove a context |
89
- | `oneuptime whoami` | Show current auth info |
102
+ | Command | Description |
103
+ | --------------------------------- | -------------------------------------------------------- |
104
+ | `oneuptime login <api-key> <url>` | Authenticate and create a context |
105
+ | `oneuptime context list` | List all contexts |
106
+ | `oneuptime context use <name>` | Switch active context |
107
+ | `oneuptime context current` | Show current context |
108
+ | `oneuptime context delete <name>` | Remove a context |
109
+ | `oneuptime whoami` | Show current auth info; `--check` asks OneUptime as well |
90
110
 
91
111
  ### Resource Operations
92
112
 
93
- Every resource supports `list`, `create` and `count`. Records (monitors, incidents, teams and the like) also support `get`, `update` and `delete`; telemetry (logs, metrics, spans and the like) does not:
94
-
95
- | Subcommand | Description |
96
- | -------------------------------------- | -------------------------------------------- |
97
- | `<resource> list [options]` | List resources with filtering and pagination |
98
- | `<resource> get <id>` | Get a single resource by ID |
99
- | `<resource> create --data <json>` | Create a new resource |
100
- | `<resource> update <id> --data <json>` | Update an existing resource |
101
- | `<resource> delete <id>` | Delete a resource |
102
- | `<resource> count [--query <json>]` | Count resources |
113
+ A resource takes the subcommands the API takes for it: `list`, `get` and `count` to read it, and `create`, `update` and `delete` to change it. Most resources take all six. The ones OneUptime writes itself, such as an email log, are read only. `oneuptime <resource> --help` lists the subcommands a resource has:
114
+
115
+ | Subcommand | Description |
116
+ | -------------------------------------------- | ------------------------------------------------------------ |
117
+ | `<resource> list [options]` | List resources with filtering and pagination |
118
+ | `<resource> get <id>` | Get a single resource by ID |
119
+ | `<resource> create [--<field> <value>]` | Create a new resource, a flag per field |
120
+ | `<resource> update <id> [--<field> <value>]` | Update an existing resource |
121
+ | `<resource> delete <id>` | Delete a resource |
122
+ | `<resource> count [--query <json>]` | Count resources |
123
+ | `<resource> fields` | List its fields: what each is for, and the flag that sets it |
124
+ | `<resource> acknowledge <id>` | Acknowledge an incident, an alert, or an episode of either |
125
+ | `<resource> resolve <id>` | Resolve one |
126
+ | `<resource> start <id>` | Start a scheduled maintenance event |
127
+ | `<resource> end <id>` | End one |
128
+ | `<resource> add-note <id> --note <markdown>` | Add a note to any of those, `--public` for its status pages |
103
129
 
104
130
  ### List Options
105
131
 
@@ -107,8 +133,22 @@ Every resource supports `list`, `create` and `count`. Records (monitors, inciden
107
133
  --query <json> Filter criteria as JSON
108
134
  --limit <n> Maximum number of results (default: 10)
109
135
  --skip <n> Number of results to skip (default: 0)
110
- --sort <json> Sort order as JSON (e.g. '{"createdAt": -1}')
136
+ --sort <json> Sort order as JSON (e.g. '{"createdAt": "DESC"}')
137
+ --fields <names> The fields to return, separated by commas
138
+ --all Every record that matches, page after page (records only)
111
139
  -o, --output Output format: json, table, wide
140
+ --json The same as -o json
141
+ ```
142
+
143
+ ### Create and Update
144
+
145
+ `create` and `update` take a flag for each field the API takes: `--title <text>`, `--incident-severity-id <id>`, `--labels <ids>` (IDs separated by commas), `--is-visible-on-status-page [true|false]` (true when given alone), `--monitor-steps <json>`. `oneuptime <resource> create --help` lists them, and `oneuptime <resource> fields` says what each field is for. `--data <json>` and `--file <path>` give the fields as JSON instead, and flags go on top of them.
146
+
147
+ Where a field names a person by user ID, a second flag names them by email address: `--user-email` beside `--user-id`, `--owner-user-emails` beside `--owner-users`. The CLI finds the person among the members and invitees of the API key's project. A team member named by an address nobody in the project has is invited, as the dashboard's Invite does:
148
+
149
+ ```bash
150
+ oneuptime incident-user-owner create --incident-id <incident-id> --user-email alice@example.com
151
+ oneuptime team-member create --team-id <team-id> --user-email new-hire@example.com
112
152
  ```
113
153
 
114
154
  ### Utility Commands
@@ -136,7 +176,7 @@ oneuptime deploy --service checkout --service-version 2.3.1 --commit "$GIT_SHA"
136
176
  | `json` | Raw JSON (default when piped) |
137
177
  | `wide` | Table with all columns shown |
138
178
 
139
- `-o` applies to `<resource> list`, `get`, `create`, `update` and `count`, as well as `oneuptime resources` and `oneuptime context list`, and can go anywhere on the command line. Any other value is rejected with an error.
179
+ Every command takes `-o` and `--json`, anywhere on the command line. `--json` is the same as `-o json`. Any other value of `-o` is rejected with an error. A command whose answer is a sentence, such as `delete` or `acknowledge`, prints the sentence unless JSON is asked for, and with JSON asked for, an error is one JSON object on standard error.
140
180
 
141
181
  ```bash
142
182
  # Explicit format
@@ -152,7 +192,7 @@ oneuptime incident list | jq '.[].title'
152
192
 
153
193
  ```bash
154
194
  # List incidents as JSON for scripting
155
- oneuptime incident list -o json --limit 100
195
+ oneuptime incident list --json --limit 100
156
196
 
157
197
  # Count resources with filter
158
198
  oneuptime incident count --query '{"currentIncidentStateId":"..."}'
@@ -164,6 +204,12 @@ oneuptime monitor create --file monitor.json
164
204
  ONEUPTIME_API_KEY=sk-xxx ONEUPTIME_URL=https://oneuptime.com oneuptime incident list
165
205
  ```
166
206
 
207
+ Every command exits with `0` when it worked, `1` when OneUptime refused it or a value is wrong, `2` when the API key is missing or refused, and `3` when the record is not there.
208
+
209
+ ## AI Agents
210
+
211
+ An agent that runs commands can work with OneUptime through the CLI instead of the MCP server. Give it the key in `ONEUPTIME_API_KEY`, and have it add `--json` to every command. `oneuptime resources --json` lists what it can work with, `oneuptime <resource> fields --json` a resource's fields and flags, and `oneuptime <resource> --help` its subcommands.
212
+
167
213
  ## Environment Variables
168
214
 
169
215
  | Variable | Description |
@@ -200,35 +246,29 @@ Output format and list size are not read from this file. Pass `-o` and `--limit`
200
246
  | `--url <url>` | Override instance URL for this command |
201
247
  | `--context <name>` | Use a specific context for this command |
202
248
  | `-o, --output <format>` | Output format: json, table, wide |
249
+ | `--json` | The same as `-o json` |
203
250
  | `--no-color` | Disable colored output |
204
251
 
205
252
  ## Supported Resources
206
253
 
207
- Every resource is a command: `oneuptime <resource> <subcommand>`. Resources are discovered from the OneUptime models that have MCP enabled, and `oneuptime resources` lists the ones your version has (`--type database` for records, `--type analytics` for telemetry).
208
-
209
- Records take `list`, `get`, `create`, `update`, `delete` and `count`:
254
+ Every resource of the OneUptime REST API is a command: `oneuptime <resource> <subcommand>`, 450 and more of them. They are worked out from OneUptime's models by the rule the API documents itself by, so a resource OneUptime gains is a command of the CLI of the same version. `oneuptime resources` lists the ones your version has (`--type database` for records, `--type analytics` for telemetry).
210
255
 
211
- | Area | Commands |
212
- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
213
- | Monitoring | `monitor`, `monitor-status`, `monitor-status-event` |
214
- | Incidents | `incident`, `incident-state`, `incident-severity`, `incident-state-timeline`, `incident-public-note`, `incident-internal-note`, `incident-alert`, `postmortem-status` |
215
- | Alerts | `alert`, `alert-state`, `alert-severity`, `alert-state-timeline`, `alert-internal-note` |
216
- | Status pages | `status-page`, `status-page-announcement` |
217
- | Scheduled maintenance | `scheduled-maintenance-event`, `scheduled-maintenance-state`, `scheduled-maintenance-state-timeline` |
218
- | Teams and on-call | `team`, `on-call-policy` |
219
- | Security | `security-case`, `security-case-evidence`, `security-case-note`, `security-case-priority`, `security-case-status`, `security-case-task`, `security-detection`, `security-playbook` |
220
- | Data security | `data-store`, `data-store-finding`, `data-store-access-entry`, `data-security-identity`, `data-flow`, `data-security-issue`, `data-security-scan`, `custom-data-type`, `check-setting`, `residency-rule`, `data-security-setting` |
221
- | Labels | `label` |
256
+ Some of them, by area:
222
257
 
223
- Telemetry takes `list`, `create` and `count`:
258
+ | Area | Commands |
259
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
260
+ | Monitoring | `monitor`, `monitor-status`, `monitor-group`, `probe` |
261
+ | Incidents | `incident`, `incident-severity`, `incident-state`, `incident-internal-note`, `incident-public-note`, `incident-episode` |
262
+ | Alerts | `alert`, `alert-severity`, `alert-state`, `alert-internal-note`, `alert-episode` |
263
+ | Status pages | `status-page`, `status-page-announcement`, `status-page-subscriber` |
264
+ | Scheduled maintenance | `scheduled-maintenance-event`, `scheduled-maintenance-state` |
265
+ | On-call | `on-call-policy`, `on-call-policy-schedule`, `escalation-rule` |
266
+ | Teams and access | `team`, `team-member`, `label`, `api-key` |
267
+ | Infrastructure | `host`, `kubernetes-cluster`, `network-device`, `service` |
268
+ | Automation | `workflow`, `runbook`, `dashboard` |
269
+ | Telemetry | `log`, `metric`, `span`, `exception-instance`, `monitor-log`, `audit-log` |
224
270
 
225
- | Area | Commands |
226
- | ---------------- | ------------------------------------------------------------ |
227
- | Observability | `log`, `metric`, `span`, `exception-instance`, `monitor-log` |
228
- | Security | `security-event`, `threat-intel-indicator` |
229
- | Changes and cost | `change-event`, `kubernetes-cost-allocation` |
230
-
231
- As more models are MCP-enabled in OneUptime, they become available in the CLI as well. The [command reference](https://oneuptime.com/docs/cli/command-reference) describes every command and its options.
271
+ The [command reference](https://oneuptime.com/docs/cli/command-reference) describes every command and its options.
232
272
 
233
273
  ## Development
234
274
 
@@ -242,6 +282,8 @@ npm run build # Bundle into build/dist/Index.js, the file npm publishe
242
282
  npm run smoke-test # Pack, install as a customer does, and run it
243
283
  ```
244
284
 
285
+ The tests never touch your own `~/.oneuptime`: each test file runs in a throwaway home of its own (`Tests/Setup`), and a run fails if your `~/.oneuptime` changed while it ran.
286
+
245
287
  ## License
246
288
 
247
289
  Apache-2.0