Skip to content

Code Reference

ActionMode

Bases: Enum

Determines whether the action should be displayed as a button or in the overflow menu.

Attributes:

Name Type Description
PRIMARY

Action is displayed as a button.

SECONDARY

Action is placed in an overflow menu (typically a popup menu under a ... button).

Source code in msadaptivecards/base.py
288
289
290
291
292
293
294
295
296
297
298
299
300
class ActionMode(Enum):
    """
    Determines whether the action should be displayed as a button or in the overflow menu.

    Attributes:
        PRIMARY:
            Action is displayed as a button.
        SECONDARY:
            Action is placed in an overflow menu (typically a popup menu under a ... button).
    """

    PRIMARY = "primary"
    SECONDARY = "secondary"

ActionModel

Bases: CamelModel

Base model for all action types

Other Parameters:

Name Type Description
title str

Label for button or link that represents this action.

icon_url str

Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+

id str

A unique identifier associated with this Action.

style ActionStyle

Controls the style of an Action, which influences how the action is displayed, spoken, etc.

fallback ActionModel

Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.

tooltip str

Defines text that should be displayed to the end user as they hover the mouse over the action, and read when using narration software.

is_enabled bool

Determines whether the action should be enabled.

mode ActionMode

Determines whether the action should be displayed as a button or in the overflow menu.

requires Dict[str, str]

A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.

Source code in msadaptivecards/base.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
class ActionModel(CamelModel):
    """
    Base model for all action types

    Keyword Args:
        title (str):
            Label for button or link that represents this action.
        icon_url (str):
            Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+
        id (str):
            A unique identifier associated with this Action.
        style (ActionStyle):
            Controls the style of an Action, which influences how the action is displayed, spoken, etc.
        fallback (ActionModel):
            Describes what to do when an unknown element is encountered or the requires of this or any
            children can't be met.
        tooltip (str):
            Defines text that should be displayed to the end user as they hover the mouse over the action,
            and read when using narration software.
        is_enabled (bool):
            Determines whether the action should be enabled.
        mode (ActionMode):
            Determines whether the action should be displayed as a button or in the overflow menu.
        requires (Dict[str, str]):
            A series of key/value pairs indicating features that the item requires with corresponding minimum version.
            When a feature is missing or of insufficient version, fallback is triggered.
    """

    title: str = Field(None, description="Label for button or link that represents this action.")
    icon_url: str = Field(
        None,
        description="Optional icon to be shown on the action in conjunction with the title. "
        "Supports data URI in version 1.2+",
    )
    id: str = Field(None, description="A unique identifier associated with this Action.")
    style: ActionStyle = Field(
        None,
        description="Controls the style of an Action, which influences how the action is displayed, spoken, etc.",
    )
    fallback: "ActionModel" = Field(
        None,
        description="Describes what to do when an unknown element is encountered or "
        "the requires of this or any children can’t be met.",
    )
    tooltip: str = Field(
        None,
        description="Defines text that should be displayed to the end user as they hover the "
        "mouse over the action, and read when using narration software.",
    )
    is_enabled: bool = Field(True, description="Determines whether the action should be enabled.")
    mode: ActionMode = Field(
        None, description="Determines whether the action should be displayed as a button or in the overflow menu."
    )
    requires: Dict[str, str] = Field(
        default_factory=dict,
        description="A series of key/value pairs indicating "
        "features that the item requires with corresponding minimum version. When a feature is missing or of "
        "insufficient version, fallback is triggered.",
    )

ActionStyle

Bases: Enum

Controls the style of an Action, which influences how the action is displayed, spoken, etc.

Attributes:

Name Type Description
DEFAULT

Action is displayed as normal

POSITIVE

Action is displayed with a positive style (typically the button becomes accent color)

DESTRUCTIVE

Action is displayed with a destructive style (typically the button becomes red)

Source code in msadaptivecards/base.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
class ActionStyle(Enum):
    """
    Controls the style of an Action, which influences how the action is displayed, spoken, etc.

    Attributes:
        DEFAULT:
            Action is displayed as normal
        POSITIVE:
            Action is displayed with a positive style (typically the button becomes accent color)
        DESTRUCTIVE:
            Action is displayed with a destructive style (typically the button becomes red)
    """

    DEFAULT = "default"
    POSITIVE = "positive"
    DESTRUCTIVE = "destructive"

