Back to godoc.org
bosun.org / cmd / bosun / sched / slack

Package slack

v0.0.0-...-8a7cd2d
Latest Go to latest

The latest major version is .

Published: Jun 18, 2020 | License: MIT | Module: bosun.org

Overview

Package slack is for creating slack notifications inside of Bosun templates

Index

func StatusColor

func StatusColor(status models.Status) string

StatusColor returns a color string that corresponds to Slack's colors based on the Status.

type Action

type Action struct {
	Type  string `json:"type"`
	Text  string `json:"text"`
	URL   string `json:"url"`
	Style string `json:"style,omitempty"`
}

Action is a struture for what slack expects as an item in the Actions slice of an Attachment.

type Attachment

type Attachment struct {
	Color    string `json:"color,omitempty"`
	Fallback string `json:"fallback"`

	AuthorID      string `json:"author_id,omitempty"`
	AuthorName    string `json:"author_name,omitempty"`
	AuthorSubname string `json:"author_subname,omitempty"`
	AuthorLink    string `json:"author_link,omitempty"`
	AuthorIcon    string `json:"author_icon,omitempty"`

	Title     string `json:"title,omitempty"`
	TitleLink string `json:"title_link,omitempty"`
	Pretext   string `json:"pretext,omitempty"`
	Text      string `json:"text"`

	ImageURL string `json:"image_url,omitempty"`
	ThumbURL string `json:"thumb_url,omitempty"`

	Fields  []interface{} `json:"fields,omitempty"`
	Actions []interface{} `json:"actions,omitempty"`

	Footer     string `json:"footer,omitempty"`
	FooterIcon string `json:"footer_icon,omitempty"`

	Ts int64 `json:"ts,omitempty"`
}

Attachment contains all the information for a slack message attachment and has methods to Set/Append fields.

func NewAttachment

func NewAttachment(m *models.IncidentState) *Attachment

NewAttachment returns a Attachment structure with the color and Timestamp set from the IncidentState.

func (*Attachment) AddActions

func (a *Attachment) AddActions(action ...interface{}) interface{}

AddActions appends an Action to the Actions field of the Attachment.

func (*Attachment) AddFields

func (a *Attachment) AddFields(field ...interface{}) interface{}

AddFields appends a Field to the Fields field of the Attachment.

func (*Attachment) SetAuthorID

func (a *Attachment) SetAuthorID(authorID string) interface{}

SetAuthorID sets the AuthorID field of the Attachment.

func (*Attachment) SetAuthorIcon

func (a *Attachment) SetAuthorIcon(authorIcon string) interface{}

SetAuthorIcon sets the AuthorIcon field of the Attachment.

func (a *Attachment) SetAuthorLink(authorLink string) interface{}

SetAuthorLink sets the AuthorLink field of the Attachment.

func (*Attachment) SetAuthorName

func (a *Attachment) SetAuthorName(authorName string) interface{}

SetAuthorName sets the AuthorName field of the Attachment.

func (*Attachment) SetAuthorSubname

func (a *Attachment) SetAuthorSubname(authorSubname string) interface{}

SetAuthorSubname sets the AuthorSubname field of the Attachment.

func (*Attachment) SetColor

func (a *Attachment) SetColor(color string) interface{}

SetColor appends an Action to the Actions field of the Attachment.

func (*Attachment) SetFallback

func (a *Attachment) SetFallback(fallback string) interface{}

SetFallback sets the FallBack field of the Attachment.

func (*Attachment) SetFooter

func (a *Attachment) SetFooter(footer string) interface{}

SetFooter sets the Footer field of the Attachment.

func (*Attachment) SetFooterIcon

func (a *Attachment) SetFooterIcon(footerIcon string) interface{}

SetFooterIcon sets the FooterIcon field of the Attachment.

func (*Attachment) SetImageURL

func (a *Attachment) SetImageURL(url string) interface{}

SetImageURL sets the ImageURL field of the Attachment.

func (*Attachment) SetPretext

func (a *Attachment) SetPretext(pretext string) interface{}

SetPretext sets the Pretext field of the Attachment.

func (*Attachment) SetText

func (a *Attachment) SetText(text string) interface{}

SetText sets the Text field of the Attachment.

func (*Attachment) SetThumbURL

func (a *Attachment) SetThumbURL(url string) interface{}

SetThumbURL sets the ThumbURL field of the Attachment.

func (*Attachment) SetTitle

func (a *Attachment) SetTitle(title string) interface{}

SetTitle sets the Title field of the Attachment.

func (a *Attachment) SetTitleLink(titleLink string) interface{}

SetTitleLink sets the TitleLink field of the Attachment.

func (*Attachment) SetTs

func (a *Attachment) SetTs(ts int64) interface{}

SetTs sets the Ts field of the Attachment.

type Field

type Field struct {
	Title string      `json:"title"`
	Value interface{} `json:"value"`
	Short bool        `json:"short"`
}

Field is a structure for what slack expects as an item in the Fields slice of an Attachment.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier