You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Export the filtered incident analytics list as a CSV file (to stdout; redirect with '> file.csv'). CSV headers and formatted values use the request locale, falling back to the member locale and then the account locale. --start-time/--end-time take Unix seconds.
191
+
192
+
The export endpoint returns a one-shot CSV and caps its row count server-side, so a wide window may come back truncated. After writing, this command compares the CSV data-row count against the incident-list total for the same filter: on a shortfall the partial CSV is still written, a 'rows=N' line (the actual written data-row count) goes to stderr, and the command exits non-zero stating written vs total — narrow the window and retry.
193
+
194
+
API: POST /insight/incident/export (insightIncidentExport)
returnfmt.Errorf("insight incident-export: wrote %d rows but cannot verify completeness against /insight/incident/list: %w", rows, err)
307
+
}
308
+
ifint64(rows) <total {
309
+
returnfmt.Errorf("insight incident-export: incomplete export — wrote %d of %d incidents matching the filter; narrow the time window (--start-time/--end-time) and retry", rows, total)
310
+
}
311
+
returnnil
312
+
})
313
+
},
314
+
}
315
+
cmd.Flags().BoolVar(&fAsc, "asc", false, "Request field ")
316
+
cmd.Flags().IntSliceVar(&fChannelIDs, "channel-ids", nil, "Request field ")
317
+
cmd.Flags().BoolVar(&fDescriptionHTMLToText, "description-html-to-text", false, "Request field ")
318
+
cmd.Flags().Int64Var(&fEndTime, "end-time", 0, "Request field ")
319
+
cmd.Flags().StringSliceVar(&fExportFields, "export-fields", nil, "Request field ")
320
+
cmd.Flags().StringSliceVar(&fIncidentIDs, "incident-ids", nil, "Request field ")
321
+
cmd.Flags().BoolVar(&fIncludeEverMuted, "include-ever-muted", false, "Request field ")
322
+
cmd.Flags().BoolVar(&fIsMyTeam, "is-my-team", false, "Request field ")
323
+
cmd.Flags().StringVar(&fOrderby, "orderby", "", "Request field ")
324
+
cmd.Flags().StringVar(&fQuery, "query", "", "Request field ")
325
+
cmd.Flags().IntSliceVar(&fResponderIDs, "responder-ids", nil, "Request field ")
326
+
cmd.Flags().Int64Var(&fSecondsToAckFrom, "seconds-to-ack-from", 0, "Request field ")
327
+
cmd.Flags().Int64Var(&fSecondsToAckTo, "seconds-to-ack-to", 0, "Request field ")
328
+
cmd.Flags().Int64Var(&fSecondsToCloseFrom, "seconds-to-close-from", 0, "Request field ")
329
+
cmd.Flags().Int64Var(&fSecondsToCloseTo, "seconds-to-close-to", 0, "Request field ")
330
+
cmd.Flags().StringSliceVar(&fSeverities, "severities", nil, "Request field ")
331
+
cmd.Flags().Int64Var(&fStartTime, "start-time", 0, "Request field ")
332
+
cmd.Flags().IntSliceVar(&fTeamIDs, "team-ids", nil, "Request field ")
333
+
cmd.Flags().StringVar(&fTimeZone, "time-zone", "", "Request field ")
334
+
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.")
335
+
returncmd
336
+
}
337
+
338
+
// countCSVDataRows counts the data records in an exported CSV body — every
339
+
// record except the header row. encoding/csv handles quoted fields with
340
+
// embedded newlines, which a naive line count would over-count.
341
+
funccountCSVDataRows(raw []byte) (int, error) {
342
+
r:=csv.NewReader(bytes.NewReader(raw))
343
+
r.FieldsPerRecord=-1
344
+
n:=0
345
+
for {
346
+
if_, err:=r.Read(); err==io.EOF {
347
+
break
348
+
} elseiferr!=nil {
349
+
return0, err
350
+
}
351
+
n++
352
+
}
353
+
ifn==0 {
354
+
return0, nil
355
+
}
356
+
returnn-1, nil
357
+
}
358
+
359
+
// insightIncidentTotal returns the number of incidents matching the export
360
+
// filter, per the incident-list endpoint — the authoritative total an export
361
+
// is verified against. Only the total is needed, so a single 1-item page is
0 commit comments