flashduty

package module
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 15 Imported by: 0

README

Flashduty SDK

English | 中文

License Go Reference CI Go Report Card

Go SDK for the Flashduty API. Provides typed methods for incident management, on-call scheduling, status pages, notification templates, and more.

Installation

go get github.com/flashcatcloud/flashduty-sdk

Requires Go 1.24+.

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	flashduty "github.com/flashcatcloud/flashduty-sdk"
)

func main() {
	client, err := flashduty.NewClient("your-app-key")
	if err != nil {
		log.Fatal(err)
	}

	incidents, err := client.ListIncidents(context.Background(), &flashduty.ListIncidentsInput{
		Progress:  "Triggered",
		StartTime: 1710000000,
		EndTime:   1710086400,
	})
	if err != nil {
		log.Fatal(err)
	}

	for _, inc := range incidents.Incidents {
		fmt.Printf("[%s] %s (channel: %s)\n", inc.Severity, inc.Title, inc.ChannelName)
	}
}

Client Options

client, err := flashduty.NewClient("your-app-key",
	flashduty.WithBaseURL("https://custom-api.example.com"),
	flashduty.WithTimeout(10 * time.Second),
	flashduty.WithUserAgent("my-app/1.0"),
	flashduty.WithHTTPClient(customHTTPClient),
	flashduty.WithLogger(myLogger),
	flashduty.WithRequestHeaders(staticHeaders),
	flashduty.WithRequestHook(func(req *http.Request) {
		// Inject per-request headers (e.g., W3C Trace Context)
		req.Header.Set("traceparent", traceID)
	}),
)
Option Default Description
WithBaseURL https://api.flashcat.cloud API base URL
WithTimeout 30s HTTP client timeout
WithUserAgent flashduty-go-sdk User-Agent header
WithHTTPClient Default http.Client Custom HTTP client
WithLogger slog-based logger Custom logger implementing Logger interface
WithRequestHeaders none Static headers included in every request
WithRequestHook none Callback invoked on every outgoing request before it is sent
Dynamic User-Agent

The User-Agent can be updated after client creation (e.g., per-session):

client.SetUserAgent("my-app/2.0 (client-name/1.2)")

Logger Interface

The SDK uses a pluggable logger. The default implementation wraps log/slog.

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
}

To adapt logrus or other backends:

type logrusAdapter struct{ *logrus.Logger }

func (a *logrusAdapter) Info(msg string, kv ...any)  { a.WithFields(kvToFields(kv)).Info(msg) }
func (a *logrusAdapter) Warn(msg string, kv ...any)  { a.WithFields(kvToFields(kv)).Warn(msg) }
func (a *logrusAdapter) Error(msg string, kv ...any) { a.WithFields(kvToFields(kv)).Error(msg) }
func (a *logrusAdapter) Debug(msg string, kv ...any) { a.WithFields(kvToFields(kv)).Debug(msg) }

func kvToFields(kv []any) logrus.Fields {
	fields := make(logrus.Fields, len(kv)/2)
	for i := 0; i+1 < len(kv); i += 2 {
		if key, ok := kv[i].(string); ok {
			fields[key] = kv[i+1]
		}
	}
	return fields
}

API Reference

Incidents
// List incidents by IDs or filters (time-based queries require StartTime and EndTime)
client.ListIncidents(ctx, &ListIncidentsInput{...}) (*ListIncidentsOutput, error)

// Get timeline events for one or more incidents
client.GetIncidentTimelines(ctx, incidentIDs) ([]IncidentTimelineOutput, error)

// Get alerts for one or more incidents
client.ListIncidentAlerts(ctx, incidentIDs, limit) ([]IncidentAlertsOutput, error)

// Find similar historical incidents
client.ListSimilarIncidents(ctx, incidentID, limit) (*ListIncidentsOutput, error)

// Create a new incident
client.CreateIncident(ctx, &CreateIncidentInput{...}) (any, error)

// Update incident fields (title, description, severity, custom fields)
client.UpdateIncident(ctx, &UpdateIncidentInput{...}) ([]string, error)

// Acknowledge incidents
client.AckIncidents(ctx, incidentIDs) error

// Close (resolve) incidents
client.CloseIncidents(ctx, incidentIDs) error
Members
// List members by person IDs, name, or email
client.ListMembers(ctx, &ListMembersInput{...}) (*ListMembersOutput, error)
Teams
// List teams by team IDs or name
client.ListTeams(ctx, &ListTeamsInput{...}) (*ListTeamsOutput, error)
Channels (Collaboration Spaces)
// List channels by IDs or name (name filtering is case-insensitive substring match)
client.ListChannels(ctx, &ListChannelsInput{...}) (*ListChannelsOutput, error)
Escalation Rules
// List escalation rules for a channel (enriched with person/team/schedule names)
client.ListEscalationRules(ctx, channelID) (*ListEscalationRulesOutput, error)
Custom Fields
// List custom field definitions, optionally filtered by IDs or name
client.ListFields(ctx, &ListFieldsInput{...}) (*ListFieldsOutput, error)
Changes
// List change records (deployments, configurations) with enriched names
client.ListChanges(ctx, &ListChangesInput{...}) (*ListChangesOutput, error)
Status Pages
// List status pages, optionally filtered by page IDs
client.ListStatusPages(ctx, pageIDs) ([]StatusPage, error)

// List active incidents or maintenances on a status page
client.ListStatusChanges(ctx, &ListStatusChangesInput{...}) (*ListStatusChangesOutput, error)

// Create an incident on a status page
client.CreateStatusIncident(ctx, &CreateStatusIncidentInput{...}) (any, error)

// Add a timeline update to a status page incident or maintenance
client.CreateChangeTimeline(ctx, &CreateChangeTimelineInput{...}) error
Templates
// Fetch the preset (default) notification template for a channel
client.GetPresetTemplate(ctx, &GetPresetTemplateInput{...}) (*GetPresetTemplateOutput, error)

// Validate and preview a notification template with size-limit checks
client.ValidateTemplate(ctx, &ValidateTemplateInput{...}) (*ValidateTemplateOutput, error)
Static Template Data

These package-level functions return compiled-in reference data for template authoring:

// Available template variables (40 variables across 7 categories)
flashduty.TemplateVariables() []TemplateVariable

// Custom Flashduty template functions (19 functions)
flashduty.TemplateCustomFunctions() []TemplateFunction

// Commonly used Sprig template functions (19 functions)
flashduty.TemplateSprigFunctions() []TemplateFunction

// Valid notification channel identifiers (13 channels)
flashduty.ChannelEnumValues() []string

Supported channels: dingtalk, dingtalk_app, feishu, feishu_app, wecom, wecom_app, slack, slack_app, telegram, teams_app, email, sms, zoom.

Channel size limits and channel-to-field mappings are available via flashduty.ChannelSizeLimits and flashduty.TemplateChannels.

Note: Static template data is compiled into the SDK. Platform-side additions require an SDK release.

Data Enrichment

Most query methods automatically enrich raw API data with human-readable names. For example, ListIncidents resolves CreatorID to CreatorName, ChannelID to ChannelName, and responder person IDs to names and emails.

Enrichment uses concurrent batch fetches via errgroup. For methods like ListChanges and ListChannels, enrichment failures are best-effort -- the primary data is still returned even if name resolution fails.

Output Formats

The SDK supports JSON and TOON (Token-Oriented Object Notation) serialization:

data, err := flashduty.Marshal(incidents, flashduty.OutputFormatJSON)
data, err := flashduty.Marshal(incidents, flashduty.OutputFormatTOON)

format := flashduty.ParseOutputFormat("toon") // defaults to JSON for unknown values

Error Handling

API errors are returned as *DutyError which implements the error interface:

incidents, err := client.ListIncidents(ctx, input)
if err != nil {
	var dutyErr *flashduty.DutyError
	if errors.As(err, &dutyErr) {
		fmt.Printf("API error [%s]: %s\n", dutyErr.Code, dutyErr.Message)
	}
}

Development

Requires Go 1.24+ and golangci-lint v2.

go test -race ./...   # Run tests with race detection
golangci-lint run     # Run the linter

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request, and note our Code of Conduct.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const PresetTemplateID = "6321aad26c12104586a88916"

PresetTemplateID is the fixed MongoDB ObjectID for the system preset template

Variables

View Source
var ChannelSizeLimits = map[string]int{
	"dingtalk":     4000,
	"dingtalk_app": 0,
	"feishu":       4000,
	"feishu_app":   0,
	"wecom":        4000,
	"wecom_app":    0,
	"slack":        15000,
	"slack_app":    15000,
	"telegram":     4096,
	"teams_app":    28000,
	"email":        0,
	"sms":          0,
	"zoom":         0,
}

ChannelSizeLimits defines the maximum rendered size per channel. 0 means no enforced limit.

View Source
var TemplateChannels = map[string]string{
	"dingtalk":     "dingtalk",
	"dingtalk_app": "dingtalk_app",
	"feishu":       "feishu",
	"feishu_app":   "feishu_app",
	"wecom":        "wecom",
	"wecom_app":    "wecom_app",
	"slack":        "slack",
	"slack_app":    "slack_app",
	"telegram":     "telegram",
	"teams_app":    "teams_app",
	"email":        "email",
	"sms":          "sms",
	"zoom":         "zoom",
}

TemplateChannels maps channel identifiers to TemplateDoc field names.

Functions

func ChannelEnumValues

func ChannelEnumValues() []string

ChannelEnumValues returns all valid notification channel identifiers.

func Marshal

func Marshal(v any, format OutputFormat) ([]byte, error)

Marshal serializes the given value using the specified format

Types

type AccountInfo

type AccountInfo struct {
	AccountID   uint64    `json:"account_id"`
	AccountName string    `json:"account_name"`
	Domain      string    `json:"domain"`
	Email       string    `json:"email"`
	Phone       string    `json:"phone,omitempty"`
	CountryCode string    `json:"country_code,omitempty"`
	Avatar      string    `json:"avatar,omitempty"`
	Locale      string    `json:"locale,omitempty"`
	TimeZone    string    `json:"time_zone,omitempty"`
	CreatedAt   Timestamp `json:"created_at"`
}

AccountInfo contains account details returned by the account info API.

type Alert

type Alert struct {
	AlertID         string            `json:"alert_id" toon:"alert_id"`
	ChannelID       int64             `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName     string            `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	IntegrationID   int64             `json:"integration_id,omitempty" toon:"integration_id,omitempty"`
	IntegrationName string            `json:"integration_name,omitempty" toon:"integration_name,omitempty"`
	IntegrationType string            `json:"integration_type,omitempty" toon:"integration_type,omitempty"`
	Title           string            `json:"title" toon:"title"`
	Description     string            `json:"description,omitempty" toon:"description,omitempty"`
	AlertKey        string            `json:"alert_key,omitempty" toon:"alert_key,omitempty"`
	AlertSeverity   string            `json:"alert_severity" toon:"alert_severity"`
	AlertStatus     string            `json:"alert_status" toon:"alert_status"`
	StartTime       Timestamp         `json:"start_time" toon:"start_time"`
	LastTime        Timestamp         `json:"last_time,omitempty" toon:"last_time,omitempty"`
	EndTime         Timestamp         `json:"end_time,omitempty" toon:"end_time,omitempty"`
	EventCnt        int               `json:"event_cnt,omitempty" toon:"event_cnt,omitempty"`
	EverMuted       bool              `json:"ever_muted,omitempty" toon:"ever_muted,omitempty"`
	Labels          map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
	Incident        *AlertIncident    `json:"incident,omitempty" toon:"incident,omitempty"`
}

Alert represents a deduplicated alert entity (Layer 1)

type AlertCondition

type AlertCondition struct {
	Key  string   `json:"key" toon:"key"`
	Oper string   `json:"oper" toon:"oper"`
	Vals []string `json:"vals" toon:"vals"`
}

AlertCondition represents a single filter condition

type AlertEvent

