api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheKeyPrefixIncidents      = "incidents"
	CacheKeyPrefixAlerts         = "alerts"
	CacheKeyPrefixIncidentDetail = "incident_detail"
	CacheKeyPrefixAlertDetail    = "alert_detail"
)

Cache key prefixes

View Source
const DefaultCacheTTL = 5 * time.Minute

DefaultCacheTTL is the default cache duration

Variables

View Source
var Version = "dev"

Version is set by the main package to include in User-Agent

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID           string
	ShortID      string
	Summary      string
	Description  string
	Status       string
	Source       string
	CreatedAt    time.Time
	UpdatedAt    time.Time
	StartedAt    *time.Time
	EndedAt      *time.Time
	ExternalURL  string
	Services     []string
	Environments []string
	Groups       []string
	Labels       map[string]string
	// Detail fields (populated by GetAlert)
	Responders   []string
	Urgency      string
	DetailLoaded bool
	// Additional detail fields
	URL                string // Rootly URL
	ExternalID         string // External system ID (e.g., Sentry issue ID)
	Noise              string // "not_noise", "noise", etc.
	IsGroupLeaderAlert bool
	GroupLeaderAlertID string
	NotifiedUsers      []AlertUser     // Users who were notified
	RelatedIncidents   []AlertIncident // Related incidents
	DeduplicationKey   string
	Data               map[string]interface{} // Raw alert payload from source
}

func MockAlerts

func MockAlerts() []Alert

MockAlerts returns sample alert data for testing

type AlertIncident added in v0.2.0

type AlertIncident struct {
	ID           string
	SequentialID string
	Title        string
	Status       string
}

AlertIncident represents an incident related to an alert

type AlertUser added in v0.2.0

type AlertUser struct {
	Name  string
	Email string
}

AlertUser represents a user who was notified about an alert

type AlertsResult

type AlertsResult struct {
	Alerts     []Alert
	Pagination PaginationInfo
}

AlertsResult contains alerts and pagination info

type Cache

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

Cache provides a simple TTL-based in-memory cache

func NewCache

func NewCache(ttl time.Duration) *Cache

NewCache creates a new cache with the given TTL

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all items from the cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes an item from the cache

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

Get retrieves an item from the cache Returns the value and true if found and not expired, nil and false otherwise

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

Set stores an item in the cache

type CacheKeyBuilder

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

CacheKeyBuilder builds cache keys from parameters

func NewCacheKey

func NewCacheKey(prefix string) *CacheKeyBuilder

NewCacheKey creates a new cache key builder

func (*CacheKeyBuilder) Build

func (b *CacheKeyBuilder) Build() string

Build generates the cache key string Format: "prefix:key1=value1:key2=value2" (sorted by key)

func (*CacheKeyBuilder) With

func (b *CacheKeyBuilder) With(key string, value interface{}) *CacheKeyBuilder

With adds a parameter to the cache key

type Client

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

func NewClient

func NewClient(cfg *config.Config) (*Client, error)

func (*Client) ClearCache

func (c *Client) ClearCache()

ClearCache clears all cached data

func (*Client) Close

func (c *Client) Close() error

Close closes the client and releases resources

func (*Client) GetAlert

func (c *Client) GetAlert(ctx context.Context, id string, updatedAt time.Time) (*Alert, error)

GetAlert fetches detailed alert data by ID updatedAt is used for cache invalidation - cache key includes it so changes invalidate the cache

func (*Client) GetIncident

func (c *Client) GetIncident(ctx context.Context, id string, updatedAt time.Time) (*Incident, error)

GetIncident fetches detailed incident data by ID updatedAt is used for cache invalidation - cache key includes it so changes invalidate the cache

func (*Client) ListAlerts

func (c *Client) ListAlerts(ctx context.Context, page int) (*AlertsResult, error)

func (*Client) ListIncidents

func (c *Client) ListIncidents(ctx context.Context, page int, sort string) (*IncidentsResult, error)

func (*Client) ValidateAPIKey

func (c *Client) ValidateAPIKey(ctx context.Context) error

type Incident

