opsgenie

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID             string            `json:"id"`
	TinyID         string            `json:"tinyId,omitempty"`
	Alias          string            `json:"alias,omitempty"`
	Message        string            `json:"message"`
	Status         AlertStatus       `json:"status,omitempty"`
	Acknowledged   bool              `json:"acknowledged,omitempty"`
	IsSeen         bool              `json:"isSeen,omitempty"`
	Tags           []string          `json:"tags,omitempty"`
	Snoozed        bool              `json:"snoozed,omitempty"`
	SnoozedUntil   *time.Time        `json:"snoozedUntil,omitempty"`
	Count          int               `json:"count,omitempty"`
	LastOccurredAt *time.Time        `json:"lastOccurredAt,omitempty"`
	CreatedAt      time.Time         `json:"createdAt"`
	UpdatedAt      *time.Time        `json:"updatedAt,omitempty"`
	Source         string            `json:"source,omitempty"`
	Owner          string            `json:"owner,omitempty"`
	Priority       Priority          `json:"priority,omitempty"`
	Responders     []Responder       `json:"responders,omitempty"`
	Integration    *Integration      `json:"integration,omitempty"`
	Report         *Report           `json:"report,omitempty"`
	Actions        []string          `json:"actions,omitempty"`
	Entity         string            `json:"entity,omitempty"`
	Description    string            `json:"description,omitempty"`
	Details        map[string]string `json:"details,omitempty"`
}

Alert represents an Opsgenie alert

type AlertRequest