AssociatedInputs

Bases: Enum

Controls which inputs are associated with the submit action.

Attributes:

Name Type Description
AUTO

Inputs on the current card and any parent cards will be validated and submitted for this Action.

NONE

None of the inputs will be validated or submitted for this Action.

Source code in msadaptivecards/base.py
303
304
305
306
307
308
309
310
311
312
313
314
315
class AssociatedInputs(Enum):
    """
    Controls which inputs are associated with the submit action.

    Attributes:
        AUTO:
            Inputs on the current card and any parent cards will be validated and submitted for this Action.
        NONE:
            None of the inputs will be validated or submitted for this Action.
    """

    AUTO = "Auto"
    NONE = "None"

BackgroundImage

Bases: CamelModel

Specifies a background image. Acceptable formats are PNG, JPEG, and GIF

Other Parameters:

Name Type Description
url str

The URL (or data url) of the image. Acceptable formats are PNG, JPEG, and GIF

fill_mode ImageFillMode

Describes how the image should fill the area.

horizontal_alignment HorizontalAlignment

Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

vertical_alignment VerticalAlignment

Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

Source code in msadaptivecards/base.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
class BackgroundImage(CamelModel):
    """
    Specifies a background image. Acceptable formats are PNG, JPEG, and GIF

    Keyword Args:
        url (str):
            The URL (or data url) of the image. Acceptable formats are PNG, JPEG, and GIF
        fill_mode (ImageFillMode):
            Describes how the image should fill the area.
        horizontal_alignment (HorizontalAlignment):
            Describes how the image should be aligned if it must be cropped or if using repeat fill mode.
        vertical_alignment (VerticalAlignment):
            Describes how the image should be aligned if it must be cropped or if using repeat fill mode.
    """

    url: str = Field(..., description="The URL (or data url) of the image. Acceptable formats are PNG, JPEG, and GIF")
    fill_mode: ImageFillMode = Field(None, description="Describes how the image should fill the area.")
    horizontal_alignment: HorizontalAlignment = Field(
        None,
        description="Describes how the image should be aligned if it must be cropped or if using repeat fill mode.",
    )
    vertical_alignment: VerticalAlignment = Field(
        None,
        description="Describes how the image should be aligned if it must be cropped or if using repeat fill mode.",
    )

BaseContainers

Bases: CamelModel

Base model for all containers.

Other Parameters:

Name Type Description
fallback ElementModel

Describes what to do when an unknown element is encountered or the requires of this or any children can't be met. height (BlockElementHeight): Specifies the height of the element. separator (bool): When true, draw a separating line at the top of the element. spacing (Spacing): Controls the amount of spacing between this element and the preceding element. id (str): A unique identifier associated with the item. is_visible: If false, this item will be removed from the visual tree. requires (Dict[str, str]): A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.

Source code in msadaptivecards/base.py
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
class BaseContainers(CamelModel):
    """
    Base model for all containers.

    Keyword Args:
        fallback (ElementModel):
            Describes what to do when an unknown element is encountered or the requires of this or any children
            can't be met.
         height (BlockElementHeight):
            Specifies the height of the element.
         separator (bool):
            When true, draw a separating line at the top of the element.
         spacing (Spacing):
            Controls the amount of spacing between this element and the preceding element.
         id (str):
            A unique identifier associated with the item.
         is_visible:
            If false, this item will be removed from the visual tree.
         requires (Dict[str, str]):
            A series of key/value pairs indicating features that the item requires with corresponding minimum version.
            When a feature is missing or of insufficient version, fallback is triggered.
    """

    fallback: ElementModel = Field(
        None,
        description="Describes what to do when an unknown element is encountered or "
        "the requires of this or any children can't be met.",
    )
    height: BlockElementHeight = Field(None, description="Specifies the height of the element.")
    separator: bool = Field(None, description="When true, draw a separating line at the top of the element.")
    spacing: Spacing = Field(
        None, description="Controls the amount of spacing between this element and the preceding element."
    )
    id: str = Field(None, description="A unique identifier associated with the item.")
    is_visible: bool = Field(True, description="If false, this item will be removed from the visual tree.")
    requires: Dict[str, str] = Field(
        default_factory=dict,
        description="A series of key/value pairs indicating features that "
        "the item requires with corresponding minimum version. When a feature is missing or of insufficient version, "
        "fallback is triggered.",
    )

