From 1d6e1133353f297a389bf7d9f8170f84b626543c Mon Sep 17 00:00:00 2001 From: ysyneu Date: Tue, 14 Jul 2026 03:03:07 -0700 Subject: [PATCH] fix(cli): accept required body fields from flags --- internal/cli/args.go | 36 ++++++++++----- internal/cli/gen_positional_test.go | 42 +++++++++++++++++ internal/cli/zz_generated_a2a_agents.go | 10 ++-- internal/cli/zz_generated_alert_enrichment.go | 34 +++++++------- internal/cli/zz_generated_alerts.go | 16 +++---- internal/cli/zz_generated_applications.go | 10 ++-- internal/cli/zz_generated_calendars.go | 10 ++-- internal/cli/zz_generated_channels.go | 32 ++++++------- internal/cli/zz_generated_incidents.go | 46 +++++++++---------- internal/cli/zz_generated_issues.go | 4 +- internal/cli/zz_generated_mcp_servers.go | 10 ++-- internal/cli/zz_generated_members.go | 10 ++-- .../zz_generated_notification_templates.go | 6 +-- .../cli/zz_generated_roles_permissions.go | 12 ++--- internal/cli/zz_generated_schedules.go | 6 +-- internal/cli/zz_generated_sessions.go | 4 +- internal/cli/zz_generated_skills.go | 10 ++-- internal/cli/zz_generated_status_pages.go | 18 ++++---- internal/cli/zz_generated_teams.go | 2 +- internal/cmd/cligen/main.go | 14 +++--- 20 files changed, 194 insertions(+), 138 deletions(-) diff --git a/internal/cli/args.go b/internal/cli/args.go index b9fd5b3..a4a7997 100644 --- a/internal/cli/args.go +++ b/internal/cli/args.go @@ -24,23 +24,37 @@ func requireArgs(argNames ...string) cobra.PositionalArgs { } } -// requireExactArg returns a positional argument validator that requires exactly -// one argument named name, producing friendly messages that match requireArgs style: -// -// - zero args: "missing . Usage: ..." -// - >1 args: "expects exactly one . Usage: ..." -func requireExactArg(name string) cobra.PositionalArgs { +// requireBodyFieldOrArgs validates a required variadic positional that folds +// into a request-body field. The same field can also come from --data or from +// its typed flag, so zero positional args are valid when either source is set. +func requireBodyFieldOrArgs(name, flagName string) cobra.PositionalArgs { + return func(cmd *cobra.Command, args []string) error { + if len(args) > 0 || bodyFieldSourceSet(cmd, flagName) { + return nil + } + return fmt.Errorf("missing %s. Usage: %s", name, cmd.UseLine()) + } +} + +// requireBodyFieldOrExactArg validates a required scalar positional that folds +// into a request-body field. The value may instead come from --data or from the +// typed flag, but extra positionals are still rejected. +func requireBodyFieldOrExactArg(name, flagName string) cobra.PositionalArgs { return func(cmd *cobra.Command, args []string) error { - switch { - case len(args) == 0: - return fmt.Errorf("missing %s. Usage: %s", name, cmd.UseLine()) - case len(args) > 1: + if len(args) > 1 { return fmt.Errorf("expects exactly one %s. Usage: %s", name, cmd.UseLine()) } - return nil + if len(args) == 1 || bodyFieldSourceSet(cmd, flagName) { + return nil + } + return fmt.Errorf("missing %s. Usage: %s", name, cmd.UseLine()) } } +func bodyFieldSourceSet(cmd *cobra.Command, flagName string) bool { + return cmd.Flags().Changed("data") || cmd.Flags().Changed(flagName) +} + // optionalArg returns a positional argument validator that accepts zero or one // argument named name. It backs generated commands whose positional folds into // an OPTIONAL body field because the operation also accepts an alternative diff --git a/internal/cli/gen_positional_test.go b/internal/cli/gen_positional_test.go index fb6ca3d..09727d6 100644 --- a/internal/cli/gen_positional_test.go +++ b/internal/cli/gen_positional_test.go @@ -99,6 +99,20 @@ func TestGenPositionalSliceRuntime(t *testing.T) { if got, want := fmt.Sprint(stub.bodyStrings("alert_ids")), "[a1 a2 a3]"; got != want { t.Errorf("alert_ids = %q, want %q", got, want) } + + if _, err := execCommand("alert", "list-by-ids", "--alert-ids", "b1,b2"); err != nil { + t.Fatalf("execCommand alert list-by-ids --alert-ids: %v", err) + } + if got, want := fmt.Sprint(stub.bodyStrings("alert_ids")), "[b1 b2]"; got != want { + t.Errorf("alert_ids from flag = %q, want %q", got, want) + } + + if _, err := execCommand("alert", "list-by-ids", "--data", `{"alert_ids":["c1","c2"]}`); err != nil { + t.Fatalf("execCommand alert list-by-ids --data: %v", err) + } + if got, want := fmt.Sprint(stub.bodyStrings("alert_ids")), "[c1 c2]"; got != want { + t.Errorf("alert_ids from data = %q, want %q", got, want) + } } // TestGenPositionalIntSliceRuntime invokes a GENERATED-ONLY int-slice command @@ -164,6 +178,34 @@ func TestGenPositionalFlagOverridesPositional(t *testing.T) { } } +func TestGenChannelEscalateRuleListArgumentSources(t *testing.T) { + saveAndResetGlobals(t) + stub := newGFStub(t) + + tests := []struct { + name string + args []string + want float64 + }{ + {name: "positional", args: []string{"channel", "escalate-rule-list", "42"}, want: 42}, + {name: "typed flag", args: []string{"channel", "escalate-rule-list", "--channel-id", "43"}, want: 43}, + {name: "data", args: []string{"channel", "escalate-rule-list", "--data", `{"channel_id":44}`}, want: 44}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if _, err := execCommand(tt.args...); err != nil { + t.Fatalf("execCommand: %v", err) + } + if stub.lastPath != "/channel/escalate/rule/list" { + t.Fatalf("path = %q, want /channel/escalate/rule/list", stub.lastPath) + } + if got := stub.lastBody["channel_id"]; got != tt.want { + t.Errorf("channel_id = %#v, want %v", got, tt.want) + } + }) + } +} + // TestGenFoldPositional unit-tests the runtime helper across all three kinds. func TestGenFoldPositional(t *testing.T) { // string scalar → args[0] diff --git a/internal/cli/zz_generated_a2a_agents.go b/internal/cli/zz_generated_a2a_agents.go index 8fadf53..192a92f 100644 --- a/internal/cli/zz_generated_a2a_agents.go +++ b/internal/cli/zz_generated_a2a_agents.go @@ -46,7 +46,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - team_id (integer) (required) — Team scope: 0 = account-wide; >0 = the owning team. - updated_at (integer) (required) — Last update time. Unix timestamp in milliseconds. `, - Args: requireExactArg("agent_id"), + Args: requireBodyFieldOrExactArg("agent_id", "agent-id"), Example: ` flashduty safari a2a-agent-get --data '{"agent_id":"a2a_6mWqZ2pK9nLcR3tY8uVb4D"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -277,7 +277,7 @@ API: POST /safari/a2a-agent/delete (remote-agent-write-delete) Request fields: --agent-id string (required) — Target agent ID. `, - Args: requireExactArg("agent_id"), + Args: requireBodyFieldOrExactArg("agent_id", "agent-id"), Example: ` flashduty safari a2a-agent-delete --data '{"agent_id":"a2a_6mWqZ2pK9nLcR3tY8uVb4D"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -325,7 +325,7 @@ API: POST /safari/a2a-agent/disable (remote-agent-write-disable) Request fields: --agent-id string (required) — Target agent ID. `, - Args: requireExactArg("agent_id"), + Args: requireBodyFieldOrExactArg("agent_id", "agent-id"), Example: ` flashduty safari a2a-agent-disable --data '{"agent_id":"a2a_6mWqZ2pK9nLcR3tY8uVb4D"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -373,7 +373,7 @@ API: POST /safari/a2a-agent/enable (remote-agent-write-enable) Request fields: --agent-id string (required) — Target agent ID. `, - Args: requireExactArg("agent_id"), + Args: requireBodyFieldOrExactArg("agent_id", "agent-id"), Example: ` flashduty safari a2a-agent-enable --data '{"agent_id":"a2a_6mWqZ2pK9nLcR3tY8uVb4D"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -440,7 +440,7 @@ Request fields: --team-id int — Reassign team scope. Omit to leave unchanged. auth_config (object, via --data) — Replace the auth config. Omit to leave unchanged. `, - Args: requireExactArg("agent_id"), + Args: requireBodyFieldOrExactArg("agent_id", "agent-id"), Example: ` flashduty safari a2a-agent-update --data '{"agent_id":"a2a_6mWqZ2pK9nLcR3tY8uVb4D","instructions":"Inspect deployment pipelines and propose rollback steps."}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_alert_enrichment.go b/internal/cli/zz_generated_alert_enrichment.go index 4e2ca6e..80fdc77 100644 --- a/internal/cli/zz_generated_alert_enrichment.go +++ b/internal/cli/zz_generated_alert_enrichment.go @@ -38,7 +38,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) (required) — Last update timestamp, Unix seconds. - updated_by (integer) (required) — Last updater member ID. `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty enrichment info --data '{"integration_id":5001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -102,7 +102,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) — Last update timestamp, Unix seconds. - updated_by (integer) (required) — Last updater member ID. `, - Args: requireArgs("integration_ids"), + Args: requireBodyFieldOrArgs("integration_ids", "integration-ids"), Example: ` flashduty enrichment list --data '{"integration_ids":[5001,5002]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -157,7 +157,7 @@ Request fields: - kind (string) (required) — Rule type. 'extraction' extracts a label via regex or GJson. 'composition' builds a label from a template. 'mapping' looks up values from a schema or API. 'drop' removes labels. [extraction, composition, mapping, drop] - settings (any) (required) — Rule-kind–specific settings. The shape depends on 'kind'. `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty enrichment upsert --data '{"integration_id":5001,"rules":[{"kind":"extraction","settings":{"override":true,"pattern":"(?P\u003cresult\u003eprod|staging|dev)","result_label":"environment","source_field":"labels.env"}},{"kind":"composition","settings":{"override":false,"result_label":"full_env","template":"{{.labels.region}}-{{.labels.environment}}"}}]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -226,7 +226,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_by (integer) (required) — Last updater member ID. - value_type (string) (required) — Stored value type. 'checkbox' is always 'bool'; 'single_select'/'multi_select'/'text' are always 'string'. [string, bool, float] `, - Args: requireExactArg("field_id"), + Args: requireBodyFieldOrExactArg("field_id", "field-id"), Example: ` flashduty field info --data '{"field_id":"66e9d3a4f7c2b04a1c8a91b3"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -433,7 +433,7 @@ API: POST /field/delete (field-write-delete) Request fields: --field-id string (required) — Field ID — 24-character hex ObjectID. `, - Args: requireExactArg("field_id"), + Args: requireBodyFieldOrExactArg("field_id", "field-id"), Example: ` flashduty field delete --data '{"field_id":"66e9d3a4f7c2b04a1c8a91b3"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -492,7 +492,7 @@ Request fields: --options []string — Replacement options list. Must obey the same per-type rules as create. default_value (any, via --data) — Replacement default value. Type must match the field's existing 'field_type'. `, - Args: requireExactArg("field_id"), + Args: requireBodyFieldOrExactArg("field_id", "field-id"), Example: ` flashduty field update --data '{"default_value":"Medium","description":"Business severity tier.","display_name":"Severity Class","field_id":"66e9d3a4f7c2b04a1c8a91b3","options":["Critical","High","Medium","Low"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -572,7 +572,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_by (integer) (required) — Last updater member ID. - url (string) (required) — Endpoint URL. `, - Args: requireExactArg("api_id"), + Args: requireBodyFieldOrExactArg("api_id", "api-id"), Example: ` flashduty enrichment mapping-api-info --data '{"api_id":"665f1a2b3c4d5e6f7a8b9c02"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -756,7 +756,7 @@ API: POST /enrichment/mapping/api/delete (mapping-api-write-delete) Request fields: --api-id string (required) — Mapping API ID (MongoDB ObjectID hex). `, - Args: requireExactArg("api_id"), + Args: requireBodyFieldOrExactArg("api_id", "api-id"), Example: ` flashduty enrichment mapping-api-delete --data '{"api_id":"665f1a2b3c4d5e6f7a8b9c02"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -823,7 +823,7 @@ Request fields: --url string — New endpoint URL (max 500 chars). (≤500 chars) headers (object, via --data) — New headers map (replaces existing). `, - Args: requireExactArg("api_id"), + Args: requireBodyFieldOrExactArg("api_id", "api-id"), Example: ` flashduty enrichment mapping-api-update --data '{"api_id":"665f1a2b3c4d5e6f7a8b9c02","retry_count":1,"timeout":3}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -903,7 +903,7 @@ API: POST /enrichment/mapping/data/download (mapping-data-read-download) Request fields: --schema-id string (required) — Mapping schema ID (MongoDB ObjectID hex). `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-data-download --data '{"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -972,7 +972,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - search_after_ctx (string) — Cursor token for the next page. - total (integer) (required) — Total matching rows. `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-data-list --data '{"asc":false,"limit":20,"orderby":"updated_at","p":1,"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1042,7 +1042,7 @@ Request fields: --keys []string (required) — Keys of rows to delete. --schema-id string (required) — Mapping schema ID (MongoDB ObjectID hex). `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-data-delete --data '{"keys":["server01","server02"],"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1098,7 +1098,7 @@ API: POST /enrichment/mapping/data/truncate (mapping-data-write-truncate) Request fields: --schema-id string (required) — Mapping schema ID (MongoDB ObjectID hex). `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-data-truncate --data '{"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1208,7 +1208,7 @@ Request fields: Response fields ('data' envelope is unwrapped — these fields are at the top level): - keys (array) (required) — Composite keys of upserted rows. `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-data-upsert --data '{"docs":[{"host":"server01","owner":"alice","service":"api","team":"sre"},{"host":"server02","owner":"bob","service":"gateway","team":"platform"}],"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1269,7 +1269,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) — Last update timestamp, Unix seconds. - updated_by (integer) (required) — Last updater member ID. `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-schema-info --data '{"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1437,7 +1437,7 @@ API: POST /enrichment/mapping/schema/delete (mapping-schema-write-delete) Request fields: --schema-id string (required) — Mapping schema ID (MongoDB ObjectID hex). `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-schema-delete --data '{"schema_id":"665f1a2b3c4d5e6f7a8b9c01"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1495,7 +1495,7 @@ Request fields: --schema-name string — New schema name (max 39 chars). (≤39 chars) --team-id int — New owning team ID. '0' removes the team association. `, - Args: requireExactArg("schema_id"), + Args: requireBodyFieldOrExactArg("schema_id", "schema-id"), Example: ` flashduty enrichment mapping-schema-update --data '{"description":"Updated description","schema_id":"665f1a2b3c4d5e6f7a8b9c01","schema_name":"CMDB Lookup v2"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_alerts.go b/internal/cli/zz_generated_alerts.go index 42821d8..446c489 100644 --- a/internal/cli/zz_generated_alerts.go +++ b/internal/cli/zz_generated_alerts.go @@ -188,7 +188,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - title_rule (string) — Title template used to derive 'title' from labels. - updated_at (integer) — Record update time, Unix epoch seconds. `, - Args: requireExactArg("alert_id"), + Args: requireBodyFieldOrExactArg("alert_id", "alert-id"), Example: ` flashduty alert event-list --data '{"alert_id":"663a1b2c3d4e5f6789abcdef"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -257,7 +257,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - type (string) (required) — Alert activity feed entry type. Each value identifies one alert lifecycle event; the matching 'detail' payload shape is determined by this field. | Type | Meaning | |---|---| | 'a_new' | Alert triggered. | | 'a_comm' | Comment added on the alert. | | 'a_close' | Alert closed. | [a_new, a_comm, a_close] - updated_at (integer) (required) — Last update timestamp in Unix epoch milliseconds. `, - Args: requireExactArg("alert_id"), + Args: requireBodyFieldOrExactArg("alert_id", "alert-id"), Example: ` flashduty alert feed --data '{"alert_id":"663a1b2c3d4e5f6789abcdef","asc":false,"limit":20}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -387,7 +387,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - title_rule (string) — Title template used to derive 'title' from the event labels (e.g. '$service::$cluster'). - updated_at (integer) — Last update timestamp, Unix epoch seconds. `, - Args: requireExactArg("alert_id"), + Args: requireBodyFieldOrExactArg("alert_id", "alert-id"), Example: ` flashduty alert info --data '{"alert_id":"663a1b2c3d4e5f6789abcdef"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -703,7 +703,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - search_after_ctx (string) — Cursor for the next page. - total (integer) — Total matching alerts. `, - Args: requireArgs("alert_ids"), + Args: requireBodyFieldOrArgs("alert_ids", "alert-ids"), Example: ` flashduty alert list-by-ids --data '{"alert_ids":["663a1b2c3d4e5f6789abcdef"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -763,7 +763,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) — Last update timestamp, Unix epoch seconds. - updated_by (integer) — Member ID who last updated the pipeline. `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty alert pipeline-info --data '{"integration_id":10001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -824,7 +824,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) — Last update timestamp, Unix epoch seconds. - updated_by (integer) — Member ID who last updated the pipeline. `, - Args: requireArgs("integration_ids"), + Args: requireBodyFieldOrArgs("integration_ids", "integration-ids"), Example: ` flashduty alert pipeline-list --data '{"integration_ids":[10001,10002]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -880,7 +880,7 @@ Request fields: --owner-id int — Optional new owner for the target incident. --title string — Optional new title for the target incident. `, - Args: requireArgs("alert_ids"), + Args: requireBodyFieldOrArgs("alert_ids", "alert-ids"), Example: ` flashduty alert merge --data '{"alert_ids":["663a1b2c3d4e5f6789abcdef"],"incident_id":"663a000000000000deadbeef"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -952,7 +952,7 @@ Request fields: - kind (string) — Rule type. [title_reset, description_reset, severity_reset, alert_drop, alert_inhibit] - settings (object) — Kind-specific settings. Shape depends on 'kind': - 'title_reset': '{ "title": "" }' - 'description_reset': '{ "description": "" }' - 'severity_reset': '{ "severity": "Critical"|"Warning"|"Info" }' - 'alert_drop': '{}' (empty object) - 'alert_inhibit': '{ "equals": ["", ...], "source_filters": }' `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty alert pipeline-upsert --data '{"integration_id":10001,"rules":[{"if":null,"kind":"severity_reset","settings":{"severity":"Warning"}}]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_applications.go b/internal/cli/zz_generated_applications.go index 4a75bae..e4d06ed 100644 --- a/internal/cli/zz_generated_applications.go +++ b/internal/cli/zz_generated_applications.go @@ -47,7 +47,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) — Last update timestamp, Unix epoch seconds. - updated_by (integer) — Last updater member ID. `, - Args: requireExactArg("application_id"), + Args: requireBodyFieldOrExactArg("application_id", "application-id"), Example: ` flashduty rum application-info --data '{"application_id":"WoyQQ3BohkdtPivubEvE8o"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -120,7 +120,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) — Last update timestamp, Unix epoch seconds. - updated_by (integer) — Last updater member ID. `, - Args: requireArgs("application_ids"), + Args: requireBodyFieldOrArgs("application_ids", "application-ids"), Example: ` flashduty rum application-infos --data '{"application_ids":["eWbr4xk3ZRnLabRa6unqwD","WoyQQ3BohkdtPivubEvE8o"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -304,7 +304,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - application_name (string) — Application display name. - client_token (string) — Token for RUM SDK initialization. `, - Args: requireExactArg("team_id"), + Args: requireBodyFieldOrExactArg("team_id", "team-id"), Example: ` flashduty rum application-create --data '{"application_name":"My Web App","is_private":false,"team_id":2477033058131,"type":"browser"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -372,7 +372,7 @@ API: POST /rum/application/delete (rum-application-write-delete) Request fields: --application-id string (required) — RUM application ID. `, - Args: requireExactArg("application_id"), + Args: requireBodyFieldOrExactArg("application_id", "application-id"), Example: ` flashduty rum application-delete --data '{"application_id":"qLpu24Dz4CAzWsESPbJYWA"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -444,7 +444,7 @@ Request fields: - endpoint (string) — Trace endpoint URL (http or https). - open_type (string) — How to open the trace link. [popup, tab] `, - Args: requireExactArg("application_id"), + Args: requireBodyFieldOrExactArg("application_id", "application-id"), Example: ` flashduty rum application-update --data '{"alerting":{"channel_ids":[2490121812131],"enabled":true},"application_id":"WoyQQ3BohkdtPivubEvE8o","application_name":"My Web App v2"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_calendars.go b/internal/cli/zz_generated_calendars.go index a4d9219..e3e0a75 100644 --- a/internal/cli/zz_generated_calendars.go +++ b/internal/cli/zz_generated_calendars.go @@ -98,7 +98,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) — Last update timestamp (Unix seconds). - total (integer) (required) — Total number of events returned. `, - Args: requireExactArg("cal_id"), + Args: requireBodyFieldOrExactArg("cal_id", "cal-id"), Example: ` flashduty calendar event-list --data '{"cal_id":"cal.QiNvtdKs4Wj52kZhT3LafM","month":5,"year":2024}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -175,7 +175,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - event_id (string) (required) — Event ID (existing or newly generated). - summary (string) (required) — Event summary. `, - Args: requireExactArg("cal_id"), + Args: requireBodyFieldOrExactArg("cal_id", "cal-id"), Example: ` flashduty calendar event-upsert --data '{"cal_id":"cal.QiNvtdKs4Wj52kZhT3LafM","description":"International Workers Day holiday","end_at":"2024-05-06","is_off":true,"start_at":"2024-05-01","summary":"Labour Day"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -325,7 +325,7 @@ API: POST /calendar/delete (calendarDelete) Request fields: --cal-id string (required) — Calendar ID. `, - Args: requireExactArg("cal_id"), + Args: requireBodyFieldOrExactArg("cal_id", "cal-id"), Example: ` flashduty calendar delete --data '{"cal_id":"cal.QiNvtdKs4Wj52kZhT3LafM"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -393,7 +393,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_by (integer) (required) — Last updater person ID. - workdays (array) — Workday numbers (0 = Sunday, 6 = Saturday). `, - Args: requireExactArg("cal_id"), + Args: requireBodyFieldOrExactArg("cal_id", "cal-id"), Example: ` flashduty calendar info --data '{"cal_id":"cal.eh9gvPtWeH3xXgKeVSRxRg"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -521,7 +521,7 @@ Request fields: --timezone string — New IANA timezone. --workdays []int — Workday numbers (0 = Sunday, 6 = Saturday). `, - Args: requireExactArg("cal_id"), + Args: requireBodyFieldOrExactArg("cal_id", "cal-id"), Example: ` flashduty calendar update --data '{"cal_id":"cal.QiNvtdKs4Wj52kZhT3LafM","cal_name":"Production On-Call Calendar (Updated)","timezone":"America/New_York","workdays":[1,2,3,4,5]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_channels.go b/internal/cli/zz_generated_channels.go index 9c13837..fb7a9c5 100644 --- a/internal/cli/zz_generated_channels.go +++ b/internal/cli/zz_generated_channels.go @@ -164,7 +164,7 @@ API: POST /channel/delete (channelDelete) Request fields: --channel-id int (required) — Channel ID. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel delete --data '{"channel_id":3521074710131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -216,7 +216,7 @@ API: POST /channel/disable (channelDisable) Request fields: --channel-id int (required) — Channel ID. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel disable --data '{"channel_id":3521074710131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -268,7 +268,7 @@ API: POST /channel/enable (channelEnable) Request fields: --channel-id int (required) — Channel ID. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel enable --data '{"channel_id":3521074710131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -712,7 +712,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) — Last update timestamp (unix seconds). - updated_by (integer) (required) — Member ID that last updated the rule. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel escalate-rule-list --data '{"channel_id":1001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -973,7 +973,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - team_name (string) — Owning team name (resolved from the team directory; empty when unavailable). - updated_at (integer) — Last update timestamp (unix seconds). `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel info --data '{"channel_id":1001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1027,7 +1027,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - channel_name (string) (required) — Channel name. - status (string) — Channel status. [enabled, disabled] `, - Args: requireArgs("channel_ids"), + Args: requireBodyFieldOrArgs("channel_ids", "channel-ids"), Example: ` flashduty channel infos --data '{"channel_ids":[1001,1002]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1091,7 +1091,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - rule_id (string) (required) — Newly created rule ID (MongoDB ObjectID). - rule_name (string) (required) — Rule name echoed back from the request. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel inhibit-rule-create --data '{"channel_id":3521074710131,"description":"When a Critical alert fires, suppress matching Info alerts","equals":["labels.cluster","labels.service"],"is_directly_discard":false,"rule_name":"Suppress Info when Critical fires","source_filters":[[{"key":"severity","oper":"IN","vals":["Critical"]}]],"target_filters":[[{"key":"severity","oper":"IN","vals":["Info"]}]]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1339,7 +1339,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) - updated_by (integer) (required) `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel inhibit-rule-list --data '{"channel_id":1001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1662,7 +1662,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - rule_id (string) (required) — Newly created rule ID (MongoDB ObjectID). - rule_name (string) (required) — Rule name echoed back from the request. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel silence-rule-create --data '{"channel_id":3521074710131,"description":"Silence all Info alerts during planned maintenance","filters":[[{"key":"severity","oper":"IN","vals":["Info"]}]],"is_directly_discard":false,"rule_name":"Maintenance window silence","time_filter":{"end_time":1773414000,"start_time":1773388800}}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1924,7 +1924,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) - updated_by (integer) (required) `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel silence-rule-list --data '{"channel_id":1001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2077,7 +2077,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - rule_id (string) (required) — Newly created rule ID (MongoDB ObjectID). - rule_name (string) (required) — Rule name echoed back from the request. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel unsubscribe-rule-create --data '{"channel_id":3521074710131,"description":"Discard all alerts from the test environment before they create incidents","filters":[[{"key":"labels.env","oper":"IN","vals":["test","dev"]}]],"rule_name":"Drop test environment alerts"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2314,7 +2314,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) - updated_by (integer) (required) `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel unsubscribe-rule-list --data '{"channel_id":1001}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2474,7 +2474,7 @@ Request fields: Response fields ('data' envelope is unwrapped — these fields are at the top level): - external_report_token (string) — Newly generated token for external reporters. Only returned when 'is_external_report_enabled' is set to 'true' in the request. Callers should store this value; it cannot be retrieved afterwards. `, - Args: requireExactArg("channel_id"), + Args: requireBodyFieldOrExactArg("channel_id", "channel-id"), Example: ` flashduty channel update --data '{"channel_id":1001,"channel_name":"Production Alerts (v2)","description":"Updated description"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2586,7 +2586,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_by (integer) (required) — ID of the person who performed the last update. - version (integer) (required) — Monotonic version number, incremented on each update. Use it for optimistic concurrency control. `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty route info --data '{"integration_id":6113996590131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2659,7 +2659,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_by (integer) (required) — ID of the person who performed the last update. - version (integer) (required) — Monotonic version number, incremented on each update. Use it for optimistic concurrency control. `, - Args: requireArgs("integration_ids"), + Args: requireBodyFieldOrArgs("integration_ids", "integration-ids"), Example: ` flashduty route list --data '{"integration_ids":[6113996590131,6113996590132]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2723,7 +2723,7 @@ Request fields: - name (string) (required) — Section name. Must be unique within the rule. - position (integer) (required) — Index in 'cases' where this section starts. Must be between 0 and the length of 'cases'. `, - Args: requireExactArg("integration_id"), + Args: requireBodyFieldOrExactArg("integration_id", "integration-id"), Example: ` flashduty route upsert --data '{"cases":[{"channel_ids":[3521074710131],"fallthrough":false,"if":[{"key":"severity","oper":"IN","vals":["Critical"]}],"routing_mode":"standard"}],"default":{"channel_ids":[3521074710131]},"integration_id":6113996590131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_incidents.go b/internal/cli/zz_generated_incidents.go index ccbc755..7909a0e 100644 --- a/internal/cli/zz_generated_incidents.go +++ b/internal/cli/zz_generated_incidents.go @@ -36,7 +36,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - status (string) — Current status of the person. - time_zone (string) — Time zone of the person. `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident war-room-default-observers --data '{"incident_id":"664a1b2c3d4e5f6a7b8c9d0e"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -88,7 +88,7 @@ Request fields: --integration-id int (required) — IM integration that hosts the war room. --member-ids []int (required) — Person IDs to add to the war room. `, - Args: requireExactArg("chat_id"), + Args: requireBodyFieldOrExactArg("chat_id", "chat-id"), Example: ` flashduty incident war-room-add-member --data '{"chat_id":"oc_5ce6d572455d361153b7cb51da133945","integration_id":362,"member_ids":[20001,20002]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -144,7 +144,7 @@ API: POST /incident/ack (incidentAck) Request fields: --incident-ids []string (required) — Incident IDs to acknowledge. At most 100 per call. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident ack --data '{"incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -271,7 +271,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - updated_at (integer) (required) — Last update timestamp (seconds). - total (integer) (required) — Total matching alerts. `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident alert-list --data '{"incident_id":"69da451ef77b1b51f40e83ee","is_active":true,"limit":100,"p":1}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -406,7 +406,7 @@ Request fields: --incident-ids []string (required) — Incident IDs to comment on. At most 100 per call. --mute-reply bool — When true, do not trigger webhook reply actions for this comment. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident comment --data '{"comment":"Identified the root cause. Rolling back the deployment now.","incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -595,7 +595,7 @@ API: POST /incident/disable-merge (incidentDisableMerge) Request fields: --incident-ids []string (required) — Incident IDs whose automatic merge should be disabled. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident disable-merge --data '{"incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -669,7 +669,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - type (string) (required) — Incident timeline entry type. Each value identifies one lifecycle event; the matching 'detail' payload shape is determined by this field. Incident types are prefixed with 'i_'. | Type | Meaning | |---|---| | 'i_new' | Incident Created: A new incident was created automatically or manually. | | 'i_assign' | Assigned: Incident was assigned to responders. | | 'i_a_rspd' | Responder Added: Additional responders joined the incident. | | 'i_notify' | Notification dispatched through a channel at a specific escalation level. | | 'i_storm' | Alert storm threshold reached on the incident. | | 'i_snooze' | Notifications snoozed for a given duration. | | 'i_wake' | Snooze cancelled and notifications resumed. | | 'i_ack' | Acknowledged: Responder confirmed they are working on the incident. | | 'i_unack' | Acknowledgement removed. | | 'i_comm' | Comment: Responder logged progress or key information. | | 'i_rslv' | Resolved: Incident was marked as resolved. | | 'i_reopen' | Reopened: Resolved incident was reopened, possibly due to recurrence. | | 'i_merge' | Merged: Multiple related incidents were merged into one. | | 'i_r_title' | Title updated. | | 'i_r_desc' | Description updated. | | 'i_r_impact' | Impact updated. | | 'i_r_rc' | Root cause updated. | | 'i_r_rsltn' | Resolution updated. | | 'i_r_severity' | Severity Changed: Incident severity level was adjusted. | | 'i_r_field' | Custom field value updated. | | 'i_m_flapping' | Incident muted by flapping detection. | | 'i_m_reply' | Mute reply marker on a comment. | | 'i_custom' | Action: Automated action or script was triggered. | | 'i_wr_create' | War Room Created: Chat group was created for collaborative response. | | 'i_wr_delete' | War room chat group deleted. | | 'i_auto_refresh' | Card auto-refresh event posted back to the timeline. | | 'a_merge' | Alert Merged: An alert was merged into an existing incident. | [i_new, i_assign, i_a_rspd, i_notify, i_storm, i_snooze, i_wake, i_ack, i_unack, i_comm, i_rslv, i_reopen, i_merge, i_r_title, i_r_desc, i_r_impact, i_r_rc, i_r_rsltn, i_r_severity, i_r_field, i_m_flapping, i_m_reply, i_custom, i_wr_create, i_wr_delete, i_auto_refresh, a_merge] - updated_at (integer) (required) — Last update timestamp in milliseconds. `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident feed --data '{"incident_id":"69da451ef77b1b51f40e83ee","limit":20,"p":1}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -740,7 +740,7 @@ Request fields: --incident-id string (required) — Incident ID (MongoDB ObjectID). field_value (any, via --data) — New field value. Type must match the field definition. `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident field-reset --data '{"field_name":"affected_service","field_value":"payment-service","incident_id":"69da451ef77b1b51f40e83ee"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1498,7 +1498,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - search_after_ctx (string) — Opaque cursor to pass as 'search_after_ctx' on the next request. - total (integer) (required) — Total number of matching incidents. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident list-by-ids --data '{"incident_ids":["69da451ef77b1b51f40e83ee","69da451ef77b1b51f40e83ef"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1556,7 +1556,7 @@ Request fields: --target-incident-id string (required) — Target incident ID that source incidents will be merged into. --title string — Optional new title for the target incident. (≤512 chars) `, - Args: requireExactArg("target_incident_id"), + Args: requireBodyFieldOrExactArg("target_incident_id", "target-incident-id"), Example: ` flashduty incident merge --data '{"comment":"Merging related database connectivity incidents into one.","source_incident_ids":["69da451ef77b1b51f40e83ef","69da451ef77b1b51f40e83f0"],"target_incident_id":"69da451ef77b1b51f40e83ee"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1785,7 +1785,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - title (string) (required) — Incident title. - updated_at (integer) (required) — Last update timestamp (seconds). `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident past-list --data '{"incident_id":"69da451ef77b1b51f40e83ee","limit":5}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1837,7 +1837,7 @@ API: POST /incident/post-mortem/delete (incidentPostMortemDelete) Request fields: --post-mortem-id string (required) — Post-mortem ID. `, - Args: requireExactArg("post_mortem_id"), + Args: requireBodyFieldOrExactArg("post_mortem_id", "post-mortem-id"), Example: ` flashduty incident post-mortem-delete --data '{"post_mortem_id":"8104935102bf89dc01ac638a5261fe7e"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1921,7 +1921,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - title (string) (required) — Report title. - updated_at_seconds (integer) (required) — Last update timestamp (seconds). `, - Args: requireExactArg("post_mortem_id"), + Args: requireBodyFieldOrExactArg("post_mortem_id", "post-mortem-id"), RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { body, err := genAssembleBody(dataJSON, func(body map[string]any) error { @@ -2094,7 +2094,7 @@ API: POST /incident/remove (incidentRemove) Request fields: --incident-ids []string (required) — Incident IDs to remove. At most 100 per call. The caller must have access to every channel the incidents belong to. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident remove --data '{"incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2148,7 +2148,7 @@ Request fields: --incident-ids []string (required) — Incident IDs to reopen. At most 100 per call. --reason string — Optional reason recorded on the timeline. (≤1024 chars) `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident reopen --data '{"incident_ids":["69da451ef77b1b51f40e83ee"],"reason":"Monitoring detected the issue recurred after the initial fix."}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2216,7 +2216,7 @@ Request fields: --root-cause string — New root cause analysis. (3-6144 chars) --title string — New incident title. (3-200 chars) `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident reset --data '{"incident_id":"69da451ef77b1b51f40e83ee","incident_severity":"Critical","title":"Database connection timeout - prod-db-01 primary"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2296,7 +2296,7 @@ Request fields: --resolution string — Optional resolution note applied to every resolved incident. (≤1024 chars) --root-cause string — Optional root cause note applied to every resolved incident. (≤1024 chars) `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident resolve --data '{"incident_ids":["69da451ef77b1b51f40e83ee"],"resolution":"Deployed hotfix v2.3.1 and restarted the affected service.","root_cause":"Memory leak in the connection pool caused by a missing cleanup call."}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2362,7 +2362,7 @@ Request fields: - personal_channels (array) — Channels to use (e.g. 'voice', 'sms', 'email'). - template_id (string) — Notification template ID (MongoDB ObjectID). `, - Args: requireArgs("person_ids"), + Args: requireBodyFieldOrArgs("person_ids", "person-ids"), Example: ` flashduty incident responder-add --data '{"incident_id":"69da451ef77b1b51f40e83ee","person_ids":[2476444212131,2476444212132]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2420,7 +2420,7 @@ Request fields: --incident-ids []string (required) — Incident IDs to snooze. At most 100 per call. --minutes int (required) — Duration in minutes. Must be greater than 0 and at most 1440 (24h). (max 1440) `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident snooze --data '{"incident_ids":["69da451ef77b1b51f40e83ee"],"minutes":60}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2476,7 +2476,7 @@ API: POST /incident/unack (incidentUnack) Request fields: --incident-ids []string (required) — Incident IDs to unacknowledge. At most 100 per call. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident unack --data '{"incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2528,7 +2528,7 @@ API: POST /incident/wake (incidentWake) Request fields: --incident-ids []string (required) — Incident IDs to wake. At most 100 per call. `, - Args: requireArgs("incident_ids"), + Args: requireBodyFieldOrArgs("incident_ids", "incident-ids"), Example: ` flashduty incident wake --data '{"incident_ids":["69da451ef77b1b51f40e83ee"]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2708,7 +2708,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - chat_name (string) (required) — Chat/group display name. - share_link (string) (required) — Join link for the war room, if provided by the IM. `, - Args: requireExactArg("chat_id"), + Args: requireBodyFieldOrExactArg("chat_id", "chat-id"), Example: ` flashduty incident war-room-detail --data '{"chat_id":"oc_a0553eda9014c2de1b3a8f75b4e0c000","integration_id":2490562293131}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -2773,7 +2773,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - plugin_type (string) (required) — IM plugin type (e.g. 'feishu', 'dingtalk', 'wecom', 'slack'). - status (string) (required) — War room status. `, - Args: requireExactArg("incident_id"), + Args: requireBodyFieldOrExactArg("incident_id", "incident-id"), Example: ` flashduty incident war-room-list --data '{"incident_id":"69da451ef77b1b51f40e83ee"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_issues.go b/internal/cli/zz_generated_issues.go index 559cdb8..a407dce 100644 --- a/internal/cli/zz_generated_issues.go +++ b/internal/cli/zz_generated_issues.go @@ -59,7 +59,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) - versions (array) `, - Args: requireExactArg("issue_id"), + Args: requireBodyFieldOrExactArg("issue_id", "issue-id"), Example: ` flashduty rum issue-info --data '{"issue_id":"NHEacQHi2DhXqobr9qPQz9"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -278,7 +278,7 @@ Request fields: --status string — New status. [for_review, reviewed, ignored, resolved] --suspected-cause string — Suspected cause. [api.failed_request, network.error, code.exception, code.invalid_object_access, code.invalid_argument, unknown] `, - Args: requireExactArg("issue_id"), + Args: requireBodyFieldOrExactArg("issue_id", "issue-id"), Example: ` flashduty rum issue-update --data '{"issue_id":"NHEacQHi2DhXqobr9qPQz9","status":"resolved"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_mcp_servers.go b/internal/cli/zz_generated_mcp_servers.go index e755d5b..9bb50b7 100644 --- a/internal/cli/zz_generated_mcp_servers.go +++ b/internal/cli/zz_generated_mcp_servers.go @@ -55,7 +55,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) (required) — Last update time. Unix timestamp in milliseconds. - url (string) — Server URL (sse / streamable-http transport). `, - Args: requireExactArg("server_id"), + Args: requireBodyFieldOrExactArg("server_id", "server-id"), Example: ` flashduty safari mcp-server-get --data '{"server_id":"mcp_4kP9wQ2nLceRtY7uVb3xA1"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -361,7 +361,7 @@ API: POST /safari/mcp/server/delete (mcp-write-server-delete) Request fields: --server-id string (required) — Target MCP server ID. `, - Args: requireExactArg("server_id"), + Args: requireBodyFieldOrExactArg("server_id", "server-id"), Example: ` flashduty safari mcp-server-delete --data '{"server_id":"mcp_4kP9wQ2nLceRtY7uVb3xA1"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -409,7 +409,7 @@ API: POST /safari/mcp/server/disable (mcp-write-server-disable) Request fields: --server-id string (required) — Target MCP server ID. `, - Args: requireExactArg("server_id"), + Args: requireBodyFieldOrExactArg("server_id", "server-id"), Example: ` flashduty safari mcp-server-disable --data '{"server_id":"mcp_4kP9wQ2nLceRtY7uVb3xA1"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -457,7 +457,7 @@ API: POST /safari/mcp/server/enable (mcp-write-server-enable) Request fields: --server-id string (required) — Target MCP server ID. `, - Args: requireExactArg("server_id"), + Args: requireBodyFieldOrExactArg("server_id", "server-id"), Example: ` flashduty safari mcp-server-enable --data '{"server_id":"mcp_4kP9wQ2nLceRtY7uVb3xA1"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -563,7 +563,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) (required) — Last update time. Unix timestamp in milliseconds. - url (string) — Server URL (sse / streamable-http transport). `, - Args: requireExactArg("server_id"), + Args: requireBodyFieldOrExactArg("server_id", "server-id"), Example: ` flashduty safari mcp-server-update --data '{"description":"Query Prometheus metrics, alerts, and rules.","server_id":"mcp_4kP9wQ2nLceRtY7uVb3xA1"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_members.go b/internal/cli/zz_generated_members.go index a9cfe92..ba456c9 100644 --- a/internal/cli/zz_generated_members.go +++ b/internal/cli/zz_generated_members.go @@ -109,7 +109,7 @@ Request fields: --member-id int (required) — Member ID --role-ids []int (required) — Role IDs to grant; appended to the member's current roles (duplicates are deduplicated). `, - Args: requireArgs("role_ids"), + Args: requireBodyFieldOrArgs("role_ids", "role-ids"), Example: ` flashduty member role-grant --data '{"member_id":5068740052131,"role_ids":[6]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -395,7 +395,7 @@ Request fields: --phone string — Phone number --time-zone string — Time zone `, - Args: requireExactArg("member_id"), + Args: requireBodyFieldOrExactArg("member_id", "member-id"), Example: ` flashduty member info-reset --data '{"locale":"zh-CN","member_id":2476444212131,"member_name":"Alice","time_zone":"Asia/Shanghai"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -477,7 +477,7 @@ Request fields: --member-id int (required) — Member ID --role-ids []int (required) — Role IDs to remove from the member. `, - Args: requireArgs("role_ids"), + Args: requireBodyFieldOrArgs("role_ids", "role-ids"), Example: ` flashduty member role-revoke --data '{"member_id":5068740052131,"role_ids":[6]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -535,7 +535,7 @@ Request fields: --member-id int (required) — Member ID --role-ids []int (required) — New set of role IDs `, - Args: requireArgs("role_ids"), + Args: requireBodyFieldOrArgs("role_ids", "role-ids"), Example: ` flashduty member role-update --data '{"member_id":5068740052131,"role_ids":[2,6]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -606,7 +606,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - status (string) — Person status. 'enabled' — active; 'pending' — invited but not yet accepted; 'deleted' — removed. [enabled, pending, deleted] - time_zone (string) — Time zone `, - Args: requireArgs("person_ids"), + Args: requireBodyFieldOrArgs("person_ids", "person-ids"), Example: ` flashduty person infos --data '{"person_ids":[2476444212131,3790925372131]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_notification_templates.go b/internal/cli/zz_generated_notification_templates.go index 17a9f27..998c8d6 100644 --- a/internal/cli/zz_generated_notification_templates.go +++ b/internal/cli/zz_generated_notification_templates.go @@ -50,7 +50,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - wecom_app (string) (required) — WeCom app message template source. - zoom (string) (required) — Zoom bot message template source. `, - Args: requireExactArg("template_id"), + Args: requireBodyFieldOrExactArg("template_id", "template-id"), Example: ` flashduty template info --data '{"template_id":"6605a1b2c3d4e5f6a7b8c9d0"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -425,7 +425,7 @@ API: POST /template/delete (template-write-delete) Request fields: --template-id string (required) — Target template ID. Pass '000000000000000000000001' to address the built-in preset. `, - Args: requireExactArg("template_id"), + Args: requireBodyFieldOrExactArg("template_id", "template-id"), Example: ` flashduty template delete --data '{"template_id":"6605a1b2c3d4e5f6a7b8c9d0"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -511,7 +511,7 @@ Request fields: --wecom-app string — WeCom app message template source. --zoom string — Zoom bot message template source. `, - Args: requireExactArg("template_id"), + Args: requireBodyFieldOrExactArg("template_id", "template-id"), Example: ` flashduty template update --data '{"description":"Updated description.","email":"Incident {{ .IncidentName }} on {{ .Severity }}","sms":"[Flashduty] {{ .IncidentName }} — {{ .Severity }}","template_id":"6605a1b2c3d4e5f6a7b8c9d0","template_name":"Prod incident default"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_roles_permissions.go b/internal/cli/zz_generated_roles_permissions.go index d4bbc98..8e6ef58 100644 --- a/internal/cli/zz_generated_roles_permissions.go +++ b/internal/cli/zz_generated_roles_permissions.go @@ -33,7 +33,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - status (string) (required) — Role status. [enabled, disabled] - updated_at (integer) (required) — Unix epoch seconds the role was last updated. `, - Args: requireExactArg("role_id"), + Args: requireBodyFieldOrExactArg("role_id", "role-id"), Example: ` flashduty role info --data '{"role_id":2}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -252,7 +252,7 @@ API: POST /role/delete (role-write-delete) Request fields: --role-id int (required) — Role ID. `, - Args: requireExactArg("role_id"), + Args: requireBodyFieldOrExactArg("role_id", "role-id"), Example: ` flashduty role delete --data '{"role_id":150}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -304,7 +304,7 @@ API: POST /role/disable (role-write-disable) Request fields: --role-id int (required) — Role ID. `, - Args: requireExactArg("role_id"), + Args: requireBodyFieldOrExactArg("role_id", "role-id"), Example: ` flashduty role disable --data '{"role_id":150}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -356,7 +356,7 @@ API: POST /role/enable (role-write-enable) Request fields: --role-id int (required) — Role ID. `, - Args: requireExactArg("role_id"), + Args: requireBodyFieldOrExactArg("role_id", "role-id"), Example: ` flashduty role enable --data '{"role_id":150}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -410,7 +410,7 @@ Request fields: --member-ids []int (required) — Member IDs to grant/revoke the role. Max 100. --role-id int (required) — Role ID to grant or revoke. `, - Args: requireArgs("member_ids"), + Args: requireBodyFieldOrArgs("member_ids", "member-ids"), Example: ` flashduty role member-grant --data '{"member_ids":[80011,80012],"role_id":150}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -468,7 +468,7 @@ Request fields: --member-ids []int (required) — Member IDs to grant/revoke the role. Max 100. --role-id int (required) — Role ID to grant or revoke. `, - Args: requireArgs("member_ids"), + Args: requireBodyFieldOrArgs("member_ids", "member-ids"), Example: ` flashduty role member-revoke --data '{"member_ids":[80011],"role_id":150}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_schedules.go b/internal/cli/zz_generated_schedules.go index 2547d36..52ddbf0 100644 --- a/internal/cli/zz_generated_schedules.go +++ b/internal/cli/zz_generated_schedules.go @@ -170,7 +170,7 @@ API: POST /schedule/delete (scheduleDelete) Request fields: --schedule-ids []int (required) — Schedule IDs to operate on. `, - Args: requireArgs("schedule_ids"), + Args: requireBodyFieldOrArgs("schedule_ids", "schedule-ids"), Example: ` flashduty schedule delete --data '{"schedule_ids":[2001]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -371,7 +371,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - update_at (integer) (required) — Last update timestamp (Unix seconds). - update_by (integer) (required) — Last updater person ID. `, - Args: requireExactArg("schedule_id"), + Args: requireBodyFieldOrExactArg("schedule_id", "schedule-id"), Example: ` flashduty schedule info --data '{"end":1712086400,"schedule_id":2001,"start":1712000000}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -554,7 +554,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - update_at (integer) (required) — Last update timestamp (Unix seconds). - update_by (integer) (required) — Last updater person ID. `, - Args: requireArgs("schedule_ids"), + Args: requireBodyFieldOrArgs("schedule_ids", "schedule-ids"), Example: ` flashduty schedule infos --data '{"schedule_ids":[2001,2002,2003]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_sessions.go b/internal/cli/zz_generated_sessions.go index 995e99c..28b78e0 100644 --- a/internal/cli/zz_generated_sessions.go +++ b/internal/cli/zz_generated_sessions.go @@ -88,7 +88,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - reasoning_tokens (integer) — Total reasoning/thinking tokens. - updated_at (integer) — Unix timestamp in milliseconds of the last session update. `, - Args: requireExactArg("session_id"), + Args: requireBodyFieldOrExactArg("session_id", "session-id"), Example: ` flashduty safari session-get --data '{"num_recent_events":50,"session_id":"sess_f8oDvqiG64uur6sBNsTc4u"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -301,7 +301,7 @@ API: POST /safari/session/delete (session-write-delete) Request fields: --session-id string (required) — Target session ID. (≥1 chars) `, - Args: requireExactArg("session_id"), + Args: requireBodyFieldOrExactArg("session_id", "session-id"), Example: ` flashduty safari session-delete --data '{"session_id":"sess_f8oDvqiG64uur6sBNsTc4u"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_skills.go b/internal/cli/zz_generated_skills.go index 17e59c9..e10cf3f 100644 --- a/internal/cli/zz_generated_skills.go +++ b/internal/cli/zz_generated_skills.go @@ -23,7 +23,7 @@ API: POST /safari/skill/enable (skill-read-enable) Request fields: --skill-id string (required) — Target skill ID. `, - Args: requireExactArg("skill_id"), + Args: requireBodyFieldOrExactArg("skill_id", "skill-id"), Example: ` flashduty safari skill-enable --data '{"skill_id":"skill_8s7Hn2kLpQ3xYbVc4Wd2m"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -96,7 +96,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) (required) — Last update time. Unix timestamp in milliseconds. - version (string) — Skill version from the frontmatter. `, - Args: requireExactArg("skill_id"), + Args: requireBodyFieldOrExactArg("skill_id", "skill-id"), Example: ` flashduty safari skill-get --data '{"skill_id":"skill_8s7Hn2kLpQ3xYbVc4Wd2m"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -239,7 +239,7 @@ API: POST /safari/skill/delete (skill-write-delete) Request fields: --skill-id string (required) — Target skill ID. `, - Args: requireExactArg("skill_id"), + Args: requireBodyFieldOrExactArg("skill_id", "skill-id"), Example: ` flashduty safari skill-delete --data '{"skill_id":"skill_8s7Hn2kLpQ3xYbVc4Wd2m"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -287,7 +287,7 @@ API: POST /safari/skill/disable (skill-write-disable) Request fields: --skill-id string (required) — Target skill ID. `, - Args: requireExactArg("skill_id"), + Args: requireBodyFieldOrExactArg("skill_id", "skill-id"), Example: ` flashduty safari skill-disable --data '{"skill_id":"skill_8s7Hn2kLpQ3xYbVc4Wd2m"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -364,7 +364,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - updated_at (integer) (required) — Last update time. Unix timestamp in milliseconds. - version (string) — Skill version from the frontmatter. `, - Args: requireExactArg("skill_id"), + Args: requireBodyFieldOrExactArg("skill_id", "skill-id"), Example: ` flashduty safari skill-update --data '{"description":"Updated triage runbook.","skill_id":"skill_8s7Hn2kLpQ3xYbVc4Wd2m"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cli/zz_generated_status_pages.go b/internal/cli/zz_generated_status_pages.go index 421eb53..5ad6658 100644 --- a/internal/cli/zz_generated_status_pages.go +++ b/internal/cli/zz_generated_status_pages.go @@ -130,7 +130,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - status (string) — Event status after this update. Omitted when the update does not change the overall status. [investigating, identified, monitoring, resolved, scheduled, ongoing, completed] - update_id (string) (required) — Update ID. `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { body, err := genAssembleBody(dataJSON, func(body map[string]any) error { @@ -215,7 +215,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - change_id (integer) (required) — Newly created event ID. - change_name (string) (required) — Event title (echoed from the request). `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), Example: ` flashduty status-page change-create --data '{"description":"We are investigating degraded performance affecting the web console.","notify_subscribers":true,"page_id":5750613685214,"start_at_seconds":1712000000,"status":"investigating","title":"Web Console Degraded Performance","type":"incident","updates":[{"component_changes":[{"component_id":"01KC3GAZ6ZJE40H55GM31RPWZE","status":"degraded"}],"description":"We are currently investigating an issue affecting some users.","status":"investigating"}]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -495,7 +495,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - status (string) — Event status after this update. Omitted when the update does not change the overall status. [investigating, identified, monitoring, resolved, scheduled, ongoing, completed] - update_id (string) (required) — Update ID. `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { vStartAtSeconds, okStartAtSeconds, err := genParseTimeFlag(cmd, "start-at-seconds", fStartAtSeconds) @@ -918,7 +918,7 @@ Request fields: Response fields ('data' envelope is unwrapped — these fields are at the top level): - job_id (string) (required) — Migration job ID. Use this to poll status or request cancellation. `, - Args: requireExactArg("source_page_id"), + Args: requireBodyFieldOrExactArg("source_page_id", "source-page-id"), Example: ` flashduty status-page migrate-structure --data '{"api_key":"sk-stsp-xxxxxxxxxxxxxxxxxxxx","source_page_id":"abcdefghij"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -974,7 +974,7 @@ API: POST /status-page/migration/cancel (statusPageMigrationCancel) Request fields: --job-id string (required) — Migration job ID. `, - Args: requireExactArg("job_id"), + Args: requireBodyFieldOrExactArg("job_id", "job-id"), Example: ` flashduty status-page migration-cancel --data '{"job_id":"01KP0311872NVYFRRQ82FW0001"}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1048,7 +1048,7 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le - target_page_id (integer) (required) — Flashduty target status page ID. Set once the job produces one, or supplied up front for subscriber migration. - updated_at (integer) (required) — Last status update time, unix seconds. `, - Args: requireExactArg("job_id"), + Args: requireBodyFieldOrExactArg("job_id", "job-id"), RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { body, err := genAssembleBody(dataJSON, func(body map[string]any) error { @@ -1097,7 +1097,7 @@ Request fields: --component-ids []string — Optional component IDs to filter subscribers by. --page-id int (required) — Status page ID. `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), Example: ` flashduty status-page subscriber-export --data '{"page_id":5750613685214}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1157,7 +1157,7 @@ Request fields: - locale (string) — Preferred locale for notifications. Defaults to the request locale when omitted. - recipient (string) (required) — Email address (for public pages) or user ID (for internal pages). (≤255 chars) `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), Example: ` flashduty status-page subscriber-import --data '{"method":"email","page_id":5750613685214,"subscribers":[{"all":true,"locale":"en-US","recipient":"alice@example.com"},{"all":false,"component_ids":["01KC3GAZ6ZJE40H55GM31RPWZE"],"locale":"zh-CN","recipient":"bob@example.com"}]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { @@ -1237,7 +1237,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - recipient (string) (required) — Subscriber recipient: email address for public pages, user ID for internal pages. - total (integer) (required) — Total matching subscribers. `, - Args: requireExactArg("page_id"), + Args: requireBodyFieldOrExactArg("page_id", "page-id"), RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { body, err := genAssembleBody(dataJSON, func(body map[string]any) error { diff --git a/internal/cli/zz_generated_teams.go b/internal/cli/zz_generated_teams.go index 1147e42..a1c70f0 100644 --- a/internal/cli/zz_generated_teams.go +++ b/internal/cli/zz_generated_teams.go @@ -100,7 +100,7 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; - team_id (integer) - team_name (string) `, - Args: requireArgs("team_ids"), + Args: requireBodyFieldOrArgs("team_ids", "team-ids"), Example: ` flashduty team infos --data '{"team_ids":[1001,1002]}'`, RunE: func(cmd *cobra.Command, args []string) error { return runCommand(cmd, args, func(ctx *RunContext) error { diff --git a/internal/cmd/cligen/main.go b/internal/cmd/cligen/main.go index b2b993a..ab4ba76 100644 --- a/internal/cmd/cligen/main.go +++ b/internal/cmd/cligen/main.go @@ -921,18 +921,18 @@ func emitCmd(fn string, s service, o specOp, mi methodInfo) string { fmt.Fprintf(&b, "\t\tShort: %q,\n", oneLine(o.Summary)) fmt.Fprintf(&b, "\t\tLong: %s,\n", quoteMultiline(longHelp(o, scalars, complexFields, specByWire))) if hasPos { - // Scalar positionals use requireExactArg so extra arguments (e.g. - // `incident info id1 id2`) are rejected with a clear error instead of - // silently dropping id2. Array positionals use requireArgs (>=1) because - // they are variadic by design. Optional scalar positionals use optionalArg - // (0-or-1) because the op also accepts an alternative lookup flag. + // Required positionals use body-aware validators: the body field can come + // from a positional, its typed flag, or --data. Scalar positionals still + // reject extras rather than silently dropping id2. Optional scalar + // positionals use optionalArg because the op accepts an alternative lookup + // flag. switch { case pos.Array: - fmt.Fprintf(&b, "\t\tArgs: requireArgs(%q),\n", pos.Wire) + fmt.Fprintf(&b, "\t\tArgs: requireBodyFieldOrArgs(%q, %q),\n", pos.Wire, flagName(pos.Wire)) case pos.Optional: fmt.Fprintf(&b, "\t\tArgs: optionalArg(%q),\n", pos.Wire) default: - fmt.Fprintf(&b, "\t\tArgs: requireExactArg(%q),\n", pos.Wire) + fmt.Fprintf(&b, "\t\tArgs: requireBodyFieldOrExactArg(%q, %q),\n", pos.Wire, flagName(pos.Wire)) } } if ex := exampleHelp(o); ex != "" {