type AlertRequest struct {
	Message     string            `json:"message"`
	Alias       string            `json:"alias,omitempty"`
	Description string            `json:"description,omitempty"`
	Responders  []Responder       `json:"responders,omitempty"`
	VisibleTo   []Responder       `json:"visibleTo,omitempty"`
	Actions     []string          `json:"actions,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Details     map[string]string `json:"details,omitempty"`
	Entity      string            `json:"entity,omitempty"`
	Source      string            `json:"source,omitempty"`
	Priority    Priority          `json:"priority,omitempty"`
	User        string            `json:"user,omitempty"`
	Note        string            `json:"note,omitempty"`
}

AlertRequest represents a request to create or update an alert

type AlertStatus

type AlertStatus string

AlertStatus represents the current status of an alert

const (
	AlertStatusOpen   AlertStatus = "open"
	AlertStatusClosed AlertStatus = "closed"
)

type AsyncResponse

type AsyncResponse struct {
	IsSuccess     bool   `json:"isSuccess"`
	Status        string `json:"status"`
	Action        string `json:"action,omitempty"`
	ProcessedAt   string `json:"processedAt,omitempty"`
	IntegrationID string `json:"integrationId,omitempty"`
	AlertID       string `json:"alertId,omitempty"`
	Alias         string `json:"alias,omitempty"`
}

AsyncResponse represents an asynchronous operation response

type BaseTimeline

type BaseTimeline struct {
	Rotations []TimelineRotation `json:"rotations,omitempty"`
}

BaseTimeline represents the base timeline before overrides

type Client

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

Client is an Opsgenie API client

func NewClient

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

NewClient creates a new Opsgenie client

func (*Client) AcknowledgeAlert

func (c *Client) AcknowledgeAlert(ctx context.Context, id, note string) error

AcknowledgeAlert acknowledges an alert by ID or alias

func (*Client) AddNoteToAlert

func (c *Client) AddNoteToAlert(ctx context.Context, id, note string) error

AddNoteToAlert adds a note to an alert by ID or alias

func (*Client) AddNoteToIncident

func (c *Client) AddNoteToIncident(ctx context.Context, id, note string) error

AddNoteToIncident adds a note to an incident by ID

func (*Client) AddResponderToIncident

func (c *Client) AddResponderToIncident(ctx context.Context, id string, responder *Responder) error

AddResponderToIncident adds a responder to an incident by ID

func (*Client) AddTagsToAlert

func (c *Client) AddTagsToAlert(ctx context.Context, id string, tags []string, note string) error

AddTagsToAlert adds tags to an alert by ID or alias

func (*Client) AssignAlert

func (c *Client) AssignAlert(ctx context.Context, id string, owner *Responder, note string) error

AssignAlert assigns an alert to a specified owner

func (*Client) CloseAlert

func (c *Client) CloseAlert(ctx context.Context, id, note string) error

CloseAlert closes an alert by ID or alias

func (*Client) CloseIncident

func (c *Client) CloseIncident(ctx context.Context, id, note string) error

CloseIncident closes an incident by ID

func (*Client) CountAlerts

func (c *Client) CountAlerts(ctx context.Context, query string) (int, error)

CountAlerts returns the count of alerts matching the query

func (*Client) CreateAlert

func (c *Client) CreateAlert(ctx context.Context, req *AlertRequest) (*CreateAlertResponse, error)

CreateAlert creates a new alert

func (*Client) CreateIncident

func (c *Client) CreateIncident(ctx context.Context, req *IncidentRequest) (*Incident, error)

CreateIncident creates a new incident

func (*Client) EscalateAlert

func (c *Client) EscalateAlert(ctx context.Context, id string, escalation *Responder, note string) error

EscalateAlert escalates an alert to a specified responder (escalation policy)

func (*Client) GetAlert

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

GetAlert retrieves an alert by ID or alias

func (*Client) GetIncident

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

GetIncident retrieves an incident by ID

func (*Client) GetOnCalls

func (c *Client) GetOnCalls(ctx context.Context, schedule string) ([]OnCall, error)

GetOnCalls retrieves the current on-call participants If schedule is provided, returns on-calls for that schedule only. If schedule is empty, returns on-calls for all schedules.

func (*Client) GetRequestStatus

func (c *Client) GetRequestStatus(ctx context.Context, requestID string) (*AsyncResponse, error)

GetRequestStatus retrieves the status of an asynchronous request

func (*Client) GetSchedule

func (c *Client) GetSchedule(ctx context.Context, id string) (*Schedule, error)

GetSchedule retrieves a schedule by ID

func (*Client) GetScheduleTimeline

func (c *Client) GetScheduleTimeline(ctx context.Context, id string, from, to time.Time) (*ScheduleTimeline, error)

GetScheduleTimeline retrieves the timeline for a schedule within a time range

func (*Client) GetTeam

func (c *Client) GetTeam(ctx context.Context, id string) (*Team, error)

GetTeam retrieves a team by ID or name

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, identifier string) (*User, error)

GetUser retrieves a user by identifier (ID, username, or email)

func (*Client) ListAlerts

func (c *Client) ListAlerts(ctx context.Context, query string, limit, offset int) (*ListAlertsResponse, error)

ListAlerts retrieves a list of alerts based on query parameters

func (*Client) ListIncidents

func (c *Client) ListIncidents(ctx context.Context, query string, limit, offset int) (*IncidentResponse, error)

ListIncidents retrieves a list of incidents based on query parameters

func (*Client) ListSchedules

func (c *Client) ListSchedules(ctx context.Context) ([]Schedule, error)

ListSchedules retrieves a list of all schedules

func (*Client) ListTeams

func (c *Client) ListTeams(ctx context.Context) ([]Team, error)

ListTeams retrieves a list of all teams

func (*Client) SnoozeAlert

func (c *Client) SnoozeAlert(ctx context.Context, id, endTime, note string) error

SnoozeAlert snoozes an alert by ID or alias until the specified end time

type Config

type Config struct {
	BaseURL       string
	Auth          auth.Provider
	CustomHeaders map[string]string
	SSLVerify     bool
	HTTPProxy     string
	HTTPSProxy    string
	SOCKSProxy    string
	NoProxy       string
}

Config holds the configuration for creating an Opsgenie client

type CreateAlertResponse

type CreateAlertResponse struct {
	Result    string  `json:"result"`
	Took      float64 `json:"took"`
	RequestID string  `json:"requestId"`
}

CreateAlertResponse represents the response when creating an alert

type DeploymentType

type DeploymentType string

DeploymentType represents the Opsgenie deployment type

const (
	DeploymentCloud DeploymentType = "cloud"
)

type ErrorResponse

type ErrorResponse struct {
	Message   string  `json:"message,omitempty"`
	Took      float64 `json:"took,omitempty"`
	RequestID string  `json:"requestId,omitempty"`
}

ErrorResponse represents an Opsgenie error response

type FinalTimeline

type FinalTimeline struct {
	Rotations []TimelineRotation `json:"rotations,omitempty"`
}

FinalTimeline represents the final computed timeline

type Forwarding

type Forwarding struct {
	FromUser  *User     `json:"fromUser,omitempty"`
	ToUser    *User     `json:"toUser,omitempty"`
	StartDate time.Time `json:"startDate"`
	EndDate   time.Time `json:"endDate"`
}

Forwarding represents a forwarding rule

type Incident

type Incident struct {
	ID               string                 `json:"id"`
	TinyID           string                 `json:"tinyId,omitempty"`
	Message          string                 `json:"message"`
	Status           IncidentStatus         `json:"status"`
	Tags             []string               `json:"tags,omitempty"`
	CreatedAt        time.Time              `json:"createdAt"`
	UpdatedAt        *time.Time             `json:"updatedAt,omitempty"`
	Priority         Priority               `json:"priority"`
	OwnerTeam        string                 `json:"ownerTeam,omitempty"`
	Responders       []Responder            `json:"responders,omitempty"`
	ExtraProperties  map[string]interface{} `json:"extraProperties,omitempty"`
	Actions          []string               `json:"actions,omitempty"`
	Description      string                 `json:"description,omitempty"`
	Details          map[string]string      `json:"details,omitempty"`
	ImpactedServices []string               `json:"impactedServices,omitempty"`
}

Incident represents an Opsgenie incident

type IncidentRequest

type IncidentRequest struct {
	Message            string            `json:"message"`
	Description        string            `json:"description,omitempty"`
	Responders         []Responder       `json:"responders,omitempty"`
	Tags               []string          `json:"tags,omitempty"`
	Details            map[string]string `json:"details,omitempty"`
	Priority           Priority          `json:"priority"`
	Note               string            `json:"note,omitempty"`
	ServiceID          string            `json:"serviceId,omitempty"`
	StatusPageEntity   *StatusPageEntity `json:"statusPageEntity,omitempty"`
	NotifyStakeholders bool              `json:"notifyStakeholders,omitempty"`
	ImpactedServices   []string          `json:"impactedServices,omitempty"`
}

IncidentRequest represents a request to create or update an incident

type IncidentResponse

type IncidentResponse struct {
	Data      *Incident `json:"data,omitempty"`
	Result    string    `json:"result,omitempty"`
	Took      float64   `json:"took,omitempty"`
	RequestID string    `json:"requestId,omitempty"`
}

IncidentResponse represents a generic incident response

type IncidentStatus

type IncidentStatus string

IncidentStatus represents the current status of an incident

const (
	IncidentStatusOpen     IncidentStatus = "open"
	IncidentStatusResolved IncidentStatus = "resolved"
	IncidentStatusClosed   IncidentStatus = "closed"
)

type Integration

type Integration struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
}

Integration represents integration information

type ListAlertsResponse

type ListAlertsResponse struct {
	Data      []Alert     `json:"data"`
	Paging    *Pagination `json:"paging,omitempty"`
	Took      float64     `json:"took,omitempty"`
	RequestID string      `json:"requestId,omitempty"`
}

ListAlertsResponse represents the response when listing alerts

type OnCall

type OnCall struct {
	ScheduleID       string   `json:"scheduleId,omitempty"`
	ScheduleName     string   `json:"scheduleName,omitempty"`
	OnCallRecipients []string `json:"onCallRecipients,omitempty"`
}

OnCall represents on-call information

type Override

type Override struct {
	Alias     string    `json:"alias,omitempty"`
	User      *User     `json:"user,omitempty"`
	StartDate time.Time `json:"startDate"`
	EndDate   time.Time `json:"endDate"`
}

Override represents a schedule override

type Pagination

type Pagination struct {
	First string `json:"first,omitempty"`
	Next  string `json:"next,omitempty"`
	Last  string `json:"last,omitempty"`
	Prev  string `json:"prev,omitempty"`
}

Pagination represents pagination information

type Priority

type Priority string

Priority represents alert/incident priority

const (
	PriorityP1 Priority = "P1"
	PriorityP2 Priority = "P2"
	PriorityP3 Priority = "P3"
	PriorityP4 Priority = "P4"
	PriorityP5 Priority = "P5"
)

type Report

type Report struct {
	AckTime        int64  `json:"ackTime,omitempty"`
	CloseTime      int64  `json:"closeTime,omitempty"`
	AcknowledgedBy string `json:"acknowledgedBy,omitempty"`
	ClosedBy       string `json:"closedBy,omitempty"`
}

Report represents alert report information

type Responder

type Responder struct {
	Type ResponderType `json:"type"`
	ID   string        `json:"id,omitempty"`
	Name string        `json:"name,omitempty"`
}

Responder represents a responder (user, team, escalation, or schedule)

type ResponderType

type ResponderType string

ResponderType represents the type of responder

const (
	ResponderTypeUser       ResponderType = "user"
	ResponderTypeTeam       ResponderType = "team"
	ResponderTypeEscalation ResponderType = "escalation"
	ResponderTypeSchedule   ResponderType = "schedule"
)

type Restriction

type Restriction struct {
	StartDay  string `json:"startDay,omitempty"`
	StartHour int    `json:"startHour,omitempty"`
	StartMin  int    `json:"startMin,omitempty"`
	EndDay    string `json:"endDay,omitempty"`
	EndHour   int    `json:"endHour,omitempty"`
	EndMin    int    `json:"endMin,omitempty"`
}

Restriction represents a specific time restriction

type Role

type Role struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Role represents a user role

type Rotation

type Rotation struct {
	ID              string           `json:"id,omitempty"`
	Name            string           `json:"name,omitempty"`
	StartDate       *time.Time       `json:"startDate,omitempty"`
	EndDate         *time.Time       `json:"endDate,omitempty"`
	Type            string           `json:"type,omitempty"`
	Length          int              `json:"length,omitempty"`
	Participants    []Responder      `json:"participants,omitempty"`
	TimeRestriction *TimeRestriction `json:"timeRestriction,omitempty"`
}

Rotation represents a schedule rotation

type Schedule

type Schedule struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description,omitempty"`
	Timezone    string     `json:"timezone,omitempty"`
	Enabled     bool       `json:"enabled,omitempty"`
	OwnerTeam   *Team      `json:"ownerTeam,omitempty"`
	Rotations   []Rotation `json:"rotations,omitempty"`
}

