adaptivecard

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 11 Imported by: 24

Documentation

Overview

Package adaptivecard provides support for generating Microsoft Teams messages using the Adaptive Card format.

See the provided examples in this repo, the Godoc generated documentation at https://pkg.go.dev/github.com/atc0005/go-teams-notify/v2 and the following resources for more information:

Index

Constants

View Source
const (
	// TypeMessage is the type for an Adaptive Card Message.
	TypeMessage string = "message"

	// PixelSizeRegex is a regular expression pattern intended to match
	// specific pixel size (height, width) values such as "50px".
	PixelSizeRegex string = "^[0-9]+px$"

	// PixelSizeExample is an example of a valid pixel size (height, width)
	// value.
	PixelSizeExample string = "50px"
)

General constants.

View Source
const (
	// TypeAdaptiveCard is the supported type value for an Adaptive Card.
	TypeAdaptiveCard string = "AdaptiveCard"

	// AdaptiveCardSchema represents the URI of the Adaptive Card schema.
	AdaptiveCardSchema string = "http://adaptivecards.io/schemas/adaptive-card.json"

	// AdaptiveCardMaxVersion represents the highest supported version of the
	// Adaptive Card schema supported in Microsoft Teams messages.
	//
	// https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#support-for-adaptive-cards
	// https://adaptivecards.io/designer
	//
	// NOTE: Documented as 1.5 (adaptivecards.io/designer), but in practice >
	// 1.4 is rejected for Power Automate workflow connectors.
	//
	// Setting to 1.4 works both for legacy O365 connectors and Workflow
	// connectors.
	AdaptiveCardMaxVersion  float64 = 1.4
	AdaptiveCardMinVersion  float64 = 1.0
	AdaptiveCardVersionTmpl string  = "%0.1f"
)

Card & TopLevelCard specific constants.

View Source
const (
	// TypeMention is the type for a user mention for a Adaptive Card Message.
	TypeMention string = "mention"

	// MentionTextFormatTemplate is the expected format of the Mention.Text
	// field value.
	MentionTextFormatTemplate string = "<at>%s</at>"
)

Mention constants.

View Source
const (

	// AttachmentContentType is the supported type value for an attached
	// Adaptive Card for a Microsoft Teams message.
	AttachmentContentType string = "application/vnd.microsoft.card.adaptive"

	AttachmentLayoutList     string = "list"
	AttachmentLayoutCarousel string = "carousel"
)

Attachment constants.

View Source
const (
	// TextBlockStyleDefault indicates that the TextBlock uses the default
	// style which provides no special styling or behavior.
	TextBlockStyleDefault string = "default"

	// TextBlockStyleHeading indicates that the TextBlock is a heading. This
	// will apply the heading styling defaults and mark the text block as a
	// heading for accessibility.
	TextBlockStyleHeading string = "heading"
)

TextBlock specific constants. https://adaptivecards.io/explorer/TextBlock.html

View Source
const (
	// TypeColumn is the type for an Adaptive Card Column.
	TypeColumn string = "Column"

	// ColumnWidthAuto indicates that a column's width should be determined
	// automatically based on other columns in the column group.
	ColumnWidthAuto string = "auto"

	// ColumnWidthStretch indicates that a column's width should be stretched
	// to fill the enclosing column group.
	ColumnWidthStretch string = "stretch"
)

Column specific constants. https://adaptivecards.io/explorer/Column.html

View Source
const (
	TypeTableColumnDefinition string = "TableColumnDefinition"
	TypeTableRow              string = "TableRow"
	TypeTableCell             string = "TableCell"
)

Table specific constants.

https://adaptivecards.io/explorer/Table.html https://adaptivecards.io/explorer/TableCell.html

View Source
const (
	SizeSmall      string = "small"
	SizeDefault    string = "default"
	SizeMedium     string = "medium"
	SizeLarge      string = "large"
	SizeExtraLarge string = "extraLarge"
)

Text size for TextBlock or TextRun elements.

View Source
const (
	WeightBolder  string = "bolder"
	WeightLighter string = "lighter"
	WeightDefault string = "default"
)

Text weight for TextBlock or TextRun elements.

View Source
const (
	ColorDefault   string = "default"
	ColorDark      string = "dark"
	ColorLight     string = "light"
	ColorAccent    string = "accent"
	ColorGood      string = "good"
	ColorWarning   string = "warning"
	ColorAttention string = "attention"
)

Supported colors for TextBlock or TextRun elements.

View Source
const (
	ImageStyleDefault string = ""
	ImageStylePerson  string = ""
)

Image specific constants. https://adaptivecards.io/explorer/Image.html

View Source
const (
	ChoiceInputStyleCompact  string = "compact"
	ChoiceInputStyleExpanded string = "expanded"
	ChoiceInputStyleFiltered string = "filtered" // Introduced in version 1.5
)

ChoiceInput specific constants.

View Source
const (
	TextInputStyleText     string = "text"
	TextInputStyleTel      string = "tel"
	TextInputStyleURL      string = "url"
	TextInputStyleEmail    string = "email"
	TextInputStylePassword string = "password" // Introduced in version 1.5
)

TextInput specific constants.

View Source
const (
	ContainerStyleDefault   string = "default"
	ContainerStyleEmphasis  string = "emphasis"
	ContainerStyleGood      string = "good"
	ContainerStyleAttention string = "attention"
	ContainerStyleWarning   string = "warning"
	ContainerStyleAccent    string = "accent"
)

Container specific constants.

View Source
const (
	SpacingDefault    string = "default"
	SpacingNone       string = "none"
	SpacingSmall      string = "small"
	SpacingMedium     string = "medium"
	SpacingLarge      string = "large"
	SpacingExtraLarge string = "extraLarge"
	SpacingPadding    string = "padding"
)

Supported spacing values for FactSet, Container and other container element types.

View Source
const (
	HorizontalAlignmentLeft   string = "left"
	HorizontalAlignmentCenter string = "center"
	HorizontalAlignmentRight  string = "right"
)

Supported Horizontal alignment values for (supported) container and text types.

View Source
const (
	VerticalAlignmentTop    string = "top"
	VerticalAlignmentCenter string = "center"
	VerticalAlignmentBottom string = "bottom"
)

Supported Horizontal alignment values for (supported) container types.

