stride

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Marks which only have a Type attribute.
	Code      = basicmark("code")
	Em        = basicmark("em")
	Strike    = basicmark("strike")
	Strong    = basicmark("strong")
	Underline = basicmark("underline")
)
View Source
const (
	ModuleActionTarget  = ModuleType("chat:actionTarget")
	ModuleBot           = ModuleType("chat:bot")
	ModuleBotMessages   = ModuleType("chat:bot:messages")
	ModuleConfiguration = ModuleType("chat:configuration")
	ModuleDialog        = ModuleType("chat:dialog")
	ModuleExternalPage  = ModuleType("chat:externalPage")
	ModuleGlance        = ModuleType("chat:glance")
	ModuleInputAction   = ModuleType("chat:inputAction")
	ModuleMessageAction = ModuleType("chat:messageAction")
	ModuleSidebar       = ModuleType("chat:sidebar")
	ModuleWebhook       = ModuleType("chat:webhook")
)
View Source
const (
	// Actions
	ActionAdd       = Action("add")
	ActionArchive   = Action("archive")
	ActionCreate    = Action("create")
	ActionDelete    = Action("delete")
	ActionRemove    = Action("remove")
	ActionUnarchive = Action("unarchive")
	ActionUpdate    = Action("update")
	// Badges
	BadgeAdded        = BadgeState("added")
	BadgeDefault      = BadgeState("default")
	BadgeImportant    = BadgeState("important")
	BadgePrimary      = BadgeState("primary")
	BadgeRemoved      = BadgeState("removed")
	BadgeThemeDefault = BadgeTheme("default")
	BadgeThemeDark    = BadgeTheme("dark")
	// Conditions
	ConditionRoomPublic    = "room_is_public"
	ConditionUserAdmin     = "user_is_admin"
	ConditionUserGuest     = "user_is_guest"
	ConditionUserRoomOwner = "user_is_room_owner"
	// Events
	EventConversationUpdates = "conversation:updates"
	EventRosterUpdates       = "roster:updates"
	// Lozenges
	LozengeDefault    = LozengeState("default")
	LozengeInProgress = LozengeState("inprogress")
	LozengeMoved      = LozengeState("moved")
	LozengeNew        = LozengeState("new")
	LozengeRemoved    = LozengeState("removed")
	LozengeSuccess    = LozengeState("success")
	// Scopes
	ScopeParticipateConversation = "participate:conversation"
	ScopeManageConversation      = "manage:conversation"
)
View Source
const (
	// "conversation:updates" actions.
	ConversationUpdatesArchive   = "archive"
	ConversationUpdatesCreate    = "create"
	ConversationUpdatesDelete    = "delete"
	ConversationUpdatesUnarchive = "unarchive"
	ConversationUpdatesUpdate    = "update"
	// "roster:updates" actions.
	RosterUpdatesAdd    = "add"
	RosterUpdatesRemove = "remove"
)

Variables

View Source
var NotImplemented = errors.New("HTTP 501 Not Implemented")

Functions

func AsText

func AsText(elem interface{}, buf io.Writer)

func RefreshDescriptor

func RefreshDescriptor(url string) error

func RequireTokenMiddleware

func RequireTokenMiddleware(c Client, next http.Handler) http.Handler

RequireTokenMiddleware requires a Bearer token signed with the client secret.

func SendReply

func SendReply(c Client, m *Message, reply *Payload) error

func SendText

func SendText(client Client, cloudID, conversationID, text string) error

func SendTextReply

func SendTextReply(c Client, m *Message, reply string) error

Types

type Action

type Action string

type ActionTarget

type ActionTarget struct {
	Key               string `json:"key"`
	CallService       *URL   `json:"callService,omitempty"`
	OpenConfiguration *Key   `json:"openConfiguration,omitempty"`
	OpenDialog        *Key   `json:"openDialog,omitempty"`
	OpenExternalPage  *Key   `json:"openExternaPage,omitempty"`
	OpenSidebar       *Key   `json:"openSidebar,omitempty"`
}

TODO: lookup authoritative definition of this object once stride docs updated with it.

func (*ActionTarget) Type

func (t *ActionTarget) Type() ModuleType

type ApplicationCard

type ApplicationCard struct {
	Attrs *ApplicationCardAttrs `json:"attrs"`
}

func (*ApplicationCard) MarshalJSON