Schedule represents an Opsgenie schedule

type ScheduleOnCallResponse

type ScheduleOnCallResponse struct {
	Parent struct {
		ID      string `json:"id"`
		Name    string `json:"name"`
		Enabled bool   `json:"enabled"`
	} `json:"_parent"`
	OnCallParticipants []string `json:"onCallParticipants"`
}

ScheduleOnCallResponse represents the response from per-schedule on-call endpoint

type ScheduleTimeline

type ScheduleTimeline struct {
	StartDate     time.Time      `json:"startDate"`
	EndDate       time.Time      `json:"endDate"`
	FinalTimeline *FinalTimeline `json:"finalTimeline,omitempty"`
	BaseTimeline  *BaseTimeline  `json:"baseTimeline,omitempty"`
	Overrides     []Override     `json:"overrides,omitempty"`
	Forwardings   []Forwarding   `json:"forwardings,omitempty"`
}

ScheduleTimeline represents schedule timeline information

type StatusPageEntity

type StatusPageEntity struct {
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
}

StatusPageEntity represents status page entity information

type Team

type Team struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Members     []TeamMember `json:"members,omitempty"`
}

Team represents an Opsgenie team

type TeamMember

type TeamMember struct {
	User *User  `json:"user,omitempty"`
	Role string `json:"role,omitempty"`
}