View Source
const (

	// TeamsActionsDisplayLimit is the observed limit on the number of visible
	// URL "buttons" in a Microsoft Teams message.
	//
	// Unlike the MessageCard format which has a clearly documented limit of 4
	// actions, testing reveals that Desktop / Web displays 6 without the
	// option to expand and see any additional defined actions. Mobile
	// displays 6 with an ellipsis to expand into a list of other Actions.
	//
	// This results in a maximum limit of 6 actions in the Actions array for a
	// Card.
	//
	// A workaround is to create multiple ActionSet elements and limit the
	// number of Actions in each set ot 6.
	//
	// https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#actions
	TeamsActionsDisplayLimit int = 6

	// TypeActionExecute is an action that gathers input fields, merges with
	// optional data field, and sends an event to the client. Clients process
	// the event by sending an Invoke activity of type adaptiveCard/action to
	// the target Bot. The inputs that are gathered are those on the current
	// card, and in the case of a show card those on any parent cards. See
	// Universal Action Model documentation for more details:
	// https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model
	//
	// TypeActionExecute was introduced in Adaptive Cards schema version 1.4.
	// TypeActionExecute actions may not render with earlier versions of the
	// Teams client.
	TypeActionExecute string = "Action.Execute"

	// ActionExecuteMinCardVersionRequired is the minimum version of the
	// Adaptive Card schema required to support Action.Execute.
	ActionExecuteMinCardVersionRequired float64 = 1.4

	// TypeActionSubmit is used in Adaptive Cards schema version 1.3 and
	// earlier or as a fallback for TypeActionExecute in schema version 1.4.
	// TypeActionSubmit is not supported in Incoming Webhooks.
	TypeActionSubmit string = "Action.Submit"

	// TypeActionOpenURL (when invoked) shows the given url either by
	// launching it in an external web browser or showing within an embedded
	// web browser.
	TypeActionOpenURL string = "Action.OpenUrl"

	// TypeActionShowCard defines an AdaptiveCard which is shown to the user
	// when the button or link is clicked.
	TypeActionShowCard string = "Action.ShowCard"

	// TypeActionToggleVisibility toggles the visibility of associated card
	// elements.
	TypeActionToggleVisibility string = "Action.ToggleVisibility"
)

Supported Actions

View Source
const (
	TypeFallbackActionExecute          string = TypeActionExecute
	TypeFallbackActionOpenURL          string = TypeActionOpenURL
	TypeFallbackActionShowCard         string = TypeActionShowCard
	TypeFallbackActionSubmit           string = TypeActionSubmit
	TypeFallbackActionToggleVisibility string = TypeActionToggleVisibility

	// TypeFallbackOptionDrop causes this element to be dropped immediately
	// when unknown elements are encountered. The unknown element doesn't
	// bubble up any higher.
	TypeFallbackOptionDrop string = "drop"
)

Supported Fallback options.

View Source
const (
	TypeElementActionSet      string = "ActionSet"
	TypeElementColumnSet      string = "ColumnSet"
	TypeElementContainer      string = "Container"
	TypeElementFactSet        string = "FactSet"
	TypeElementImage          string = "Image"
	TypeElementImageSet       string = "ImageSet"
	TypeElementInputChoiceSet string = "Input.ChoiceSet"
	TypeElementInputDate      string = "Input.Date"
	TypeElementInputNumber    string = "Input.Number"
	TypeElementInputText      string = "Input.Text"
	TypeElementInputTime      string = "Input.Time"
	TypeElementInputToggle    string = "Input.Toggle"
	TypeElementMedia          string = "Media"         // Introduced in version 1.1 (TODO: Is this supported in Teams message?)
	TypeElementRichTextBlock  string = "RichTextBlock" // Introduced in version 1.2
	TypeElementTable          string = "Table"         // Introduced in version 1.5
	TypeElementTextBlock      string = "TextBlock"
	TypeElementTextRun        string = "TextRun" // Introduced in version 1.2
)

Valid types for an Adaptive Card element. Not all types are supported by Microsoft Teams.

TODO: Confirm whether all types are supported.

View Source
const (
	MSTeamsWidthFull string = "Full"
)

Supported width values for the msteams property used in in Adaptive Card messages sent via Microsoft Teams.

View Source
const (
	TypeElementMSTeamsCodeBlock string = "CodeBlock"
)

Known extension types for an Adaptive Card element.

Variables

View Source
var (
	// ErrInvalidType indicates that an invalid type was specified.
	ErrInvalidType = errors.New("invalid type value")

	// ErrInvalidFieldValue indicates that an invalid value was specified.
	ErrInvalidFieldValue = errors.New("invalid field value")

	// ErrMissingValue indicates that an expected value was missing.
	ErrMissingValue = errors.New("missing expected value")

	// ErrValueNotFound indicates that a requested value was not found.
	ErrValueNotFound = errors.New("requested value not found")
)

Sentinel errors for this package.

Functions

func AddMention

func AddMention(card *Card, textBlock *Element, prependText bool, separator string, mentions ...Mention) error

AddMention adds one or more provided user mentions to the specified Card. The Text field for the specified TextBlock element is updated with the Mention Text. If specified, the Mention Text is prepended, otherwise appended. If specified, a custom separator is used between the Mention Text and the TextBlock Text field, otherwise the default separator is used.

NOTE: This function "registers" the specified Mention values with the Card and updates the specified textBlock element, however the caller is responsible for ensuring that the specified textBlock element is added to the Card.

An error is returned if specified Mention values fail validation, or one of Card or Element pointers are null.

func ConvertBreakToEOL

func ConvertBreakToEOL(s string) string

ConvertBreakToEOL converts <br> statements into \n\n to provide comparable spacing in Adaptive Card TextBlock elements.

This function is intended for processing text for use in an Adaptive Card TextBlock element. The goal is to provide spacing in rendered text display comparable to native display.

The primary use case of this function is to process text that was previously formatted in preparation for use in a MessageCard; the MessageCard format supports <br> statements for text spacing/formatting where the Adaptive Card format does not.

func ConvertEOL

func ConvertEOL(s string) string

ConvertEOL converts \r\n (windows), \r (mac) and \n (unix) into \n\n.

This function is intended for processing text for use in an Adaptive Card TextBlock element. The goal is to provide spacing in rendered text display comparable to native display.

NOTE: There are known discrepancies in the way that Microsoft Teams renders text in desktop, web and mobile, so even with using this helper function some differences are to be expected.

Types

type Action