func (n *ApplicationCard) MarshalJSON() ([]byte, error)

type ApplicationCardAttrs

type ApplicationCardAttrs struct {
	Background  *URL              `json:"background,omitempty"`
	Collapsible bool              `json:"collapsible"`
	Context     *CardAttrContext  `json:"context,omitempty"`
	Description *CardAttrText     `json:"description,omitempty"`
	Details     []CardAttrDetails `json:"details,omitempty"`
	Link        *URL              `json:"link,omitempty"`
	Preview     *URL              `json:"preview,omitempty"`
	Text        string            `json:"text"`
	TextURL     string            `json:"textUrl,omitempty"`
	Title       CardAttrTitle     `json:"title"`
}

type Badge

type Badge struct {
	Appearance BadgeState `json:"appearance,omitempty"`
	Max        int        `json:"max"`
	Theme      string     `json:"theme,omitempty"`
	Value      int        `json:"value"`
}

type BadgeState

type BadgeState string

type BadgeTheme

type BadgeTheme string

type Bot

type Bot struct {
	Key           string `json:"key"`
	Mention       *URL   `json:"mention,omitempty"`
	DirectMessage *URL   `json:"directMessage,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/bot/

func (*Bot) Type

func (b *Bot) Type() ModuleType

type BotMessages

type BotMessages struct {
	Key     string `json:"key"`
	Pattern string `json:"pattern"`
	URL     string `json:"url"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/bot-messages/

func (*BotMessages) Type

func (b *BotMessages) Type() ModuleType

type CardAttrContext

type CardAttrContext struct {
	Icon Icon   `json:"icon"`
	Text string `json:"text"`
}

type CardAttrDetails

type CardAttrDetails struct {
	Badge   *Badge          `json:"badge,omitempty"`
	Icon    *Icon           `json:"icon,omitempty"`
	Lozenge *Lozenge        `json:"lozenge,omitempty"`
	Text    string          `json:"text,omitempty"`
	Title   string          `json:"title,omitempty"`
	Users   []*CardAttrUser `json:"users,omitempty"`
}

type CardAttrText

type CardAttrText struct {
	Text string `json:"text"`
}

type CardAttrTitle

type CardAttrTitle struct {
	Text string        `json:"text"`
	User *CardAttrUser `json:"user,omitempty"`
}

type CardAttrUser

type CardAttrUser struct {
	ID   string `json:"id,omitempty"`
	Icon *Icon  `json:"icon,omitempty"`
}

type Client

type Client interface {
	SendMessage(cloudID, conversationID string, payload *Payload) error
	SendUserMessage(cloudID, userID string, payload *Payload) error
	GetConversation(cloudID, conversationID string) (*ConversationCommon, error)
	GetConversationByName(cloudID, conversationName string) (*ConversationCommon, error)
	GetUser(cloudID, userID string) (user *User, err error)
	ConvertDocToText(doc *Document) (plain string, err error)
	ValidateToken(tokenString string) (jwt.MapClaims, error)
}

func New

func New(clientID, clientSecret string) Client

func NewClient

func NewClient(clientID, clientSecret string, httpClient HttpClient) Client

func NewRoomClient

func NewRoomClient(roomToken string, httpClient HttpClient) Client

NewRoomClient returns a Client configured with a room specific token.

type Configuration

type Configuration struct {
	Key          string             `json:"key"`
	Page         *ConfigurationPage `json:"page,omitempty"`
	ExternalPage *ConfigurationPage `json:"externalPage,omitempty"`
	State        struct {
		URL string `json:"url"`
	} `json:"state"`
	// Defaults to "jwt", alternative is "none"
	Authentication string `json:"authentication,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/configuration/

func (*Configuration) Type

func (c *Configuration) Type() ModuleType

type ConfigurationPage

type ConfigurationPage struct {
	// URL to load in the client (Page) or external browser (ExternalPage).
	URL    string `json:"url,omitempty"`
	Target string `json:"target,omitempty"`
}

type ConversationCommon

type ConversationCommon struct {
	AvatarURL  string `json:"avatarUrl"`
	CloudID    string `json:"cloudId"`
	Created    time.Time
	ID         string `json:"id"`
	IsArchived bool   `json:"isArchived"`
	Modified   time.Time
	Name       string `json:"name"`
	Privacy    string `json:"privacy"`
	Topic      string `json:"topic"`
	Type       string `json:"type"`
}

type ConversationMeta

type ConversationMeta struct {
	AvatarURL  string `json:"avatarUrl"`
	Created    string `json:"created"`
	ID         string `json:"id"`
	IsArchived bool   `json:"isArchived"`
	Modified   string `json:"modified"`
	Name       string `json:"name"`
	Privacy    string `json:"privacy"`
	Topic      string `json:"topic"`
	Type       string `json:"type"`
}

type ConversationUpdate

type ConversationUpdate struct {
	Action       string           `json:"action"`
	CloudID      string           `json:"cloudId"`
	Conversation ConversationMeta `json:"conversation"`
	Type         string           `json:"type"`
	Initiator    ID               `json:"initiator"`
}

type Conversations

type Conversations struct {
	Values []*ConversationCommon `json:"values"`
	// API limits us to a certain number of results per request. The following attributes
	// allow us to determine whether we've hit that limit and how to fetch the next set.
	Cursor string `json:"cursor"`
	Limit  int    `json:"limit"`
	Size   int    `json:"size"`
}

type Descriptor

type Descriptor struct {
	BaseURL   string                  `json:"baseUrl"`
	Key       string                  `json:"key"`
	LifeCycle *LifeCycle              `json:"lifecycle"`
	Modules   map[ModuleType][]Module `json:"modules"`
}

type Dialog

type Dialog struct {
	Key     string        `json:"key"`
	Title   Name          `json:"title"`
	Options DialogOptions `json:"options"`
	URL     string        `json:"url"`
	// Defaults to "jwt", alternative is "none"
	Authentication string `json:"authentication,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/dialog/

func (*Dialog) Type

func (d *Dialog) Type() ModuleType

type DialogAction

type DialogAction struct {
	Key  string `json:"key"`
	Name Name   `json:"name"`
}

type DialogOptions

type DialogOptions struct {
	Size             DialogSize     `json:"size"`
	PrimaryAction    DialogAction   `json:"primaryAction"`
	SecondaryActions []DialogAction `json:"secondaryActions"`
}

type DialogSize

type DialogSize struct {
	Width  string `json:"width"`
	Height string `json:"height"`
}

type Document

type Document struct {
	Version int           `json:"version"`
	Content []interface{} `json:"content"`
}

Document is a representation of a rich object or message.

func (*Document) MarshalJSON

func (d *Document) MarshalJSON() ([]byte, error)

func (*Document) UnmarshalJSON

func (d *Document) UnmarshalJSON(b []byte) (err error)

type Emoji

type Emoji struct {
	Attrs EmojiAttrs `json:"attrs"`
}

Emoji is an inline group node.

func (*Emoji) MarshalJSON

func (n *Emoji) MarshalJSON() ([]byte, error)

func (*Emoji) Type

func (n *Emoji) Type() inlineGroupNode

type EmojiAttrs

type EmojiAttrs struct {
	ID        string `json:"id,omitempty"`
	ShortName string `json:"shortName"`
	Text      string `json:"text,omitempty"`
}

type ExternalPage

type ExternalPage struct {
	Name Name   `json:"name"`
	URL  string `json:"url"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/externalPage/

func (*ExternalPage) Type

func (e *ExternalPage) Type() ModuleType

type Glance

type Glance struct {
	Key      string `json:"key"`
	Name     Name   `json:"name"`
	Icon     Icon   `json:"icon"`
	Target   string `json:"target,omitempty"`
	QueryURL string `json:"queryUrl"`
	// Default weight is 100, so we should omit this if 0.
	Weight int `json:"weight,omitempty"`
	// Conditions // not supported
	Authentication string `json:"authentication,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/glance/

func (*Glance) Type

func (g *Glance) Type() ModuleType

type GlanceBody

type GlanceBody struct {
	Context  GlanceContext          `json:"context"`
	Label    GlanceLabel            `json:"label"`
	Metadata map[string]interface{} `json:"metadata"`
}

type GlanceContext

type GlanceContext struct {
	CloudID        string `json:"cloudId"`
	ConversationID string `json:"conversationId,omitempty"`
	UserID         string `json:"userId,omitempty"`
}

type GlanceLabel

type GlanceLabel struct {
	Value string `json:"value"`
}

type HardBreak

type HardBreak struct {
}

HardBreak is an inline group node.

func (*HardBreak) MarshalJSON

func (n *HardBreak) MarshalJSON() ([]byte, error)

func (*HardBreak) Type

func (n *HardBreak) Type() inlineGroupNode

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
	Post(string, string, io.Reader) (*http.Response, error)
}

type ID

type ID struct {
	ID string `json:"id"`
}

ID repesents an object with a single field, URL.

type Icon

type Icon struct {
	URL string `json:"url"`
	// URL2x used for descriptor, glances, etc.
	URL2x string `json:"url@2x,omitempty"`
	// Label used in document nodes.
	Label string `json:"label,omitempty"`
}

type InlineGroupNode

type InlineGroupNode interface {
	Type() inlineGroupNode
}

type InputAction

type InputAction struct {
	Key    string `json:"key"`
	Name   Name   `json:"name"`
	Target string `json:"target"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/inputAction/

func (*InputAction) Type

func (i *InputAction) Type() ModuleType

type Key

type Key struct {
	Key string `json:"key"`
}

Key represents an object with a single field, Key.

type LifeCycle

type LifeCycle struct {
	Installed   string `json:"installed"`
	Uninstalled string `json:"uninstalled"`
}

type LifeCyclePayload

type LifeCyclePayload struct {
	Key           string `json:"key"`
	ProductType   string `json:"productType"`
	CloudID       string `json:"cloudId"`
	ResourceType  string `json:"resourceType"`
	ResourceID    string `json:"resourceId"`
	EventType     string `json:"eventType"`
	UserID        string `json:"userId"`
	OAuthClientID string `json:"oauthClientId"`
	Version       string `json:"version"`
}
type Link struct {
	Href  string `json:"href"`
	Title string `json:"title,omitempty"`
}

Link is a mark.

func (*Link) MarshalJSON

func (m *Link) MarshalJSON() ([]byte, error)

func (*Link) Type

func (m *Link) Type() mark

type Lozenge

type Lozenge struct {
	Text       string       `json:"text"`
	Appearance LozengeState `json:"appearance,omitempty"`
	Bold       bool         `json:"bold,omitempty"`
}

type LozengeState

type LozengeState string

type Mark

type Mark interface {
	Type() mark
}

type Mention

type Mention struct {
	Attrs MentionAttrs `json:"attrs"`
}

Mention is an inline group node.

func (*Mention) MarshalJSON

func (n *Mention) MarshalJSON() ([]byte, error)

func (*Mention) Type

func (n *Mention) Type() inlineGroupNode

type MentionAttrs

type MentionAttrs struct {
	ID   string `json:"id"`
	Text string `json:"text"`
}

type Message

type Message struct {
	CloudID      string `json:"cloudId"`
	Conversation struct {
		ID string `json:"id"`
	} `json:"conversation"`
	Sender struct {
		ID string `json:"id"`
	} `json:"sender"`
	Message struct {
		ID   string `json:"id"`
		Text string `json:"text"`
	} `json:"message"`
}

Message represents an incoming message.

func ReadMessage

func ReadMessage(req *http.Request) (msg *Message, err error)

type MessageAction

type MessageAction struct {
	Key    string `json:"key"`
	Name   Name   `json:"name"`
	Target string `json:"target"`
	// Default weight is 100, so we should omit this if 0.
	Weight int `json:"weight,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/messageAction/

func (*MessageAction) Type

func (m *MessageAction) Type() ModuleType

type Module

type Module interface {
	Type() ModuleType
}

type ModuleType

type ModuleType string

type Name

type Name struct {
	Value string `json:"value"`
	I18n  string `json:"i18n,omitempty"`
}

type Panel

type Panel struct {
	Content []interface{} `json:"content"`
	Attrs   PanelAttrs    `json:"attrs"`
}

Panel is an inline group node. https://developer.atlassian.com/cloud/stride/apis/document/nodes/panel/

func (*Panel) MarshalJSON

func (n *Panel) MarshalJSON() ([]byte, error)

func (*Panel) Type

func (n *Panel) Type() inlineGroupNode

Panel is an inline group node.

func (*Panel) UnmarshalJSON

func (d *Panel) UnmarshalJSON(b []byte) error

type PanelAttrs

type PanelAttrs struct {
	// Valid values: “info” | “note” | “tip” | “warning”
	PanelType string `json:"panelType"`
}

type Paragraph

type Paragraph struct {
	Content []InlineGroupNode `json:"content"`
}

Paragraph is a container for inline group nodes.

func (*Paragraph) MarshalJSON

func (p *Paragraph) MarshalJSON() ([]byte, error)

func (*Paragraph) UnmarshalJSON

func (p *Paragraph) UnmarshalJSON(b []byte) (err error)

type Payload

type Payload struct {
	Body *Document `json:"body"`
}

Payload represents an outgoing message.

func PlainText

func PlainText(text string) *Payload

func ReadPayload

func ReadPayload(bs []byte) (p *Payload, err error)

func (*Payload) AsText

func (p *Payload) AsText() string

func (*Payload) String

func (payload *Payload) String() string

type RequestContext

type RequestContext struct {
	ConversationID string
	CloudID        string
	UserID         string
}

func GetRequestContext

func GetRequestContext(r *http.Request) *RequestContext

GetRequestContext returns the RequestContext for a request.

type RosterUpdate

type RosterUpdate struct {
	Action       string           `json:"action"`
	CloudID      string           `json:"cloudId"`
	Conversation ConversationMeta `json:"conversation"`
	Type         string           `json:"type"`
	User         ID               `json:"initiator"`
}
type Sidebar struct {
	Key  string `json:"key"`
	Name Name   `json:"name"`
	URL  string `json:"url"`
	Icon *Icon  `json:"icon,omitempty"`
	// Defaults to "jwt", alternative is "none"
	Authentication string `json:"authentication,omitempty"`
}

https://developer.atlassian.com/cloud/stride/apis/modules/chat/sidebar/

func (*Sidebar) Type

func (s *Sidebar) Type() ModuleType

type Subscript

type Subscript struct{}

Subscript is a mark. Subscript and Superscript share the 'subsup' mark type and are mutually exclusive.

func (*Subscript) MarshalJSON

func (m *Subscript) MarshalJSON() ([]byte, error)

func (*Subscript) Type

func (m *Subscript) Type() mark

type Superscript

type Superscript struct{}

Superscript is a mark. Subscript and Superscript share the 'subsup' mark type and are mutually exclusive.

func (*Superscript) MarshalJSON

func (m *Superscript) MarshalJSON() ([]byte, error)

func (*Superscript) Type

func (m *Superscript) Type() mark

type Text

type Text struct {
	Text  string `json:"text"`
	Marks []Mark `json:"marks,omitempty"`
}

func (*Text) MarshalJSON

func (n *Text) MarshalJSON() ([]byte, error)

func (*Text) Type

func (n *Text) Type() inlineGroupNode

Text is an inline group node.

func (*Text) UnmarshalJSON

func (t *Text) UnmarshalJSON(b []byte) (err error)

type TextColor

type TextColor struct {
	Color string
}

TextColor is a mark.

func (*TextColor) MarshalJSON

func (m *TextColor) MarshalJSON() ([]byte, error)

func (*TextColor) Type

func (m *TextColor) Type() mark

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

TokenResponse represents the expected response from the auth API.

func (*TokenResponse) Validate

func (tr *TokenResponse) Validate() error

type URL

type URL struct {
	URL string `json:"url"`
}

URL repesents an object with a single field, URL.

type User

type User struct {
	ID          string `json:"id"`
	UserName    string `json:"userName"`
	DisplayName string `json:"displayName"`
	NickName    string `json:"nickName"`
	Name        struct {
		GivenName  string `json:"givenName"`
		Formatted  string `json:"formatted"`
		FamilyName string `json:"familyName"`
	} `json:"name"`
	Title    string `json:"title"`
	Active   bool   `json:"active"`
	Timezone string `json:"timezone"`
	Emails   []struct {
		Primary bool   `json:"primary"`
		Value   string `json:"value"`
	} `json:"emails"`
	Photos []struct {
		Primary bool   `json:"primary"`
		Value   string `json:"value"`
	} `json:"photos"`
	Meta struct {
		ResourceTyoe string `json:"resourceType"`
		LastModified string `json:"lastModified"`
		Created      string `json:"created"`
	} `json:"meta"`
}

type Webhook

type Webhook struct {
	Key   string `json:"key"`
	Event string `json:"event"`
	URL   string `json:"url"`
}

func (*Webhook) Type

func (w *Webhook) Type() ModuleType

Jump to

Keyboard shortcuts

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