type AlertEvent struct {
	EventID         string            `json:"event_id" toon:"event_id"`
	AlertID         string            `json:"alert_id,omitempty" toon:"alert_id,omitempty"`
	AccountID       int64             `json:"account_id,omitempty" toon:"account_id,omitempty"`
	ChannelID       int64             `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	IntegrationID   int64             `json:"integration_id,omitempty" toon:"integration_id,omitempty"`
	IntegrationType string            `json:"integration_type,omitempty" toon:"integration_type,omitempty"`
	Title           string            `json:"title,omitempty" toon:"title,omitempty"`
	Description     string            `json:"description,omitempty" toon:"description,omitempty"`
	EventSeverity   string            `json:"event_severity" toon:"event_severity"`
	EventStatus     string            `json:"event_status" toon:"event_status"`
	EventTime       Timestamp         `json:"event_time" toon:"event_time"`
	Labels          map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
	CreatedAt       Timestamp         `json:"created_at,omitempty" toon:"created_at,omitempty"`
	UpdatedAt       Timestamp         `json:"updated_at,omitempty" toon:"updated_at,omitempty"`
}

AlertEvent represents a raw alert event

type AlertFilterGroup

type AlertFilterGroup []AlertCondition

AlertFilterGroup represents AND conditions within an OR group

type AlertFilters

type AlertFilters []AlertFilterGroup

AlertFilters represents alert filter conditions as OR groups of AND conditions

type AlertIncident

type AlertIncident struct {
	IncidentID string `json:"incident_id" toon:"incident_id"`
	Title      string `json:"title,omitempty" toon:"title,omitempty"`
	Progress   string `json:"progress,omitempty" toon:"progress,omitempty"`
}

AlertIncident is the parent incident reference embedded in an alert

type AlertPreview

type AlertPreview struct {
	AlertID   string            `json:"alert_id" toon:"alert_id"`
	Title     string            `json:"title" toon:"title"`
	Severity  string            `json:"severity" toon:"severity"`
	Status    string            `json:"status" toon:"status"`
	StartTime Timestamp         `json:"start_time" toon:"start_time"`
	Labels    map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
}

AlertPreview represents a preview of an alert

type AssignedTo

type AssignedTo struct {
	PersonIDs        []int64   `json:"person_ids,omitempty" toon:"person_ids,omitempty"`
	EscalateRuleID   string    `json:"escalate_rule_id,omitempty" toon:"escalate_rule_id,omitempty"`
	LayerIdx         int       `json:"layer_idx,omitempty" toon:"layer_idx,omitempty"`
	Type             string    `json:"type,omitempty" toon:"type,omitempty"`
	Emails           []string  `json:"emails,omitempty" toon:"emails,omitempty"`
	EscalateRuleName string    `json:"escalate_rule_name,omitempty" toon:"escalate_rule_name,omitempty"`
	AssignedAt       Timestamp `json:"assigned_at,omitempty" toon:"assigned_at,omitempty"`
	ID               string    `json:"id,omitempty" toon:"id,omitempty"`
}

AssignedTo represents the current assignment target for an incident.

type AuditLogParam

type AuditLogParam struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

AuditLogParam represents a single path parameter captured in an audit log entry.

type AuditLogRecord

type AuditLogRecord struct {
	CreatedAt     TimestampMilli  `json:"created_at"`
	AccountID     int64           `json:"account_id"`
	MemberID      int64           `json:"member_id"`
	MemberName    string          `json:"member_name"`
	RequestID     string          `json:"request_id"`
	IP            string          `json:"ip"`
	Operation     string          `json:"operation"`
	OperationName string          `json:"operation_name"`
	Body          string          `json:"body"`
	Params        []AuditLogParam `json:"params"`
	IsDangerous   bool            `json:"is_dangerous"`
	IsWrite       bool            `json:"is_write"`
}

AuditLogRecord represents a single audit log entry returned by /audit/search.

type Change

type Change struct {
	ChangeID    string            `json:"change_id" toon:"change_id"`
	Title       string            `json:"title" toon:"title"`
	Description string            `json:"description,omitempty" toon:"description,omitempty"`
	Type        string            `json:"type,omitempty" toon:"type,omitempty"`
	Status      string            `json:"status,omitempty" toon:"status,omitempty"`
	ChannelID   int64             `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName string            `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	CreatorID   int64             `json:"creator_id,omitempty" toon:"creator_id,omitempty"`
	CreatorName string            `json:"creator_name,omitempty" toon:"creator_name,omitempty"`
	StartTime   Timestamp         `json:"start_time,omitempty" toon:"start_time,omitempty"`
	EndTime     Timestamp         `json:"end_time,omitempty" toon:"end_time,omitempty"`
	Labels      map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
}

Change represents a change record

type ChangeTimeline

type ChangeTimeline struct {
	TimelineID  int64     `json:"timeline_id" toon:"timeline_id"`
	At          Timestamp `json:"at" toon:"at"`
	Status      string    `json:"status,omitempty" toon:"status,omitempty"`
	Description string    `json:"description,omitempty" toon:"description,omitempty"`
}

ChangeTimeline represents a timeline entry in status change

type ChangeTrendPoint

type ChangeTrendPoint struct {
	Timestamp        Timestamp `json:"ts"`
	ChangeCount      int       `json:"change_cnt"`
	ChangeEventCount int       `json:"change_event_cnt"`
}

ChangeTrendPoint preserves the change counters for each time bucket.

type ChannelInfo

type ChannelInfo struct {
	ChannelID   int64  `json:"channel_id" toon:"channel_id"`
	ChannelName string `json:"channel_name" toon:"channel_name"`
	TeamID      int64  `json:"team_id,omitempty" toon:"team_id,omitempty"`
	TeamName    string `json:"team_name,omitempty" toon:"team_name,omitempty"`
	CreatorID   int64  `json:"creator_id,omitempty" toon:"creator_id,omitempty"`
	CreatorName string `json:"creator_name,omitempty" toon:"creator_name,omitempty"`
}

ChannelInfo represents channel information with enriched fields

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Flashduty API client

func NewClient

func NewClient(appKey string, opts ...Option) (*Client, error)

NewClient creates a new Flashduty API client

func (*Client) AckIncidents

func (c *Client) AckIncidents(ctx context.Context, incidentIDs []string) error

AckIncidents acknowledges one or more incidents

func (*Client) AddIncidentResponders

func (c *Client) AddIncidentResponders(ctx context.Context, input *IncidentAddResponderInput) error

AddIncidentResponders adds responders to an incident.

func (*Client) AddIncidentWarRoomMembers

func (c *Client) AddIncidentWarRoomMembers(ctx context.Context, input *IncidentWarRoomAddMemberInput) error

AddIncidentWarRoomMembers adds members to an existing incident war room.

func (*Client) CancelStatusPageMigration

func (c *Client) CancelStatusPageMigration(ctx context.Context, jobID string) error

CancelStatusPageMigration requests cancellation of an in-flight status page migration job identified by jobID.

func (*Client) CloseIncidents

func (c *Client) CloseIncidents(ctx context.Context, incidentIDs []string) error

CloseIncidents closes (resolves) one or more incidents

func (*Client) CommentIncidents

func (c *Client) CommentIncidents(ctx context.Context, input *IncidentCommentInput) error

CommentIncidents adds a comment to one or more incidents.

func (*Client) CreateChangeTimeline

func (c *Client) CreateChangeTimeline(ctx context.Context, input *CreateChangeTimelineInput) error

CreateChangeTimeline adds a timeline update to a status page incident or maintenance

func (*Client) CreateIncident

func (c *Client) CreateIncident(ctx context.Context, input *CreateIncidentInput) (*CreateIncidentOutput, error)

CreateIncident creates a new incident

func (*Client) CreateIncidentWarRoom

func (c *Client) CreateIncidentWarRoom(ctx context.Context, input *IncidentWarRoomCreateInput) (*IncidentWarRoom, error)

CreateIncidentWarRoom creates an IM war room for an incident.

func (*Client) CreateMCPServer

func (c *Client) CreateMCPServer(ctx context.Context, input *CreateMCPServerInput) (*CreateMCPServerOutput, error)

CreateMCPServer registers a new MCP server with Flashduty.

func (*Client) CreateStatusIncident

func (c *Client) CreateStatusIncident(ctx context.Context, input *CreateStatusIncidentInput) (*CreateStatusIncidentOutput, error)

CreateStatusIncident creates an incident on a status page

func (*Client) DeleteIncidentWarRoom

func (c *Client) DeleteIncidentWarRoom(ctx context.Context, input *IncidentWarRoomDeleteInput) error

DeleteIncidentWarRoom deletes an incident war room.

func (*Client) DeleteTeam

func (c *Client) DeleteTeam(ctx context.Context, input *TeamDeleteInput) error

DeleteTeam permanently deletes a team by ID, name, or ref_id.

func (*Client) DisableIncidentMerge

func (c *Client) DisableIncidentMerge(ctx context.Context, incidentIDs []string) error

DisableIncidentMerge disables merge for one or more incidents.

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context) (*AccountInfo, error)

GetAccountInfo retrieves the account information for the authenticated app key.

func (*Client) GetAlertDetail

func (c *Client) GetAlertDetail(ctx context.Context, input *GetAlertDetailInput) (*GetAlertDetailOutput, error)

GetAlertDetail fetches detailed information for a single alert

func (*Client) GetAlertFeed

func (c *Client) GetAlertFeed(ctx context.Context, input *GetAlertFeedInput) (*GetAlertFeedOutput, error)

GetAlertFeed fetches the feed/timeline for an alert with enriched person names

func (*Client) GetIncidentDetail

func (c *Client) GetIncidentDetail(ctx context.Context, input *GetIncidentDetailInput) (*GetIncidentDetailOutput, error)

GetIncidentDetail fetches detailed information for a single incident

func (*Client) GetIncidentFeed

func (c *Client) GetIncidentFeed(ctx context.Context, input *GetIncidentFeedInput) (*GetIncidentFeedOutput, error)

GetIncidentFeed fetches the feed/timeline for an incident with enriched person names

func (*Client) GetIncidentTimelines

func (c *Client) GetIncidentTimelines(ctx context.Context, incidentIDs []string) ([]IncidentTimelineOutput, error)

GetIncidentTimelines fetches timelines for one or more incidents concurrently

func (*Client) GetIncidentWarRoom

func (c *Client) GetIncidentWarRoom(ctx context.Context, input *IncidentWarRoomDetailInput) (*IncidentWarRoom, error)

GetIncidentWarRoom fetches war room details from the IM provider.

func (*Client) GetIncidentWarRoomDefaultObservers

func (c *Client) GetIncidentWarRoomDefaultObservers(ctx context.Context, incidentID string) ([]IncidentWarRoomObserver, error)

GetIncidentWarRoomDefaultObservers returns historical responders eligible for observer invitation.

func (*Client) GetMemberInfo

func (c *Client) GetMemberInfo(ctx context.Context) (*MemberInfo, error)

func (*Client) GetPresetTemplate

func (c *Client) GetPresetTemplate(ctx context.Context, input *GetPresetTemplateInput) (*GetPresetTemplateOutput, error)

GetPresetTemplate fetches the preset (default) notification template for a channel.

func (*Client) GetScheduleDetail

func (c *Client) GetScheduleDetail(ctx context.Context, input *GetScheduleDetailInput) (*GetScheduleDetailOutput, error)

GetScheduleDetail fetches detailed schedule information with computed slots

func (*Client) GetStatusPageMigrationStatus

func (c *Client) GetStatusPageMigrationStatus(ctx context.Context, jobID string) (*StatusPageMigrationJob, error)

GetStatusPageMigrationStatus fetches the current state of a status page migration job identified by jobID.

func (*Client) GetTeamInfo

func (c *Client) GetTeamInfo(ctx context.Context, input *TeamGetInput) (*TeamItem, error)

GetTeamInfo retrieves full team detail by ID, name, or ref_id. It calls /team/info for metadata, then /person/infos to resolve member names.

func (*Client) ListAlertEvents

func (c *Client) ListAlertEvents(ctx context.Context, input *ListAlertEventsInput) (*ListAlertEventsOutput, error)

ListAlertEvents queries raw alert events

func (*Client) ListAlertEventsGlobal

func (c *Client) ListAlertEventsGlobal(ctx context.Context, input *ListAlertEventsGlobalInput) (*ListAlertEventsGlobalOutput, error)

ListAlertEventsGlobal queries alert events globally across all alerts

func (*Client) ListAlerts

func (c *Client) ListAlerts(ctx context.Context, input *ListAlertsInput) (*ListAlertsOutput, error)

ListAlerts queries alerts by filters

func (*Client) ListAlertsByIDs

func (c *Client) ListAlertsByIDs(ctx context.Context, alertIDs []string) (*ListAlertsOutput, error)

ListAlertsByIDs fetches alerts by their IDs

func (*Client) ListChanges

func (c *Client) ListChanges(ctx context.Context, input *ListChangesInput) (*ListChangesOutput, error)

ListChanges queries change records (deployments, configurations)

func (*Client) ListChannels

func (c *Client) ListChannels(ctx context.Context, input *ListChannelsInput) (*ListChannelsOutput, error)

ListChannels queries channels by IDs or name, returns enriched data with team/creator names

func (*Client) ListEscalationRules

func (c *Client) ListEscalationRules(ctx context.Context, channelID int64) (*ListEscalationRulesOutput, error)

ListEscalationRules queries escalation rules for a channel

func (*Client) ListFields

func (c *Client) ListFields(ctx context.Context, input *ListFieldsInput) (*ListFieldsOutput, error)

ListFields queries custom field definitions

func (*Client) ListIncidentAlerts

func (c *Client) ListIncidentAlerts(ctx context.Context, incidentIDs []string, limit int) ([]IncidentAlertsOutput, error)

ListIncidentAlerts fetches alerts for one or more incidents concurrently

func (*Client) ListIncidentWarRooms

func (c *Client) ListIncidentWarRooms(ctx context.Context, input *IncidentWarRoomListInput) (*IncidentWarRoomListOutput, error)

ListIncidentWarRooms lists war rooms for an incident.

func (*Client) ListIncidents

func (c *Client) ListIncidents(ctx context.Context, input *ListIncidentsInput) (*ListIncidentsOutput, error)

ListIncidents queries incidents by IDs or filters, returns enriched data with names

func (*Client) ListMembers

func (c *Client) ListMembers(ctx context.Context, input *ListMembersInput) (*ListMembersOutput, error)

ListMembers queries members by IDs, name, or email

func (*Client) ListPostMortems

func (c *Client) ListPostMortems(ctx context.Context, input *ListPostMortemsInput) (*ListPostMortemsOutput, error)

ListPostMortems queries post-mortem reports

func (*Client) ListSchedulesWithSlots

func (c *Client) ListSchedulesWithSlots(ctx context.Context, input *ListSchedulesWithSlotsInput) (*ListSchedulesWithSlotsOutput, error)

ListSchedulesWithSlots queries schedules with computed on-call slots for a time range

func (*Client) ListSimilarIncidents

func (c *Client) ListSimilarIncidents(ctx context.Context, incidentID string, limit int) (*ListIncidentsOutput, error)

ListSimilarIncidents finds similar historical incidents for a given incident

func (*Client) ListStatusChanges

func (c *Client) ListStatusChanges(ctx context.Context, input *ListStatusChangesInput) (*ListStatusChangesOutput, error)

ListStatusChanges lists active incidents or maintenances on a status page

func (*Client) ListStatusPages

func (c *Client) ListStatusPages(ctx context.Context, pageIDs []int64) ([]StatusPage, error)

ListStatusPages queries status pages, optionally filtering by page IDs

func (*Client) ListTeams

func (c *Client) ListTeams(ctx context.Context, input *ListTeamsInput) (*ListTeamsOutput, error)

ListTeams queries teams by IDs or name

func (*Client) ListWarRoomEnabledDataSources

func (c *Client) ListWarRoomEnabledDataSources(ctx context.Context) (*ListWarRoomEnabledDataSourcesOutput, error)

ListWarRoomEnabledDataSources lists IM integrations with war-room creation enabled.

func (*Client) MergeAlertsToIncident

func (c *Client) MergeAlertsToIncident(ctx context.Context, input *MergeAlertsInput) error

MergeAlertsToIncident merges alerts into an existing incident

func (*Client) MergeIncidents

func (c *Client) MergeIncidents(ctx context.Context, input *MergeIncidentsInput) error

MergeIncidents merges source incidents into a target incident

func (*Client) MonitAgentCatalog

func (c *Client) MonitAgentCatalog(ctx context.Context, input *MonitAgentCatalogInput) (*MonitAgentCatalogOutput, error)

MonitAgentCatalog lists the tools the runner exposes for the given target.

func (*Client) MonitAgentInvoke

func (c *Client) MonitAgentInvoke(ctx context.Context, input *MonitAgentInvokeInput) (*MonitAgentInvokeOutput, error)

MonitAgentInvoke runs one or more tools against the given target. Tools execute concurrently on the runner; the response preserves request order.

func (*Client) MonitQueryDiagnose

func (c *Client) MonitQueryDiagnose(ctx context.Context, input *MonitQueryDiagnoseInput) (*MonitQueryDiagnoseOutput, error)

MonitQueryDiagnose runs a built-in diagnostic operation (log pattern extraction or metric trend analysis) against a configured datasource.

func (*Client) MonitQueryRows

func (c *Client) MonitQueryRows(ctx context.Context, input *MonitQueryRowsInput) (*MonitQueryRowsOutput, error)

MonitQueryRows executes a raw expression against a datasource and returns the rows. The caller is responsible for crafting datasource-appropriate expressions (PromQL, LogsQL, LogQL, SQL).

func (*Client) QueryChangeTrend

func (c *Client) QueryChangeTrend(ctx context.Context, input *QueryChangeTrendInput) (*QueryChangeTrendOutput, error)

QueryChangeTrend queries change volume trends over time

func (*Client) QueryInsightAlertTopK

func (c *Client) QueryInsightAlertTopK(ctx context.Context, input *QueryInsightAlertTopKInput) (*QueryInsightAlertTopKOutput, error)

QueryInsightAlertTopK queries top alert sources grouped by a label

func (*Client) QueryInsightByChannel

func (c *Client) QueryInsightByChannel(ctx context.Context, input *InsightQueryInput) (*QueryInsightByChannelOutput, error)

QueryInsightByChannel queries pre-aggregated metrics grouped by channel

func (*Client) QueryInsightByResponder

func (c *Client) QueryInsightByResponder(ctx context.Context, input *InsightQueryInput) (*QueryInsightByResponderOutput, error)

QueryInsightByResponder queries pre-aggregated metrics grouped by responder

func (*Client) QueryInsightByTeam

func (c *Client) QueryInsightByTeam(ctx context.Context, input *InsightQueryInput) (*QueryInsightByTeamOutput, error)

QueryInsightByTeam queries pre-aggregated metrics grouped by team

func (*Client) QueryInsightIncidentList

func (c *Client) QueryInsightIncidentList(ctx context.Context, input *QueryInsightIncidentListInput) (*QueryInsightIncidentListOutput, error)

QueryInsightIncidentList queries incidents with attached performance metrics

func (*Client) QueryMonitorRuleStatus

QueryMonitorRuleStatus queries monitor rule status counts grouped by folder family.

func (*Client) QueryNotificationTrend

func (c *Client) QueryNotificationTrend(ctx context.Context, input *QueryNotificationTrendInput) (*QueryNotificationTrendOutput, error)

QueryNotificationTrend queries notification volume trends over time

func (*Client) ReassignIncidents

func (c *Client) ReassignIncidents(ctx context.Context, input *ReassignIncidentsInput) error

ReassignIncidents reassigns one or more incidents to new responders

func (*Client) RemoveIncidents

func (c *Client) RemoveIncidents(ctx context.Context, incidentIDs []string) error

RemoveIncidents removes one or more incidents.

func (*Client) ReopenIncidents

func (c *Client) ReopenIncidents(ctx context.Context, incidentIDs []string) error

ReopenIncidents reopens one or more closed incidents

func (*Client) SearchAuditLogs

func (c *Client) SearchAuditLogs(ctx context.Context, input *SearchAuditLogsInput) (*SearchAuditLogsOutput, error)

SearchAuditLogs searches the audit log

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(userAgent string)

SetUserAgent updates the User-Agent header for subsequent requests. This is useful when the user agent must change after client creation (e.g., per-session MCP client info).

func (*Client) SnoozeIncidents

func (c *Client) SnoozeIncidents(ctx context.Context, input *SnoozeIncidentsInput) error

SnoozeIncidents snoozes one or more incidents for the specified duration

func (*Client) StartStatusPageEmailSubscriberMigration

func (c *Client) StartStatusPageEmailSubscriberMigration(ctx context.Context, input *StartStatusPageEmailSubscriberMigrationInput) (*StartStatusPageMigrationOutput, error)

StartStatusPageEmailSubscriberMigration starts an asynchronous migration of email subscribers from an external provider into an existing Flashduty status page. The returned job ID can be polled with GetStatusPageMigrationStatus and cancelled with CancelStatusPageMigration.

func (*Client) StartStatusPageMigration

func (c *Client) StartStatusPageMigration(ctx context.Context, input *StartStatusPageMigrationInput) (*StartStatusPageMigrationOutput, error)

StartStatusPageMigration starts an asynchronous migration of status page structure and history from an external provider into Flashduty. The returned job ID can be polled with GetStatusPageMigrationStatus and cancelled with CancelStatusPageMigration.

func (*Client) UnackIncidents

func (c *Client) UnackIncidents(ctx context.Context, incidentIDs []string) error

UnackIncidents cancels acknowledgement for one or more incidents.

func (*Client) UpdateIncident

func (c *Client) UpdateIncident(ctx context.Context, input *UpdateIncidentInput) ([]string, error)

UpdateIncident updates an incident's fields. Returns the list of updated field names.

Built-in fields (title, description, severity, impact, root_cause, resolution) are sent in a single POST to /incident/reset. The legacy per-field endpoints (/incident/{title,description,severity}/reset) are deliberately not used: they require JWT/cookie auth in the gateway, while /incident/reset accepts app_key, which is what SDK callers carry. Custom fields go through /incident/field/reset, one call per field, because that endpoint takes a single field_name/field_value pair.

func (*Client) UpsertTeam

func (c *Client) UpsertTeam(ctx context.Context, input *TeamUpsertInput) (*TeamUpsertOutput, error)

UpsertTeam creates or updates a team. TeamName is required by the API.

func (*Client) ValidateTemplate

func (c *Client) ValidateTemplate(ctx context.Context, input *ValidateTemplateInput) (*ValidateTemplateOutput, error)

ValidateTemplate validates and previews a notification template.

func (*Client) WakeIncidents

func (c *Client) WakeIncidents(ctx context.Context, incidentIDs []string) error

WakeIncidents wakes one or more incidents from snooze.

type CreateChangeTimelineInput

type CreateChangeTimelineInput struct {
	PageID           int64  // Required
	ChangeID         int64  // Required
	Message          string // Required
	AtSeconds        int64  // Optional. Defaults to current time
	Status           string // Optional
	ComponentChanges string // Optional. JSON array of component status changes
}

CreateChangeTimelineInput contains parameters for adding a timeline entry

type CreateIncidentInput

type CreateIncidentInput struct {
	Title       string // Required. Length: 3-200 characters
	Severity    string // Required. Info, Warning, Critical
	ChannelID   int64  // Optional collaboration space ID
	Description string // Optional. Max 6144 characters
	AssignedTo  []int  // Optional person IDs to assign as responders
}

CreateIncidentInput contains parameters for creating an incident

type CreateIncidentOutput

type CreateIncidentOutput struct {
	IncidentID string `json:"incident_id"` // 24-hex MongoDB ObjectID of the new incident
	Title      string `json:"title"`       // echoes the request title
}

CreateIncidentOutput is the data payload of POST /incident/create.

type CreateMCPServerInput

type CreateMCPServerInput struct {
	ServerName     string            `json:"server_name"`
	Description    string            `json:"description"`
	Transport      string            `json:"transport"`
	Command        string            `json:"command,omitempty"`
	Args           []string          `json:"args,omitempty"`
	Env            map[string]string `json:"env,omitempty"`
	URL            string            `json:"url,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	ConnectTimeout int               `json:"connect_timeout,omitempty"`
	CallTimeout    int               `json:"call_timeout,omitempty"`
	Status         string            `json:"status,omitempty"`
	TeamID         int64             `json:"team_id"`
}