BlockElementHeight

Bases: Enum

Specifies the height of the element.

Attributes:

Name Type Description
AUTO

The height of the container will be determined by the height of its contents.

STRETCH

The container will stretch its height to the available remaining height of the parent container.

Source code in msadaptivecards/base.py
122
123
124
125
126
127
128
129
130
131
132
133
134
class BlockElementHeight(Enum):
    """
    Specifies the height of the element.

    Attributes:
        AUTO:
            The height of the container will be determined by the height of its contents.
        STRETCH:
            The container will stretch its height to the available remaining height of the parent container.
    """

    AUTO = "auto"
    STRETCH = "stretch"

CamelModel

Bases: BaseModel

Standard configuration for Pydantic BaseModel to generate camel cased json which is what adaptive cards uses.

Source code in msadaptivecards/base.py
14
15
16
17
18
19
20
21
class CamelModel(BaseModel):
    """
    Standard configuration for Pydantic BaseModel to generate camel cased json which is what adaptive cards uses.
    """

    class Config:
        alias_generator = _to_camel
        allow_population_by_field_name = True

Colors

Bases: Enum

Controls the color of TextBlock elements.

Attributes:

Name Type Description
DEFAULT

Default black

DARK

Black

LIGHT

Light green

ACCENT

Blue

GOOD

Green

WARNING

Orange

ATTENTION

Yellow

Source code in msadaptivecards/base.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
class Colors(Enum):
    """
    Controls the color of TextBlock elements.

    Attributes:
        DEFAULT:
            Default black
        DARK:
            Black
        LIGHT:
            Light green
        ACCENT:
            Blue
        GOOD:
            Green
        WARNING:
            Orange
        ATTENTION:
            Yellow
    """

    DEFAULT = "default"
    DARK = "dark"
    LIGHT = "light"
    ACCENT = "accent"
    GOOD = "good"
    WARNING = "warning"
    ATTENTION = "attention"

ElementModel

Bases: CamelModel

Base model for element types

Other Parameters:

Name Type Description
fallback ElementModel

Describes what to do when an unknown element is encountered or the requires of this or any children can't be met.

height BlockElementHeight

Specifies the height of the element.

separator bool

When true, draw a separating line at the top of the element.

spacing Spacing

Controls the amount of spacing between this element and the preceding element.

id str

A unique identifier associated with the item.

is_visible bool

If false, this item will be removed from the visual tree.

requires Dict[str, str]

A series of key/value pairs indicating features that the item requires with corresponding minimum version. When a feature is missing or of insufficient version, fallback is triggered.

Source code in msadaptivecards/base.py
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
class ElementModel(CamelModel):
    """
    Base model for element types

    Keyword Args:
        fallback (ElementModel):
            Describes what to do when an unknown element is encountered or the requires of this or any children
            can't be met.
        height (BlockElementHeight):
            Specifies the height of the element.
        separator (bool):
            When true, draw a separating line at the top of the element.
        spacing (Spacing):
            Controls the amount of spacing between this element and the preceding element.
        id (str):
            A unique identifier associated with the item.
        is_visible (bool):
            If false, this item will be removed from the visual tree.
        requires (Dict[str, str]):
            A series of key/value pairs indicating features that the item requires with corresponding minimum version.
            When a feature is missing or of insufficient version, fallback is triggered.

    """

    fallback: "ElementModel" = Field(
        None,
        description="Describes what to do when an unknown element is encountered or the requires of this or any "
        "children can't be met.",
    )
    height: BlockElementHeight = Field(None, description="Specifies the height of the element.")
    separator: bool = Field(None, description="When true, draw a separating line at the top of the element.")
    spacing: Spacing = Field(
        None, description="Controls the amount of spacing between this element and the preceding element."
    )
    id: str = Field(None, description="A unique identifier associated with the item.")
    is_visible: bool = Field(True, description="If false, this item will be removed from the visual tree.")
    requires: Dict[str, str] = Field(
        None,
        description="A series of key/value pairs indicating features that the item requires with corresponding "
        "minimum version. When a feature is missing or of insufficient version, fallback is triggered.",
    )

FontSize

Bases: Enum

Controls size of text.

Attributes:

Name Type Description
DEFAULT

Default size

SMALL