type Action struct {

	// Type is required; specific values are supported.
	//
	// Action.Submit is not supported for Incoming Webhooks.
	//
	// Action.Execute was added in Adaptive Card schema version 1.4. which
	// Teams MAY not fully support.
	//
	// The supported actions are Action.OpenURL, Action.ShowCard,
	// Action.ToggleVisibility, and Action.Execute (see above).
	//
	// https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#support-for-adaptive-cards
	// https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model#schema
	Type string `json:"type"`

	// ID is a unique identifier associated with this Action.
	ID string `json:"id,omitempty"`

	// Title is a label for the button or link that represents this action.
	Title string `json:"title,omitempty"`

	// URL to open; required for the Action.OpenUrl type, optional for other
	// action types.
	URL string `json:"url,omitempty"`

	// Fallback describes what to do when an unknown element is encountered or
	// the requirements of this or any children can't be met.
	Fallback string `json:"fallback,omitempty"`

	// Card property is used by Action.ShowCard type.
	//
	// NOTE: Based on a review of JSON content, it looks like `ActionCard` is
	// really just a `Card` type.
	//
	// refs https://github.com/matthidinger/ContosoScubaBot/blob/master/Cards/SubscriberNotification.JSON
	Card *Card `json:"card,omitempty"`

	// TargetElements is the collection of TargetElement values.
	//
	// It is not recommended to include Input elements with validation due to
	// confusion that can arise from invalid inputs that are not currently
	// visible.
	//
	// https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/input-validation
	TargetElements []TargetElement `json:"targetElements,omitempty"`
}

Action represents an action that a user may take on a card. Actions typically get rendered in an "action bar" at the bottom of a card.

TODO: Extend with additional supported fields.

func NewActionOpenURL

func NewActionOpenURL(url string, title string) (Action, error)

NewActionOpenURL creates a new Action.OpenURL value using the provided URL and title. An error is returned if invalid values are supplied.

func NewActionToggleVisibility added in v2.9.0

func NewActionToggleVisibility(title string) Action

NewActionToggleVisibility creates a new Action.ToggleVisibility value using the (optionally) provided title text.

NOTE: The caller is responsible for adding required TargetElement values to meet validation requirements.

func (*Action) AddHiddenTargetElement added in v2.9.0

func (a *Action) AddHiddenTargetElement(elements ...Element) error

AddHiddenTargetElement records the Element IDs from the given Elements in new TargetElement values. All new TargetElement values are explicitly set as not visible.

func (*Action) AddTargetElement added in v2.9.0

func (a *Action) AddTargetElement(visible *bool, elements ...Element) error

AddTargetElement records the IDs from the given Elements in new TargetElement values. The specified visibility setting is used for the new TargetElement values.

  • If true, always show target Element.
  • If false, always hide target Element.
  • If nil, allow toggling target Element's visibility.

If the given visibility setting is nil, then the visibility setting for the TargetElement values is omitted. This enables toggling visibility for the target Elements (e.g., toggle button behavior).

func (*Action) AddTargetElementID added in v2.9.0

func (a *Action) AddTargetElementID(visible *bool, elementIDs ...string) error

AddTargetElementID records the given Element ID values in the TargetElements collection. A non-empty ID value is required, but the Adaptive Card "tree" is not searched for a valid match; it is up to the caller to ensure that the given ID value is valid.

The specified visibility setting is used for the new TargetElement values.

  • If true, always show target Element.
  • If false, always hide target Element.
  • If nil, allow toggling target Element's visibility.

If the given visibility setting is nil, then the visibility setting for the TargetElement values is omitted. This enables toggling visibility for the target Elements (e.g., toggle button behavior).

func (*Action) AddVisibleTargetElement added in v2.9.0

func (a *Action) AddVisibleTargetElement(elements ...Element) error

AddVisibleTargetElement records the Element IDs from the given Elements in new TargetElement values. All new TargetElement values are explicitly set as visible.

func (Action) Validate

func (a Action) Validate() error

Validate asserts that fields have valid values.

type Actions

type Actions []Action

Actions is a collection of Action values.

func (Actions) Validate

func (a Actions) Validate() error

Validate asserts that the collection of Action values are all valid.

type Attachment

type Attachment struct {

	// ContentType is required; must be set to
	// "application/vnd.microsoft.card.adaptive".
	ContentType string `json:"contentType"`

	// ContentURL appears to be related to support for tabs. Most examples
	// have this value set to null.
	//
	// TODO: Update this description with confirmed details.
	ContentURL NullString `json:"contentUrl,omitempty"`

	// Content represents the content of an Adaptive Card.
	//
	// TODO: Should this be a pointer?
	Content TopLevelCard `json:"content"`
}

Attachment represents an attached Adaptive Card for a Microsoft Teams message.

func (Attachment) Validate

func (a Attachment) Validate() error

Validate asserts that fields have valid values.

type Attachments

type Attachments []Attachment

Attachments is a collection of Adaptive Cards for a Microsoft Teams message.

func (Attachments) Validate

func (a Attachments) Validate() error

Validate asserts that the collection of Attachment values are all valid.

type Card

type Card struct {

	// Type is required; must be set to "AdaptiveCard"
	Type string `json:"type"`

	// Schema represents the URI of the Adaptive Card schema.
	Schema string `json:"$schema"`

	// Version is required for top-level cards (i.e., the outer card in an
	// attachment); the schema version that the content for an Adaptive Card
	// requires.
	//
	// The TopLevelCard type is a superset of the Card type and asserts that
	// this field is properly set, whereas the validation logic for this
	// (Card) type skips that assertion.
	Version string `json:"version"`

	// FallbackText is the text shown when the client doesn't support the
	// version specified (may contain markdown).
	FallbackText string `json:"fallbackText,omitempty"`

	// Body represents the body of an Adaptive Card. The body is made up of
	// building-blocks known as elements. Elements can be composed to create
	// many types of cards. These elements are shown in the primary card
	// region.
	Body []Element `json:"body"`

	// Actions is a collection of actions to show in the card's action bar.
	// The action bar is displayed at the bottom of a Card.
	//
	// NOTE: The max display limit has been observed to be a fixed value for
	// web/desktop app and a matching value as an initial display limit for
	// mobile app with the option to expand remaining actions in a list.
	//
	// This value is recorded in this package as "TeamsActionsDisplayLimit".
	//
	// To work around this limit, create multiple ActionSets each limited to
	// the value of TeamsActionsDisplayLimit.
	Actions []Action `json:"actions,omitempty"`

	// MSTeams is a container for properties specific to Microsoft Teams
	// messages, including formatting properties and user mentions.
	//
	// NOTE: Using pointer in order to omit unused field from JSON output.
	// https://stackoverflow.com/questions/18088294/how-to-not-marshal-an-empty-struct-into-json-with-go
	// MSTeams *MSTeams `json:"msteams,omitempty"`
	//
	// TODO: Revisit this and use a pointer if remote API doesn't like
	// receiving an empty object, though brief testing doesn't show this to be
	// a problem.
	MSTeams MSTeams `json:"msteams,omitempty"`

	// MinHeight specifies the minimum height of the card.
	MinHeight string `json:"minHeight,omitempty"`

	// VerticalContentAlignment defines how the content should be aligned
	// vertically within the container. Only relevant for fixed-height cards,
	// or cards with a minHeight specified. If MinHeight field is specified,
	// this field is required.
	VerticalContentAlignment string `json:"verticalContentAlignment,omitempty"`
}