CreateMCPServerInput is the payload for POST /safari/mcp/server/create. Transport must be one of "stdio", "sse", or "streamable-http". Fields are conditionally required by the backend depending on Transport: stdio uses Command/Args/Env; sse and streamable-http use URL/Headers. ConnectTimeout and CallTimeout are in seconds.

TeamID is always serialized (no omitempty) because 0 is a meaningful sentinel — it explicitly requests account scope, distinct from "field omitted". Callers must set it deliberately: 0 = account scope; >0 = team scope.

type CreateMCPServerOutput

type CreateMCPServerOutput struct {
	ServerID string `json:"server_id"`
	Status   string `json:"status"`
}

CreateMCPServerOutput is the unwrapped data block returned by POST /safari/mcp/server/create.

type CreateStatusIncidentInput

type CreateStatusIncidentInput struct {
	PageID             int64  // Required
	Title              string // Required. Max 255 characters
	Message            string // Optional. Initial update message
	Status             string // Optional. Default: "investigating"
	AffectedComponents string // Optional. Format: "id1:degraded,id2:partial_outage"
	NotifySubscribers  bool   // Whether to notify page subscribers
}

CreateStatusIncidentInput contains parameters for creating a status page incident

type CreateStatusIncidentOutput

type CreateStatusIncidentOutput struct {
	ChangeID   int64  `json:"change_id"`   // ID of the newly created status-page change/incident
	ChangeName string `json:"change_name"` // event title, echoed from the request
}

CreateStatusIncidentOutput is the data payload of POST /status-page/change/create.

type DataSourceIntegration

type DataSourceIntegration struct {
	DataSourceID int64          `json:"data_source_id" toon:"data_source_id"`
	Name         string         `json:"name,omitempty" toon:"name,omitempty"`
	PluginType   string         `json:"plugin_type,omitempty" toon:"plugin_type,omitempty"`
	Category     string         `json:"category,omitempty" toon:"category,omitempty"`
	Settings     map[string]any `json:"settings,omitempty" toon:"settings,omitempty"`
}

DataSourceIntegration represents a configured Flashduty integration data source.

type DimensionInsightItem

type DimensionInsightItem struct {
	MetricsBase

	TotalIncidentCnt                int     `json:"total_incident_cnt" toon:"total_incident_cnt"`
	TotalIncidentsAcknowledged      int     `json:"total_incidents_acknowledged" toon:"total_incidents_acknowledged"`
	TotalIncidentsClosed            int     `json:"total_incidents_closed" toon:"total_incidents_closed"`
	TotalIncidentsAutoClosed        int     `json:"total_incidents_auto_closed" toon:"total_incidents_auto_closed"`
	TotalIncidentsManuallyClosed    int     `json:"total_incidents_manually_closed" toon:"total_incidents_manually_closed"`
	TotalIncidentsTimeoutClosed     int     `json:"total_incidents_timeout_closed" toon:"total_incidents_timeout_closed"`
	TotalIncidentsEscalated         int     `json:"total_incidents_escalated" toon:"total_incidents_escalated"`
	TotalIncidentsManuallyEscalated int     `json:"total_incidents_manually_escalated" toon:"total_incidents_manually_escalated"`
	TotalIncidentsTimeoutEscalated  int     `json:"total_incidents_timeout_escalated" toon:"total_incidents_timeout_escalated"`
	TotalIncidentsReassigned        int     `json:"total_incidents_reassigned" toon:"total_incidents_reassigned"`
	TotalInterruptions              int     `json:"total_interruptions" toon:"total_interruptions"`
	TotalNotifications              int     `json:"total_notifications" toon:"total_notifications"`
	TotalEngagedSeconds             int     `json:"total_engaged_seconds" toon:"total_engaged_seconds"`
	TotalSecondsToAck               int     `json:"total_seconds_to_ack" toon:"total_seconds_to_ack"`
	TotalSecondsToClose             int     `json:"total_seconds_to_close" toon:"total_seconds_to_close"`
	MeanSecondsToAck                float64 `json:"mean_seconds_to_ack" toon:"mean_seconds_to_ack"`
	MeanSecondsToClose              float64 `json:"mean_seconds_to_close" toon:"mean_seconds_to_close"`
	NoiseReductionPct               float64 `json:"noise_reduction_pct" toon:"noise_reduction_pct"`
	AcknowledgementPct              float64 `json:"acknowledgement_pct" toon:"acknowledgement_pct"`
	TotalAlertCnt                   int     `json:"total_alert_cnt" toon:"total_alert_cnt"`
	TotalAlertEventCnt              int     `json:"total_alert_event_cnt" toon:"total_alert_event_cnt"`
}

DimensionInsightItem represents pre-aggregated metrics for a team or channel dimension.

type DutyError

type DutyError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

DutyError represents Flashduty API error

func (*DutyError) Error

func (e *DutyError) Error() string

Error implements the error interface for DutyError

type EnrichedIncident