TeamMember represents a team member

type TimeRestriction

type TimeRestriction struct {
	Type         string        `json:"type,omitempty"`
	Restrictions []Restriction `json:"restrictions,omitempty"`
}

TimeRestriction represents time-based restrictions

type TimelinePeriod

type TimelinePeriod struct {
	StartDate time.Time  `json:"startDate"`
	EndDate   time.Time  `json:"endDate"`
	Recipient *Responder `json:"recipient,omitempty"`
}

TimelinePeriod represents a period in a timeline rotation

type TimelineRotation

type TimelineRotation struct {
	ID      string           `json:"id,omitempty"`
	Name    string           `json:"name,omitempty"`
	Periods []TimelinePeriod `json:"periods,omitempty"`
}

TimelineRotation represents a rotation in the timeline

type User

type User struct {
	ID       string   `json:"id,omitempty"`
	Username string   `json:"username,omitempty"`
	FullName string   `json:"fullName,omitempty"`
	Email    string   `json:"email,omitempty"`
	Role     *Role    `json:"role,omitempty"`
	Blocked  bool     `json:"blocked,omitempty"`
	Verified bool     `json:"verified,omitempty"`
	Tags     []string `json:"tags,omitempty"`
	Timezone string   `json:"timezone,omitempty"`
	Locale   string   `json:"locale,omitempty"`
}

User represents an Opsgenie user

Jump to

Keyboard shortcuts

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