escalation

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveStep

type ActiveStep struct {
	StepID          string
	PolicyID        string
	AlertID         int
	LastEscalation  time.Time
	LoopCount       int
	ForceEscalation bool
	StepNumber      int
}

type Config

type Config struct {
	NCStore         *notificationchannel.Store
	LogStore        *alertlog.Store
	SlackLookupFunc func(ctx context.Context, channelID string) (*slack.Channel, error)
}

type Policy

type Policy struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Repeat      int    `json:"repeat"`
	// contains filtered or unexported fields
}

func (Policy) IsUserFavorite added in v0.28.0

func (p Policy) IsUserFavorite() bool

IsUserFavorite returns true if this policy is a favorite of the current user.

func (Policy) Normalize

func (p Policy) Normalize() (*Policy, error)

type SearchCursor

type SearchCursor struct {
	Name       string `json:"n,omitempty"`
	IsFavorite bool   `json:"f,omitempty"`
}

SearchCursor is used to indicate a position in a paginated list.

type SearchOptions

type SearchOptions struct {
	Search string       `json:"s,omitempty"`
	After  SearchCursor `json:"a,omitempty"`

	// FavoritesUserID specifies the UserID whose favorite escalation policies want to be displayed.
	FavoritesUserID string `json:"u,omitempty"`

	// FavoritesOnly controls filtering the results to those marked as favorites by FavoritesUserID.
	FavoritesOnly bool `json:"g,omitempty"`

	// FavoritesFirst indicates that escalation policy marked as favorite (by FavoritesUserID) should be returned first (before any non-favorites).
	FavoritesFirst bool `json:"f,omitempty"`

	// Omit specifies a list of policy IDs to exclude from the results.
	Omit []string `json:"o,omitempty"`

	Limit int `json:"-"`
}

SearchOptions allow filtering and paginating the list of escalation policies.

type Step

type Step struct {
	ID           string `json:"id"`
	PolicyID     string `json:"escalation_policy_id"`
	DelayMinutes int    `json:"delay_minutes"`
	StepNumber   int    `json:"step_number"`

	Targets []assignment.Target
}

func (Step) Delay

func (s Step) Delay() time.Duration

func (Step) Normalize

func (s Step) Normalize() (*Step, error)

type Store

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

func NewStore added in v0.30.0

func NewStore(ctx context.Context, db *sql.DB, cfg Config) (*Store, error)

func (*Store) AddStepTargetTx added in v0.30.0

func (s *Store) AddStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error

AddStepTargetTx adds a target to an escalation policy step.

func (*Store) CreatePolicyTx added in v0.30.0

func (s *Store) CreatePolicyTx(ctx context.Context, tx *sql.Tx, p *Policy) (*Policy, error)

CreatePolicyTx creates a new escalation policy in the database.

func (*Store) CreateStepTx added in v0.30.0

func (s *Store) CreateStepTx(ctx context.Context, tx *sql.Tx, st *Step) (*Step, error)

CreateStepTx adds a step to an escalation policy.

func (*Store) DeleteManyPoliciesTx added in v0.30.0

func (s *Store) DeleteManyPoliciesTx(ctx context.Context, tx *sql.Tx, ids []string) error

DeleteManyPoliciesTx deletes multiple policies in a single transaction.

func (*Store) DeleteStepTargetTx added in v0.30.0

func (s *Store) DeleteStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error

DeleteStepTargetTx removes the target from the step.

func (*Store) DeleteStepTx added in v0.30.0

func (s *Store) DeleteStepTx(ctx context.Context, tx *sql.Tx, id string) (string, error)

DeleteStepTx deletes a step from an escalation policy.

func (*Store) FindAllOnCallStepsForUserTx added in v0.30.0

func (s *Store) FindAllOnCallStepsForUserTx(ctx context.Context, tx *sql.Tx, userID string) ([]Step, error)

FindAllOnCallStepsForUserTx returns all steps a user is currently on-call for.

func (*Store) FindAllPoliciesBySchedule added in v0.30.0

func (s *Store) FindAllPoliciesBySchedule(ctx context.Context, scheduleID string) ([]Policy, error)

FindAllPoliciesBySchedule will return all policies that have the given schedule assigned to them.

func (*Store) FindAllStepTargetsTx added in v0.30.0

func (s *Store) FindAllStepTargetsTx(ctx context.Context, tx *sql.Tx, stepID string) ([]assignment.Target, error)

FindAllStepTargetsTx returns the targets for a step.

func (*Store) FindAllSteps added in v0.30.0

func (s *Store) FindAllSteps(ctx context.Context, policyID string) ([]Step, error)

func (*Store) FindAllStepsTx added in v0.30.0

func (s *Store) FindAllStepsTx(ctx context.Context, tx *sql.Tx, policyID string) ([]Step, error)

FindAllStepsTx returns all steps for a policy.

func (*Store) FindManyPolicies added in v0.30.0

func (s *Store) FindManyPolicies(ctx context.Context, ids []string) ([]Policy, error)

FindManyPolicies returns escalation policies for the given IDs.

func (*Store) FindOnePolicyForUpdateTx added in v0.30.0

func (s *Store) FindOnePolicyForUpdateTx(ctx context.Context, tx *sql.Tx, id string) (*Policy, error)

FindOnePolicyForUpdateTx returns a single policy locked to the tx for updating.

func (*Store) FindOnePolicyTx added in v0.30.0

func (s *Store) FindOnePolicyTx(ctx context.Context, tx *sql.Tx, id string) (*Policy, error)

FindOnePolicyTx returns a policy by ID.

func (*Store) FindOneStepForUpdateTx added in v0.30.0

func (s *Store) FindOneStepForUpdateTx(ctx context.Context, tx *sql.Tx, id string) (*Step, error)

FindOneStepForUpdateTx returns a step locked within the tx for update.

func (*Store) Search added in v0.30.0

func (s *Store) Search(ctx context.Context, opts *SearchOptions) ([]Policy, error)

func (*Store) UpdatePolicyTx added in v0.30.0

func (s *Store) UpdatePolicyTx(ctx context.Context, tx *sql.Tx, p *Policy) error

UpdatePolicyTx will update a single escalation policy.

func (*Store) UpdateStepDelayTx added in v0.30.0

func (s *Store) UpdateStepDelayTx(ctx context.Context, tx *sql.Tx, stepID string, stepDelay int) error

UpdateStepDelayTx updates the delay for a step.

func (*Store) UpdateStepNumberTx added in v0.30.0

func (s *Store) UpdateStepNumberTx(ctx context.Context, tx *sql.Tx, stepID string, stepNumber int) error

UpdateStepNumberTx updates the step number for a step.

Jump to

Keyboard shortcuts

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