Documentation ¶
Index ¶
- Constants
- func EncodePluginData(data PluginData) map[string]string
- type Alert
- type AlertBody
- type AlertNote
- type AlertResult
- type App
- type Bot
- func (b *Bot) BroadcastAccessRequestMessage(ctx context.Context, recipients []common.Recipient, reqID string, ...) (data accessrequest.SentMessages, err error)
- func (b *Bot) CheckHealth(ctx context.Context) error
- func (b *Bot) FetchRecipient(ctx context.Context, name string) (*common.Recipient, error)
- func (b *Bot) PostReviewReply(ctx context.Context, _ string, alertID string, review types.AccessReview) error
- func (b Bot) SendReviewReminders(ctx context.Context, recipients []common.Recipient, ...) error
- func (b *Bot) SupportedApps() []common.App
- func (b *Bot) UpdateMessages(ctx context.Context, reqID string, data pd.AccessRequestData, ...) error
- type Client
- func (og Client) CheckHealth(ctx context.Context) error
- func (og Client) CreateAlert(ctx context.Context, reqID string, reqData RequestData) (OpsgenieData, error)
- func (og Client) GetOnCall(ctx context.Context, scheduleName string) (RespondersResult, error)
- func (og Client) PostReviewNote(ctx context.Context, alertID string, review types.AccessReview) error
- func (og Client) ResolveAlert(ctx context.Context, alertID string, resolution Resolution) error
- type ClientConfig
- type Config
- type OpsgenieData
- type PluginData
- type RequestData
- type Resolution
- type ResolutionTag
- type Responder
- type RespondersResult
Constants ¶
const ResolvedApproved = ResolutionTag("approved")
ResolvedApproved is added to alerts that are approved.
const ResolvedDenied = ResolutionTag("denied")
ResolvedDenied is added to alerts that are denied.
const ResolvedExpired = ResolutionTag("expired")
ResolvedExpired is added to alerts that are expired.
const ResolvedPromoted = ResolutionTag("promoted")
ResolvedPromoted is added to alerts that are promoted to an access list.
const Unresolved = ResolutionTag("")
Unresolved is added to alerts that are yet to be resolved.
Variables ¶
This section is empty.
Functions ¶
func EncodePluginData ¶
func EncodePluginData(data PluginData) map[string]string
EncodePluginData serializes a PluginData struct into a string map.
Types ¶
type Alert ¶
type Alert struct { // ID is the id of the Opsgenie alert. ID string `json:"id"` // Title is the title of the Opsgenie alert. Title string `json:"title"` // Status is the curerent status of the Opsgenie alert. Status string `json:"status"` // AlertKey is the key of the Opsgenie alert. AlertKey string `json:"alert_key"` // Details are a map of key-value pairs to use as custom properties of the alert. Details map[string]string `json:"details"` }
Alert represents an Opsgenie alert
type AlertBody ¶
type AlertBody struct { // Message is the message the alert is created with. Message string `json:"message,omitempty"` // Alias is the client-defined identifier of the alert. Alias string `json:"alias,omitempty"` // Description field of the alert. Description string `json:"description,omitempty"` // Responders are the teams/users that the alert will be routed to send notifications. Responders []Responder `json:"responders,omitempty"` // Priority is the priority the alert is created with. Priority string `json:"priority,omitempty"` }
AlertBody represents and Opsgenie alert body
type AlertNote ¶
type AlertNote struct { // User is the user that created the note. User string `json:"user"` // Source is the display name of the request source. Source string `json:"source"` // Note is the alert note. Note string `json:"note"` }
AlertNote represents an Opsgenie alert note
type AlertResult ¶
type AlertResult struct { // Alert contains the actual alert data. Alert Alert `json:"alert"` }
AlertResult is a wrapper around Alert
type App ¶
App is a wrapper around the base app to allow for extra functionality.
func NewOpsgenieApp ¶
NewOpsgenieApp initializes a new teleport-opsgenie app and returns it.
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is a opsgenie client that works with AccessRequest. It's responsible for formatting and Opsgenie alerts when an action occurs with an access request: a new request popped up, or a request is processed/updated.
func (*Bot) BroadcastAccessRequestMessage ¶
func (b *Bot) BroadcastAccessRequestMessage(ctx context.Context, recipients []common.Recipient, reqID string, reqData pd.AccessRequestData) (data accessrequest.SentMessages, err error)
BroadcastAccessRequestMessage creates an alert for the provided recipients (schedules)
func (*Bot) CheckHealth ¶
CheckHealth checks if the bot can connect to its messaging service
func (*Bot) FetchRecipient ¶
FetchRecipient returns the recipient for the given raw recipient.
func (*Bot) PostReviewReply ¶
func (b *Bot) PostReviewReply(ctx context.Context, _ string, alertID string, review types.AccessReview) error
PostReviewReply posts an alert note.
func (Bot) SendReviewReminders ¶
func (b Bot) SendReviewReminders(ctx context.Context, recipients []common.Recipient, accessList *accesslist.AccessList) error
SendReviewReminders will send a review reminder that an access list needs to be reviewed.
func (*Bot) SupportedApps ¶
SupportedApps are the apps supported by this bot.
func (*Bot) UpdateMessages ¶
func (b *Bot) UpdateMessages(ctx context.Context, reqID string, data pd.AccessRequestData, alertData accessrequest.SentMessages, reviews []types.AccessReview) error
UpdateMessages add notes to the alert containing updates to status. This will also resolve alerts based on the resolution tag.
type Client ¶
type Client struct { ClientConfig // contains filtered or unexported fields }
Client is a wrapper around resty.Client.
func NewClient ¶
func NewClient(conf ClientConfig) (*Client, error)
NewClient creates a new Opsgenie client for managing alerts.
func (Client) CheckHealth ¶
CheckHealth pings opsgenie.
func (Client) CreateAlert ¶
func (og Client) CreateAlert(ctx context.Context, reqID string, reqData RequestData) (OpsgenieData, error)
CreateAlert creates an opsgenie alert.
func (Client) PostReviewNote ¶
func (og Client) PostReviewNote(ctx context.Context, alertID string, review types.AccessReview) error
PostReviewNote posts a note once a new request review appears.
func (Client) ResolveAlert ¶
ResolveAlert resolves an alert and posts a note with resolution details.
type ClientConfig ¶
type ClientConfig struct { // APIKey is the API key for Opsgenie APIKey string // APIEndpoint is the endpoint for the Opsgenie API // api url of the form https://api.opsgenie.com/v2/ with optional trailing '/' APIEndpoint string // DefaultSchedules are the default on-call schedules to check for auto approval DefaultSchedules []string // Priority is the priority alerts are to be created with Priority string // WebProxyURL is the Teleport address used when building the bodies of the alerts // allowing links to the access requests to be built WebProxyURL *url.URL // ClusterName is the name of the Teleport cluster ClusterName string // StatusSink receives any status updates from the plugin for // further processing. Status updates will be ignored if not set. StatusSink common.StatusSink }
ClientConfig is the config for the opsgenie client.
func (*ClientConfig) CheckAndSetDefaults ¶
func (cfg *ClientConfig) CheckAndSetDefaults() error
type Config ¶
type Config struct { common.BaseConfig // Opsgenie contains the opsgenie specific configuration. Opsgenie common.GenericAPIConfig // ClientConfig contains the config for the opsgenie client. ClientConfig ClientConfig // AccessTokenProvider provides a method to get the bearer token // for use when authorizing to a 3rd-party provider API. AccessTokenProvider auth.AccessTokenProvider }
Config stores the full configuration for the teleport-opsgenie plugin to run.
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults checks the config struct for any logical errors, and sets default values if some values are missing. If critical values are missing and we can't set defaults for them, this will return an error.
type OpsgenieData ¶
OpsgenieData stores the notification alert info.
type PluginData ¶
type PluginData struct { RequestData OpsgenieData }
PluginData is a data associated with access request that we store in Teleport using UpdatePluginData API.
func DecodePluginData ¶
func DecodePluginData(dataMap map[string]string) (data PluginData)
DecodePluginData deserializes a string map to PluginData struct.
type RequestData ¶
type RequestData struct { User string Roles []string Created time.Time RequestReason string ReviewsCount int Resolution Resolution SystemAnnotations types.Labels }
RequestData stores a slice of some request fields in a convenient format.
type Resolution ¶
type Resolution struct { Tag ResolutionTag Reason string }
Resolution stores the resolution (approved, denied or expired) and its reason.
type ResolutionTag ¶
type ResolutionTag string
ResolutionTag represents if and in which state an access request was resolved.
type Responder ¶
type Responder struct { // Name is the name of the responder. Name string `json:"name,omitempty"` // Username is the opsgenie username of the responder. Username string `json:"username,omitempty"` // Type is the type of responder team/user Type string `json:"type,omitempty"` // ID is the ID of the responder. ID string `json:"id,omitempty"` }
Responder represents an Opsgenie responder
type RespondersResult ¶
type RespondersResult struct { // Data is a wrapper around the OnCallRecipients. Data struct { OnCallRecipients []string `json:"onCallRecipients,omitempty"` } `json:"data,omitempty"` }
RespondersResult represents a group of Opsgenie responders