Card represents the content of an Adaptive Card. The TopLevelCard is a superset of this one, asserting that the Version field is properly set. That type is used exclusively for Message Attachments. This type is used directly for the Action.ShowCard Card field.

func NewCard

func NewCard() Card

NewCard creates and returns an empty Card.

func NewMentionCard

func NewMentionCard(displayName string, id string, msgText string) (Card, error)

NewMentionCard creates a new Card with user Mention using the given displayName, ID and message text. An error is returned if provided values are insufficient to create the user mention.

func NewTextBlockCard

func NewTextBlockCard(text string, title string, wrap bool) (Card, error)

NewTextBlockCard creates a new Card using the specified text and optional title. If specified, the TextBlock has text wrapping enabled.

func (*Card) AddAction

func (c *Card) AddAction(prepend bool, actions ...Action) error

AddAction adds one or more provided Actions to the associated Card. If specified, the Action values are prepended to the Card (as a collection retaining current order), otherwise appended.

NOTE: The max display limit for a Card's actions array has been observed to be a fixed value for web/desktop app and a matching value as an initial display limit for mobile app with the option to expand remaining actions in a list.

This value is recorded in this package as "TeamsActionsDisplayLimit".

Consider adding Action values to one or more ActionSet elements as needed and include within the Card.Body directly or within a Container to workaround this limit.

An error is returned if specified Action values fail validation.

func (*Card) AddContainer

func (c *Card) AddContainer(prepend bool, container Container) error

AddContainer adds the given Container Element to the collection of Element values for the Card. If specified, the Container Element is inserted at the beginning of the collection, otherwise appended to the end.

func (*Card) AddElement

func (c *Card) AddElement(prepend bool, elements ...Element) error

AddElement adds one or more provided Elements to the Body of the associated Card. If specified, the Element values are prepended to the Card Body (as a contiguous set retaining current order), otherwise appended to the Card Body.

An error is returned if specified Element values fail validation.

func (*Card) AddFactSet

func (c *Card) AddFactSet(prepend bool, factsets ...FactSet) error

AddFactSet adds one or more provided FactSet elements to the Body of the associated Card. If specified, the FactSet values are prepended to the Card Body (as a contiguous set retaining current order), otherwise appended to the Card Body.

An error is returned if specified FactSet values fail validation.

TODO: Is this needed? Should we even have a separate FactSet type that is so difficult to work with?

func (*Card) AddMention

func (c *Card) AddMention(prepend bool, mentions ...Mention) error

AddMention adds one or more provided user mentions to the associated Card along with a new TextBlock element. The Text field for the new TextBlock element is updated with the Mention Text.

If specified, the new TextBlock element is inserted as the first element in the Card body. This effectively creates a dedicated TextBlock that acts as a "lead-in" or "announcement block" for other elements in the Card. If false, the newly created TextBlock is appended to the Card, effectively creating a "CC" list commonly found at the end of an email message.

An error is returned if specified Mention values fail validation.

func (*Card) GetElement

func (c *Card) GetElement(id string) (*Element, error)

GetElement searches all Element values attached to the Card for the specified ID (case sensitive). If found, a pointer to the Element is returned, otherwise an error is returned.

func (*Card) Mention

func (c *Card) Mention(displayName string, id string, msgText string, prependElement bool) error

Mention uses the given display name, ID and message text to add a new user Mention and TextBlock element to the Card. If specified, the new TextBlock element is added as the first element of the Card, otherwise it is added last. An error is returned if provided values are insufficient to create the user mention.

func (*Card) SetFullWidth

func (c *Card) SetFullWidth()

SetFullWidth enables full width display for the Card.

func (Card) Validate

func (c Card) Validate() error

Validate asserts that fields have valid values.

type Column

type Column struct {
	// Type is required; must be set to "Column" when used with ColumnSet type
	// or "TableColumnDefinition" when used as a Table column.
	Type string `json:"type,omitempty"`

	// ID is a unique identifier associated with this Column.
	ID string `json:"id,omitempty"`

	// Width represents the width of a column in the column group OR a column
	// in a table. Valid values consist of fixed strings OR a number
	// representing the relative width.
	//
	// If used in a column group, valid values are "auto", "stretch", a number
	// representing relative width of the column in the column group or a
	// string that specifies a pixel width, like "50px".
	//
	// If used in a table, valid values are a number representing relative
	// width of the column relative to the other columns in the table or a
	// string that specifies a pixel width, like "50px".
	Width interface{} `json:"width,omitempty"`

	// Items are the card elements that should be rendered inside of the
	// column.
	Items []*Element `json:"items,omitempty"`

	// SelectAction is an action that will be invoked when the Column is
	// tapped or selected. Action.ShowCard is not supported.
	SelectAction *ISelectAction `json:"selectAction,omitempty"`

	// HorizontalCellContentAlignment is a property of the Table element type.
	//
	// This field controls how the content of all cells in the column is
	// horizontally aligned by default. When specified, this value overrides
	// the setting at the table level. When not specified, horizontal
	// alignment is defined at the table, row or cell level.
	HorizontalCellContentAlignment string `json:"horizontalCellContentAlignment,omitempty"`

	// VerticalCellContentAlignment is a property of the Table element type.
	//
	// This field controls how the content of all cells in the column is
	// vertically aligned by default. When specified, this value overrides the
	// setting at the table level. When not specified, vertical alignment is
	// defined at the table, row or cell level.
	VerticalCellContentAlignment string `json:"verticalCellContentAlignment,omitempty"`
}

Column is a container used by a ColumnSet or Table element type. Each container may contain one or more elements.

https://adaptivecards.io/explorer/Column.html

func NewColumn added in v2.9.0

func NewColumn() Column

NewColumn creates an empty Column.

func (*Column) AddSelectAction added in v2.9.0

func (c *Column) AddSelectAction(action interface{}) error

AddSelectAction adds a given Action or ISelectAction value to the associated Column. This action will be invoked when the Column is tapped or selected.