type EnrichedIncident struct {
	// Basic fields
	IncidentID  string `json:"incident_id" toon:"incident_id"`
	Title       string `json:"title" toon:"title"`
	Description string `json:"description,omitempty" toon:"description,omitempty"`
	Severity    string `json:"severity" toon:"severity"`
	Progress    string `json:"progress" toon:"progress"`

	// Time fields
	StartTime Timestamp `json:"start_time" toon:"start_time"`
	AckTime   Timestamp `json:"ack_time,omitempty" toon:"ack_time,omitempty"`
	CloseTime Timestamp `json:"close_time,omitempty" toon:"close_time,omitempty"`

	// Channel (enriched)
	ChannelID   int64  `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName string `json:"channel_name,omitempty" toon:"channel_name,omitempty"`

	// Creator (enriched)
	CreatorID    int64  `json:"creator_id,omitempty" toon:"creator_id,omitempty"`
	CreatorName  string `json:"creator_name,omitempty" toon:"creator_name,omitempty"`
	CreatorEmail string `json:"creator_email,omitempty" toon:"creator_email,omitempty"`

	// Closer (enriched)
	CloserID   int64  `json:"closer_id,omitempty" toon:"closer_id,omitempty"`
	CloserName string `json:"closer_name,omitempty" toon:"closer_name,omitempty"`

	// Responders (enriched)
	Responders []EnrichedResponder `json:"responders,omitempty" toon:"responders,omitempty"`

	// Timeline (full)
	Timeline []TimelineEvent `json:"timeline,omitempty" toon:"timeline,omitempty"`

	// Alerts (preview)
	AlertsPreview []AlertPreview `json:"alerts_preview,omitempty" toon:"alerts_preview,omitempty"`
	AlertsTotal   int            `json:"alerts_total" toon:"alerts_total"`

	// Other
	Labels       map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
	CustomFields map[string]any    `json:"custom_fields,omitempty" toon:"custom_fields,omitempty"`
}

EnrichedIncident contains full incident data with human-readable names

type EnrichedResponder

type EnrichedResponder struct {
	PersonID       int64     `json:"person_id" toon:"person_id"`
	PersonName     string    `json:"person_name" toon:"person_name"`
	Email          string    `json:"email,omitempty" toon:"email,omitempty"`
	AssignedAt     Timestamp `json:"assigned_at,omitempty" toon:"assigned_at,omitempty"`
	AcknowledgedAt Timestamp `json:"acknowledged_at,omitempty" toon:"acknowledged_at,omitempty"`
}

EnrichedResponder contains responder info with human-readable names

type EscalationLayer

type EscalationLayer struct {
	LayerIdx       int               `json:"layer_idx" toon:"layer_idx"`
	Timeout        int               `json:"timeout" toon:"timeout"`
	NotifyInterval float64           `json:"notify_interval,omitempty" toon:"notify_interval,omitempty"`
	MaxTimes       int               `json:"max_times,omitempty" toon:"max_times,omitempty"`
	ForceEscalate  bool              `json:"force_escalate,omitempty" toon:"force_escalate,omitempty"`
	Target         *EscalationTarget `json:"target,omitempty" toon:"target,omitempty"`
}

EscalationLayer represents a layer in an escalation rule

type EscalationRule

type EscalationRule struct {
	RuleID      string            `json:"rule_id" toon:"rule_id"`
	RuleName    string            `json:"rule_name" toon:"rule_name"`
	Description string            `json:"description,omitempty" toon:"description,omitempty"`
	ChannelID   int64             `json:"channel_id" toon:"channel_id"`
	ChannelName string            `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	Status      string            `json:"status,omitempty" toon:"status,omitempty"`
	Priority    int               `json:"priority" toon:"priority"`
	AggrWindow  int               `json:"aggr_window" toon:"aggr_window"`
	Layers      []EscalationLayer `json:"layers,omitempty" toon:"layers,omitempty"`
	TimeFilters []TimeFilter      `json:"time_filters,omitempty" toon:"time_filters,omitempty"`
	Filters     AlertFilters      `json:"filters,omitempty" toon:"filters,omitempty"`
}

EscalationRule represents an escalation rule with full details

type EscalationTarget

type EscalationTarget struct {
	Persons   []PersonTarget   `json:"persons,omitempty" toon:"persons,omitempty"`
	Teams     []TeamTarget     `json:"teams,omitempty" toon:"teams,omitempty"`
	Schedules []ScheduleTarget `json:"schedules,omitempty" toon:"schedules,omitempty"`
	NotifyBy  *NotifyBy        `json:"notify_by,omitempty" toon:"notify_by,omitempty"`
	Webhooks  []WebhookConfig  `json:"webhooks,omitempty" toon:"webhooks,omitempty"`
}

EscalationTarget represents the complete target configuration for a layer

type FieldInfo

type FieldInfo struct {
	FieldID      string   `json:"field_id" toon:"field_id"`
	FieldName    string   `json:"field_name" toon:"field_name"`
	DisplayName  string   `json:"display_name" toon:"display_name"`
	FieldType    string   `json:"field_type" toon:"field_type"`
	ValueType    string   `json:"value_type" toon:"value_type"`
	Options      []string `json:"options,omitempty" toon:"options,omitempty"`
	DefaultValue any      `json:"default_value,omitempty" toon:"default_value,omitempty"`
}

FieldInfo represents custom field definition

type FlashdutyResponse

type FlashdutyResponse struct {
	Error *DutyError `json:"error,omitempty"`
	Data  any        `json:"data,omitempty"`
}

FlashdutyResponse represents the standard Flashduty API response structure

type GetAlertDetailInput

type GetAlertDetailInput struct {
	AlertID string // Required
}

GetAlertDetailInput contains parameters for getting alert detail

type GetAlertDetailOutput

type GetAlertDetailOutput struct {
	Alert Alert `json:"alert"`
}

GetAlertDetailOutput contains full alert detail

type GetAlertFeedInput

type GetAlertFeedInput struct {
	AlertID string   // Required
	Limit   int      // Optional (default 20)
	Page    int      // Optional (default 1)
	Asc     bool     // Optional
	Types   []string // Optional: filter by event type
}

GetAlertFeedInput contains parameters for getting alert feed/timeline

type GetAlertFeedOutput

type GetAlertFeedOutput struct {
	Items       []TimelineEvent `json:"items"`
	HasNextPage bool            `json:"has_next_page"`
}

GetAlertFeedOutput contains alert feed events

type GetIncidentDetailInput

type GetIncidentDetailInput struct {
	IncidentID string // Required
}

GetIncidentDetailInput contains parameters for getting incident detail

type GetIncidentDetailOutput

type GetIncidentDetailOutput struct {
	Incident IncidentDetail `json:"incident"`
}

GetIncidentDetailOutput contains full incident detail

type GetIncidentFeedInput

type GetIncidentFeedInput struct {
	IncidentID string // Required
	Limit      int    // Max results (default 20)
	Page       int    // Page number (default 1)
	Asc        bool   // Sort ascending by time (default false)
}

GetIncidentFeedInput contains parameters for getting incident feed/timeline

type GetIncidentFeedOutput

type GetIncidentFeedOutput struct {
	Items       []TimelineEvent `json:"items"`
	HasNextPage bool            `json:"has_next_page"`
}

GetIncidentFeedOutput contains incident feed events

type GetPresetTemplateInput

type GetPresetTemplateInput struct {
	Channel string // Required. One of the keys in TemplateChannels.
}

GetPresetTemplateInput contains parameters for fetching a preset template.

type GetPresetTemplateOutput

type GetPresetTemplateOutput struct {
	Channel      string `json:"channel"`
	FieldName    string `json:"field_name"`
	TemplateCode string `json:"template_code"`
}

GetPresetTemplateOutput contains the preset template result.

type GetScheduleDetailInput

type GetScheduleDetailInput struct {
	ScheduleID int64 // Required
	Start      int64 // Required: Unix seconds, start of time range
	End        int64 // Required: Unix seconds, end of time range
}

GetScheduleDetailInput contains parameters for getting schedule detail

type GetScheduleDetailOutput

type GetScheduleDetailOutput struct {
	Schedule ScheduleDetail `json:"schedule"`
}

GetScheduleDetailOutput contains full schedule detail

type IncidentAddResponderInput

type IncidentAddResponderInput struct {
	IncidentID string
	PersonIDs  []int64
	Notify     *IncidentNotifyInput
}

IncidentAddResponderInput contains parameters for adding responders to an incident.

type IncidentAlertsOutput

type IncidentAlertsOutput struct {
	IncidentID string         `json:"incident_id"`
	Alerts     []AlertPreview `json:"alerts"`
	Total      int            `json:"total"`
}

IncidentAlertsOutput contains alerts data for a single incident

type IncidentCommentInput

type IncidentCommentInput struct {
	IncidentIDs []string
	Comment     string
	MuteReply   bool
	Notify      *IncidentNotifyInput
}

IncidentCommentInput contains parameters for adding a comment to one or more incidents.

type IncidentDetail

type IncidentDetail struct {
	IncidentID    string            `json:"incident_id" toon:"incident_id"`
	Title         string            `json:"title" toon:"title"`
	Description   string            `json:"description,omitempty" toon:"description,omitempty"`
	Severity      string            `json:"incident_severity" toon:"severity"`
	Progress      string            `json:"progress" toon:"progress"`
	StartTime     Timestamp         `json:"start_time" toon:"start_time"`
	AckTime       Timestamp         `json:"ack_time,omitempty" toon:"ack_time,omitempty"`
	CloseTime     Timestamp         `json:"close_time,omitempty" toon:"close_time,omitempty"`
	ChannelID     int64             `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName   string            `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	CreatorID     int64             `json:"creator_id,omitempty" toon:"creator_id,omitempty"`
	CloserID      int64             `json:"closer_id,omitempty" toon:"closer_id,omitempty"`
	AISummary     string            `json:"ai_summary,omitempty" toon:"ai_summary,omitempty"`
	RootCause     string            `json:"root_cause,omitempty" toon:"root_cause,omitempty"`
	Resolution    string            `json:"resolution,omitempty" toon:"resolution,omitempty"`
	Impact        string            `json:"impact,omitempty" toon:"impact,omitempty"`
	Frequency     string            `json:"frequency,omitempty" toon:"frequency,omitempty"`
	AlertCnt      int               `json:"alert_cnt" toon:"alert_cnt"`
	AlertEventCnt int               `json:"alert_event_cnt" toon:"alert_event_cnt"`
	PostMortemID  string            `json:"post_mortem_id,omitempty" toon:"post_mortem_id,omitempty"`
	Responders    []RawResponder    `json:"responders,omitempty" toon:"responders,omitempty"`
	Labels        map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
	Fields        map[string]any    `json:"fields,omitempty" toon:"fields,omitempty"`
}

IncidentDetail represents full incident data from the /incident/info endpoint

type IncidentNotifyInput

type IncidentNotifyInput struct {
	FollowPreference bool
	PersonalChannels []string
	TemplateID       string
}

IncidentNotifyInput contains optional notification controls for incident write operations.

type IncidentTimelineOutput

type IncidentTimelineOutput struct {
	IncidentID string          `json:"incident_id"`
	Timeline   []TimelineEvent `json:"timeline"`
	Total      int             `json:"total"`
}

IncidentTimelineOutput contains timeline data for a single incident

type IncidentWarRoom

type IncidentWarRoom struct {
	AccountID     int64     `json:"account_id,omitempty" toon:"account_id,omitempty"`
	IntegrationID int64     `json:"integration_id,omitempty" toon:"integration_id,omitempty"`
	ChatID        string    `json:"chat_id" toon:"chat_id"`
	ChatName      string    `json:"chat_name,omitempty" toon:"chat_name,omitempty"`
	ShareLink     string    `json:"share_link,omitempty" toon:"share_link,omitempty"`
	IncidentID    string    `json:"incident_id,omitempty" toon:"incident_id,omitempty"`
	CreatedBy     int64     `json:"created_by,omitempty" toon:"created_by,omitempty"`
	CreatedAt     Timestamp `json:"created_at,omitempty" toon:"created_at,omitempty"`
	PluginType    string    `json:"plugin_type,omitempty" toon:"plugin_type,omitempty"`
	Status        string    `json:"status,omitempty" toon:"status,omitempty"`
}

IncidentWarRoom represents an IM war room.

type IncidentWarRoomAddMemberInput

type IncidentWarRoomAddMemberInput struct {
	IntegrationID int64
	ChatID        string
	MemberIDs     []int64
}

IncidentWarRoomAddMemberInput contains parameters for adding members to a war room.

type IncidentWarRoomCreateInput

type IncidentWarRoomCreateInput struct {
	IncidentID    string
	IntegrationID int64
	MemberIDs     []int64
	AddObservers  bool
}

IncidentWarRoomCreateInput contains parameters for creating an incident war room.

type IncidentWarRoomDeleteInput

type IncidentWarRoomDeleteInput struct {
	IncidentID    string
	IntegrationID int64
}

IncidentWarRoomDeleteInput contains parameters for deleting an incident war room.

type IncidentWarRoomDetailInput

type IncidentWarRoomDetailInput struct {
	IntegrationID int64
	ChatID        string
}

IncidentWarRoomDetailInput contains parameters for fetching a war room detail.

type IncidentWarRoomItem

type IncidentWarRoomItem = IncidentWarRoom

IncidentWarRoomItem represents a war room list item.

type IncidentWarRoomListInput

type IncidentWarRoomListInput struct {
	IncidentID    string
	IntegrationID int64
}

IncidentWarRoomListInput contains parameters for listing war rooms on an incident.

type IncidentWarRoomListOutput

type IncidentWarRoomListOutput struct {
	Items []IncidentWarRoomItem `json:"items" toon:"items"`
}

IncidentWarRoomListOutput contains war rooms for an incident.

type IncidentWarRoomObserver

type IncidentWarRoomObserver struct {
	PersonID   int64     `json:"person_id" toon:"person_id"`
	PersonName string    `json:"person_name,omitempty" toon:"person_name,omitempty"`
	Nickname   string    `json:"nickname,omitempty" toon:"nickname,omitempty"`
	Name       string    `json:"name,omitempty" toon:"name,omitempty"`
	Email      string    `json:"email,omitempty" toon:"email,omitempty"`
	Phone      string    `json:"phone,omitempty" toon:"phone,omitempty"`
	Status     string    `json:"status,omitempty" toon:"status,omitempty"`
	AssignedAt Timestamp `json:"assigned_at,omitempty" toon:"assigned_at,omitempty"`
}

IncidentWarRoomObserver represents a default observer candidate for war room invitation.

func (IncidentWarRoomObserver) DisplayName

func (o IncidentWarRoomObserver) DisplayName() string

DisplayName returns the best available human-readable observer name.

type InsightAlertByLabelItem

type InsightAlertByLabelItem struct {
	Label              string `json:"label" toon:"label"`
	Hours              string `json:"hours,omitempty" toon:"hours,omitempty"`
	TotalAlertCnt      int    `json:"total_alert_cnt" toon:"total_alert_cnt"`
	TotalAlertEventCnt int    `json:"total_alert_event_cnt" toon:"total_alert_event_cnt"`
}

InsightAlertByLabelItem represents a top-K alert source grouped by label

type InsightIncidentItem

