Implemented the Monitorv2 crud into cli#12
Open
obs-gh-joedarling wants to merge 14 commits into
Open
Conversation
- Restore skill/KG source files to proper generated imports (our stubs caused CI typecheck failures when codegen regenerated correct types) - Extract createApiConfiguration helper to src/rest/api-config.ts so monitor REST wrappers can use MonitorApi directly without pulling in ObserveRestSDK (which imports SkillsApi/V2KnowledgeGraphApi absent from the local dev spec) - Fix MonitorV2RuleKind enum values in create/update commands (string literals → enum constants) - Fix MonitorV2CronSchedule.interval reference in view (field is cronConfig in current schema) - Fix test Parameters<fn>[N] indices (off-by-one: commands with a positional arg use [2] not [3]; commands without use [1] not [2]) - Add noUncheckedIndexedAccess-safe ! assertions on mock.calls[0] - Add required outputStage field to MultiStageQuery test fixtures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- delete: require --force flag to prevent accidental deletions - create: add fullDescription with MonitorV2Definition schema link and minimal JSON example in help text - list: add client-side pagination (--limit, --offset) with default limit of 100, consistent with alert list and metric list Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename --rule-kind → --kind in create and update for consistency with list - Extract shared ruleKindColor to monitor-utils.ts; fix Count color blue → green - Add --definition inline JSON flag to create and update (mutex with --definition-file) - Show definition section in monitor view human-readable output - Update index.ts brief: "View" → "Manage observe monitors" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
obs-gh-abhinavpappu
left a comment
Collaborator
There was a problem hiding this comment.
Would you mind also updating this PR to use the newly added experimental option (#14). Gives us some flexibility to change the schema after merging this in for a short while before we make it fixed.
Essentially just switch to defineCommand instead of buildCommand and add experimental: true to each of the commands. Also use defineRoutes instead of buildRouteMap.
94abeeb to
151f9f6
Compare
… round 3 - Merge origin/main: adds defineCommand/defineRoutes wrappers and OBSERVE_CLI_EXPERIMENTAL gating (PR #14) - Convert all monitor commands to defineCommand({ experimental: true }) and monitorRoutes to defineRoutes - Replace --force with --yes on delete; add interactive readline confirmation prompt when stdin is a TTY - Strip layout fields from monitor view human-readable output - Update delete tests: force → yes, add confirmFn injection tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
151f9f6 to
2f9ceab
Compare
- Refactor all monitor rest helpers to use ObserveRestSDK instead of
directly instantiating MonitorApi with createApiConfiguration, matching
the pattern used by all other rest files
- Add --file flag to monitor update supporting the edit flow:
observe monitor view <id> --json > monitor.json
# edit monitor.json
observe monitor update <id> --file monitor.json
--file is mutually exclusive with all other update flags
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove unnecessary optional chain and fix conditional operator to satisfy @typescript-eslint/no-unnecessary-condition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
obs-gh-abhinavpappu
left a comment
Collaborator
There was a problem hiding this comment.
Vikram actually suggested keeping it simple initially with just a single --file flag similar to the other CLIs, and then we can add the other top-level flags later as an alternative option if desired. And for consistency, we should probably have --file on create as well instead of the current flags.
Remove individual field flags (--name, --kind, --definition, etc.) from both create and update in favour of a single --file flag, matching the pattern used by other CLIs. Also fix update to use !== undefined instead of != null when building the patch, preserving explicit null values per JSON merge-patch semantics. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
obs-gh-abhinavpappu
approved these changes
Jul 1, 2026
|
|
||
| observe monitor view <id> --json # full monitor definition | ||
|
|
||
| observe monitor create --name "My Monitor" \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observe Monitor CLI — feature demo
0. Experimental gate
observe --help—monitorabsent from top-level commandsexport OBSERVE_CLI_EXPERIMENTAL=1— unlock experimental commandsobserve --help—monitor [experimental]now visible1. Help (with experimental flag)
monitor --help— available subcommandsmonitor create --help— single--fileflagFull schema reference: [Observe API Reference](https://developer.observeinc.com/#model/monitorv2definition).
2.
monitor listlist — all monitors (IDs and names redacted)
list --kind Count— filter by rule kindlist --no-disabled— only enabled monitorslist --sort name— sorted alphabeticallylist --limit 5— client-side pagination (first page)list --limit 5 --offset 5— second pagelist --json— machine-readable output[ { "id": "XXXXXXXX", "name": "Monitor N", "ruleKind": "Threshold", "disabled": false }, { "id": "XXXXXXXX", "name": "Monitor N", "ruleKind": "Count", "disabled": false }, { "id": "XXXXXXXX", "name": "Monitor N", "ruleKind": "Count", "disabled": false } ]3.
monitor viewview <id>— human-readable output including definitionview <id> --json— full monitor JSON{ "id": "41076897", "name": "Joe - Test Monitor", "ruleKind": "Count", "disabled": true, "description": "This is just a test monitor used to test monitor cli commands." }4.
monitor createcreate --file— from JSON file{ "id": "41077231", "name": "CLI Demo Monitor", "ruleKind": "Count", "disabled": false }5.
monitor updateupdate --file— full round-trip edit (view → edit → update)6.
monitor disabledisable <id>disable <id> --json{ "id": "41077231", "name": "CLI Demo Monitor (edited)", "disabled": true }7.
monitor enableenable <id>enable <id> --json{ "id": "41077231", "name": "CLI Demo Monitor (edited)", "disabled": false }8.
monitor deletedelete without
--yes— confirmation prompt (typento cancel)delete --yes— confirmed deletionview after delete — confirms not found
9. Error handling
non-integer ID
float ID
zero ID
create with missing required field in
--filecreate with invalid JSON in
--fileview non-existent monitor
Demo complete
All demo-created monitors were cleaned up.