An error is returned if the given Action or ISelectAction value fails validation or if a value other than an Action or ISelectAction is provided.

func (Column) Validate

func (c Column) Validate() error

Validate asserts that fields have valid values.

type ColumnItems

type ColumnItems []*Element

ColumnItems is a collection of card elements that should be rendered inside of the column.

func (ColumnItems) Validate

func (ci ColumnItems) Validate() error

Validate asserts that the Items collection field for a column contains valid values. Special handling is applied since the collection could contain nil values.

type Columns

type Columns []Column

Columns is a collection of Column values for a ColumnSet or a Table.

func (Columns) Validate

func (c Columns) Validate() error

Validate asserts that the collection of Column values are all valid.

type Container

type Container Element

Container is an Element type that allows grouping items together.

func NewContainer

func NewContainer() Container

NewContainer creates an empty Container.

func NewHiddenContainer added in v2.9.0

func NewHiddenContainer() Container

NewHiddenContainer creates an empty Container whose initial state is set as hidden from view.

func (*Container) AddAction

func (c *Container) AddAction(prepend bool, actions ...Action) error

AddAction adds one or more provided Action values to the associated Container as one or more new ActionSets. The number of actions in each newly created ActionSet is limited to the number specified by TeamsActionsDisplayLimit.

If specified, the newly created ActionSets are inserted before other Elements in the Container, otherwise appended.

If adding an action to be used when the Container is tapped or selected use AddSelectAction() instead.

An error is returned if specified Action values fail validation.

func (*Container) AddElement

func (c *Container) AddElement(prepend bool, element Element) error

AddElement adds the given Element to the collection of Element values in the container. If specified, the Element is inserted at the beginning of the collection, otherwise appended to the end.

func (*Container) AddSelectAction added in v2.9.0

func (c *Container) AddSelectAction(action interface{}) error

AddSelectAction adds a given Action or ISelectAction value to the associated Container. This action will be invoked when the Container is tapped or selected.

An error is returned if the given Action or ISelectAction value fails validation or if a value other than an Action or ISelectAction is provided.

type Element

type Element struct {

	// Type is required and indicates the type of the element used in the body
	// of an Adaptive Card.
	// https://adaptivecards.io/explorer/AdaptiveCard.html
	Type string `json:"type"`

	// ID is a unique identifier associated with this Element.
	ID string `json:"id,omitempty"`

	// Text is required by the TextBlock and TextRun element types. Text is
	// used to display text. A subset of markdown is supported for text used
	// in TextBlock elements, but no formatting is permitted in text used in
	// TextRun elements.
	//
	// https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/text-features
	// https://adaptivecards.io/explorer/TextBlock.html
	// https://adaptivecards.io/explorer/TextRun.html
	Text string `json:"text,omitempty"`

	// URL is required for the Image element type. URL is the URL to an Image
	// in an ImageSet element type.
	//
	// https://adaptivecards.io/explorer/Image.html
	// https://adaptivecards.io/explorer/ImageSet.html
	URL string `json:"url,omitempty"`

	// Size controls the size of text within a TextBlock element.
	Size string `json:"size,omitempty"`

	// Weight controls the weight of text in TextBlock or TextRun elements.
	Weight string `json:"weight,omitempty"`

	// Color controls the color of TextBlock elements or text used in TextRun
	// elements.
	Color string `json:"color,omitempty"`

	// Spacing controls the amount of spacing between this element and the
	// preceding element.
	Spacing string `json:"spacing,omitempty"`

	// HorizontalAlignment controls the horizontal text alignment.
	HorizontalAlignment string `json:"horizontalAlignment,omitempty"`

	// The style of the element for accessibility purposes. Valid values
	// differ based on the element type. For example, a TextBlock element
	// supports the "heading" style, whereas the Column element supports the
	// "attention" style (TextBlock does not).
	Style string `json:"style,omitempty"`

	// Items is required for most Container element types. Items is a
	// collection of card elements to render inside the Container.
	Items []Element `json:"items,omitempty"`

	// Columns is a collection of Columns used to divide a region. This field
	// is used both by ColumnSet and Table element types. The specific field
	// validation applied is based on the Type field of this Element.
	Columns []Column `json:"columns,omitempty"`

	// Rows defines the rows of the table. This field is used by a Table
	// element type.
	Rows []TableRow `json:"rows,omitempty"`

	// GridStyle defines the style of the grid. This property currently only
	// controls the grid's color. This field is used by a Table element type.
	GridStyle string `json:"gridStyle,omitempty"`

	// FirstRowAsHeaders specifies whether the first row of the table should be
	// treated as a header row, and be announced as such by accessibility
	// software. This field is used by a Table element type.
	//
	// If not specified defaults to true.
	//
	// NOTE: We define this field as a pointer type so that omitting a value
	// for the pointer leaves the field out of the generated JSON payload (due
	// to 'omitempty' behavior of the JSON encoder and results in the
	// "defaults to true" behavior as defined by the schema.
	FirstRowAsHeaders *bool `json:"firstRowAsHeaders,omitempty"`

	// Visible specifies whether this element will be removed from the visual
	// tree.
	//
	// If not specified defaults to true.
	//
	// NOTE: We define this field as a pointer type so that omitting a value
	// for the pointer leaves the field out of the generated JSON payload (due
	// to 'omitempty' behavior of the JSON encoder and results in the
	// "defaults to true" behavior as defined by the schema.
	Visible *bool `json:"isVisible,omitempty"`

	// ShowGridLines specified whether grid lines should be displayed.  This
	// field is used by a Table element type.
	//
	// If not specified defaults to true.
	//
	// NOTE: We define this field as a pointer type so that omitting a value
	// for the pointer leaves the field out of the generated JSON payload (due
	// to 'omitempty' behavior of the JSON encoder and results in the
	// "defaults to true" behavior as defined by the schema.
	ShowGridLines *bool `json:"showGridLines,omitempty"`

	// Actions is required for the ActionSet element type. Actions is a
	// collection of Actions to show for an ActionSet element type.
	//
	// TODO: Should this be a pointer?
	Actions []Action `json:"actions,omitempty"`

	// SelectAction is an Action that will be invoked when the Container
	// element is tapped or selected. Action.ShowCard is not supported.
	//
	// This field is used by supported Container element types (Column,
	// ColumnSet, Container).
	//
	SelectAction *ISelectAction `json:"selectAction,omitempty"`

	// Facts is required for the FactSet element type. Actions is a collection
	// of Fact values that are part of a FactSet element type. Each Fact value
	// is a key/value pair displayed in tabular form.
	//
	// TODO: Should this be a pointer?
	Facts []Fact `json:"facts,omitempty"`

	// Wrap controls whether text is allowed to wrap or is clipped for
	// TextBlock elements.
	Wrap bool `json:"wrap,omitempty"`

	// IsSubtle specifies whether this element should appear slightly toned
	// down.
	IsSubtle bool `json:"isSubtle,omitempty"`

	// Separator, when true, indicates that a separating line shown should be
	// drawn at the top of the element.
	Separator bool `json:"separator,omitempty"`

	// CodeSnippet provides the content for a CodeBlock element, specific to MSTeams.
	CodeSnippet string `json:"codeSnippet,omitempty"`

	// Language specifies the language of a CodeBlock element, specific to MSTeams.
	Language string `json:"language,omitempty"`

	// StartLineNumber specifies the initial line number of CodeBlock element, specific to MSTeams.
	StartLineNumber int `json:"startLineNumber,omitempty"`
}