type Incident struct {
	ID              string
	SequentialID    string
	Title           string
	Summary         string
	Status          string
	Severity        string
	Kind            string
	CreatedAt       time.Time
	UpdatedAt       time.Time
	StartedAt       *time.Time
	DetectedAt      *time.Time
	AcknowledgedAt  *time.Time
	MitigatedAt     *time.Time
	ResolvedAt      *time.Time
	InTriageAt      *time.Time
	ClosedAt        *time.Time
	CancelledAt     *time.Time
	ScheduledFor    *time.Time
	ScheduledUntil  *time.Time
	Services        []string
	Environments    []string
	Teams           []string
	SlackChannelURL string
	JiraIssueURL    string
	// Detail fields (populated by GetIncident)
	URL              string
	ShortURL         string
	Causes           []string
	IncidentTypes    []string
	Functionalities  []string
	Roles            []IncidentRole
	CommanderName    string
	CommunicatorName string
	CreatedByName    string
	CreatedByEmail   string
	DetailLoaded     bool
	// Additional detail fields
	Source                      string
	Private                     bool
	MitigationMessage           string
	ResolutionMessage           string
	RetrospectiveProgressStatus string
	SlackChannelName            string
	SlackChannelArchived        bool
	Labels                      map[string]string
	StartedByName               string
	StartedByEmail              string
	MitigatedByName             string
	MitigatedByEmail            string
	ResolvedByName              string
	ResolvedByEmail             string
	// Integration links
	GoogleMeetingURL      string
	LinearIssueURL        string
	ZoomMeetingJoinURL    string
	GithubIssueURL        string
	GitlabIssueURL        string
	PagerdutyIncidentURL  string
	OpsgenieIncidentURL   string
	AsanaTaskURL          string
	TrelloCardURL         string
	ConfluencePageURL     string
	DatadogNotebookURL    string
	ServiceNowIncidentURL string
	FreshserviceTicketURL string
}

func MockIncidents

func MockIncidents() []Incident

MockIncidents returns sample incident data for testing

func (*Incident) Duration added in v0.2.0

func (i *Incident) Duration() int64

Duration returns the total incident duration in seconds

func (*Incident) InTriageDuration added in v0.2.0

func (i *Incident) InTriageDuration() int64

InTriageDuration returns time spent in triage in seconds

func (*Incident) MaintenanceDuration added in v0.2.0

func (i *Incident) MaintenanceDuration() int64

MaintenanceDuration returns scheduled maintenance duration in seconds

func (*Incident) TimeToAcknowledge added in v0.2.0

func (i *Incident) TimeToAcknowledge() float64

TimeToAcknowledge returns time from started_at to acknowledged_at in hours

func (*Incident) TimeToClose added in v0.2.0

func (i *Incident) TimeToClose() float64

TimeToClose returns time from started_at to closed_at in hours

func (*Incident) TimeToDetection added in v0.2.0

func (i *Incident) TimeToDetection() float64

TimeToDetection returns time from started_at to detected_at in hours

func (*Incident) TimeToMitigation added in v0.2.0

func (i *Incident) TimeToMitigation() float64

TimeToMitigation returns time from started_at to mitigated_at in hours

func (*Incident) TimeToResolution added in v0.2.0

func (i *Incident) TimeToResolution() float64

TimeToResolution returns time from started_at to resolved_at in hours

func (*Incident) TimeToTriage added in v0.2.0

func (i *Incident) TimeToTriage() float64

TimeToTriage returns time from in_triage_at to started_at in hours

type IncidentRole

type IncidentRole struct {
	Name      string
	UserName  string
	UserEmail string
}

type IncidentsResult

type IncidentsResult struct {
	Incidents  []Incident
	Pagination PaginationInfo
}

IncidentsResult contains incidents and pagination info

type PaginationInfo

type PaginationInfo struct {
	CurrentPage int
	TotalPages  int
	TotalCount  int
	HasNext     bool
	HasPrev     bool
}

PaginationInfo contains pagination state

type PersistentCache

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

PersistentCache provides a TTL-based cache backed by BoltDB

func NewPersistentCache

func NewPersistentCache(ttl time.Duration) (*PersistentCache, error)

NewPersistentCache creates a new persistent cache at ~/.rootly-tui/cache.db

func (*PersistentCache) Cleanup

func (c *PersistentCache) Cleanup()

Cleanup removes expired entries from the cache

func (*PersistentCache) Clear

func (c *PersistentCache) Clear()

Clear removes all items from the cache

func (*PersistentCache) Close

func (c *PersistentCache) Close() error

Close closes the database connection

func (*PersistentCache) Delete

func (c *PersistentCache) Delete(key string)

Delete removes an item from the cache

func (*PersistentCache) Get

func (c *PersistentCache) Get(key string) (interface{}, bool)

Get retrieves an item from the cache

func (*PersistentCache) GetTyped

func (c *PersistentCache) GetTyped(key string, dest interface{}) bool

GetTyped retrieves and unmarshals an item from the cache

func (*PersistentCache) Set

func (c *PersistentCache) Set(key string, value interface{})

Set stores an item in the cache

Jump to

Keyboard shortcuts

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