Documentation
¶
Index ¶
- Constants
- Variables
- func AsText(elem interface{}, buf io.Writer)
- func RefreshDescriptor(url string) error
- func RequireTokenMiddleware(c Client, next http.Handler) http.Handler
- func SendReply(c Client, m *Message, reply *Payload) error
- func SendText(client Client, cloudID, conversationID, text string) error
- func SendTextReply(c Client, m *Message, reply string) error
- type Action
- type ActionTarget
- type ApplicationCard
- type ApplicationCardAttrs
- type Badge
- type BadgeState
- type BadgeTheme
- type Bot
- type BotMessages
- type CardAttrContext
- type CardAttrDetails
- type CardAttrText
- type CardAttrTitle
- type CardAttrUser
- type Client
- type Configuration
- type ConfigurationPage
- type ConversationCommon
- type ConversationMeta
- type ConversationUpdate
- type Conversations
- type Descriptor
- type Dialog
- type DialogAction
- type DialogOptions
- type DialogSize
- type Document
- type Emoji
- type EmojiAttrs
- type ExternalPage
- type Glance
- type GlanceBody
- type GlanceContext
- type GlanceLabel
- type HardBreak
- type HttpClient
- type ID
- type Icon
- type InlineGroupNode
- type InputAction
- type Key
- type LifeCycle
- type LifeCyclePayload
- type Link
- type Lozenge
- type LozengeState
- type Mark
- type Mention
- type MentionAttrs
- type Message
- type MessageAction
- type Module
- type ModuleType
- type Name
- type Panel
- type PanelAttrs
- type Paragraph
- type Payload
- type RequestContext
- type RosterUpdate
- type Sidebar
- type Subscript
- type Superscript
- type Text
- type TextColor
- type TokenResponse
- type URL
- type User
- type Webhook
Constants ¶
const ( // Marks which only have a Type attribute. Code = basicmark("code") Em = basicmark("em") Strike = basicmark("strike") Strong = basicmark("strong") Underline = basicmark("underline") )
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") )
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" )
const ( // "conversation:updates" actions. ConversationUpdatesArchive = "archive" ConversationUpdatesCreate = "create" ConversationUpdatesDelete = "delete" ConversationUpdatesUnarchive = "unarchive" ConversationUpdatesUpdate = "update" // "roster:updates" actions. RosterUpdatesAdd = "add" RosterUpdatesRemove = "remove" )
Variables ¶
var NotImplemented = errors.New("HTTP 501 Not Implemented")
Functions ¶
func RefreshDescriptor ¶
func RequireTokenMiddleware ¶
RequireTokenMiddleware requires a Bearer token signed with the client secret.
Types ¶
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 CardAttrDetails ¶
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 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 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 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 DialogOptions ¶
type DialogOptions struct {
Size DialogSize `json:"size"`
PrimaryAction DialogAction `json:"primaryAction"`
SecondaryActions []DialogAction `json:"secondaryActions"`
}
type DialogSize ¶
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 (*Document) UnmarshalJSON ¶
type Emoji ¶
type Emoji struct {
Attrs EmojiAttrs `json:"attrs"`
}
Emoji is an inline group node.
func (*Emoji) MarshalJSON ¶
type EmojiAttrs ¶
type ExternalPage ¶
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 GlanceLabel ¶
type GlanceLabel struct {
Value string `json:"value"`
}
type HardBreak ¶
type HardBreak struct {
}
HardBreak is an inline group node.
func (*HardBreak) MarshalJSON ¶
type HttpClient ¶
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 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 Lozenge ¶
type Lozenge struct {
Text string `json:"text"`
Appearance LozengeState `json:"appearance,omitempty"`
Bold bool `json:"bold,omitempty"`
}
type LozengeState ¶
type LozengeState string
type Mention ¶
type Mention struct {
Attrs MentionAttrs `json:"attrs"`
}
Mention is an inline group node.
func (*Mention) MarshalJSON ¶
type MentionAttrs ¶
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.
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 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 (*Panel) UnmarshalJSON ¶
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 (*Paragraph) UnmarshalJSON ¶
type Payload ¶
type Payload struct {
Body *Document `json:"body"`
}
Payload represents an outgoing message.
func ReadPayload ¶
type RequestContext ¶
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 ¶
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 ¶
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 TextColor ¶
type TextColor struct {
Color string
}
TextColor is a mark.
func (*TextColor) MarshalJSON ¶
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"`
}