uptimer-cli 0.0.0-stage → 0.2.1

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.
@@ -0,0 +1,187 @@
1
+ # Uptimer CLI commands and payloads
2
+
3
+ Use these examples for payload field names and edge cases. `uptimer --help` carries the same examples inline. Replace example hostnames, channel IDs, and monitor IDs with values for the selected instance.
4
+
5
+ ## Command map
6
+
7
+ | Resource | Commands |
8
+ | ------------------------ | ------------------------------------------------------------------------------------------------- |
9
+ | `monitors` | `list [--limit N]`, `create --file F`, `update ID --file F`, `delete ID`, `pause ID`, `resume ID` |
10
+ | `monitors groups` | `reorder --file F`, `assign --file F` |
11
+ | `notification-channels` | `list [--limit N]`, `create --file F`, `update ID --file F`, `delete ID` |
12
+ | `status-pages` | `list`, `create --file F`, `update ID --file F`, `delete ID` |
13
+ | `settings` | `get`, `update --file F` |
14
+ | `settings uptime-rating` | `get`, `update --file F` |
15
+
16
+ `F` is a JSON file path, or `-` for stdin. IDs are positive safe integers. Monitor/channel limits are 1–200, default 50; status-page lists have no `--limit` option. No command implements per-ID GET, pagination, export, or automatic synchronization.
17
+
18
+ ## Monitors
19
+
20
+ ### HTTP monitor
21
+
22
+ Save as `http-monitor.json` and invoke `uptimer monitors create --file http-monitor.json`:
23
+
24
+ ```json
25
+ {
26
+ "name": "API Health",
27
+ "type": "http",
28
+ "target": "https://api.example.com/health",
29
+ "interval_sec": 60,
30
+ "timeout_ms": 5000,
31
+ "http_method": "GET",
32
+ "expected_status_json": [200]
33
+ }
34
+ ```
35
+
36
+ The API uses `target`, `interval_sec`, `timeout_ms`, and `http_method`, rather than `url`, `interval_seconds`, `timeout_seconds`, or `method`. `http_headers_json` is an object of header strings; its contents may contain credentials and must stay out of shared output.
37
+
38
+ ### TCP monitor
39
+
40
+ Save as `tcp-monitor.json` and invoke `uptimer monitors create --file tcp-monitor.json`:
41
+
42
+ ```json
43
+ {
44
+ "name": "TLS Port",
45
+ "type": "tcp",
46
+ "target": "example.com:443",
47
+ "interval_sec": 60,
48
+ "timeout_ms": 5000
49
+ }
50
+ ```
51
+
52
+ The target includes the host and port in one string. HTTP-only fields are invalid for TCP monitors.
53
+
54
+ ### Patch a monitor
55
+
56
+ Save as `monitor-patch.json`, replacing ID 42 with an ID returned by the instance:
57
+
58
+ ```json
59
+ {
60
+ "show_on_status_page": false,
61
+ "http_headers_json": null
62
+ }
63
+ ```
64
+
65
+ ```sh
66
+ uptimer monitors update 42 --file monitor-patch.json
67
+ uptimer monitors pause 42
68
+ uptimer monitors resume 42
69
+ ```
70
+
71
+ PATCH omission preserves existing fields. `null` clears supported nullable fields such as `http_headers_json`, `http_body`, or `response_keyword`; it does not make every field nullable.
72
+
73
+ ### Groups
74
+
75
+ Save as `group-assignment.json`, replacing 42 with an actual monitor ID:
76
+
77
+ ```json
78
+ {
79
+ "monitor_ids": [42],
80
+ "group_name": "Core"
81
+ }
82
+ ```
83
+
84
+ Use `uptimer monitors groups assign --file group-assignment.json`. Group reorder input is an object with a `groups` array; each entry has `group_name` (a string or null) and `group_sort_order` (an integer). It is not a `name`/`sort_order` pair.
85
+
86
+ `group_name: null` unassigns the group, and the CLI accepts that response.
87
+
88
+ ## Notification channels
89
+
90
+ Notification input uses `config_json`, even though it is a JSON object. The channel's `type` is `webhook` for both custom webhooks and the Telegram preset.
91
+
92
+ ### Custom webhook
93
+
94
+ Save as `webhook-channel.json` and use `uptimer notification-channels create --file webhook-channel.json`:
95
+
96
+ ```json
97
+ {
98
+ "name": "Operations Webhook",
99
+ "type": "webhook",
100
+ "config_json": {
101
+ "preset": "custom",
102
+ "url": "https://hooks.example.com/uptimer",
103
+ "method": "POST",
104
+ "payload_type": "json",
105
+ "payload_template": {
106
+ "text": "{{message}}"
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ A real webhook URL can contain a credential. CLI output masks `config_json.url`, `config_json.headers`, and `config_json.payload_template`, but input files and logs outside the CLI are still yours to protect.
113
+
114
+ ### Telegram
115
+
116
+ Save as `telegram-channel.json` and use the same notification-channel create command with that file:
117
+
118
+ ```json
119
+ {
120
+ "name": "Telegram Alerts",
121
+ "type": "webhook",
122
+ "config_json": {
123
+ "preset": "telegram",
124
+ "chat_id": "@status_channel",
125
+ "bot_token_secret_ref": "UPTIMER_TELEGRAM_BOT_TOKEN"
126
+ }
127
+ }
128
+ ```
129
+
130
+ The referenced secret binding must already exist on the Worker. The CLI does not create secrets. If an administrator explicitly chooses the direct-token input instead, inject the value privately as `config_json.bot_token` and omit `bot_token_secret_ref`; creation accepts exactly one credential source. Channel PATCH payloads do not include `type`.
131
+
132
+ ## Status pages
133
+
134
+ Save as `status-page.json` and invoke `uptimer status-pages create --file status-page.json`:
135
+
136
+ ```json
137
+ {
138
+ "slug": "public-status",
139
+ "name": "Public Status",
140
+ "title": "Service status",
141
+ "description": "Service availability",
142
+ "is_public": true,
143
+ "monitor_ids": []
144
+ }
145
+ ```
146
+
147
+ Creation requires `name`, `slug`, and `title`. Replace the empty membership list with known monitor IDs to display those monitors. For updates, omitted `monitor_ids` preserves membership, while `[]` unlinks all monitors. Optional `logo_url` and `custom_hostname` accept `null` to clear their value. Setting `custom_hostname` records the application's routing hostname; it does not provision DNS or a Cloudflare domain.
148
+
149
+ Deleting a linked page can return HTTP 409. Explain its existing links and act only within the authorized request.
150
+
151
+ ## Global settings
152
+
153
+ Save as `settings-patch.json` and invoke `uptimer settings update --file settings-patch.json`:
154
+
155
+ ```json
156
+ {
157
+ "site_timezone": "Asia/Shanghai",
158
+ "site_locale": "en",
159
+ "retention_check_results_days": 7
160
+ }
161
+ ```
162
+
163
+ Global settings have no create/delete commands. Branding belongs to status pages; `site_title` is not a settings input. Use `retention_check_results_days`, not `retention_days`.
164
+
165
+ For the separate uptime-rating command, save as `uptime-rating.json`:
166
+
167
+ ```json
168
+ {
169
+ "uptime_rating_level": 4
170
+ }
171
+ ```
172
+
173
+ ```sh
174
+ uptimer settings uptime-rating get
175
+ uptimer settings uptime-rating update --file uptime-rating.json
176
+ ```
177
+
178
+ The level is an integer from 1 to 5. Query settings again after an update to verify the saved values.
179
+
180
+ ## Schema references
181
+
182
+ For a field not covered here, consult the matching deployed API version or these upstream schemas rather than inventing an option:
183
+
184
+ - [Monitors and groups](https://github.com/nexttylabs/Uptimer/blob/master/apps/worker/src/schemas/monitors.ts)
185
+ - [Notification channels](https://github.com/nexttylabs/Uptimer/blob/master/apps/worker/src/schemas/notification-channels.ts)
186
+ - [Status pages](https://github.com/nexttylabs/Uptimer/blob/master/apps/worker/src/schemas/status-pages.ts)
187
+ - [Settings](https://github.com/nexttylabs/Uptimer/blob/master/apps/worker/src/schemas/settings.ts)