Small font size

MEDIUM

Medium font size

LARGE

Large font size

EXTRA_LARGE

Larger font size

Source code in msadaptivecards/base.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
class FontSize(Enum):
    """
    Controls size of text.

    Attributes:
        DEFAULT:
            Default size
        SMALL:
            Small font size
        MEDIUM:
            Medium font size
        LARGE:
            Large font size
        EXTRA_LARGE:
            Larger font size
    """

    DEFAULT = "default"
    SMALL = "small"
    MEDIUM = "medium"
    LARGE = "large"
    EXTRA_LARGE = "extraLarge"

FontType

Bases: Enum

Type of font to use for rendering.

Attributes:

Name Type Description
DEFAULT

Default font

MONOSPACE

Monospace font

Source code in msadaptivecards/base.py
197
198
199
200
201
202
203
204
205
206
207
208
209
class FontType(Enum):
    """
    Type of font to use for rendering.

    Attributes:
        DEFAULT:
            Default font
        MONOSPACE:
            Monospace font
    """

    DEFAULT = "default"
    MONOSPACE = "monospace"

FontWeight

Bases: Enum

Controls the weight of TextBlock elements.

Attributes:

Name Type Description
DEFAULT

Normal weight for the font

LIGHTER

Font has lighter lines

BOLDER

Bold font size

Source code in msadaptivecards/base.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
class FontWeight(Enum):
    """
    Controls the weight of TextBlock elements.

    Attributes:
        DEFAULT:
            Normal weight for the font
        LIGHTER:
            Font has lighter lines
        BOLDER:
            Bold font size
    """

    DEFAULT = "default"
    LIGHTER = "lighter"
    BOLDER = "bolder"

HorizontalAlignment

Bases: Enum

Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

See More: https://adaptivecards.io/explorer/BackgroundImage.html

Attributes:

Name Type Description
LEFT

Position to the left.

CENTER

Position in the center.

RIGHT

Position to the right.

Source code in msadaptivecards/base.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class HorizontalAlignment(Enum):
    """
    Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

    See More: https://adaptivecards.io/explorer/BackgroundImage.html

    Attributes:
        LEFT:
            Position to the left.
        CENTER:
            Position in the center.
        RIGHT:
            Position to the right.
    """

    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"

ImageFillMode

Bases: Enum

Describes how the image should fill the area. See More: https://adaptivecards.io/explorer/BackgroundImage.html

Attributes:

Name Type Description
COVER str

The background image covers the entire width of the container. Its aspect ratio is preserved. Content may be clipped if the aspect ratio of the image doesn't match the aspect ratio of the container. verticalAlignment is respected (horizontalAlignment is meaningless since it's stretched width). This is the default mode and is the equivalent to the current model.

REPEAT_HORIZONTALLY str

The background image isn't stretched. It is repeated in the x axis as many times as necessary to cover the container's width. verticalAlignment is honored (default is top), horizontalAlignment is ignored.

REPEAT_VERTICALLY str

The background image isn't stretched. It is repeated in the y axis as many times as necessary to cover the container's height. verticalAlignment is ignored, horizontalAlignment is honored (default is left).

REPEAT str

The background image isn't stretched. It is repeated first in the x axis then in the y axis as many times as necessary to cover the entire container. Both horizontalAlignment and verticalAlignment are honored (defaults are left and top).

Source code in msadaptivecards/base.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class ImageFillMode(Enum):
    """
    Describes how the image should fill the area.
    See More: https://adaptivecards.io/explorer/BackgroundImage.html

    Attributes:
        COVER (str):
            The background image covers the entire width of the container. Its aspect ratio is preserved.
            Content may be clipped if the aspect ratio of the image doesn't match the aspect ratio of the container.
            verticalAlignment is respected (horizontalAlignment is meaningless since it's stretched width). This is
            the default mode and is the equivalent to the current model.
        REPEAT_HORIZONTALLY (str):
            The background image isn't stretched. It is repeated in the x axis as many times as necessary to cover
            the container's width. verticalAlignment is honored (default is top), horizontalAlignment is ignored.
        REPEAT_VERTICALLY (str):
            The background image isn't stretched. It is repeated in the y axis as many times as necessary to cover the
            container's height. verticalAlignment is ignored, horizontalAlignment is honored (default is left).
        REPEAT (str):
            The background image isn't stretched. It is repeated first in the x axis then in the y axis as many times
            as necessary to cover the entire container. Both horizontalAlignment and verticalAlignment are
            honored (defaults are left and top).
    """

    COVER = "cover"
    REPEAT_HORIZONTALLY = "repeatHorizontally"
    REPEAT_VERTICALLY = "repeatVertically"
    REPEAT = "repeat"