Element is a "building block" for an Adaptive Card. Elements are shown within the primary card region (aka, "body"), columns and other container types. Not all fields of this Go struct type are supported by all Adaptive Card element types.

func NewActionSet

func NewActionSet() Element

NewActionSet creates an empty ActionSet.

TODO: Should we create a type alias for ActionSet, or keep it as a "base" Element type?

func NewActionSetsFromActions

func NewActionSetsFromActions(actions ...Action) ([]Element, error)

NewActionSetsFromActions creates a new ActionSet for every TeamsActionsDisplayLimit count of Actions given. An error is returned if the specified Actions do not pass validation.

func NewCodeBlock added in v2.13.0

func NewCodeBlock(snippet string, language string, firstLine int) Element

NewCodeBlock creates a new CodeBlock element with snippet, language, and optional firstLine. This is an MSTeams extension element.

Supported languages include:

  • Bash
  • C
  • C#
  • C++
  • CSS
  • DOS
  • Go
  • GraphQL
  • HTML
  • Java
  • JavaScript
  • JSON
  • Perl
  • PHP
  • PlainText
  • PowerShell
  • Python
  • SQL
  • TypeScript
  • Verilog
  • VHDL
  • Visual Basic
  • XML

See https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format for additional languages that may be supported.

func NewColumnSet added in v2.9.0

func NewColumnSet() Element

NewColumnSet creates an empty Element of type ColumnSet.

func NewHiddenTextBlock added in v2.9.0

func NewHiddenTextBlock(text string, wrap bool) Element

NewHiddenTextBlock creates a new TextBlock element using the optional user specified Text. If specified, text wrapping is enabled.

The new TextBlock is explicitly hidden from view. To view this Element, the caller should set an ID value and then allow toggling visibility by referencing this TextBlock's ID from a TargetElement associated with a ToggleVisibility Action.

func NewTable added in v2.8.0

func NewTable() Element

NewTable creates an empty Element of Table type.

func NewTableFromTableCells added in v2.8.0

func NewTableFromTableCells(cells [][]TableCell, numColumns int, firstRowIsHeaders bool, showGridLines bool) (Element, error)

NewTableFromTableCells accepts a multidimensional collection of TableCell values, the number of columns that the table should have, a boolean value indicating whether the first row should be treated as a header row and another boolean value indicating whether grid lines should be displayed for the table.

If the specified number of columns is zero then the number of columns will be calculated using the number of values in the first row.

The outer slice is the collection of rows and the inner slice is the collection of values. The number of cells per row is determined by the number of cell values in that row. If a collection of values for a row is empty, an empty row is inserted into the generated table.

func NewTableWithGridFromTableCells added in v2.8.0

func NewTableWithGridFromTableCells(cells []TableCell, perRow int) (Element, error)

NewTableWithGridFromTableCells accepts a collection of TableCell values and the number of cells that should be inserted per table row. Header values are not inserted.

func NewTextBlock

func NewTextBlock(text string, wrap bool) Element

NewTextBlock creates a new TextBlock element using the optional user specified Text. If specified, text wrapping is enabled.

func NewTitleTextBlock

func NewTitleTextBlock(title string, wrap bool) Element

NewTitleTextBlock uses the specified text to create a new TextBlock formatted as a "header" or "title" element. If specified, the TextBlock has text wrapping enabled. The effect is meant to emulate the visual effects of setting a MessageCard.Title field.

func (*Element) AddTableRow added in v2.8.0

func (e *Element) AddTableRow(rows ...TableRow) error

AddTableRow adds one or many TableRow values to an Element of Table type. An error is returned if a TableRow value fails validation or if AddRow is called on any Element type other than a Table.

func (Element) HasMentionText

func (e Element) HasMentionText(m Mention) bool

HasMentionText asserts that a supported Element type contains the required Mention text string necessary to link a user mention to a specific Element.

func (Element) Validate

func (e Element) Validate() error

Validate asserts that fields have valid values.

type Elements

type Elements []Element

Elements is a collection of Element values.

func (Elements) Validate

func (e Elements) Validate() error

Validate asserts that the collection of Element values are all valid.

type Fact

type Fact struct {
	// Title is required; the title of the fact.
	Title string `json:"title"`

	// Value is required; the value of the fact.
	Value string `json:"value"`
}

Fact represents a Fact in a FactSet as a key/value pair.

func (Fact) Validate

func (f Fact) Validate() error

Validate asserts that fields have valid values.

type FactSet

type FactSet Element

FactSet is an Element type that groups and displays a series of facts (i.e. name/value pairs) in a tabular form.

func NewFactSet

func NewFactSet() FactSet

NewFactSet creates an empty FactSet.

func (*FactSet) AddFact

func (fs *FactSet) AddFact(facts ...Fact) error

AddFact adds one or many Fact values to a FactSet. An error is returned if the Fact fails validation or if AddFact is called on an unsupported Element type.

type Facts

type Facts []Fact

Facts is a collection of Fact values.

func (Facts) Validate

func (f Facts) Validate() error

Validate asserts that the collection of Fact values are all valid.

type ISelectAction