type InsightIncidentItem struct {
	IncidentID         string            `json:"incident_id" toon:"incident_id"`
	Title              string            `json:"title" toon:"title"`
	Description        string            `json:"description,omitempty" toon:"description,omitempty"`
	TeamID             int64             `json:"team_id,omitempty" toon:"team_id,omitempty"`
	TeamName           string            `json:"team_name,omitempty" toon:"team_name,omitempty"`
	ChannelID          int64             `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName        string            `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	Progress           string            `json:"progress" toon:"progress"`
	Severity           string            `json:"severity" toon:"severity"`
	CreatedAt          Timestamp         `json:"created_at" toon:"created_at"`
	ClosedBy           string            `json:"closed_by,omitempty" toon:"closed_by,omitempty"`
	SecondsToAck       int               `json:"seconds_to_ack" toon:"seconds_to_ack"`
	SecondsToClose     int               `json:"seconds_to_close" toon:"seconds_to_close"`
	EngagedSeconds     int               `json:"engaged_seconds" toon:"engaged_seconds"`
	Hours              string            `json:"hours,omitempty" toon:"hours,omitempty"`
	Responders         []RawResponder    `json:"responders,omitempty" toon:"responders,omitempty"`
	AssignedTo         *AssignedTo       `json:"assigned_to,omitempty" toon:"assigned_to,omitempty"`
	Labels             map[string]string `json:"labels,omitempty" toon:"labels,omitempty"`
	Fields             map[string]any    `json:"fields,omitempty" toon:"fields,omitempty"`
	Notifications      int               `json:"notifications,omitempty" toon:"notifications,omitempty"`
	Interruptions      int               `json:"interruptions,omitempty" toon:"interruptions,omitempty"`
	Assignments        int               `json:"assignments,omitempty" toon:"assignments,omitempty"`
	Reassignments      int               `json:"reassignments,omitempty" toon:"reassignments,omitempty"`
	Acknowledgements   int               `json:"acknowledgements,omitempty" toon:"acknowledgements,omitempty"`
	Escalations        int               `json:"escalations,omitempty" toon:"escalations,omitempty"`
	TimeoutEscalations int               `json:"timeout_escalations,omitempty" toon:"timeout_escalations,omitempty"`
	ManualEscalations  int               `json:"manual_escalations,omitempty" toon:"manual_escalations,omitempty"`
	CreatorID          int64             `json:"creator_id,omitempty" toon:"creator_id,omitempty"`
	CreatorName        string            `json:"creator_name,omitempty" toon:"creator_name,omitempty"`
}

InsightIncidentItem represents an incident with attached performance metrics from the insight API

type InsightQueryInput

type InsightQueryInput struct {
	StartTime          int64             // Required: Unix seconds
	EndTime            int64             // Required: Unix seconds
	TeamIDs            []int64           // Filter by teams (max 100)
	ChannelIDs         []int64           // Filter by channels (max 100)
	ResponderIDs       []int64           // Filter by responders (max 100)
	Severities         []string          // Filter: Critical, Warning, Info
	SplitHours         bool              // Split metrics into work/sleep/off buckets
	AggregateUnit      string            // day, week, or month for time-series
	TimeZone           string            // IANA timezone (e.g., Asia/Shanghai)
	Labels             map[string]string // Exact-match label filters
	Fields             map[string]string // Exact-match field filters
	SecondsToAckFrom   int               // Range filter on acknowledgment time (lower bound)
	SecondsToAckTo     int               // Range filter on acknowledgment time (upper bound)
	SecondsToCloseFrom int               // Range filter on resolution time (lower bound)
	SecondsToCloseTo   int               // Range filter on resolution time (upper bound)
}