SelectAction

Bases: ActionModel

Marker model for select actions.

Source code in msadaptivecards/base.py
449
450
451
452
453
454
class SelectAction(ActionModel):
    """
    Marker model for select actions.
    """

    pass

Spacing

Bases: Enum

Controls the amount of spacing between this element and the preceding element.

Attributes:

Name Type Description
DEFAULT

Default spacing

NONE

No spacing between elements

SMALL

Small spacing between elements

MEDIUM

Medium spacing between elements

LARGE

Large spacing between elements

EXTRA_LARGE

Extra large spacing between elements

PADDING

Add padding between elements

Source code in msadaptivecards/base.py
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class Spacing(Enum):
    """
    Controls the amount of spacing between this element and the preceding element.

    Attributes:
        DEFAULT:
            Default spacing
        NONE:
            No spacing between elements
        SMALL:
            Small spacing between elements
        MEDIUM:
            Medium spacing between elements
        LARGE:
            Large spacing between elements
        EXTRA_LARGE:
            Extra large spacing between elements
        PADDING:
            Add padding between elements
    """

    DEFAULT = "default"
    NONE = "none"
    SMALL = "small"
    MEDIUM = "medium"
    LARGE = "large"
    EXTRA_LARGE = "extraLarge"
    PADDING = "padding"

Style

Bases: Enum

Style hint for Container.

See More: https://adaptivecards.io/explorer/Container.html

Attributes:

Name Type Description
DEFAULT

Default style with

EMPHASIS

Emphasis the background color of the container

GOOD

'Good' background color, a green color type

ATTENTION

'Attention' color, orange/red color type

WARNING

'Warning' color, yellow/orange color type

ACCENT

'Accent' color, blue color type

Source code in msadaptivecards/base.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
class Style(Enum):
    """
    Style hint for Container.

    See More: https://adaptivecards.io/explorer/Container.html

    Attributes:
        DEFAULT:
            Default style with
        EMPHASIS:
            Emphasis the background color of the container
        GOOD:
            'Good' background color, a green color type
        ATTENTION:
            'Attention' color, orange/red color type
        WARNING:
            'Warning' color, yellow/orange color type
        ACCENT:
            'Accent' color, blue color type
    """

    DEFAULT = "default"
    EMPHASIS = "emphasis"
    GOOD = "good"
    ATTENTION = "attention"
    WARNING = "warning"
    ACCENT = "accent"

TextBlockStyle

Bases: Enum

The style of this TextBlock for accessibility purposes.

Attributes:

Name Type Description
DEFAULT

This is the default style which provide no special styling or behavior.

HEADING

The TextBlock is a heading. This will apply the heading styling defaults and mark the text block as a heading for accessibility.

Source code in msadaptivecards/base.py
254
255
256
257
258
259
260
261
262
263
264
265
266
267
class TextBlockStyle(Enum):
    """
    The style of this TextBlock for accessibility purposes.

    Attributes:
        DEFAULT:
            This is the default style which provide no special styling or behavior.
        HEADING:
            The TextBlock is a heading. This will apply the heading styling defaults and mark the text block as a
            heading for accessibility.
    """

    DEFAULT = "default"
    HEADING = "heading"

VerticalAlignment

Bases: Enum

Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

See More: https://adaptivecards.io/explorer/BackgroundImage.html

Attributes:

Name Type Description
TOP

Position to the top.

CENTER

Position in the center.

BOTTOM

Position to the bottom.

Source code in msadaptivecards/base.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class VerticalAlignment(Enum):
    """
    Describes how the image should be aligned if it must be cropped or if using repeat fill mode.

    See More: https://adaptivecards.io/explorer/BackgroundImage.html

    Attributes:
        TOP:
            Position to the top.
        CENTER:
            Position in the center.
        BOTTOM:
            Position to the bottom.
    """

    TOP = "top"
    CENTER = "center"
    BOTTOM = "bottom"

Last update: 2022-08-16