type ISelectAction struct {

	// Type is required; specific values are supported.
	//
	// The supported actions are Action.Execute, Action.OpenUrl,
	// Action.ToggleVisibility.
	//
	// See also https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference
	Type string `json:"type"`

	// ID is a unique identifier associated with this ISelectAction.
	ID string `json:"id,omitempty"`

	// Title is a label for the button or link that represents this action.
	Title string `json:"title,omitempty"`

	// URL is required for the Action.OpenUrl type, optional for other action
	// types.
	URL string `json:"url,omitempty"`

	// Fallback describes what to do when an unknown element is encountered or
	// the requirements of this or any children can't be met.
	Fallback string `json:"fallback,omitempty"`

	// TargetElements is the collection of TargetElement values.
	//
	// This field is specific to the Action.ToggleVisibility Action type.
	//
	// It is not recommended to include Input elements with validation due to
	// confusion that can arise from invalid inputs that are not currently
	// visible.
	//
	// https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/input-validation
	TargetElements []TargetElement `json:"targetElements,omitempty"`
}

ISelectAction represents an Action that will be invoked when a container type (e.g., Column, ColumnSet, Container) is tapped or selected. Action.ShowCard is not supported.

TODO: Extend with additional supported fields.

func (ISelectAction) Validate

func (i ISelectAction) Validate() error

Validate asserts that fields have valid values.

type MSTeams

type MSTeams struct {

	// Width controls the width of Adaptive Cards within a Microsoft Teams
	// messages.
	// https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format#full-width-adaptive-card
	Width string `json:"width,omitempty"`

	// AllowExpand controls whether images can be displayed in stage view
	// selectively.
	//
	// https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format#stage-view-for-images-in-adaptive-cards
	AllowExpand bool `json:"allowExpand,omitempty"`

	// Entities is a collection of user mentions.
	// TODO: Should this be a slice of pointers?
	Entities []Mention `json:"entities,omitempty"`
}

MSTeams represents a container for properties specific to Microsoft Teams messages, including formatting properties and user mentions.

func (MSTeams) Validate

func (m MSTeams) Validate() error

Validate asserts that fields have valid values.

type Mention

type Mention struct {
	// Type is required; must be set to "mention".
	Type string `json:"type"`

	// Text must match a portion of the message text field. If it does not,
	// the mention is ignored.
	//
	// Brief testing indicates that this needs to wrap a name/value in <at>NAME
	// HERE</at> tags.
	Text string `json:"text"`

	// Mentioned represents a user that is mentioned.
	Mentioned Mentioned `json:"mentioned"`
}

Mention represents a mention in the message for a specific user.

func NewMention

func NewMention(displayName string, id string) (Mention, error)

NewMention uses the given display name and ID to create a user Mention value for inclusion in a Card. An error is returned if provided values are insufficient to create the user mention.

func (Mention) Validate

func (m Mention) Validate() error

Validate asserts that fields have valid values.

Element.Validate() asserts that required Mention.Text content is found for each recorded user mention the Card..

type Mentioned

type Mentioned struct {
	// ID is the unique identifier for a user that is mentioned. This value
	// can be an object ID (e.g., 5e8b0f4d-2cd4-4e17-9467-b0f6a5c0c4d0) or a
	// UserPrincipalName (e.g., NewUser@contoso.onmicrosoft.com).
	ID string `json:"id"`

	// Name is the DisplayName of the user mentioned.
	Name string `json:"name"`
}

Mentioned represents the user id and name of a user that is mentioned.

func (Mentioned) Validate

func (m Mentioned) Validate() error

Validate asserts that fields have valid values.

type Mentions

type Mentions []Mention

Mentions is a collection of Mention values.

func (Mentions) Validate

func (m Mentions) Validate() error

Validate asserts that the collection of Mention values are all valid.

type Message

type Message struct {
	// Type is required; must be set to "message".
	Type string `json:"type"`

	// Attachments is a collection of one or more Adaptive Cards.
	//
	// NOTE: Including multiple attachment *without* AttachmentLayout set to
	// "carousel" hides cards after the first. Not sure if this is a bug, or
	// if it's intentional.
	Attachments []Attachment `json:"attachments"`

	// AttachmentLayout controls the layout for Adaptive Cards in the
	// Attachments collection.
	AttachmentLayout string `json:"attachmentLayout,omitempty"`

	// ValidateFunc is an optional user-specified validation function that is
	// responsible for validating a Message. If not specified, default
	// validation is performed.
	ValidateFunc func() error `json:"-"`
	// contains filtered or unexported fields
}

Message represents a Microsoft Teams message containing one or more Adaptive Cards.

func NewMentionMessage

func NewMentionMessage(displayName string, id string, msgText string) (*Message, error)

NewMentionMessage creates a new simple Message. Using the given message text, displayName and ID, a user Mention is also created and added to the new Message. An error is returned if provided values are insufficient to create the user mention.

func NewMessage

func NewMessage() *Message

NewMessage creates a new Message with required fields predefined.

func NewMessageFromCard

func NewMessageFromCard(card Card) (*Message, error)

NewMessageFromCard is a helper function for creating a new Message based off of an existing Card value.

func NewSimpleMessage

func NewSimpleMessage(text string, title string, wrap bool) (*Message, error)

NewSimpleMessage creates a new simple Message using the specified text and optional title. If specified, text wrapping is enabled. An error is returned if an empty text string is specified.

func (*Message) Attach

func (m *Message) Attach(cards ...Card) error

Attach receives and adds one or more Card values to the Attachments collection for a Microsoft Teams message.

NOTE: Including multiple cards in the attachments collection *without* attachmentLayout set to "carousel" hides cards after the first. Not sure if this is a bug, or if it's intentional.

func (*Message) Carousel

func (m *Message) Carousel() *Message

Carousel sets the Message Attachment layout to Carousel display mode.

func (*Message) Mention

func (m *Message) Mention(prependElement bool, displayName string, id string, msgText string) error

Mention uses the provided display name, ID and text values to add a new user Mention and TextBlock element to the first Card in the Message.

If no Cards are yet attached to the Message, a new card is created using the Mention and TextBlock element. If specified, the new TextBlock element is added as the first element of the Card, otherwise it is added last. An error is returned if insufficient values are provided.

func (*Message) Payload

func (m *Message) Payload() io.Reader

Payload returns the prepared Message payload. The caller should call Prepare() prior to calling this method, results are undefined otherwise.

func (*Message) Prepare

func (m *Message) Prepare() error

Prepare handles tasks needed to construct a payload from a Message for delivery to an endpoint.

func (*Message) PrettyPrint

func (m *Message) PrettyPrint() string

PrettyPrint returns a formatted JSON payload of the Message if the Prepare() method has been called, or an empty string otherwise.

func (Message) Validate

func (m Message) Validate() error

Validate performs validation for Message using ValidateFunc if defined, otherwise applying default validation.

type NullString

type NullString string

NullString represents a string value used in component fields that may potentially be null in the input JSON feed.

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. This compliments the custom Unmarshaler implementation to handle potentially null component description field value.

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface to handle potentially null component description field value.

