@@ -12,16 +12,21 @@ const defaultQueryLimit = 20
1212
1313// ListIncidentsInput contains parameters for listing incidents
1414type ListIncidentsInput struct {
15- IncidentIDs []string // Direct lookup by IDs (if set, other filters are ignored)
16- Progress string // Filter: Triggered, Processing, Closed (comma-separated for multiple)
17- Severity string // Filter: Info, Warning, Critical
18- ChannelID int64 // Filter by collaboration space ID
19- StartTime int64 // Unix timestamp (seconds), required if no IncidentIDs
20- EndTime int64 // Unix timestamp (seconds), required if no IncidentIDs
21- Title string // Keyword search in incident title
22- Limit int // Max results (default 20, max 100)
23- Page int // Page number (default 1)
24- IncludeAlerts bool // Whether to include alerts preview (default true)
15+ IncidentIDs []string // Direct lookup by IDs (if set, other filters are ignored)
16+ Progress string // Filter: Triggered, Processing, Closed (comma-separated for multiple)
17+ Severity string // Filter: Info, Warning, Critical
18+ ChannelIDs []int64 // Filter by collaboration space IDs
19+ // Deprecated: use ChannelIDs. If both are set, ChannelIDs wins; otherwise
20+ // a non-zero ChannelID is wrapped into a single-element ChannelIDs slice.
21+ // The backend /incident/list endpoint expects channel_ids (array) — singular
22+ // channel_id is silently ignored.
23+ ChannelID int64
24+ StartTime int64 // Unix timestamp (seconds), required if no IncidentIDs
25+ EndTime int64 // Unix timestamp (seconds), required if no IncidentIDs
26+ Title string
27+ Limit int
28+ Page int
29+ IncludeAlerts bool
2530}
2631
2732// ListIncidentsOutput contains the result of listing incidents
@@ -50,7 +55,7 @@ func (c *Client) ListIncidents(ctx context.Context, input *ListIncidentsInput) (
5055 if page <= 0 {
5156 page = 1
5257 }
53- rawIncidents , err = c .fetchIncidentsByFilters (ctx , input .Progress , input .Severity , input .ChannelID , input .StartTime , input .EndTime , input .Title , limit , page )
58+ rawIncidents , err = c .fetchIncidentsByFilters (ctx , input .Progress , input .Severity , mergeChannelIDs ( input .ChannelIDs , input . ChannelID ) , input .StartTime , input .EndTime , input .Title , limit , page )
5459 }
5560
5661 if err != nil {
@@ -441,7 +446,7 @@ func (c *Client) fetchIncidentsByIDs(ctx context.Context, incidentIDs []string)
441446}
442447
443448// fetchIncidentsByFilters fetches incidents by filters
444- func (c * Client ) fetchIncidentsByFilters (ctx context.Context , progress , severity string , channelID , startTime , endTime int64 , title string , limit , page int ) ([]RawIncident , error ) {
449+ func (c * Client ) fetchIncidentsByFilters (ctx context.Context , progress , severity string , channelIDs [] int64 , startTime , endTime int64 , title string , limit , page int ) ([]RawIncident , error ) {
445450 requestBody := map [string ]any {
446451 "p" : page ,
447452 "limit" : limit ,
@@ -455,8 +460,8 @@ func (c *Client) fetchIncidentsByFilters(ctx context.Context, progress, severity
455460 if severity != "" {
456461 requestBody ["incident_severity" ] = severity
457462 }
458- if channelID > 0 {
459- requestBody ["channel_id " ] = channelID
463+ if len ( channelIDs ) > 0 {
464+ requestBody ["channel_ids " ] = channelIDs
460465 }
461466 if title != "" {
462467 requestBody ["title" ] = title
0 commit comments