InsightQueryInput contains common parameters for all /insight/* endpoints

type ListAlertEventsGlobalInput

type ListAlertEventsGlobalInput struct {
	StartTime        int64    // Required
	EndTime          int64    // Required
	IntegrationTypes []string // Optional
	IntegrationIDs   []int64  // Optional
	ChannelIDs       []int64  // Optional
	Severities       []string // Optional: serialized as a comma-separated list
	OrderBy          string   // Optional
	Limit            int      // Optional (default 20)
	Page             int      // Optional (default 1)
	SearchAfterCtx   string   // Optional
}

ListAlertEventsGlobalInput contains parameters for listing alert events globally

type ListAlertEventsGlobalOutput

type ListAlertEventsGlobalOutput struct {
	AlertEvents    []AlertEvent `json:"alert_events"`
	Total          int          `json:"total"`
	HasNextPage    bool         `json:"has_next_page"`
	SearchAfterCtx string       `json:"search_after_ctx,omitempty"`
}

ListAlertEventsGlobalOutput contains global alert event results

type ListAlertEventsInput

type ListAlertEventsInput struct {
	AlertID string // Required: alert ID

	// Deprecated: /alert/event/list does not accept time-range filtering.
	StartTime int64
	// Deprecated: /alert/event/list does not accept time-range filtering.
	EndTime int64
	// Deprecated: /alert/event/list does not accept pagination.
	Limit int
	// Deprecated: /alert/event/list does not accept pagination.
	Page int
}

ListAlertEventsInput contains parameters for listing alert events

type ListAlertEventsOutput

type ListAlertEventsOutput struct {
	AlertEvents []AlertEvent `json:"alert_events"`
}

ListAlertEventsOutput contains alert events

type ListAlertsInput

type ListAlertsInput struct {
	StartTime      int64             // Required
	EndTime        int64             // Required
	AlertSeverity  string            // Optional
	IsActive       *bool             // Optional (pointer to distinguish unset from false)
	ChannelIDs     []int64           // Optional
	IntegrationIDs []int64           // Optional
	AlertKeys      []string          // Optional
	EverMuted      *bool             // Optional
	Title          string            // Optional
	Labels         map[string]string // Optional
	Limit          int               // Optional (default 20)
	Page           int               // Optional (default 1)
	OrderBy        string            // Optional
	Asc            bool              // Optional
	SearchAfterCtx string            // Optional: cursor for deep pagination
}

ListAlertsInput contains parameters for listing alerts

type ListAlertsOutput

type ListAlertsOutput struct {
	Alerts         []Alert `json:"alerts"`
	Total          int     `json:"total"`
	HasNextPage    bool    `json:"has_next_page"`
	SearchAfterCtx string  `json:"search_after_ctx,omitempty"`
}

ListAlertsOutput contains the result of listing alerts

type ListChangesInput

type ListChangesInput struct {
	ChangeIDs  []string // Direct lookup by change IDs
	ChannelIDs []int64  // Filter by collaboration space IDs
	// Deprecated: use ChannelIDs. The backend /change/list endpoint expects
	// channel_ids (array) — singular channel_id is silently ignored.
	ChannelID int64
	StartTime int64 // Unix timestamp (seconds)
	EndTime   int64 // Unix timestamp (seconds)
	Type      string
	Limit     int
	Page      int
}

ListChangesInput contains parameters for listing changes

type ListChangesOutput

type ListChangesOutput struct {
	Changes []Change `json:"changes"`
	Total   int      `json:"total"`
}

ListChangesOutput contains the result of listing changes

type ListChannelsInput

type ListChannelsInput struct {
	ChannelIDs []int64 // Direct lookup by channel IDs
	Name       string  // Search by channel name (case-insensitive substring match, done client-side)
}

ListChannelsInput contains parameters for listing channels

type ListChannelsOutput

type ListChannelsOutput struct {
	Channels []ChannelInfo `json:"channels"`
	Total    int           `json:"total"`
}

ListChannelsOutput contains the result of listing channels

type ListEscalationRulesOutput

type ListEscalationRulesOutput struct {
	Rules []EscalationRule `json:"rules"`
	Total int              `json:"total"`
}

ListEscalationRulesOutput contains the result of listing escalation rules

type ListFieldsInput

type ListFieldsInput struct {
	FieldIDs  []string // Filter by field IDs
	FieldName string   // Filter by exact field name
}

ListFieldsInput contains parameters for listing custom fields

type ListFieldsOutput

type ListFieldsOutput struct {
	Fields []FieldInfo `json:"fields"`
	Total  int         `json:"total"`
}

ListFieldsOutput contains the result of listing fields

type ListIncidentsInput

type ListIncidentsInput struct {
	IncidentIDs []string // Direct lookup by IDs (if set, other filters are ignored)
	Progress    string   // Filter: Triggered, Processing, Closed (comma-separated for multiple)
	Severity    string   // Filter: Info, Warning, Critical
	ChannelIDs  []int64  // Filter by collaboration space IDs
	// Deprecated: use ChannelIDs. If both are set, ChannelIDs wins; otherwise
	// a non-zero ChannelID is wrapped into a single-element ChannelIDs slice.
	// The backend /incident/list endpoint expects channel_ids (array) — singular
	// channel_id is silently ignored.
	ChannelID int64
	StartTime int64 // Unix timestamp (seconds), required if no IncidentIDs
	EndTime   int64 // Unix timestamp (seconds), required if no IncidentIDs
	// Query is the backend's full-text search field on /incident/list. It
	// searches across title/labels/content via Doris and also resolves a 24-char
	// ObjectID to incident_ids and a 6-char string to a num lookup. Prefer this
	// over Title for free-form search; fall back to Title only when the caller
	// wants exact/regex/wildcard matching against the title field alone.
	Query         string
	Title         string
	Limit         int
	Page          int
	IncludeAlerts bool
	// AlertsPreviewLimit caps how many alerts per incident populate
	// AlertsPreview when IncludeAlerts is true. When <=0, falls back to the
	// SDK's defaultQueryLimit. Smaller values reduce response size sharply
	// for callers (e.g. LLMs) that just want a representative sample rather
	// than an exhaustive list — drill into one incident with ListIncidentAlerts
	// when the full set is needed.
	AlertsPreviewLimit int
}

ListIncidentsInput contains parameters for listing incidents

type ListIncidentsOutput

type ListIncidentsOutput struct {
	Incidents []EnrichedIncident `json:"incidents"`
	Total     int                `json:"total"`
}

ListIncidentsOutput contains the result of listing incidents

type ListMembersInput

type ListMembersInput struct {
	PersonIDs []int64 // Direct lookup by person IDs
	Name      string  // Search by member name (fuzzy match)
	Email     string  // Search by email address
	Page      int     // Page number (default 1)
}

ListMembersInput contains parameters for listing members

type ListMembersOutput

type ListMembersOutput struct {
	// PersonInfos is populated when querying by PersonIDs
	PersonInfos []PersonInfo `json:"person_infos,omitempty"`
	// Members is populated when listing/searching members
	Members []MemberItem `json:"members,omitempty"`
	Total   int          `json:"total"`
}

ListMembersOutput contains the result of listing members

type ListPostMortemsInput

type ListPostMortemsInput struct {
	// Deprecated: /incident/post-mortem/list does not support incident_id filtering.
	IncidentID string

	Status                string  // drafting or published
	TeamIDs               []int64 // Optional team filter
	ChannelIDs            []int64 // Optional channel filter
	CreatedAtStartSeconds int64   // Optional creation time lower bound
	CreatedAtEndSeconds   int64   // Optional creation time upper bound
	OrderBy               string  // created_at_seconds or updated_at_seconds
	Asc                   bool    // Sort ascending when true
	Limit                 int     // Max results (default 20)
	Page                  int     // Page number (default 1)
	SearchAfterCtx        string  // Cursor for the next page
}

ListPostMortemsInput contains parameters for listing post-mortem reports

type ListPostMortemsOutput

type ListPostMortemsOutput struct {
	PostMortems    []PostMortem `json:"post_mortems"`
	Total          int          `json:"total"`
	HasNextPage    bool         `json:"has_next_page"`
	SearchAfterCtx string       `json:"search_after_ctx,omitempty"`
}

ListPostMortemsOutput contains post-mortem reports

type ListSchedulesWithSlotsInput

type ListSchedulesWithSlotsInput struct {
	Start      int64   // Required: Unix seconds, start of time range for slot computation
	End        int64   // Required: Unix seconds, end of time range (max 45-day window)
	TeamIDs    []int64 // Optional: filter by teams
	Query      string  // Optional: schedule name search keyword
	IsMyTeam   bool    // Optional: only schedules in the current user's teams
	IsMyManage bool    // Optional: only schedules created by the current user inside their teams
	Limit      int     // Max results (default 20)
	Page       int     // Page number (default 1)

	// Deprecated: use TeamIDs.
	TeamID int64
}

ListSchedulesWithSlotsInput contains parameters for listing schedules with computed slots

type ListSchedulesWithSlotsOutput

type ListSchedulesWithSlotsOutput struct {
	Schedules []ScheduleDetail `json:"schedules"`
	Total     int64            `json:"total"`
}

ListSchedulesWithSlotsOutput contains schedules with computed on-call slots

type ListStatusChangesInput

type ListStatusChangesInput struct {
	PageID     int64  // Required
	ChangeType string // Required: "incident" or "maintenance"
}

ListStatusChangesInput contains parameters for listing status page changes

type ListStatusChangesOutput

type ListStatusChangesOutput struct {
	Changes []StatusChange `json:"changes"`
	Total   int            `json:"total"`
}

ListStatusChangesOutput contains the result of listing status changes

type ListTeamsInput

type ListTeamsInput struct {
	TeamIDs  []int64 // Direct lookup by team IDs
	Name     string  // Search by team name
	Page     int     // Page number (default 1)
	Limit    int     // Page size (max 100, default 20)
	OrderBy  string  // Sort field: created_at, updated_at, team_name
	Asc      bool    // Ascending sort order
	PersonID int64   // Filter by member ID
}

ListTeamsInput contains parameters for listing teams

type ListTeamsOutput

type ListTeamsOutput struct {
	Teams []TeamInfo `json:"teams"`
	Total int        `json:"total"`
}

ListTeamsOutput contains the result of listing teams

type ListWarRoomEnabledDataSourcesOutput

type ListWarRoomEnabledDataSourcesOutput struct {
	Items []DataSourceIntegration `json:"items" toon:"items"`
}

ListWarRoomEnabledDataSourcesOutput contains IM integrations that have war-room enabled.

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
}

Logger defines the logging interface for the SDK. Consumers can implement this to integrate with any logging backend.

The keysAndValues parameter uses alternating key-value pairs (slog-style):

logger.Info("request complete", "status", 200, "duration_ms", 42)

To adapt logrus, implement a thin wrapper that converts keysAndValues to logrus.Fields:

type logrusAdapter struct{ *logrus.Logger }
func (a *logrusAdapter) Info(msg string, kv ...any)  { a.WithFields(kvToFields(kv)).Info(msg) }
func (a *logrusAdapter) Warn(msg string, kv ...any)  { a.WithFields(kvToFields(kv)).Warn(msg) }
func (a *logrusAdapter) Error(msg string, kv ...any) { a.WithFields(kvToFields(kv)).Error(msg) }
func (a *logrusAdapter) Debug(msg string, kv ...any) { a.WithFields(kvToFields(kv)).Debug(msg) }
func kvToFields(kv []any) logrus.Fields {
    fields := make(logrus.Fields, len(kv)/2)
    for i := 0; i+1 < len(kv); i += 2 {
        if key, ok := kv[i].(string); ok {
            fields[key] = kv[i+1]
        }
    }
    return fields
}

type MemberInfo

type MemberInfo struct {
	AccountID   uint64    `json:"account_id"`
	AccountName string    `json:"account_name"`
	MemberID    uint64    `json:"member_id"`
	MemberName  string    `json:"member_name"`
	Email       string    `json:"email"`
	Phone       string    `json:"phone,omitempty"`
	CountryCode string    `json:"country_code,omitempty"`
	Avatar      string    `json:"avatar,omitempty"`
	Locale      string    `json:"locale,omitempty"`
	TimeZone    string    `json:"time_zone,omitempty"`
	CreatedAt   Timestamp `json:"created_at"`
}

type MemberItem

type MemberItem struct {
	MemberID       int       `json:"member_id"`
	MemberName     string    `json:"member_name"`
	Phone          string    `json:"phone,omitempty"`
	PhoneVerified  bool      `json:"phone_verified,omitempty"`
	Email          string    `json:"email,omitempty"`
	EmailVerified  bool      `json:"email_verified,omitempty"`
	AccountRoleIDs []int     `json:"account_role_ids,omitempty"`
	TimeZone       string    `json:"time_zone,omitempty"`
	Locale         string    `json:"locale,omitempty"`
	Status         string    `json:"status"`
	CreatedAt      Timestamp `json:"created_at"`
	UpdatedAt      Timestamp `json:"updated_at"`
	RefID          string    `json:"ref_id,omitempty"`
}

MemberItem represents a member item as defined in the OpenAPI spec

type MemberItemShort

type MemberItemShort struct {
	MemberID   int    `json:"MemberID"`
	MemberName string `json:"MemberName"`
}

MemberItemShort represents a short member item for invite response

type MemberListResponse

type MemberListResponse struct {
	Error *DutyError `json:"error,omitempty"`
	Data  *struct {
		P     int          `json:"p"`
		Limit int          `json:"limit"`
		Total int          `json:"total"`
		Items []MemberItem `json:"items"`
	} `json:"data,omitempty"`
}

MemberListResponse represents the response for member list API

type MergeAlertsInput

type MergeAlertsInput struct {
	AlertIDs   []string // Required
	IncidentID string   // Required
	Comment    string   // Optional
	Title      string   // Optional
}

MergeAlertsInput contains parameters for merging alerts into an incident

type MergeIncidentsInput

type MergeIncidentsInput struct {
	SourceIncidentIDs []string // Required: IDs to merge (max 100)
	TargetIncidentID  string   // Required: destination incident
}

MergeIncidentsInput contains parameters for merging incidents

type MetricsBase

type MetricsBase struct {
	Hours         string    `json:"hours,omitempty" toon:"hours,omitempty"`
	TS            Timestamp `json:"ts,omitempty" toon:"ts,omitempty"`
	ChannelID     int64     `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	TeamID        int64     `json:"team_id,omitempty" toon:"team_id,omitempty"`
	ResponderID   int64     `json:"responder_id,omitempty" toon:"responder_id,omitempty"`
	AccountID     int64     `json:"account_id,omitempty" toon:"account_id,omitempty"`
	TeamName      string    `json:"team_name,omitempty" toon:"team_name,omitempty"`
	ChannelName   string    `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	ResponderName string    `json:"responder_name,omitempty" toon:"responder_name,omitempty"`
}

MetricsBase represents the shared bucket and dimension fields returned by /insight/* APIs.

type MonitAgentCatalogInput

type MonitAgentCatalogInput struct {
	TargetLocator string
	TargetKind    string
}

MonitAgentCatalogInput is the request payload for /monit/tools/catalog. TargetKind is optional — the agent infers it from TargetLocator when unambiguous (e.g. host:web-01 → host, mysql:prod-master → mysql).

type MonitAgentCatalogOutput

type MonitAgentCatalogOutput struct {
	Tools []MonitAgentTool `json:"tools"`
}

MonitAgentCatalogOutput is the decoded response from /monit/tools/catalog.

type MonitAgentInvokeInput

type MonitAgentInvokeInput struct {
	TargetLocator string
	TargetKind    string
	Tools         []MonitAgentInvokeTool
}

MonitAgentInvokeInput is the request payload for /monit/tools/invoke. At most 8 tools may be invoked per call; the runner executes them concurrently and returns them in the same order.

type MonitAgentInvokeOutput

type MonitAgentInvokeOutput struct {
	Results []MonitAgentInvokeResult `json:"results"`
}

MonitAgentInvokeOutput is the decoded response from /monit/tools/invoke.

Three error layers exist and callers must distinguish them:

  1. The error returned by this method — an HTTP-level failure (network error, 5xx, malformed JSON).
  2. A request-level error wrapped in dataEnvelope.Error — surfaced as the method's returned error (target_unavailable, ambiguous_target_kind, unknown_toolset_hash, forward_failed). When this fires, Results is not populated.
  3. Results[i].Error — a per-tool failure; other entries in Results may have succeeded and callers should consume them.

type MonitAgentInvokeResult

type MonitAgentInvokeResult struct {
	Tool  string          `json:"tool"`
	Data  json.RawMessage `json:"data,omitempty"`
	Error string          `json:"error,omitempty"`
}

MonitAgentInvokeResult is one entry in the returned `results` array. The runner returns results in the request order, with the same length as the input `tools` array, even when some tools error — callers must inspect Error per result and not assume "no outer error" means all tools succeeded.

Data carries the per-tool payload (typically {summary, data}) and is left as RawMessage so the agent doesn't have to model every tool's shape.

type MonitAgentInvokeTool

type MonitAgentInvokeTool struct {
	Tool   string          `json:"tool"`
	Params json.RawMessage `json:"params,omitempty"`
}

MonitAgentInvokeTool is a single entry in the /monit/tools/invoke `tools` array. Params is the tool-specific argument payload — left as RawMessage so callers can pass the JSON they already have without round-tripping through map[string]any.

type MonitAgentTool

type MonitAgentTool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"input_schema"`
}

MonitAgentTool describes a single tool the runner exposes for a target. InputSchema is a JSON Schema fragment, intentionally kept as RawMessage so callers can pipe it straight to a tool-using LLM without re-marshalling.

type MonitQueryDiagnoseInput

type MonitQueryDiagnoseInput struct {
	DsType         string
	DsName         string
	TimeStart      int64
	TimeEnd        int64
	Operation      string
	Input          MonitQueryDiagnoseQuery
	MaxLogsScanned int
	MaxPatterns    int
	TimeoutSeconds int
}

MonitQueryDiagnoseInput is the request payload for /monit/query/diagnose.

TimeStart and TimeEnd are unix seconds; they marshal into a nested time_range:{start,end} object on the wire. The server defaults the time range to the last 15m if both are zero and rejects spans > 6h.

MaxLogsScanned, MaxPatterns and TimeoutSeconds are optional caps; the server applies defaults (10000 / 20 / 25) when omitted and refuses values above 50000 / 50 / 30. Operation is also optional — the agent infers it from DsType (`log_patterns` for log datasources, `metric_trends` for metric datasources).

type MonitQueryDiagnoseOutput

type MonitQueryDiagnoseOutput struct {
	Operation string          `json:"operation"`
	Results   json.RawMessage `json:"results"`
}

MonitQueryDiagnoseOutput is the decoded response from /monit/query/diagnose. Results varies by Operation (log_patterns vs metric_trends), so it is left as RawMessage for callers to decode based on Operation.

type MonitQueryDiagnoseQuery

type MonitQueryDiagnoseQuery struct {
	Query string `json:"query"`
}

MonitQueryDiagnoseQuery is the inner `input` payload of /monit/query/diagnose. For log datasources it is a filter-only LogsQL/LogQL query; for metric datasources it is a matrix PromQL expression.

type MonitQueryRowsInput

type MonitQueryRowsInput struct {
	DsType string
	DsName string
	Expr   string
	Args   map[string]string
}

MonitQueryRowsInput is the request payload for /monit/query/rows.

Args carries template parameters for parameterized queries; the server contract requires every arg value to be a string (no implicit coercion).

type MonitQueryRowsOutput

type MonitQueryRowsOutput struct {
	Data json.RawMessage `json:"-"`
}

MonitQueryRowsOutput is the decoded response from /monit/query/rows. Data shape varies per datasource (PromQL instant vector, MySQL rows, …) so it is left as RawMessage for callers to shape.

func (*MonitQueryRowsOutput) UnmarshalJSON

func (o *MonitQueryRowsOutput) UnmarshalJSON(b []byte) error

UnmarshalJSON captures the entire response data field as a RawMessage so callers can decode per-datasource. The server returns data as a JSON array of {fields,values} objects, but the row schema is datasource-specific.

type MonitorRuleFolderStatus

type MonitorRuleFolderStatus struct {
	FolderID           int64  `json:"folder_id"`
	FolderName         string `json:"folder_name,omitempty"`
	RuleTotal          int64  `json:"rule_total"`
	TriggeredRuleCount int64  `json:"triggered_rule_count"`
}

MonitorRuleFolderStatus contains monitor rule counts for a single folder family.

type NotificationTrendPoint

type NotificationTrendPoint struct {
	Timestamp  Timestamp `json:"ts"`
	SMSCount   int       `json:"sms_cnt"`
	VoiceCount int       `json:"voice_cnt"`
	EmailCount int       `json:"email_cnt"`
}

NotificationTrendPoint preserves the per-channel notification counters for each time bucket.

type NotifyBy

type NotifyBy struct {
	FollowPreference bool     `json:"follow_preference" toon:"follow_preference"`
	Critical         []string `json:"critical,omitempty" toon:"critical,omitempty"`
	Warning          []string `json:"warning,omitempty" toon:"warning,omitempty"`
	Info             []string `json:"info,omitempty" toon:"info,omitempty"`
}

NotifyBy represents direct message notification configuration

type Option

type Option func(*Client)

Option configures the Client

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets the base URL for the API client. Invalid URLs are validated eagerly; NewClient returns an error if parsing fails.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets a custom HTTP client. Nil values are ignored.

func WithLogger

func WithLogger(l Logger) Option

WithLogger sets a custom logger for the SDK client. Nil values are ignored.

func WithRequestHeaders

func WithRequestHeaders(headers http.Header) Option

WithRequestHeaders sets static headers that will be included in every API request. These are applied after the SDK's own headers (Content-Type, Accept, User-Agent).

func WithRequestHook

func WithRequestHook(hook func(*http.Request)) Option

WithRequestHook sets a callback invoked on every outgoing HTTP request before it is sent. Use this to inject per-request headers such as W3C Trace Context (traceparent/tracestate). The hook receives the fully constructed *http.Request and may modify headers or other fields.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP client timeout

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent sets the User-Agent header

type OutputFormat

type OutputFormat string

OutputFormat defines the serialization format for tool results

const (
	// OutputFormatJSON uses standard JSON serialization (default)
	OutputFormatJSON OutputFormat = "json"
	// OutputFormatTOON uses Token-Oriented Object Notation for reduced token usage
	OutputFormatTOON OutputFormat = "toon"
)

func ParseOutputFormat

func ParseOutputFormat(s string) OutputFormat

ParseOutputFormat converts a string to OutputFormat, defaulting to JSON

func (OutputFormat) String

func (f OutputFormat) String() string

String returns the string representation of OutputFormat

type PersonInfo

type PersonInfo struct {
	PersonID   int64  `json:"person_id" toon:"person_id"`
	PersonName string `json:"person_name" toon:"person_name"`
	Email      string `json:"email,omitempty" toon:"email,omitempty"`
	Avatar     string `json:"avatar,omitempty" toon:"avatar,omitempty"`
	As         string `json:"as,omitempty" toon:"as,omitempty"`
}

PersonInfo represents person information from /person/infos API

type PersonTarget

type PersonTarget struct {
	PersonID   int64  `json:"person_id" toon:"person_id"`
	PersonName string `json:"person_name,omitempty" toon:"person_name,omitempty"`
	Email      string `json:"email,omitempty" toon:"email,omitempty"`
}

PersonTarget represents a person in escalation target

type PostMortem

type PostMortem struct {
	AccountID        int64     `json:"account_id,omitempty" toon:"account_id,omitempty"`
	PostMortemID     string    `json:"post_mortem_id" toon:"post_mortem_id"`
	TemplateID       string    `json:"template_id,omitempty" toon:"template_id,omitempty"`
	IncidentIDs      []string  `json:"incident_ids,omitempty" toon:"incident_ids,omitempty"`
	MediaCount       int       `json:"media_count,omitempty" toon:"media_count,omitempty"`
	AuthorIDs        []int64   `json:"author_ids,omitempty" toon:"author_ids,omitempty"`
	TeamID           int64     `json:"team_id,omitempty" toon:"team_id,omitempty"`
	ChannelID        int64     `json:"channel_id,omitempty" toon:"channel_id,omitempty"`
	ChannelName      string    `json:"channel_name,omitempty" toon:"channel_name,omitempty"`
	IsPrivate        bool      `json:"is_private,omitempty" toon:"is_private,omitempty"`
	Title            string    `json:"title,omitempty" toon:"title,omitempty"`
	Status           string    `json:"status,omitempty" toon:"status,omitempty"`
	CreatedAtSeconds Timestamp `json:"created_at_seconds,omitempty" toon:"created_at_seconds,omitempty"`
	UpdatedAtSeconds Timestamp `json:"updated_at_seconds,omitempty" toon:"updated_at_seconds,omitempty"`
}

PostMortem represents post-mortem metadata returned by /incident/post-mortem/list.

type QueryChangeTrendInput

type QueryChangeTrendInput struct {
	Step      string // Required: day, week, or month
	StartTime int64  // Required: Unix seconds
	EndTime   int64  // Required: Unix seconds
}

QueryChangeTrendInput contains parameters for querying change volume trends

type QueryChangeTrendOutput

type QueryChangeTrendOutput struct {
	DataPoints []ChangeTrendPoint `json:"data_points"`
}

QueryChangeTrendOutput contains change volume trend data

type QueryInsightAlertTopKInput

type QueryInsightAlertTopKInput struct {
	InsightQueryInput
	Label   string // Required: "check" or "resource"
	K       int    // Top K results (1-100, default 20)
	OrderBy string // "total_alert_cnt" or "total_alert_event_cnt"
	Asc     bool   // Sort ascending when true
}

QueryInsightAlertTopKInput contains parameters for querying top alert sources

type QueryInsightAlertTopKOutput

type QueryInsightAlertTopKOutput struct {
	Items []InsightAlertByLabelItem `json:"items"`
}

QueryInsightAlertTopKOutput contains top-K alert sources

type QueryInsightByChannelOutput

type QueryInsightByChannelOutput struct {
	Items []DimensionInsightItem `json:"items"`
}

QueryInsightByChannelOutput contains per-channel insight metrics

type QueryInsightByResponderOutput

type QueryInsightByResponderOutput struct {
	Items []ResponderInsightItem `json:"items"`
}

QueryInsightByResponderOutput contains per-responder insight metrics

type QueryInsightByTeamOutput

type QueryInsightByTeamOutput struct {
	Items []DimensionInsightItem `json:"items"`
}

QueryInsightByTeamOutput contains team-level insight metrics

type QueryInsightIncidentListInput

type QueryInsightIncidentListInput struct {
	InsightQueryInput
	Limit          int    // Max results (default 20)
	Page           int    // Page number (default 1)
	SearchAfterCtx string // Cursor for the next page when returned by the API
	OrderBy        string // Deprecated: the API does not support orderby for this endpoint
}

QueryInsightIncidentListInput contains parameters for querying incidents with metrics

type QueryInsightIncidentListOutput

type QueryInsightIncidentListOutput struct {
	Items          []InsightIncidentItem `json:"items"`
	Total          int                   `json:"total"`
	HasNextPage    bool                  `json:"has_next_page"`
	SearchAfterCtx string                `json:"search_after_ctx,omitempty"`
}

QueryInsightIncidentListOutput contains incidents with performance metrics

type QueryMonitorRuleStatusInput

type QueryMonitorRuleStatusInput struct {
	// Deprecated: /monit/rule/counter/status does not currently accept request filters.
	TeamID int64
}

QueryMonitorRuleStatusInput contains parameters for querying monitor rule status

type QueryMonitorRuleStatusOutput

type QueryMonitorRuleStatusOutput struct {
	Statuses []MonitorRuleFolderStatus `json:"statuses"`
}

QueryMonitorRuleStatusOutput contains monitor rule status summaries.

type QueryNotificationTrendInput

type QueryNotificationTrendInput struct {
	ChannelIDs []int64 // Optional: filter by channels
	Step       string  // Required: day, week, or month
	StartTime  int64   // Required: Unix seconds
	EndTime    int64   // Required: Unix seconds
}

QueryNotificationTrendInput contains parameters for querying notification trends

type QueryNotificationTrendOutput

type QueryNotificationTrendOutput struct {
	DataPoints []NotificationTrendPoint `json:"data_points"`
}

QueryNotificationTrendOutput contains notification volume trend data

type RawIncident

type RawIncident struct {
	IncidentID  string            `json:"incident_id"`
	Title       string            `json:"title"`
	Description string            `json:"description,omitempty"`
	Severity    string            `json:"incident_severity"`
	Progress    string            `json:"progress"`
	StartTime   Timestamp         `json:"start_time"`
	AckTime     Timestamp         `json:"ack_time,omitempty"`
	CloseTime   Timestamp         `json:"close_time,omitempty"`
	ChannelID   int64             `json:"channel_id,omitempty"`
	CreatorID   int64             `json:"creator_id,omitempty"`
	CloserID    int64             `json:"closer_id,omitempty"`
	Responders  []RawResponder    `json:"responders,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Fields      map[string]any    `json:"fields,omitempty"`
}

RawIncident represents raw incident data from API

type RawResponder

type RawResponder struct {
	PersonID       int64     `json:"person_id"`
	AssignedAt     Timestamp `json:"assigned_at,omitempty"`
	AcknowledgedAt Timestamp `json:"acknowledged_at,omitempty"`
	PersonName     string    `json:"person_name,omitempty"`
	Email          string    `json:"email,omitempty"`
	As             string    `json:"as,omitempty"`
}

RawResponder represents raw responder data from API

type RawTimelineItem

type RawTimelineItem struct {
	RefID     string         `json:"ref_id,omitempty"`
	Type      string         `json:"type"`
	CreatedAt TimestampMilli `json:"created_at"`
	UpdatedAt TimestampMilli `json:"updated_at,omitempty"`
	AccountID int64          `json:"account_id,omitempty"`
	CreatorID int64          `json:"creator_id,omitempty"`
	PersonID  int64          `json:"person_id,omitempty"`
	Detail    map[string]any `json:"detail,omitempty"`
}

RawTimelineItem represents raw timeline data from API

type ReassignIncidentsInput

type ReassignIncidentsInput struct {
	IncidentIDs []string // Required
	PersonIDs   []int64  // Required: new responders
}

ReassignIncidentsInput contains parameters for reassigning incidents

type ResponderInsightItem

type ResponderInsightItem struct {
	MetricsBase

	Email                           string  `json:"email,omitempty" toon:"email,omitempty"`
	TotalIncidentCnt                int     `json:"total_incident_cnt" toon:"total_incident_cnt"`
	TotalIncidentsAcknowledged      int     `json:"total_incidents_acknowledged" toon:"total_incidents_acknowledged"`
	TotalIncidentsReassigned        int     `json:"total_incidents_reassigned" toon:"total_incidents_reassigned"`
	TotalIncidentsEscalated         int     `json:"total_incidents_escalated" toon:"total_incidents_escalated"`
	TotalIncidentsTimeoutEscalated  int     `json:"total_incidents_timeout_escalated" toon:"total_incidents_timeout_escalated"`
	TotalIncidentsManuallyEscalated int     `json:"total_incidents_manually_escalated" toon:"total_incidents_manually_escalated"`
	TotalInterruptions              int     `json:"total_interruptions" toon:"total_interruptions"`
	TotalNotifications              int     `json:"total_notifications" toon:"total_notifications"`
	TotalEngagedSeconds             int     `json:"total_engaged_seconds" toon:"total_engaged_seconds"`
	TotalSecondsToAck               int     `json:"total_seconds_to_ack" toon:"total_seconds_to_ack"`
	MeanSecondsToAck                float64 `json:"mean_seconds_to_ack" toon:"mean_seconds_to_ack"`
	AcknowledgementPct              float64 `json:"acknowledgement_pct" toon:"acknowledgement_pct"`
}

ResponderInsightItem represents per-responder pre-aggregated metrics.

type ScheduleCalculatedLayer

type ScheduleCalculatedLayer struct {
	LayerName string                       `json:"layer_name"`
	Name      string                       `json:"name"`
	Mode      int                          `json:"mode"`
	Schedules []ScheduleCalculatedSchedule `json:"schedules"`
}

ScheduleCalculatedLayer represents computed schedule slots for a single layer.

type ScheduleCalculatedSchedule

type ScheduleCalculatedSchedule struct {
	Start Timestamp     `json:"start"`
	End   Timestamp     `json:"end"`
	Group ScheduleGroup `json:"group"`
	Index int           `json:"index"`
}

ScheduleCalculatedSchedule represents a computed slot inside a layer.

type ScheduleDetail

type ScheduleDetail struct {
	ID             *int64                    `json:"id,omitempty"`
	Name           *string                   `json:"name,omitempty"`
	AccountID      int64                     `json:"account_id"`
	GroupID        *int64                    `json:"group_id,omitempty"`
	Disabled       *int                      `json:"disabled,omitempty"`
	CreateAt       Timestamp                 `json:"create_at"`
	CreateBy       int64                     `json:"create_by"`
	UpdateAt       Timestamp                 `json:"update_at"`
	UpdateBy       int64                     `json:"update_by"`
	Layers         []ScheduleLayer           `json:"layers,omitempty"`
	Field          string                    `json:"field,omitempty"`
	ScheduleLayers []ScheduleCalculatedLayer `json:"schedule_layers,omitempty"`
	FinalSchedule  ScheduleCalculatedLayer   `json:"final_schedule"`
	Start          Timestamp                 `json:"start,omitempty"`
	End            Timestamp                 `json:"end,omitempty"`
	Notify         ScheduleNotify            `json:"notify,omitempty"`
	ScheduleID     int64                     `json:"schedule_id"`
	ScheduleName   *string                   `json:"schedule_name,omitempty"`
	TeamID         *int64                    `json:"team_id,omitempty"`
	Description    *string                   `json:"description,omitempty"`
	LayerSchedules []ScheduleCalculatedLayer `json:"layer_schedules,omitempty"`
	Status         *int                      `json:"status,omitempty"`
	CurOncall      *ScheduleOncallGroup      `json:"cur_oncall,omitempty"`
	NextOncall     *ScheduleOncallGroup      `json:"next_oncall,omitempty"`
}

ScheduleDetail represents the schedule payload returned by /schedule/list and /schedule/info.

type ScheduleGroup

type ScheduleGroup struct {
	GroupName string           `json:"group_name"`
	Name      string           `json:"name"`
	Members   []ScheduleMember `json:"members"`
	Start     Timestamp        `json:"start"`
	End       Timestamp        `json:"end"`
}

ScheduleGroup represents a rotating group inside a schedule layer.

type ScheduleInfo

type ScheduleInfo struct {
	ScheduleID   int64  `json:"schedule_id" toon:"schedule_id"`
	ScheduleName string `json:"schedule_name" toon:"schedule_name"`
}

ScheduleInfo represents schedule information from /schedule/infos API

type ScheduleLayer

type ScheduleLayer struct {
	AccountID             int64            `json:"account_id"`
	Name                  string           `json:"name"`
	ScheduleID            int64            `json:"schedule_id"`
	Hidden                int              `json:"hidden"`
	Mode                  int              `json:"mode"`
	Weight                int              `json:"weight"`
	Groups                []ScheduleGroup  `json:"groups"`
	RotationDuration      int64            `json:"rotation_duration"`
	HandoffTime           int64            `json:"handoff_time"`
	EnableTime            Timestamp        `json:"enable_time"`
	ExpireTime            Timestamp        `json:"expire_time"`
	RestrictMode          int              `json:"restrict_mode"`
	RestrictStart         int64            `json:"restrict_start"`
	RestrictEnd           int64            `json:"restrict_end"`
	RestrictPeriods       []map[string]any `json:"restrict_periods,omitempty"`
	DayMask               map[string]any   `json:"day_mask,omitempty"`
	CreateAt              Timestamp        `json:"create_at"`
	CreateBy              int64            `json:"create_by"`
	UpdateAt              Timestamp        `json:"update_at"`
	UpdateBy              int64            `json:"update_by"`
	LayerName             string           `json:"layer_name,omitempty"`
	FairRotation          bool             `json:"fair_rotation,omitempty"`
	LayerStart            Timestamp        `json:"layer_start,omitempty"`
	LayerEnd              *Timestamp       `json:"layer_end,omitempty"`
	RotationUnit          string           `json:"rotation_unit,omitempty"`
	RotationValue         int64            `json:"rotation_value,omitempty"`
	MaskContinuousEnabled bool             `json:"mask_continuous_enabled,omitempty"`
}

ScheduleLayer represents a configured layer in a schedule.

type ScheduleMember

type ScheduleMember struct {
	RoleID    int64   `json:"role_id"`
	PersonIDs []int64 `json:"person_ids"`
}

ScheduleMember represents a role and the people assigned under it.

type ScheduleNotify

type ScheduleNotify struct {
	AdvanceInTime int64                   `json:"advance_in_time,omitempty"`
	FixedTime     map[string]any          `json:"fixed_time,omitempty"`
	By            map[string]any          `json:"by,omitempty"`
	IM            map[string]string       `json:"im,omitempty"`
	Webhooks      []ScheduleNotifyWebhook `json:"webhooks,omitempty"`
}

ScheduleNotify represents schedule notification settings.

type ScheduleNotifyWebhook

type ScheduleNotifyWebhook struct {
	Type  string `json:"type,omitempty"`
	Name  string `json:"name,omitempty"`
	Token string `json:"token,omitempty"`
	URL   string `json:"url,omitempty"`
}

ScheduleNotifyWebhook represents a configured schedule notification target.

type ScheduleOncallGroup

type ScheduleOncallGroup struct {
	Start    Timestamp     `json:"start"`
	End      Timestamp     `json:"end"`
	Group    ScheduleGroup `json:"group"`
	UpdateAt Timestamp     `json:"update_at"`
	Weight   int           `json:"weight"`
	Index    int           `json:"index"`
}

ScheduleOncallGroup represents the current or next on-call group snapshot.

type ScheduleTarget

type ScheduleTarget struct {
	ScheduleID   int64   `json:"schedule_id" toon:"schedule_id"`
	ScheduleName string  `json:"schedule_name,omitempty" toon:"schedule_name,omitempty"`
	RoleIDs      []int64 `json:"role_ids,omitempty" toon:"role_ids,omitempty"`
}

ScheduleTarget represents a schedule in escalation target

type SearchAuditLogsInput

type SearchAuditLogsInput struct {
	StartTime int64 // Required: Unix seconds
	EndTime   int64 // Required: Unix seconds
	Limit     int   // Max results (default 20)

	RequestID      string   // Optional: filter by request ID
	SearchAfterCtx string   // Optional: opaque cursor for the next page
	Operations     []string // Optional: filter by operation names
	PersonID       int64    // Optional: filter by operator person ID
	IsDangerous    *bool    // Optional: filter high-risk operations
	IsWrite        *bool    // Optional: filter read/write operations

	// Deprecated: use Operations.
	Operation string
	// Deprecated: use PersonID.
	OperatorID int64
	// Deprecated: /audit/search uses SearchAfterCtx for pagination.
	Page int
}

SearchAuditLogsInput contains parameters for searching audit logs

type SearchAuditLogsOutput

type SearchAuditLogsOutput struct {
	AuditLogs      []AuditLogRecord `json:"audit_logs"`
	Total          int64            `json:"total"`
	SearchAfterCtx string           `json:"search_after_ctx"`
}

SearchAuditLogsOutput contains audit log entries plus the next-page cursor.

type SnoozeIncidentsInput

type SnoozeIncidentsInput struct {
	IncidentIDs []string // Required
	Minutes     int64    // Required: snooze duration in minutes (max 1440)
}

SnoozeIncidentsInput contains parameters for snoozing incidents

type StartStatusPageEmailSubscriberMigrationInput

type StartStatusPageEmailSubscriberMigrationInput struct {
	SourceAPIKey string // Required. API key for the source provider
	SourcePageID string // Required. Page identifier in the source provider
	TargetPageID int64  // Required. Flashduty status page ID to import into
}

StartStatusPageEmailSubscriberMigrationInput contains parameters for starting an email subscriber migration from an external provider into an existing Flashduty status page.

type StartStatusPageMigrationInput

type StartStatusPageMigrationInput struct {
	SourceAPIKey string // Required. API key for the source provider (e.g. Atlassian Statuspage)
	SourcePageID string // Required. Page identifier in the source provider
	URLName      string // Optional. URL name to use when creating a new Flashduty public status page
}

StartStatusPageMigrationInput contains parameters for starting a status page structure and history migration from an external provider.

type StartStatusPageMigrationOutput

type StartStatusPageMigrationOutput struct {
	JobID string `json:"job_id"`
}

StartStatusPageMigrationOutput contains the result of starting an async status page migration. Both structure and email subscriber migrations return a job ID that can be polled with GetStatusPageMigrationStatus.

type StatusChange

type StatusChange struct {
	ChangeID    int64            `json:"change_id" toon:"change_id"`
	PageID      int64            `json:"page_id" toon:"page_id"`
	Title       string           `json:"title" toon:"title"`
	Description string           `json:"description,omitempty" toon:"description,omitempty"`
	Type        string           `json:"type" toon:"type"`
	Status      string           `json:"status" toon:"status"`
	CreatedAt   Timestamp        `json:"created_at" toon:"created_at"`
	UpdatedAt   Timestamp        `json:"updated_at,omitempty" toon:"updated_at,omitempty"`
	Timelines   []ChangeTimeline `json:"timelines,omitempty" toon:"timelines,omitempty"`
}

StatusChange represents a change event on status page

type StatusComponent

type StatusComponent struct {
	ComponentID   string `json:"component_id" toon:"component_id"`
	ComponentName string `json:"component_name" toon:"component_name"`
	Status        string `json:"status" toon:"status"`
	SectionID     string `json:"section_id,omitempty" toon:"section_id,omitempty"`
}

StatusComponent represents a component in status page

type StatusPage

type StatusPage struct {
	PageID        int64             `json:"page_id" toon:"page_id"`
	PageName      string            `json:"page_name" toon:"page_name"`
	Slug          string            `json:"slug,omitempty" toon:"slug,omitempty"`
	Description   string            `json:"description,omitempty" toon:"description,omitempty"`
	Sections      []StatusSection   `json:"sections,omitempty" toon:"sections,omitempty"`
	Components    []StatusComponent `json:"components,omitempty" toon:"components,omitempty"`
	OverallStatus string            `json:"overall_status,omitempty" toon:"overall_status,omitempty"`
}

StatusPage represents a status page

type StatusPageMigrationJob

type StatusPageMigrationJob struct {
	JobID        string                      `json:"job_id"`
	SourcePageID string                      `json:"source_page_id"`
	TargetPageID int64                       `json:"target_page_id"`
	Phase        string                      `json:"phase"`
	Status       string                      `json:"status"`
	Progress     StatusPageMigrationProgress `json:"progress"`
	Error        string                      `json:"error,omitempty"`
	CreatedAt    Timestamp                   `json:"created_at"`
	UpdatedAt    Timestamp                   `json:"updated_at"`
}

StatusPageMigrationJob describes the state of a status page migration job.

type StatusPageMigrationProgress

type StatusPageMigrationProgress struct {
	TotalSteps           int      `json:"total_steps"`
	CompletedSteps       int      `json:"completed_steps"`
	ComponentsImported   int      `json:"components_imported"`
	SectionsImported     int      `json:"sections_imported"`
	IncidentsImported    int      `json:"incidents_imported"`
	MaintenancesImported int      `json:"maintenances_imported"`
	SubscribersImported  int      `json:"subscribers_imported"`
	SubscribersSkipped   int      `json:"subscribers_skipped"`
	TemplatesImported    int      `json:"templates_imported"`
	Warnings             []string `json:"warnings,omitempty"`
}

StatusPageMigrationProgress describes incremental counters reported by a migration job. Fields are populated best-effort; zero values indicate either the counter does not apply to the current phase or no items of that kind have been processed yet.

type StatusSection

type StatusSection struct {
	SectionID   string `json:"section_id" toon:"section_id"`
	SectionName string `json:"section_name" toon:"section_name"`
}

StatusSection represents a section in status page

type TeamDeleteInput

type TeamDeleteInput struct {
	TeamID   int64
	TeamName string
	RefID    string
}

TeamDeleteInput contains parameters for deleting a team

type TeamGetInput

type TeamGetInput struct {
	TeamID   int64
	TeamName string
	RefID    string
}

TeamGetInput contains parameters for getting a single team

type TeamInfo

type TeamInfo struct {
	TeamID    int64        `json:"team_id" toon:"team_id"`
	TeamName  string       `json:"team_name" toon:"team_name"`
	PersonIDs []int64      `json:"person_ids,omitempty" toon:"person_ids,omitempty"`
	Members   []TeamMember `json:"members,omitempty" toon:"members,omitempty"`
}

TeamInfo represents team information (used by list/batch endpoints)

type TeamItem

type TeamItem struct {
	AccountID     int64        `json:"account_id" toon:"account_id"`
	TeamID        int64        `json:"team_id" toon:"team_id"`
	TeamName      string       `json:"team_name" toon:"team_name"`
	Description   string       `json:"description" toon:"description"`
	Status        string       `json:"status" toon:"status"`
	CreatorID     int64        `json:"creator_id" toon:"creator_id"`
	CreatorName   string       `json:"creator_name" toon:"creator_name"`
	UpdatedBy     int64        `json:"updated_by" toon:"updated_by"`
	UpdatedByName string       `json:"updated_by_name" toon:"updated_by_name"`
	CreatedAt     Timestamp    `json:"created_at" toon:"created_at"`
	UpdatedAt     Timestamp    `json:"updated_at" toon:"updated_at"`
	PersonIDs     []int64      `json:"person_ids" toon:"person_ids"`
	RefID         string       `json:"ref_id" toon:"ref_id"`
	Members       []TeamMember `json:"members,omitempty" toon:"members,omitempty"`
}

TeamItem represents full team detail from /team/info

type TeamMember

type TeamMember struct {
	PersonID   int64  `json:"person_id" toon:"person_id"`
	PersonName string `json:"person_name" toon:"person_name"`
	Email      string `json:"email,omitempty" toon:"email,omitempty"`
}

TeamMember represents a team member

type TeamTarget

type TeamTarget struct {
	TeamID   int64          `json:"team_id" toon:"team_id"`
	TeamName string         `json:"team_name,omitempty" toon:"team_name,omitempty"`
	Members  []PersonTarget `json:"members,omitempty" toon:"members,omitempty"`
}

TeamTarget represents a team in escalation target with members

type TeamUpsertInput

type TeamUpsertInput struct {
	TeamID           int64
	TeamName         string
	Description      string
	PersonIDs        []int64
	Emails           []string
	Phones           []string
	CountryCode      string
	RefID            string
	ResetIfNameExist bool
}

TeamUpsertInput contains parameters for creating or updating a team

type TeamUpsertOutput

type TeamUpsertOutput struct {
	TeamID   int64  `json:"team_id"`
	TeamName string `json:"team_name"`
}

TeamUpsertOutput contains the result of creating or updating a team

type TemplateFunction

type TemplateFunction struct {
	Name        string `json:"name" toon:"name"`
	Syntax      string `json:"syntax" toon:"syntax"`
	Description string `json:"description" toon:"description"`
}

TemplateFunction describes a function available in notification templates

func TemplateCustomFunctions

func TemplateCustomFunctions() []TemplateFunction

TemplateCustomFunctions returns the list of custom Flashduty template functions.

NOTE: This data is compiled into the SDK. Platform-side additions require an SDK release.

func TemplateSprigFunctions

func TemplateSprigFunctions() []TemplateFunction

TemplateSprigFunctions returns the list of commonly used Sprig template functions.

NOTE: This data is compiled into the SDK. Platform-side additions require an SDK release.

type TemplateVariable

type TemplateVariable struct {
	Name        string `json:"name" toon:"name"`
	Type        string `json:"type" toon:"type"`
	Description string `json:"description" toon:"description"`
	Example     string `json:"example,omitempty" toon:"example,omitempty"`
	Category    string `json:"category" toon:"category"`
}

TemplateVariable describes a variable available in notification templates

func TemplateVariables

func TemplateVariables() []TemplateVariable

TemplateVariables returns the list of available template variables.

NOTE: This data is compiled into the SDK. Platform-side additions require an SDK release.

type TimeFilter

type TimeFilter struct {
	Start  string `json:"start" toon:"start"`
	End    string `json:"end" toon:"end"`
	Repeat []int  `json:"repeat,omitempty" toon:"repeat,omitempty"`
	CalID  string `json:"cal_id,omitempty" toon:"cal_id,omitempty"`
	IsOff  bool   `json:"is_off,omitempty" toon:"is_off,omitempty"`
}

TimeFilter represents time-based filter for rule activation

type TimelineEvent

type TimelineEvent struct {
	Type         string         `json:"type" toon:"type"`
	Timestamp    TimestampMilli `json:"timestamp" toon:"timestamp"`
	OperatorID   int64          `json:"operator_id,omitempty" toon:"operator_id,omitempty"`
	OperatorName string         `json:"operator_name,omitempty" toon:"operator_name,omitempty"`
	Detail       any            `json:"detail,omitempty" toon:"detail,omitempty"`
}

TimelineEvent represents an entry in incident timeline

type Timestamp

type Timestamp int64

Timestamp is a Unix-seconds instant as it appears on the Flashduty API wire.

It marshals to an RFC3339 string in the local timezone, so structured output is human- and LLM-readable instead of an opaque integer. It unmarshals from either a numeric epoch (the wire form) or an RFC3339 string (so a marshaled value round-trips). The zero value marshals to 0 — an unset sentinel, never a 1970 date — and is dropped by `json:",omitempty"`.

Use Timestamp only for absolute instants. Durations, cyclic-window offsets, and counts stay int64.

func (Timestamp) IsZero

func (t Timestamp) IsZero() bool

IsZero reports whether the value is the unset sentinel (0).

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON renders a non-zero value as a quoted RFC3339 string in the local timezone; zero renders as the bare integer 0.

func (Timestamp) String

func (t Timestamp) String() string

String renders the instant as RFC3339 in the local timezone, or "0" when unset. Non-JSON encoders (TOON, fmt) render the value through this method.

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Time returns the instant as a time.Time.

func (Timestamp) Unix

func (t Timestamp) Unix() int64

Unix returns the raw wire value (Unix seconds).

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a numeric Unix-seconds epoch, a quoted integer, an RFC3339 string, or null (→ 0).

type TimestampMilli

type TimestampMilli int64

TimestampMilli is a Unix-milliseconds instant. It has the same rendering contract as Timestamp (RFC3339 out, epoch-or-RFC3339 in, zero→0); only the wire unit differs.

func (TimestampMilli) IsZero

func (t TimestampMilli) IsZero() bool

IsZero reports whether the value is the unset sentinel (0).

func (TimestampMilli) MarshalJSON

func (t TimestampMilli) MarshalJSON() ([]byte, error)

MarshalJSON renders a non-zero value as a quoted RFC3339 string in the local timezone; zero renders as the bare integer 0. RFC3339Nano is used so that sub-second (millisecond) precision survives a marshal→unmarshal round-trip; it elides trailing zeros, so whole-second values render identically to a plain RFC3339 timestamp.

func (TimestampMilli) String

func (t TimestampMilli) String() string

String renders the instant as RFC3339Nano in the local timezone (preserving sub-second precision), or "0" when unset. Non-JSON encoders (TOON, fmt) render the value through this method.

func (TimestampMilli) Time

func (t TimestampMilli) Time() time.Time

Time returns the instant as a time.Time.

func (TimestampMilli) Unix

func (t TimestampMilli) Unix() int64

Unix returns the raw wire value (milliseconds since the Unix epoch).

func (*TimestampMilli) UnmarshalJSON

func (t *TimestampMilli) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a numeric Unix-milliseconds epoch, a quoted integer, an RFC3339 string, or null (→ 0).

type UpdateIncidentInput

type UpdateIncidentInput struct {
	IncidentID   string         // Required
	Title        string         // Optional, empty = skip
	Description  string         // Optional
	Severity     string         // Optional
	Impact       string         // Optional
	RootCause    string         // Optional
	Resolution   string         // Optional
	CustomFields map[string]any // Optional
}

UpdateIncidentInput contains parameters for updating an incident

type ValidateTemplateInput

type ValidateTemplateInput struct {
	Channel      string // Required. One of the keys in TemplateChannels.
	TemplateCode string // Required. The Go template code to validate.
	IncidentID   string // Optional. Real incident ID for preview; uses mock data if empty.
}

ValidateTemplateInput contains parameters for validating a template.

type ValidateTemplateOutput

type ValidateTemplateOutput struct {
	Channel         string   `json:"channel"`
	FieldName       string   `json:"field_name"`
	TemplateCode    string   `json:"template_code"`
	Success         bool     `json:"success"`
	RenderedPreview string   `json:"rendered_preview"`
	RenderedSize    int      `json:"rendered_size"`
	SizeLimit       int      `json:"size_limit"`
	Errors          []string `json:"errors"`
	Warnings        []string `json:"warnings"`
}

ValidateTemplateOutput contains the validation result.

type WebhookConfig

type WebhookConfig struct {
	Type     string         `json:"type" toon:"type"`
	Alias    string         `json:"alias,omitempty" toon:"alias,omitempty"`
	Settings map[string]any `json:"settings,omitempty" toon:"settings,omitempty"`
}

WebhookConfig represents a webhook configuration in escalation target

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL