diff --git a/go.mod b/go.mod index 83d931b..54dc92f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/flashcatcloud/flashduty-cli go 1.26.0 require ( - github.com/flashcatcloud/go-flashduty v0.15.18 + github.com/flashcatcloud/go-flashduty v0.15.19 github.com/mattn/go-runewidth v0.0.30 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 diff --git a/go.sum b/go.sum index 03402c8..874059d 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY= github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/flashcatcloud/go-flashduty v0.15.18 h1:sa2x7FQVfaPPMs068OtpZuFMbCIoOtuGR1YGavnxuuk= -github.com/flashcatcloud/go-flashduty v0.15.18/go.mod h1:YpHiTYXR5NXBI/rGRZfUy537XMkhdCkwA8NW1QoRHwk= +github.com/flashcatcloud/go-flashduty v0.15.19 h1:QDb15Dssyb/q3n9UgCQHH7kNtuyyRw0Den6isoJ0gLU= +github.com/flashcatcloud/go-flashduty v0.15.19/go.mod h1:YpHiTYXR5NXBI/rGRZfUy537XMkhdCkwA8NW1QoRHwk= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk= diff --git a/internal/cli/zz_generated_channels.go b/internal/cli/zz_generated_channels.go index 2d36943..410559c 100644 --- a/internal/cli/zz_generated_channels.go +++ b/internal/cli/zz_generated_channels.go @@ -756,6 +756,65 @@ Response fields ('data' envelope is unwrapped — rows are nested under items[]; return cmd } +func genChannelsChannelEscalateRuleReorderCmd() *cobra.Command { + var dataJSON string + var fChannelID int64 + var fDragRuleID string + var fTargetRuleID string + cmd := &cobra.Command{ + Use: "escalate-rule-reorder", + Short: "Reorder escalation rules", + Long: `Reorder escalation rules. + +Change the evaluation order of a channel's escalation rules by moving one rule into another rule's slot. + +API: POST /channel/escalate/rule/reorder (channelEscalateRuleReorder) + +Request fields: + --channel-id int (required) — Owning channel ID; obtain it from 'POST /channel/list'. + --drag-rule-id string (required) — ID of the rule being dragged (24-character hex), as returned in 'rule_id' by the create or list endpoint. + --target-rule-id string (required) — ID of the rule whose slot the dragged rule moves into (24-character hex). +`, + 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 { + if cmd.Flags().Changed("channel-id") { + body["channel_id"] = fChannelID + } + if cmd.Flags().Changed("drag-rule-id") { + body["drag_rule_id"] = fDragRuleID + } + if cmd.Flags().Changed("target-rule-id") { + body["target_rule_id"] = fTargetRuleID + } + return nil + }) + if err != nil { + return err + } + req := new(flashduty.ReorderEscalationRulesRequest) + if err := genBindBody(ctx.Cmd.ErrOrStderr(), body, req); err != nil { + return err + } + resp, err := ctx.Client.Channels.ChannelEscalateRuleReorder(cmdContext(ctx.Cmd), req) + if err != nil { + return err + } + if resp != nil && len(resp.Raw) > 0 { + return ctx.WriteRaw(resp.Raw) + } + ctx.WriteResult("OK: POST /channel/escalate/rule/reorder") + return nil + }) + }, + } + cmd.Flags().Int64Var(&fChannelID, "channel-id", 0, "Owning channel ID; obtain it from 'POST /channel/list'. (required)") + cmd.Flags().StringVar(&fDragRuleID, "drag-rule-id", "", "ID of the rule being dragged (24-character hex), as returned in 'rule_id' by the create or list endpoint. (required)") + cmd.Flags().StringVar(&fTargetRuleID, "target-rule-id", "", "ID of the rule whose slot the dragged rule moves into (24-character hex). (required)") + cmd.Flags().StringVar(&dataJSON, "data", "", "Full request body as JSON; positional arguments and typed flags override its fields. Accepts inline JSON, or - to read stdin.") + return cmd +} + func genChannelsChannelEscalateRuleUpdateCmd() *cobra.Command { var dataJSON string var fAggrWindow int64 @@ -2722,6 +2781,7 @@ func registerGeneratedChannels(root *cobra.Command) { genAddLeaf(gChannel, genChannelsChannelEscalateRuleEnableCmd()) genAddLeaf(gChannel, genChannelsChannelEscalateRuleInfoCmd()) genAddLeaf(gChannel, genChannelsChannelEscalateRuleListCmd()) + genAddLeaf(gChannel, genChannelsChannelEscalateRuleReorderCmd()) genAddLeaf(gChannel, genChannelsChannelEscalateRuleUpdateCmd()) genAddLeaf(gChannel, genChannelsChannelInfoCmd()) genAddLeaf(gChannel, genChannelsChannelInfosCmd()) diff --git a/internal/cli/zz_generated_manifest.go b/internal/cli/zz_generated_manifest.go index f92b040..1a00829 100644 --- a/internal/cli/zz_generated_manifest.go +++ b/internal/cli/zz_generated_manifest.go @@ -56,6 +56,7 @@ var generatedOpIDs = []string{ "channelEscalateRuleEnable", "channelEscalateRuleInfo", "channelEscalateRuleList", + "channelEscalateRuleReorder", "channelEscalateRuleUpdate", "channelInfo", "channelInfos",