type TableCell added in v2.8.0

type TableCell struct {
	// Type is required; must be set to "TableCell".
	Type string `json:"type"`

	// Style is a style hint for a TableCell.
	Style string `json:"style,omitempty"`

	// Bleed determines whether the element should bleed through its parent's
	// padding.
	Bleed bool `json:"bleed,omitempty"`

	// MinHeight specifies the minimum height of the container in pixels
	// (e.g., 80px).
	MinHeight string `json:"minHeight,omitempty"`

	// VerticalContentAlignment defines how the content should be aligned
	// vertically within the container.
	//
	// When not specified, the value of VerticalContentAlignment is inherited
	// from the parent container. If no parent container has
	// VerticalContentAlignment set, it defaults to Top.
	VerticalContentAlignment string `json:"verticalContentAlignment,omitempty"`

	// Items are the card elements that should be rendered inside of the
	// cell.
	Items []*Element `json:"items,omitempty"`
}

TableCell represents a cell within a row of a Table element.

https://adaptivecards.io/explorer/TableCell.html

func NewTableCellFromElement added in v2.8.0

func NewTableCellFromElement(element Element) (TableCell, error)

NewTableCellFromElement accepts an Element value and returns a TableCell populated with that Element.

func NewTableCellFromElements added in v2.8.0

func NewTableCellFromElements(elements ...Element) (TableCell, error)

NewTableCellFromElements accepts a collection of Element values and returns a TableCell populated with those Elements.

func (*TableCell) AddElement added in v2.8.0

func (tr *TableCell) AddElement(elements ...*Element) error

AddElement adds one or many Element value pointers to a TableCell. An error is returned if any Element value fails validation.

func (TableCell) Validate added in v2.8.0

func (tr TableCell) Validate() error

Validate asserts that fields have valid values.

type TableCells added in v2.8.0

type TableCells []TableCell

TableCells is a collection of TableCell values.

func NewTableCellsWithTextBlock added in v2.8.0

func NewTableCellsWithTextBlock(items []interface{}) (TableCells, error)

NewTableCellsWithTextBlock accepts a collection of items that can be converted to string values and returns a collection of TableCells, each populated with a single TextBlock containing one of the given items.

Example usage:

vals := []int{1, 2, 3} items := make([]interface{}, len(vals))

for i := range vals {
	items[i] = vals[i]
}

tableCells := NewTextBlockTableCells(items)

func (TableCells) Validate added in v2.8.0

func (tcs TableCells) Validate() error

Validate asserts that the collection of TableCell values are all valid.

type TableColumnDefinition added in v2.8.0

type TableColumnDefinition Column

TableColumnDefinition defines the characteristics of a column in a Table element such as number of columns or their sizes.

https://adaptivecards.io/explorer/Table.html

func (TableColumnDefinition) Validate added in v2.8.0

func (tcd TableColumnDefinition) Validate() error

Validate asserts that fields have valid values.

type TableColumnDefinitions added in v2.8.0

type TableColumnDefinitions []Column

TableColumnDefinitions is a collection of TableColumnDefinition values.

We use this as a "wrapper" type to convert a Columns collection so that we can apply specific validation requirements specific to a Table column.

func (TableColumnDefinitions) Validate added in v2.8.0

func (tcds TableColumnDefinitions) Validate() error

Validate asserts that the collection of TableColumnDefinition values are all valid.

type TableRow added in v2.8.0

type TableRow struct {
	// Type is required; must be set to "TableRow".
	Type string `json:"type"`

	// Style defines the style of the entire row.
	Style string `json:"style,omitempty"`

	// HorizontalCellContentAlignment is a property of the Table element type.
	//
	// This field controls how the content of all cells in the row is
	// horizontally aligned by default. When specified, this value overrides
	// both the setting at the table and columns level. When not specified,
	// horizontal alignment is defined at the table, column or cell level.
	HorizontalCellContentAlignment string `json:"horizontalCellContentAlignment,omitempty"`

	// VerticalCellContentAlignment is a property of the Table element type.
	//
	// This field controls how the content of all cells in the column is
	// vertically aligned by default. When specified, this value overrides the
	// setting at the table and column level. When not specified, vertical
	// alignment is defined either at the table, column or cell level.
	VerticalCellContentAlignment string `json:"verticalCellContentAlignment,omitempty"`

	// Cells are the cells in this row. If a row contains more cells than
	// there are columns defined on the Table element, the extra cells are
	// ignored.
	Cells []TableCell `json:"cells"`
}

TableRow is a row within a Table each being a collection of cells. Rows are not required, which allows empty Tables to be generated via templating without breaking the rendering of the whole card.

https://adaptivecards.io/explorer/Table.html

func NewTableRowFromCells added in v2.8.0

func NewTableRowFromCells(cells ...TableCell) (TableRow, error)

NewTableRowFromCells accepts a collection of TableCell values and returns a TableRow populated with those TableCells.

func (*TableRow) AddCell added in v2.8.0

func (tr *TableRow) AddCell(cells ...TableCell) error

AddCell adds one or many TableCell values to a TableRow. An error is returned if any TableCell value fails validation.

func (TableRow) Validate added in v2.8.0

func (tr TableRow) Validate() error

Validate asserts that fields have valid values.

type TableRows added in v2.8.0

type TableRows []TableRow

TableRows is a collection of TableRow values.

func (TableRows) Validate added in v2.8.0

func (trs TableRows) Validate() error

Validate asserts that the collection of TableRow values are all valid.

type TargetElement added in v2.9.0

type TargetElement struct {
	// ElementID is the ID value of the element to toggle.
	ElementID string `json:"elementId"`

	// Visible provides display or visibility control for a target Element.
	//
	//  - If true, always show target element.
	//  - If false, always hide target element.
	//  - If not supplied, toggle target element's visibility.
	//
	// NOTE: We define this field as a pointer type so that omitting a value
	// for the pointer leaves the field out of the generated JSON payload (due
	// to 'omitempty' behavior of the JSON encoder. If leaving this field out,
	// visibility can be toggled for target Elements.
	Visible *bool `json:"isVisible,omitempty"`
}

TargetElement represents an entry for Action.ToggleVisibility's targetElements property.

type TopLevelCard

type TopLevelCard struct {
	Card
}

TopLevelCard represents the outer or top-level Card for a Microsoft Teams Message attachment.

func (TopLevelCard) Validate

func (tc TopLevelCard) Validate() error

Validate asserts that fields have valid values.

Jump to

Keyboard shortcuts

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