66 "strconv"
77 "strings"
88
9- gflashduty "github.com/flashcatcloud/go-flashduty"
9+ "github.com/flashcatcloud/go-flashduty"
1010 "github.com/spf13/cobra"
1111
1212 "github.com/flashcatcloud/flashduty-cli/internal/output"
@@ -35,7 +35,7 @@ func newAlertListCmd() *cobra.Command {
3535 Use : "list" ,
3636 Short : "List alerts" ,
3737 RunE : func (cmd * cobra.Command , args []string ) error {
38- return runGFCommand (cmd , args , func (ctx * RunContext ) error {
38+ return runCommand (cmd , args , func (ctx * RunContext ) error {
3939 if active && recovered {
4040 return fmt .Errorf ("--active and --recovered are mutually exclusive" )
4141 }
@@ -49,7 +49,7 @@ func newAlertListCmd() *cobra.Command {
4949 return fmt .Errorf ("invalid --until: %w" , err )
5050 }
5151
52- req := & gflashduty .AlertListRequest {
52+ req := & flashduty .AlertListRequest {
5353 StartTime : startTime ,
5454 EndTime : endTime ,
5555 AlertSeverity : severity ,
@@ -60,13 +60,13 @@ func newAlertListCmd() *cobra.Command {
6060 // Preserve legacy semantics: --active sends is_active=true,
6161 // --recovered sends is_active=false, neither omits the filter.
6262 if active {
63- req .IsActive = gflashduty .Bool (true )
63+ req .IsActive = flashduty .Bool (true )
6464 } else if recovered {
65- req .IsActive = gflashduty .Bool (false )
65+ req .IsActive = flashduty .Bool (false )
6666 }
6767
6868 if muted {
69- req .EverMuted = gflashduty .Bool (true )
69+ req .EverMuted = flashduty .Bool (true )
7070 }
7171
7272 if channel != "" {
@@ -77,19 +77,19 @@ func newAlertListCmd() *cobra.Command {
7777 req .ChannelIDs = channelIDs
7878 }
7979
80- result , _ , err := ctx .GFClient .Alerts .ReadList (cmdContext (ctx .Cmd ), req )
80+ result , _ , err := ctx .Client .Alerts .ReadList (cmdContext (ctx .Cmd ), req )
8181 if err != nil {
8282 return err
8383 }
8484
8585 cols := []output.Column {
86- {Header : "ID" , Field : func (v any ) string { return v .(gflashduty .AlertItem ).AlertID }},
87- {Header : "TITLE" , MaxWidth : 50 , Field : func (v any ) string { return v .(gflashduty .AlertItem ).Title }},
88- {Header : "SEVERITY" , Field : func (v any ) string { return v .(gflashduty .AlertItem ).AlertSeverity }},
89- {Header : "STATUS" , Field : func (v any ) string { return v .(gflashduty .AlertItem ).AlertStatus }},
90- {Header : "EVENTS" , Field : func (v any ) string { return fmt .Sprintf ("%d" , v .(gflashduty .AlertItem ).EventCnt ) }},
91- {Header : "CHANNEL" , Field : func (v any ) string { return v .(gflashduty .AlertItem ).ChannelName }},
92- {Header : "STARTED" , Field : func (v any ) string { return output .FormatTime (v .(gflashduty .AlertItem ).StartTime ) }},
86+ {Header : "ID" , Field : func (v any ) string { return v .(flashduty .AlertItem ).AlertID }},
87+ {Header : "TITLE" , MaxWidth : 50 , Field : func (v any ) string { return v .(flashduty .AlertItem ).Title }},
88+ {Header : "SEVERITY" , Field : func (v any ) string { return v .(flashduty .AlertItem ).AlertSeverity }},
89+ {Header : "STATUS" , Field : func (v any ) string { return v .(flashduty .AlertItem ).AlertStatus }},
90+ {Header : "EVENTS" , Field : func (v any ) string { return fmt .Sprintf ("%d" , v .(flashduty .AlertItem ).EventCnt ) }},
91+ {Header : "CHANNEL" , Field : func (v any ) string { return v .(flashduty .AlertItem ).ChannelName }},
92+ {Header : "STARTED" , Field : func (v any ) string { return output .FormatTime (v .(flashduty .AlertItem ).StartTime ) }},
9393 }
9494
9595 return ctx .PrintList (result .Items , cols , len (result .Items ), page , int (result .Total ))
@@ -116,8 +116,8 @@ func newAlertGetCmd() *cobra.Command {
116116 Short : "Get alert detail" ,
117117 Args : requireArgs ("alert_id" ),
118118 RunE : func (cmd * cobra.Command , args []string ) error {
119- return runGFCommand (cmd , args , func (ctx * RunContext ) error {
120- result , _ , err := ctx .GFClient .Alerts .ReadInfo (cmdContext (ctx .Cmd ), & gflashduty .AlertInfoRequest {
119+ return runCommand (cmd , args , func (ctx * RunContext ) error {
120+ result , _ , err := ctx .Client .Alerts .ReadInfo (cmdContext (ctx .Cmd ), & flashduty .AlertInfoRequest {
121121 AlertID : ctx .Args [0 ],
122122 })
123123 if err != nil {
@@ -135,7 +135,7 @@ func newAlertGetCmd() *cobra.Command {
135135 }
136136}
137137
138- func printAlertDetail (w io.Writer , a * gflashduty .AlertItem ) {
138+ func printAlertDetail (w io.Writer , a * flashduty .AlertItem ) {
139139 if a == nil {
140140 return
141141 }
@@ -178,8 +178,8 @@ func newAlertEventsCmd() *cobra.Command {
178178 Short : "List alert events" ,
179179 Args : requireArgs ("alert_id" ),
180180 RunE : func (cmd * cobra.Command , args []string ) error {
181- return runGFCommand (cmd , args , func (ctx * RunContext ) error {
182- result , _ , err := ctx .GFClient .Alerts .ReadEventList (cmdContext (ctx .Cmd ), & gflashduty .AlertEventListRequest {
181+ return runCommand (cmd , args , func (ctx * RunContext ) error {
182+ result , _ , err := ctx .Client .Alerts .ReadEventList (cmdContext (ctx .Cmd ), & flashduty .AlertEventListRequest {
183183 AlertID : ctx .Args [0 ],
184184 })
185185 if err != nil {
@@ -192,11 +192,11 @@ func newAlertEventsCmd() *cobra.Command {
192192 }
193193
194194 cols := []output.Column {
195- {Header : "EVENT_ID" , Field : func (v any ) string { return v .(gflashduty .AlertEventItem ).EventID }},
196- {Header : "SEVERITY" , Field : func (v any ) string { return v .(gflashduty .AlertEventItem ).EventSeverity }},
197- {Header : "STATUS" , Field : func (v any ) string { return v .(gflashduty .AlertEventItem ).EventStatus }},
198- {Header : "TIME" , Field : func (v any ) string { return output .FormatTime (v .(gflashduty .AlertEventItem ).EventTime ) }},
199- {Header : "TITLE" , MaxWidth : 50 , Field : func (v any ) string { return v .(gflashduty .AlertEventItem ).Title }},
195+ {Header : "EVENT_ID" , Field : func (v any ) string { return v .(flashduty .AlertEventItem ).EventID }},
196+ {Header : "SEVERITY" , Field : func (v any ) string { return v .(flashduty .AlertEventItem ).EventSeverity }},
197+ {Header : "STATUS" , Field : func (v any ) string { return v .(flashduty .AlertEventItem ).EventStatus }},
198+ {Header : "TIME" , Field : func (v any ) string { return output .FormatTime (v .(flashduty .AlertEventItem ).EventTime ) }},
199+ {Header : "TITLE" , MaxWidth : 50 , Field : func (v any ) string { return v .(flashduty .AlertEventItem ).Title }},
200200 }
201201
202202 return ctx .PrintTotal (result .Items , cols , len (result .Items ))
@@ -213,12 +213,12 @@ func newAlertTimelineCmd() *cobra.Command {
213213 Short : "View alert timeline" ,
214214 Args : requireArgs ("alert_id" ),
215215 RunE : func (cmd * cobra.Command , args []string ) error {
216- return runGFCommand (cmd , args , func (ctx * RunContext ) error {
217- req := & gflashduty .AlertFeedRequest {AlertID : ctx .Args [0 ]}
216+ return runCommand (cmd , args , func (ctx * RunContext ) error {
217+ req := & flashduty .AlertFeedRequest {AlertID : ctx .Args [0 ]}
218218 req .Limit = limit
219219 req .Page = page
220220
221- result , _ , err := ctx .GFClient .Alerts .ReadFeed (cmdContext (ctx .Cmd ), req )
221+ result , _ , err := ctx .Client .Alerts .ReadFeed (cmdContext (ctx .Cmd ), req )
222222 if err != nil {
223223 return err
224224 }
@@ -236,10 +236,10 @@ func newAlertTimelineCmd() *cobra.Command {
236236 nameByID := resolveAlertFeedOperators (ctx , result .Items )
237237
238238 cols := []output.Column {
239- {Header : "TIME" , Field : func (v any ) string { return output .FormatTime (v .(gflashduty .FeedItem ).CreatedAt ) }},
240- {Header : "TYPE" , Field : func (v any ) string { return string (v .(gflashduty .FeedItem ).Type ) }},
239+ {Header : "TIME" , Field : func (v any ) string { return output .FormatTime (v .(flashduty .FeedItem ).CreatedAt ) }},
240+ {Header : "TYPE" , Field : func (v any ) string { return string (v .(flashduty .FeedItem ).Type ) }},
241241 {Header : "OPERATOR" , Field : func (v any ) string {
242- it := v .(gflashduty .FeedItem )
242+ it := v .(flashduty .FeedItem )
243243 if it .CreatorID == 0 {
244244 return "system"
245245 }
@@ -249,7 +249,7 @@ func newAlertTimelineCmd() *cobra.Command {
249249 return strconv .FormatInt (it .CreatorID , 10 )
250250 }},
251251 {Header : "DETAIL" , MaxWidth : 80 , Field : func (v any ) string {
252- d := v .(gflashduty .FeedItem ).Detail
252+ d := v .(flashduty .FeedItem ).Detail
253253 if d == nil {
254254 return "-"
255255 }
@@ -272,7 +272,7 @@ func newAlertTimelineCmd() *cobra.Command {
272272// alert-feed items to display names via /person/infos, replicating the
273273// operator-name enrichment the legacy SDK did server-side. Best-effort: a
274274// lookup failure yields a nil map and callers fall back to the numeric ID.
275- func resolveAlertFeedOperators (rc * RunContext , items []gflashduty .FeedItem ) map [int64 ]string {
275+ func resolveAlertFeedOperators (rc * RunContext , items []flashduty .FeedItem ) map [int64 ]string {
276276 seen := make (map [int64 ]struct {}, len (items ))
277277 ids := make ([]uint64 , 0 , len (items ))
278278 for _ , it := range items {
@@ -288,7 +288,7 @@ func resolveAlertFeedOperators(rc *RunContext, items []gflashduty.FeedItem) map[
288288 if len (ids ) == 0 {
289289 return nil
290290 }
291- resp , _ , err := rc .GFClient .Members .PersonInfos (cmdContext (rc .Cmd ), & gflashduty .PersonInfosRequest {PersonIDs : ids })
291+ resp , _ , err := rc .Client .Members .PersonInfos (cmdContext (rc .Cmd ), & flashduty .PersonInfosRequest {PersonIDs : ids })
292292 if err != nil || resp == nil {
293293 return nil
294294 }
@@ -307,8 +307,8 @@ func newAlertMergeCmd() *cobra.Command {
307307 Short : "Merge alerts into an incident" ,
308308 Args : requireArgs ("alert_id" ),
309309 RunE : func (cmd * cobra.Command , args []string ) error {
310- return runGFCommand (cmd , args , func (ctx * RunContext ) error {
311- if _ , err := ctx .GFClient .Alerts .WriteMerge (cmdContext (ctx .Cmd ), & gflashduty .AlertMergeRequest {
310+ return runCommand (cmd , args , func (ctx * RunContext ) error {
311+ if _ , err := ctx .Client .Alerts .WriteMerge (cmdContext (ctx .Cmd ), & flashduty .AlertMergeRequest {
312312 AlertIDs : ctx .Args ,
313313 IncidentID : incidentID ,
314314 Comment : comment ,
0 commit comments